2011-05-20 19:04:25 +02:00
|
|
|
<?php
|
2011-08-21 12:48:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Database driver for the Calendar plugin
|
|
|
|
*
|
2011-11-21 11:20:48 +01:00
|
|
|
* @version @package_version@
|
2011-08-21 12:48:33 +02:00
|
|
|
* @author Lazlo Westerhof <hello@lazlo.me>
|
2011-12-07 12:51:23 +01:00
|
|
|
* @author Thomas Bruederli <bruederli@kolabsys.com>
|
2011-08-21 12:48:33 +02:00
|
|
|
*
|
2011-10-27 10:20:46 +02:00
|
|
|
* Copyright (C) 2010, Lazlo Westerhof <hello@lazlo.me>
|
2014-01-27 19:12:29 +01:00
|
|
|
* Copyright (C) 2012-2014, Kolab Systems AG <contact@kolabsys.com>
|
2011-08-21 12:48:33 +02:00
|
|
|
*
|
2011-10-27 10:20:46 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2011-08-21 12:48:33 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-10-27 10:20:46 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2011-08-21 12:48:33 +02:00
|
|
|
*
|
2011-10-27 10:20:46 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-21 12:48:33 +02:00
|
|
|
*/
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
class database_driver extends calendar_driver
|
|
|
|
{
|
2012-07-06 17:15:45 +02:00
|
|
|
const DB_DATE_FORMAT = 'Y-m-d H:i:s';
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
// features this backend supports
|
2011-05-22 17:29:09 +02:00
|
|
|
public $alarms = true;
|
2011-05-20 19:04:25 +02:00
|
|
|
public $attendees = true;
|
2011-07-26 08:38:13 +02:00
|
|
|
public $freebusy = false;
|
2011-05-20 19:04:25 +02:00
|
|
|
public $attachments = true;
|
2013-03-13 10:26:59 +01:00
|
|
|
public $alarm_types = array('DISPLAY');
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
private $rc;
|
|
|
|
private $cal;
|
2011-08-04 23:55:41 +02:00
|
|
|
private $cache = array();
|
2011-05-20 19:04:25 +02:00
|
|
|
private $calendars = array();
|
|
|
|
private $calendar_ids = '';
|
2011-06-14 17:19:16 -06:00
|
|
|
private $free_busy_map = array('free' => 0, 'busy' => 1, 'out-of-office' => 2, 'outofoffice' => 2, 'tentative' => 3);
|
2013-07-18 14:56:36 +02:00
|
|
|
private $sensitivity_map = array('public' => 0, 'private' => 1, 'confidential' => 2);
|
2012-07-06 17:15:45 +02:00
|
|
|
private $server_timezone;
|
2011-05-23 19:53:11 +02:00
|
|
|
|
|
|
|
private $db_events = 'events';
|
|
|
|
private $db_calendars = 'calendars';
|
|
|
|
private $db_attachments = 'attachments';
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*/
|
|
|
|
public function __construct($cal)
|
|
|
|
{
|
|
|
|
$this->cal = $cal;
|
|
|
|
$this->rc = $cal->rc;
|
2012-07-06 17:15:45 +02:00
|
|
|
$this->server_timezone = new DateTimeZone(date_default_timezone_get());
|
2011-05-23 19:53:11 +02:00
|
|
|
|
|
|
|
// read database config
|
2013-07-18 11:46:32 +02:00
|
|
|
$db = $this->rc->get_dbh();
|
|
|
|
$this->db_events = $this->rc->config->get('db_table_events', $db->table_name($this->db_events));
|
|
|
|
$this->db_calendars = $this->rc->config->get('db_table_calendars', $db->table_name($this->db_calendars));
|
|
|
|
$this->db_attachments = $this->rc->config->get('db_table_attachments', $db->table_name($this->db_attachments));
|
2011-05-23 19:53:11 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
$this->_read_calendars();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read available calendars for the current user and store them internally
|
|
|
|
*/
|
|
|
|
private function _read_calendars()
|
|
|
|
{
|
2011-08-26 23:24:49 +02:00
|
|
|
$hidden = array_filter(explode(',', $this->rc->config->get('hidden_calendars', '')));
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
if (!empty($this->rc->user->ID)) {
|
|
|
|
$calendar_ids = array();
|
|
|
|
$result = $this->rc->db->query(
|
2011-06-05 19:08:47 -06:00
|
|
|
"SELECT *, calendar_id AS id FROM " . $this->db_calendars . "
|
2011-09-07 17:33:34 +02:00
|
|
|
WHERE user_id=?
|
|
|
|
ORDER BY name",
|
2011-05-20 19:04:25 +02:00
|
|
|
$this->rc->user->ID
|
|
|
|
);
|
|
|
|
while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
|
2011-07-31 14:40:52 +02:00
|
|
|
$arr['showalarms'] = intval($arr['showalarms']);
|
2012-09-21 09:55:07 +02:00
|
|
|
$arr['active'] = !in_array($arr['id'], $hidden);
|
|
|
|
$arr['name'] = html::quote($arr['name']);
|
2013-10-17 16:58:05 +02:00
|
|
|
$arr['listname'] = html::quote($arr['name']);
|
2011-05-20 19:04:25 +02:00
|
|
|
$this->calendars[$arr['calendar_id']] = $arr;
|
|
|
|
$calendar_ids[] = $this->rc->db->quote($arr['calendar_id']);
|
|
|
|
}
|
|
|
|
$this->calendar_ids = join(',', $calendar_ids);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of available calendars from this source
|
2012-12-04 20:10:04 +01:00
|
|
|
*
|
|
|
|
* @param bool $active Return only active calendars
|
|
|
|
* @param bool $personal Return only personal calendars
|
|
|
|
*
|
|
|
|
* @return array List of calendars
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
2012-12-04 20:10:04 +01:00
|
|
|
public function list_calendars($active = false, $personal = false)
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
|
|
|
// attempt to create a default calendar for this user
|
|
|
|
if (empty($this->calendars)) {
|
|
|
|
if ($this->create_calendar(array('name' => 'Default', 'color' => 'cc0000')))
|
|
|
|
$this->_read_calendars();
|
|
|
|
}
|
2012-12-04 20:10:04 +01:00
|
|
|
|
|
|
|
$calendars = $this->calendars;
|
|
|
|
|
|
|
|
// filter active calendars
|
|
|
|
if ($active) {
|
|
|
|
foreach ($calendars as $idx => $cal) {
|
|
|
|
if (!$cal['active']) {
|
|
|
|
unset($calendars[$idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 'personal' is unsupported in this driver
|
|
|
|
|
2014-01-27 19:12:29 +01:00
|
|
|
// append the virtual birthdays calendar
|
|
|
|
if ($this->rc->config->get('calendar_contact_birthdays', false)) {
|
|
|
|
$prefs = $this->rc->config->get('birthday_calendar', array('color' => '87CEFA'));
|
|
|
|
$hidden = array_filter(explode(',', $this->rc->config->get('hidden_calendars', '')));
|
|
|
|
|
|
|
|
$id = self::BIRTHDAY_CALENDAR_ID;
|
|
|
|
if (!$active || !in_array($id, $hidden)) {
|
|
|
|
$calendars[$id] = array(
|
|
|
|
'id' => $id,
|
|
|
|
'name' => $this->cal->gettext('birthdays'),
|
|
|
|
'listname' => $this->cal->gettext('birthdays'),
|
|
|
|
'color' => $prefs['color'],
|
2014-01-28 11:55:06 +01:00
|
|
|
'showalarms' => (bool)$this->rc->config->get('calendar_birthdays_alarm_type'),
|
2014-01-27 19:12:29 +01:00
|
|
|
'active' => !in_array($id, $hidden),
|
|
|
|
'class_name' => 'birthdays',
|
|
|
|
'readonly' => true,
|
|
|
|
'default' => false,
|
|
|
|
'children' => false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-04 20:10:04 +01:00
|
|
|
return $calendars;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
2012-12-04 20:10:04 +01:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Create a new calendar assigned to the current user
|
|
|
|
*
|
|
|
|
* @param array Hash array with calendar properties
|
|
|
|
* name: Calendar name
|
|
|
|
* color: The color of the calendar
|
|
|
|
* @return mixed ID of the calendar on success, False on error
|
|
|
|
*/
|
|
|
|
public function create_calendar($prop)
|
|
|
|
{
|
|
|
|
$result = $this->rc->db->query(
|
2011-05-23 19:53:11 +02:00
|
|
|
"INSERT INTO " . $this->db_calendars . "
|
2011-07-31 14:40:52 +02:00
|
|
|
(user_id, name, color, showalarms)
|
2011-09-07 17:33:34 +02:00
|
|
|
VALUES (?, ?, ?, ?)",
|
2011-05-20 19:04:25 +02:00
|
|
|
$this->rc->user->ID,
|
|
|
|
$prop['name'],
|
2011-07-31 14:40:52 +02:00
|
|
|
$prop['color'],
|
|
|
|
$prop['showalarms']?1:0
|
2011-05-20 19:04:25 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
if ($result)
|
2013-05-07 11:34:45 +02:00
|
|
|
return $this->rc->db->insert_id($this->db_calendars);
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-26 23:24:49 +02:00
|
|
|
|
2011-06-05 19:08:47 -06:00
|
|
|
/**
|
|
|
|
* Update properties of an existing calendar
|
|
|
|
*
|
|
|
|
* @see calendar_driver::edit_calendar()
|
|
|
|
*/
|
|
|
|
public function edit_calendar($prop)
|
|
|
|
{
|
2014-01-27 19:12:29 +01:00
|
|
|
// birthday calendar properties are saved in user prefs
|
|
|
|
if ($prop['id'] == self::BIRTHDAY_CALENDAR_ID) {
|
2014-01-28 11:55:06 +01:00
|
|
|
$prefs['birthday_calendar'] = $this->rc->config->get('birthday_calendar', array('color' => '87CEFA'));
|
2014-01-27 19:12:29 +01:00
|
|
|
if (isset($prop['color']))
|
2014-01-28 11:55:06 +01:00
|
|
|
$prefs['birthday_calendar']['color'] = $prop['color'];
|
2014-01-27 19:12:29 +01:00
|
|
|
if (isset($prop['showalarms']))
|
2014-01-28 11:55:06 +01:00
|
|
|
$prefs['calendar_birthdays_alarm_type'] = $prop['showalarms'] ? $this->alarm_types[0] : '';
|
|
|
|
$this->rc->user->save_prefs($prefs);
|
2014-01-27 19:12:29 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-05 19:08:47 -06:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"UPDATE " . $this->db_calendars . "
|
2011-07-31 14:40:52 +02:00
|
|
|
SET name=?, color=?, showalarms=?
|
2011-06-05 19:08:47 -06:00
|
|
|
WHERE calendar_id=?
|
|
|
|
AND user_id=?",
|
|
|
|
$prop['name'],
|
|
|
|
$prop['color'],
|
2011-07-31 14:40:52 +02:00
|
|
|
$prop['showalarms']?1:0,
|
2011-06-05 19:08:47 -06:00
|
|
|
$prop['id'],
|
|
|
|
$this->rc->user->ID
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->rc->db->affected_rows($query);
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:24:49 +02:00
|
|
|
/**
|
|
|
|
* Set active/subscribed state of a calendar
|
|
|
|
* Save a list of hidden calendars in user prefs
|
|
|
|
*
|
|
|
|
* @see calendar_driver::subscribe_calendar()
|
|
|
|
*/
|
|
|
|
public function subscribe_calendar($prop)
|
|
|
|
{
|
|
|
|
$hidden = array_flip(explode(',', $this->rc->config->get('hidden_calendars', '')));
|
|
|
|
|
|
|
|
if ($prop['active'])
|
|
|
|
unset($hidden[$prop['id']]);
|
|
|
|
else
|
|
|
|
$hidden[$prop['id']] = 1;
|
|
|
|
|
|
|
|
return $this->rc->user->save_prefs(array('hidden_calendars' => join(',', array_keys($hidden))));
|
|
|
|
}
|
|
|
|
|
2011-06-05 19:08:47 -06:00
|
|
|
/**
|
|
|
|
* Delete the given calendar with all its contents
|
|
|
|
*
|
|
|
|
* @see calendar_driver::remove_calendar()
|
|
|
|
*/
|
|
|
|
public function remove_calendar($prop)
|
|
|
|
{
|
|
|
|
if (!$this->calendars[$prop['id']])
|
|
|
|
return false;
|
2011-07-01 21:08:12 +02:00
|
|
|
|
|
|
|
// events and attachments will be deleted by foreign key cascade
|
|
|
|
|
2011-06-05 19:08:47 -06:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_calendars . "
|
|
|
|
WHERE calendar_id=?",
|
|
|
|
$prop['id']
|
|
|
|
);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
2011-06-05 19:08:47 -06:00
|
|
|
return $this->rc->db->affected_rows($query);
|
|
|
|
}
|
2011-05-20 19:04:25 +02:00
|
|
|
|
2014-05-13 17:09:53 +02:00
|
|
|
/**
|
|
|
|
* Search for shared or otherwise not listed calendars the user has access
|
|
|
|
*
|
|
|
|
* @param string Search string
|
|
|
|
* @param string Section/source to search
|
|
|
|
* @return array List of calendars
|
|
|
|
*/
|
|
|
|
public function search_calendars($query, $source)
|
|
|
|
{
|
|
|
|
// not implemented
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Add a single event to the database
|
|
|
|
*
|
|
|
|
* @param array Hash array with event properties
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::new_event()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
|
|
|
public function new_event($event)
|
|
|
|
{
|
2012-11-21 10:33:02 +01:00
|
|
|
if (!$this->validate($event))
|
|
|
|
return false;
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
if (!empty($this->calendars)) {
|
|
|
|
if ($event['calendar'] && !$this->calendars[$event['calendar']])
|
|
|
|
return false;
|
|
|
|
if (!$event['calendar'])
|
|
|
|
$event['calendar'] = reset(array_keys($this->calendars));
|
2013-05-07 11:31:30 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
$event = $this->_save_preprocess($event);
|
2013-05-07 11:31:30 +02:00
|
|
|
|
|
|
|
$this->rc->db->query(sprintf(
|
2011-05-23 19:53:11 +02:00
|
|
|
"INSERT INTO " . $this->db_events . "
|
2014-04-09 13:54:04 +02:00
|
|
|
(calendar_id, created, changed, uid, %s, %s, all_day, recurrence, title, description, location, categories, url, free_busy, priority, sensitivity, status, attendees, alarms, notifyat)
|
|
|
|
VALUES (?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
2013-03-06 15:25:45 +01:00
|
|
|
$this->rc->db->quote_identifier('start'),
|
|
|
|
$this->rc->db->quote_identifier('end'),
|
2011-05-20 19:04:25 +02:00
|
|
|
$this->rc->db->now(),
|
2012-07-06 17:15:45 +02:00
|
|
|
$this->rc->db->now()
|
2011-05-20 19:04:25 +02:00
|
|
|
),
|
|
|
|
$event['calendar'],
|
|
|
|
strval($event['uid']),
|
2012-07-06 17:15:45 +02:00
|
|
|
$event['start']->format(self::DB_DATE_FORMAT),
|
|
|
|
$event['end']->format(self::DB_DATE_FORMAT),
|
2011-06-01 18:35:10 +02:00
|
|
|
intval($event['all_day']),
|
2011-10-14 11:58:42 +02:00
|
|
|
$event['_recurrence'],
|
2011-05-20 19:04:25 +02:00
|
|
|
strval($event['title']),
|
|
|
|
strval($event['description']),
|
|
|
|
strval($event['location']),
|
2014-01-27 11:25:17 +01:00
|
|
|
join(',', (array)$event['categories']),
|
2013-05-16 13:32:01 +02:00
|
|
|
strval($event['url']),
|
2011-05-20 19:04:25 +02:00
|
|
|
intval($event['free_busy']),
|
|
|
|
intval($event['priority']),
|
2011-05-27 18:41:01 +02:00
|
|
|
intval($event['sensitivity']),
|
2014-04-09 13:54:04 +02:00
|
|
|
strval($event['status']),
|
2011-07-26 08:38:13 +02:00
|
|
|
$event['attendees'],
|
2011-05-23 21:00:14 +02:00
|
|
|
$event['alarms'],
|
|
|
|
$event['notifyat']
|
2011-05-20 19:04:25 +02:00
|
|
|
);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
2013-05-07 11:34:45 +02:00
|
|
|
$event_id = $this->rc->db->insert_id($this->db_events);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
|
|
|
if ($event_id) {
|
2011-09-01 00:37:23 +02:00
|
|
|
$event['id'] = $event_id;
|
2011-08-04 23:55:41 +02:00
|
|
|
|
2011-07-01 21:08:12 +02:00
|
|
|
// add attachments
|
|
|
|
if (!empty($event['attachments'])) {
|
|
|
|
foreach ($event['attachments'] as $attachment) {
|
|
|
|
$this->add_attachment($attachment, $event_id);
|
|
|
|
unset($attachment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-30 22:57:36 +02:00
|
|
|
$this->_update_recurring($event);
|
2011-07-01 21:08:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $event_id;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update an event entry with the given data
|
|
|
|
*
|
|
|
|
* @param array Hash array with event properties
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::edit_event()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
|
|
|
public function edit_event($event)
|
|
|
|
{
|
|
|
|
if (!empty($this->calendars)) {
|
2011-06-01 18:35:10 +02:00
|
|
|
$update_master = false;
|
|
|
|
$update_recurring = true;
|
2011-09-01 00:37:23 +02:00
|
|
|
$old = $this->get_event($event);
|
2011-05-30 22:57:36 +02:00
|
|
|
|
2012-10-18 22:02:29 +02:00
|
|
|
// increment sequence number
|
2013-07-22 19:42:41 +02:00
|
|
|
if ($old['sequence'] && empty($event['sequence']))
|
2012-10-18 22:02:29 +02:00
|
|
|
$event['sequence'] = max($event['sequence'], $old['sequence']+1);
|
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
// modify a recurring event, check submitted savemode to do the right things
|
|
|
|
if ($old['recurrence'] || $old['recurrence_id']) {
|
2011-09-01 00:37:23 +02:00
|
|
|
$master = $old['recurrence_id'] ? $this->get_event(array('id' => $old['recurrence_id'])) : $old;
|
2011-06-01 18:35:10 +02:00
|
|
|
|
2011-06-01 18:44:24 +02:00
|
|
|
// keep saved exceptions (not submitted by the client)
|
|
|
|
if ($old['recurrence']['EXDATE'])
|
|
|
|
$event['recurrence']['EXDATE'] = $old['recurrence']['EXDATE'];
|
|
|
|
|
2011-09-19 10:03:38 +02:00
|
|
|
switch ($event['_savemode']) {
|
2011-06-01 18:35:10 +02:00
|
|
|
case 'new':
|
|
|
|
$event['uid'] = $this->cal->generate_uid();
|
|
|
|
return $this->new_event($event);
|
|
|
|
|
|
|
|
case 'current':
|
|
|
|
// add exception to master event
|
|
|
|
$master['recurrence']['EXDATE'][] = $old['start'];
|
|
|
|
$update_master = true;
|
|
|
|
|
|
|
|
// just update this occurence (decouple from master)
|
|
|
|
$update_recurring = false;
|
|
|
|
$event['recurrence_id'] = 0;
|
|
|
|
$event['recurrence'] = array();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'future':
|
|
|
|
if ($master['id'] != $event['id']) {
|
|
|
|
// set until-date on master event, then save this instance as new recurring event
|
2012-07-06 17:15:45 +02:00
|
|
|
$master['recurrence']['UNTIL'] = clone $event['start'];
|
|
|
|
$master['recurrence']['UNTIL']->sub(new DateInterval('P1D'));
|
2011-06-01 18:35:10 +02:00
|
|
|
unset($master['recurrence']['COUNT']);
|
|
|
|
$update_master = true;
|
2012-07-06 17:15:45 +02:00
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
// if recurrence COUNT, update value to the correct number of future occurences
|
|
|
|
if ($event['recurrence']['COUNT']) {
|
2012-10-30 16:10:12 +01:00
|
|
|
$fromdate = clone $event['start'];
|
2012-07-06 17:15:45 +02:00
|
|
|
$fromdate->setTimezone($this->server_timezone);
|
2011-06-01 18:35:10 +02:00
|
|
|
$sqlresult = $this->rc->db->query(sprintf(
|
|
|
|
"SELECT event_id FROM " . $this->db_events . "
|
|
|
|
WHERE calendar_id IN (%s)
|
2013-03-06 15:25:45 +01:00
|
|
|
AND %s >= ?
|
2011-06-01 18:35:10 +02:00
|
|
|
AND recurrence_id=?",
|
2013-03-06 15:25:45 +01:00
|
|
|
$this->calendar_ids,
|
|
|
|
$this->rc->db->quote_identifier('start')
|
2011-06-01 18:35:10 +02:00
|
|
|
),
|
2012-07-06 17:15:45 +02:00
|
|
|
$fromdate->format(self::DB_DATE_FORMAT),
|
2011-06-01 18:35:10 +02:00
|
|
|
$master['id']);
|
|
|
|
if ($count = $this->rc->db->num_rows($sqlresult))
|
|
|
|
$event['recurrence']['COUNT'] = $count;
|
|
|
|
}
|
|
|
|
|
|
|
|
$update_recurring = true;
|
|
|
|
$event['recurrence_id'] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// else: 'future' == 'all' if modifying the master event
|
|
|
|
|
|
|
|
default: // 'all' is default
|
|
|
|
$event['id'] = $master['id'];
|
|
|
|
$event['recurrence_id'] = 0;
|
|
|
|
|
|
|
|
// use start date from master but try to be smart on time or duration changes
|
2012-07-06 17:15:45 +02:00
|
|
|
$old_start_date = $old['start']->format('Y-m-d');
|
2013-01-09 11:49:12 +01:00
|
|
|
$old_start_time = $old['allday'] ? '' : $old['start']->format('H:i');
|
2012-07-06 17:15:45 +02:00
|
|
|
$old_duration = $old['end']->format('U') - $old['start']->format('U');
|
2011-06-01 18:35:10 +02:00
|
|
|
|
2012-07-06 17:15:45 +02:00
|
|
|
$new_start_date = $event['start']->format('Y-m-d');
|
2013-01-09 11:49:12 +01:00
|
|
|
$new_start_time = $event['allday'] ? '' : $event['start']->format('H:i');
|
2012-07-06 17:15:45 +02:00
|
|
|
$new_duration = $event['end']->format('U') - $event['start']->format('U');
|
2011-06-01 18:35:10 +02:00
|
|
|
|
2011-09-23 12:50:06 +02:00
|
|
|
$diff = $old_start_date != $new_start_date || $old_start_time != $new_start_time || $old_duration != $new_duration;
|
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
// shifted or resized
|
2011-09-23 13:01:16 +02:00
|
|
|
if ($diff && ($old_start_date == $new_start_date || $old_duration == $new_duration)) {
|
2012-07-06 17:15:45 +02:00
|
|
|
$event['start'] = $master['start']->add($old['start']->diff($event['start']));
|
|
|
|
$event['end'] = clone $event['start'];
|
|
|
|
$event['end']->add(new DateInterval('PT'.$new_duration.'S'));
|
2011-06-01 18:35:10 +02:00
|
|
|
}
|
2013-11-20 12:36:17 +01:00
|
|
|
// dates did not change, use the ones from master
|
|
|
|
else if ($event['start'] == $old['start'] && $event['end'] == $old['end']) {
|
|
|
|
$event['start'] = $master['start'];
|
|
|
|
$event['end'] = $master['end'];
|
|
|
|
}
|
2011-06-01 18:35:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$success = $this->_update_event($event, $update_recurring);
|
|
|
|
if ($success && $update_master)
|
|
|
|
$this->_update_event($master, true);
|
2011-05-30 22:57:36 +02:00
|
|
|
|
|
|
|
return $success;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert save data to be used in SQL statements
|
|
|
|
*/
|
|
|
|
private function _save_preprocess($event)
|
|
|
|
{
|
2014-01-23 10:03:55 +01:00
|
|
|
// shift dates to server's timezone (except for all-day events)
|
|
|
|
if (!$event['allday']) {
|
|
|
|
$event['start'] = clone $event['start'];
|
|
|
|
$event['start']->setTimezone($this->server_timezone);
|
|
|
|
$event['end'] = clone $event['end'];
|
|
|
|
$event['end']->setTimezone($this->server_timezone);
|
|
|
|
}
|
2012-07-06 17:15:45 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
// compose vcalendar-style recurrencue rule from structured data
|
2012-08-16 08:57:25 +02:00
|
|
|
$rrule = $event['recurrence'] ? libcalendaring::to_rrule($event['recurrence']) : '';
|
2011-10-14 11:58:42 +02:00
|
|
|
$event['_recurrence'] = rtrim($rrule, ';');
|
2011-05-20 19:04:25 +02:00
|
|
|
$event['free_busy'] = intval($this->free_busy_map[strtolower($event['free_busy'])]);
|
2013-07-18 14:56:36 +02:00
|
|
|
$event['sensitivity'] = intval($this->sensitivity_map[strtolower($event['sensitivity'])]);
|
2014-04-09 13:54:04 +02:00
|
|
|
|
|
|
|
if ($event['free_busy'] == 'tentative') {
|
|
|
|
$event['status'] = 'TENTATIVE';
|
|
|
|
}
|
|
|
|
|
2011-06-19 17:56:23 -06:00
|
|
|
if (isset($event['allday'])) {
|
2011-06-01 18:35:10 +02:00
|
|
|
$event['all_day'] = $event['allday'] ? 1 : 0;
|
2011-06-19 17:56:23 -06:00
|
|
|
}
|
2014-04-17 17:49:00 +02:00
|
|
|
|
2011-05-23 21:00:14 +02:00
|
|
|
// compute absolute time to notify the user
|
2011-05-30 22:57:36 +02:00
|
|
|
$event['notifyat'] = $this->_get_notification($event);
|
2014-04-17 17:49:00 +02:00
|
|
|
|
|
|
|
if (is_array($event['valarms'])) {
|
|
|
|
$event['alarms'] = $this->serialize_alarms($event['valarms']);
|
|
|
|
}
|
|
|
|
|
2011-07-26 08:38:13 +02:00
|
|
|
// process event attendees
|
|
|
|
$_attendees = '';
|
|
|
|
foreach ((array)$event['attendees'] as $attendee) {
|
2011-08-23 23:10:35 +02:00
|
|
|
if (!$attendee['name'] && !$attendee['email'])
|
|
|
|
continue;
|
2011-07-26 08:38:13 +02:00
|
|
|
$_attendees .= 'NAME="'.addcslashes($attendee['name'], '"') . '"' .
|
|
|
|
';STATUS=' . $attendee['status'].
|
|
|
|
';ROLE=' . $attendee['role'] .
|
|
|
|
';EMAIL=' . $attendee['email'] .
|
|
|
|
"\n";
|
|
|
|
}
|
|
|
|
$event['attendees'] = rtrim($_attendees);
|
|
|
|
|
2011-05-30 22:57:36 +02:00
|
|
|
return $event;
|
|
|
|
}
|
2011-06-01 18:35:10 +02:00
|
|
|
|
2011-05-30 22:57:36 +02:00
|
|
|
/**
|
|
|
|
* Compute absolute time to notify the user
|
|
|
|
*/
|
|
|
|
private function _get_notification($event)
|
|
|
|
{
|
2014-04-17 17:49:00 +02:00
|
|
|
if ($event['valarms'] && $event['start'] > new DateTime()) {
|
2012-08-16 08:57:25 +02:00
|
|
|
$alarm = libcalendaring::get_next_alarm($event);
|
2011-06-05 19:22:25 -06:00
|
|
|
|
2014-04-17 17:49:00 +02:00
|
|
|
if ($alarm['time'] && in_array($alarm['action'], $this->alarm_types))
|
2012-05-16 18:36:03 +02:00
|
|
|
return date('Y-m-d H:i:s', $alarm['time']);
|
2011-05-30 22:57:36 +02:00
|
|
|
}
|
2012-05-16 18:36:03 +02:00
|
|
|
|
2011-05-30 22:57:36 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
/**
|
|
|
|
* Save the given event record to database
|
|
|
|
*
|
|
|
|
* @param array Event data, already passed through self::_save_preprocess()
|
|
|
|
* @param boolean True if recurring events instances should be updated, too
|
|
|
|
*/
|
|
|
|
private function _update_event($event, $update_recurring = true)
|
|
|
|
{
|
|
|
|
$event = $this->_save_preprocess($event);
|
|
|
|
$sql_set = array();
|
2014-04-09 13:54:04 +02:00
|
|
|
$set_cols = array('start', 'end', 'all_day', 'recurrence_id', 'sequence', 'title', 'description', 'location', 'categories', 'url', 'free_busy', 'priority', 'sensitivity', 'status', 'attendees', 'alarms', 'notifyat');
|
2011-06-01 18:35:10 +02:00
|
|
|
foreach ($set_cols as $col) {
|
2012-07-06 17:15:45 +02:00
|
|
|
if (is_object($event[$col]) && is_a($event[$col], 'DateTime'))
|
|
|
|
$sql_set[] = $this->rc->db->quote_identifier($col) . '=' . $this->rc->db->quote($event[$col]->format(self::DB_DATE_FORMAT));
|
2014-01-27 11:25:17 +01:00
|
|
|
else if (is_array($event[$col]))
|
|
|
|
$sql_set[] = $this->rc->db->quote_identifier($col) . '=' . $this->rc->db->quote(join(',', $event[$col]));
|
2014-04-09 13:54:04 +02:00
|
|
|
else if (array_key_exists($col, $event))
|
2011-06-01 18:35:10 +02:00
|
|
|
$sql_set[] = $this->rc->db->quote_identifier($col) . '=' . $this->rc->db->quote($event[$col]);
|
|
|
|
}
|
|
|
|
|
2011-10-14 11:58:42 +02:00
|
|
|
if ($event['_recurrence'])
|
|
|
|
$sql_set[] = $this->rc->db->quote_identifier('recurrence') . '=' . $this->rc->db->quote($event['_recurrence']);
|
|
|
|
|
2011-09-19 10:03:38 +02:00
|
|
|
if ($event['_fromcalendar'] && $event['_fromcalendar'] != $event['calendar'])
|
2011-09-19 09:50:13 +02:00
|
|
|
$sql_set[] = 'calendar_id=' . $this->rc->db->quote($event['calendar']);
|
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
$query = $this->rc->db->query(sprintf(
|
|
|
|
"UPDATE " . $this->db_events . "
|
2012-07-06 17:15:45 +02:00
|
|
|
SET changed=%s %s
|
2011-06-01 18:35:10 +02:00
|
|
|
WHERE event_id=?
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$this->rc->db->now(),
|
|
|
|
($sql_set ? ', ' . join(', ', $sql_set) : '')
|
|
|
|
),
|
|
|
|
$event['id']
|
|
|
|
);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
$success = $this->rc->db->affected_rows($query);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
|
|
|
// add attachments
|
|
|
|
if ($success && !empty($event['attachments'])) {
|
|
|
|
foreach ($event['attachments'] as $attachment) {
|
|
|
|
$this->add_attachment($attachment, $event['id']);
|
|
|
|
unset($attachment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove attachments
|
|
|
|
if ($success && !empty($event['deleted_attachments'])) {
|
|
|
|
foreach ($event['deleted_attachments'] as $attachment) {
|
|
|
|
$this->remove_attachment($attachment, $event['id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-04 23:55:41 +02:00
|
|
|
if ($success) {
|
|
|
|
unset($this->cache[$event['id']]);
|
|
|
|
if ($update_recurring)
|
|
|
|
$this->_update_recurring($event);
|
|
|
|
}
|
2011-07-01 21:08:12 +02:00
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
2011-05-30 22:57:36 +02:00
|
|
|
/**
|
|
|
|
* Insert "fake" entries for recurring occurences of this event
|
|
|
|
*/
|
|
|
|
private function _update_recurring($event)
|
|
|
|
{
|
|
|
|
if (empty($this->calendars))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// clear existing recurrence copies
|
|
|
|
$this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_events . "
|
|
|
|
WHERE recurrence_id=?
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$event['id']
|
|
|
|
);
|
|
|
|
|
|
|
|
// create new fake entries
|
|
|
|
if ($event['recurrence']) {
|
2011-10-14 11:58:42 +02:00
|
|
|
// include library class
|
|
|
|
require_once($this->cal->home . '/lib/calendar_recurrence.php');
|
2011-05-30 22:57:36 +02:00
|
|
|
|
2011-10-14 11:58:42 +02:00
|
|
|
$recurrence = new calendar_recurrence($this->cal, $event);
|
2012-07-06 17:15:45 +02:00
|
|
|
|
2013-05-08 09:07:29 +02:00
|
|
|
$count = 0;
|
2012-07-06 17:15:45 +02:00
|
|
|
$duration = $event['start']->diff($event['end']);
|
|
|
|
while ($next_start = $recurrence->next_start()) {
|
|
|
|
$next_start->setTimezone($this->server_timezone);
|
|
|
|
$next_end = clone $next_start;
|
|
|
|
$next_end->add($duration);
|
2014-04-09 13:54:04 +02:00
|
|
|
$notify_at = $this->_get_notification(array('alarms' => $event['alarms'], 'start' => $next_start, 'end' => $next_end, 'status' => $event['status']));
|
2011-05-30 22:57:36 +02:00
|
|
|
$query = $this->rc->db->query(sprintf(
|
|
|
|
"INSERT INTO " . $this->db_events . "
|
2014-04-09 13:54:04 +02:00
|
|
|
(calendar_id, recurrence_id, created, changed, uid, %s, %s, all_day, recurrence, title, description, location, categories, url, free_busy, priority, sensitivity, status, alarms, attendees, notifyat)
|
|
|
|
SELECT calendar_id, ?, %s, %s, uid, ?, ?, all_day, recurrence, title, description, location, categories, url, free_busy, priority, sensitivity, status, alarms, attendees, ?
|
2011-05-30 22:57:36 +02:00
|
|
|
FROM " . $this->db_events . " WHERE event_id=? AND calendar_id IN (" . $this->calendar_ids . ")",
|
2013-03-06 15:25:45 +01:00
|
|
|
$this->rc->db->quote_identifier('start'),
|
|
|
|
$this->rc->db->quote_identifier('end'),
|
2011-05-30 22:57:36 +02:00
|
|
|
$this->rc->db->now(),
|
2012-07-06 17:15:45 +02:00
|
|
|
$this->rc->db->now()
|
2011-05-30 22:57:36 +02:00
|
|
|
),
|
|
|
|
$event['id'],
|
2012-07-06 17:15:45 +02:00
|
|
|
$next_start->format(self::DB_DATE_FORMAT),
|
|
|
|
$next_end->format(self::DB_DATE_FORMAT),
|
2011-05-30 22:57:36 +02:00
|
|
|
$notify_at,
|
|
|
|
$event['id']
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$this->rc->db->affected_rows($query))
|
|
|
|
break;
|
|
|
|
|
|
|
|
// stop adding events for inifinite recurrence after 20 years
|
2013-05-08 08:55:58 +02:00
|
|
|
if (++$count > 999 || (!$recurrence->recurEnd && !$recurrence->recurCount && $next_start->format('Y') > date('Y') + 20))
|
2011-05-30 22:57:36 +02:00
|
|
|
break;
|
|
|
|
}
|
2011-05-23 21:00:14 +02:00
|
|
|
}
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move a single event
|
|
|
|
*
|
|
|
|
* @param array Hash array with event properties
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::move_event()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
|
|
|
public function move_event($event)
|
|
|
|
{
|
2011-06-01 18:35:10 +02:00
|
|
|
// let edit_event() do all the magic
|
2011-09-01 00:37:23 +02:00
|
|
|
return $this->edit_event($event + (array)$this->get_event($event));
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resize a single event
|
|
|
|
*
|
|
|
|
* @param array Hash array with event properties
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::resize_event()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
|
|
|
public function resize_event($event)
|
|
|
|
{
|
2011-06-01 18:35:10 +02:00
|
|
|
// let edit_event() do all the magic
|
2011-09-01 00:37:23 +02:00
|
|
|
return $this->edit_event($event + (array)$this->get_event($event));
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a single event from the database
|
|
|
|
*
|
2011-07-18 15:28:57 +02:00
|
|
|
* @param array Hash array with event properties
|
|
|
|
* @param boolean Remove record irreversible (@TODO)
|
|
|
|
*
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::remove_event()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
2011-07-18 15:28:57 +02:00
|
|
|
public function remove_event($event, $force = true)
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
|
|
|
if (!empty($this->calendars)) {
|
2011-09-01 00:37:23 +02:00
|
|
|
$event += (array)$this->get_event($event);
|
2011-06-01 18:35:10 +02:00
|
|
|
$master = $event;
|
|
|
|
$update_master = false;
|
|
|
|
$savemode = 'all';
|
|
|
|
|
|
|
|
// read master if deleting a recurring event
|
|
|
|
if ($event['recurrence'] || $event['recurrence_id']) {
|
2012-01-04 17:02:26 +01:00
|
|
|
$master = $event['recurrence_id'] ? $this->get_event(array('id' => $event['recurrence_id'])) : $event;
|
2011-09-19 10:03:38 +02:00
|
|
|
$savemode = $event['_savemode'];
|
2011-06-01 18:35:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch ($savemode) {
|
|
|
|
case 'current':
|
|
|
|
// add exception to master event
|
|
|
|
$master['recurrence']['EXDATE'][] = $event['start'];
|
|
|
|
$update_master = true;
|
|
|
|
|
|
|
|
// just delete this single occurence
|
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_events . "
|
|
|
|
WHERE calendar_id IN (" . $this->calendar_ids . ")
|
|
|
|
AND event_id=?",
|
|
|
|
$event['id']
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'future':
|
|
|
|
if ($master['id'] != $event['id']) {
|
|
|
|
// set until-date on master event
|
2012-07-06 17:15:45 +02:00
|
|
|
$master['recurrence']['UNTIL'] = clone $event['start'];
|
|
|
|
$master['recurrence']['UNTIL']->sub(new DateInterval('P1D'));
|
2011-06-01 18:35:10 +02:00
|
|
|
unset($master['recurrence']['COUNT']);
|
|
|
|
$update_master = true;
|
|
|
|
|
|
|
|
// delete this and all future instances
|
2013-05-08 08:55:58 +02:00
|
|
|
$fromdate = clone $event['start'];
|
2012-07-06 17:15:45 +02:00
|
|
|
$fromdate->setTimezone($this->server_timezone);
|
2011-06-01 18:35:10 +02:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_events . "
|
|
|
|
WHERE calendar_id IN (" . $this->calendar_ids . ")
|
2013-03-06 15:25:45 +01:00
|
|
|
AND " . $this->rc->db->quote_identifier('start') . " >= ?
|
2011-06-01 18:35:10 +02:00
|
|
|
AND recurrence_id=?",
|
2012-07-06 17:15:45 +02:00
|
|
|
$fromdate->format(self::DB_DATE_FORMAT),
|
2011-06-01 18:35:10 +02:00
|
|
|
$master['id']
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// else: future == all if modifying the master event
|
|
|
|
|
|
|
|
default: // 'all' is default
|
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_events . "
|
|
|
|
WHERE (event_id=? OR recurrence_id=?)
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$master['id'],
|
|
|
|
$master['id']
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$success = $this->rc->db->affected_rows($query);
|
|
|
|
if ($success && $update_master)
|
|
|
|
$this->_update_event($master, true);
|
2011-06-04 15:52:12 -04:00
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
return $success;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-23 21:00:14 +02:00
|
|
|
/**
|
|
|
|
* Return data of a specific event
|
2011-09-01 00:37:23 +02:00
|
|
|
* @param mixed Hash array with event properties or event UID
|
2012-12-04 20:10:04 +01:00
|
|
|
* @param boolean Only search in writeable calendars (ignored)
|
|
|
|
* @param boolean Only search in active calendars
|
|
|
|
* @param boolean Only search in personal calendars (ignored)
|
2011-05-23 21:00:14 +02:00
|
|
|
* @return array Hash array with event properties
|
|
|
|
*/
|
2012-12-04 20:10:04 +01:00
|
|
|
public function get_event($event, $writeable = false, $active = false, $personal = false)
|
2011-05-23 21:00:14 +02:00
|
|
|
{
|
2011-08-29 00:54:10 +02:00
|
|
|
$id = is_array($event) ? ($event['id'] ? $event['id'] : $event['uid']) : $event;
|
2012-10-18 22:02:29 +02:00
|
|
|
$col = is_array($event) && is_numeric($id) ? 'event_id' : 'uid';
|
|
|
|
|
2011-08-04 23:55:41 +02:00
|
|
|
if ($this->cache[$id])
|
|
|
|
return $this->cache[$id];
|
2012-12-04 20:10:04 +01:00
|
|
|
|
|
|
|
if ($active) {
|
|
|
|
$calendars = $this->calendars;
|
|
|
|
foreach ($calendars as $idx => $cal) {
|
|
|
|
if (!$cal['active']) {
|
|
|
|
unset($calendars[$idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$cals = join(',', $calendars);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$cals = $this->calendar_ids;
|
|
|
|
}
|
|
|
|
|
2011-05-23 21:00:14 +02:00
|
|
|
$result = $this->rc->db->query(sprintf(
|
2012-12-21 17:52:07 +01:00
|
|
|
"SELECT e.*, (SELECT COUNT(attachment_id) FROM " . $this->db_attachments . "
|
|
|
|
WHERE event_id = e.event_id OR event_id = e.recurrence_id) AS _attachments
|
|
|
|
FROM " . $this->db_events . " AS e
|
2011-09-23 14:01:34 +02:00
|
|
|
WHERE e.calendar_id IN (%s)
|
|
|
|
AND e.$col=?",
|
2012-12-04 20:10:04 +01:00
|
|
|
$cals
|
2011-05-23 21:00:14 +02:00
|
|
|
),
|
|
|
|
$id);
|
|
|
|
|
2011-10-12 22:38:06 +02:00
|
|
|
if ($result && ($event = $this->rc->db->fetch_assoc($result)) && $event['event_id']) {
|
2011-08-04 23:55:41 +02:00
|
|
|
$this->cache[$id] = $this->_read_postprocess($event);
|
|
|
|
return $this->cache[$id];
|
2011-06-01 18:35:10 +02:00
|
|
|
}
|
2011-05-23 21:00:14 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Get event data
|
|
|
|
*
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::load_events()
|
2011-05-20 19:04:25 +02:00
|
|
|
*/
|
2013-10-21 20:24:49 +02:00
|
|
|
public function load_events($start, $end, $query = null, $calendars = null, $virtual = 1, $modifiedsince = null)
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
|
|
|
if (empty($calendars))
|
|
|
|
$calendars = array_keys($this->calendars);
|
|
|
|
else if (is_string($calendars))
|
|
|
|
$calendars = explode(',', $calendars);
|
2011-07-16 20:03:19 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
// only allow to select from calendars of this use
|
2011-06-28 08:43:21 +02:00
|
|
|
$calendar_ids = array_map(array($this->rc->db, 'quote'), array_intersect($calendars, array_keys($this->calendars)));
|
2011-05-20 19:04:25 +02:00
|
|
|
|
2011-07-16 20:03:19 +02:00
|
|
|
// compose (slow) SQL query for searching
|
|
|
|
// FIXME: improve searching using a dedicated col and normalized values
|
|
|
|
if ($query) {
|
|
|
|
foreach (array('title','location','description','categories','attendees') as $col)
|
|
|
|
$sql_query[] = $this->rc->db->ilike($col, '%'.$query.'%');
|
|
|
|
$sql_add = 'AND (' . join(' OR ', $sql_query) . ')';
|
|
|
|
}
|
|
|
|
|
2013-10-21 20:24:49 +02:00
|
|
|
if (!$virtual)
|
2013-10-22 12:51:47 +02:00
|
|
|
$sql_add .= ' AND e.recurrence_id = 0';
|
2013-10-21 20:24:49 +02:00
|
|
|
|
|
|
|
if ($modifiedsince)
|
|
|
|
$sql_add .= ' AND e.changed >= ' . $this->rc->db->quote(date('Y-m-d H:i:s', $modifiedsince));
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
$events = array();
|
2011-05-23 21:00:14 +02:00
|
|
|
if (!empty($calendar_ids)) {
|
2011-05-20 19:04:25 +02:00
|
|
|
$result = $this->rc->db->query(sprintf(
|
2014-03-26 11:36:48 +01:00
|
|
|
"SELECT e.*, (SELECT COUNT(attachment_id) FROM " . $this->db_attachments . "
|
|
|
|
WHERE event_id = e.event_id OR event_id = e.recurrence_id) AS _attachments
|
|
|
|
FROM " . $this->db_events . " e
|
2011-07-04 17:02:00 +02:00
|
|
|
WHERE e.calendar_id IN (%s)
|
2014-03-26 11:36:48 +01:00
|
|
|
AND e.start <= %s AND e.end >= %s
|
|
|
|
%s",
|
2011-05-23 21:00:14 +02:00
|
|
|
join(',', $calendar_ids),
|
2011-05-22 17:29:09 +02:00
|
|
|
$this->rc->db->fromunixtime($end),
|
2011-06-13 18:41:32 -06:00
|
|
|
$this->rc->db->fromunixtime($start),
|
|
|
|
$sql_add
|
2011-05-20 19:04:25 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
while ($result && ($event = $this->rc->db->fetch_assoc($result))) {
|
2011-05-23 21:00:14 +02:00
|
|
|
$events[] = $this->_read_postprocess($event);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
}
|
2014-01-27 19:12:29 +01:00
|
|
|
|
|
|
|
// add events from the address books birthday calendar
|
|
|
|
if (in_array(self::BIRTHDAY_CALENDAR_ID, $calendars)) {
|
2014-01-28 15:55:45 +01:00
|
|
|
$events = array_merge($events, $this->load_birthday_events($start, $end, $search, $modifiedsince));
|
2014-01-27 19:12:29 +01:00
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
return $events;
|
|
|
|
}
|
|
|
|
|
2011-05-23 21:00:14 +02:00
|
|
|
/**
|
|
|
|
* Convert sql record into a rcube style event object
|
|
|
|
*/
|
|
|
|
private function _read_postprocess($event)
|
|
|
|
{
|
|
|
|
$free_busy_map = array_flip($this->free_busy_map);
|
2013-07-18 14:56:36 +02:00
|
|
|
$sensitivity_map = array_flip($this->sensitivity_map);
|
2011-05-23 21:00:14 +02:00
|
|
|
|
|
|
|
$event['id'] = $event['event_id'];
|
2012-07-06 17:15:45 +02:00
|
|
|
$event['start'] = new DateTime($event['start']);
|
|
|
|
$event['end'] = new DateTime($event['end']);
|
2011-06-18 15:21:20 -06:00
|
|
|
$event['allday'] = intval($event['all_day']);
|
2013-07-23 17:27:25 +02:00
|
|
|
$event['created'] = new DateTime($event['created']);
|
2013-07-18 14:06:45 +02:00
|
|
|
$event['changed'] = new DateTime($event['changed']);
|
2011-05-23 21:00:14 +02:00
|
|
|
$event['free_busy'] = $free_busy_map[$event['free_busy']];
|
2013-07-18 14:56:36 +02:00
|
|
|
$event['sensitivity'] = $sensitivity_map[$event['sensitivity']];
|
2011-05-23 21:00:14 +02:00
|
|
|
$event['calendar'] = $event['calendar_id'];
|
2011-07-06 09:43:42 +02:00
|
|
|
$event['recurrence_id'] = intval($event['recurrence_id']);
|
2011-05-23 21:00:14 +02:00
|
|
|
|
|
|
|
// parse recurrence rule
|
|
|
|
if ($event['recurrence'] && preg_match_all('/([A-Z]+)=([^;]+);?/', $event['recurrence'], $m, PREG_SET_ORDER)) {
|
|
|
|
$event['recurrence'] = array();
|
|
|
|
foreach ($m as $rr) {
|
|
|
|
if (is_numeric($rr[2]))
|
|
|
|
$rr[2] = intval($rr[2]);
|
|
|
|
else if ($rr[1] == 'UNTIL')
|
2012-07-06 17:15:45 +02:00
|
|
|
$rr[2] = date_create($rr[2]);
|
2014-03-17 12:40:21 +01:00
|
|
|
else if ($rr[1] == 'RDATE')
|
|
|
|
$rr[2] = array_map('date_create', explode(',', $rr[2]));
|
2011-05-31 17:12:59 +02:00
|
|
|
else if ($rr[1] == 'EXDATE')
|
2012-07-06 17:15:45 +02:00
|
|
|
$rr[2] = array_map('date_create', explode(',', $rr[2]));
|
2011-05-23 21:00:14 +02:00
|
|
|
$event['recurrence'][$rr[1]] = $rr[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-04 17:02:00 +02:00
|
|
|
if ($event['_attachments'] > 0)
|
|
|
|
$event['attachments'] = (array)$this->list_attachments($event);
|
|
|
|
|
2011-07-26 08:38:13 +02:00
|
|
|
// decode serialized event attendees
|
|
|
|
if ($event['attendees']) {
|
|
|
|
$attendees = array();
|
|
|
|
foreach (explode("\n", $event['attendees']) as $line) {
|
|
|
|
$att = array();
|
2012-07-06 17:15:45 +02:00
|
|
|
foreach (rcube_utils::explode_quoted_string(';', $line) as $prop) {
|
2011-07-26 08:38:13 +02:00
|
|
|
list($key, $value) = explode("=", $prop);
|
|
|
|
$att[strtolower($key)] = stripslashes(trim($value, '""'));
|
|
|
|
}
|
|
|
|
$attendees[] = $att;
|
|
|
|
}
|
|
|
|
$event['attendees'] = $attendees;
|
|
|
|
}
|
2013-11-20 12:36:17 +01:00
|
|
|
else {
|
|
|
|
$event['attendees'] = array();
|
|
|
|
}
|
2014-04-17 17:49:00 +02:00
|
|
|
|
|
|
|
// decode serialized alarms
|
|
|
|
if ($event['alarms']) {
|
|
|
|
$event['valarms'] = $this->unserialize_alarms($event['alarms']);
|
|
|
|
}
|
|
|
|
|
2011-08-23 23:10:35 +02:00
|
|
|
unset($event['event_id'], $event['calendar_id'], $event['notifyat'], $event['all_day'], $event['_attachments']);
|
2011-05-23 21:00:14 +02:00
|
|
|
return $event;
|
|
|
|
}
|
|
|
|
|
2011-05-22 18:45:04 +02:00
|
|
|
/**
|
|
|
|
* Get a list of pending alarms to be displayed to the user
|
|
|
|
*
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::pending_alarms()
|
2011-05-22 18:45:04 +02:00
|
|
|
*/
|
|
|
|
public function pending_alarms($time, $calendars = null)
|
|
|
|
{
|
2011-05-23 21:00:14 +02:00
|
|
|
if (empty($calendars))
|
|
|
|
$calendars = array_keys($this->calendars);
|
|
|
|
else if (is_string($calendars))
|
|
|
|
$calendars = explode(',', $calendars);
|
|
|
|
|
2011-07-31 14:40:52 +02:00
|
|
|
// only allow to select from calendars with activated alarms
|
|
|
|
$calendar_ids = array();
|
|
|
|
foreach ($calendars as $cid) {
|
|
|
|
if ($this->calendars[$cid] && $this->calendars[$cid]['showalarms'])
|
|
|
|
$calendar_ids[] = $cid;
|
|
|
|
}
|
|
|
|
$calendar_ids = array_map(array($this->rc->db, 'quote'), $calendar_ids);
|
2011-05-23 21:00:14 +02:00
|
|
|
|
|
|
|
$alarms = array();
|
|
|
|
if (!empty($calendar_ids)) {
|
|
|
|
$result = $this->rc->db->query(sprintf(
|
|
|
|
"SELECT * FROM " . $this->db_events . "
|
|
|
|
WHERE calendar_id IN (%s)
|
2013-03-06 15:25:45 +01:00
|
|
|
AND notifyat <= %s AND %s > %s",
|
2011-05-23 21:00:14 +02:00
|
|
|
join(',', $calendar_ids),
|
2011-05-30 23:04:21 +02:00
|
|
|
$this->rc->db->fromunixtime($time),
|
2013-03-06 15:25:45 +01:00
|
|
|
$this->rc->db->quote_identifier('end'),
|
2011-05-23 21:00:14 +02:00
|
|
|
$this->rc->db->fromunixtime($time)
|
|
|
|
));
|
|
|
|
|
|
|
|
while ($result && ($event = $this->rc->db->fetch_assoc($result)))
|
|
|
|
$alarms[] = $this->_read_postprocess($event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $alarms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Feedback after showing/sending an alarm notification
|
|
|
|
*
|
2011-07-27 16:06:06 +02:00
|
|
|
* @see calendar_driver::dismiss_alarm()
|
2011-05-23 21:00:14 +02:00
|
|
|
*/
|
2011-05-25 23:16:13 +02:00
|
|
|
public function dismiss_alarm($event_id, $snooze = 0)
|
2011-05-23 21:00:14 +02:00
|
|
|
{
|
2011-05-25 23:16:13 +02:00
|
|
|
// set new notifyat time or unset if not snoozed
|
2012-07-06 17:15:45 +02:00
|
|
|
$notify_at = $snooze > 0 ? date(self::DB_DATE_FORMAT, time() + $snooze) : null;
|
2011-05-23 21:00:14 +02:00
|
|
|
|
|
|
|
$query = $this->rc->db->query(sprintf(
|
|
|
|
"UPDATE " . $this->db_events . "
|
|
|
|
SET changed=%s, notifyat=?
|
|
|
|
WHERE event_id=?
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$this->rc->db->now()),
|
|
|
|
$notify_at,
|
|
|
|
$event_id
|
|
|
|
);
|
2011-05-25 23:16:13 +02:00
|
|
|
|
2011-05-23 21:00:14 +02:00
|
|
|
return $this->rc->db->affected_rows($query);
|
2011-05-22 18:45:04 +02:00
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Save an attachment related to the given event
|
|
|
|
*/
|
2011-07-01 21:08:12 +02:00
|
|
|
private function add_attachment($attachment, $event_id)
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
2011-07-04 17:02:00 +02:00
|
|
|
$data = $attachment['data'] ? $attachment['data'] : file_get_contents($attachment['path']);
|
|
|
|
|
|
|
|
$query = $this->rc->db->query(
|
2011-07-01 21:08:12 +02:00
|
|
|
"INSERT INTO " . $this->db_attachments .
|
|
|
|
" (event_id, filename, mimetype, size, data)" .
|
|
|
|
" VALUES (?, ?, ?, ?, ?)",
|
|
|
|
$event_id,
|
|
|
|
$attachment['name'],
|
|
|
|
$attachment['mimetype'],
|
2011-07-04 17:02:00 +02:00
|
|
|
strlen($data),
|
|
|
|
base64_encode($data)
|
|
|
|
);
|
2011-07-01 21:08:12 +02:00
|
|
|
|
|
|
|
return $this->rc->db->affected_rows($query);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a specific attachment from the given event
|
|
|
|
*/
|
2011-07-01 21:08:12 +02:00
|
|
|
private function remove_attachment($attachment_id, $event_id)
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
2011-07-01 21:08:12 +02:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"DELETE FROM " . $this->db_attachments .
|
|
|
|
" WHERE attachment_id = ?" .
|
|
|
|
" AND event_id IN (SELECT event_id FROM " . $this->db_events .
|
|
|
|
" WHERE event_id = ?" .
|
|
|
|
" AND calendar_id IN (" . $this->calendar_ids . "))",
|
|
|
|
$attachment_id,
|
|
|
|
$event_id
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->rc->db->affected_rows($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List attachments of specified event
|
|
|
|
*/
|
|
|
|
public function list_attachments($event)
|
|
|
|
{
|
|
|
|
$attachments = array();
|
|
|
|
|
2011-07-04 17:46:56 +02:00
|
|
|
if (!empty($this->calendar_ids)) {
|
2011-07-01 21:08:12 +02:00
|
|
|
$result = $this->rc->db->query(
|
|
|
|
"SELECT attachment_id AS id, filename AS name, mimetype, size " .
|
|
|
|
" FROM " . $this->db_attachments .
|
2011-07-04 17:02:00 +02:00
|
|
|
" WHERE event_id IN (SELECT event_id FROM " . $this->db_events .
|
|
|
|
" WHERE event_id=?" .
|
|
|
|
" AND calendar_id IN (" . $this->calendar_ids . "))".
|
|
|
|
" ORDER BY filename",
|
2011-07-04 17:46:56 +02:00
|
|
|
$event['recurrence_id'] ? $event['recurrence_id'] : $event['event_id']
|
2011-07-01 21:08:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
|
|
|
|
$attachments[] = $arr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $attachments;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get attachment properties
|
|
|
|
*/
|
|
|
|
public function get_attachment($id, $event)
|
|
|
|
{
|
2011-07-04 17:46:56 +02:00
|
|
|
if (!empty($this->calendar_ids)) {
|
2011-07-01 21:08:12 +02:00
|
|
|
$result = $this->rc->db->query(
|
|
|
|
"SELECT attachment_id AS id, filename AS name, mimetype, size " .
|
|
|
|
" FROM " . $this->db_attachments .
|
|
|
|
" WHERE attachment_id=?".
|
2011-07-04 17:02:00 +02:00
|
|
|
" AND event_id=?",
|
2011-07-01 21:08:12 +02:00
|
|
|
$id,
|
2011-07-04 17:46:56 +02:00
|
|
|
$event['recurrence_id'] ? $event['recurrence_id'] : $event['id']
|
2011-07-01 21:08:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
if ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get attachment body
|
|
|
|
*/
|
|
|
|
public function get_attachment_body($id, $event)
|
|
|
|
{
|
2011-07-04 17:46:56 +02:00
|
|
|
if (!empty($this->calendar_ids)) {
|
2011-07-01 21:08:12 +02:00
|
|
|
$result = $this->rc->db->query(
|
|
|
|
"SELECT data " .
|
|
|
|
" FROM " . $this->db_attachments .
|
|
|
|
" WHERE attachment_id=?".
|
2011-07-04 17:02:00 +02:00
|
|
|
" AND event_id=?",
|
2011-07-01 21:08:12 +02:00
|
|
|
$id,
|
|
|
|
$event['id']
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
|
|
|
|
return base64_decode($arr['data']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the given category
|
|
|
|
*/
|
|
|
|
public function remove_category($name)
|
|
|
|
{
|
2011-06-05 19:08:47 -06:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"UPDATE " . $this->db_events . "
|
|
|
|
SET categories=''
|
|
|
|
WHERE categories=?
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$name
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->rc->db->affected_rows($query);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update/replace a category
|
|
|
|
*/
|
|
|
|
public function replace_category($oldname, $name, $color)
|
|
|
|
{
|
2011-06-05 19:08:47 -06:00
|
|
|
$query = $this->rc->db->query(
|
|
|
|
"UPDATE " . $this->db_events . "
|
|
|
|
SET categories=?
|
|
|
|
WHERE categories=?
|
|
|
|
AND calendar_id IN (" . $this->calendar_ids . ")",
|
|
|
|
$name,
|
|
|
|
$oldname
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->rc->db->affected_rows($query);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
2014-04-17 17:49:00 +02:00
|
|
|
/**
|
|
|
|
* Helper method to serialize the list of alarms into a string
|
|
|
|
*/
|
|
|
|
private function serialize_alarms($valarms)
|
|
|
|
{
|
|
|
|
foreach ((array)$valarms as $i => $alarm) {
|
|
|
|
if ($alarm['trigger'] instanceof DateTime) {
|
|
|
|
$valarms[$i]['trigger'] = '@' . $alarm['trigger']->format('c');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $valarms ? json_encode($valarms) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper method to decode a serialized list of alarms
|
|
|
|
*/
|
|
|
|
private function unserialize_alarms($alarms)
|
|
|
|
{
|
|
|
|
// decode json serialized alarms
|
|
|
|
if ($alarms && $alarms[0] == '[') {
|
|
|
|
$valarms = json_decode($alarms, true);
|
|
|
|
foreach ($valarms as $i => $alarm) {
|
|
|
|
if ($alarm['trigger'][0] == '@') {
|
|
|
|
try {
|
|
|
|
$valarms[$i]['trigger'] = new DateTime(substr($alarm['trigger'], 1));
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
unset($valarms[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// convert legacy alarms data
|
|
|
|
else if (strlen($alarms)) {
|
|
|
|
list($trigger, $action) = explode(':', $alarms, 2);
|
|
|
|
if ($trigger = libcalendaring::parse_alaram_value($trigger)) {
|
|
|
|
$valarms = array(array('action' => $action, 'trigger' => $trigger[3] ?: $trigger[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $valarms;
|
|
|
|
}
|
|
|
|
|
2014-04-23 20:44:46 +02:00
|
|
|
/**
|
|
|
|
* Handler for user_delete plugin hook
|
|
|
|
*/
|
|
|
|
public function user_delete($args)
|
|
|
|
{
|
|
|
|
$db = $this->rc->db;
|
|
|
|
$user = $args['user'];
|
|
|
|
$event_ids = array();
|
|
|
|
|
|
|
|
$events = $db->query(
|
|
|
|
"SELECT event_id FROM " . $this->db_events . " AS ev" .
|
|
|
|
" LEFT JOIN " . $this->db_calendars . " cal ON (ev.calendar_id = cal.calendar_id)".
|
|
|
|
" WHERE user_id=?",
|
|
|
|
$user->ID);
|
|
|
|
|
|
|
|
while ($row = $db->fetch_assoc($calendars)) {
|
|
|
|
$event_ids[] = $row['event_id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($event_ids)) {
|
|
|
|
foreach (array($this->db_attachments, $this->db_events) as $table) {
|
|
|
|
$db->query(sprintf("DELETE FROM $table WHERE event_id IN (%s)", join(',', $event_ids)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (array($this->db_calendars, 'itipinvitations') as $table) {
|
|
|
|
$db->query("DELETE FROM $table WHERE user_id=?", $user->ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|