Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube

Resolved conflicts
This commit is contained in:
Aleksander Machniak (Kolab Systems) 2011-06-28 10:36:11 +02:00
commit 641482b70f
3 changed files with 40 additions and 33 deletions

View file

@ -606,8 +606,7 @@ class database_driver extends calendar_driver
$calendars = explode(',', $calendars);
// only allow to select from calendars of this use
$calendar_ids = array_intersect($calendars, array_keys($this->calendars));
array_walk($calendar_ids, array($this->rc->db, 'quote'));
$calendar_ids = array_map(array($this->rc->db, 'quote'), array_intersect($calendars, array_keys($this->calendars)));
$events = array();
if (!empty($calendar_ids)) {
@ -691,8 +690,7 @@ class database_driver extends calendar_driver
$calendars = explode(',', $calendars);
// only allow to select from calendars of this use
$calendar_ids = array_intersect($calendars, array_keys($this->calendars));
array_walk($calendar_ids, array($this->rc->db, 'quote'));
$calendar_ids = array_map(array($this->rc->db, 'quote'), array_intersect($calendars, array_keys($this->calendars)));
$alarms = array();
if (!empty($calendar_ids)) {

View file

@ -254,21 +254,31 @@ class kolab_calendar
public function update_event($event)
{
$updated = false;
$old = $this->storage->getObject($event['id']);
$object = array_merge($old, $this->_from_rcube_event($event));
$saved = $this->storage->save($object, $event['id']);
if (PEAR::isError($saved)) {
raise_error(array(
'code' => 600, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Error saving contact object to Kolab server:" . $saved->getMessage()),
true, false);
}
else {
$updated = true;
}
$updated = false;
$old = $this->storage->getObject($event['id']);
$object = array_merge($old, $this->_from_rcube_event($event));
$saved = $this->storage->save($object, $event['id']);
if (PEAR::isError($saved)) {
raise_error(array(
'code' => 600, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Error saving contact object to Kolab server:" . $saved->getMessage()),
true, false);
}
else {
$updated = true;
}
// delete alarm settings in local database
if ($updated && ($old['alarm'] != $object['alarm'] || $old['start-date'] != $object['start-date'])) {
$query = $this->cal->rc->db->query(
"DELETE FROM kolab_alarms
WHERE event_id=?",
$event['id']
);
}
return $updated;
}
@ -391,6 +401,7 @@ class kolab_calendar
'end' => $rec['end-date'],
'allday' => $allday,
'recurrence' => $rrule,
'_alarm' => $rec['alarm'],
'alarms' => $alarm_value . $alarm_unit,
'categories' => $rec['categories'],
'free_busy' => $rec['show-time-as'],

View file

@ -308,7 +308,7 @@ class kolab_driver extends calendar_driver
if ($calendars && !in_array($cid, $calendars))
continue;
$events = array_merge($this->calendars[$cid]->list_events($start, $end, $search));
$events = array_merge($events, $this->calendars[$cid]->list_events($start, $end, $search));
}
return $events;
@ -334,23 +334,21 @@ class kolab_driver extends calendar_driver
public function pending_alarms($time, $calendars = null)
{
$events = array();
foreach ($this->load_events($time, $time + 86400 * 365) as $e) {
foreach ($this->load_events($time, $time + 86400 * 365, $calendars) as $e) {
// add to list if alarm is set
if ($e['alarm'] && ($notifyat = $e['start'] - $e['alarm'] * 60) <= $time) {
if ($e['_alarm'] && ($notifyat = $e['start'] - $e['_alarm'] * 60) <= $time) {
$id = $e['id'];
$events[$id] = $e;
$events[$id]['notifyat'] = $notifyat;
}
}
// get alarm information stored in local database
if (!empty($events)) {
$event_ids = array_keys($events);
array_walk($event_ids, array($this->rc->db, 'quote'));
$event_ids = array_map(array($this->rc->db, 'quote'), array_keys($events));
$result = $this->rc->db->query(sprintf(
"SELECT * FROM kolab_alarms
WHERE event_id IN (%s)
AND notifyat <= %s",
WHERE event_id IN (%s)",
join(',', $event_ids),
$this->rc->db->now()
));
@ -367,7 +365,7 @@ class kolab_driver extends calendar_driver
continue;
// snooze function may have shifted alarm time
$notifyat = $dbdata['notifyat'] ? strtotime($notifyat) : $e['notifyat'];
$notifyat = $dbdata[$id]['notifyat'] ? strtotime($dbdata[$id]['notifyat']) : $e['notifyat'];
if ($notifyat <= $time)
$alarms[] = $e;
}
@ -386,12 +384,12 @@ class kolab_driver extends calendar_driver
$notifyat = $snooze > 0 ? date('Y-m-d H:i:s', time() + $snooze) : null;
$query = $this->rc->db->query(
"UPDATE kolab_alarms
SET dismissed=?, notifyat=?
WHERE event_id=?",
"REPLACE INTO kolab_alarms
(event_id, dismissed, notifyat)
VALUES(?, ?, ?)",
$event_id,
$snooze > 0 ? 0 : 1,
$notifyat,
$event_id
$notifyat
);
return $this->rc->db->affected_rows($query);