forked from extern/egroupware
Improved alarm handling
This commit is contained in:
parent
6ecb981cb5
commit
015245d235
@ -66,6 +66,11 @@ class calendar_bo
|
||||
*/
|
||||
var $debug=false;
|
||||
|
||||
/**
|
||||
* @var int $now timestamp in server-time
|
||||
*/
|
||||
var $now;
|
||||
|
||||
/**
|
||||
* @var int $now_su timestamp of actual user-time
|
||||
*/
|
||||
@ -189,7 +194,8 @@ class calendar_bo
|
||||
$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
|
||||
$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
|
||||
|
||||
$this->now_su = egw_time::to('now','ts');
|
||||
$this->now = time();
|
||||
$this->now_su = egw_time::server2user($this->now,'ts');
|
||||
|
||||
$this->user = $GLOBALS['egw_info']['user']['account_id'];
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ class calendar_boupdate extends calendar_bo
|
||||
|
||||
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar',$cal_id, 'modify', time());
|
||||
|
||||
return $this->so->save_alarm($cal_id,$alarm, $this->now_su);
|
||||
return $this->so->save_alarm($cal_id,$alarm, $this->now);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1457,7 +1457,7 @@ class calendar_boupdate extends calendar_bo
|
||||
|
||||
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar',$cal_id, 'modify', time());
|
||||
|
||||
return $this->so->delete_alarm($id, $this->now_su);
|
||||
return $this->so->delete_alarm($id, $this->now);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1537,10 +1537,10 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
*
|
||||
* @param int $cal_id Id of the calendar-entry
|
||||
* @param array $alarm array with fields: text, owner, enabled, ..
|
||||
* @param timestamp $now_su=0 timestamp for modification of related event
|
||||
* @param timestamp $now=0 timestamp for modification of related event
|
||||
* @return string id of the alarm
|
||||
*/
|
||||
function save_alarm($cal_id, $alarm, $now_su = 0)
|
||||
function save_alarm($cal_id, $alarm, $now=0)
|
||||
{
|
||||
//echo "<p>save_alarm(cal_id=$cal_id, alarm="; print_r($alarm); echo ")</p>\n";
|
||||
if (!($id = $alarm['id']))
|
||||
@ -1566,8 +1566,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
}
|
||||
|
||||
// update the modification information of the related event
|
||||
$datetime = $GLOBALS['egw']->datetime;
|
||||
$now = ($now_su ? $now_su : time() + $datetime->this->tz_offset);
|
||||
if (!$now) $now = time();
|
||||
$modifier = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$this->db->update($this->cal_table, array('cal_modified' => $now, 'cal_modifier' => $modifier),
|
||||
array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
|
||||
@ -1596,17 +1595,16 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
* delete one alarms identified by its id
|
||||
*
|
||||
* @param string $id alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is used as the job-id too
|
||||
* @param timestamp $now_su=0 timestamp for modification of related event
|
||||
* @param timestamp $now=0 timestamp for modification of related event
|
||||
* @return int number of alarms deleted
|
||||
*/
|
||||
function delete_alarm($id, $now_su = 0)
|
||||
function delete_alarm($id, $now=0)
|
||||
{
|
||||
// update the modification information of the related event
|
||||
list(,$cal_id) = explode(':',$id);
|
||||
if ($cal_id)
|
||||
{
|
||||
$datetime = $GLOBALS['egw']->datetime;
|
||||
$now = ($now_su ? $now_su : time() + $datetime->this->tz_offset);
|
||||
if (!$now) $now = time();
|
||||
$modifier = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$this->db->update($this->cal_table, array('cal_modified' => $now, 'cal_modifier' => $modifier),
|
||||
array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
|
||||
|
@ -652,7 +652,7 @@ class calendar_uiforms extends calendar_ui
|
||||
$offset = DAY_s * $content['new_alarm']['days'] + HOUR_s * $content['new_alarm']['hours'] + 60 * $content['new_alarm']['mins'];
|
||||
$alarm = array(
|
||||
'offset' => $offset,
|
||||
'time' => ($content['actual_date'] ? $content['actual_date'] : $content['start']) - $offset,
|
||||
'time' => $content['start'] - $offset,
|
||||
'all' => !$content['new_alarm']['owner'],
|
||||
'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
|
||||
);
|
||||
@ -1094,24 +1094,36 @@ function replace_eTemplate_onsubmit()
|
||||
{
|
||||
// makes keys of the alarm-array starting with 1
|
||||
$content['alarm'] = array(false);
|
||||
foreach(array_values($event['alarm']) as $id => $alarm)
|
||||
if (!$content['edit_single'])
|
||||
{
|
||||
if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ,0,$alarm['owner']))
|
||||
foreach(array_values($event['alarm']) as $id => $alarm)
|
||||
{
|
||||
continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
|
||||
if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ,0,$alarm['owner']))
|
||||
{
|
||||
continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
|
||||
}
|
||||
$alarm['all'] = (int) $alarm['all'];
|
||||
$days = (int) ($alarm['offset'] / DAY_s);
|
||||
$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
|
||||
$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
|
||||
$label = array();
|
||||
if ($days) $label[] = $days.' '.lang('days');
|
||||
if ($hours) $label[] = $hours.' '.lang('hours');
|
||||
if ($minutes) $label[] = $minutes.' '.lang('Minutes');
|
||||
$alarm['offset'] = implode(', ',$label);
|
||||
$content['alarm'][] = $alarm;
|
||||
|
||||
$readonlys['delete_alarm['.$id.']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
|
||||
}
|
||||
$alarm['all'] = (int) $alarm['all'];
|
||||
$days = (int) ($alarm['offset'] / DAY_s);
|
||||
$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
|
||||
$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
|
||||
$label = array();
|
||||
if ($days) $label[] = $days.' '.lang('days');
|
||||
if ($hours) $label[] = $hours.' '.lang('hours');
|
||||
if ($minutes) $label[] = $minutes.' '.lang('Minutes');
|
||||
$alarm['offset'] = implode(', ',$label);
|
||||
$content['alarm'][] = $alarm;
|
||||
|
||||
$readonlys['delete_alarm['.$id.']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// disable the alarm tab
|
||||
$readonlys['button[add_alarm]'] = true;
|
||||
$readonlys['new_alarm[days]'] = true;
|
||||
$readonlys['new_alarm[hours]'] = true;
|
||||
$readonlys['new_alarm[mins]'] = true;
|
||||
$readonlys['new_alarm[owner]'] = true;
|
||||
}
|
||||
if (count($content['alarm']) == 1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user