2004-08-01 17:36:04 +02:00
|
|
|
<?php
|
2007-03-09 12:26:22 +01:00
|
|
|
/**
|
2016-05-01 19:47:59 +02:00
|
|
|
* EGroupware - Calendar's views and widgets
|
2007-03-09 12:26:22 +01:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package calendar
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2016-05-01 19:47:59 +02:00
|
|
|
* @copyright (c) 2004-16 by RalfBecker-At-outdoor-training.de
|
2007-03-09 12:26:22 +01:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
use EGroupware\Api\Link;
|
|
|
|
use EGroupware\Api\Framework;
|
|
|
|
use EGroupware\Api\Egw;
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Class to generate the calendar views and the necesary widgets
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2010-01-17 03:03:11 +01:00
|
|
|
* The listview is in a separate class calendar_uilist!
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2007-03-09 12:26:22 +01:00
|
|
|
* The new UI, BO and SO classes have a strikt definition, in which time-zone they operate:
|
|
|
|
* UI only operates in user-time, so there have to be no conversation at all !!!
|
|
|
|
* BO's functions take and return user-time only (!), they convert internaly everything to servertime, because
|
|
|
|
* SO operates only on server-time
|
|
|
|
*
|
|
|
|
* The state of the UI elements is managed in the uical class, which all UI classes extend.
|
|
|
|
*
|
2010-01-17 03:03:11 +01:00
|
|
|
* All permanent debug messages of the calendar-code should done via the debug-message method of the calendar_bo class !!!
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2008-06-07 19:45:33 +02:00
|
|
|
class calendar_uiviews extends calendar_ui
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
var $public_functions = array(
|
2008-06-07 19:45:33 +02:00
|
|
|
'index' => True,
|
2004-08-01 17:36:04 +02:00
|
|
|
);
|
2006-06-02 21:38:08 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* integer level or string function- or widget-name
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var mixed
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
var $debug=false;
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* extra rows above and below the workday
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2006-10-17 22:01:08 +02:00
|
|
|
var $extraRows = 2;
|
|
|
|
|
2010-12-09 22:04:34 +01:00
|
|
|
/**
|
|
|
|
* removes n extra rows below the workday
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
var $remBotExtraRows = 0;
|
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
/**
|
|
|
|
* extra rows original (save original value even if it gets changed in the class)
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2006-10-17 22:01:08 +02:00
|
|
|
*/
|
|
|
|
var $extraRowsOriginal;
|
2004-08-01 17:36:04 +02:00
|
|
|
|
|
|
|
var $timeRow_width = 40;
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* how many rows per day get displayed, gets set by the timeGridWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
var $rowsToDisplay;
|
|
|
|
|
|
|
|
/**
|
2010-07-31 09:51:52 +02:00
|
|
|
* height in percent of one row, gets set by the timeGridWidget
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2006-05-14 18:50:20 +02:00
|
|
|
var $rowHeight;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* standard params for calling bocal::search for all views, set by the constructor
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var array
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
var $search_params;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-05-31 02:33:27 +02:00
|
|
|
/**
|
2006-06-02 21:38:08 +02:00
|
|
|
* should we use a time grid, can be set for week- and month-view to false by the cal_pref no_time_grid
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var boolean
|
2006-05-31 02:33:27 +02:00
|
|
|
*/
|
|
|
|
var $use_time_grid=true;
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2014-11-26 14:30:13 +01:00
|
|
|
/**
|
|
|
|
* Pref value of use_time_grid preference
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $use_time_grid_pref = '';
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2006-06-02 21:38:08 +02:00
|
|
|
/**
|
|
|
|
* Can we display the whole day in a timeGrid of the size of the workday and just scroll to workday start
|
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var boolean
|
2006-06-02 21:38:08 +02:00
|
|
|
*/
|
|
|
|
var $scroll_to_wdstart=false;
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-10-17 22:01:08 +02:00
|
|
|
/**
|
|
|
|
* counter for the current whole day event of a single day
|
|
|
|
*
|
2006-12-29 08:57:47 +01:00
|
|
|
* @var int
|
2006-10-17 22:01:08 +02:00
|
|
|
*/
|
|
|
|
var $wholeDayPosCounter=1;
|
2006-05-31 02:33:27 +02:00
|
|
|
|
2009-08-03 11:51:35 +02:00
|
|
|
/**
|
|
|
|
* Switch to disable private data and possibility to view and edit events
|
|
|
|
* in case of a public view (sitemgr)
|
|
|
|
*/
|
|
|
|
var $allowEdit = true;
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2008-06-07 19:45:33 +02:00
|
|
|
function __construct($set_states=null)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2008-06-07 19:45:33 +02:00
|
|
|
parent::__construct(false,$set_states); // call the parent's constructor
|
2006-10-17 22:01:08 +02:00
|
|
|
$this->extraRowsOriginal = $this->extraRows; //save original extraRows value
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['nonavbar'] = False;
|
2016-01-26 15:47:05 +01:00
|
|
|
|
2015-10-09 21:48:28 +02:00
|
|
|
// Check for GET message (from merge)
|
|
|
|
if($_GET['msg'])
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
Framework::message($_GET['msg']);
|
2015-10-09 21:48:28 +02:00
|
|
|
unset($_GET['msg']);
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
// standard params for calling bocal::search for all views
|
2010-02-02 12:35:13 +01:00
|
|
|
$this->owner = str_replace('%2C',',',$this->owner);
|
2004-08-01 17:36:04 +02:00
|
|
|
$this->search_params = array(
|
|
|
|
'start' => $this->date,
|
2012-02-07 15:10:34 +01:00
|
|
|
'cat_id' => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0,
|
2006-03-03 19:51:46 +01:00
|
|
|
'users' => explode(',',$this->owner),
|
2017-06-12 20:35:12 +02:00
|
|
|
'owner' => explode(',',$this->owner),
|
2004-08-01 17:36:04 +02:00
|
|
|
'filter' => $this->filter,
|
|
|
|
'daywise' => True,
|
2015-01-19 20:32:26 +01:00
|
|
|
'use_so_events' => $this->test === 'true',
|
2004-08-01 17:36:04 +02:00
|
|
|
);
|
2016-05-04 19:15:18 +02:00
|
|
|
// $this->holidays = $this->bo->read_holidays($this->year);
|
2013-01-31 15:16:48 +01:00
|
|
|
|
2006-03-03 19:51:46 +01:00
|
|
|
$this->check_owners_access();
|
2015-01-19 20:32:26 +01:00
|
|
|
|
2014-11-26 14:30:13 +01:00
|
|
|
//ATM: Forces use_time_grid preference to use all views by ignoring the preference value
|
|
|
|
//@TODO: the whole use_time_grid preference should be removed (including dependent vars)
|
|
|
|
// after we decided that is not neccessary to have it at all
|
|
|
|
$this->use_time_grid_pref = 'all'; //$this->cal_prefs['use_time_grid'];
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2011-01-05 22:49:55 +01:00
|
|
|
/**
|
|
|
|
* Calculate iso8601 week-number, which is defined for Monday as first day of week only
|
|
|
|
*
|
2011-01-05 23:26:34 +01:00
|
|
|
* We addjust the day, if user prefs want a different week-start-day
|
|
|
|
*
|
|
|
|
* @param int|string|DateTime $time
|
2011-01-05 22:49:55 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2011-01-05 23:26:34 +01:00
|
|
|
public function week_number($time)
|
2011-01-05 22:49:55 +01:00
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
if (!is_a($time,'DateTime')) $time = new Api\DateTime($time);
|
2011-01-05 23:26:34 +01:00
|
|
|
|
|
|
|
// if week does not start Monday and $time is Sunday --> add one day
|
|
|
|
if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
|
|
|
|
{
|
|
|
|
$time->modify('+1day');
|
|
|
|
}
|
|
|
|
// if week does start Saturday and $time is Saturday --> add two days
|
|
|
|
elseif ($this->cal_prefs['weekdaystarts'] == 'Saturday' && $wday == 6)
|
2011-01-05 22:49:55 +01:00
|
|
|
{
|
2011-01-05 23:26:34 +01:00
|
|
|
$time->modify('+2days');
|
2011-01-05 22:49:55 +01:00
|
|
|
}
|
|
|
|
return $time->format('W');
|
|
|
|
}
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2016-03-14 20:36:22 +01:00
|
|
|
* Load all views used by calendar, client side switches between them as needed
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2015-07-01 00:26:59 +02:00
|
|
|
function index($content=array())
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2015-06-25 19:44:28 +02:00
|
|
|
if($content['merge'])
|
|
|
|
{
|
|
|
|
// View from sidebox is JSON encoded
|
|
|
|
$this->manage_states(array_merge($content,json_decode($content['view'],true)));
|
|
|
|
if($content['first'])
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
$this->first = Api\DateTime::to($content['first'],'ts');
|
2015-06-25 19:44:28 +02:00
|
|
|
}
|
|
|
|
if($content['last'])
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
$this->last = Api\DateTime::to($content['last'],'ts');
|
2015-06-25 19:44:28 +02:00
|
|
|
}
|
|
|
|
$_GET['merge'] = $content['merge'];
|
|
|
|
$this->merge();
|
|
|
|
return;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
// handle views in other files
|
2015-06-10 23:51:28 +02:00
|
|
|
if (!isset($this->public_functions[$this->view]) && $this->view !== 'listview')
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2015-06-15 23:38:03 +02:00
|
|
|
$this->view = 'week';
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
// get manual to load the right page
|
|
|
|
$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view));
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
// Sidebox & iframe for old views
|
2015-08-12 00:30:50 +02:00
|
|
|
if(in_array($this->view,array('year')) && $_GET['view'])
|
2015-06-10 23:51:28 +02:00
|
|
|
{
|
2015-06-15 23:38:03 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['nonavbar'] = true;
|
|
|
|
$this->manage_states($_GET);
|
2016-05-01 19:47:59 +02:00
|
|
|
$this->{$this->view}();
|
2015-06-15 23:38:03 +02:00
|
|
|
return;
|
2015-06-10 23:51:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-06 19:24:45 +01:00
|
|
|
// Toolbar
|
2016-05-01 19:47:59 +02:00
|
|
|
$tmpl = new Etemplate('calendar.toolbar');
|
2016-01-06 19:24:45 +01:00
|
|
|
$tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content));
|
2016-02-10 18:03:42 +01:00
|
|
|
// Adjust toolbar for mobile
|
2016-05-01 19:47:59 +02:00
|
|
|
if(Api\Header\UserAgent::mobile()){
|
2016-02-10 18:03:42 +01:00
|
|
|
$tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar');
|
|
|
|
$tmpl->setElementAttribute('toolbar','view_range', '3');
|
|
|
|
}
|
2016-01-06 19:24:45 +01:00
|
|
|
$tmpl->exec('calendar_uiviews::index',array());
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
// Load the different views once, we'll switch between them on the client side
|
2016-05-01 19:47:59 +02:00
|
|
|
$todo = new Etemplate('calendar.todo');
|
2015-06-10 23:51:28 +02:00
|
|
|
$label = '';
|
2016-09-28 14:20:16 +02:00
|
|
|
$todo->exec('calendar_uiviews::index',array('todos'=>'', 'label' => $label));
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
// Actually, this takes care of most of it...
|
|
|
|
$this->week();
|
2015-07-03 11:10:01 +02:00
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
$planner = new Etemplate('calendar.planner');
|
2015-06-25 19:44:28 +02:00
|
|
|
// Get the actions
|
2016-05-01 19:47:59 +02:00
|
|
|
$planner->setElementAttribute('planner','actions',$this->get_actions());
|
|
|
|
$planner->exec('calendar_uiviews::index',array());
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
// List view in a separate file
|
|
|
|
$list_ui = new calendar_uilist();
|
|
|
|
$list_ui->listview();
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2016-01-06 19:24:45 +01:00
|
|
|
/**
|
|
|
|
* Generate the calendar toolbar actions
|
|
|
|
*/
|
2016-05-01 19:47:59 +02:00
|
|
|
protected function getToolbarActions()
|
2016-01-06 19:24:45 +01:00
|
|
|
{
|
|
|
|
$group = 0;
|
|
|
|
$actions = array(
|
|
|
|
'add' => array(
|
|
|
|
'caption' => 'Add',
|
2016-01-21 19:41:54 +01:00
|
|
|
'icon' => 'add',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => ++$group,
|
2016-01-06 21:37:29 +01:00
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
2016-01-06 19:24:45 +01:00
|
|
|
'hint' => 'Add',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
|
|
|
'day_view' => array(
|
2016-06-20 16:05:27 +02:00
|
|
|
'caption' => 'Dayview',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => '1_day_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => ++$group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
2016-06-20 16:05:27 +02:00
|
|
|
'hint' => 'Dayview',
|
2016-01-06 19:24:45 +01:00
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'day'))
|
|
|
|
),
|
|
|
|
'4day_view' => array(
|
|
|
|
'caption' => 'Four days view',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => '4_day_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Four days view',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'day4'))
|
|
|
|
),
|
|
|
|
'week_view' => array(
|
2016-06-20 16:05:27 +02:00
|
|
|
'caption' => 'Weekview',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'week_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
2016-06-20 16:05:27 +02:00
|
|
|
'hint' => 'Weekview',
|
2016-01-06 19:24:45 +01:00
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'week'))
|
|
|
|
),
|
|
|
|
'weekN_view' => array(
|
|
|
|
'caption' => 'Multiple week view',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'multiweek_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Multiple week view',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'weekN'))
|
|
|
|
),
|
|
|
|
'month_view' => array(
|
2016-06-20 16:05:27 +02:00
|
|
|
'caption' => 'Monthview',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'month_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
2016-06-20 16:05:27 +02:00
|
|
|
'hint' => 'Monthview',
|
2016-01-06 19:24:45 +01:00
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'month'))
|
|
|
|
),
|
|
|
|
'planner_category' => array(
|
|
|
|
'caption' => 'Planner by category',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'planner_category_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Planner by category',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'category')),
|
|
|
|
),
|
|
|
|
'planner_user' => array(
|
|
|
|
'caption' => 'Planner by user',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'planner_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Planner by user',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'user')),
|
|
|
|
),
|
|
|
|
'planner_month' => array(
|
|
|
|
'caption' => 'Yearly planner',
|
2019-09-13 17:50:13 +02:00
|
|
|
'icon' => 'year_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Yearly planner',
|
|
|
|
'toolbarDefault' => false,
|
|
|
|
'data' => array('state' => array('view' => 'planner', 'sortby' => 'month')),
|
|
|
|
),
|
|
|
|
'list' => array(
|
|
|
|
'caption' => 'Listview',
|
|
|
|
'icon' => 'list',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Listview',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
'data' => array('state' => array('view' => 'listview')),
|
|
|
|
),
|
|
|
|
'weekend' => array(
|
|
|
|
'caption' => 'Weekend',
|
2019-09-25 11:17:44 +02:00
|
|
|
'icon' => '7_day_view',
|
2016-01-06 19:24:45 +01:00
|
|
|
'checkbox' => true,
|
|
|
|
'checked' => $this->cal_prefs['saved_states']['weekend'],
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Toggle weekend',
|
|
|
|
'toolbarDefault' => false,
|
2016-01-09 01:54:27 +01:00
|
|
|
'data' => array('toggle_off' => '5', 'toggle_on' => '7')
|
2016-01-06 19:24:45 +01:00
|
|
|
),
|
|
|
|
'previous' => array(
|
|
|
|
'caption' => 'Previous',
|
|
|
|
'icon' => 'previous',
|
|
|
|
'group' => ++$group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Previous',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
2016-01-21 19:41:54 +01:00
|
|
|
'today' => array(
|
|
|
|
'caption' => 'Today',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Today',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
2016-01-06 19:24:45 +01:00
|
|
|
'next' => array(
|
|
|
|
'caption' => 'Next',
|
|
|
|
'icon' => 'next',
|
|
|
|
'group' => $group,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_action',
|
|
|
|
'hint' => 'Next',
|
|
|
|
'toolbarDefault' => true,
|
|
|
|
),
|
|
|
|
);
|
2021-03-03 16:55:51 +01:00
|
|
|
|
|
|
|
// Add integrated app options
|
|
|
|
$integration_data = Api\Hooks::process(array('location' => 'calendar_search_union'));
|
|
|
|
foreach($integration_data as $app => $app_hooks)
|
|
|
|
{
|
|
|
|
foreach ($app_hooks as $data)
|
|
|
|
{
|
|
|
|
// App might have multiple hooks, let it specify something else
|
|
|
|
$app = $data['selects']['app'] ?: $app;
|
|
|
|
|
|
|
|
// Don't add if no access or app already added
|
|
|
|
if (!array_key_exists($app, $GLOBALS['egw_info']['user']['apps']) || array_key_exists($app, $actions['integration']['children']))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Don't show infolog if there are no configured types
|
|
|
|
if($app == 'infolog' && empty($GLOBALS['egw_info']['user']['preferences']['infolog']['calendar_integration']))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$img = self::integration_get_icons($app, null, [])[0];
|
|
|
|
preg_match('/<img src=\"(.*?)\".*\/>/', $img, $results);
|
|
|
|
$actions['integration_'.$app] = array(
|
|
|
|
'caption' => $app,
|
|
|
|
'iconUrl' => $results[1] ?: "$app\navbar",
|
|
|
|
'checkbox' => true,
|
|
|
|
'hint' => lang("show %1 from %2",lang(Link::get_registry($app,'entries') ?: 'entries'),lang(Link::get_registry($app,'name'))),
|
|
|
|
'group' => 'integration',
|
|
|
|
'onExecute' => 'javaScript:app.calendar.toolbar_integration_action',
|
|
|
|
'checked' => in_array($app,$this->cal_prefs['integration_toggle']),
|
|
|
|
'data' => array('toggle_off' => '0', 'toggle_on' => '1')
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2016-05-01 19:47:59 +02:00
|
|
|
if (Api\Header\UserAgent::mobile())
|
2016-03-29 12:33:10 +02:00
|
|
|
{
|
|
|
|
foreach (array_keys($actions) as $key)
|
|
|
|
{
|
2016-04-26 14:35:09 +02:00
|
|
|
if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) {
|
2016-03-29 12:33:10 +02:00
|
|
|
$actions[$key]['toolbarDefault'] = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$actions[$key]['toolbarDefault'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$actions['weekend']['data'] = array('toggle_off' => '7', 'toggle_on' => '5');
|
|
|
|
unset($actions['pgp']);
|
|
|
|
}
|
2016-01-06 19:24:45 +01:00
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
|
|
|
* Displays the planner view
|
|
|
|
*
|
2016-05-04 21:07:54 +02:00
|
|
|
* @param boolean|Etemplate $home = false if etemplate return content suitable for home-page
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2015-08-05 23:24:07 +02:00
|
|
|
function &planner($content = array(), $home=false)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2010-01-15 04:53:12 +01:00
|
|
|
if ($this->sortby == 'month') // yearly planner with month rows
|
|
|
|
{
|
|
|
|
$this->first = $this->bo->date2array($this->date);
|
|
|
|
$this->first['day'] = 1;
|
|
|
|
unset($this->first['raw']);
|
|
|
|
$this->last = $this->first;
|
|
|
|
$this->last['year']++;
|
|
|
|
$this->last = $this->bo->date2ts($this->last)-1;
|
|
|
|
}
|
2016-02-03 19:27:52 +01:00
|
|
|
elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
|
|
|
if ($this->day < 15) // show one complete month
|
|
|
|
{
|
|
|
|
$this->_week_align_month($this->first,$this->last);
|
|
|
|
}
|
|
|
|
else // show 2 half month
|
|
|
|
{
|
|
|
|
$this->_week_align_month($this->first,$this->last,15);
|
|
|
|
}
|
|
|
|
}
|
2016-02-03 19:27:52 +01:00
|
|
|
elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-05-02 22:22:47 +02:00
|
|
|
$start = new Api\DateTime($this->date);
|
|
|
|
$start->setWeekstart();
|
|
|
|
$this->first = $start->format('ts');
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->last = $this->bo->date2array($this->first);
|
2016-02-03 19:27:52 +01:00
|
|
|
$this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
|
|
|
unset($this->last['raw']);
|
|
|
|
$this->last = $this->bo->date2ts($this->last);
|
|
|
|
}
|
|
|
|
else // dayview
|
|
|
|
{
|
|
|
|
$this->first = $this->bo->date2ts($this->date);
|
|
|
|
$this->last = $this->bo->date2array($this->first);
|
2016-02-03 19:27:52 +01:00
|
|
|
$this->last['day'] += 0;
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
|
|
|
unset($this->last['raw']);
|
|
|
|
$this->last = $this->bo->date2ts($this->last);
|
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2011-02-15 21:35:46 +01:00
|
|
|
$merge = $this->merge();
|
2011-06-22 17:34:00 +02:00
|
|
|
if($merge)
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
Egw::redirect_link('/index.php',array(
|
2011-06-22 17:34:00 +02:00
|
|
|
'menuaction' => 'calendar.calendar_uiviews.index',
|
|
|
|
'msg' => $merge,
|
2017-10-05 19:20:21 +02:00
|
|
|
'ajax' => 'true'
|
2011-06-22 17:34:00 +02:00
|
|
|
));
|
|
|
|
}
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
$search_params = $this->search_params;
|
|
|
|
$search_params['daywise'] = false;
|
|
|
|
$search_params['start'] = $this->first;
|
|
|
|
$search_params['end'] = $this->last;
|
2005-11-23 15:21:20 +01:00
|
|
|
$search_params['enum_groups'] = $this->sortby == 'user';
|
2015-08-05 23:24:07 +02:00
|
|
|
$content['planner'] = $this->bo->search($search_params);
|
|
|
|
foreach($content['planner'] as &$event)
|
|
|
|
{
|
|
|
|
$this->to_client($event);
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
|
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
$tmpl = $home ? $home : new Etemplate('calendar.planner');
|
2010-04-15 20:23:02 +02:00
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
$tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($this->first, Api\DateTime::ET2));
|
|
|
|
$tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($this->last, Api\DateTime::ET2));
|
2016-02-23 22:47:33 +01:00
|
|
|
$tmpl->setElementAttribute('planner','owner', $search_params['users']);
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl->setElementAttribute('planner','group_by', $this->sortby);
|
|
|
|
// Get the actions
|
|
|
|
$tmpl->setElementAttribute('planner','actions',$this->get_actions());
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-08-05 23:24:07 +02:00
|
|
|
$tmpl->exec(__METHOD__, $content);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Displays the monthview or a multiple week-view
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* Used for home app
|
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown
|
2016-02-22 23:45:48 +01:00
|
|
|
* @param boolean|etemplate2 $home = false if not false return content suitable for home-page
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
function &month($weeks=0,$home=false)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
|
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
if (!$home)
|
|
|
|
{
|
|
|
|
trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED);
|
|
|
|
return;
|
|
|
|
}
|
2014-10-20 11:14:24 +02:00
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
$this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views
|
|
|
|
$granularity = 0;
|
2011-02-15 21:35:46 +01:00
|
|
|
if($weeks)
|
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
|
|
|
|
|
|
|
|
$list = $this->cal_prefs['use_time_grid'];
|
|
|
|
if(!is_array($list))
|
2011-02-15 21:35:46 +01:00
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$list = explode(',',$list);
|
|
|
|
}
|
|
|
|
if(is_array($list))
|
|
|
|
{
|
|
|
|
$granularity = in_array('weekN',$list) ? 0 : $granularity;
|
2011-02-15 21:35:46 +01:00
|
|
|
}
|
2011-06-22 17:34:00 +02:00
|
|
|
}
|
2016-02-22 23:45:48 +01:00
|
|
|
$content = array('view' => array());
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
if ($weeks)
|
|
|
|
{
|
2016-05-02 22:22:47 +02:00
|
|
|
$start = new Api\DateTime($this->date);
|
|
|
|
$start->setWeekstart();
|
|
|
|
$this->first = $start->format('ts');
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->last = strtotime("+$weeks weeks",$this->first) - 1;
|
2014-02-25 10:41:08 +01:00
|
|
|
$weekNavH = "$weeks weeks";
|
2015-02-18 09:46:43 +01:00
|
|
|
$navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '.
|
|
|
|
$this->bo->long_date($this->first,$this->last);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$this->_week_align_month($this->first,$this->last);
|
2014-02-25 10:41:08 +01:00
|
|
|
$weekNavH = "1 month";
|
2015-02-18 09:46:43 +01:00
|
|
|
$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
|
2004-08-01 17:36:04 +02:00
|
|
|
|
2016-05-01 19:47:59 +02:00
|
|
|
// Loop through, using Api\DateTime to handle DST
|
2016-02-22 23:45:48 +01:00
|
|
|
$week = 0;
|
2016-03-18 16:49:11 +01:00
|
|
|
$week_start = new EGroupware\Api\DateTime($this->first);
|
2016-02-22 23:45:48 +01:00
|
|
|
$week_start->setTime(0,0,0);
|
2016-05-01 19:47:59 +02:00
|
|
|
$week_end = new Api\DateTime($week_start);
|
2016-02-22 23:45:48 +01:00
|
|
|
$week_end->add(new DateInterval('P6DT23H59M59S'));
|
2016-03-18 16:49:11 +01:00
|
|
|
$last = new EGroupware\Api\DateTime($this->last);
|
2016-02-22 23:45:48 +01:00
|
|
|
for ($week_start; $week_start < $last; $week_start->add('1 week'), $week_end->add('1 week'))
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-02-22 23:45:48 +01:00
|
|
|
$search_params = $this->search_params;
|
|
|
|
$search_params['start'] = $week_start->format('ts');
|
|
|
|
$search_params['end'] = $week_end->format('ts');
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2016-02-23 22:29:13 +01:00
|
|
|
$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
|
|
|
|
array(
|
|
|
|
'id' => $week_start->format('Ymd')
|
|
|
|
);
|
2016-02-22 23:45:48 +01:00
|
|
|
$home->setElementAttribute("view[$week]",'onchange',false);
|
|
|
|
$home->setElementAttribute("view[$week]",'granularity',$granularity);
|
|
|
|
$home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']);
|
|
|
|
$week++;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-02-23 22:29:13 +01:00
|
|
|
|
|
|
|
// Get the actions
|
|
|
|
$home->setElementAttribute('view','actions',$this->get_actions());
|
2016-03-06 15:58:36 +01:00
|
|
|
|
2016-02-22 23:45:48 +01:00
|
|
|
$home->exec(__METHOD__, $content);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get start and end of a month aligned to full weeks
|
|
|
|
*
|
|
|
|
* @param int &$first timestamp 0h of first day of week containing the first of the current month
|
|
|
|
* @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
|
|
|
function _week_align_month(&$first,&$last,$day=1)
|
|
|
|
{
|
2016-05-02 22:22:47 +02:00
|
|
|
$start = new Api\DateTime($this->date);
|
|
|
|
$start->setDate($this->year,$this->month,$this->day=$day);
|
|
|
|
$start->setWeekstart();
|
|
|
|
$first = $start->format('ts');
|
|
|
|
$start->setDate($this->year,$this->month+1,$day);
|
|
|
|
if ($day == 1) $start->add('-1day');
|
|
|
|
$start->setWeekstart();
|
2005-11-09 00:15:14 +01:00
|
|
|
// now we need to calculate the end of the last day of that week
|
|
|
|
// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
|
2016-05-02 22:22:47 +02:00
|
|
|
$arr = $start->format('array');
|
2016-05-01 19:47:59 +02:00
|
|
|
$arr['day'] += 6;
|
|
|
|
$arr['hour'] = 23;
|
|
|
|
$arr['min'] = $arr['sec'] = 59;
|
|
|
|
unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it
|
|
|
|
$last = $this->bo->date2ts($arr);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Displays the weekview, with 5 or 7 days
|
2004-08-31 11:40:09 +02:00
|
|
|
*
|
2014-11-05 17:13:26 +01:00
|
|
|
* @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used
|
2016-02-22 23:45:48 +01:00
|
|
|
* @param boolean|etemplate2 $home = false if not false return content suitable for home-page
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2005-11-09 00:15:14 +01:00
|
|
|
function week($days=0,$home=false)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if (!$days)
|
|
|
|
{
|
|
|
|
$days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview'];
|
|
|
|
if ($days != 5) $days = 7;
|
|
|
|
if ($days != $this->cal_prefs['days_in_weekview']) // save the preference
|
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
|
|
|
|
$GLOBALS['egw']->preferences->save_repository();
|
2004-08-01 17:36:04 +02:00
|
|
|
$this->cal_prefs['days_in_weekview'] = $days;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
|
|
|
|
|
2016-01-27 18:48:33 +01:00
|
|
|
if ($days <= 4) // next 4 days view
|
2006-06-02 21:38:08 +02:00
|
|
|
{
|
|
|
|
$wd_start = $this->first = $this->bo->date2ts($this->date);
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->last = strtotime("+$days days",$this->first) - 1;
|
2016-02-22 23:45:48 +01:00
|
|
|
$view = $days == 1 ? 'day' : 'day4';
|
2014-10-20 11:14:24 +02:00
|
|
|
}
|
2006-06-02 21:38:08 +02:00
|
|
|
else
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 22:22:47 +02:00
|
|
|
$start = new Api\DateTime($this->date);
|
|
|
|
$start->setWeekstart();
|
|
|
|
$wd_start = $this->first = $start->format('ts');
|
2015-08-05 23:24:07 +02:00
|
|
|
if ($days <= 5) // no weekend-days
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2006-06-02 21:38:08 +02:00
|
|
|
switch($this->cal_prefs['weekdaystarts'])
|
|
|
|
{
|
|
|
|
case 'Saturday':
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->first = strtotime("+2 days",$this->first);
|
|
|
|
break;
|
2006-06-02 21:38:08 +02:00
|
|
|
case 'Sunday':
|
2008-03-20 09:54:18 +01:00
|
|
|
$this->first = strtotime("+1 day",$this->first);
|
2006-06-02 21:38:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
$this->last = strtotime("+$days days",$this->first) - 1;
|
2016-02-22 23:45:48 +01:00
|
|
|
$view = 'week';
|
|
|
|
}
|
|
|
|
|
|
|
|
$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
|
|
|
|
|
|
|
|
$list = $this->cal_prefs['use_time_grid'];
|
|
|
|
if(!is_array($list))
|
|
|
|
{
|
|
|
|
$list = explode(',',$list);
|
|
|
|
}
|
|
|
|
if(is_array($list))
|
|
|
|
{
|
|
|
|
$granularity = in_array($view,$list) ? 0 : $granularity;
|
2011-06-22 17:34:00 +02:00
|
|
|
}
|
2011-02-15 21:35:46 +01:00
|
|
|
|
2004-09-01 15:54:57 +02:00
|
|
|
$search_params = array(
|
2005-11-09 00:15:14 +01:00
|
|
|
'start' => $this->first,
|
|
|
|
'end' => $this->last,
|
2004-09-01 15:54:57 +02:00
|
|
|
) + $this->search_params;
|
|
|
|
|
2004-08-31 11:40:09 +02:00
|
|
|
$users = $this->search_params['users'];
|
|
|
|
if (!is_array($users)) $users = array($users);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
$content = array('view' => array());
|
2006-12-15 21:05:47 +01:00
|
|
|
|
2016-01-05 21:43:19 +01:00
|
|
|
if(!$home)
|
2015-05-06 21:03:45 +02:00
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
// Fill with the minimum needed 'weeks'
|
|
|
|
$min = max(
|
|
|
|
6, // Some months need 6 weeks for full display
|
|
|
|
$this->cal_prefs['multiple_weeks'], // WeekN view
|
|
|
|
$this->cal_prefs['week_consolidate'] // We collapse after this many users
|
|
|
|
);
|
|
|
|
for($i = 0; $i < $min; $i++)
|
|
|
|
{
|
|
|
|
$content['view'][] = array();
|
|
|
|
}
|
2015-05-06 21:03:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
// Always do 7 days for a week so scrolling works properly
|
|
|
|
$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
|
2016-01-27 18:35:25 +01:00
|
|
|
if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row
|
|
|
|
$days == 1 // Showing just 1 day
|
|
|
|
)
|
2015-05-06 21:03:45 +02:00
|
|
|
{
|
2016-01-05 21:43:19 +01:00
|
|
|
$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
|
|
|
|
array('owner' => $users);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:11:39 +02:00
|
|
|
foreach($users as $uid)
|
2016-01-05 21:43:19 +01:00
|
|
|
{
|
|
|
|
$search_params['users'] = $uid;
|
|
|
|
$content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params))
|
|
|
|
+ array('owner' => $uid);
|
|
|
|
}
|
2015-05-06 21:03:45 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-01 19:47:59 +02:00
|
|
|
$tmpl = $home ? $home :new Etemplate('calendar.view');
|
|
|
|
foreach(array_keys($content['view']) as $index)
|
2016-02-22 23:45:48 +01:00
|
|
|
{
|
|
|
|
$tmpl->setElementAttribute("view[$index]",'granularity',$granularity);
|
|
|
|
$tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']);
|
|
|
|
}
|
2015-06-10 23:51:28 +02:00
|
|
|
|
|
|
|
// Get the actions
|
|
|
|
$tmpl->setElementAttribute('view','actions',$this->get_actions());
|
2015-07-03 11:10:01 +02:00
|
|
|
|
2015-05-06 21:03:45 +02:00
|
|
|
$tmpl->exec(__METHOD__, $content);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 23:51:28 +02:00
|
|
|
/**
|
|
|
|
* Get todos via AJAX
|
|
|
|
*/
|
2016-05-01 19:47:59 +02:00
|
|
|
public static function ajax_get_todos($_date, $owner)
|
2015-06-10 23:51:28 +02:00
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
$date = Api\DateTime::to($_date, 'array');
|
2015-06-10 23:51:28 +02:00
|
|
|
$ui = new calendar_uiviews();
|
|
|
|
$ui->year = $date['year'];
|
|
|
|
$ui->month = $date['month'];
|
|
|
|
$ui->day = $date['day'];
|
|
|
|
$ui->owner = (int)$owner;
|
|
|
|
|
|
|
|
$label = '';
|
|
|
|
$todos = $ui->get_todos($label);
|
2016-05-01 19:47:59 +02:00
|
|
|
Api\Json\Response::get()->data(array(
|
2015-06-10 23:51:28 +02:00
|
|
|
'label' => $label,
|
|
|
|
'todos' => $todos
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
|
|
|
* Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider
|
|
|
|
*
|
2004-08-31 11:40:09 +02:00
|
|
|
* @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
|
2004-08-01 17:36:04 +02:00
|
|
|
* On return $todo_label contains the label for the todo-box
|
2016-05-01 19:47:59 +02:00
|
|
|
* @return string/boolean Api\Html with a table of open todo's or false if no hook availible
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
|
|
|
function get_todos(&$todo_label)
|
|
|
|
{
|
2016-05-01 19:47:59 +02:00
|
|
|
$todos_from_hook = Api\Hooks::process(array(
|
2004-08-01 17:36:04 +02:00
|
|
|
'location' => 'calendar_include_todos',
|
|
|
|
'year' => $this->year,
|
|
|
|
'month' => $this->month,
|
|
|
|
'day' => $this->day,
|
|
|
|
'owner' => $this->owner // num. id of the user, not necessary current user
|
|
|
|
));
|
|
|
|
|
|
|
|
if(is_array($todo_label))
|
|
|
|
{
|
|
|
|
list($label,$showall)=$todo_label;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$label=$todo_label;
|
|
|
|
$showall=true;
|
|
|
|
}
|
2005-11-09 00:15:14 +01:00
|
|
|
$maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow'];
|
2004-08-01 17:36:04 +02:00
|
|
|
if($maxshow <= 0)
|
|
|
|
{
|
|
|
|
$maxshow=10;
|
|
|
|
}
|
|
|
|
//print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow");
|
|
|
|
|
2017-01-31 17:17:54 +01:00
|
|
|
$todo_label = '';
|
|
|
|
$todo_list = array();
|
2004-08-01 17:36:04 +02:00
|
|
|
if (is_array($todos_from_hook) && count($todos_from_hook))
|
|
|
|
{
|
|
|
|
foreach($todos_from_hook as $todos)
|
|
|
|
{
|
|
|
|
$i = 0;
|
2005-11-09 00:15:14 +01:00
|
|
|
if (is_array($todos))
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2005-11-09 00:15:14 +01:00
|
|
|
$todo_label = !empty($label) ? $label : lang("open ToDo's:");
|
|
|
|
|
2015-07-15 18:29:10 +02:00
|
|
|
foreach($todos as &$todo)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
|
|
|
if(!$showall && ($i++ > $maxshow))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$icons = '';
|
2015-12-28 18:59:47 +01:00
|
|
|
foreach($todo['icons'] as $name => $alt)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:39:41 +02:00
|
|
|
$icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"');
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2015-07-15 18:29:10 +02:00
|
|
|
$todo['icons'] = $icons;
|
2010-12-10 21:05:51 +01:00
|
|
|
if($todo['edit']) {
|
2015-07-15 18:29:10 +02:00
|
|
|
$todo['edit_size'] = $todo['edit']['size'];
|
2010-12-10 21:05:51 +01:00
|
|
|
unset($todo['edit']['size']);
|
2016-05-02 17:39:41 +02:00
|
|
|
$edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" ');
|
2016-05-01 19:47:59 +02:00
|
|
|
$edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
|
|
|
|
$todo['edit'] = Framework::link('/index.php',$todo['edit'],true);
|
2010-12-10 21:05:51 +01:00
|
|
|
}
|
2017-01-31 17:17:54 +01:00
|
|
|
$todo_list[] = $todo;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-31 17:17:54 +01:00
|
|
|
return $todo_list;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2004-08-01 17:36:04 +02:00
|
|
|
/**
|
2016-05-02 17:26:56 +02:00
|
|
|
* Get onclick attribute to open integration item for edit
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* Name of the attribute is 'edit_link' and it should be an array with values for keys:
|
|
|
|
* - 'edit' => array('menuaction' => 'app.class.method')
|
|
|
|
* - 'edit_id' => 'app_id'
|
|
|
|
* - 'edit_popup' => '400x300' (optional)
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* @param string $app
|
|
|
|
* @param int|string $id
|
|
|
|
* @return string
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2016-05-02 17:26:56 +02:00
|
|
|
public static function integration_get_popup($app,$id)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$app_data = calendar_bo::integration_get_data($app,'edit_link');
|
|
|
|
|
|
|
|
if (is_array($app_data) && isset($app_data['edit']))
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$popup_size = $app_data['edit_popup'];
|
|
|
|
$edit = $app_data['edit'];
|
|
|
|
$edit[$app_data['edit_id']] = $id;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$edit = Link::edit($app,$id,$popup_size);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
if ($edit)
|
|
|
|
{
|
|
|
|
if ($popup_size)
|
|
|
|
{
|
|
|
|
$popup = ' data-app="app|'.$popup_size.'"';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$popup = ' data-app="app|'.$app.'|'.'"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $popup;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-02 17:26:56 +02:00
|
|
|
* Get icons for an integration event
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* Attribute 'icons' is either null (--> navbar icon), false (--> no icon)
|
|
|
|
* or a callback with parameters $id,$event
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* Icons specified in $events['icons'] are always displayed!
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* @param string $app
|
|
|
|
* @param int|string $id
|
|
|
|
* @param array $event
|
|
|
|
* @return array
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2016-05-02 17:26:56 +02:00
|
|
|
static function integration_get_icons($app,$id,$event)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$icons = array();
|
|
|
|
if ($event['icons'])
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
foreach(explode(',',$event['icons']) as $icon)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
list($icon_app,$icon) = explode(':',$icon);
|
|
|
|
if (Api\Image::find($icon_app,$icon))
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$icons[] = Api\Html::image($icon_app,$icon);
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
$app_data = calendar_bo::integration_get_data($app,'icons');
|
|
|
|
if (is_null($app_data))
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2021-03-04 14:29:15 +01:00
|
|
|
if (($icon = Api\Link::get_registry($app,'icon')) &&
|
|
|
|
($icon = explode('/', $icon)))
|
|
|
|
{
|
|
|
|
|
|
|
|
$icons[] = Api\Html::image($icon[0], $icon[1]); // use icon from link registry
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$icons[] = Api\Html::image($app,'navbar'); // use navbar icon
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
elseif ($app_data)
|
2006-06-02 21:38:08 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$icons += (array)ExecMethod2($app_data,$id,$event);
|
2006-06-02 21:38:08 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
return $icons;
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-02 17:26:56 +02:00
|
|
|
* Get the actions for the non-list views
|
|
|
|
*
|
|
|
|
* We use the actions from the list as a base, and only change what we have to
|
|
|
|
* to get it to work outside of a nextmatch.
|
2004-08-01 17:36:04 +02:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* @return Array
|
2004-08-01 17:36:04 +02:00
|
|
|
*/
|
2016-05-02 17:26:56 +02:00
|
|
|
protected static function get_actions()
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
// Just copy from the list, but change to match our needs
|
|
|
|
$ui = new calendar_uilist();
|
|
|
|
$actions = $ui->get_actions();
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2016-05-02 17:26:56 +02:00
|
|
|
unset($actions['no_notifications']);
|
|
|
|
unset($actions['select_all']);
|
2010-07-31 09:51:52 +02:00
|
|
|
|
2016-05-02 17:26:56 +02:00
|
|
|
// This disables the event actions for the grid rows (calendar weeks/owners)
|
|
|
|
foreach($actions as $id => &$action)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
if($id=='add') continue;
|
|
|
|
if(!$action['enabled'])
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$action['enabled'] = 'javaScript:app.calendar.is_event';
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
$actions['add']['open'] = '{"app":"calendar","type":"add"}';
|
|
|
|
$actions['add']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2019-01-17 17:21:19 +01:00
|
|
|
$actions['copy']['open'] = '{"app": "calendar", "type": "edit", "extra": "cal_id=$id&action=copy"}';
|
2016-05-02 17:26:56 +02:00
|
|
|
$actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2019-01-17 17:21:19 +01:00
|
|
|
$actions['print']['open'] = '{"app": "calendar", "type": "edit", "extra": "cal_id=$id&print=1"}';
|
2016-08-01 17:11:29 +02:00
|
|
|
$actions['print']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2021-02-09 21:42:51 +01:00
|
|
|
$actions['notifications']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2007-05-19 09:49:57 +02:00
|
|
|
|
2016-05-02 17:26:56 +02:00
|
|
|
foreach($actions['status']['children'] as $id => &$status)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$status = array(
|
|
|
|
'id' => $id,
|
|
|
|
'caption' => $status,
|
|
|
|
'onExecute' => 'javaScript:app.calendar.status'
|
|
|
|
);
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
|
|
|
|
if ($actions['filemanager'])
|
2006-05-31 02:33:27 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url'];
|
|
|
|
$actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2006-05-31 02:33:27 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
if ($actions['infolog_app'])
|
|
|
|
{
|
|
|
|
$actions['infolog_app']['open'] = '{"app": "infolog", "type": "add", "extra": "type=task&action=$app&action_id=$id"}';
|
|
|
|
$actions['infolog_app']['onExecute'] = 'javaScript:app.calendar.action_open';
|
2010-07-31 09:51:52 +02:00
|
|
|
}
|
2018-06-19 22:35:08 +02:00
|
|
|
// Get documents working with other views
|
|
|
|
$set_execute = function(&$action) use (&$set_execute)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2018-06-19 22:35:08 +02:00
|
|
|
$action['onExecute'] = 'javaScript:app.calendar.action_merge';
|
2018-07-30 09:51:44 +02:00
|
|
|
if (!empty($action['children']))
|
2018-06-19 22:35:08 +02:00
|
|
|
{
|
2018-07-30 09:51:44 +02:00
|
|
|
foreach($action['children'] as &$child)
|
|
|
|
{
|
|
|
|
$set_execute($child);
|
|
|
|
}
|
2018-06-19 22:35:08 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
$set_execute($actions['documents']);
|
2016-05-02 17:26:56 +02:00
|
|
|
$actions['ical']['onExecute'] = 'javaScript:app.calendar.ical';
|
|
|
|
|
|
|
|
$actions['delete']['onExecute'] = 'javaScript:app.calendar.delete';
|
2005-11-09 00:15:14 +01:00
|
|
|
|
2016-05-02 17:26:56 +02:00
|
|
|
return $actions;
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2005-11-09 00:15:14 +01:00
|
|
|
/**
|
2016-05-02 17:26:56 +02:00
|
|
|
* Marks whole day events for later usage and increments extraRows
|
2005-11-09 00:15:14 +01:00
|
|
|
*
|
2016-05-02 17:26:56 +02:00
|
|
|
* @param array $dayEvents
|
|
|
|
* @return array $dayEvents
|
2005-11-09 00:15:14 +01:00
|
|
|
*/
|
2016-05-02 17:26:56 +02:00
|
|
|
function tagWholeDayOnTop($dayEvents)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$this->extraRows = $this->extraRowsOriginal;
|
|
|
|
$this->remBotExtraRows = 0;
|
|
|
|
|
|
|
|
if (is_array($dayEvents))
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
foreach ($dayEvents as $day=>$oneDayEvents)
|
2004-08-01 17:36:04 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$extraRowsToAdd = 0;
|
|
|
|
foreach ($oneDayEvents as $num => $event)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$start = $this->bo->date2array($event['start']);
|
|
|
|
$end = $this->bo->date2array($event['end']);
|
|
|
|
if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
|
2010-07-31 09:51:52 +02:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
if($event['non_blocking'])
|
2010-12-22 16:17:56 +01:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$dayEvents[$day][$num]['whole_day_on_top']=true;
|
|
|
|
$this->whole_day_positions[$num]=($this->rowHeight*($num+2));
|
|
|
|
$extraRowsToAdd++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$dayEvents[$day][$num]['whole_day']=true;
|
2010-12-22 16:17:56 +01:00
|
|
|
}
|
2010-07-31 09:51:52 +02:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
$this->to_client($dayEvents[$day][$num]);
|
2005-11-09 00:15:14 +01:00
|
|
|
}
|
2016-05-02 17:26:56 +02:00
|
|
|
// check after every day if we have to increase $this->extraRows
|
|
|
|
if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows)
|
2005-11-09 00:15:14 +01:00
|
|
|
{
|
2016-05-02 17:26:56 +02:00
|
|
|
$this->remBotExtraRows = $extraRowsToAdd;
|
|
|
|
$this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd);
|
2010-01-21 00:21:00 +01:00
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
}
|
2010-01-21 00:21:00 +01:00
|
|
|
}
|
2006-10-17 22:01:08 +02:00
|
|
|
return $dayEvents;
|
|
|
|
}
|
2004-08-01 17:36:04 +02:00
|
|
|
}
|