move calendar to new api

This commit is contained in:
Ralf Becker 2016-05-01 17:47:59 +00:00
parent ca2ffb6aea
commit dcc003cedf
37 changed files with 1843 additions and 2024 deletions

View File

@ -9,6 +9,8 @@
* @version $Id$
*/
use EGroupware\Api;
die('This file is only used on http://www.egroupware.org/ and therefore disabled on local installations!');
if(empty($_POST['locale']) || !preg_match('/^[A-Z]{2}$/',$_POST['locale']))
@ -68,7 +70,7 @@ if(!file_exists($file) || filesize($file) < 300) // treat very small files as no
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE Api\Html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>eGroupWare.org: There is already a holiday-file for '<?php echo $_POST['locale']; ?>' !!!</title>

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
$GLOBALS['egw_info'] = array(
'flags' => array(
'currentapp' => 'calendar',
@ -28,9 +30,9 @@ include ('../header.inc.php');
function fail_exit($msg)
{
echo "<html>\n<head>\n<title>$msg</title>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=".
$GLOBALS['egw']->translation->charset()."\" />\n</head>\n<body><h1>$msg</h1>\n</body>\n</html>\n";
Api\Translation::charset()."\" />\n</head>\n<body><h1>$msg</h1>\n</body>\n</html>\n";
$GLOBALS['egw']->common->egw_exit();
exit();
}
if (!$loged_in)
@ -107,6 +109,7 @@ if ($_GET['debug'])
}
else
{
html::content_header('freebusy.ifb','text/calendar');
Api\Header\Content::type('freebusy.ifb','text/calendar');
}
echo ExecMethod2('calendar.calendar_ical.freebusy',$user,$_GET['end']);
$ical = new calendar_ical();
echo $ical->freebusy($user, $_GET['end']);

View File

@ -1,502 +1,507 @@
<?php
/**************************************************************************\
* eGroupWare - Holiday *
* http://www.egroupware.org *
* Written by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - Holiday *
* http://www.egroupware.org *
* Written by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
use EGroupware\Api;
use EGroupware\Api\Framework;
/**
* Business object for calendar holidays
*
* @package calendar
* @author Mark Peters <skeeter@phpgroupware.org>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class boholiday
/* $Id$ */
/**
* Business object for calendar holidays
*
* @package calendar
* @author Mark Peters <skeeter@phpgroupware.org>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class boholiday
{
var $public_functions = Array(
'add' => True,
'delete_holiday' => True,
'delete_locale' => True,
'accept_holiday' => True,
'read_entries' => True,
'read_entry' => True,
'add_entry' => True,
'update_entry' => True
);
var $debug = false;
var $base_url = '/index.php';
var $ui;
var $so;
var $owner;
var $year;
var $id;
var $total;
var $start;
var $query;
var $sort;
var $locales = Array();
var $holidays;
var $cached_holidays;
function boholiday()
{
var $public_functions = Array(
'add' => True,
'delete_holiday' => True,
'delete_locale' => True,
'accept_holiday' => True,
$this->so =& CreateObject('calendar.soholiday');
'read_entries' => True,
'read_entry' => True,
'add_entry' => True,
'update_entry' => True
);
var $debug = false;
var $base_url = '/index.php';
var $ui;
var $so;
var $owner;
var $year;
var $id;
var $total;
var $start;
var $query;
var $sort;
var $locales = Array();
var $holidays;
var $cached_holidays;
function boholiday()
$this->start = (int)get_var('start',array('POST','GET'));
$this->query = get_var('query',array('POST','GET'));
$this->sort = get_var('sort',array('POST','GET'));
$this->order = get_var('order',array('POST','GET'));
$this->id = get_var('id',array('POST','GET'));
$this->year = get_var('year',array('POST','GET'),date('Y'));
$this->locale = get_var('locale',array('POST','GET'));
if ($this->locale)
{
$this->so =& CreateObject('calendar.soholiday');
$this->start = (int)get_var('start',array('POST','GET'));
$this->query = get_var('query',array('POST','GET'));
$this->sort = get_var('sort',array('POST','GET'));
$this->order = get_var('order',array('POST','GET'));
$this->id = get_var('id',array('POST','GET'));
$this->year = get_var('year',array('POST','GET'),date('Y'));
$this->locale = get_var('locale',array('POST','GET'));
if ($this->locale)
{
$this->locales[] = $this->locale;
}
if($this->debug)
{
echo '<-- Locale = '.$this->locales[0].' -->'."\n";
}
$this->total = $this->so->holiday_total($this->locales[0],$this->query,$this->year);
$this->locales[] = $this->locale;
}
/* Begin Calendar functions */
function read_entry($id=0)
if($this->debug)
{
if($this->debug)
{
echo "BO : Reading Holiday ID : ".$id."<br>\n";
}
if(!$id)
{
if(!$this->id)
{
return Array();
}
else
{
$id = $this->id;
}
}
return $this->so->read_holiday($id);
echo '<-- Locale = '.$this->locales[0].' -->'."\n";
}
function delete_holiday($id=0)
{
if(!$id)
{
if($this->id)
{
$id = $this->id;
}
}
$this->total = $this->so->holiday_total($this->locales[0],$this->query,$this->year);
}
$this->ui =& CreateObject('calendar.uiholiday');
if($id)
/* Begin Calendar functions */
function read_entry($id=0)
{
if($this->debug)
{
echo "BO : Reading Holiday ID : ".$id."<br>\n";
}
if(!$id)
{
if(!$this->id)
{
$this->so->delete_holiday($id);
$this->ui->edit_locale();
return Array();
}
else
{
$this->ui->admin();
$id = $this->id;
}
}
function delete_locale($locale='')
{
if(!$locale)
{
if($this->locales[0])
{
$locale = $this->locales[0];
}
}
return $this->so->read_holiday($id);
}
if($locale)
function delete_holiday($id=0)
{
if(!$id)
{
if($this->id)
{
$this->so->delete_locale($locale);
$id = $this->id;
}
$this->ui =& CreateObject('calendar.uiholiday');
}
$this->ui =& CreateObject('calendar.uiholiday');
if($id)
{
$this->so->delete_holiday($id);
$this->ui->edit_locale();
}
else
{
$this->ui->admin();
}
}
function accept_holiday()
function delete_locale($locale='')
{
if(!$locale)
{
$send_back_to = str_replace('submitlocale','holiday_admin',$_SERVER['HTTP_REFERER']);
if(!@$this->locales[0])
if($this->locales[0])
{
Header('Location: '.$send_back_to);
$locale = $this->locales[0];
}
}
$send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to);
$file = './holidays.'.$this->locales[0];
if(!file_exists($file) && count($_POST['name']))
{
$fp = fopen($file,'w');
fwrite($fp,"charset\t".$GLOBALS['egw']->translation->charset()."\n");
if($locale)
{
$this->so->delete_locale($locale);
}
$this->ui =& CreateObject('calendar.uiholiday');
$this->ui->admin();
}
$holidays = array();
foreach($_POST['name'] as $i => $name)
{
$holiday = array(
'locale' => $_POST['locale'],
'name' => str_replace('\\','',$name),
'day' => $_POST['day'][$i],
'month' => $_POST['month'][$i],
'occurence' => $_POST['occurence'][$i],
'dow' => $_POST['dow'][$i],
'observance' => $_POST['observance'][$i],
);
}
// sort holidays by year / occurence:
usort($holidays,'_holiday_cmp');
$last_year = -1;
foreach($holidays as $holiday)
{
$year = $holiday['occurence'] <= 0 ? 0 : $holiday['occurence'];
if ($year != $last_year)
{
echo "\n".($year ? $year : 'regular (year=0)').":\n";
$last_year = $year;
}
fwrite($fp,"$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n");
}
fclose($fp);
}
function accept_holiday()
{
$send_back_to = str_replace('submitlocale','holiday_admin',$_SERVER['HTTP_REFERER']);
if(!@$this->locales[0])
{
Header('Location: '.$send_back_to);
}
function get_holiday_list($locale='', $sort='', $order='', $query='', $total='', $year=0)
$send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to);
$file = './holidays.'.$this->locales[0];
if(!file_exists($file) && count($_POST['name']))
{
$locale = ($locale?$locale:$this->locales[0]);
$sort = ($sort?$sort:$this->sort);
$order = ($order?$order:$this->order);
$query = ($query?$query:$this->query);
$year = ($$year?$$year:$this->year);
return $this->so->read_holidays($locale,$query,$order,$year);
$fp = fopen($file,'w');
fwrite($fp,"charset\t".Api\Translation::charset()."\n");
$holidays = array();
foreach($_POST['name'] as $i => $name)
{
$holiday = array(
'locale' => $_POST['locale'],
'name' => str_replace('\\','',$name),
'day' => $_POST['day'][$i],
'month' => $_POST['month'][$i],
'occurence' => $_POST['occurence'][$i],
'dow' => $_POST['dow'][$i],
'observance' => $_POST['observance'][$i],
);
}
// sort holidays by year / occurence:
usort($holidays,'_holiday_cmp');
$last_year = -1;
foreach($holidays as $holiday)
{
$year = $holiday['occurence'] <= 0 ? 0 : $holiday['occurence'];
if ($year != $last_year)
{
echo "\n".($year ? $year : 'regular (year=0)').":\n";
$last_year = $year;
}
fwrite($fp,"$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n");
}
fclose($fp);
}
Header('Location: '.$send_back_to);
}
function get_holiday_list($locale='', $sort='', $order='', $query='', $total='', $year=0)
{
$locale = ($locale?$locale:$this->locales[0]);
$sort = ($sort?$sort:$this->sort);
$order = ($order?$order:$this->order);
$query = ($query?$query:$this->query);
$year = ($$year?$$year:$this->year);
return $this->so->read_holidays($locale,$query,$order,$year);
}
function get_locale_list($sort='', $order='', $query='')
{
$sort = ($sort?$sort:$this->sort);
$order = ($order?$order:$this->order);
$query = ($query?$query:$this->query);
return $this->so->get_locale_list($sort,$order,$query);
}
function prepare_read_holidays($year=0,$owner=0)
{
$this->year = (isset($year) && $year > 0?$year: Api\DateTime::to(time() - $GLOBALS['egw']->datetime->tz_offset,'Y'));
$this->owner = ($owner?$owner:$GLOBALS['egw_info']['user']['account_id']);
if($this->debug)
{
echo 'Setting Year to : '.$this->year.'<br>'."\n";
}
function get_locale_list($sort='', $order='', $query='')
if(@$GLOBALS['egw_info']['user']['preferences']['common']['country'])
{
$sort = ($sort?$sort:$this->sort);
$order = ($order?$order:$this->order);
$query = ($query?$query:$this->query);
return $this->so->get_locale_list($sort,$order,$query);
$this->locales[] = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
}
elseif(@$GLOBALS['egw_info']['user']['preferences']['calendar']['locale'])
{
$this->locales[] = $GLOBALS['egw_info']['user']['preferences']['calendar']['locale'];
}
else
{
$this->locales[] = 'US';
}
function prepare_read_holidays($year=0,$owner=0)
if($this->owner != $GLOBALS['egw_info']['user']['account_id'])
{
$this->year = (isset($year) && $year > 0?$year:$GLOBALS['egw']->common->show_date(time() - $GLOBALS['egw']->datetime->tz_offset,'Y'));
$this->owner = ($owner?$owner:$GLOBALS['egw_info']['user']['account_id']);
if($this->debug)
$owner_pref = new Api\Preferences($owner);
$owner_prefs = $owner_pref->read_repository();
if(@$owner_prefs['common']['country'])
{
echo 'Setting Year to : '.$this->year.'<br>'."\n";
$this->locales[] = $owner_prefs['common']['country'];
}
if(@$GLOBALS['egw_info']['user']['preferences']['common']['country'])
elseif(@$owner_prefs['calendar']['locale'])
{
$this->locales[] = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
$this->locales[] = $owner_prefs['calendar']['locale'];
}
elseif(@$GLOBALS['egw_info']['user']['preferences']['calendar']['locale'])
unset($owner_pref);
}
if($GLOBALS['egw_info']['server']['auto_load_holidays'] == True && $this->locales)
{
foreach($this->locales as $local)
{
$this->locales[] = $GLOBALS['egw_info']['user']['preferences']['calendar']['locale'];
$this->auto_load_holidays($local, $year);
}
}
}
function auto_load_holidays($locale, $year=0)
{
//error_log(__METHOD__."('$locale', $year)");
if (!Api\Cache::getInstance(__CLASS__, $locale.'-'.$year) && // check if autoload has been tried for this locale and year
(!($total_year = $this->so->holiday_total($locale, '', $year)) ||
// automatic try load new holidays, if there are no irregular ones for queried year
$total_year == $this->so->holiday_total($locale, '', 1901)))
{
//error_log(__METHOD__."('$locale', $year) attemption autoload ...");
Api\Cache::setInstance(__CLASS__, $locale.'-'.$year, true, 864000); // do NOT try again for 10 days
@set_time_limit(0);
/* get the file that contains the calendar events for your locale */
/* "http://www.egroupware.org/cal/holidays.US.csv"; */
if(isset($GLOBALS['egw_info']['server']['holidays_url_path']) && $GLOBALS['egw_info']['server']['holidays_url_path'] != 'localhost')
{
$load_from = $GLOBALS['egw_info']['server']['holidays_url_path'];
}
else
{
$this->locales[] = 'US';
}
if($this->owner != $GLOBALS['egw_info']['user']['account_id'])
{
$owner_pref =& CreateObject('phpgwapi.preferences',$owner);
$owner_prefs = $owner_pref->read_repository();
if(@$owner_prefs['common']['country'])
if ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/')
{
$this->locales[] = $owner_prefs['common']['country'];
}
elseif(@$owner_prefs['calendar']['locale'])
{
$this->locales[] = $owner_prefs['calendar']['locale'];
}
unset($owner_pref);
}
if($GLOBALS['egw_info']['server']['auto_load_holidays'] == True && $this->locales)
{
foreach($this->locales as $local)
{
$this->auto_load_holidays($local, $year);
}
}
}
function auto_load_holidays($locale, $year=0)
{
//error_log(__METHOD__."('$locale', $year)");
if (!egw_cache::getInstance(__CLASS__, $locale.'-'.$year) && // check if autoload has been tried for this locale and year
(!($total_year = $this->so->holiday_total($locale, '', $year)) ||
// automatic try load new holidays, if there are no irregular ones for queried year
$total_year == $this->so->holiday_total($locale, '', 1901)))
{
//error_log(__METHOD__."('$locale', $year) attemption autoload ...");
egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 864000); // do NOT try again for 10 days
@set_time_limit(0);
/* get the file that contains the calendar events for your locale */
/* "http://www.egroupware.org/cal/holidays.US.csv"; */
if(isset($GLOBALS['egw_info']['server']['holidays_url_path']) && $GLOBALS['egw_info']['server']['holidays_url_path'] != 'localhost')
{
$load_from = $GLOBALS['egw_info']['server']['holidays_url_path'];
$server_host = ($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url'];
}
else
{
if ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/')
{
$server_host = ($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url'];
}
else
{
$server_host = $GLOBALS['egw_info']['server']['webserver_url'];
}
$load_from = $server_host.'/calendar/egroupware.org';
$server_host = $GLOBALS['egw_info']['server']['webserver_url'];
}
$load_from = $server_host.'/calendar/egroupware.org';
}
// echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale).'.csv'."<br>\n";
if($GLOBALS['egw_info']['server']['holidays_url_path'] == 'localhost')
{
$lines = file(EGW_SERVER_ROOT.'/calendar/egroupware.org/holidays.'.strtoupper($locale).'.csv');
}
else
{
$lines = file($url=$load_from.'/holidays.'.strtoupper($locale).'.csv', 0, egw_framework::proxy_context());
//error_log(__METHOD__."('$locale', $year) file('$url')=".array2string($lines));
}
if (!$lines)
{
return false;
}
// reading the holidayfile from egroupware.org via network::gethttpsocketfile contains all the headers!
foreach($lines as $line)
{
$fields = preg_split("/[\t\n ]+/",$line);
if ($fields[0] == 'charset' && $fields[1])
{
$lines = translation::convert($lines,$fields[1]);
break;
}
}
foreach ($lines as $line)
{
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$line);
if(count($holiday) == 7)
{
$holiday['locale'] = $holiday[0];
$holiday['name'] = $GLOBALS['egw']->db->db_addslashes($holiday[1]);
$holiday['mday'] = (int)$holiday[2];
$holiday['month_num'] = (int)$holiday[3];
$holiday['occurence'] = (int)$holiday[4];
$holiday['dow'] = (int)$holiday[5];
$holiday['observance_rule'] = (int)$holiday[6];
$holiday['hol_id'] = 0;
$this->so->save_holiday($holiday);
}
}
}
}
function save_holiday($holiday)
{
$this->so->save_holiday($holiday);
}
function add()
{
if(@$_POST['submit'])
if($GLOBALS['egw_info']['server']['holidays_url_path'] == 'localhost')
{
$holiday = $_POST['holiday'];
if(empty($holiday['mday']))
{
$holiday['mday'] = 0;
}
if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='')
{
$this->bo->locales[0] = $holiday['locale'];
}
elseif(!isset($holiday['locale']) || $holiday['locale']=='')
{
$holiday['locale'] = $this->bo->locales[0];
}
if(!isset($holiday['hol_id']))
{
$holiday['hol_id'] = $this->bo->id;
}
// some input validation
if (!$holiday['mday'] == !$holiday['occurence'])
{
$errors[] = lang('You need to set either a day or a occurence !!!');
}
if($holiday['year'] && $holiday['occurence'])
{
$errors[] = lang('You can only set a year or a occurence !!!');
}
else
{
$holiday['occurence'] = (int)($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']);
unset($holiday['year']);
}
// Still need to put some validation in here.....
$this->ui =& CreateObject('calendar.uiholiday');
if (is_array($errors))
{
$holiday['month'] = $holiday['month_num'];
$holiday['day'] = $holiday['mday'];
$this->ui->edit_holiday($errors,$holiday);
}
else
{
$this->so->save_holiday($holiday);
$this->ui->edit_locale($holiday['locale']);
}
$lines = file(EGW_SERVER_ROOT.'/calendar/egroupware.org/holidays.'.strtoupper($locale).'.csv');
}
}
function sort_holidays_by_date($holidays)
{
$c_holidays = count($holidays);
for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++)
else
{
for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++)
{
if($holidays[$outer_loop]['date'] > $holidays[$inner_loop]['date'])
{
$temp = $holidays[$inner_loop];
$holidays[$inner_loop] = $holidays[$outer_loop];
$holidays[$outer_loop] = $temp;
}
}
$lines = file($url=$load_from.'/holidays.'.strtoupper($locale).'.csv', 0, Framework::proxy_context());
//error_log(__METHOD__."('$locale', $year) file('$url')=".array2string($lines));
}
return $holidays;
}
function set_holidays_to_date($holidays)
{
$new_holidays = Array();
for($i=0;$i<count($holidays);$i++)
{
// echo "Setting Holidays Date : ".date('Ymd',$holidays[$i]['date'])."<br>\n";
$new_holidays[date('Ymd',$holidays[$i]['date'])][] = $holidays[$i];
}
return $new_holidays;
}
function read_holiday()
{
if(isset($this->cached_holidays))
{
return $this->cached_holidays;
}
$holidays = $this->so->read_holidays($this->locales,'','',$this->year);
if(count($holidays) == 0)
{
return $holidays;
}
$temp_locale = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
foreach($holidays as $i => $holiday)
{
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
{
if(is_object($holidaycalc))
{
unset($holidaycalc);
}
$GLOBALS['egw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
$holidaycalc =& CreateObject('calendar.holidaycalc');
}
$holidays[$i]['date'] = $holidaycalc->calculate_date($holiday, $holidays, $this->year);
}
unset($holidaycalc);
$this->holidays = $this->sort_holidays_by_date($holidays);
$this->cached_holidays = $this->set_holidays_to_date($this->holidays);
$GLOBALS['egw_info']['user']['preferences']['common']['country'] = $temp_locale;
return $this->cached_holidays;
}
/* End Calendar functions */
function check_admin()
{
if(!@$GLOBALS['egw_info']['user']['apps']['admin'])
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php'));
}
}
function rule_string($holiday)
{
if (!is_array($holiday))
if (!$lines)
{
return false;
}
$monthnames = array(
'','January','February','March','April','May','June',
'July','August','September','October','November','December'
);
$month = $holiday['month'] ? lang($monthnames[$holiday['month']]) : '';
if (!$holiday['day'])
// reading the holidayfile from egroupware.org via network::gethttpsocketfile contains all the headers!
foreach($lines as $line)
{
$occ = $holiday['occurence'] == 99 ? lang('last') : $holiday['occurence'].'.';
$fields = preg_split("/[\t\n ]+/",$line);
$dow_str = Array(lang('Sun'),lang('Mon'),lang('Tue'),lang('Wed'),lang('Thu'),lang('Fri'),lang('Sat'));
$dow = $dow_str[$holiday['dow']];
if ($fields[0] == 'charset' && $fields[1])
{
$lines = Api\Translation::convert($lines,$fields[1]);
break;
}
}
foreach ($lines as $line)
{
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$line);
if(count($holiday) == 7)
{
$holiday['locale'] = $holiday[0];
$holiday['name'] = $GLOBALS['egw']->db->db_addslashes($holiday[1]);
$holiday['mday'] = (int)$holiday[2];
$holiday['month_num'] = (int)$holiday[3];
$holiday['occurence'] = (int)$holiday[4];
$holiday['dow'] = (int)$holiday[5];
$holiday['observance_rule'] = (int)$holiday[6];
$holiday['hol_id'] = 0;
$this->so->save_holiday($holiday);
}
}
}
}
$str = lang('%1 %2 in %3',$occ,$dow,$month);
function save_holiday($holiday)
{
$this->so->save_holiday($holiday);
}
function add()
{
if(@$_POST['submit'])
{
$holiday = $_POST['holiday'];
if(empty($holiday['mday']))
{
$holiday['mday'] = 0;
}
if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='')
{
$this->bo->locales[0] = $holiday['locale'];
}
elseif(!isset($holiday['locale']) || $holiday['locale']=='')
{
$holiday['locale'] = $this->bo->locales[0];
}
if(!isset($holiday['hol_id']))
{
$holiday['hol_id'] = $this->bo->id;
}
// some input validation
if (!$holiday['mday'] == !$holiday['occurence'])
{
$errors[] = lang('You need to set either a day or a occurence !!!');
}
if($holiday['year'] && $holiday['occurence'])
{
$errors[] = lang('You can only set a year or a occurence !!!');
}
else
{
$str = $GLOBALS['egw']->common->dateformatorder($holiday['occurence']>1900?$holiday['occurence']:'',$month,$holiday[day]);
$holiday['occurence'] = (int)($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']);
unset($holiday['year']);
}
if ($holiday['observance_rule'])
// Still need to put some validation in here.....
$this->ui =& CreateObject('calendar.uiholiday');
if (is_array($errors))
{
$str .= ' ('.lang('Observance Rule').')';
$holiday['month'] = $holiday['month_num'];
$holiday['day'] = $holiday['mday'];
$this->ui->edit_holiday($errors,$holiday);
}
else
{
$this->so->save_holiday($holiday);
$this->ui->edit_locale($holiday['locale']);
}
return $str;
}
}
function _holiday_cmp($a,$b)
function sort_holidays_by_date($holidays)
{
if (($year_diff = ($a['occurence'] <= 0 ? 0 : $a['occurence']) - ($b['occurence'] <= 0 ? 0 : $b['occurence'])))
$c_holidays = count($holidays);
for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++)
{
return $year_diff;
for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++)
{
if($holidays[$outer_loop]['date'] > $holidays[$inner_loop]['date'])
{
$temp = $holidays[$inner_loop];
$holidays[$inner_loop] = $holidays[$outer_loop];
$holidays[$outer_loop] = $temp;
}
}
}
return $a['month'] - $b['month'] ? $a['month'] - $b['month'] : $a['day'] - $b['day'];
return $holidays;
}
function set_holidays_to_date($holidays)
{
$new_holidays = Array();
for($i=0;$i<count($holidays);$i++)
{
// echo "Setting Holidays Date : ".date('Ymd',$holidays[$i]['date'])."<br>\n";
$new_holidays[date('Ymd',$holidays[$i]['date'])][] = $holidays[$i];
}
return $new_holidays;
}
function read_holiday()
{
if(isset($this->cached_holidays))
{
return $this->cached_holidays;
}
$holidays = $this->so->read_holidays($this->locales,'','',$this->year);
if(count($holidays) == 0)
{
return $holidays;
}
$temp_locale = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
foreach($holidays as $i => $holiday)
{
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
{
if(is_object($holidaycalc))
{
unset($holidaycalc);
}
$GLOBALS['egw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
$holidaycalc =& CreateObject('calendar.holidaycalc');
}
$holidays[$i]['date'] = $holidaycalc->calculate_date($holiday, $holidays, $this->year);
}
unset($holidaycalc);
$this->holidays = $this->sort_holidays_by_date($holidays);
$this->cached_holidays = $this->set_holidays_to_date($this->holidays);
$GLOBALS['egw_info']['user']['preferences']['common']['country'] = $temp_locale;
return $this->cached_holidays;
}
/* End Calendar functions */
function check_admin()
{
if(!@$GLOBALS['egw_info']['user']['apps']['admin'])
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php'));
}
}
function rule_string($holiday)
{
if (!is_array($holiday))
{
return false;
}
$monthnames = array(
'','January','February','March','April','May','June',
'July','August','September','October','November','December'
);
$month = $holiday['month'] ? lang($monthnames[$holiday['month']]) : '';
if (!$holiday['day'])
{
$occ = $holiday['occurence'] == 99 ? lang('last') : $holiday['occurence'].'.';
$dow_str = Array(lang('Sun'),lang('Mon'),lang('Tue'),lang('Wed'),lang('Thu'),lang('Fri'),lang('Sat'));
$dow = $dow_str[$holiday['dow']];
$str = lang('%1 %2 in %3',$occ,$dow,$month);
}
else
{
$arr = array($month,$holiday['day']);
if ($holiday['occurence']>1900) array_unshift ($arr, $holiday['occurence']);
$str = implode('-', $arr);
}
if ($holiday['observance_rule'])
{
$str .= ' ('.lang('Observance Rule').')';
}
return $str;
}
}
function _holiday_cmp($a,$b)
{
if (($year_diff = ($a['occurence'] <= 0 ? 0 : $a['occurence']) - ($b['occurence'] <= 0 ? 0 : $b['occurence'])))
{
return $year_diff;
}
return $a['month'] - $b['month'] ? $a['month'] - $b['month'] : $a['day'] - $b['day'];
}

View File

