mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-12 17:08:34 +01:00
More Home progress:
- Add support for calendar favorites. Note only the list view can be dragged, others are context menu only
This commit is contained in:
parent
8c5ea8eba9
commit
57f5569fc4
@ -36,7 +36,6 @@ class addressbook_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
$this->context['sel_options']['tid'][$tid] = $data['name'];
|
||||
}
|
||||
error_log(array2string($this->nm_settings['col_filter']));
|
||||
$this->nm_settings += array(
|
||||
'get_rows' => 'addressbook_favorite_portlet::get_rows',
|
||||
// Use a different template so it can be accessed from client side
|
||||
|
180
calendar/inc/class.calendar_favorite_portlet.inc.php
Normal file
180
calendar/inc/class.calendar_favorite_portlet.inc.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Egroupware - Addressbook - A portlet for displaying a list of entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package addressbook
|
||||
* @subpackage home
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* The addressbook_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
*/
|
||||
class calendar_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct the portlet
|
||||
* Calendar complicates things...
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'calendar';
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
if($this->favorite['state']['view'] == 'listview')
|
||||
{
|
||||
$ui = new calendar_uilist();
|
||||
$this->context['template'] = 'calendar.list.rows';
|
||||
$this->context['sel_options'] = array();
|
||||
foreach($ui->content_types as $tid => $data)
|
||||
{
|
||||
$this->context['sel_options']['tid'][$tid] = $data['name'];
|
||||
}
|
||||
$this->nm_settings += array(
|
||||
'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options)
|
||||
'no_filter2' => True, // I disable the 2. filter (params are the same as for filter)
|
||||
'no_cat' => True, // I disable the cat-selectbox
|
||||
'filter' => 'after',
|
||||
'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
|
||||
'row_modified' => 'modified',
|
||||
'get_rows' => 'calendar_favorite_portlet::get_rows',
|
||||
// Use a different template so it can be accessed from client side
|
||||
'template' => 'calendar.list.rows'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
{
|
||||
|
||||
// Always load app's css
|
||||
egw_framework::includeCSS('calendar','app');
|
||||
|
||||
if($this->favorite['state']['view'] == 'listview' || !$this->favorite['state']['view'])
|
||||
{
|
||||
$ui = new calendar_uilist();
|
||||
}
|
||||
else
|
||||
{
|
||||
$ui = new calendar_uiviews();
|
||||
$etemplate->read('home.legacy');
|
||||
|
||||
$etemplate->set_dom_id($id);
|
||||
// Always load app's javascript, so most actions have a chance of working
|
||||
egw_framework::validate_file('','app',$this->context['appname']);
|
||||
}
|
||||
|
||||
switch($this->favorite['state']['view'])
|
||||
{
|
||||
case 'listview':
|
||||
default:
|
||||
$ui = new calendar_uilist();
|
||||
|
||||
|
||||
$this->context['sel_options']['filter'] = &$ui->date_filters;
|
||||
$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
|
||||
|
||||
// Early exit
|
||||
return parent::exec($id, $etemplate);
|
||||
|
||||
break;
|
||||
|
||||
case 'planner_user':
|
||||
case 'planner_cat':
|
||||
case 'planner':
|
||||
$content = array('legacy' => $ui->planner(true));
|
||||
break;
|
||||
case 'year':
|
||||
$content = array('legacy' => $ui->year(true));
|
||||
break;
|
||||
case 'month':
|
||||
$content = array('legacy' => $ui->month(0,true));
|
||||
break;
|
||||
case 'weekN':
|
||||
$content = array('legacy' => $ui->weekN(true));
|
||||
break;
|
||||
case 'week':
|
||||
$content = array('legacy' => $ui->week(0,true));
|
||||
break;
|
||||
case 'day':
|
||||
$content = array('legacy' => $ui->day(true));
|
||||
break;
|
||||
case 'day4':
|
||||
$content = array('legacy' => $ui->week(4,true));
|
||||
break;
|
||||
}
|
||||
|
||||
$etemplate->exec(get_called_class() .'::process',$content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override from calendar list to clear the app header
|
||||
*
|
||||
* @param type $query
|
||||
* @param type $rows
|
||||
* @param type $readonlys
|
||||
* @return integer Total rows found
|
||||
*/
|
||||
public static function get_rows(&$query, &$rows, &$readonlys)
|
||||
{
|
||||
$ui = new calendar_uilist();
|
||||
$total = $ui->get_rows($query, $rows, $readonlys);
|
||||
unset($GLOBALS['egw_info']['flags']['app_header']);
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Here we need to handle any incoming data. Setup is done in the constructor,
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
*/
|
||||
public static function process($values = array())
|
||||
{
|
||||
parent::process($values);
|
||||
$ui = new calendar_uilist();
|
||||
if (is_array($values) && !empty($values['nm']['action']))
|
||||
{
|
||||
if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
|
||||
{
|
||||
egw_framework::message(lang('You need to select some entries first'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = $failed = $action_msg = null;
|
||||
if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
|
||||
$success,$failed,$action_msg,'calendar_list',$msg, $content['nm']['checkboxes']['no_notifications']))
|
||||
{
|
||||
$msg .= lang('%1 event(s) %2',$success,$action_msg);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($values['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'calendar::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get addressbook tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
}
|
||||
elseif(is_null($msg))
|
||||
{
|
||||
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
elseif($msg)
|
||||
{
|
||||
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
unset($values['nm']['action']);
|
||||
unset($values['nm']['select_all']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -815,7 +815,7 @@ class calendar_uilist extends calendar_ui
|
||||
*
|
||||
* @return array see nextmatch_widget::get_actions()
|
||||
*/
|
||||
private function get_actions()
|
||||
public function get_actions()
|
||||
{
|
||||
$actions = array(
|
||||
'add' => array(
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="home.list" template="" lang="" group="0" version="1.9.001">
|
||||
<template id="home.legacy" template="" lang="" group="0" version="1.9.001">
|
||||
<html id="legacy"/>
|
||||
</template>
|
||||
</overlay>
|
||||
|
Loading…
Reference in New Issue
Block a user