@ -6,11 +6,15 @@
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Joerg Lehrke <jlehrke@noc.de>
* @copyright (c) 2004-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2004-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode
{
define('ACL_TYPE_IDENTIFER','***ACL***');
@ -20,17 +24,6 @@ define('HOUR_s',60*60);
define('DAY_s',24*HOUR_s);
define('WEEK_s',7*DAY_s);
/**
* Gives read access to the calendar, but all events the user is not participating are private!
* Used by addressbook.
*/
define('EGW_ACL_READ_FOR_PARTICIPANTS',EGW_ACL_CUSTOM_1);
define('EGW_ACL_FREEBUSY',EGW_ACL_CUSTOM_2);
/**
* Allows to invite an other user (if configured to be used!)
*/
define('EGW_ACL_INVITE',EGW_ACL_CUSTOM_3);
/**
* Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
*/
@ -56,6 +49,20 @@ require_once(EGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_so.inc.php');
*/
class calendar_bo
{
/**
* Gives read access to the calendar, but all events the user is not participating are private!
* Used by addressbook.
*/
const ACL_READ_FOR_PARTICIPANTS = Acl::CUSTOM1;
/**
* Right to see free/busy data only
*/
const ACL_FREEBUSY = Acl::CUSTOM2;
/**
* Allows to invite an other user (if configured to be used!)
*/
const ACL_INVITE = Acl::CUSTOM3;
/**
* @var int $debug name of method to debug or level of debug-messages:
* False=Off as higher as more messages you get ;-)
@ -196,7 +203,7 @@ class calendar_bo
/**
* Instance of the categories class
*
* @var categories
* @var Api\Categories
*/
var $categories;
@ -228,16 +235,16 @@ class calendar_bo
$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
$this->now = time();
$this->now_su = egw_time::server2user($this->now,'ts');
$this->now_su = Api\DateTime::server2user($this->now,'ts');
$this->user = $GLOBALS['egw_info']['user']['account_id'];
$this->grants = $GLOBALS['egw']->acl->get_grants('calendar');
if (!is_array($this->resources = $GLOBALS['egw']->session->appsession('resources','calendar')))
if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
{
$this->resources = array();
foreach($GLOBALS['egw']->hooks->process('calendar_resources') as $app => $data)
foreach(Api\Hooks::process('calendar_resources') as $app => $data)
{
if ($data && $data['type'])
{
@ -253,16 +260,16 @@ class calendar_bo
'type' => '',
'app' => 'api-accounts',
);
$GLOBALS['egw']->session->appsession('resources','calendar',$this->resources);
Api\Cache::setSession('calendar', 'resources', $this->resources);
}
//echo "registered resources="; _debug_array($this->resources);
$this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar Api\Config is under phpgwapi
$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
$this->categories = new categories($this->user,'calendar');
$this->categories = new Api\Categories($this->user,'calendar');
$this->customfields = config::get_customfields('calendar');
$this->customfields = Api\Storage\Customfields::get('calendar');
foreach($this->alarms as $secs => &$label)
{
@ -317,7 +324,7 @@ class calendar_bo
$data[] = array(
'res_id' => $id,
'email' => $email,
'rights' => EGW_ACL_READ_FOR_PARTICIPANTS,
'rights' => self::ACL_READ_FOR_PARTICIPANTS,
'name' => $name,
);
}
@ -372,7 +379,7 @@ class calendar_bo
foreach($_users as $user)
{
$user = trim($user);
if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$user))
if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
{
if ($user && !in_array($user,$users)) // already added?
{
@ -398,7 +405,7 @@ class calendar_bo
{
// use only members which gave the user a read-grant
if (!in_array($member, $users) &&
($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$member)))
($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
{
$users[] = $member;
}
@ -443,7 +450,7 @@ class calendar_bo
* otherwise the original recuring event (with the first start- + enddate) is returned
* num_rows int number of entries to return, default or if 0, max_entries from the prefs
* order column-names plus optional DESC|ASC separted by comma
* ignore_acl if set and true no check_perms for a general EGW_ACL_READ grants is performed
* ignore_acl if set and true no check_perms for a general Acl::READ grants is performed
* enum_groups boolean if set and true, group-members will be added as participants with status 'G'
* cols string|array columns to select, if set an iterator will be returned
* append string to append to the query, eg. GROUP BY
@ -484,7 +491,7 @@ class calendar_bo
$params['private_grants'] = array();
foreach($this->grants as $user => $rights)
{
if ($rights & EGW_ACL_PRIVATE) $params['private_grants'][] = $user;
if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
}
}
@ -548,7 +555,7 @@ class calendar_bo
}
else
{
$is_private = !$this->check_perms(EGW_ACL_READ,$event);
$is_private = !$this->check_perms(Acl::READ,$event);
}
if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
{
@ -640,7 +647,7 @@ class calendar_bo
// no method, fall back to link title
if (is_null($app_data))
{
$is_private = !egw_link::title($app,$id);
$is_private = !Link::title($app,$id);
}
// boolean value to make all events of $app public (false) or private (true)
elseif (is_bool($app_data))
@ -658,7 +665,7 @@ class calendar_bo
/**
* Clears all non-private info from a privat event
*
* That function only returns the infos allowed to be viewed by people without EGW_ACL_PRIVATE grants
* That function only returns the infos allowed to be viewed by people without Acl::PRIVAT grants
*
* @param array &$event
* @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
@ -724,7 +731,7 @@ class calendar_bo
if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future
{
if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont,true), $maxdays);
$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
return;
}
if ($new_horizont < time()+31*DAY_s)
@ -745,11 +752,11 @@ class calendar_bo
$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
}
// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
$this->set_recurrences($event,egw_time::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time!
$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time!
}
}
// update the horizont
config::save_value('horizont',$this->config['horizont'],'calendar');
Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
}
@ -790,15 +797,15 @@ class calendar_bo
$exceptions = array();
foreach((array)$event['recur_exception'] as $exception)
{
$exceptions[] = egw_time::to($exception, true); // true = date
$exceptions[] = Api\DateTime::to($exception, true); // true = date
}
foreach($events as $event)
{
$is_exception = in_array(egw_time::to($event['start'], true), $exceptions);
$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
$start = $this->date2ts($event['start'],true);
if ($event['whole_day'])
{
$time = $this->so->startOfDay(new egw_time($event['end'], egw_time::$user_timezone));
$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
$time->setTime(23, 59, 59);
$end = $this->date2ts($time,true);
}
@ -806,7 +813,7 @@ class calendar_bo
{
$end = $this->date2ts($event['end'],true);
}
//error_log(__METHOD__."() start=".egw_time::to($start).", is_exception=".array2string($is_exception));
//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
}
}
@ -815,7 +822,7 @@ class calendar_bo
* Convert data read from the db, eg. convert server to user-time
*
* Also make sure all timestamps comming from DB as string are converted to integer,
* to avoid misinterpretation by egw_time as Ymd string.
* to avoid misinterpretation by Api\DateTime as Ymd string.
*
* @param array &$events array of event-arrays (reference)
* @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
@ -828,32 +835,32 @@ class calendar_bo
// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
if (empty($event['tzid']) && (!$event['tz_id'] || !($event['tzid'] = calendar_timezones::id2tz($event['tz_id']))))
{
$event['tzid'] = egw_time::$server_timezone->getName();
$event['tzid'] = Api\DateTime::$server_timezone->getName();
}
// database returns timestamps as string, convert them to integer
// to avoid misinterpretation by egw_time as Ymd string
// to avoid misinterpretation by Api\DateTime as Ymd string
// (this will fail on 32bit systems for times > 2038!)
$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls egw_time
$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
$event['end'] = (int)$event['end'];
$event['whole_day'] = self::isWholeDay($event);
if ($event['whole_day'] && $date_format != 'server')
{
// Adjust dates to user TZ
$stime =& $this->so->startOfDay(new egw_time((int)$event['start'], egw_time::$server_timezone), $event['tzid']);
$event['start'] = egw_time::to($stime, $date_format);
$time =& $this->so->startOfDay(new egw_time((int)$event['end'], egw_time::$server_timezone), $event['tzid']);
$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
$event['start'] = Api\DateTime::to($stime, $date_format);
$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
$time->setTime(23, 59, 59);
$event['end'] = egw_time::to($time, $date_format);
$event['end'] = Api\DateTime::to($time, $date_format);
if (!empty($event['recurrence']))
{
$time =& $this->so->startOfDay(new egw_time((int)$event['recurrence'], egw_time::$server_timezone), $event['tzid']);
$event['recurrence'] = egw_time::to($time, $date_format);
$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
$event['recurrence'] = Api\DateTime::to($time, $date_format);
}
if (!empty($event['recur_enddate']))
{
$time =& $this->so->startOfDay(new egw_time((int)$event['recur_enddate'], egw_time::$server_timezone), $event['tzid']);
$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
$time->setTime(23, 59, 59);
$event['recur_enddate'] = egw_time::to($time, $date_format);
$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
}
$timestamps = array('modified','created');
}
@ -877,8 +884,8 @@ class calendar_bo
if ($event['whole_day'] && $date_format != 'server')
{
// Adjust dates to user TZ
$time =& $this->so->startOfDay(new egw_time((int)$date, egw_time::$server_timezone), $event['tzid']);
$date = egw_time::to($time, $date_format);
$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
$date = Api\DateTime::to($time, $date_format);
}
else
{
@ -908,7 +915,7 @@ class calendar_bo
{
if (empty($ts) || $date_format == 'server') return $ts;
return egw_time::server2user($ts,$date_format);
return Api\DateTime::server2user($ts,$date_format);
}
/**
@ -918,7 +925,7 @@ class calendar_bo
* @param mixed $date =null date to specify a single event of a series
* @param boolean $ignore_acl should we ignore the acl, default False for a single id, true for multiple id's
* @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in servertime, 'array'=array, or string with date-format
* @param array|int $clear_private_infos_users =null if not null, return events with EGW_ACL_FREEBUSY too,
* @param array|int $clear_private_infos_users =null if not null, return events with self::ACL_FREEBUSY too,
* but call clear_private_infos() with the given users
* @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
*/
@ -930,7 +937,7 @@ class calendar_bo
$return = null;
$check = $clear_private_infos_users ? EGW_ACL_FREEBUSY : EGW_ACL_READ;
$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
{
if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
@ -961,7 +968,7 @@ class calendar_bo
$return = self::$cached_event;
}
}
if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(EGW_ACL_READ,$return))
if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
{
$this->clear_private_infos($return, (array)$clear_private_infos_users);
}
@ -1000,7 +1007,7 @@ class calendar_bo
// if $end is before recur_enddate, use it instead
if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
{
//echo "<p>recur_enddate={$event['recur_enddate']}=".egw_time::to($event['recur_enddate'])." > end=$end=".egw_time::to($end)." --> using end instead of recur_enddate</p>\n";
//echo "<p>recur_enddate={$event['recur_enddate']}=".Api\DateTime::to($event['recur_enddate'])." > end=$end=".Api\DateTime::to($end)." --> using end instead of recur_enddate</p>\n";
// insert at least the event itself, if it's behind the horizont
$event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end;
}
@ -1091,7 +1098,7 @@ class calendar_bo
{
static $res_info_cache = array();
if (!is_scalar($uid)) throw new egw_exception_wrong_parameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
if (!isset($res_info_cache[$uid]))
{
@ -1136,7 +1143,7 @@ class calendar_bo
* Note: Participating in an event is considered as haveing read-access on that event,
* even if you have no general read-grant from that user.
*
* @param int $needed necessary ACL right: EGW_ACL_{READ|EDIT|DELETE}
* @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE}
* @param mixed $event event as array or the event-id or 0 for a general check
* @param int $other uid to check (if event==0) or 0 to check against $this->user
* @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
@ -1185,9 +1192,9 @@ class calendar_bo
$grant = $grants[$owner];
// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
if ($grant & ~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY;
if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
if (is_array($event) && ($needed == EGW_ACL_READ || $needed == EGW_ACL_FREEBUSY))
if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
{
// Check if the $user is one of the participants or has a read-grant from one of them
// in that case he has an implicite READ grant for that event
@ -1199,19 +1206,19 @@ class calendar_bo
if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
{
// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
$grant |= EGW_ACL_FREEBUSY | EGW_ACL_READ | EGW_ACL_PRIVATE;
$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
break;
}
elseif ($grants[$uid] & EGW_ACL_READ)
elseif ($grants[$uid] & Acl::READ)
{
// if we have a READ grant from a participant, we dont give an implicit privat grant too
$grant |= EGW_ACL_READ;
$grant |= Acl::READ;
// we cant break here, as we might be a participant too, and would miss the privat grant
}
elseif (!is_numeric($uid))
{
// if the owner only grants EGW_ACL_FREEBUSY we are not interested in the recources explicit rights
if ($grant == EGW_ACL_FREEBUSY) continue;
// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
if ($grant == self::ACL_FREEBUSY) continue;
// if we have a resource as participant
$resource = $this->resource_info($uid);
$grant |= $resource['rights'];
@ -1219,17 +1226,17 @@ class calendar_bo
}
}
}
if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == EGW_ACL_ADD)
if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
{
$access = False; // a group can't be the owner of an event
}
else
{
$access = $user == $owner || $grant & $needed
&& ($needed == EGW_ACL_FREEBUSY || !$private || $grant & EGW_ACL_PRIVATE);
&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
}
// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
if ($access && $needed == EGW_ACL_DELETE && $event['deleted'] &&
if ($access && $needed == Acl::DELETE && $event['deleted'] &&
!$GLOBALS['egw_info']['user']['apps']['admin'] &&
$GLOBALS['egw_info']['server']['calendar_delete_history'] != 'userpurge')
{
@ -1254,7 +1261,7 @@ class calendar_bo
*/
static function date2ts($date,$user2server=False)
{
return $user2server ? egw_time::user2server($date,'ts') : egw_time::to($date,'ts');
return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
}
/**
@ -1266,7 +1273,7 @@ class calendar_bo
*/
static function date2array($date,$server2user=False)
{
return $server2user ? egw_time::server2user($date,'array') : egw_time::to($date,'array');
return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
}
/**
@ -1279,7 +1286,7 @@ class calendar_bo
*/
static function date2string($date,$server2user=False,$format='Ymd')
{
return $server2user ? egw_time::server2user($date,$format) : egw_time::to($date,$format);
return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
}
/**
@ -1291,7 +1298,7 @@ class calendar_bo
*/
static function format_date($date,$format='')
{
return egw_time::to($date,$format);
return Api\DateTime::to($date,$format);
}
/**
@ -1317,12 +1324,12 @@ class calendar_bo
{
static $acl2string = array(
0 => 'ACL-UNKNOWN',
EGW_ACL_READ => 'ACL_READ',
EGW_ACL_ADD => 'ACL_ADD',
EGW_ACL_EDIT => 'ACL_EDIT',
EGW_ACL_DELETE => 'ACL_DELETE',
EGW_ACL_PRIVATE => 'ACL_PRIVATE',
EGW_ACL_FREEBUSY => 'ACL_FREEBUSY',
Acl::READ => 'ACL_READ',
Acl::ADD => 'ACL_ADD',
Acl::EDIT => 'ACL_EDIT',
Acl::DELETE => 'ACL_DELETE',
Acl::PRIVAT => 'ACL_PRIVATE',
self::ACL_FREEBUSY => 'ACL_FREEBUSY',
);
for($i = 2; $i < func_num_args(); ++$i)
{
@ -1521,7 +1528,7 @@ class calendar_bo
}
else
{
$id2lid[$id] = common::grab_owner_name($id);
$id2lid[$id] = Api\Accounts::username($id);
$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
}
}
@ -1554,19 +1561,19 @@ class calendar_bo
switch($status[0])
{
case 'A': // accepted
$status = html::image('calendar','accepted',$lang_status);
$status = Api\Html::image('calendar','accepted',$lang_status);
break;
case 'R': // rejected
$status = html::image('calendar','rejected',$lang_status);
$status = Api\Html::image('calendar','rejected',$lang_status);
break;
case 'T': // tentative
$status = html::image('calendar','tentative',$lang_status);
$status = Api\Html::image('calendar','tentative',$lang_status);
break;
case 'U': // no response = unknown
$status = html::image('calendar','needs-action',$lang_status);
$status = Api\Html::image('calendar','needs-action',$lang_status);
break;
case 'D': // delegated
$status = html::image('calendar','forward',$lang_status);
$status = Api\Html::image('calendar','forward',$lang_status);
break;
case 'G': // group invitation
// Todo: Image, seems not to be used
@ -1578,7 +1585,7 @@ class calendar_bo
{
$status = '('.$lang_status.')';
}
$names[$id] = html::htmlspecialchars($this->participant_name($id)).($quantity > 1 ? ' ('.$quantity.')' : '').' '.$status;
$names[$id] = Api\Html::htmlspecialchars($this->participant_name($id)).($quantity > 1 ? ' ('.$quantity.')' : '').' '.$status;
// add role, if not a regular participant
if ($role != 'REQ-PARTICIPANT')
@ -1623,7 +1630,7 @@ class calendar_bo
if (!isset($id2cat[$cat_id]))
{
$id2cat[$cat_id] = categories::read($cat_id);
$id2cat[$cat_id] = Api\Categories::read($cat_id);
}
$cat = $id2cat[$cat_id];
@ -1646,7 +1653,7 @@ class calendar_bo
*/
private static function _list_cals_add($id,&$users,&$groups)
{
$name = common::grab_owner_name($id);
$name = Api\Accounts::username($id);
if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
{
return; // do not return no longer existing accounts which eg. still mentioned in acl
@ -1698,7 +1705,7 @@ class calendar_bo
{
self::_list_cals_add($group,$users,$groups);
if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,EGW_ACL_READ,'calendar')))
if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
{
foreach($account_perms as $id)
{
@ -1759,7 +1766,7 @@ class calendar_bo
if (!$this->cached_holidays) // try reading the holidays from the session
{
$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar');
$this->cached_holidays = Api\Cache::getSession('calendar', 'holidays');
}
if (!isset($this->cached_holidays[$year]))
{
@ -1773,7 +1780,7 @@ class calendar_bo
// search for birthdays
if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
{
$contacts = new addressbook_bo();
$contacts = new Api\Contacts();
$filter = array(
'n_family' => "!''",
'bday' => "!''",
@ -1813,7 +1820,7 @@ class calendar_bo
}
}
// store holidays and birthdays in the session
$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar',$this->cached_holidays);
$this->cached_holidays = Api\Cache::setSession('calendar', 'holidays', $this->cached_holidays);
}
if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
{
@ -1880,13 +1887,13 @@ class calendar_bo
case 'participants':
foreach (array_keys($event[$val]) as $key)
{
$extra_fields [$val] = accounts::id2name($key, 'account_fullname');
$extra_fields [$val] = Api\Accounts::id2name($key, 'account_fullname');
}
break;
case 'modifier':
case 'creator':
case 'owner':
$extra_fields [$val] = accounts::id2name($event[$val], 'account_fullname');
$extra_fields [$val] = Api\Accounts::id2name($event[$val], 'account_fullname');
break;
default:
$extra_fields [] = $event[$val];
@ -1929,7 +1936,7 @@ class calendar_bo
* Check access to the file store
*
* @param int $id id of entry
* @param int $check EGW_ACL_READ for read and EGW_ACL_EDIT for write or delete access
* @param int $check Acl::READ for read and Acl::EDIT for write or delete access
* @param string $rel_path =null currently not used in calendar
* @param int $user =null for which user to check, default current user
* @return boolean true if access is granted or false otherwise
@ -1948,11 +1955,11 @@ class calendar_bo
*/
function check_set_default_prefs()
{
if ($this->cal_prefs['interval'] && ($set = $GLOBALS['egw']->session->appsession('default_prefs_set','calendar')))
if ($this->cal_prefs['interval'] && ($set = Api\Cache::getSession('calendar', 'default_prefs_set')))
{
return;
}
$GLOBALS['egw']->session->appsession('default_prefs_set','calendar','set');
Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
$forced_prefs =& $GLOBALS['egw']->preferences->forced['calendar'];
@ -2088,7 +2095,7 @@ class calendar_bo
}
$content = array(
'info_cat' => $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $calendar['category']),
'info_cat' => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
'info_priority' => $calendar['priority'] ,
'info_public' => $calendar['public'] != 'private',
'info_subject' => $calendar['title'],
@ -2104,9 +2111,9 @@ class calendar_bo
$content['link_app'][] = $calendar['info_link']['app'];
$content['link_id'][] = $calendar['info_link']['id'];
// Copy claendar's links
foreach(egw_link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
{
if ($link['app'] != egw_link::VFS_APPNAME)
if ($link['app'] != Link::VFS_APPNAME)
{
$content['link_app'][] = $link['app'];
$content['link_id'][] = $link['id'];
@ -2117,7 +2124,7 @@ class calendar_bo
}
}
// Copy same custom fields
foreach(array_keys(config::get_customfields('infolog')) as $name)
foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
{
if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
}
@ -2140,7 +2147,7 @@ class calendar_bo
{
$set['ts_start'] = $event['start'];
$set['ts_title'] = $this->link_title($event);
$set['start_time'] = egw_time::to($event['start'],'H:i');
$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
$set['ts_description'] = $event['description'];
if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
$set['ts_duration'] = ($event['end'] - $event['start']) / 60;
@ -2148,9 +2155,9 @@ class calendar_bo
$set['end_time'] = null; // unset end-time
$set['cat_id'] = (int)$event['category'];
foreach(egw_link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
{
if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME)
if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
{
$set['link_app'][] = $link['app'];
$set['link_id'][] = $link['id'];

View File

@ -6,11 +6,15 @@
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Joerg Lehrke <jlehrke@noc.de>
* @copyright (c) 2005-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2005-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
// types of messsages send by calendar_boupdate::send_update
define('MSG_DELETED',0);
define('MSG_MODIFIED',1);
@ -148,11 +152,11 @@ class calendar_boupdate extends calendar_bo
}
// check if user has the permission to update / create the event
if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT,$event['id']) ||
$new_event && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner'])) &&
!$this->check_perms(EGW_ACL_ADD,0,$event['owner']))
if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) ||
$new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) &&
!$this->check_perms(Acl::ADD,0,$event['owner']))
{
$messages[] = lang('Access to calendar of %1 denied!',common::grab_owner_name($event['owner']));
$messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner']));
return false;
}
if ($new_event)
@ -338,7 +342,7 @@ class calendar_boupdate extends calendar_bo
foreach($conflicts as $key => $conflict)
{
$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
if (!$this->check_perms(EGW_ACL_READ,$conflict))
if (!$this->check_perms(Acl::READ,$conflict))
{
$conflicts[$key] = array(
'id' => $conflict['id'],
@ -371,7 +375,7 @@ class calendar_boupdate extends calendar_bo
if($old_event['deleted'] && $event['deleted'] == null)
{
// Restored, bring back links
egw_link::restore('calendar', $cal_id);
Link::restore('calendar', $cal_id);
}
if ($this->log_file)
{
@ -391,7 +395,7 @@ class calendar_boupdate extends calendar_bo
}
// notify the link-class about the update, as other apps may be subscribt to it
egw_link::notify_update('calendar',$cal_id,$event);
Link::notify_update('calendar',$cal_id,$event);
return $cal_id;
}
@ -446,7 +450,7 @@ class calendar_boupdate extends calendar_bo
}
else
{
$ret = $this->check_perms(EGW_ACL_INVITE,0,$uid);
$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
}
//error_log(__METHOD__."($uid) = ".array2string($ret));
//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@ -608,7 +612,7 @@ class calendar_boupdate extends calendar_bo
}
if ($account_id)
{
$pref_obj = new preferences($account_id);
$pref_obj = new Api\Preferences($account_id);
$prefs = $pref_obj->read_repository();
}
else
@ -771,11 +775,11 @@ class calendar_boupdate extends calendar_bo
}
}
$user_prefs = $GLOBALS['egw_info']['user']['preferences'];
$startdate = new egw_time($event['start']);
$enddate = new egw_time($event['end']);
$modified = new egw_time($event['modified']);
if ($old_event) $olddate = new egw_time($old_event['start']);
//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
$startdate = new Api\DateTime($event['start']);
$enddate = new Api\DateTime($event['end']);
$modified = new Api\DateTime($event['modified']);
if ($old_event) $olddate = new Api\DateTime($old_event['start']);
//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
$owner_prefs = $ics = null;
foreach($to_notify as $userid => $statusid)
{
@ -789,7 +793,7 @@ class calendar_boupdate extends calendar_bo
// check if responsible of a resource has read rights on event (might be private!)
if ($res_info['app'] == 'resources' && $res_info['responsible'] &&
!$this->check_perms(EGW_ACL_READ, $event, 0, 'ts', null, $res_info['responsible']))
!$this->check_perms(Acl::READ, $event, 0, 'ts', null, $res_info['responsible']))
{
// --> use only details from (private-)cleared event only containing resource ($userid)
// reading server timezone, to be able to use cleared event for iCal generation further down
@ -804,7 +808,7 @@ class calendar_boupdate extends calendar_bo
// check if event-owner wants non-EGroupware users notified
if (is_null($owner_prefs))
{
$preferences = new preferences($owner);
$preferences = new Api\Preferences($owner);
$owner_prefs = $preferences->read_repository();
}
if ($role != 'CHAIR' && // always notify externals CHAIRs
@ -830,16 +834,16 @@ class calendar_boupdate extends calendar_bo
$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
if (is_numeric($userid))
{
$preferences = new preferences($userid);
$preferences = new Api\Preferences($userid);
$GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository();
$GLOBALS['egw']->accounts->get_account_name($userid,$lid,$tfn,$tln);
$fullname = common::display_fullname('',$tfn,$tln);
$fullname = Api\Accounts::format_username('',$tfn,$tln);
}
else // external email address: use preferences of event-owner, plus some hardcoded settings (eg. ical notification)
else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification)
{
if (is_null($owner_prefs))
{
$preferences = new preferences($owner);
$preferences = new Api\Preferences($owner);
$GLOBALS['egw_info']['user']['preferences'] = $owner_prefs = $preferences->read_repository();
}
$part_prefs = $owner_prefs;
@ -858,7 +862,7 @@ class calendar_boupdate extends calendar_bo
if ($lang !== $part_prefs['common']['lang'])
{
translation::init();
Api\Translation::init();
$lang = $part_prefs['common']['lang'];
}
$event_arr = null;
@ -890,7 +894,7 @@ class calendar_boupdate extends calendar_bo
$details['enddate'] = $enddate->format($timeformat);
$modified->setTimezone($timezone);
$details['updated'] = $modified->format($timeformat) . ', ' . common::grab_owner_name($event['modifier']);
$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
if ($old_event != False)
{
@ -1000,7 +1004,7 @@ class calendar_boupdate extends calendar_bo
}
if ($lang !== $GLOBALS['egw_info']['user']['preferences']['common']['lang'])
{
translation::init();
Api\Translation::init();
}
// restore timezone, in case we had to reset it to server-timezone
if ($restore_tz) date_default_timezone_set($restore_tz);
@ -1029,7 +1033,7 @@ class calendar_boupdate extends calendar_bo
//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
$event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
{
return False; // event not found
@ -1038,7 +1042,7 @@ class calendar_boupdate extends calendar_bo
{
$to_notify = $event['participants'];
}
elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner]
elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner]
{
$to_notify[$alarm['owner']] = 'A';
}
@ -1047,7 +1051,7 @@ class calendar_boupdate extends calendar_bo
return False; // no rights
}
// need to load calendar translations and set currentapp, so calendar can reload a different lang
translation::add_app('calendar');
Api\Translation::add_app('calendar');
$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
@ -1081,9 +1085,9 @@ class calendar_boupdate extends calendar_bo
//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
// check if user has the permission to update / create the event
if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT,$event['id']) ||
!$event['id'] && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner']) &&
!$this->check_perms(EGW_ACL_ADD,0,$event['owner'])))
if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
!$this->check_perms(Acl::ADD,0,$event['owner'])))
{
return false;
}
@ -1105,32 +1109,32 @@ class calendar_boupdate extends calendar_bo
{
if (!empty($event['start']))
{
$time = $this->so->startOfDay(new egw_time($event['start'], egw_time::$user_timezone));
$event['start'] = egw_time::to($time, 'ts');
$time = $this->so->startOfDay(new Api\DateTime($event['start'], Api\DateTime::$user_timezone));
$event['start'] = Api\DateTime::to($time, 'ts');
$save_event['start'] = $time;
}
if (!empty($event['end']))
{
$time = new egw_time($event['end'], egw_time::$user_timezone);
$time = new Api\DateTime($event['end'], Api\DateTime::$user_timezone);
$time->setTime(23, 59, 59);
$event['end'] = egw_time::to($time, 'ts');
$event['end'] = Api\DateTime::to($time, 'ts');
$save_event['end'] = $time;
}
if (!empty($event['recurrence']))
{
$time = $this->so->startOfDay(new egw_time($event['recurrence'], egw_time::$user_timezone));
$event['recurrence'] = egw_time::to($time, 'ts');
$time = $this->so->startOfDay(new Api\DateTime($event['recurrence'], Api\DateTime::$user_timezone));
$event['recurrence'] = Api\DateTime::to($time, 'ts');
}
if (!empty($event['recur_enddate']))
{
$time = $this->so->startOfDay(new egw_time($event['recur_enddate'], egw_time::$user_timezone));
$event['recur_enddate'] = egw_time::to($time, 'ts');
$time = $this->so->startOfDay(new Api\DateTime($event['recur_enddate'], Api\DateTime::$user_timezone));
$event['recur_enddate'] = Api\DateTime::to($time, 'ts');
$time->setUser();
$save_event['recur_enddate'] = egw_time::to($time, 'ts');
$save_event['recur_enddate'] = Api\DateTime::to($time, 'ts');
}
$timestamps = array('modified','created');
// all-day events are handled in server time
$event['tzid'] = $save_event['tzid'] = egw_time::$server_timezone->getName();
$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
}
else
{
@ -1145,7 +1149,7 @@ class calendar_boupdate extends calendar_bo
// convert tzid name to integer tz_id, of set user default
if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
{
$event['tz_id'] = calendar_timezones::tz2id($event['tzid'] = egw_time::$user_timezone->getName());
$event['tz_id'] = calendar_timezones::tz2id($event['tzid'] = Api\DateTime::$user_timezone->getName());
}
// same with the recur exceptions
if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@ -1154,8 +1158,8 @@ class calendar_boupdate extends calendar_bo
{
if ($event['whole_day'])
{
$time = $this->so->startOfDay(new egw_time($date, egw_time::$user_timezone));
$date = egw_time::to($time, 'ts');
$time = $this->so->startOfDay(new Api\DateTime($date, Api\DateTime::$user_timezone));
$date = Api\DateTime::to($time, 'ts');
}
else
{
@ -1236,7 +1240,7 @@ class calendar_boupdate extends calendar_bo
calendar_so::split_user($uid, $user_type, $user_id);
if ($user_type == 'c' && (!$old_event || !isset($old_event['participants'][$uid])))
{
egw_link::link('calendar', $cal_id, 'addressbook', $user_id);
Link::link('calendar', $cal_id, 'addressbook', $user_id);
}
}
}
@ -1264,9 +1268,9 @@ class calendar_boupdate extends calendar_bo
{
if (!is_array($event) && !($event = $this->read($event))) return false;
return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']);
return $this->check_perms(Acl::EDIT,0,$event['owner']);
}
// check if we have a category acl for the event or not (null)
// check if we have a category Acl for the event or not (null)
$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
if (!is_null($access))
{
@ -1277,7 +1281,7 @@ class calendar_boupdate extends calendar_bo
{
$resource = $this->resource_info($uid);
return EGW_ACL_EDIT & $resource['rights'];
return Acl::EDIT & $resource['rights'];
}
if (!is_array($event) && !($event = $this->read($event))) return false;
@ -1287,7 +1291,7 @@ class calendar_boupdate extends calendar_bo
$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
}
$memberships[] = $uid;
return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT,0,$uid);
return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
}
/**
@ -1343,7 +1347,7 @@ class calendar_boupdate extends calendar_bo
{
if (!isset(self::$cat_rights_cache))
{
self::$cat_rights_cache = egw_cache::getSession('calendar','cat_rights',
self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
}
//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
@ -1375,7 +1379,7 @@ class calendar_boupdate extends calendar_bo
if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
}
egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
}
}
@ -1534,7 +1538,7 @@ class calendar_boupdate extends calendar_bo
{
//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
if (!($event = $this->read($cal_id,$recur_date)) ||
!$ignore_acl && !$this->check_perms(EGW_ACL_DELETE,$event))
!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
{
return false;
}
@ -1547,18 +1551,18 @@ class calendar_boupdate extends calendar_bo
if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
{
$config = config::read('phpgwapi');
$config = Api\Config::read('phpgwapi');
if(!$config['calendar_delete_history'] || $event['deleted'])
{
$this->so->delete($cal_id);
// delete all links to the event
egw_link::unlink(0,'calendar',$cal_id);
Link::unlink(0,'calendar',$cal_id);
}
elseif ($config['calendar_delete_history'])
{
// mark all links to the event as deleted, but keep them
egw_link::unlink(0,'calendar',$cal_id,'','','',true);
Link::unlink(0,'calendar',$cal_id,'','','',true);
$event['deleted'] = $this->now;
$this->save($event, $ignore_acl);
@ -1585,7 +1589,7 @@ class calendar_boupdate extends calendar_bo
else
{
if (!($exception = $this->read($id))) continue;
$exception['uid'] = common::generate_uid('calendar', $id);
$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
$exception['reference'] = $exception['recurrence'] = 0;
$this->update($exception, true, true, false, true, $msg=null, true);
++$exceptions_kept;
@ -1753,12 +1757,12 @@ class calendar_boupdate extends calendar_bo
$var['owner'] = Array(
'field' => lang('Owner'),
'data' => common::grab_owner_name($event['owner'])
'data' => Api\Accounts::username($event['owner'])
);
$var['updated'] = Array(
'field' => lang('Updated'),
'data' => $this->format_date($event['modtime']).', '.common::grab_owner_name($event['modifier'])
'data' => $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier'])
);
$var['access'] = Array(
@ -1798,7 +1802,7 @@ class calendar_boupdate extends calendar_bo
echo "<p>error opening '$this->log_file' !!!</p>\n";
return false;
}
fwrite($f,$type.': '.common::grab_owner_name($this->user).': '.date('r')."\n");
fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
fwrite($f,"Time: time to save / saved time read back / old time before save\n");
foreach(array('start','end') as $name)
{
@ -1823,20 +1827,20 @@ class calendar_boupdate extends calendar_bo
*
* @param array $event
* @param array $old_event
* @param egw_time $instance_date For recurring events, this is the date we
* @param Api\DateTime $instance_date For recurring events, this is the date we
* are dealing with
*/
function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null)
function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
{
if ($old_event !== null && $event['start'] == $old_event['start']) return;
$time = new egw_time($event['start']);
$time = new Api\DateTime($event['start']);
if(!is_array($event['alarm']))
{
$event['alarm'] = $this->so->read_alarms($event['id']);
}
foreach($event['alarm'] as $id => &$alarm)
foreach($event['alarm'] as &$alarm)
{
if($event['recur_type'] != MCAL_RECUR_NONE)
{
@ -1860,7 +1864,7 @@ class calendar_boupdate extends calendar_bo
*/
function save_alarm($cal_id, $alarm, $update_modified=true)
{
if (!$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
{
//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
return false; // no rights to add the alarm
@ -1880,7 +1884,7 @@ class calendar_boupdate extends calendar_bo
{
list(,$cal_id) = explode(':',$id);
if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
{
return false; // no rights to delete the alarm
}
@ -1909,7 +1913,7 @@ class calendar_boupdate extends calendar_bo
{
foreach ($old_categories as $cat_id)
{
if (!$this->categories->check_perms(EGW_ACL_READ, $cat_id))
if (!$this->categories->check_perms(Acl::READ, $cat_id))
{
$old_cats_preserve[] = $cat_id;
}
@ -1962,7 +1966,7 @@ class calendar_boupdate extends calendar_bo
$cat_list = array();
foreach ($cat_id_list as $cat_id)
{
if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) &&
if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) &&
($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
{
$cat_list[] = $cat_name;
@ -2066,7 +2070,7 @@ class calendar_boupdate extends calendar_bo
foreach(array_keys($this->grants) as $user)
{
$user = trim($user);
if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user))
if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
{
if ($user && !in_array($user,$users)) // already added?
{
@ -2090,7 +2094,7 @@ class calendar_boupdate extends calendar_bo
{
// use only members which gave the user a read-grant
if (!in_array($member, $users) &&
$this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $member))
$this->check_perms(Acl::READ|self::ACL_FREEBUSY, 0, $member))
{
$users[] = $member;
}
@ -2203,7 +2207,7 @@ class calendar_boupdate extends calendar_bo
// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
{
$egwEvent['tzid'] = egw_time::$server_timezone->getName();
$egwEvent['tzid'] = Api\DateTime::$server_timezone->getName();
}
if (!isset(self::$tz_cache[$egwEvent['tzid']]))
{
@ -2211,7 +2215,7 @@ class calendar_boupdate extends calendar_bo
}
if (!$event['tzid'])
{
$event['tzid'] = egw_time::$server_timezone->getName();
$event['tzid'] = Api\DateTime::$server_timezone->getName();
}
if (!isset(self::$tz_cache[$event['tzid']]))
{
@ -2231,9 +2235,9 @@ class calendar_boupdate extends calendar_bo
// UID found
if (empty($event['recurrence']))
{
$egwstart = new egw_time($egwEvent['start'], egw_time::$server_timezone);
$egwstart = new Api\DateTime($egwEvent['start'], Api\DateTime::$server_timezone);
$egwstart->setTimezone(self::$tz_cache[$egwEvent['tzid']]);
$dtstart = new egw_time($event['start'], egw_time::$server_timezone);
$dtstart = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
$dtstart->setTimezone(self::$tz_cache[$event['tzid']]);
if ($egwEvent['recur_type'] == MCAL_RECUR_NONE &&
$event['recur_type'] == MCAL_RECUR_NONE ||
@ -2333,7 +2337,7 @@ class calendar_boupdate extends calendar_bo
$egwCategories = explode(',', $egwEvent['category']);
foreach ($egwCategories as $cat_id)
{
if ($this->categories->check_perms(EGW_ACL_READ, $cat_id) &&
if ($this->categories->check_perms(Acl::READ, $cat_id) &&
!in_array($cat_id, $event['category']))
{
if ($this->log)
@ -2590,7 +2594,7 @@ class calendar_boupdate extends calendar_bo
$egw_rrule->current = clone $egw_rrule->time;
while ($egw_rrule->valid())
{
$occurrence = egw_time::to($egw_rrule->current(), 'server');
$occurrence = Api\DateTime::to($egw_rrule->current(), 'server');
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@ -2659,13 +2663,13 @@ class calendar_boupdate extends calendar_bo
// check ACL
if (is_array($master_event))
{
$acl_edit = $this->check_perms(EGW_ACL_EDIT, $master_event['id']);
$acl_edit = $this->check_perms(Acl::EDIT, $master_event['id']);
}
else
{
if (is_array($stored_event))
{
$acl_edit = $this->check_perms(EGW_ACL_EDIT, $stored_event['id']);
$acl_edit = $this->check_perms(Acl::EDIT, $stored_event['id']);
}
else
{

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @package calendar
* @author RalfBecker-AT-outdoor-training.de
* @copyright (c) 2005-8 by RalfBecker-AT-outdoor-training.de
* @copyright (c) 2005-16 by RalfBecker-AT-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
/**
@ -22,6 +24,8 @@ class calendar_datasource extends datasource
*/
function __construct()
{
if (false) parent::__construct(); // can not be called, but gives IDE warning
$this->datasource('calendar');
$this->valid = PM_PLANNED_START|PM_PLANNED_END|PM_PLANNED_TIME|PM_RESOURCES|PM_CAT_ID;
@ -63,7 +67,7 @@ class calendar_datasource extends datasource
// return first global category, as PM only supports one
foreach($data['category'] ? explode(',', $data['category']) : array() as $cat_id)
{
if (categories::is_global($cat_id))
if (Api\Categories::is_global($cat_id))
{
$ds['cat_id'] = $cat_id;
break;
@ -75,13 +79,14 @@ class calendar_datasource extends datasource
// if the event spans multiple days, we have to substract the nights (24h - daily working time specified in PM)
if (($ds['pe_planned_time']/ 60 > 24) && date('Y-m-d',$ds['pe_planned_end']) != date('Y-m-d',$ds['pe_planned_start']))
{
$start = $end = null;
foreach(array('start','end') as $name)
{
$$name = $cal->date2array($ds['pe_planned_'.$name]);
${$name}['hour'] = 12;
${$name}['minute'] = ${$name}['second'] = 0;
unset(${$name}['raw']);
$$name = $cal->date2ts($$name);
$arr = $cal->date2array($ds['pe_planned_'.$name]);
$arr['hour'] = 12;
$arr['minute'] = ${$name}['second'] = 0;
unset($arr['raw']);
$$name = $cal->date2ts($arr);
}
$nights = round(($end - $start) / DAY_s);

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Calendar - importexport
* EGroupware - Calendar - importexport
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -136,7 +136,7 @@ class calendar_egw_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function copy ( $_dst_identifier ) {
unset($_dst_identifier); // not used
}
/**
@ -147,7 +147,7 @@ class calendar_egw_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function move ( $_dst_identifier ) {
unset($_dst_identifier); // not used
}
/**
@ -165,5 +165,4 @@ class calendar_egw_record implements importexport_iface_egw_record
public function __destruct() {
}
} // end of calendar_egw_record
?>
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare
* EGroupware calendar export
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -11,13 +11,15 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* export CSV plugin of calendar
*/
class calendar_export_csv implements importexport_iface_export_plugin {
public function __construct() {
translation::add_app('calendar');
Api\Translation::add_app('calendar');
$this->bo = new calendar_bo();
$this->get_selects();
}
@ -30,8 +32,8 @@ class calendar_export_csv implements importexport_iface_export_plugin {
public function export( $_stream, importexport_definition $_definition) {
$options = $_definition->plugin_options;
$limit_exception = bo_merge::is_export_limit_excepted();
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar');
// Custom fields need to be specifically requested
$cfs = array();
foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
@ -55,31 +57,31 @@ class calendar_export_csv implements importexport_iface_export_plugin {
'users' => $options['criteria']['owner'],
'cfs' => $cfs // Otherwise we shouldn't get any custom fields
);
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
$query['offset'] = 0;
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}
$events =& $this->bo->search($query);
break;
case 'search_results':
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
$states = Api\Cache::getSession('calendar', 'session_data');
if($states['view'] == 'listview') {
$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
$query = Api\Cache::getSession('calendar', 'calendar_list');
$query['num_rows'] = -1; // all
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
$query['start'] = 0;
$query['cfs'] = $cfs;
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}
$ui = new calendar_uilist();
$ui->get_rows($query, $events, $unused);
} else {
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
$query = Api\Cache::getSession('calendar', 'session_data');
$query['users'] = explode(',', $query['owner']);
$query['num_rows'] = -1;
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}
@ -238,7 +240,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
*/
public function get_selectors_etpl($definition = null) {
$states = $this->bo->cal_prefs['saved_states'];
$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
$list = Api\Cache::getSession('calendar', 'calendar_list');
if(!$list['startdate'])
{
switch($states['view']) {
@ -253,23 +255,23 @@ class calendar_export_csv implements importexport_iface_export_plugin {
$query = $this->get_query_day($states);
break;
}
$start= new egw_time($query['start']);
$end = new egw_time($query['end']);
$start= new Api\DateTime($query['start']);
$end = new Api\DateTime($query['end']);
}
else
{
$start= new egw_time($list['startdate']);
$end = new egw_time($list['enddate']);
$start= new Api\DateTime($list['startdate']);
$end = new Api\DateTime($list['enddate']);
}
if ($states['view'] == 'listview')
{
$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
$list = Api\Cache::getSession('calendar', 'calendar_list');
// Use UI to get dates
$ui = new calendar_uilist();
$list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
$ui->get_rows($list,$rows,$readonlys);
$start = $ui->first ? $ui->first : new egw_time($ui->date);
$start = $ui->first ? $ui->first : new Api\DateTime($ui->date);
$end = $ui->last;
// Special handling

View File

@ -11,6 +11,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* iCal export plugin of calendar
*/
@ -29,8 +31,8 @@ class calendar_export_ical extends calendar_export_csv {
// Custom fields need to be specifically requested
$cfs = array();
$limit_exception = bo_merge::is_export_limit_excepted();
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar');
if($options['selection'] == 'criteria')
{
@ -42,7 +44,7 @@ class calendar_export_ical extends calendar_export_csv {
'users' => $options['criteria']['owner'],
'cfs' => $cfs // Otherwise we shouldn't get any custom fields
);
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
$query['offset'] = 0;
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}
@ -51,15 +53,15 @@ class calendar_export_ical extends calendar_export_csv {
// Scheduled export will use 'all', which we don't allow through UI
elseif ($options['selection'] == 'search_results' || $options['selection'] == 'all')
{
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
$states = Api\Cache::getSession('calendar', 'session_data');
if($states['view'] == 'listview')
{
$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
$query = Api\Cache::getSession('calendar', 'calendar_list');
$query['num_rows'] = -1; // all
$query['start'] = 0;
$query['cfs'] = $cfs;
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}
$ui = new calendar_uilist();
@ -68,10 +70,10 @@ class calendar_export_ical extends calendar_export_csv {
}
else
{
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
$query = Api\Cache::getSession('calendar', 'session_data');
$query['users'] = explode(',', $query['owner']);
$query['num_rows'] = -1;
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
{
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
}

View File

@ -5,13 +5,14 @@
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
* @subpackage groupdav
* @subpackage caldav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Acl;
/**
* CalDAV/CardDAV/GroupDAV access: Calendar handler
@ -270,7 +271,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
function output_vcalendar($files)
{
// todo ETag logic with CTag to not download unchanged calendar again
html::content_header('calendar.ics', 'text/calendar');
Api\Header\Content::type('calendar.ics', 'text/calendar');
$n = 0;
foreach($files as $file)
@ -306,7 +307,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
{
echo "END:VCALENDAR\n";
}
common::egw_exit();
exit();
}
/**
@ -831,7 +832,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
return $oldEvent;
}
if (is_null($oldEvent) && ($user >= 0 && !$this->bo->check_perms(EGW_ACL_ADD, 0, $user) ||
if (is_null($oldEvent) && ($user >= 0 && !$this->bo->check_perms(Acl::ADD, 0, $user) ||
// if we require an extra invite grant, we fail if that does not exist (bind privilege is not given in that case)
$this->bo->require_acl_invite && $user && $user != $GLOBALS['egw_info']['user']['account_id'] &&
!$this->bo->check_acl_invite($user)))
@ -899,7 +900,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
}
}
// if no edit-rights (aka no organizer), update only attendee stuff: status and alarms
if (!$this->check_access(EGW_ACL_EDIT, $oldEvent))
if (!$this->check_access(Acl::EDIT, $oldEvent))
{
$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user, true);
$user_and_memberships[] = $user;
@ -937,12 +938,12 @@ class calendar_groupdav extends Api\CalDAV\Handler
!($oldEvent['recur_date'] == $event['recurrence'] || !$event['recurrence'] && !$oldEvent['recurrence']))
{
// if recurrence not found --> log it and continue with other recurrence
$this->caldav->log(__METHOD__."(,,$user) could NOT find recurrence=$event[recurrence]=".egw_time::to($event['recurrence']).' of event series! event='.array2string($event));
$this->caldav->log(__METHOD__."(,,$user) could NOT find recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).' of event series! event='.array2string($event));
continue;
}
}
}
if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".egw_time::to($event['recurrence']).", event=".array2string($event));
if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
if (isset($event['participants']) && isset($event['participants'][$user]) &&
$event['participants'][$user] !== $oldEvent['participants'][$user])
{
@ -950,13 +951,13 @@ class calendar_groupdav extends Api\CalDAV\Handler
// real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence!
$recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0))
{
if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".egw_time::to($recurrence).')');
if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
return '403 Forbidden';
}
else
{
++$modified;
if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".egw_time::to($recurrence).')');
if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
}
}
// import alarms, if given and changed
@ -986,7 +987,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
// lightning will pop up the alarm, as long as the Sequence (etag) does NOT change
// --> update the etag alone, if user has no edit rights
if ($this->agent == 'lightning' && !$this->check_access(EGW_ACL_EDIT, $oldEvent) &&
if ($this->agent == 'lightning' && !$this->check_access(Acl::EDIT, $oldEvent) &&
isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']]))
{
// just update etag in database
@ -1191,7 +1192,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
function free_busy_report($path,$options,$user)
{
unset($path); // unused, but required by function signature
if (!$this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user))
if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
{
return '403 Forbidden';
}
@ -1207,7 +1208,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
header('Content-Type: text/calendar');
echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok
exit(); // otherwise we get a 207 multistatus, not 200 Ok
}
/**
@ -1224,7 +1225,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
$privileges = parent::current_user_privileges($path, $user);
//error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges));
if ($this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user))
if ($this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
{
$privileges['read-free-busy'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'read-free-busy', '');
@ -1237,7 +1238,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
{
$privileges['schedule-deliver'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-deliver', '');
}
// remove bind privilege on other users or groups calendars, if calendar config require_acl_invite is set
// remove bind privilege on other users or groups calendars, if calendar Api\Config require_acl_invite is set
// and current user has no invite grant
if ($user && $user != $GLOBALS['egw_info']['user']['account_id'] && isset($privileges['bind']) &&
!$this->bo->check_acl_invite($user))
@ -1381,14 +1382,14 @@ class calendar_groupdav extends Api\CalDAV\Handler
$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server')) &&
if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
// above can be true, if current user is not in master but just a recurrence
(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
{
if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
return $retval;
}
if (!$this->bo->check_perms(EGW_ACL_READ, $event, 0, 'server'))
if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server'))
{
$this->bo->clear_private_infos($event, array($this->bo->user, $event['owner']));
}
@ -1466,16 +1467,16 @@ class calendar_groupdav extends Api\CalDAV\Handler
/**
* Check if user has the neccessary rights on an event
*
* @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE
* @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE
* @param array|int $event event-array or id
* @return boolean null if entry does not exist, false if no access, true if access permitted
*/
function check_access($acl,$event)
{
if ($acl == EGW_ACL_READ)
if ($acl == Acl::READ)
{
// we need at least EGW_ACL_FREEBUSY to get some information
$acl = EGW_ACL_FREEBUSY;
// we need at least calendar_bo::ACL_FREEBUSY to get some information
$acl = calendar_bo::ACL_FREEBUSY;
}
return $this->bo->check_perms($acl,$event,0,'server');
}
@ -1483,7 +1484,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
/**
* Add extra properties for calendar collections
*
* @param array $props regular props by the groupdav handler
* @param array $props regular props by the Api\CalDAV handler
* @param string $displayname
* @param string $base_uri =null base url of handler
* @param int $user =null account_id of owner of current collection

View File

@ -10,6 +10,11 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
/**
* diverse static calendar hooks
*/
@ -79,12 +84,12 @@ class calendar_hooks
static function admin()
{
$file = Array(
'Site Configuration' => egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
'Custom fields' => egw::link('/index.php','menuaction=admin.customfields.index&appname=calendar'),
'Calendar Holiday Management' => egw::link('/index.php','menuaction=calendar.uiholiday.admin'),
'Global Categories' => egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar'),
'Category ACL' => egw::link('/index.php','menuaction=calendar.calendar_uiforms.cat_acl'),
'Update timezones' => egw::link('/index.php','menuaction=calendar.calendar_timezones.update'),
'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
'Custom fields' => Egw::link('/index.php','menuaction=admin.customfields.index&appname=calendar'),
'Calendar Holiday Management' => Egw::link('/index.php','menuaction=calendar.uiholiday.admin'),
'Global Categories' => Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar'),
'Category ACL' => Egw::link('/index.php','menuaction=calendar.calendar_uiforms.cat_acl'),
'Update timezones' => Egw::link('/index.php','menuaction=calendar.calendar_timezones.update'),
);
display_section('calendar','calendar',$file);
}
@ -101,18 +106,6 @@ class calendar_hooks
$bo = new calendar_bo();
$bo->check_set_default_prefs();
}
$mainscreen = array(
'0' => lang('None'),
'day' => lang('Dayview'),
'day4' => lang('Four days view'),
'1' => lang('Weekview'),
'weekN' => lang('Multiple week view'),
'month' => lang('Monthview'),
'year' => lang('yearview'),
'planner_cat' => lang('Planner by category'),
'planner_user' => lang('Planner by user'),
'listview' => lang('Listview'),
);
$yesno = array(
'1' => lang('Yes'),
'0' => lang('No'),
@ -162,10 +155,7 @@ class calendar_hooks
'Saturday' => lang('Saturday')
);
for ($i=0; $i < 24; ++$i)
{
$times[$i] = $GLOBALS['egw']->common->formattime($i,'00');
}
$times = Api\Etemplate\Widget\Select::typeOptions('select-time', '');
for ($i = 2; $i <= 4; ++$i)
{
@ -209,7 +199,7 @@ class calendar_hooks
$options = array('0' => lang('none'));
foreach($GLOBALS['egw']->accounts->search(array('type' => 'owngroups','app' => 'calendar')) as $group)
{
$options[$group['account_id']] = common::grab_owner_name($group['account_id']);
$options[$group['account_id']] = Api\Accounts::username($group['account_id']);
}
$freebusy_url = calendar_bo::freebusy_url($GLOBALS['egw_info']['user']['account_lid'],$GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy_pw']);
$freebusy_url = '<a href="'.$freebusy_url.'" target="_blank">'.$freebusy_url.'</a>';
@ -218,7 +208,7 @@ class calendar_hooks
// Timezone for file exports
$export_tzs = array('0' => 'Use Event TZ');
$export_tzs += egw_time::getTimezones();
$export_tzs += Api\DateTime::getTimezones();
}
$link_title_options = ExecMethod('calendar.calendar_bo.get_link_options');
$settings = array(
@ -577,7 +567,7 @@ class calendar_hooks
'name' => 'default_document',
'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('calendar')).' '.
lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','calendar_title').' '.
lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
@ -589,7 +579,7 @@ class calendar_hooks
'name' => 'document_dir',
'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('calendar')).' '.
lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','calendar_title').' '.
lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
@ -772,7 +762,7 @@ END:VALARM';
/**
* Sync default alarms from CalDAV to Calendar
*
* Gets called by groupdav::PROPPATCH() for 'default-alarm-vevent-date(time)' changes
* Gets called by Api\CalDAV::PROPPATCH() for 'default-alarm-vevent-date(time)' changes
*/
public static function sync_default_alarms()
{
@ -791,25 +781,25 @@ END:VALARM';
/**
* ACL rights and labels used
*
* @param string|array string with location or array with parameters incl. "location", specially "owner" for selected acl owner
* @return array acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs
* @param string|array string with location or array with parameters incl. "location", specially "owner" for selected Acl owner
* @return array Acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs
*/
public static function acl_rights($params)
{
$rights = array(
acl::CUSTOM2 => 'freebusy',
acl::CUSTOM3 => 'invite',
acl::READ => 'read',
acl::ADD => 'add',
acl::EDIT => 'edit',
acl::DELETE => 'delete',
acl::PRIVAT => 'private',
Acl::CUSTOM2 => 'freebusy',
Acl::CUSTOM3 => 'invite',
Acl::READ => 'read',
Acl::ADD => 'add',
Acl::EDIT => 'edit',
Acl::DELETE => 'delete',
Acl::PRIVAT => 'private',
);
$require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
if (!$require_acl_invite || $require_acl_invite == 'groups' && !($params['owner'] < 0))
{
unset($rights[acl::CUSTOM3]);
unset($rights[Acl::CUSTOM3]);
}
return $rights;
}
@ -833,9 +823,11 @@ END:VALARM';
*/
public static function mail_import($args)
{
unset($args); // not used, but required by function signature
return array (
'menuaction' => 'calendar.calendar_uiforms.mail_import',
'popup' => egw_link::get_registry('calendar', 'edit_popup')
'popup' => Link::get_registry('calendar', 'edit_popup')
);
}
}
@ -846,11 +838,12 @@ function calendar_purge_old($config)
$id = 'calendar_purge';
// Cancel old purge
ExecMethod('phpgwapi.asyncservice.cancel_timer', $id);
$async = new Api\Asyncservice();
$async->cancel_timer($id);
if((float)$config > 0)
{
$result = ExecMethod2('phpgwapi.asyncservice.set_timer',
$result = $async->set_timer(
array('month' => '*', 'day' => 1),
$id,
'calendar.calendar_boupdate.purge',

View File

@ -13,6 +13,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Acl;
/**
* iCal import and export via Horde iCalendar classes
@ -179,7 +180,7 @@ class calendar_ical extends calendar_boupdate
if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
$this->clientProperties = $_clientProperties;
$this->vCalendar = new Horde_Icalendar;
$this->addressbook = new addressbook_bo;
$this->addressbook = new Api\Contacts;
}
@ -254,7 +255,7 @@ class calendar_ical extends calendar_boupdate
{
if ($this->read($event, $recurrence, true, 'server'))
{
if ($this->check_perms(EGW_ACL_FREEBUSY, $event, 0, 'server'))
if ($this->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server'))
{
$this->clear_private_infos($event, array($this->user, $event['owner']));
}
@ -360,7 +361,7 @@ class calendar_ical extends calendar_boupdate
{
// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
!in_array($tzid = egw_time::$user_timezone->getName(), $vtimezones_added) &&
!in_array($tzid = Api\DateTime::$user_timezone->getName(), $vtimezones_added) &&
calendar_timezones::add_vtimezone($vcal, $tzid))
{
$vtimezones_added[] = $tzid;
@ -606,8 +607,8 @@ class calendar_ical extends calendar_boupdate
$event['end-nextday'] = $event['end'] + 12*3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
{
$time = new egw_time($event[$f],egw_time::$server_timezone);
$arr = egw_time::to($time,'array');
$time = new Api\DateTime($event[$f],Api\DateTime::$server_timezone);
$arr = Api\DateTime::to($time,'array');
$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
array('VALUE' => 'DATE'));
}
@ -669,9 +670,9 @@ class calendar_ical extends calendar_boupdate
// use 'DATE' instead of 'DATE-TIME' on whole day events
foreach ($event['recur_exception'] as $id => $timestamp)
{
$time = new egw_time($timestamp,egw_time::$server_timezone);
$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
$time->setTimezone(self::$tz_cache[$event['tzid']]);
$arr = egw_time::to($time,'array');
$arr = Api\DateTime::to($time,'array');
$days[$id] = array(
'year' => $arr['year'],
'month' => $arr['month'],
@ -743,9 +744,9 @@ class calendar_ical extends calendar_boupdate
}
else
{
$time = new egw_time($recur_date,egw_time::$server_timezone);
$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
$time->setTimezone(self::$tz_cache[$event['tzid']]);
$arr = egw_time::to($time,'array');
$arr = Api\DateTime::to($time,'array');
$vevent->setAttribute($icalFieldName, array(
'year' => $arr['year'],
'month' => $arr['month'],
@ -765,9 +766,9 @@ class calendar_ical extends calendar_boupdate
}
else
{
$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
$time->setTimezone(self::$tz_cache[$event['tzid']]);
$arr = egw_time::to($time,'array');
$arr = Api\DateTime::to($time,'array');
$vevent->setAttribute($icalFieldName, array(
'year' => $arr['year'],
'month' => $arr['month'],
@ -990,12 +991,12 @@ class calendar_ical extends calendar_boupdate
{
foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
{
$valueData = translation::convert($valueData,translation::charset(),$charset);
$paramData = (array) translation::convert(is_array($value) ?
$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
$paramData = (array) Api\Translation::convert(is_array($value) ?
$parameters[$key][$valueID] : $parameters[$key],
translation::charset(),$charset);
$valuesData = (array) translation::convert($values[$key],
translation::charset(),$charset);
Api\Translation::charset(),$charset);
$valuesData = (array) Api\Translation::convert($values[$key],
Api\Translation::charset(),$charset);
$content = $valueData . implode(';', $valuesData);
if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
@ -1066,11 +1067,11 @@ class calendar_ical extends calendar_boupdate
{
if (empty($tzid) || $tzid == 'UTC')
{
return egw_time::to($time,'ts');
return Api\DateTime::to($time,'ts');
}
if (!is_a($time,'DateTime'))
{
$time = new egw_time($time,egw_time::$server_timezone);
$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
}
if (!isset(self::$tz_cache[$tzid]))
{
@ -1156,7 +1157,7 @@ class calendar_ical extends calendar_boupdate
}
else
{
$tzid = egw_time::$user_timezone->getName();
$tzid = Api\DateTime::$user_timezone->getName();
}
date_default_timezone_set($tzid);
@ -1186,7 +1187,7 @@ class calendar_ical extends calendar_boupdate
{
$event_info['type'] = $event['recur_type'] == MCAL_RECUR_NONE ?
'SINGLE' : 'SERIES-MASTER';
$event_info['acl_edit'] = $this->check_perms(EGW_ACL_EDIT, $cal_id);
$event_info['acl_edit'] = $this->check_perms(Acl::EDIT, $cal_id);
if (($event_info['stored_event'] = $this->read($cal_id, 0, false, 'server')) &&
$event_info['stored_event']['recur_type'] != MCAL_RECUR_NONE &&
($event_info['stored_event']['recur_type'] != $event['recur_type']
@ -1346,28 +1347,28 @@ class calendar_ical extends calendar_boupdate
if (!empty($event['whole_day']) && $event['tzid'] != $event_info['stored_event']['tzid'])
{
// Adjust dates to original TZ
$time = new egw_time($event['start'],egw_time::$server_timezone);
$time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone);
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
$event['start'] = egw_time::to($time,'server');
//$time = new egw_time($event['end'],egw_time::$server_timezone);
$event['start'] = Api\DateTime::to($time,'server');
//$time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone);
//$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
//$time->setTime(23, 59, 59);
$time->modify('+'.round(($event['end']-$event['start'])/DAY_s).' day');
$event['end'] = egw_time::to($time,'server');
$event['end'] = Api\DateTime::to($time,'server');
if ($event['recur_type'] != MCAL_RECUR_NONE)
{
foreach ($event['recur_exception'] as $key => $day)
{
$time = new egw_time($day,egw_time::$server_timezone);
$time = new Api\DateTime($day,Api\DateTime::$server_timezone);
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
$event['recur_exception'][$key] = egw_time::to($time,'server');
$event['recur_exception'][$key] = Api\DateTime::to($time,'server');
}
}
elseif ($event['recurrence'])
{
$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
$event['recurrence'] = egw_time::to($time,'server');
$event['recurrence'] = Api\DateTime::to($time,'server');
}
error_log(__METHOD__."() TZ adjusted {$event_info['stored_event']['tzid']} --> {$event['tzid']} event=".array2string($event));
}*/
@ -1400,7 +1401,7 @@ class calendar_ical extends calendar_boupdate
if (!is_null($user))
{
if ($user > 0 && $this->check_perms(EGW_ACL_ADD, 0, $user))
if ($user > 0 && $this->check_perms(Acl::ADD, 0, $user))
{
$event['owner'] = $user;
}
@ -1426,7 +1427,7 @@ class calendar_ical extends calendar_boupdate
// check if an owner is set and the current user has add rights
// for that owners calendar; if not set the current user
elseif (!isset($event['owner'])
|| !$this->check_perms(EGW_ACL_ADD, 0, $event['owner']))
|| !$this->check_perms(Acl::ADD, 0, $event['owner']))
{
$event['owner'] = $this->user;
}
@ -1982,7 +1983,7 @@ class calendar_ical extends calendar_boupdate
$owner = $this->user;
break;
default:
if ((int)$owner && $this->check_perms(EGW_ACL_EDIT, 0, $owner))
if ((int)$owner && $this->check_perms(Acl::EDIT, 0, $owner))
{
$this->calendarOwner = $owner;
}
@ -2216,13 +2217,13 @@ class calendar_ical extends calendar_boupdate
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
'(' . $this->productManufacturer .
', '. $this->productName .', ' .
($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
}
//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
// . $this->productName .', ' .
// ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .')',
// ($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .')',
// __FILE__, __LINE__, PEAR_LOG_DEBUG);
}
@ -2257,7 +2258,7 @@ class calendar_ical extends calendar_boupdate
}
else
{
$tzid = egw_time::$user_timezone->getName();
$tzid = Api\DateTime::$user_timezone->getName();
}
date_default_timezone_set($tzid);
@ -2441,7 +2442,7 @@ class calendar_ical extends calendar_boupdate
try
{
$tz = calendar_timezones::DateTimeZone($attributes['params']['TZID']);
// sometimes we do not get an egw_time object but no exception is thrown
// sometimes we do not get an Api\DateTime object but no exception is thrown
// may be php 5.2.x related. occurs when a NokiaE72 tries to open Outlook invitations
if ($tz instanceof DateTimeZone)
{
@ -3117,8 +3118,8 @@ class calendar_ical extends calendar_boupdate
return false;
}
$last->setTime(0, 0, 0);
//error_log(__METHOD__."() rrule=$recurence --> ".array2string($rriter)." --> enddate=".array2string($last).'='.egw_time::to($last, ''));
$event['recur_enddate'] = egw_time::to($last, 'server');
//error_log(__METHOD__."() rrule=$recurence --> ".array2string($rriter)." --> enddate=".array2string($last).'='.Api\DateTime::to($last, ''));
$event['recur_enddate'] = Api\DateTime::to($last, 'server');
}
// translate COUNT into an enddate, as we only store enddates
elseif($event['recur_count'])
@ -3135,7 +3136,7 @@ class calendar_ical extends calendar_boupdate
return false;
}
$last->setTime(0, 0, 0);
$event['recur_enddate'] = egw_time::to($last, 'server');
$event['recur_enddate'] = Api\DateTime::to($last, 'server');
unset($event['recur_count']);
}

View File

@ -1,8 +1,6 @@
<?php
/**
* eGroupWare
*
* Plugin to import events from a CSV file
* EGroupWare - Plugin to import events from a CSV file
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -13,6 +11,8 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
/**
* class import_csv for calendar
@ -148,8 +148,8 @@ class calendar_import_csv extends importexport_basic_import_csv {
else
{
// Search app via link query
$result = egw_link::query($resource['app'], $search, $options);
$result = Link::query($resource['app'], $search, $options);
if($result)
{
$id = $resource['type'] . key($result);
@ -224,7 +224,7 @@ class calendar_import_csv extends importexport_basic_import_csv {
// unconditional insert
$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
}
return $success;
}
@ -308,7 +308,7 @@ class calendar_import_csv extends importexport_basic_import_csv {
return $result;
}
default:
throw new egw_exception('Unsupported action');
throw new Api\Exception('Unsupported action');
}
}
@ -350,5 +350,4 @@ class calendar_import_csv extends importexport_basic_import_csv {
$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
}
} // end of iface_export_plugin
?>
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare
* EGroupWare iCal import plugin
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -236,5 +236,4 @@ class calendar_import_ical implements importexport_iface_import_plugin {
public function get_results() {
return $this->results;
}
} // end of iface_export_plugin
?>
}

View File

@ -1,21 +1,23 @@
<?php
/**
* Calendar - document merge
* EGroupware Calendar - document merge
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Nathan Gray
* @package calendar
* @copyright (c) 2007-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2011 Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* Calendar - document merge object
*/
class calendar_merge extends bo_merge
class calendar_merge extends Api\Storage\Merge
{
/**
* Functions that can be called via menuaction
@ -71,10 +73,10 @@ class calendar_merge extends bo_merge
parent::__construct();
// overwrite global export-limit, if one is set for calendar/appointments
$this->export_limit = bo_merge::getExportLimit('calendar');
$this->export_limit = Api\Storage\Merge::getExportLimit('calendar');
// switch of handling of html formated content, if html is not used
$this->parse_html_styles = egw_customfields::use_html('calendar');
// switch of handling of Api\Html formated content, if Api\Html is not used
$this->parse_html_styles = Api\Storage\Customfields::use_html('calendar');
$this->bo = new calendar_boupdate();
self::$range_tags['start'] = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
@ -130,8 +132,8 @@ class calendar_merge extends bo_merge
$ids = array('start' => PHP_INT_MAX, 'end' => 0);
$this->ids = array();
foreach($events as $event) {
if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'],'ts');
if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'],'ts');
if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
// Keep ids for future use
$this->ids[] = $event['id'];
}
@ -149,7 +151,7 @@ class calendar_merge extends bo_merge
'offset' => 0,
'enum_recuring' => true,
'order' => 'cal_start',
'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null
'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
));
$ids = array();
foreach($events as $event) {
@ -176,7 +178,7 @@ class calendar_merge extends bo_merge
$events = $this->bo->search($this->query + $id + array(
'offset' => 0,
'order' => 'cal_start',
'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null
'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
));
if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false)
{
@ -204,10 +206,10 @@ class calendar_merge extends bo_merge
$this->ids = $events;
}
// as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions
if (bo_merge::hasExportLimit($this->export_limit) && !bo_merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit)
if (Api\Storage\Merge::hasExportLimit($this->export_limit) && !Api\Storage\Merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit)
{
$err = lang('No rights to export more than %1 entries!',(int)$this->export_limit);
throw new egw_exception_wrong_userinput($err);
throw new Api\Exception\WrongUserinput($err);
}
$replacements = array();
$n = 0;
@ -284,7 +286,7 @@ class calendar_merge extends bo_merge
'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'),
) as $name => $format)
{
$value = egw_time::to($event[$what],$format);
$value = Api\DateTime::to($event[$what],$format);
if ($format == 'l') $value = lang($value);
$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
}
@ -304,7 +306,7 @@ class calendar_merge extends bo_merge
$this->cf_link_to_expand($event, $content, $replacements);
}
$custom = config::get_customfields('calendar');
$custom = Api\Storage\Customfields::get('calendar');
foreach(array_keys($custom) as $name)
{
$replacements['$$'.($prefix?$prefix.'/':'').'#'.$name.'$$'] = $event['#'.$name];
@ -371,8 +373,8 @@ class calendar_merge extends bo_merge
foreach($list as $event)
{
if($this->ids && !in_array($event['id'], $this->ids)) continue;
$start = egw_time::to($event['start'], 'array');
$end = egw_time::to($event['end'], 'array');
$start = Api\DateTime::to($event['start'], 'array');
$end = Api\DateTime::to($event['end'], 'array');
$replacements = $this->calendar_replacements($event);
if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
$dow = date('l',$event['start']);
@ -474,8 +476,8 @@ class calendar_merge extends bo_merge
foreach($list as $event)
{
if($this->ids && !in_array($event['id'], $this->ids)) continue;
$start = egw_time::to($event['start'], 'array');
$end = egw_time::to($event['end'], 'array');
$start = Api\DateTime::to($event['start'], 'array');
$end = Api\DateTime::to($event['end'], 'array');
$replacements = $this->calendar_replacements($event);
if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
//$dow = date('l',$event['start']);
@ -597,10 +599,10 @@ class calendar_merge extends bo_merge
*/
public function show_replacements()
{
$GLOBALS['egw']->translation->add_app('calendar');
Api\Translation::add_app('calendar');
$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Replacements for inserting events into documents');
$GLOBALS['egw_info']['flags']['nonavbar'] = true;
common::egw_header();
$GLOBALS['egw']->framework->header();
echo "<table width='90%' align='center'>\n";
echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>";
@ -647,7 +649,7 @@ class calendar_merge extends bo_merge
echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n";
}
echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
$custom = config::get_customfields('calendar');
$custom = Api\Storage\Customfields::get('calendar');
foreach($custom as $name => $field)
{
echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
@ -720,6 +722,6 @@ class calendar_merge extends bo_merge
echo "</table>\n";
common::egw_footer();
$GLOBALS['egw']->framework->footer();
}
}

View File

@ -11,12 +11,17 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/**
* eTemplate tag list widget
*
* The naming convention is <appname>_<subtype>_etemplate_widget
*/
class calendar_owner_etemplate_widget extends etemplate_widget_taglist
class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
{
/**
@ -28,8 +33,8 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
public function beforeSendToClient($cname, array $expand=null)
{
egw_framework::validate_file('.','et2_widget_owner','calendar');
egw_framework::includeCSS('calendar');
Framework::includeJS('.','et2_widget_owner','calendar');
Framework::includeCSS('calendar');
$bo = new calendar_bo();
@ -50,7 +55,7 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
foreach($list as $type)
{
$account_options = array('account_type' => $type);
$accounts_type = accounts::link_query('',$account_options);
$accounts_type = Api\Accounts::link_query('',$account_options);
if($type == 'accounts')
{
$accounts_type = array_intersect_key($accounts_type, $GLOBALS['egw']->acl->get_grants('calendar'));
@ -77,12 +82,11 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
if(!is_numeric($owner))
{
$resource = $bo->resources[substr($owner, 0,1)];
$label = egw_link::title($resource['app'], substr($owner,1));
$linked_owners[$resource['app']][substr($owner,1)] = $label;
$label = Link::title($resource['app'], substr($owner,1));
}
else if (!in_array($owner, array_keys($accounts)))
{
$label = egw_link::title('api-accounts',$owner);
$label = Link::title('api-accounts',$owner);
$resource = array('app'=> 'api-accounts');
}
else
@ -114,7 +118,7 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
}
$valid =& self::get_array($validated, $form_name, true);
$valid = $value;
if (true) $valid = $value;
}
}
/**
@ -138,25 +142,24 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
$mapped = array();
$_results = array();
// Handle accounts seperately
// Handle Api\Accounts seperately
if($type == '')
{
$list = array('accounts', 'owngroups');
foreach($list as $a_type)
{
$account_options = $options + array('account_type' => $a_type);
$_results += accounts::link_query($query,$account_options);
$_results += Api\Accounts::link_query($query,$account_options);
}
$_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar'));
}
else if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
else if ($data['app'] && Link::get_registry($data['app'], 'query'))
{
$_results = egw_link::query($data['app'], $query,$options);
$_results = Link::query($data['app'], $query,$options);
}
if(!$_results) continue;
$_results = array_unique($_results);
foreach($_results as $id => $title)
foreach(array_unique($_results) as $id => $title)
{
if($id && $title)
{
@ -181,10 +184,10 @@ class calendar_owner_etemplate_widget extends etemplate_widget_taglist
}
// switch regular JSON response handling off
egw_json_request::isJSONRequest(false);
Api\Json\Request::isJSONRequest(false);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($results);
common::egw_exit();
exit();
}
}

View File

@ -7,11 +7,15 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Christian Binder <christian-AT-jaytraxx.de>
* @author Joerg Lehrke <jlehrke@noc.de>
* @copyright (c) 2005-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2005-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
/**
* some necessary defines used by the calendar
*/
@ -101,13 +105,13 @@ class calendar_so
/**
* reference to global db-object
*
* @var egw_db
* @var Api\Db
*/
var $db;
/**
* instance of the async object
*
* @var asyncservice
* @var Api\AsyncService
*/
var $async;
/**
@ -191,7 +195,7 @@ class calendar_so
if ($start) $where[] = "cal_end>".(int)$start;
if ($_where) $where = array_merge($where, $_where);
// egw_db::union uses egw_db::select which check if join contains "WHERE"
// Api\Db::union uses Api\Db::select which check if join contains "WHERE"
// to support old join syntax like ", other_table WHERE ...",
// therefore we have to use eg. "WHERe" instead!
$sql = "(SELECT * FROM $this->dates_table WHERe ".$this->db->expression($this->dates_table, $where).") $this->dates_table";
@ -236,7 +240,7 @@ class calendar_so
//in_array($filter,array('owner','deleted')) ||
$params['enum_recuring']===false)
{
throw new egw_exception_assertion_failed("Unsupported value for parameters!");
throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
}
$where = is_array($params['query']) ? $params['query'] : array();
if ($cat_id) $where[] = $this->cat_filter($cat_id);
@ -286,7 +290,7 @@ class calendar_so
$sql .= "\nORDER BY ".$params['order'];
}
if ($offset === false) // return all rows --> egw_db::query wants offset=0, num_rows=-1
if ($offset === false) // return all rows --> Api\Db::query wants offset=0, num_rows=-1
{
$offset = 0;
$num_rows = -1;
@ -381,7 +385,7 @@ class calendar_so
unset($row['recur_enddate']);
}
$row['recur_exception'] = $row['alarm'] = array();
$events[$row['cal_id']] = egw_db::strip_array_keys($row,'cal_');
$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
}
if (!$events) return $events;
@ -393,7 +397,7 @@ class calendar_so
if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length)
{
// event (without uid), not strong enough uid => create new uid
$event['uid'] = common::generate_uid('calendar',$event['id']);
$event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']);
$this->db->update($this->cal_table, array('cal_uid' => $event['uid']),
array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar');
}
@ -567,11 +571,11 @@ class calendar_so
/**
* Query calendar main table and return iterator of query
*
* Use as: foreach(get_cal_data() as $data) { $data = egw_db::strip_array_keys($data, 'cal_'); // do something with $data
* Use as: foreach(get_cal_data() as $data) { $data = Api\Db::strip_array_keys($data, 'cal_'); // do something with $data
*
* @param array $query filter, keys have to use 'cal_' prefix
* @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
* @return Iterator as egw_db::select
* @return Iterator as Api\Db::select
*/
function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
{
@ -733,14 +737,14 @@ class calendar_so
{
foreach(array('cal_title','cal_description','cal_location') as $col)
{
$to_or[] = $col.' '.$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%');
$to_or[] = $col.' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%');
}
$where[] = '('.implode(' OR ',$to_or).')';
// Searching - restrict private to own or private grant
if (!isset($params['private_grants']))
{
$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], EGW_ACL_PRIVATE, 'calendar');
$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar');
$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user
}
$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')';
@ -1026,7 +1030,7 @@ class calendar_so
// compile a list of recurrences per cal_id
if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
$events[$id] = egw_db::strip_array_keys($row,'cal_');
$events[$id] = Api\Db::strip_array_keys($row,'cal_');
}
//_debug_array($events);
if (count($ids))
@ -1151,7 +1155,7 @@ class calendar_so
{
return; // disable integration for GroupDAV, SyncML, ...
}
self::$integration_data = $GLOBALS['egw']->hooks->process(array(
self::$integration_data = Api\Hooks::process(array(
'location' => 'calendar_search_union',
'cols' => $selects[0]['cols'], // cols to return
'start' => $start,
@ -1253,7 +1257,7 @@ class calendar_so
else
{
// special handling for egw_cal, as old databases have a different column order!!!
$cols =& egw_cache::getSession(__CLASS__,$table);
$cols =& Api\Cache::getSession(__CLASS__,$table);
if (is_null($cols))
{
@ -1350,7 +1354,7 @@ ORDER BY cal_user_type, cal_usre_id
while ($rrule->valid() && ($enddate = $occurrence));
$enddate->modify(($event['end'] - $event['start']).' second');
$event['recur_enddate'] = $enddate->format('server');
//error_log(__METHOD__."($event[title]) start=".egw_time::to($event['start'],'string').', end='.egw_time::to($event['end'],'string').', range_end='.egw_time::to($event['recur_enddate'],'string'));
//error_log(__METHOD__."($event[title]) start=".Api\DateTime::to($event['start'],'string').', end='.Api\DateTime::to($event['end'],'string').', range_end='.Api\DateTime::to($event['recur_enddate'],'string'));
}
// add colum prefix 'cal_' if there's not already a 'recur_' prefix
@ -1432,7 +1436,7 @@ ORDER BY cal_user_type, cal_usre_id
// event without uid or not strong enough uid
if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length)
{
$update['cal_uid'] = $event['cal_uid'] = common::generate_uid('calendar',$cal_id);
$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id);
}
// set caldav_name, if not given by caller
if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>='))
@ -1699,11 +1703,11 @@ ORDER BY cal_user_type, cal_usre_id
return false;
}
$start = $timestamp ? $timestamp : (int)time() + $alarm['offset'];
$event = egw_db::strip_array_keys($_event, 'cal_');
$event = Api\Db::strip_array_keys($_event, 'cal_');
$rrule = calendar_rrule::event2rrule($event, false);
foreach ($rrule as $time)
{
if ($start < ($ts = egw_time::to($time,'server')))
if ($start < ($ts = Api\DateTime::to($time,'server')))
{
$alarm['time'] = $ts - $alarm['offset'];
return true;
@ -2230,7 +2234,7 @@ ORDER BY cal_user_type, cal_usre_id
'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)!
), __LINE__, __FILE__);
// handle links
egw_link::unlink('', 'calendar', $row['cal_id']);
Link::unlink('', 'calendar', $row['cal_id']);
}
}
@ -2654,10 +2658,10 @@ ORDER BY cal_user_type, cal_usre_id
if (in_array($filter, array('map','tz_map','rrule','tz_rrule')))
{
// real exception
$locts = (int)egw_time::to($egw_rrule->current(),'server');
$locts = (int)Api\DateTime::to($egw_rrule->current(),'server');
if ($expand_all)
{
$remts = (int)egw_time::to($remote_rrule->current(),'server');
$remts = (int)Api\DateTime::to($remote_rrule->current(),'server');
if ($remote)
{
$days[$locts]= $remts;
@ -2680,14 +2684,14 @@ ORDER BY cal_user_type, cal_usre_id
if (!$egw_rrule->valid()) return $days;
}
$day = $egw_rrule->current();
$locts = (int)egw_time::to($day,'server');
$locts = (int)Api\DateTime::to($day,'server');
$tz_exception = ($filter == 'tz_rrule');
//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
// '()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)");
if ($expand_all)
{
$remote_day = $remote_rrule->current();
$remts = (int)egw_time::to($remote_day,'server');
$remts = (int)Api\DateTime::to($remote_day,'server');
// error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
// '()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)");
}
@ -2906,7 +2910,7 @@ ORDER BY cal_user_type, cal_usre_id
if (empty($event['tzid']))
{
$timezone = egw_time::$server_timezone;
$timezone = Api\DateTime::$server_timezone;
}
else
{
@ -2916,14 +2920,14 @@ ORDER BY cal_user_type, cal_usre_id
}
$timezone = self::$tz_cache[$event['tzid']];
}
$start_time = new egw_time($event['start'],egw_time::$server_timezone);
$start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone);
$start_time->setTimezone($timezone);
$end_time = new egw_time($event['end'],egw_time::$server_timezone);
$end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone);
$end_time->setTimezone($timezone);
//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
// '(): ' . $start . '-' . $end);
$start = egw_time::to($start_time,'array');
$end = egw_time::to($end_time,'array');
$start = Api\DateTime::to($start_time,'array');
$end = Api\DateTime::to($end_time,'array');
return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59;
@ -2932,16 +2936,16 @@ ORDER BY cal_user_type, cal_usre_id
/**
* Moves a datetime to the beginning of the day within timezone
*
* @param egw_time $time the datetime entry
* @param Api\DateTime $time the datetime entry
* @param string tz_id timezone
*
* @return DateTime
*/
function &startOfDay(egw_time $time, $tz_id=null)
function &startOfDay(Api\DateTime $time, $tz_id=null)
{
if (empty($tz_id))
{
$timezone = egw_time::$server_timezone;
$timezone = Api\DateTime::$server_timezone;
}
else
{
@ -2951,7 +2955,7 @@ ORDER BY cal_user_type, cal_usre_id
}
$timezone = self::$tz_cache[$tz_id];
}
return new egw_time($time->format('Y-m-d 00:00:00'), $timezone);
return new Api\DateTime($time->format('Y-m-d 00:00:00'), $timezone);
}
/**

View File

@ -1,6 +1,5 @@
<?php
/*
/**
* Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @link http://www.egroupware.org
@ -8,6 +7,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/**
* Creates a grid with rows for the time, columns for (multiple) days containing events
*
@ -16,7 +18,7 @@
*
* @author Nathan Gray
*/
class calendar_timegrid_etemplate_widget extends etemplate_widget
class calendar_timegrid_etemplate_widget extends Etemplate\Widget
{
/**
@ -33,7 +35,7 @@
$value =& self::get_array(self::$request->content, $form_name, true);
if(!is_array($value)) $value = array();
foreach($value as $day => &$events)
foreach($value as &$events)
{
if(!is_array($events))
{
@ -44,7 +46,7 @@
if(!is_array($event)) continue;
foreach(array('start','end') as $date)
{
$event[$date] = egw_time::to($event[$date],'Y-m-d\TH:i:s\Z');
$event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z');
}
}
}
@ -58,6 +60,6 @@
{
$cal_bo = new calendar_bo();
$holidays = $cal_bo->read_holidays((int)$year);
egw_json_response::get()->data($holidays);
Api\Json\Response::get()->data($holidays);
}
}

View File

@ -7,11 +7,13 @@
* @link http://www.egroupware.org
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2009-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2009-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* Class for timezone information
*
@ -98,7 +100,7 @@ class calendar_timezones
),__LINE__,__FILE__,false,'','calendar')->fetch()))
{
$id = $data['tz_id'];
self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_');
self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_');
}
}
// check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires'
@ -109,7 +111,7 @@ class calendar_timezones
),__LINE__,__FILE__,false,'','calendar')->fetch()))
{
$id = $data['tz_id'];
self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_');
self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_');
}
}
if (isset($id) && $what != 'id')
@ -142,7 +144,7 @@ class calendar_timezones
'tz_id' => $id,
),__LINE__,__FILE__,false,'','calendar')->fetch()))
{
$data = egw_db::strip_array_keys($data,'tz_');
$data = Api\Db::strip_array_keys($data,'tz_');
self::$tz2id[$data['tzid']] = $id;
}
}
@ -168,8 +170,8 @@ class calendar_timezones
*/
public static function init_static()
{
self::$tz_cache =& egw_cache::getSession(__CLASS__,'tz_cache');
self::$tz2id =& egw_cache::getSession(__CLASS__,'tz2id');
self::$tz_cache =& Api\Cache::getSession(__CLASS__,'tz_cache');
self::$tz2id =& Api\Cache::getSession(__CLASS__,'tz2id');
// init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar
if (!is_array(self::$tz2id))
@ -182,7 +184,7 @@ class calendar_timezones
}
// check for updated timezones once per session
if (!egw_cache::getSession(__CLASS__, 'tzs_checked'))
if (!Api\Cache::getSession(__CLASS__, 'tzs_checked'))
{
$updated = false;
$msg = self::import_zones($updated);
@ -193,7 +195,7 @@ class calendar_timezones
self::$import_msg = $msg.'<br/>'.$alias_msg;
egw_cache::setSession(__CLASS__, 'tzs_checked', true);
Api\Cache::setSession(__CLASS__, 'tzs_checked', true);
}
}
@ -203,9 +205,9 @@ class calendar_timezones
* @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
* @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT
* @return string message about update
* @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version
* @throws egw_exception_wrong_userinput if no PDO sqlite support
* @throws egw_exception_wrong_userinput for broken sqlite extension
* @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version
* @throws Api\Exception\WrongUserinput if no PDO sqlite support
* @throws Api\Exception\WrongUserinput for broken sqlite extension
* @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json
*/
public static function import_zones(&$updated=null, $file='calendar/setup/zones.json')
@ -214,17 +216,17 @@ class calendar_timezones
if (!file_exists($path) || !is_readable($path) || !($fp = fopen($path, 'r')))
{
throw new egw_exception_wrong_parameter(__METHOD__."('$file') not found or readable!");
throw new Api\Exception\WrongParameter(__METHOD__."('$file') not found or readable!");
}
// only read a couple of bytes to parse version
$json = fread($fp, 80);
$matches = null;
if (!preg_match('/"version": *"([^"]+)"/', $json, $matches))
{
throw new egw_exception_wrong_parameter('Could not read timezoneversion!');
throw new Api\Exception\WrongParameter('Could not read timezoneversion!');
}
$tz_version = $matches[1];
$config = config::read('phpgwapi');
$config = Api\Config::read('phpgwapi');
//echo "<p>tz_version($path)=$tz_version, tz_db_version=$config[tz_version]</p>\n";
if ($tz_version === $config['tz_version'])
{
@ -236,7 +238,7 @@ class calendar_timezones
fclose($fp);
if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones']))
{
throw new egw_exception_wrong_parameter('Could not parse zones.json!');
throw new Api\Exception\WrongParameter('Could not parse zones.json!');
}
// import zones first and then aliases
$tz2id = array();
@ -267,7 +269,7 @@ class calendar_timezones
if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
}
}
config::save_value('tz_version', $tz_version, 'phpgwapi');
Api\Config::save_value('tz_version', $tz_version, 'phpgwapi');
//_debug_array($tz2id);
$updated = true;
@ -280,7 +282,7 @@ class calendar_timezones
* @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
* @param string $file ='calendar/setup/tz_aliases.inc.php' filename relative to EGW_SERVER_ROOT
* @return string message about update
* @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version
* @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version
*/
public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php')
{
@ -288,9 +290,9 @@ class calendar_timezones
if (!file_exists($path) || !is_readable($path))
{
throw new egw_exception_wrong_parameter(__METHOD__."('$file') not found or readable!");
throw new Api\Exception\WrongParameter(__METHOD__."('$file') not found or readable!");
}
$config = config::read('phpgwapi');
$config = Api\Config::read('phpgwapi');
$tz_aliases_mtime = date('Y-m-d H:i:s', filemtime($path));
if ($tz_aliases_mtime === $config['tz_aliases_mtime'])
{
@ -315,7 +317,7 @@ class calendar_timezones
}
//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id));
}
config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi');
Api\Config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi');
//_debug_array($tz2id);
$updated = true;
@ -330,7 +332,7 @@ class calendar_timezones
{
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
throw new egw_exception_no_permission_admin();
throw new Api\Exception\NoPermission\Admin();
}
if (empty(self::$import_msg))
{
@ -363,16 +365,16 @@ class calendar_timezones
if (is_a($standard, 'Horde_Icalendar'))
{
$time = $standard->getAttribute('DTSTART');
$dtstart = new egw_time($time, egw_time::$server_timezone);
$dtstart->setTimezone(egw_time::$server_timezone);
$dtstart = new Api\DateTime($time, Api\DateTime::$server_timezone);
$dtstart->setTimezone(Api\DateTime::$server_timezone);
$standard->setAttribute('DTSTART', $dtstart->format('Ymd\THis'), array(), false);
}
$daylight = $horde_vtimezone->findComponent('DAYLIGHT');
if (is_a($daylight, 'Horde_Icalendar'))
{
$time = $daylight->getAttribute('DTSTART');
$dtstart = new egw_time($time, egw_time::$server_timezone);
$dtstart->setTimezone(egw_time::$server_timezone);
$dtstart = new Api\DateTime($time, Api\DateTime::$server_timezone);
$dtstart->setTimezone(Api\DateTime::$server_timezone);
$daylight->setAttribute('DTSTART', $dtstart->format('Ymd\THis'), array(), false);
}
//error_log($vtimezone); error_log($horde_vtimezone->_exportvData('VTIMEZONE'));
@ -396,11 +398,11 @@ class calendar_timezones
}
else
{
$prefs_obj = new preferences($user);
$prefs_obj = new Api\Preferences($user);
$prefs = $prefs_obj->read();
$tzid = $prefs['common']['tz'];
}
if (!$tzid) $tzid = egw_time::$server_timezone->getName();
if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName();
switch ($type)
{
@ -435,7 +437,7 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_
// echo "<h3>Testing availability of VTIMEZONE data for each tzid supported by PHP</h3>\n";
// foreach(DateTimeZone::listIdentifiers() as $tz)
echo "<h3>Testing availability of VTIMEZONE data for each TZID supported by EGroupware</h3>\n";
foreach(call_user_func_array('array_merge',egw_time::getTimezones()) as $tz => $label)
foreach(call_user_func_array('array_merge',Api\DateTime::getTimezones()) as $tz => $label)
{
if (($id = calendar_timezones::tz2id($tz,'component')) || $tz == 'UTC') // UTC is always supported
{

View File

@ -9,10 +9,12 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* Calendar - tracking object
*/
class calendar_tracking extends bo_tracking
class calendar_tracking extends Api\Storage\Tracking
{
/**
* Application we are tracking (required!)

View File

@ -1,15 +1,21 @@
<?php
/**
* eGroupWare - Calendar's shared base-class of all UI classes
* EGroupware - Calendar's shared base-class of all UI classes
*
* @link http://www.egroupware.org
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2004-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2004-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* Shared base-class of all calendar UserInterface classes
*
@ -47,9 +53,9 @@ class calendar_ui
*/
var $datetime;
/**
* Instance of categories class
* Instance of Api\Categories class
*
* @var categories
* @var Api\Categories
*/
var $categories;
/**
@ -147,7 +153,7 @@ class calendar_ui
}
$this->datetime = $GLOBALS['egw']->datetime;
$this->categories = new categories($this->user,'calendar');
$this->categories = new Api\Categories($this->user,'calendar');
$this->common_prefs = &$GLOBALS['egw_info']['user']['preferences']['common'];
$this->cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
@ -167,7 +173,7 @@ class calendar_ui
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
// make sure the hook for export_limit is registered
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','calendar')) $GLOBALS['egw']->hooks->register_single_app_hook('calendar','export_limit');
if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true);
}
/**
@ -188,13 +194,13 @@ class calendar_ui
{
foreach($GLOBALS['egw']->accounts->members($owner, true) as $member)
{
if (!$this->bo->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$member))
if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$member))
{
$no_access_group[$member] = $this->bo->participant_name($member);
}
}
}
elseif (!$this->bo->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$owner))
elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$owner))
{
$no_access[$owner] = $this->bo->participant_name($owner);
unset($owner_array[$idx]);
@ -203,7 +209,7 @@ class calendar_ui
if (count($no_access))
{
$message = lang('Access denied to the calendar of %1 !!!',implode(', ',$no_access));
egw_framework::message($message,'error');
Framework::message($message,'error');
$this->owner = implode(',',$owner_array);
return $message;
}
@ -395,18 +401,18 @@ class calendar_ui
*/
function event_icons($event)
{
$is_private = !$event['public'] && !$this->bo->check_perms(EGW_ACL_READ,$event);
$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event);
$icons = array();
if (!$is_private)
{
if($event['priority'] == 3)
{
$icons[] = html::image('calendar','high',lang('high priority'));
$icons[] = Api\Html::image('calendar','high',lang('high priority'));
}
if($event['recur_type'] != MCAL_RECUR_NONE)
{
$icons[] = html::image('calendar','recur',lang('recurring event'));
$icons[] = Api\Html::image('calendar','recur',lang('recurring event'));
}
// icons for single user, multiple users or group(s) and resources
foreach(array_keys($event['participants']) as $uid)
@ -416,16 +422,16 @@ class calendar_ui
if (isset($icons['single']) || $GLOBALS['egw']->accounts->get_type($uid) == 'g')
{
unset($icons['single']);
$icons['multiple'] = html::image('calendar','users');
$icons['multiple'] = Api\Html::image('calendar','users');
}
elseif (!isset($icons['multiple']))
{
$icons['single'] = html::image('calendar','single');
$icons['single'] = Api\Html::image('calendar','single');
}
}
elseif(!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon']))
{
$icons[$uid[0]] = html::image($this->bo->resources[$uid[0]]['app'],
$icons[$uid[0]] = Api\Html::image($this->bo->resources[$uid[0]]['app'],
($this->bo->resources[$uid[0]]['icon'] ? $this->bo->resources[$uid[0]]['icon'] : 'navbar'),
lang($this->bo->resources[$uid[0]]['app']),
'width="16px" height="16px"');
@ -434,19 +440,19 @@ class calendar_ui
}
if($event['non_blocking'])
{
$icons[] = html::image('calendar','nonblocking',lang('non blocking'));
$icons[] = Api\Html::image('calendar','nonblocking',lang('non blocking'));
}
if($event['public'] == 0)
{
$icons[] = html::image('calendar','private',lang('private'));
$icons[] = Api\Html::image('calendar','private',lang('private'));
}
if(isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
{
$icons[] = html::image('calendar','alarm',lang('alarm'));
$icons[] = Api\Html::image('calendar','alarm',lang('alarm'));
}
if($event['participants'][$this->user][0] == 'U')
{
$icons[] = html::image('calendar','needs-action',lang('Needs action'));
$icons[] = Api\Html::image('calendar','needs-action',lang('Needs action'));
}
return $icons;
}
@ -471,8 +477,8 @@ class calendar_ui
$vars['hour'] = $hour;
$vars['minute'] = $minute;
}
return html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
. '" title="'.html::htmlspecialchars(lang('Add')).'"');
return Api\Html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
. '" title="'.Api\Html::htmlspecialchars(lang('Add')).'"');
}
/**
@ -481,7 +487,7 @@ class calendar_ui
function sidebox_menu()
{
// Magic etemplate2 favorites menu (from framework)
display_sidebox('calendar', lang('Favorites'), egw_framework::favorite_list('calendar'));
display_sidebox('calendar', lang('Favorites'), Framework\Favorites::list_favorites('calendar'));
$file = array('menuOpened' => true); // menu open by default
@ -496,7 +502,7 @@ class calendar_ui
// Merge print placeholders (selectbox in etemplate)
if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])
{
$file['Placeholders'] = egw::link('/index.php','menuaction=calendar.calendar_merge.show_replacements');
$file['Placeholders'] = Egw::link('/index.php','menuaction=calendar.calendar_merge.show_replacements');
}
$appname = 'calendar';
$menu_title = lang('Calendar Menu');
@ -519,10 +525,10 @@ class calendar_ui
if ($GLOBALS['egw_info']['user']['apps']['admin'])
{
$file = Array(
'Configuration'=>egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
'Custom Fields'=>egw::link('/index.php','menuaction=admin.customfields.index&appname=calendar'),
'Holiday Management'=>egw::link('/index.php','menuaction=calendar.uiholiday.admin'),
'Global Categories' =>egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar'),
'Configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
'Custom Fields'=>Egw::link('/index.php','menuaction=admin.customfields.index&appname=calendar'),
'Holiday Management'=>Egw::link('/index.php','menuaction=calendar.uiholiday.admin'),
'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar'),
);
$GLOBALS['egw']->framework->sidebox($appname,lang('Admin'),$file,'admin');
}
@ -539,11 +545,11 @@ class calendar_ui
$this->manage_states(array_merge($content,json_decode($content['view'],true)));
if($content['first'])
{
$this->first = egw_time::to($content['first'],'ts');
$this->first = Api\DateTime::to($content['first'],'ts');
}
if($content['last'])
{
$this->last = new egw_time($content['last']);
$this->last = new Api\DateTime($content['last']);
$this->last->setTime(23, 59, 59);
$this->last = $this->last->format('ts');
}
@ -552,12 +558,12 @@ class calendar_ui
$this->merge();
return;
}
$sidebox = new etemplate_new('calendar.sidebox');
$sidebox = new Etemplate('calendar.sidebox');
$cont = $this->cal_prefs['saved_states'];
if (!is_array($cont)) $cont = array();
$cont['view'] = $this->view ? $this->view : 'week';
$cont['date'] = $this->date ? $this->date : egw_time();
$cont['date'] = $this->date ? $this->date : Api\DateTime();
$readonlys = array();
$sel_options['status_filter'] = array(
@ -598,22 +604,22 @@ class calendar_ui
*
* This allows to pass only changed information for a single (recurring) event
* and update the UI without a refreshing any more than needed. If adding,
* a notification via egw_framework::refresh_opener() is still needed but
* a notification via Framework::refresh_opener() is still needed but
* edits, updates and deletes will be automatic.
* If the event is recurring, we send the next month's worth of recurrences
* for lack of a better way to determine how much to send.
*
* @param int $event_id
* @param egw_time $recurrence_date
* @param Api\DateTime $recurrence_date
*/
public function update_client($event_id, egw_time $recurrence_date = null)
public function update_client($event_id, Api\DateTime $recurrence_date = null)
{
if(!$event_id) return;
// Directly update stored data.
// Make sure we have the whole event
$event = $this->bo->read($event_id, $recurrence_date);
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if(!$event)
{
@ -630,7 +636,7 @@ class calendar_ui
// If it's recurring, try to send the next month or so
else if($event['recur_type'] )
{
$this_month = new egw_time('next month');
$this_month = new Api\DateTime('next month');
$rrule = calendar_rrule::event2rrule($event, true);
$rrule->rewind();
do
@ -658,13 +664,13 @@ class calendar_ui
{
if(!$event || !is_array($event)) return false;
if (!$this->bo->check_perms(EGW_ACL_EDIT,$event))
if (!$this->bo->check_perms(Acl::EDIT,$event))
{
$event['class'] .= 'rowNoEdit ';
}
// Delete disabled for other applications
if (!$this->bo->check_perms(EGW_ACL_DELETE,$event) || !is_numeric($event['id']))
if (!$this->bo->check_perms(Acl::DELETE,$event) || !is_numeric($event['id']))
{
$event['class'] .= 'rowNoDelete ';
}
@ -683,7 +689,7 @@ class calendar_ui
// respect category permissions
if(!empty($event['category']))
{
$event['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
$event['category'] = $this->categories->check_list(Acl::READ, $event['category']);
}
$event['non_blocking'] = (bool)$event['non_blocking'];
@ -702,7 +708,7 @@ class calendar_ui
}
else
{
$is_private = !$this->bo->check_perms(EGW_ACL_READ,$event);
$is_private = !$this->bo->check_perms(Acl::READ,$event);
}
if ($is_private)
{
@ -721,10 +727,10 @@ class calendar_ui
if ($event['recur_type'] != MCAL_RECUR_NONE)
{
$event['app_id'] .= ':'.egw_time::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
}
// set id for grid
$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.egw_time::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts') : '');
$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts') : '');
$event['parts'] = implode(",\n",$this->bo->participants($event,false));
$event['date'] = $this->bo->date2string($event['start']);
@ -734,7 +740,7 @@ class calendar_ui
{
if(is_int($event[$field]))
{
$event[$field] = egw_time::to($event[$field], egw_time::ET2);
$event[$field] = Api\DateTime::to($event[$field], Api\DateTime::ET2);
}
}
}
@ -762,18 +768,18 @@ class calendar_ui
{
case 'month':
// Trim to _only_ the month, do not pad to week start / end
$time = new egw_time($this->date);
$time = new Api\DateTime($this->date);
$timespan = array(array(
'start' => egw_time::to($time->format('Y-m-01 00:00:00'),'ts'),
'end' => egw_time::to($time->format('Y-m-t 23:59:59'),'ts')
'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'),'ts'),
'end' => Api\DateTime::to($time->format('Y-m-t 23:59:59'),'ts')
));
break;
case 'week':
$timespan = array();
$start = new egw_time($this->first);
$start = new Api\DateTime($this->first);
$t = clone $start;
$t->modify('+1 week')->modify('-1 second');
if($t->format('ts') < egw_time::to($this->last,'ts'))
if($t->format('ts') < Api\DateTime::to($this->last,'ts'))
{
do
{
@ -795,16 +801,16 @@ class calendar_ui
}
}
$merge = new calendar_merge();
//error_log($_GET['merge'] . ' Timespan: ');foreach($timespan as $t) error_log(egw_time::to($t['start']) . ' - ' . egw_time::to($t['end']));
//error_log($_GET['merge'] . ' Timespan: ');foreach($timespan as $t) error_log(Api\DateTime::to($t['start']) . ' - ' . Api\DateTime::to($t['end']));
$error = $merge->download($_GET['merge'], $timespan, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
// Here? Doesn't actually give the message
egw_framework::refresh_opener($error, 'calendar');
Framework::refresh_opener($error, 'calendar');
}
unset($_GET['merge']);
if($error)
{
// This doesn't give message either, but at least it doesn't give a blank screen
egw_framework::redirect_link('/index.php', array(
Framework::redirect_link('/index.php', array(
'msg' => $error,
'cd' => 'yes'
));

View File

@ -5,11 +5,19 @@
* @link http://www.egroupware.org
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2004-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2004-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Vfs;
use EGroupware\Api\Etemplate;
/**
* calendar UserInterface forms: view and edit events, freetime search
*
@ -76,7 +84,7 @@ class calendar_uiforms extends calendar_ui
{
if ($uid[0] == 'c')
{
$title = egw_link::title('addressbook', substr($uid, 1));
$title = Link::title('addressbook', substr($uid, 1));
break;
}
}
@ -100,7 +108,7 @@ class calendar_uiforms extends calendar_ui
}
if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
!$this->bo->check_perms(EGW_ACL_ADD,0,$owner))
!$this->bo->check_perms(Acl::ADD,0,$owner))
{
if ($owner) // make an owner who is no user or we have no add-rights a participant
{
@ -127,7 +135,7 @@ class calendar_uiforms extends calendar_ui
if(isset($_GET['start']))
{
$start = egw_time::to($_GET['start'], 'ts');
$start = Api\DateTime::to($_GET['start'], 'ts');
}
else
{
@ -150,7 +158,7 @@ class calendar_uiforms extends calendar_ui
{
$participants[$uid] = $participant_types['u'][$uid] =
calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
}
elseif (is_array($this->bo->resources[$uid[0]]))
{
@ -160,7 +168,7 @@ class calendar_uiforms extends calendar_ui
$uid = $account_id;
$participants[$uid] = $participant_types['u'][$uid] =
calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
continue;
}
$res_data = $this->bo->resources[$uid[0]];
@ -252,7 +260,7 @@ class calendar_uiforms extends calendar_ui
{
list($date) = each($content['recur_exception']['delete_exception']);
// eT2 converts time to
if (!is_numeric($date)) $date = egw_time::to (str_replace('Z','', $date), 'ts');
if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
unset($content['recur_exception']['delete_exception']);
if (($key = array_search($date,$content['recur_exception'])) !== false)
{
@ -262,7 +270,7 @@ class calendar_uiforms extends calendar_ui
{
if (!($exception = $this->bo->read($id)) ||
$exception['recurrence'] != $content['recur_exception'][$key]) continue;
$exception['uid'] = common::generate_uid('calendar', $id);
$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
$exception['reference'] = $exception['recurrence'] = 0;
$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
break;
@ -489,7 +497,7 @@ class calendar_uiforms extends calendar_ui
{
$msg = lang('Status changed');
//Refresh the event in the main window after changing status
egw_framework::refresh_opener($msg, 'calendar', $event['id']);
Framework::refresh_opener($msg, 'calendar', $event['id']);
}
}
if (!$content['no_popup'])
@ -565,7 +573,7 @@ class calendar_uiforms extends calendar_ui
unset($event['modified']);
unset($event['modifier']);
unset($event['caldav_name']);
$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner;
$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
// Clear participant stati
foreach($event['participant_types'] as $type => &$participants)
@ -593,16 +601,16 @@ class calendar_uiforms extends calendar_ui
// Get links to be copied
// With no ID, $content['link_to']['to_id'] is used
$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
foreach(egw_link::get_links('calendar', $content['id']) as $link)
foreach(Link::get_links('calendar', $content['id']) as $link)
{
if ($link['app'] != egw_link::VFS_APPNAME)
if ($link['app'] != Link::VFS_APPNAME)
{
egw_link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
}
elseif ($link['app'] == egw_link::VFS_APPNAME)
elseif ($link['app'] == Link::VFS_APPNAME)
{
egw_link::link('calendar', $content['link_to']['to_id'], egw_link::VFS_APPNAME, array(
'tmp_name' => egw_link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
'name' => $link['id'],
), $link['remark']);
}
@ -619,7 +627,7 @@ class calendar_uiforms extends calendar_ui
case 'print':
case 'apply':
case 'infolog':
if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
{
$msg = lang('Permission denied');
$button = '';
@ -787,7 +795,7 @@ class calendar_uiforms extends calendar_ui
{
$update_type = 'edit';
}
// check if there are messages from update, eg. removed participants or categories because of missing rights
// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
if ($messages)
{
$msg .= ($msg ? ', ' : '').implode(', ',$messages);
@ -796,7 +804,7 @@ class calendar_uiforms extends calendar_ui
{
$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
htmlspecialchars(egw::link('/index.php',array(
htmlspecialchars(Egw::link('/index.php',array(
'menuaction' => 'calendar.calendar_uiforms.edit',
'cal_id' => $content['id'],
))).'">','</a>');
@ -808,11 +816,11 @@ class calendar_uiforms extends calendar_ui
if ($old_event && $old_event['id'] != $event['id'])
{
$update_type = 'edit';
foreach ((array)$old_alarms as $alarm)
foreach ((array)$old_event['alarms'] as $alarm)
{
// check if alarms still needed in old event, if not delete it
$event_time = $alarm['time'] + $alarm['offset'];
if ($event_time >= $actual_date)
if ($event_time >= $this->bo->now_su)
{
$this->bo->delete_alarm($alarm['id']);
}
@ -850,7 +858,7 @@ class calendar_uiforms extends calendar_ui
));
foreach ((array)$events as $exception)
{
if ($exception['recurrence'] > $actual_date)
if ($exception['recurrence'] > $this->bo->now_su)
{
$exception['recurrence'] += $offset;
$exception['reference'] = $event['id'];
@ -875,18 +883,18 @@ class calendar_uiforms extends calendar_ui
$message .= lang(', stati of participants reset');
}
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if($response && $update_type != 'delete')
{
$this->update_client($event['id']);
}
$msg = $message . ($msg ? ', ' . $msg : '');
egw_framework::refresh_opener($msg, 'calendar', $event['id'], $event['recur_type'] ? 'edit' : $update_type);
Framework::refresh_opener($msg, 'calendar', $event['id'], $event['recur_type'] ? 'edit' : $update_type);
// writing links for new entry, existing ones are handled by the widget itself
if (!$content['id'] && is_array($content['link_to']['to_id']))
{
egw_link::link('calendar',$event['id'],$content['link_to']['to_id']);
Link::link('calendar',$event['id'],$content['link_to']['to_id']);
}
}
else
@ -898,7 +906,7 @@ class calendar_uiforms extends calendar_ui
case 'cancel':
if($content['cancel_needs_refresh'])
{
egw_framework::refresh_opener($msg, 'calendar');
Framework::refresh_opener($msg, 'calendar');
}
break;
@ -934,7 +942,7 @@ class calendar_uiforms extends calendar_ui
{
$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
}
if ($this->bo->check_perms(EGW_ACL_EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
{
$alarm = array(
'offset' => $offset,
@ -954,7 +962,7 @@ class calendar_uiforms extends calendar_ui
$event['alarm'][$alarm_id] = $alarm;
$msg = lang('Alarm added');
egw_framework::refresh_opener($msg,'calendar', $event['id'], 'update');
Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
}
else
{
@ -979,7 +987,7 @@ class calendar_uiforms extends calendar_ui
$msg .= ($msg ? "\n" : '').implode("\n", $notification_errors);
}
// New event, send data before updating so it's there
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if($response && !$content['id'] && $event['id'])
{
$this->update_client($event['id']);
@ -988,25 +996,25 @@ class calendar_uiforms extends calendar_ui
{
if ($content['lock_token']) // remove an existing lock
{
egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
}
if ($content['no_popup'])
{
egw::redirect_link('/index.php',array(
Egw::redirect_link('/index.php',array(
'menuaction' => 'calendar.calendar_uiviews.index',
'msg' => $msg,
));
}
if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
{
egw_framework::refresh_opener($msg,'calendar');
Framework::refresh_opener($msg,'calendar');
}
else
{
egw_framework::refresh_opener($msg, 'calendar', $event['id'], $button == 'save' ? ($content['id'] ? $update_type : 'add') : 'delete');
Framework::refresh_opener($msg, 'calendar', $event['id'], $button == 'save' ? ($content['id'] ? $update_type : 'add') : 'delete');
}
egw_framework::window_close();
common::egw_exit();
Framework::window_close();
exit();
}
unset($event['no_notifications']);
return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
@ -1041,7 +1049,7 @@ class calendar_uiforms extends calendar_ui
{
unset($alarm['uid'], $alarm['id'], $alarm['time']);
}
if($this->bo->check_perms(EGW_ACL_EDIT,$event))
if($this->bo->check_perms(Acl::EDIT,$event))
{
return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
}
@ -1073,12 +1081,11 @@ class calendar_uiforms extends calendar_ui
$as_of_date = time();
}
//error_log(__METHOD__ . egw_time::to($old_event['start']) . ' -> '. egw_time::to($event['start']) . ' as of ' . egw_time::to($as_of_date));
//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
{
$msg = lang("Error: You can't shift a series from the past!");
$noerror = false;
return $msg;
}
@ -1091,9 +1098,9 @@ class calendar_uiforms extends calendar_ui
// base start-date of new series on actual / clicked date
$event['start'] = $as_of_date ;
if (egw_time::to($old_event['start'],'Ymd') < egw_time::to($as_of_date,'Ymd') ||
if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
// Adjust for requested date in the past
egw_time::to($as_of_date,'ts') < time()
Api\DateTime::to($as_of_date,'ts') < time()
)
{
@ -1114,19 +1121,19 @@ class calendar_uiforms extends calendar_ui
$occurrence = $rriter->current();
}
while ($rriter->valid() && (
egw_time::to($occurrence, 'ts') <= time() ||
egw_time::to($occurrence, 'Ymd') < egw_time::to($as_of_date,'Ymd')
Api\DateTime::to($occurrence, 'ts') <= time() ||
Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
) && ($last = $occurrence));
// Make sure as_of_date is still valid, may have to move forward
if(egw_time::to($as_of_date,'ts') < egw_time::to($last,'ts') ||
egw_time::to($as_of_date, 'Ymd') == egw_time::to($last, 'Ymd'))
if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
{
$event['start'] = egw_time::to($rriter->current(),'ts') + $offset;
$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
}
//error_log(__METHOD__ ." Series should end at " . egw_time::to($last) . " New series starts at " . egw_time::to($event['start']));
//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
if ($duration)
{
$event['end'] = $event['start'] + $duration;
@ -1135,37 +1142,37 @@ class calendar_uiforms extends calendar_ui
{
$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
}
//error_log(__LINE__.": event[start]=$event[start]=".egw_time::to($event['start']).", duration={$duration}, event[end]=$event[end]=".egw_time::to($event['end']).", offset=$offset\n");
//error_log(__LINE__.": event[start]=$event[start]=".Api\DateTime::to($event['start']).", duration={$duration}, event[end]=$event[end]=".Api\DateTime::to($event['end']).", offset=$offset\n");
$event['participants'] = $old_event['participants'];
foreach ($old_event['recur_exception'] as $key => $exdate)
{
if ($exdate > egw_time::to($last,'ts'))
if ($exdate > Api\DateTime::to($last,'ts'))
{
//error_log("Moved exception on " . egw_time::to($exdate));
//error_log("Moved exception on " . Api\DateTime::to($exdate));
unset($old_event['recur_exception'][$key]);
$event['recur_exception'][$key] += $offset;
}
else
{
//error_log("Kept exception on ". egw_time::to($exdate));
//error_log("Kept exception on ". Api\DateTime::to($exdate));
unset($event['recur_exception'][$key]);
}
}
$last->setTime(0, 0, 0);
$old_event['recur_enddate'] = egw_time::to($last, 'ts');
$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
{
$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
htmlspecialchars(egw::link('/index.php',array(
htmlspecialchars(Egw::link('/index.php',array(
'menuaction' => 'calendar.calendar_uiforms.edit',
'cal_id' => $content['id'],
'cal_id' => $event['id'],
))).'">','</a>');
$event = $orig_event;
}
}
$event['start'] = egw_time::to($event['start'],'ts');
$event['start'] = Api\DateTime::to($event['start'],'ts');
return $msg;
}
@ -1262,7 +1269,7 @@ class calendar_uiforms extends calendar_ui
'preset[size]' => filesize($ics_file),
);
if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
$response = egw_json_response::get();
$response = Api\Json\Response::get();
$response->call('app.calendar.custom_mail', $vars);
}
@ -1276,7 +1283,7 @@ class calendar_uiforms extends calendar_ui
{
if (is_numeric($uid))
{
return common::grab_owner_name($uid);
return Api\Accounts::username($uid);
}
elseif (($info = $this->bo->resource_info($uid)))
{
@ -1353,14 +1360,14 @@ class calendar_uiforms extends calendar_ui
}
// vfs path
if (!empty($_GET['ical_vfs']) &&
(!egw_vfs::file_exists($_GET['ical_vfs']) || !($_GET['ical'] = file_get_contents(egw_vfs::PREFIX.$_GET['ical_vfs']))))
(!Vfs::file_exists($_GET['ical_vfs']) || !($_GET['ical'] = file_get_contents(Vfs::PREFIX.$_GET['ical_vfs']))))
{
//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
$event =& $this->default_add_event();
}
if (!empty($_GET['ical_data']) &&
!($_GET['ical'] = egw_link::get_data($_GET['ical_data'])))
!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
{
//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
@ -1410,12 +1417,12 @@ class calendar_uiforms extends calendar_ui
{
if (!$preserv['no_popup'])
{
egw_framework::window_close(lang('Permission denied'));
Framework::window_close(lang('Permission denied'));
}
else
{
$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
common::egw_exit();
exit();
}
}
$event =& $this->default_add_event();
@ -1431,7 +1438,7 @@ class calendar_uiforms extends calendar_ui
}
else
{
$date = $this->bo->so->startOfDay(new egw_time($_GET['date'], egw_time::$user_timezone));
$date = $this->bo->so->startOfDay(new Api\DateTime($_GET['date'], Api\DateTime::$user_timezone));
$date->setUser();
}
$event = $this->bo->read($cal_id, $date, true);
@ -1447,8 +1454,8 @@ class calendar_uiforms extends calendar_ui
}
}
// set new start and end if given by $_GET
if(isset($_GET['start'])) { $event['start'] = egw_time::to($_GET['start'],'ts'); }
if(isset($_GET['end'])) { $event['end'] = egw_time::to($_GET['end'],'ts'); }
if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
// check if the event is the whole day
$start = $this->bo->date2array($event['start']);
@ -1468,13 +1475,13 @@ class calendar_uiforms extends calendar_ui
}
if(!$n)
{
$event['title'] = egw_link::title($link_app,$link_id);
$event['title'] = Link::title($link_app,$link_id);
// ask first linked app via "calendar_set" hook, for further data to set, incl. links
if (($set = $GLOBALS['egw']->hooks->single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
{
foreach((array)$set['link_app'] as $i => $l_app)
{
if (($l_id=$set['link_id'][$i])) egw_link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
}
unset($set['link_app']);
unset($set['link_id']);
@ -1482,39 +1489,39 @@ class calendar_uiforms extends calendar_ui
$event = array_merge($event,$set);
}
}
egw_link::link('calendar',$link_to_id,$link_app,$link_id);
Link::link('calendar',$link_to_id,$link_app,$link_id);
}
}
}
$etpl = new etemplate_new();
$etpl = new Etemplate();
if (!$etpl->read($preserv['template']))
{
$etpl->read($preserv['template'] = 'calendar.edit');
}
$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event);
$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
//echo "view=$view, event="; _debug_array($event);
// shared locking of entries to edit
if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
{
$lock_path = egw_vfs::app_entry_lock_path('calendar',$event['id']);
$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock
{
egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
}
if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
{
$msg .= ' '.lang('This entry is currently opened by %1!',
(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
common::grab_owner_name($lock_uid) : $lock['owner']));
Api\Accounts::username($lock_uid) : $lock['owner']));
}
elseif($lock)
{
$preserv['lock_token'] = $lock['token'];
}
elseif(egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
{
//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
}
@ -1534,7 +1541,7 @@ class calendar_uiforms extends calendar_ui
'view' => $view,
'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
));
egw_framework::message($msg, $msg_type);
Framework::message($msg, $msg_type);
$content['duration'] = $content['end'] - $content['start'];
if (isset($this->durations[$content['duration']])) $content['end'] = '';
@ -1586,7 +1593,7 @@ class calendar_uiforms extends calendar_ui
if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
$readonlys['participants'][$row]['status'] = $no_status;
if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event))
if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
$readonlys['participants']['delete'][$uid] = true;
// todo: make the participants available as links with email as title
$content['participants'][$row++]['title'] = $this->get_title($uid);
@ -1599,7 +1606,7 @@ class calendar_uiforms extends calendar_ui
usort($members, array($this, 'uid_title_cmp'));
foreach($members as $member)
{
if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member))
if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
{
$preserv['participants'][$row] = $content['participants'][$row] = array(
'app' => 'Group invitation',
@ -1608,8 +1615,8 @@ class calendar_uiforms extends calendar_ui
);
$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
// read access is enough to invite participants, but you need edit rights to change status
$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(EGW_ACL_EDIT,0,$member);
$content['participants'][$row++]['title'] = common::grab_owner_name($member);
$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
$content['participants'][$row++]['title'] = Api\Accounts::username($member);
}
}
}
@ -1631,7 +1638,7 @@ class calendar_uiforms extends calendar_ui
$content['alarm'] = array(false);
foreach(array_values($event['alarm']) as $id => $alarm)
{
if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ,0,$alarm['owner']))
if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
{
continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
}
@ -1652,7 +1659,7 @@ class calendar_uiforms extends calendar_ui
$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
$content['alarm'][] = $alarm;
$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
}
if (count($content['alarm']) == 1)
{
@ -1682,7 +1689,7 @@ class calendar_uiforms extends calendar_ui
// respect category permissions
if(!empty($event['category']))
{
$content['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
}
}
else
@ -1720,13 +1727,13 @@ class calendar_uiforms extends calendar_ui
{
$readonlys['action'] = true;
}
if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
{
$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
}
$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE,$event);
$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users
if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users
{
$sel_options['owner'][0] = lang('All participants');
}
@ -1736,7 +1743,7 @@ class calendar_uiforms extends calendar_ui
}
foreach((array) $event['participant_types']['u'] as $uid => $status)
{
if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(EGW_ACL_EDIT,0,$uid))
if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
{
$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
}
@ -1798,12 +1805,12 @@ class calendar_uiforms extends calendar_ui
*/
function ajax_unlock($id,$token)
{
$lock_path = egw_vfs::app_entry_lock_path('calendar',$id);
$lock_path = Vfs::app_entry_lock_path('calendar',$id);
$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
{
egw_vfs::unlock($lock_path,$token,false);
Vfs::unlock($lock_path,$token,false);
}
}
@ -1833,7 +1840,7 @@ class calendar_uiforms extends calendar_ui
$ical_string = $_GET['ical'];
if ($ical_string == 'session' || $_usesession)
{
$session_data = egw_cache::getSession('calendar', 'ical');
$session_data = Api\Cache::getSession('calendar', 'ical');
$ical_string = $session_data['attachment'];
$ical_charset = $session_data['charset'];
$ical_method = $session_data['method'];
@ -1843,7 +1850,7 @@ class calendar_uiforms extends calendar_ui
if (!($events = $ical->icaltoegw($ical_string, '', $ical_charset)) || count($events) != 1)
{
error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
$GLOBALS['egw']->framework->render(html::fieldset('<pre>'.htmlspecialchars($ical_string).'</pre>',
$GLOBALS['egw']->framework->render(Api\Html::fieldset('<pre>'.htmlspecialchars($ical_string).'</pre>',
lang('Error: importing the iCal')));
return;
}
@ -1956,7 +1963,7 @@ class calendar_uiforms extends calendar_ui
if (!$event['id'])
{
// if organizer is a EGroupware user, but we have no rights to organizers calendar
if (isset($event['owner']) && !$this->bo->check_perms(EGW_ACL_ADD,0,$event['owner']))
if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
{
// --> make organize a participant with role chair and current user the owner
$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@ -1999,7 +2006,7 @@ class calendar_uiforms extends calendar_ui
// add notification-errors, if we have some
$msg = array_merge((array)$msg, notifications::errors(true));
}
egw_framework::message(implode("\n", (array)$msg));
Framework::message(implode("\n", (array)$msg));
$readonlys['button[edit]'] = !$event['id'];
$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
switch(strtolower($ical_method))
@ -2015,7 +2022,7 @@ class calendar_uiforms extends calendar_ui
$event['ics_method_label'] = lang('Meeting request');
break;
}
$tpl = new etemplate_new('calendar.meeting');
$tpl = new Etemplate('calendar.meeting');
$tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event, 2);
}
@ -2033,7 +2040,7 @@ class calendar_uiforms extends calendar_ui
foreach($conflicts as $k => $conflict)
{
$is_readable = $this->bo->check_perms(EGW_ACL_READ,$conflict);
$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
$conflicts[$k] += array(
'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
@ -2051,7 +2058,7 @@ class calendar_uiforms extends calendar_ui
'conflicts' => array_values($conflicts), // conflicts have id-start as key
);
$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
$resources_config = config::read('resources');
$resources_config = Api\Config::read('resources');
$readonlys = array();
foreach (array_keys($allConflicts) as $pId)
@ -2090,7 +2097,7 @@ class calendar_uiforms extends calendar_ui
*/
function ajax_freetimesearch(array $edit_content)
{
$response = egw_json_response::get();
$response = Api\Json\Response::get();
//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
// convert start/end date-time values to timestamps
@ -2098,7 +2105,7 @@ class calendar_uiforms extends calendar_ui
{
if (!empty($edit_content[$name]))
{
$date = new egw_time($edit_content[$name]);
$date = new Api\DateTime($edit_content[$name]);
$edit_content[$name] = $date->format('ts');
}
}
@ -2148,7 +2155,7 @@ class calendar_uiforms extends calendar_ui
$content['search_window'] = 7 * DAY_s;
// store content in session
egw_cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
@ -2174,7 +2181,7 @@ class calendar_uiforms extends calendar_ui
*/
function freetimesearch($content = null)
{
$etpl = new etemplate_new('calendar.freetimesearch');
$etpl = new Etemplate('calendar.freetimesearch');
$sel_options['search_window'] = array(
7*DAY_s => lang('one week'),
14*DAY_s => lang('two weeks'),
@ -2185,8 +2192,8 @@ class calendar_uiforms extends calendar_ui
if (!is_array($content))
{
// get content from session (and delete it immediatly)
$content = egw_cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
egw_cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
$sTime = $content['start_time'];
@ -2413,13 +2420,13 @@ class calendar_uiforms extends calendar_ui
{
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
throw new egw_exception_no_permission_admin();
throw new Api\Exception\NoPermission\Admin();
}
if ($_content)
{
list($button) = each($_content['button']);
unset($_content['button']);
if ($button != 'cancel') // store changed acl
if ($button != 'cancel') // store changed Acl
{
foreach($_content as $data)
{
@ -2435,7 +2442,7 @@ class calendar_uiforms extends calendar_ui
}
if ($button != 'apply') // end dialog
{
egw::redirect_link('/index.php', array(
Egw::redirect_link('/index.php', array(
'menuaction' => 'admin.admin_ui.index',
'ajax' => 'true'
), 'admin');
@ -2468,7 +2475,7 @@ class calendar_uiforms extends calendar_ui
$content[] = array('cat_id' => '');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
$tmp = new etemplate_new('calendar.cat_acl');
$tmp = new Etemplate('calendar.cat_acl');
$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
}
@ -2524,8 +2531,8 @@ class calendar_uiforms extends calendar_ui
{
$content['history']['filter'] = array(
'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
);
}
@ -2576,7 +2583,7 @@ class calendar_uiforms extends calendar_ui
$return = false;
break;
}
else if ($owner > 0 && $this->bo->check_perms(EGW_ACL_EDIT, $eventId,0,'ts',$date))
else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
{
$return = false;
break;
@ -2597,7 +2604,7 @@ class calendar_uiforms extends calendar_ui
// If we have a recuring event for a particular day, make an exception
if ($event['recur_type'] != MCAL_RECUR_NONE && $date)
{
$d = new egw_time($date, egw_time::$user_timezone);
$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
if (!empty($event['whole_day']))
{
$d =& $this->bo->so->startOfDay($d);
@ -2606,9 +2613,11 @@ class calendar_uiforms extends calendar_ui
$event = $this->bo->read($eventId, $d, true);
// For DnD, create an exception if they gave the date
$preserv = null;
$this->_create_exception($event,$preserv);
unset($event['id']);
$messages = null;
$conflicts = $this->bo->update($event,false,true,false,true,$messages);
if (!is_array($conflicts) && $conflicts)
{
@ -2626,7 +2635,7 @@ class calendar_uiforms extends calendar_ui
}
}
$d = new egw_time($targetDateTime, egw_time::$user_timezone);
$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
$event['start'] = $d->format('ts');
$event['end'] = $event['start']+$duration;
@ -2634,7 +2643,7 @@ class calendar_uiforms extends calendar_ui
{
// calculate offset against clicked recurrance,
// depending on which is smaller
$offset = egw_time::to($targetDateTime,'ts') - egw_time::to($seriesInstance,'ts');
$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
$event['start'] = $old_event['start'] + $offset;
$event['duration'] = $duration;
@ -2657,6 +2666,7 @@ class calendar_uiforms extends calendar_ui
$event['non_blocking'] = false;
// If there's a conflict, it won't save the change and the conflict popup will be blank
// so save the change now, and then let the conflict check happen.
$message = null;
$this->bo->update($event,true, true, false, true, $message,true);
// Whole day non blocking with DAY_s would add a day
@ -2697,7 +2707,7 @@ class calendar_uiforms extends calendar_ui
$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
$this->update_client($event['id'],$d);
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if(!is_array($conflicts) && $conflicts)
{
if(is_int($conflicts))
@ -2751,7 +2761,7 @@ class calendar_uiforms extends calendar_ui
// If we have a recuring event for a particular day, make an exception
if ($event['recur_type'] != MCAL_RECUR_NONE && $date)
{
$d = new egw_time($date, egw_time::$user_timezone);
$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
if (!empty($event['whole_day']))
{
$d =& $this->bo->so->startOfDay($date);
@ -2785,7 +2795,7 @@ class calendar_uiforms extends calendar_ui
{
list($id, $date) = explode(':',$eventId);
$event=$this->bo->read($id);
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if ($this->bo->delete($event['id'], (int)$date))
{
@ -2817,14 +2827,14 @@ class calendar_uiforms extends calendar_ui
if (!is_array($mailContent) && ($_GET['egw_data']))
{
// get raw mail data
egw_link::get_data ($_GET['egw_data']);
Link::get_data ($_GET['egw_data']);
return false;
}
if (is_array($mailContent))
{
// Addressbook
$AB = new addressbook_bo();
$AB = new Api\Contacts();
$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
$participants[0] = array (
@ -2885,19 +2895,19 @@ class calendar_uiforms extends calendar_ui
{
if($attachment['egw_data'])
{
egw_link::link('calendar',$event['link_to']['to_id'],egw_link::DATA_APPNAME, $attachment);
Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment);
}
else if(is_readable($attachment['tmp_name']) ||
(egw_vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
{
egw_link::link('calendar',$event['link_to']['to_id'],'file', $attachment);
Link::link('calendar',$event['link_to']['to_id'],'file', $attachment);
}
}
}
}
else
{
egw_framework::window_close(lang('No content found to show up as calendar entry.'));
Framework::window_close(lang('No content found to show up as calendar entry.'));
}
return $this->process_edit($event);

View File

@ -10,6 +10,13 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* Class to generate the calendar listview and the search
*
@ -51,7 +58,7 @@ class calendar_uilist extends calendar_ui
/**
* Constructor
*
* @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST
* @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST
*/
function __construct($set_states=null)
{
@ -68,48 +75,49 @@ class calendar_uilist extends calendar_ui
/**
* Show the listview
*/
function listview($content=null,$msg='',$home=false)
function listview($_content=null,$msg='',$home=false)
{
if ($_GET['msg']) $msg .= $_GET['msg'];
if ($this->group_warning) $msg .= $this->group_warning;
$etpl = new etemplate_new('calendar.list');
$etpl = new Etemplate('calendar.list');
// Handle merge from sidebox
if($_GET['merge'])
{
$content['nm']['action'] = 'document_'.$_GET['merge'];
$content['nm']['select_all'] = true;
$_content['nm']['action'] = 'document_'.$_GET['merge'];
$_content['nm']['select_all'] = true;
}
if (is_array($content))
if (is_array($_content))
{
// handle a single button like actions
foreach(array('delete','timesheet','document') as $button)
{
if ($content['nm']['rows'][$button])
if ($_content['nm']['rows'][$button])
{
list($id) = each($content['nm']['rows'][$button]);
$content['nm']['action'] = $button;
$content['nm']['selected'] = array($id);
list($id) = each($_content['nm']['rows'][$button]);
$_content['nm']['action'] = $button;
$_content['nm']['selected'] = array($id);
}
}
// Handle actions
if ($content['nm']['action'])
if ($_content['nm']['action'])
{
// Allow merge using the date range filter
if(strpos($content['nm']['action'],'document') !== false &&
!count($content['nm']['selected']) && !$content['nm']['select_all']) {
$content['nm']['selected'][] = $this->get_merge_range($content['nm']);
if(strpos($_content['nm']['action'],'document') !== false &&
!count($_content['nm']['selected']) && !$_content['nm']['select_all']) {
$_content['nm']['selected'][] = $this->get_merge_range($_content['nm']);
}
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
if (!count($_content['nm']['selected']) && !$_content['nm']['select_all'])
{
$msg = lang('You need to select some events first');
}
else
{
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']))
$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);
}
@ -121,7 +129,7 @@ class calendar_uilist extends calendar_ui
}
}
$content = array(
'nm' => egw_session::appsession('calendar_list','calendar'),
'nm' => Api\Cache::getSession('calendar', 'calendar_list'),
);
if (!is_array($content['nm']))
{
@ -155,6 +163,7 @@ class calendar_uilist extends calendar_ui
if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) &&
!empty($json_data['request']['parameters'][0]))
{
$params = null;
parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
if (isset($params['keywords'])) // new search => set filters so every match is shown
{
@ -168,7 +177,7 @@ class calendar_uilist extends calendar_ui
$sel_options['filter'] = &$this->date_filters;
// Send categories for row styling - calendar uses no_cat, so they don't go automatically
$sel_options['category'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,calendar',$no_lang,false,$value['cat_id']);
$sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar');
// Prevent double encoding - widget does this on its own, but we're just grabbing the options
foreach($sel_options['category'] as &$label)
{
@ -192,9 +201,9 @@ class calendar_uilist extends calendar_ui
if($msg)
{
egw_framework::message($msg);
Framework::message($msg);
}
$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,$readonlys,array(),$home ? -1 : 0);
$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0);
// Not sure why this has to be echoed instead of appended, but that's what works.
//echo calendar_uiviews::edit_series();
@ -229,10 +238,11 @@ class calendar_uilist extends calendar_ui
* @internal
* @param array &$params parameters
* @param array &$rows returned rows/events
* @param array &$readonlys eg. to disable buttons based on acl
* @param array &$readonlys eg. to disable buttons based on Acl
*/
function get_rows(&$params,&$rows,&$readonlys)
{
unset($readonlys); // not used;
//echo "uilist::get_rows() params="; _debug_array($params);
if ($params['filter'] == 'custom')
{
@ -251,7 +261,7 @@ class calendar_uilist extends calendar_ui
$this->manage_states(array('date' => $this->bo->date2string($params['startdate'])));
}
}
$old_params = egw_session::appsession('calendar_list','calendar');
$old_params = Api\Cache::getSession('calendar', 'calendar_list');
if (is_array($old_params))
{
if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly
@ -264,7 +274,7 @@ class calendar_uilist extends calendar_ui
$this->adjust_for_search($params['search'],$params);
}
}
if (!$params['csv_export']) egw_session::appsession('calendar_list','calendar',$params);
if (!$params['csv_export']) Api\Cache::setSession('calendar', 'calendar_list', $params);
// do we need to query custom fields and which
// Check stored preference if selectcols isn't available (ie: first call)
@ -292,22 +302,22 @@ class calendar_uilist extends calendar_ui
);
// Non-blocking events above blocking
$search_params['order'] .= ', cal_non_blocking DESC';
switch($params['filter'])
{
case 'all':
break;
case 'before':
$search_params['end'] = $params['date'] ? egw_time::to($params['date'],'ts') : $this->date;
$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date;
$label = lang('Before %1',$this->bo->long_date($search_params['end']));
break;
case 'custom':
$this->first = $search_params['start'] = egw_time::to($params['startdate'],'ts');
$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts');
$this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
$label = $this->bo->long_date($this->first,$this->last);
break;
case 'today':
$today = new egw_time();
$today = new Api\DateTime();
$today->setTime(0, 0, 0);
$this->first = $search_params['start'] = $today->format('ts');
$today->setTime(23,59,59);
@ -324,8 +334,8 @@ class calendar_uilist extends calendar_ui
$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
$search_params['start'] = $this->first;
$search_params['end'] = $this->last;
$params['startdate'] = egw_time::to($this->first, egw_time::ET2);
$params['enddate'] = egw_time::to($this->last, egw_time::ET2);
$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
$params['enddate'] = Api\DateTime::to($this->last, Api\DateTime::ET2);
break;
case 'month':
@ -340,14 +350,14 @@ class calendar_uilist extends calendar_ui
$this->last--;
$search_params['start'] = $this->first;
$search_params['end'] = $this->last;
$params['startdate'] = egw_time::to($this->first, egw_time::ET2);
$params['enddate'] = egw_time::to($this->last, egw_time::ET2);
$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
$params['enddate'] = Api\DateTime::to($this->last, Api\DateTime::ET2);
break;
// fall through to after given date
case 'after':
default:
$this->date = $params['startdate'] ? egw_time::to($params['startdate'],'ts') : $this->date;
$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date;
$label = lang('After %1',$this->bo->long_date($this->date));
$search_params['start'] = $this->date;
break;
@ -381,7 +391,7 @@ class calendar_uilist extends calendar_ui
// it to match changing list filters
if($params['view'] && $params['view'] == 'listview')
{
egw_json_response::get()->call('app.calendar.set_app_header',
Api\Json\Response::get()->call('app.calendar.set_app_header',
(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') .
$label);
}
@ -397,7 +407,7 @@ class calendar_uilist extends calendar_ui
$this->to_client($event);
}
$matches = null;
if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
{
$app = $matches[1];
@ -405,7 +415,7 @@ class calendar_uilist extends calendar_ui
$icons = array();
if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
{
$icons[] = html::image('calendar','private');
$icons[] = Api\Html::image('calendar','private');
}
else
{
@ -414,7 +424,7 @@ class calendar_uilist extends calendar_ui
}
else
{
$is_private = !$this->bo->check_perms(EGW_ACL_READ,$event);
$is_private = !$this->bo->check_perms(Acl::READ,$event);
}
if ($is_private)
{
@ -445,17 +455,13 @@ class calendar_uilist extends calendar_ui
}
elseif ($event['recur_type'] != MCAL_RECUR_NONE)
{
$event['app_id'] .= ':'.egw_time::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
}
else
{
$view_link = egw::link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
}
// Format start and end with timezone
foreach(array('start','end') as $time)
{
$event[$time] = egw_time::to($event[$time],'Y-m-d\TH:i:s\Z');
$event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z');
}
$rows[] = $event;
@ -472,13 +478,13 @@ class calendar_uilist extends calendar_ui
$users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']);
$this->bo->warnings['groupmembers'] = '';
if($message = $this->check_owners_access($users,$no_access))
if(($message = $this->check_owners_access($users)))
{
egw_json_response::get()->error($message);
Api\Json\Response::get()->error($message);
}
else if($this->bo->warnings['groupmembers'])
{
egw_json_response::get()->error($this->bo->warnings['groupmembers']);
Api\Json\Response::get()->error($this->bo->warnings['groupmembers']);
}
$rows['sel_options']['filter'] = $this->date_filters;
if($label)
@ -492,7 +498,7 @@ class calendar_uilist extends calendar_ui
$app = $this->bo->resources[$owner[0]]['app'];
$_owner = substr($owner,1);
// Try link first
$title = egw_link::title($app, $_owner );
$title = Link::title($app, $_owner );
if($title)
{
$rows['sel_options']['owner'][$owner] = $title;
@ -555,9 +561,10 @@ class calendar_uilist extends calendar_ui
if ($use_all)
{
// get the whole selection
$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar');
$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
$query['num_rows'] = -1; // all
$readonlys = null;
$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document'))); // true = only return the id's
// Get rid of any extras (rows that aren't events)
if(in_array($action,array('ical','document')))
@ -574,8 +581,9 @@ class calendar_uilist extends calendar_ui
// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
elseif($action == 'document')
{
$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar');
$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
$events = null;
$this->get_rows($query,$events,$readonlys);
foreach($events as $key => $event)
{
@ -602,9 +610,9 @@ class calendar_uilist extends calendar_ui
}
$boical = new calendar_ical();
$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
html::content_header('event.ics', 'text/calendar', bytes($ical));
Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical));
echo $ical;
common::egw_exit();
exit();
case 'document':
if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];
@ -627,6 +635,7 @@ class calendar_uilist extends calendar_ui
{
$id = $id['id'];
}
$matches = null;
if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
{
$app = $matches[1];
@ -662,9 +671,9 @@ class calendar_uilist extends calendar_ui
}
}
if(egw_json_response::isJSONResponse())
if(Api\Json\Response::isJSONResponse())
{
egw_json_response::get()->call('egw.refresh','','calendar',$id,'delete');
Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete');
}
}
else
@ -679,7 +688,7 @@ class calendar_uilist extends calendar_ui
// unDelete the whole thing
$recur_date = 0;
}
if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) &&
if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) &&
is_array($event) && $event['deleted'])
{
$event['deleted'] = null;
@ -687,10 +696,10 @@ class calendar_uilist extends calendar_ui
{
$success++;
if(egw_json_response::isJSONResponse())
if(Api\Json\Response::isJSONResponse())
{
egw_json_response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
egw_json_response::get()->call('egw.refresh','','calendar',$id,'edit');
Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
}
break;
}
@ -702,6 +711,7 @@ class calendar_uilist extends calendar_ui
if($id && ($event = $this->bo->read($id, $recur_date)))
{
$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
$quantity = $role = null;
calendar_so::split_status($old_status, $quantity, $role);
if ($old_status != $status)
{
@ -710,9 +720,9 @@ class calendar_uilist extends calendar_ui
if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
false,true,$skip_notification))
{
if(egw_json_response::isJSONResponse())
if(Api\Json\Response::isJSONResponse())
{
egw_json_response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
}
$success++;
//$msg = lang('Status changed');
@ -735,7 +745,7 @@ class calendar_uilist extends calendar_ui
}
elseif ($app)
{
$query = egw_session::appsession('calendar_list','calendar');
$query = Api\Cache::getSession('calendar', 'calendar_list');
$query['query'] = $app_id;
$query['search'] = $app_id;
$result = $this->bo->search($query);
@ -775,14 +785,14 @@ class calendar_uilist extends calendar_ui
$err = $timesheet_bo->save($timesheet);
//get the project manager linked to the calnedar entry
$calApp_links = egw_link::get_links('calendar', $event['id']);
$calApp_links = Link::get_links('calendar', $event['id']);
foreach ($calApp_links as $l_app)
{
if ($l_app['app'] == 'projectmanager')
{
$prj_links = $l_app;
//Links timesheet to projectmanager
egw_link::link('timesheet', $timesheet_bo->data['ts_id'], 'projectmanager', $prj_links['id']);
Link::link('timesheet', $timesheet_bo->data['ts_id'], 'projectmanager', $prj_links['id']);
}
}
@ -795,7 +805,7 @@ class calendar_uilist extends calendar_ui
if(!$recur_date || $app) {
// Create link
$link_id = $app ? $app_id : $id;
egw_link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
}
}
else
@ -867,7 +877,7 @@ class calendar_uilist extends calendar_ui
'default' => true,
'allowOnMultiple' => false,
'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
'popup' => egw_link::get_registry('calendar', 'view_popup'),
'popup' => Link::get_registry('calendar', 'view_popup'),
'group' => $group=1,
'onExecute' => 'javaScript:app.calendar.cal_open',
'disableClass' => 'rowNoView',
@ -877,7 +887,7 @@ class calendar_uilist extends calendar_ui
'group' => $group,
'disableClass' => 'rowNoView',
'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id&action=copy',
'popup' => egw_link::get_registry('calendar', 'view_popup'),
'popup' => Link::get_registry('calendar', 'view_popup'),
'allowOnMultiple' => false,
),
'select_all' => array(
@ -923,7 +933,7 @@ class calendar_uilist extends calendar_ui
'group' => $group,
'allowOnMultiple' => false,
'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=calendar&action_id=$id',
'popup' => egw_link::get_registry('infolog', 'add_popup'),
'popup' => Link::get_registry('infolog', 'add_popup'),
);
}
if ($GLOBALS['egw_info']['user']['apps']['timesheet'])
@ -936,7 +946,7 @@ class calendar_uilist extends calendar_ui
'allowOnMultiple' => false,
'hideOnDisabled' => true, // show only one timesheet action in context menu
'onExecute' => 'javaScript:app.calendar.cal_fix_app_id',
'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'popup' => Link::get_registry('timesheet', 'add_popup'),
);
$actions['timesheet-add'] = array( // automatic add for multiple events
'icon' => 'timesheet/navbar',
@ -956,7 +966,7 @@ class calendar_uilist extends calendar_ui
);
$actions['documents'] = calendar_merge::document_action(
$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
$this->bo->cal_prefs['default_document'],bo_merge::getExportLimit('calendar')
$this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar')
);
++$group;
$actions['delete'] = array(

View File

@ -1,15 +1,22 @@
<?php
/**
* eGroupWare - Calendar's views and widgets
* EGroupware - Calendar's views and widgets
*
* @link http://www.egroupware.org
* @package calendar
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2004-15 by RalfBecker-At-outdoor-training.de
* @copyright (c) 2004-16 by RalfBecker-At-outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* Class to generate the calendar views and the necesary widgets
*
@ -139,7 +146,7 @@ class calendar_uiviews extends calendar_ui
// Check for GET message (from merge)
if($_GET['msg'])
{
egw_framework::message($_GET['msg']);
Framework::message($_GET['msg']);
unset($_GET['msg']);
}
// standard params for calling bocal::search for all views
@ -173,7 +180,7 @@ class calendar_uiviews extends calendar_ui
*/
public function week_number($time)
{
if (!is_a($time,'DateTime')) $time = new egw_time($time);
if (!is_a($time,'DateTime')) $time = new Api\DateTime($time);
// if week does not start Monday and $time is Sunday --> add one day
if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
@ -199,11 +206,11 @@ class calendar_uiviews extends calendar_ui
$this->manage_states(array_merge($content,json_decode($content['view'],true)));
if($content['first'])
{
$this->first = egw_time::to($content['first'],'ts');
$this->first = Api\DateTime::to($content['first'],'ts');
}
if($content['last'])
{
$this->last = egw_time::to($content['last'],'ts');
$this->last = Api\DateTime::to($content['last'],'ts');
}
$_GET['merge'] = $content['merge'];
$this->merge();
@ -223,32 +230,32 @@ class calendar_uiviews extends calendar_ui
{
$GLOBALS['egw_info']['flags']['nonavbar'] = true;
$this->manage_states($_GET);
$old_calendar = $this->{$this->view}();
$this->{$this->view}();
return;
}
// Toolbar
$tmpl = new etemplate_new('calendar.toolbar');
$tmpl = new Etemplate('calendar.toolbar');
$tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content));
// Adjust toolbar for mobile
if(html::$ua_mobile){
if(Api\Header\UserAgent::mobile()){
$tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar');
$tmpl->setElementAttribute('toolbar','view_range', '3');
}
$tmpl->exec('calendar_uiviews::index',array());
// Load the different views once, we'll switch between them on the client side
$tmpl = new etemplate_new('calendar.todo');
$todo = new Etemplate('calendar.todo');
$label = '';
$tmpl->exec('calendar_uiviews::index',array('todos'=>$this->get_todos($label), 'label' => $label));
$todo->exec('calendar_uiviews::index',array('todos'=>$this->get_todos($label), 'label' => $label));
// Actually, this takes care of most of it...
$this->week();
$tmpl = new etemplate_new('calendar.planner');
$planner = new Etemplate('calendar.planner');
// Get the actions
$tmpl->setElementAttribute('planner','actions',$this->get_actions());
$tmpl->exec('calendar_uiviews::index',array());
$planner->setElementAttribute('planner','actions',$this->get_actions());
$planner->exec('calendar_uiviews::index',array());
// List view in a separate file
$list_ui = new calendar_uilist();
@ -257,10 +264,8 @@ class calendar_uiviews extends calendar_ui
/**
* Generate the calendar toolbar actions
*
* @param Array $content
*/
protected function getToolbarActions($content = array())
protected function getToolbarActions()
{
$group = 0;
$actions = array(
@ -388,7 +393,7 @@ class calendar_uiviews extends calendar_ui
'toolbarDefault' => true,
),
);
if (html::$ua_mobile)
if (Api\Header\UserAgent::mobile())
{
foreach (array_keys($actions) as $key)
{
@ -454,7 +459,7 @@ class calendar_uiviews extends calendar_ui
$merge = $this->merge();
if($merge)
{
egw::redirect_link('/index.php',array(
Egw::redirect_link('/index.php',array(
'menuaction' => 'calendar.calendar_uiviews.index',
'msg' => $merge,
));
@ -473,10 +478,10 @@ class calendar_uiviews extends calendar_ui
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));
$tmpl = $home ? $home :new etemplate_new('calendar.planner');
$tmpl = $home ? $home : new Etemplate('calendar.planner');
$tmpl->setElementAttribute('planner','start_date', egw_time::to($this->first, egw_time::ET2));
$tmpl->setElementAttribute('planner','end_date', egw_time::to($this->last, egw_time::ET2));
$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));
$tmpl->setElementAttribute('planner','owner', $search_params['users']);
$tmpl->setElementAttribute('planner','group_by', $this->sortby);
// Get the actions
@ -535,11 +540,11 @@ class calendar_uiviews extends calendar_ui
}
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));
// Loop through, using egw_time to handle DST
// Loop through, using Api\DateTime to handle DST
$week = 0;
$week_start = new EGroupware\Api\DateTime($this->first);
$week_start->setTime(0,0,0);
$week_end = new egw_time($week_start);
$week_end = new Api\DateTime($week_start);
$week_end->add(new DateInterval('P6DT23H59M59S'));
$last = new EGroupware\Api\DateTime($this->last);
for ($week_start; $week_start < $last; $week_start->add('1 week'), $week_end->add('1 week'))
@ -585,12 +590,12 @@ class calendar_uiviews extends calendar_ui
}
// 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!!!
$last = $this->bo->date2array($last);
$last['day'] += 6;
$last['hour'] = 23;
$last['min'] = $last['sec'] = 59;
unset($last['raw']); // otherwise date2ts does not calc raw new, but uses it
$last = $this->bo->date2ts($last);
$arr = $this->bo->date2array($last);
$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);
}
/**
@ -602,7 +607,7 @@ class calendar_uiviews extends calendar_ui
*/
private function close_button($uid)
{
return html::a_href(html::image('phpgwapi', 'close.button', 'Close','style="width: 12px; padding-top: 1px;"'), array(
return Api\Html::a_href(Api\Html::image('phpgwapi', 'close.button', 'Close','style="width: 12px; padding-top: 1px;"'), array(
'menuaction' => 'calendar.calendar_uiviews.index',
'close' => $uid,
));
@ -702,7 +707,7 @@ class calendar_uiviews extends calendar_ui
}
else
{
foreach($this->_get_planner_users(false) as $uid => $label)
foreach(array_keys($this->_get_planner_users(false)) as $uid)
{
$search_params['users'] = $uid;
$content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params))
@ -710,8 +715,8 @@ class calendar_uiviews extends calendar_ui
}
}
}
$tmpl = $home ? $home :new etemplate_new('calendar.view');
foreach($content['view'] as $index => $week)
$tmpl = $home ? $home :new Etemplate('calendar.view');
foreach(array_keys($content['view']) as $index)
{
$tmpl->setElementAttribute("view[$index]",'granularity',$granularity);
$tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']);
@ -726,9 +731,9 @@ class calendar_uiviews extends calendar_ui
/**
* Get todos via AJAX
*/
public static function ajax_get_todos($date, $owner)
public static function ajax_get_todos($_date, $owner)
{
$date = egw_time::to($date, 'array');
$date = Api\DateTime::to($_date, 'array');
$ui = new calendar_uiviews();
$ui->year = $date['year'];
$ui->month = $date['month'];
@ -737,7 +742,7 @@ class calendar_uiviews extends calendar_ui
$label = '';
$todos = $ui->get_todos($label);
egw_json_response::get()->data(array(
Api\Json\Response::get()->data(array(
'label' => $label,
'todos' => $todos
));
@ -748,11 +753,11 @@ class calendar_uiviews extends calendar_ui
*
* @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
* On return $todo_label contains the label for the todo-box
* @return string/boolean html with a table of open todo's or false if no hook availible
* @return string/boolean Api\Html with a table of open todo's or false if no hook availible
*/
function get_todos(&$todo_label)
{
$todos_from_hook = $GLOBALS['egw']->hooks->process(array(
$todos_from_hook = Api\Hooks::process(array(
'location' => 'calendar_include_todos',
'year' => $this->year,
'month' => $this->month,
@ -802,12 +807,11 @@ class calendar_uiviews extends calendar_ui
if($todo['edit']) {
$todo['edit_size'] = $todo['edit']['size'];
unset($todo['edit']['size']);
$edit_icon_href = html::a_href( $icons, $todo['edit'],'',' data-todo="app|'.$width.'x'.$height.'" ');
$edit_href = html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
$todo['edit'] = egw_framework::link('/index.php',$todo['edit'],true);
$edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|'.$width.'x'.$height.'" ');
$edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
$todo['edit'] = Framework::link('/index.php',$todo['edit'],true);
}
$icon_href = html::a_href($icons,$todo['view']);
$href = html::a_href($todo['title'], $todo['view']);
$icon_href = Api\Html::a_href($icons,$todo['view']);
$content .= " <tr class=\"$class\">\n <td valign=\"top\" width=\"15%\" nowrap>".
($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)).
"</td>\n <td>".($this->printer_friendly?$todo['title']:
@ -865,10 +869,9 @@ class calendar_uiviews extends calendar_ui
*
* @param int $start time in minutes
* @param int $end time in minutes
* @param int $minimum = 0 minimum height
* @return float height in percent
*/
function times2height($start,$end,$minimum=0)
function times2height($start,$end)
{
$minimum = $this->rowHeight;
$height = $this->time2pos($end) - $this->time2pos($start);
@ -898,9 +901,9 @@ class calendar_uiviews extends calendar_ui
// determine if the browser supports scrollIntoView: IE4+, firefox1.0+ and safari2.0+ does
// then show all hours in a div of the size of the workday and scroll to the workday start
// still disabled, as things need to be re-aranged first, to that the column headers are not scrolled
$this->scroll_to_wdstart = false;/*$this->use_time_grid && (html::$user_agent == 'msie' ||
html::$user_agent == 'mozilla' && html::ua_version >= 5.0 ||
html::$user_agent == 'safari' && html::ua_version >= 2.0);*/
$this->scroll_to_wdstart = false;/*$this->use_time_grid && (Api\Header\UserAgent::type() == 'msie' ||
Api\Header\UserAgent::type() == 'mozilla' && Api\Html::ua_version >= 5.0 ||
Api\Header\UserAgent::type() == 'safari' && Api\Html::ua_version >= 2.0);*/
if ($this->scroll_to_wdstart)
{
@ -959,7 +962,7 @@ class calendar_uiviews extends calendar_ui
);
if (!isset($show[$this->granularity_m]) ? $t % 60 == 0 : in_array($t % 60,$show[$this->granularity_m]))
{
$time = $GLOBALS['egw']->common->formattime(sprintf('%02d',$t/60),sprintf('%02d',$t%60));
$time = common::formattime(sprintf('%02d',$t/60),sprintf('%02d',$t%60));
}
if ($add_links) $time = $this->add_link($time,$this->date,(int) ($t/60),$t%60);
$html .= $indent."\t\t".'<div class="calendar_calTimeRowTime">'.$time."</div>\n";
@ -977,7 +980,7 @@ class calendar_uiviews extends calendar_ui
$html .= $indent."\t".'<div id="calendar_calDayCols" class="calendar_calDayCols'.
($this->use_time_grid ? ($this->bo->common_prefs['timeformat'] == 12 ? '12h' : '') : 'NoTime').'">'."\n";
if (html::$user_agent == 'msie') // necessary IE hack - stupid thing ...
if (Api\Header\UserAgent::type() == 'msie') // necessary IE hack - stupid thing ...
{
// Lars Kneschke 2005-08-28
// why do we use a div in a div which has the same height and width???
@ -1007,7 +1010,7 @@ class calendar_uiviews extends calendar_ui
$dayColWidth,$indent."\t\t",$short_title,++$on_off & 1,$col_owner);
++$n;
}
if (html::$user_agent == 'msie') $html .= "</div>\n";
if (Api\Header\UserAgent::type() == 'msie') $html .= "</div>\n";
$html .= $indent."\t</div>\n"; // calendar_calDayCols
}
@ -1106,13 +1109,13 @@ class calendar_uiviews extends calendar_ui
);
$this->_day_class_holiday($day_ymd,$class,$holidays);
// the weekday and date
if (!$short_title && $holidays) $title .= html::htmlspecialchars(': '.$holidays);
if (!$short_title && $holidays) $title .= Api\Html::htmlspecialchars(': '.$holidays);
if ($short_title === true)
{
if ($this->allowEdit)
{
$title = html::a_href($title,$day_view,'',
$title = Api\Html::a_href($title,$day_view,'',
!isset($this->holidays[$day_ymd])?' title="'.$this->bo->long_date($ts,0,false,true).'"':'');
}
}
@ -1122,7 +1125,7 @@ class calendar_uiviews extends calendar_ui
$day_view['date'] = $this->bo->date2string($ts -= 12*HOUR_s);
if ($this->allowEdit)
{
$title = html::a_href(html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' <span> '.$title;
$title = Api\Html::a_href(Api\Html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' <span> '.$title;
}
else
{
@ -1131,7 +1134,7 @@ class calendar_uiviews extends calendar_ui
$day_view['date'] = $this->bo->date2string($ts += 48*HOUR_s);
if ($this->allowEdit)
{
$title .= ' </span> '.html::a_href(html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
$title .= ' </span> '.Api\Html::a_href(Api\Html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
}
else
{
@ -1140,7 +1143,7 @@ class calendar_uiviews extends calendar_ui
}
if (is_bool($short_title) || ($short_title != "")) {
$html .= $indent."\t".'<div style="height: '. $this->rowHeight .'%;" class="calendar_calDayColHeader '.$class.'"'.
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"':'').'>'.$title."</div>\n";
($holidays ? ' title="'.Api\Html::htmlspecialchars($holidays).'"':'').'>'.$title."</div>\n";
}
if ($this->use_time_grid)
@ -1148,7 +1151,7 @@ class calendar_uiviews extends calendar_ui
// drag and drop: check if the current user has EDIT permissions on the grid
if($owner)
{
$dropPermission = $this->bo->check_perms(EGW_ACL_EDIT,0,$owner);
$dropPermission = $this->bo->check_perms(Acl::EDIT,0,$owner);
}
else
{
@ -1224,7 +1227,7 @@ class calendar_uiviews extends calendar_ui
* @param boolean $only_weekend = false show only the weekend in header-color, otherwise every second days is shown too
* @param boolean $show_bdays = true If available, also show birthdays (or hide Bdays)
* Note that this is not the place to disable a preference.
* If the preferences allow birthdays to be displayed, they are cached within the holidays structure.
* If the Api\Preferences allow birthdays to be displayed, they are cached within the holidays structure.
* This setting just suppressing the available data in the view.
*/
function _day_class_holiday($day_ymd,&$class,&$holidays,$only_weekend=false,$show_bdays=true)
@ -1327,7 +1330,7 @@ class calendar_uiviews extends calendar_ui
* @param $width int width of the widget
* @param string $indent string for correct indention
* @param int $owner owner of the calendar the event is in
* @param boolean $return_array = false should an array with keys(tooltip,popup,html) be returned or the complete widget as string
* @param boolean $return_array = false should an array with keys(tooltip,popup,Api\Html) be returned or the complete widget as string
* @param string $block = 'event_widget' template used the render the widget
* @param int $z_index is the z-index of the drag-drobable outer box of the event.
* @return string/array
@ -1341,7 +1344,7 @@ class calendar_uiviews extends calendar_ui
static $tpl = False;
if (!$tpl)
{
$tpl = new Template(common::get_tpl_dir('calendar'));
$tpl = new Framework\Template(Framework\Template::get_dir('calendar'));
$tpl->set_file('event_widget_t','event_widget.tpl');
$tpl->set_block('event_widget_t','event_widget');
@ -1371,7 +1374,7 @@ class calendar_uiviews extends calendar_ui
$app_id = $matches[2];
if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
{
$icons[] = html::image('calendar','private');
$icons[] = Api\Html::image('calendar','private');
}
else
{
@ -1380,16 +1383,16 @@ class calendar_uiviews extends calendar_ui
}
elseif($event['id'])
{
if (($is_private = !$this->bo->check_perms(EGW_ACL_READ,$event)))
if (($is_private = !$this->bo->check_perms(Acl::READ,$event)))
{
$icons = array(html::image('calendar','private'));
$icons = array(Api\Html::image('calendar','private'));
}
else
{
$icons = $this->event_icons($event);
}
}
$cats = $this->bo->categories($this->categories->check_list(EGW_ACL_READ, $event['category']),$color);
$cats = $this->bo->categories($this->categories->check_list(Acl::READ, $event['category']),$color);
// these values control varius aspects of the geometry of the eventWidget
$small_trigger_width = 120 + 20*count($icons);
$corner_radius=$width > $small_trigger_width ? 10 : 5;
@ -1462,14 +1465,14 @@ class calendar_uiviews extends calendar_ui
$tpl->set_var(array(
// event-content, some of it displays only if it really has content or is needed
'owner' => $GLOBALS['egw']->common->grab_owner_name($event['owner']),
'owner' => Api\Accounts::username($event['owner']),
'header_icons' => $small ? '' : implode("",$icons),
'body_icons' => $small ? implode("\n",$icons) : '',
'icons' => implode('',$icons),
'timespan' => $timespan,
'title' => ($title = !$is_private ? html::htmlspecialchars($event['title']) : lang('private')),
'title' => ($title = !$is_private ? Api\Html::htmlspecialchars($event['title']) : lang('private')),
'header' => $small_height ? $title : $timespan,
'description' => !$is_private ? nl2br(html::htmlspecialchars($event['description'])) : '',
'description' => !$is_private ? nl2br(Api\Html::htmlspecialchars($event['description'])) : '',
'location' => !$is_private ? $this->add_nonempty($event['location'],lang('Location')) : '',
'participants' => $participants,
'times' => !$event['multiday'] ? $this->add_nonempty($this->bo->timespan($event['start_m'],$event['end_m'],true),lang('Time')) :
@ -1480,7 +1483,7 @@ class calendar_uiviews extends calendar_ui
$this->add_nonempty($this->bo->format_date($event['end']),lang('End')),
'category' => !$is_private ? $this->add_nonempty($cats,lang('Category')) : '',
// the tooltip is based on the content of the actual widget, this way it takes no extra bandwidth/volum
// 'tooltip' => html::tooltip(False,False,array('BorderWidth'=>0,'Padding'=>0)),
// 'tooltip' => Api\Html::tooltip(False,False,array('BorderWidth'=>0,'Padding'=>0)),
// various aspects of the geometry or style
'corner_radius' => $corner_radius.'px',
'header_height' => $header_height.'px',
@ -1517,7 +1520,7 @@ class calendar_uiviews extends calendar_ui
// to be able to show some lines of description text
if ($event['whole_day'] || ($event['end'] - $event['start']) > ($this->cal_prefs['interval'] * 3 * 60))
{
$tpl->set_var('bodydescription', !$is_private ? nl2br(html::htmlspecialchars($event['description'])) : '');
$tpl->set_var('bodydescription', !$is_private ? nl2br(Api\Html::htmlspecialchars($event['description'])) : '');
}
// set the bodydescription to empty if it is not visible
else
@ -1547,7 +1550,7 @@ class calendar_uiviews extends calendar_ui
$popup = $event['id']."|n";
}
}
$tooltip = html::htmlspecialchars($tooltip, true); // true=need double-encoding, as it is transported as attribute!
$tooltip = Api\Html::htmlspecialchars($tooltip, true); // true=need double-encoding, as it is transported as attribute!
//_debug_array($event);
if ($return_array)
@ -1586,7 +1589,7 @@ class calendar_uiviews extends calendar_ui
$z_index = is_null($z_index) ? 20 : (int)$z_index;
if ($this->use_time_grid &&
((int)$event['id'] || substr($event['id'],0,7) == 'infolog') && $this->bo->check_perms(EGW_ACL_EDIT,$event))
((int)$event['id'] || substr($event['id'],0,7) == 'infolog') && $this->bo->check_perms(Acl::EDIT,$event))
{
if (!$event['whole_day_on_top'] &&
!$event['whole_day'] &&
@ -1652,11 +1655,11 @@ class calendar_uiviews extends calendar_ui
}
else
{
$edit = egw_link::edit($app,$id,$popup_size);
$edit = Link::edit($app,$id,$popup_size);
}
if ($edit)
{
$view_link = egw::link('/index.php',$edit);
$view_link = Egw::link('/index.php',$edit);
if ($popup_size)
{
@ -1691,16 +1694,16 @@ class calendar_uiviews extends calendar_ui
foreach(explode(',',$event['icons']) as $icon)
{
list($icon_app,$icon) = explode(':',$icon);
if (common::find_image($icon_app,$icon))
if (Api\Image::find($icon_app,$icon))
{
$icons[] = html::image($icon_app,$icon);
$icons[] = Api\Html::image($icon_app,$icon);
}
}
}
$app_data = calendar_bo::integration_get_data($app,'icons');
if (is_null($app_data))
{
$icons[] = html::image($app,'navbar'); // use navbar icon
$icons[] = Api\Html::image($app,'navbar'); // use navbar icon
}
elseif ($app_data)
{
@ -1809,7 +1812,7 @@ class calendar_uiviews extends calendar_ui
case 'month':
$title = lang('Month');
$sort2label = array();
$time = new egw_time($start);
$time = new Api\DateTime($start);
for($n = 0; $n < self::YEARLY_PLANNER_NUM_MONTH; ++$n)
{
$sort2label[$time->format('Y-m')] = lang($time->format('F')).' '.$time->format('Y');
@ -1937,12 +1940,12 @@ class calendar_uiviews extends calendar_ui
$by_cat === 'user' && $this->cal_prefs['planner_show_empty_rows'] == 'cat' ||
is_int($by_cat) && $this->cal_prefs['planner_show_empty_rows'] == 'user'))
{
continue; // dont show empty categories or user rows
continue; // dont show empty Api\Categories or user rows
}
$class = $class == 'row_on' ? 'row_off' : 'row_on';
if ($by_cat === 'month')
{
$time = new egw_time($sort.'-01');
$time = new Api\DateTime($sort.'-01');
$start = $time->format('ts');
$time->modify('+1month -1second');
$end = $time->format('ts');
@ -1983,7 +1986,7 @@ class calendar_uiviews extends calendar_ui
{
foreach((array) $GLOBALS['egw']->accounts->members($user, true) as $user)
{
if ($this->bo->check_perms(EGW_ACL_READ | EGW_ACL_FREEBUSY,0,$user))
if ($this->bo->check_perms(Acl::READ | calendar_bo::ACL_FREEBUSY,0,$user))
{
$users[$user] = $this->bo->participant_name($user);
}
@ -2005,7 +2008,7 @@ class calendar_uiviews extends calendar_ui
}
/**
* get all categories used as sort criteria for the planner by category
* get all Api\Categories used as sort criteria for the planner by category
*
* the returned cat is as direct sub-category of $this->cat_id or a main (level 1) category if !$this->cat_id
*
@ -2093,11 +2096,11 @@ class calendar_uiviews extends calendar_ui
if ($this->day >= 15) $prev = $t_arr; // we stay in the same month
$prev['day'] = $this->day < 15 ? 15 : 1;
$half = $this->bo->date2string($prev);
$title = html::a_href(html::image('phpgwapi','first',lang('back one month'),$options=' alt="<<"'),array(
$title = Api\Html::a_href(Api\Html::image('phpgwapi','first',lang('back one month'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $full,
)) . ' &nbsp; '.
html::a_href(html::image('phpgwapi','left',lang('back half a month'),$options=' alt="<"'),array(
Api\Html::a_href(Api\Html::image('phpgwapi','left',lang('back half a month'),$options=' alt="<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $half,
)) . ' &nbsp; '.$title;
@ -2119,11 +2122,11 @@ class calendar_uiviews extends calendar_ui
if ($this->day < 15) $next = $t_arr; // we stay in the same month
$next['day'] = $this->day < 15 ? 15 : 1;
$half = $this->bo->date2string($next);
$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward half a month'),$options=' alt=">>"'),array(
$title .= ' &nbsp; '.Api\Html::a_href(Api\Html::image('phpgwapi','right',lang('forward half a month'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $half,
)). ' &nbsp; '.
html::a_href(html::image('phpgwapi','last',lang('forward one month'),$options=' alt=">>"'),array(
Api\Html::a_href(Api\Html::image('phpgwapi','last',lang('forward one month'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $full,
));
@ -2160,21 +2163,21 @@ class calendar_uiviews extends calendar_ui
$title = lang('Week').' '.$this->week_number($t);
if ($days > 7)
{
$title = html::a_href($title,array(
$title = Api\Html::a_href($title,array(
'menuaction' => 'calendar.calendar_uiviews.planner',
'planner_days' => 7,
'date' => date('Ymd',$t),
),false,' title="'.html::htmlspecialchars(lang('Weekview')).'"');
),false,' title="'.Api\Html::htmlspecialchars(lang('Weekview')).'"');
}
else
{
// prev. week
$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
$title = Api\Html::a_href(Api\Html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$t-7*DAY_s),
)) . ' &nbsp; <b>'.$title;
// next week
$title .= '</b> &nbsp; '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
$title .= '</b> &nbsp; '.Api\Html::a_href(Api\Html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$t+7*DAY_s),
));
@ -2218,31 +2221,31 @@ class calendar_uiviews extends calendar_ui
}
if ($days > 1)
{
$title = html::a_href($title,array(
$title = Api\Html::a_href($title,array(
'menuaction' => 'calendar.calendar_uiviews.planner',
'planner_days' => 1,
'date' => date('Ymd',$t),
),false,strpos($class,'calendar_calHoliday') !== false || strpos($class,'calendar_calBirthday') !== false ? '' : ' title="'.html::htmlspecialchars(lang('Dayview')).'"');
),false,strpos($class,'calendar_calHoliday') !== false || strpos($class,'calendar_calBirthday') !== false ? '' : ' title="'.Api\Html::htmlspecialchars(lang('Dayview')).'"');
}
if ($days < 5)
{
if (!$i) // prev. day only for the first day
{
$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
$title = Api\Html::a_href(Api\Html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$start-DAY_s),
)) . ' &nbsp; '.$title;
}
if ($i == $days-1) // next day only for the last day
{
$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
$title .= ' &nbsp; '.Api\Html::a_href(Api\Html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$start+DAY_s),
));
}
}
$content .= $indent."\t".'<div class="calendar_plannerDayScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;"'.
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
($holidays ? ' title="'.Api\Html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
}
$content .= $indent."</div>\n"; // end of plannerScale
@ -2262,11 +2265,11 @@ class calendar_uiviews extends calendar_ui
// month scale with navigation
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
$title = lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
$title = lang(Api\DateTime::to($this->first,'F')).' '.Api\DateTime::to($this->first,'Y').' - '.
lang(Api\DateTime::to($this->last,'F')).' '.Api\DateTime::to($this->last,'Y');
// calculate date for navigation links
$time = new egw_time($this->first);
$time = new Api\DateTime($this->first);
$time->modify('-1year');
$last_year = $time->format('Ymd');
$time->modify('+11month');
@ -2276,19 +2279,19 @@ class calendar_uiviews extends calendar_ui
$time->modify('+11month');
$next_year = $time->format('Ymd');
$title = html::a_href(html::image('phpgwapi','first',lang('back one year'),$options=' alt="<<"'),array(
$title = Api\Html::a_href(Api\Html::image('phpgwapi','first',lang('back one year'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $last_year,
)) . ' &nbsp; '.
html::a_href(html::image('phpgwapi','left',lang('back one month'),$options=' alt="<"'),array(
Api\Html::a_href(Api\Html::image('phpgwapi','left',lang('back one month'),$options=' alt="<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $last_month,
)) . ' &nbsp; '.$title;
$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward one month'),$options=' alt=">>"'),array(
$title .= ' &nbsp; '.Api\Html::a_href(Api\Html::image('phpgwapi','right',lang('forward one month'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $next_month,
)). ' &nbsp; '.
html::a_href(html::image('phpgwapi','last',lang('forward one year'),$options=' alt=">>"'),array(
Api\Html::a_href(Api\Html::image('phpgwapi','last',lang('forward one year'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $next_year,
));
@ -2299,7 +2302,7 @@ class calendar_uiviews extends calendar_ui
// day of month scale
$content .= $indent.'<div class="calendar_plannerScale">'."\n";
$today = egw_time::to('now','d');
$today = Api\DateTime::to('now','d');
for($left = 0,$i = 0; $i < 31; $left += $day_width,++$i)
{
$class = $i & 1 ? 'row_on' : 'row_off';
@ -2433,7 +2436,7 @@ class calendar_uiviews extends calendar_ui
{
$content .= $indent.'<div class="calendar_eventRowsMarkedDay '.$class.
'" style="left: '.$left.'%; width:'.$day_width.'%;"'.
($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').
($holidays ? ' title="'.Api\Html::htmlspecialchars($holidays).'"' : '').
' ></div>'."\n";
}
}
@ -2536,7 +2539,7 @@ class calendar_uiviews extends calendar_ui
$width = $this->_planner_pos($event['end'],$start,$end) - $left;
$color = $data['color'] ? $data['color'] : 'gray';
$tooltip = html::htmlspecialchars(str_replace(array("\n","\r","'",'"'),array('','',"\\'",'&quot;'),$data['tooltip']));
$tooltip = Api\Html::htmlspecialchars(str_replace(array("\n","\r","'",'"'),array('','',"\\'",'&quot;'),$data['tooltip']));
return $indent.'<div class="calendar_plannerEvent'.($data['private'] ? 'Private' : '').'" style="left: '.$left.
'%; width: '.$width.'%; background-color: '.$color.';"'.'data-tooltip="'. $tooltip.'" '.
'" data-date ="'.$this->bo->date2string($event['start']).'|'.$data['popup'].'">'."\n".$data['html'].$indent."</div>\n";
@ -2657,7 +2660,7 @@ class calendar_uiviews extends calendar_ui
/**
*
* Returns the special icon html code for holidays
* Returns the special icon Api\Html code for holidays
*
* @param string $type is the type of the holiday, currently either 'hday' or
* 'bday'
@ -2667,9 +2670,9 @@ class calendar_uiviews extends calendar_ui
//Set the special icon which will be prepended to the event
switch ($type) {
case "bday":
return html::image('calendar', 'cake', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
return Api\Html::image('calendar', 'cake', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
case "hday":
return html::image('calendar', 'date', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
return Api\Html::image('calendar', 'date', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Wizard for Adressbook CSV export
* EGroupware - Wizard for Adressbook CSV export
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -9,6 +9,8 @@
* @version $Id$
*/
use EGroupware\Api;
class calendar_wizard_export_csv extends importexport_wizard_basic_export_csv
{
public function __construct() {
@ -21,12 +23,9 @@ class calendar_wizard_export_csv extends importexport_wizard_basic_export_csv
unset($this->export_fields['participants-c']);
unset($this->export_fields['participants-r']);
$custom = config::get_customfields('calendar', true);
$custom = Api\Storage\Customfields::get('calendar', true);
foreach($custom as $name => $data) {
$this->export_fields['#'.$name] = $data['label'];
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Wizard for user CSV import
* EGroupware - Wizard for user CSV import
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
class calendar_wizard_import_csv extends importexport_wizard_basic_import_csv
{
@ -30,7 +32,7 @@ class calendar_wizard_import_csv extends importexport_wizard_basic_import_csv
// List each custom field
unset($this->mapping_fields['customfields']);
$custom = config::get_customfields('calendar');
$custom = Api\Storage\Customfields::get('calendar');
foreach($custom as $name => $data) {
$this->mapping_fields['#'.$name] = $data['label'];
}
@ -52,7 +54,7 @@ class calendar_wizard_import_csv extends importexport_wizard_basic_import_csv
{
$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
$content['msg'] .= "\n*" ;
return $result;
}

View File

@ -12,6 +12,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Acl;
/**
* Required for TZID <--> AS timezone blog test, if script is called directly via URL
*/
@ -57,9 +60,9 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
private $calendar;
/**
* Instance of addressbook_bo
* Instance of Api\Contacts
*
* @var addressbook_bo
* @var Api\Contacts
*/
private $addressbook;
@ -211,7 +214,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
{
foreach($this->calendar->so->get_recurrence_exceptions($event,
egw_time::$server_timezone->getName(), $cutoffdate, 0, 'all') as $recur_date)
Api\DateTime::$server_timezone->getName(), $cutoffdate, 0, 'all') as $recur_date)
{
$messagelist[] = $this->StatMessage($id, $event['id'].':'.$recur_date);
}
@ -544,7 +547,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
}
if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD, $old_event ? $old_event : 0,$account))
if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
{
// @todo: write in users calendar and make account only a participant
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!");
@ -605,7 +608,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
$save_event = $this->message2event($exception, $account, $ex_event);
$save_event['participants'] = $participants; // not contained in $exception
$save_event['reference'] = $event['id'];
$save_event['recurrence'] = egw_time::server2user($exception->exceptionstarttime);
$save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime);
$ex_ok = $this->calendar->save($save_event);
ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) saving exception=".array2string($save_event).' returned '.array2string($ex_ok));
//error_log(__METHOD__."('$folderid',$id,...) exception=".array2string($exception).") saving exception=".array2string($save_event).' returned '.array2string($ex_ok));
@ -633,7 +636,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
'end' => 'endtime',
) as $key => $attr)
{
if (isset($message->$attr)) $event[$key] = egw_time::server2user($message->$attr);
if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
}
// copying strings
foreach(array(
@ -683,7 +686,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
//'n_fn' => $attendee->name, // not sure if we want matches without email
);
// search addressbook for participant
if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo();
if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
if ((list($data) = $this->addressbook->search($search,
array('id','egw_addressbook.account_id as account_id','n_fn'),
'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
@ -810,14 +813,14 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
}
if ($message->recurrence->until)
{
$event['recur_enddate'] = egw_time::server2user($message->recurrence->until);
$event['recur_enddate'] = Api\DateTime::server2user($message->recurrence->until);
}
$event['recur_exceptions'] = array();
if ($message->exceptions)
{
foreach($message->exceptions as $exception)
{
$event['recur_exception'][] = egw_time::server2user($exception->exceptionstarttime);
$event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime);
}
$event['recur_exception'] = array_unique($event['recur_exception']);
}
@ -1132,7 +1135,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
$message->categories = array();
foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id)
{
$message->categories[] = categories::id2name($cat_id);
$message->categories[] = Api\Categories::id2name($cat_id);
}
// recurring information, only if not a single recurrence eg. virtual exception (!$recur_date)
@ -1221,7 +1224,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
/* disabled virtual exceptions for now, as AS does NOT support changed participants or status
// add virtual exceptions here too (get_recurrence_exceptions should be able to return real-exceptions too!)
foreach($this->calendar->so->get_recurrence_exceptions($event,
egw_time::$server_timezone->getName(), $cutoffdate, 0, 'all') as $exception_time)
Api\DateTime::$server_timezone->getName(), $cutoffdate, 0, 'all') as $exception_time)
{
// exceptions seems to be full SyncAppointments, with only exceptionstarttime required
$exception = $this->GetMessage($folderid, $event['id'].':'.$exception_time, $contentparameters);
@ -1275,7 +1278,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
$backup = $this->calendar->debug;
//$this->calendar->debug = 2;
list($id) = explode(':',$id);
$this->calendar->check_perms(EGW_ACL_FREEBUSY, $id, 0, 'server');
$this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server');
$this->calendar->debug = $backup;
}
else
@ -1343,7 +1346,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
* - "dstbias": offset in minutes for no DST --> DST, usually 60 or 0 for no DST
*
* @link http://download.microsoft.com/download/5/D/D/5DD33FDF-91F5-496D-9884-0A0B0EE698BB/%5BMS-ASDTYPE%5D.pdf
* @throws egw_exception_assertion_failed if no vtimezone data found for given timezone
* @throws Api\Exception\AssertionFailed if no vtimezone data found for given timezone
*/
static public function tz2as($tz)
{
@ -1401,7 +1404,7 @@ END:VTIMEZONE
}
else
{
throw new egw_exception_assertion_failed("NO standard component for '$name' in '$component'!");
throw new Api\Exception\AssertionFailed("NO standard component for '$name' in '$component'!");
}
}
// get bias and dstbias from standard component, which is present in all tz's
@ -1548,7 +1551,7 @@ END:VTIMEZONE
{
if (!$n) // check users timezone first
{
$tz = egw_time::$user_timezone->getName();
$tz = Api\DateTime::$user_timezone->getName();
}
elseif (!($tz = calendar_timezones::id2tz($n))) // no further timezones to check
{

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Calendar Holidays
* EGroupware - Calendar Holidays
*
* @link http://www.egroupware.org
* @package calendar
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* Storage layer for calendar holidays
*
@ -22,7 +24,7 @@ class soholiday
/**
* Reference to the global db-object
*
* @var egw_db
* @var Api\Db
*/
var $db;
var $table = 'egw_cal_holidays';

File diff suppressed because it is too large Load Diff

View File

@ -1,72 +0,0 @@
<?php
/**
* eGroupWare Calendar: rounded corners
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package calendar
* @copyright (c) 2004-9 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
include_once('../../phpgwapi/inc/common_functions.inc.php');
check_load_extension('gd',true); // true = throw exception if not loadable
foreach(array('width'=>1,'height'=>1,'color1'=>'000080','color2'=>'ffffff') as $name => $default)
{
$$name = isset($_GET[$name]) ? $_GET[$name] : $default;
}
foreach(array('color1','color2') as $name)
{
preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or
die("Wrong value '".htmlspecialchars($$name)."' for $name, should be something like #80FFFF' !!!");
$$name = array('r'=>hexdec($rgb[1]),'g'=>hexdec($rgb[2]),'b'=>hexdec($rgb[3]));
}
$image = @imagecreate(abs($width),abs($height))
or die("Cannot Initialize new GD image stream");
$length = max($width,$height);
$dist = $length / 256;
if ($dist < 1) $dist = 1;
$anz = round($length / $dist);
foreach ($color1 as $c => $val)
{
$c_step[$c] = ($color2[$c] - $val) / $anz;
}
$rgb = $color1;
for ($l = 0; $l < $length; $l += $dist)
{
$color = imagecolorallocate($image,(int)$rgb['r'],(int)$rgb['g'],(int)$rgb['b']);
foreach($rgb as $c => $val)
{
$rgb[$c] += $c_step[$c];
}
if ($width > $height)
{
imagefilledrectangle($image,(int)$l,0,(int) ($l+$dist),$height-1,$color);
}
else
{
imagefilledrectangle($image,0,(int)$l,$width-1,(int) ($l+$dist),$color);
}
}
// allow caching for 7 days
header('Cache-Control: public');
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+7*24*60*60) . ' GMT');
if (function_exists('imagegif'))
{
header("Content-type: image/gif");
imagegif($image);
}
else
{
header("Content-type: image/png");
imagepng($image);
}
imagedestroy($image);

View File

@ -1,73 +0,0 @@
<?php
/**
* eGroupWare Calendar: rounded corners
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package calendar
* @copyright (c) 2004-9 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
include_once('../../phpgwapi/inc/common_functions.inc.php');
check_load_extension('gd',true); // true = throw exception if not loadable
foreach(array('width'=>-20,'height'=>40,'border'=>1,'color'=>'000080','bgcolor'=>'0000FF') as $name => $default)
{
$$name = isset($_GET[$name]) ? $_GET[$name] : $default;
}
$image = @imagecreate(abs($width),abs($height))
or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($image, 254, 254, 254);
imagecolortransparent($image, $white);
foreach(array('color','bgcolor') as $name)
{
preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or
die("Wrong value '".htmlspecialchars($$name)."' for $name, should be something like #80FFFF' !!!");
$$name = imagecolorallocate($image,hexdec($rgb[1]),hexdec($rgb[2]),hexdec($rgb[3]));
}
$radius = min(abs($width),abs($height));
$center_x = $width > 0 ? abs($width)-$radius-1 : $radius;
$center_y = $height < 0 ? abs($height)-$radius-1 : $radius;
//echo "width=$width, height=$height => radius=$radius: center_x=$center_x, center_y=$center_y";
if ($border) imagefilledellipse($image,$center_x,$center_y,2*$radius,2*$radius,$color);
imagefilledellipse($image,$center_x,$center_y,2*($radius-$border),2*($radius-$border),$bgcolor);
if (abs($height) > abs($width))
{
if ($height < 0) // lower corners
{
$y1 = 0;
$y2 = abs($height)-$radius-1;
}
else
{
$y1 = $radius;
$y2 = abs($height)-1;
}
imagefilledrectangle($image,0,$y1,abs($width),$y2,$bgcolor);
if ($border)
{
$x1 = $width < 0 ? 0 : abs($width)-$border;
$x2 = $width < 0 ? $border-1 : abs($width)-1;
imagefilledrectangle($image,$x1,$y1,$x2,$y2,$color);
}
}
session_cache_limiter('public'); // allow caching
if (function_exists('imagegif'))
{
header("Content-type: image/gif");
imagegif($image);
}
else
{
header("Content-type: image/png");
imagepng($image);
}
imagedestroy($image);

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
*/
$setup_info['calendar']['name'] = 'calendar';
$setup_info['calendar']['version'] = '14.3.903';
$setup_info['calendar']['version'] = '16.1';
$setup_info['calendar']['app_order'] = 3;
$setup_info['calendar']['enable'] = 1;
$setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index&ajax=true';
@ -50,19 +50,6 @@ $setup_info['calendar']['hooks']['mail_import'] = 'calendar_hooks::mail_import';
/* Dependencies for this app to work */
$setup_info['calendar']['depends'][] = array(
'appname' => 'phpgwapi',
'versions' => Array('14.1')
);
$setup_info['calendar']['depends'][] = array(
'appname' => 'etemplate',
'versions' => Array('14.1')
);
// installation checks for calendar
$setup_info['calendar']['check_install'] = array(
// check if PEAR is availible
'' => array(
'func' => 'pear_check',
'from' => 'Calendar (iCal import+export)',
),
'appname' => 'api',
'versions' => Array('16.1')
);

View File

@ -9,6 +9,8 @@
* @version $Id$
*/
use EGroupware\Api;
function calendar_v0_9_2to0_9_3update_owner($table, $field)
{
$GLOBALS['egw_setup']->oProc->query("select distinct($field) from $table");
@ -1426,7 +1428,7 @@ function calendar_upgrade1_0_1_007()
function calendar_upgrade1_0_1_008()
{
$config_data = config::read('calendar');
$config_data = Api\Config::read('calendar');
if (isset($config_data['fields'])) // old custom fields
{
$customfields = array();
@ -1445,9 +1447,9 @@ function calendar_upgrade1_0_1_008()
}
if (count($customfields))
{
config::save_value('customfields', $customfields, 'calendar');
Api\Config::save_value('customfields', $customfields, 'calendar');
}
config::save_value('fields', null, 'calendar');
Api\Config::save_value('fields', null, 'calendar');
}
$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.009';
return $GLOBALS['setup_info']['calendar']['currentver'];
@ -1615,7 +1617,7 @@ function calendar_upgrade1_5_001()
function calendar_upgrade1_5_002()
{
// update the alarm methods
$async = new asyncservice();
$async = new Api\AsyncService();
foreach((array)$async->read('cal:%') as $job)
{
if ($job['method'] == 'calendar.bocalupdate.send_alarm')
@ -2261,7 +2263,7 @@ function calendar_upgrade1_9_009()
));
foreach($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id AS cal_id,range_start AS start,tz_tzid AS tzid,recur_type,recur_interval,recur_data FROM egw_cal_repeats JOIN egw_cal ON egw_cal.cal_id=egw_cal_repeats.cal_id LEFT JOIN egw_cal_timezones ON egw_cal.tz_id=egw_cal_timezones.tz_id', __LINE__, __FILE__) as $event)
{
if (!$event['tzid']) $event['tzid'] = egw_time::$server_timezone->getName();
if (!$event['tzid']) $event['tzid'] = Api\DateTime::$server_timezone->getName();
$rrule = calendar_rrule::event2rrule($event);
$rrule_str = '';
foreach($rrule->generate_rrule('2.0') as $name => $value)
@ -2324,7 +2326,7 @@ WHERE egw_cal_user.cal_recur_date=0 AND
FROM egw_cal_user master_user
WHERE master_user.cal_recur_date=0 AND master_user.cal_id=master.cal_id
)
ORDER BY master.cal_id DESC", __LINE__, __FILE__, 0, -1, false, egw_db::FETCH_ASSOC) as $row)
ORDER BY master.cal_id DESC", __LINE__, __FILE__, 0, -1, false, Api\Db::FETCH_ASSOC) as $row)
{
$GLOBALS['egw_setup']->db->insert('egw_cal_user', $row, false, __LINE__, __FILE__, 'calendar');
}
@ -2346,9 +2348,9 @@ FROM egw_cal
JOIN egw_cal_repeats ON egw_cal_repeats.cal_id=egw_cal.cal_id
JOIN egw_cal_dates ON egw_cal_dates.cal_id=egw_cal.cal_id AND cal_start=range_start
JOIN egw_cal_timezones ON egw_cal.tz_id=egw_cal_timezones.tz_id
WHERE range_end IS NOT NULL", __LINE__, __FILE__, 0, -1, false, egw_db::FETCH_ASSOC) as $event)
WHERE range_end IS NOT NULL", __LINE__, __FILE__, 0, -1, false, Api\Db::FETCH_ASSOC) as $event)
{
$event = egw_db::strip_array_keys($event, 'cal_');
$event = Api\Db::strip_array_keys($event, 'cal_');
$event['recur_enddate'] = $event['range_end'];
$rrule = calendar_rrule::event2rrule($event, false);
$rrule->rewind();
@ -2670,7 +2672,9 @@ function calendar_upgrade14_3_900()
*/
function calendar_upgrade14_3_901()
{
preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner) {
Api\Preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner)
{
unset($attr, $owner); // not used, but required by function signature
if($old_value['state'] && is_array($old_value['state']))
{
unset($old_value['state']['date']);
@ -2689,7 +2693,9 @@ function calendar_upgrade14_3_901()
*/
function calendar_upgrade14_3_902()
{
preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner) {
Api\Preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner)
{
unset($attr, $owner); // not used, but required by function signature
switch($old_value)
{
case 'all':
@ -2703,3 +2709,9 @@ function calendar_upgrade14_3_902()
});
return $GLOBALS['setup_info']['calendar']['currentver'] = '14.3.903';
}
function calendar_upgrade14_3_903()
{
return $GLOBALS['setup_info']['calendar']['currentver'] = '16.1';
}

View File

@ -9,6 +9,9 @@
* option) any later version. *
\**************************************************************************/
use EGroupware\Api;
use EGroupware\Api\Acl;
/* $Id$ */
/*
@ -168,7 +171,7 @@ class module_calendar_list extends Module
if (!isset($GLOBALS['egw']->accounts))
{
$GLOBALS['egw']->accounts = new accounts();
$GLOBALS['egw']->accounts = new Api\Accounts();
}
$this->accounts =& $GLOBALS['egw']->accounts;
$search_params = array(
@ -185,12 +188,12 @@ class module_calendar_list extends Module
{
$is_group = false;
$has_read_permissions = false;
$acl = new acl($entry['account_id']);
$acl = new Acl($entry['account_id']);
$acl->read_repository();
// get the rights for each account to check whether the anon user has read permissions.
$rights = $acl->get_rights($anon_user,'calendar');
// also add the anon user if it's his own calendar.
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user))
if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user))
{
$has_read_permissions = true;
}
@ -201,7 +204,7 @@ class module_calendar_list extends Module
foreach ($anon_groups as $parent_group)
{
$rights = $acl->get_rights($parent_group,'calendar');
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group))
if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group))
{
$has_read_permissions = true;
break;
@ -217,7 +220,7 @@ class module_calendar_list extends Module
}
else
{
$users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
$users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
}
}
}
@ -240,7 +243,7 @@ class module_calendar_list extends Module
function get_content(&$arguments,$properties)
{
$html = "";
$GLOBALS['egw']->translation->add_app('calendar');
Api\Translation::add_app('calendar');
$this->bo = new calendar_bo();
$this->ui = new calendar_uiviews();
$this->ui->allowEdit = false;
@ -259,7 +262,7 @@ class module_calendar_list extends Module
$first = $start = (int) ($this->bo->now_su +
(60 * 60 * 24 * 7 * $dateOffset));
}
if ($arguments['useWeekStart'])
if ($arguments['useWeekStart'])
{
$first = $this->ui->datetime->get_weekday_start(
adodb_date('Y',$start),

View File

@ -9,6 +9,10 @@
* option) any later version. *
\**************************************************************************/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
/* $Id$ */
class module_calendar_month extends Module
@ -32,9 +36,9 @@ class module_calendar_month extends Module
*/
var $uiviews;
/**
* Instance of the accounts object
* Instance of the Api\Accounts object
*
* @var accounts
* @var Api\Accounts
*/
var $accounts;
/**
@ -117,7 +121,7 @@ class module_calendar_month extends Module
if (! isset($GLOBALS['egw']->accounts))
{
$GLOBALS['egw']->accounts = new accounts();
$GLOBALS['egw']->accounts = new Api\Accounts();
}
$this->accounts =& $GLOBALS['egw']->accounts;
$search_params=array(
@ -163,12 +167,12 @@ class module_calendar_month extends Module
{
$is_group = false;
$has_read_permissions = false;
$acl = new acl($entry['account_id']);
$acl = new Acl($entry['account_id']);
$acl->read_repository();
// get the rights for each account to check whether the anon user has read permissions.
$rights = $acl->get_rights($anon_user,'calendar');
// also add the anon user if it's his own calendar.
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user))
if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user))
{
$has_read_permissions = true;
}
@ -179,7 +183,7 @@ class module_calendar_month extends Module
foreach ($anon_groups as $parent_group)
{
$rights = $acl->get_rights($parent_group,'calendar');
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group))
if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group))
{
$has_read_permissions = true;
break;
@ -195,7 +199,7 @@ class module_calendar_month extends Module
}
else
{
$users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
$users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
}
}
}
@ -218,7 +222,7 @@ class module_calendar_month extends Module
function get_content(&$arguments,$properties)
{
$html = "";
$GLOBALS['egw']->translation->add_app('calendar');
Api\Translation::add_app('calendar');
$this->ui = new calendar_uiviews();
$this->ui->allowEdit = false;
$this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false;
@ -300,7 +304,7 @@ class module_calendar_month extends Module
$title = lang('Wk').' '.adodb_date('W',$week_start);
if (!isset($GLOBALS['egw']->template))
{
$GLOBALS['egw']->template = new Template;
$GLOBALS['egw']->template = new Framework\Template;
}
$html .= $this->ui->timeGridWidget($this->ui->tagWholeDayOnTop($week),$weeks == 2 ? 30 : 60,200,'',$title,0,$week_start+WEEK_s >= $last);
}

View File

@ -10,6 +10,12 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* Calendar planner block for sitemgr
*/
@ -87,7 +93,7 @@ class module_calendar_planner extends Module
*/
function get_user_interface()
{
$cats = new categories('','calendar');
$cats = new Api\Categories('','calendar');
foreach($cats->return_array('all',0,False,'','cat_name','',True) as $cat)
{
$this->arguments['cat_id']['options'][$cat['id']] = str_repeat('&nbsp; ',$cat['level']).$cat['name'];
@ -99,7 +105,7 @@ class module_calendar_planner extends Module
if (!isset($GLOBALS['egw']->accounts))
{
$GLOBALS['egw']->accounts = new accounts();
$GLOBALS['egw']->accounts = new Api\Accounts();
}
$this->accounts =& $GLOBALS['egw']->accounts;
$search_params = array(
@ -116,12 +122,12 @@ class module_calendar_planner extends Module
{
$is_group = false;
$has_read_permissions = false;
$acl = new acl($entry['account_id']);
$acl = new Acl($entry['account_id']);
$acl->read_repository();
// get the rights for each account to check whether the anon user has read permissions.
$rights = $acl->get_rights($anon_user,'calendar');
// also add the anon user if it's his own calendar.
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user))
if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user))
{
$has_read_permissions = true;
}
@ -132,7 +138,7 @@ class module_calendar_planner extends Module
foreach ($anon_groups as $parent_group)
{
$rights = $acl->get_rights($parent_group,'calendar');
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group))
if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group))
{
$has_read_permissions = true;
break;
@ -148,7 +154,7 @@ class module_calendar_planner extends Module
}
else
{
$users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
$users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
}
}
}
@ -170,9 +176,9 @@ class module_calendar_planner extends Module
$options = array('start' => 0, 'num_rows' => 50);
foreach ($calendar_bo->resources as $type => $data)
{
if ($type != '' && $data['app'] && egw_link::get_registry($data['app'], 'query'))
if ($type != '' && $data['app'] && Link::get_registry($data['app'], 'query'))
{
$_results = egw_link::query($data['app'], $query,$options);
$_results = Link::query($data['app'], $query,$options);
}
if(!$_results) continue;
$_results = array_unique($_results);
@ -230,15 +236,15 @@ class module_calendar_planner extends Module
$html = '<style type="text/css">'."\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].self::CALENDAR_CSS.");\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].self::ETEMPLATE_CSS.");\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].categories::css(categories::GLOBAL_APPNAME).");\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].categories::css('calendar').");\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].Api\Categories::css(Api\Categories::GLOBAL_APPNAME).");\n";
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].Api\Categories::css('calendar').");\n";
$html .= '.popupMainDiv #calendar-planner { position: static;}
#calendar-planner .calendar_plannerWidget, #calendar-planner div.calendar_plannerRows {
height: auto !important;
}
</style>'."\n";
$html .= html::image('sitemgr', 'left', lang('Previous'), 'onclick=\'app.calendar.toolbar_action({id:"previous"});\'')
. html::image('sitemgr', 'right', lang('Next'), 'style="float: right;" onclick=\'app.calendar.toolbar_action({id:"next"});\'');
$html .= Api\Html::image('sitemgr', 'left', lang('Previous'), 'onclick=\'app.calendar.toolbar_action({id:"previous"});\'')
. Api\Html::image('sitemgr', 'right', lang('Next'), 'style="float: right;" onclick=\'app.calendar.toolbar_action({id:"next"});\'');
if (is_array($params['owner']))
{
@ -247,7 +253,7 @@ class module_calendar_planner extends Module
$html .= $buffer;
return '';
});
egw_framework::$header_done = true;
Framework::$header_done = true;
$ui = new calendar_uiviews();
$ui->sortby = $arguments['sortby'];
$ui->owner = $params['owner'];
@ -294,10 +300,10 @@ class module_calendar_planner extends Module
$ui->to_client($event);
}
$tmpl = new etemplate_new('calendar.planner');
$tmpl = new Etemplate('calendar.planner');
$tmpl->setElementAttribute('planner','start_date', egw_time::to($ui->first, egw_time::ET2));
$tmpl->setElementAttribute('planner','end_date', egw_time::to($ui->last, egw_time::ET2));
$tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($ui->first, Api\DateTime::ET2));
$tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2));
$tmpl->setElementAttribute('planner','owner', $search_params['owner']);
$tmpl->setElementAttribute('planner','group_by', $ui->sortby);
$tmpl->exec(__METHOD__, $content,array(), array('__ALL__' => true),array(),2);