Changeset View
Changeset View
Standalone View
Standalone View
plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php
Show All 40 Lines | class tasklist_kolab_driver extends tasklist_driver | ||||
private $bonnie_api = false; | private $bonnie_api = false; | ||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
*/ | */ | ||||
public function __construct($plugin) | public function __construct($plugin) | ||||
{ | { | ||||
$this->rc = $plugin->rc; | $this->rc = $plugin->rc; | ||||
$this->plugin = $plugin; | $this->plugin = $plugin; | ||||
if (kolab_storage::$version == '2.0') { | if (kolab_storage::$version == '2.0') { | ||||
$this->alarm_absolute = false; | $this->alarm_absolute = false; | ||||
} | } | ||||
// tasklist use fully encoded identifiers | // tasklist use fully encoded identifiers | ||||
kolab_storage::$encode_ids = true; | kolab_storage::$encode_ids = true; | ||||
// get configuration for the Bonnie API | // get configuration for the Bonnie API | ||||
$this->bonnie_api = libkolab::get_bonnie_api(); | $this->bonnie_api = libkolab::get_bonnie_api(); | ||||
$this->_read_lists(); | |||||
$this->plugin->register_action('folder-acl', array($this, 'folder_acl')); | $this->plugin->register_action('folder-acl', array($this, 'folder_acl')); | ||||
} | } | ||||
/** | /** | ||||
* Read available calendars for the current user and store them internally | * Read available calendars for the current user and store them internally | ||||
*/ | */ | ||||
private function _read_lists($force = false) | private function _read_lists($force = false) | ||||
{ | { | ||||
// already read sources | // already read sources | ||||
if (isset($this->lists) && !$force) | if (isset($this->lists) && !$force) { | ||||
return $this->lists; | return $this->lists; | ||||
} | |||||
// get all folders that have type "task" | // get all folders that have type "task" | ||||
$folders = kolab_storage::sort_folders(kolab_storage::get_folders('task')); | $folders = kolab_storage::sort_folders(kolab_storage::get_folders('task')); | ||||
$this->lists = $this->folders = array(); | $this->lists = $this->folders = array(); | ||||
$delim = $this->rc->get_storage()->get_hierarchy_delimiter(); | $delim = $this->rc->get_storage()->get_hierarchy_delimiter(); | ||||
// find default folder | // find default folder | ||||
Show All 14 Lines | private function _read_lists($force = false) | ||||
foreach ($folders as $folder) { | foreach ($folders as $folder) { | ||||
$tasklist = $this->folder_props($folder, $prefs); | $tasklist = $this->folder_props($folder, $prefs); | ||||
$this->lists[$tasklist['id']] = $tasklist; | $this->lists[$tasklist['id']] = $tasklist; | ||||
$this->folders[$tasklist['id']] = $folder; | $this->folders[$tasklist['id']] = $folder; | ||||
$this->folders[$folder->name] = $folder; | $this->folders[$folder->name] = $folder; | ||||
} | } | ||||
return $this->lists; | |||||
} | } | ||||
/** | /** | ||||
* Derive list properties from the given kolab_storage_folder object | * Derive list properties from the given kolab_storage_folder object | ||||
*/ | */ | ||||
protected function folder_props($folder, $prefs) | protected function folder_props($folder, $prefs) | ||||
{ | { | ||||
if ($folder->get_namespace() == 'personal') { | if ($folder->get_namespace() == 'personal') { | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | protected function folder_props($folder, $prefs) | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Get a list of available task lists from this source | * Get a list of available task lists from this source | ||||
*/ | */ | ||||
public function get_lists(&$tree = null) | public function get_lists(&$tree = null) | ||||
{ | { | ||||
$this->_read_lists(); | |||||
// attempt to create a default list for this user | // attempt to create a default list for this user | ||||
if (empty($this->lists) && !isset($this->search_more_results)) { | if (empty($this->lists) && !isset($this->search_more_results)) { | ||||
$prop = array('name' => 'Tasks', 'color' => '0000CC', 'default' => true); | $prop = array('name' => 'Tasks', 'color' => '0000CC', 'default' => true); | ||||
if ($this->create_list($prop)) | if ($this->create_list($prop)) | ||||
$this->_read_lists(true); | $this->_read_lists(true); | ||||
} | } | ||||
$folders = array(); | $folders = array(); | ||||
Show All 30 Lines | public function get_lists(&$tree = null) | ||||
$fullname = $folder->get_name(); | $fullname = $folder->get_name(); | ||||
$listname = $folder->get_foldername(); | $listname = $folder->get_foldername(); | ||||
// special handling for virtual folders | // special handling for virtual folders | ||||
if ($folder instanceof kolab_storage_folder_user) { | if ($folder instanceof kolab_storage_folder_user) { | ||||
$lists[$list_id] = array( | $lists[$list_id] = array( | ||||
'id' => $list_id, | 'id' => $list_id, | ||||
'name' => $folder->get_name(), | 'name' => $fullname, | ||||
'listname' => $listname, | 'listname' => $listname, | ||||
'title' => $folder->get_title(), | 'title' => $folder->get_title(), | ||||
'virtual' => true, | 'virtual' => true, | ||||
'editable' => false, | 'editable' => false, | ||||
'rights' => 'l', | 'rights' => 'l', | ||||
'group' => 'other virtual', | 'group' => 'other virtual', | ||||
'class' => 'user', | 'class' => 'user', | ||||
'parent' => $parent_id, | 'parent' => $parent_id, | ||||
); | ); | ||||
} | } | ||||
else if ($folder->virtual) { | else if ($folder->virtual) { | ||||
$lists[$list_id] = array( | $lists[$list_id] = array( | ||||
'id' => $list_id, | 'id' => $list_id, | ||||
'name' => kolab_storage::object_name($fullname), | 'name' => $fullname, | ||||
'listname' => $listname, | 'listname' => $listname, | ||||
'virtual' => true, | 'virtual' => true, | ||||
'editable' => false, | 'editable' => false, | ||||
'rights' => 'l', | 'rights' => 'l', | ||||
'group' => $folder->get_namespace(), | 'group' => $folder->get_namespace(), | ||||
'class' => 'folder', | 'class' => 'folder', | ||||
'parent' => $parent_id, | 'parent' => $parent_id, | ||||
); | ); | ||||
Show All 14 Lines | class tasklist_kolab_driver extends tasklist_driver | ||||
/** | /** | ||||
* Get the kolab_calendar instance for the given calendar ID | * Get the kolab_calendar instance for the given calendar ID | ||||
* | * | ||||
* @param string List identifier (encoded imap folder name) | * @param string List identifier (encoded imap folder name) | ||||
* @return object kolab_storage_folder Object nor null if list doesn't exist | * @return object kolab_storage_folder Object nor null if list doesn't exist | ||||
*/ | */ | ||||
protected function get_folder($id) | protected function get_folder($id) | ||||
{ | { | ||||
$this->_read_lists(); | |||||
// create list and folder instance if necesary | // create list and folder instance if necesary | ||||
if (!$this->lists[$id]) { | if (!$this->lists[$id]) { | ||||
$folder = kolab_storage::get_folder(kolab_storage::id_decode($id)); | $folder = kolab_storage::get_folder(kolab_storage::id_decode($id)); | ||||
if ($folder->type) { | if ($folder->type) { | ||||
$this->folders[$id] = $folder; | $this->folders[$id] = $folder; | ||||
$this->lists[$id] = $this->folder_props($folder, $this->rc->config->get('kolab_tasklists', array())); | $this->lists[$id] = $this->folder_props($folder, $this->rc->config->get('kolab_tasklists', array())); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | public function subscribe_list($prop) | ||||
if ($prop['recursive']) { | if ($prop['recursive']) { | ||||
foreach ((array)kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) { | foreach ((array)kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) { | ||||
if (isset($prop['permanent'])) | if (isset($prop['permanent'])) | ||||
($prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder)); | ($prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder)); | ||||
if (isset($prop['active'])) | if (isset($prop['active'])) | ||||
($prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder)); | ($prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder)); | ||||
} | } | ||||
} | } | ||||
return $ret; | return $ret; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Delete the given list with all its contents | * Delete the given list with all its contents | ||||
* | * | ||||
* @param array Hash array with list properties | * @param array Hash array with list properties | ||||
* id: list Identifier | * id: list Identifier | ||||
* @return boolean True on success, Fales on failure | * @return boolean True on success, Fales on failure | ||||
*/ | */ | ||||
public function delete_list($prop) | public function delete_list($prop) | ||||
{ | { | ||||
if ($prop['id'] && ($folder = $this->get_folder($prop['id']))) { | if ($prop['id'] && ($folder = $this->get_folder($prop['id']))) { | ||||
if (kolab_storage::folder_delete($folder->name)) | if (kolab_storage::folder_delete($folder->name)) { | ||||
return true; | return true; | ||||
else | } | ||||
$this->last_error = kolab_storage::$last_error; | $this->last_error = kolab_storage::$last_error; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Search for shared or otherwise not listed tasklists the user has access | * Search for shared or otherwise not listed tasklists the user has access | ||||
* | * | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | class tasklist_kolab_driver extends tasklist_driver | ||||
/** | /** | ||||
* Get number of tasks matching the given filter | * Get number of tasks matching the given filter | ||||
* | * | ||||
* @param array List of lists to count tasks of | * @param array List of lists to count tasks of | ||||
* @return array Hash array with counts grouped by status (all|flagged|completed|today|tomorrow|nodate) | * @return array Hash array with counts grouped by status (all|flagged|completed|today|tomorrow|nodate) | ||||
*/ | */ | ||||
public function count_tasks($lists = null) | public function count_tasks($lists = null) | ||||
{ | { | ||||
if (empty($lists)) | if (empty($lists)) { | ||||
$lists = array_keys($this->lists); | $lists = $this->_read_lists(); | ||||
else if (is_string($lists)) | $lists = array_keys($lists); | ||||
} | |||||
else if (is_string($lists)) { | |||||
$lists = explode(',', $lists); | $lists = explode(',', $lists); | ||||
} | |||||
$today_date = new DateTime('now', $this->plugin->timezone); | $today_date = new DateTime('now', $this->plugin->timezone); | ||||
$today = $today_date->format('Y-m-d'); | $today = $today_date->format('Y-m-d'); | ||||
$tomorrow_date = new DateTime('now + 1 day', $this->plugin->timezone); | $tomorrow_date = new DateTime('now + 1 day', $this->plugin->timezone); | ||||
$tomorrow = $tomorrow_date->format('Y-m-d'); | $tomorrow = $tomorrow_date->format('Y-m-d'); | ||||
$counts = array('all' => 0, 'flagged' => 0, 'today' => 0, 'tomorrow' => 0, 'overdue' => 0, 'nodate' => 0, 'mytasks' => 0); | $counts = array('all' => 0, 'flagged' => 0, 'today' => 0, 'tomorrow' => 0, 'overdue' => 0, 'nodate' => 0, 'mytasks' => 0); | ||||
foreach ($lists as $list_id) { | foreach ($lists as $list_id) { | ||||
if (!$folder = $this->get_folder($list_id)) { | if (!$folder = $this->get_folder($list_id)) { | ||||
continue; | continue; | ||||
} | } | ||||
foreach ($folder->select(array(array('tags','!~','x-complete'))) as $record) { | foreach ($folder->select(array(array('tags','!~','x-complete'))) as $record) { | ||||
$rec = $this->_to_rcube_task($record, $list_id, false); | $rec = $this->_to_rcube_task($record, $list_id, false); | ||||
if ($this->is_complete($rec)) // don't count complete tasks | if ($this->is_complete($rec)) // don't count complete tasks | ||||
continue; | continue; | ||||
$counts['all']++; | $counts['all']++; | ||||
if ($rec['flagged']) | if ($rec['flagged']) | ||||
Show All 25 Lines | class tasklist_kolab_driver extends tasklist_driver | ||||
* - from: Date range start as string (Y-m-d) | * - from: Date range start as string (Y-m-d) | ||||
* - to: Date range end as string (Y-m-d) | * - to: Date range end as string (Y-m-d) | ||||
* - search: Search query string | * - search: Search query string | ||||
* @param array List of lists to get tasks from | * @param array List of lists to get tasks from | ||||
* @return array List of tasks records matchin the criteria | * @return array List of tasks records matchin the criteria | ||||
*/ | */ | ||||
public function list_tasks($filter, $lists = null) | public function list_tasks($filter, $lists = null) | ||||
{ | { | ||||
if (empty($lists)) | if (empty($lists)) { | ||||
$lists = array_keys($this->lists); | $lists = $this->_read_lists(); | ||||
else if (is_string($lists)) | $lists = array_keys($lists); | ||||
} | |||||
else if (is_string($lists)) { | |||||
$lists = explode(',', $lists); | $lists = explode(',', $lists); | ||||
} | |||||
$config = kolab_storage_config::get_instance(); | |||||
$results = array(); | $results = array(); | ||||
// query Kolab storage | // query Kolab storage | ||||
$query = array(); | $query = array(); | ||||
if ($filter['mask'] & tasklist::FILTER_MASK_COMPLETE) | if ($filter['mask'] & tasklist::FILTER_MASK_COMPLETE) | ||||
$query[] = array('tags','~','x-complete'); | $query[] = array('tags','~','x-complete'); | ||||
else if (empty($filter['since'])) | else if (empty($filter['since'])) | ||||
$query[] = array('tags','!~','x-complete'); | $query[] = array('tags','!~','x-complete'); | ||||
// full text search (only works with cache enabled) | // full text search (only works with cache enabled) | ||||
if ($filter['search']) { | if ($filter['search']) { | ||||
$search = mb_strtolower($filter['search']); | $search = mb_strtolower($filter['search']); | ||||
foreach (rcube_utils::normalize_string($search, true) as $word) { | foreach (rcube_utils::normalize_string($search, true) as $word) { | ||||
$query[] = array('words', '~', $word); | $query[] = array('words', '~', $word); | ||||
} | } | ||||
} | } | ||||
if ($filter['since']) { | if ($filter['since']) { | ||||
$query[] = array('changed', '>=', $filter['since']); | $query[] = array('changed', '>=', $filter['since']); | ||||
} | } | ||||
// load all tags into memory first | |||||
kolab_storage_config::get_instance()->get_tags(); | |||||
foreach ($lists as $list_id) { | foreach ($lists as $list_id) { | ||||
if (!$folder = $this->get_folder($list_id)) { | if (!$folder = $this->get_folder($list_id)) { | ||||
continue; | continue; | ||||
} | } | ||||
foreach ($folder->select($query) as $record) { | |||||
$this->load_tags($record); | |||||
$task = $this->_to_rcube_task($record, $list_id); | |||||
foreach ($folder->select($query) as $record) { | |||||
// TODO: post-filter tasks returned from storage | // TODO: post-filter tasks returned from storage | ||||
$record['list_id'] = $list_id; | |||||
$results[] = $task; | $results[] = $record; | ||||
} | } | ||||
} | } | ||||
$config->apply_tags($results, true); | |||||
$config->apply_links($results); | |||||
foreach (array_keys($results) as $idx) { | |||||
$results[$idx] = $this->_to_rcube_task($results[$idx], $results[$idx]['list_id']); | |||||
} | |||||
// avoid session race conditions that will loose temporary subscriptions | // avoid session race conditions that will loose temporary subscriptions | ||||
$this->plugin->rc->session->nowrite = true; | $this->plugin->rc->session->nowrite = true; | ||||
return $results; | return $results; | ||||
} | } | ||||
/** | /** | ||||
* Return data of a specific task | * Return data of a specific task | ||||
* | * | ||||
* @param mixed Hash array with task properties or task UID | * @param mixed Hash array with task properties or task UID | ||||
* @return array Hash array with task properties or false if not found | * @return array Hash array with task properties or false if not found | ||||
*/ | */ | ||||
public function get_task($prop) | public function get_task($prop) | ||||
{ | { | ||||
$this->_read_lists(); | |||||
$this->_parse_id($prop); | $this->_parse_id($prop); | ||||
$id = $prop['uid']; | $id = $prop['uid']; | ||||
$list_id = $prop['list']; | $list_id = $prop['list']; | ||||
$folders = $list_id ? array($list_id => $this->get_folder($list_id)) : $this->folders; | $folders = $list_id ? array($list_id => $this->get_folder($list_id)) : $this->folders; | ||||
// find task in the available folders | // find task in the available folders | ||||
foreach ($folders as $list_id => $folder) { | foreach ($folders as $list_id => $folder) { | ||||
if (is_numeric($list_id) || !$folder) | if (is_numeric($list_id) || !$folder) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | public function restore_task_revision($prop, $rev) | ||||
return false; | return false; | ||||
} | } | ||||
$this->_parse_id($prop); | $this->_parse_id($prop); | ||||
$uid = $prop['uid']; | $uid = $prop['uid']; | ||||
$list_id = $prop['list']; | $list_id = $prop['list']; | ||||
list($uid, $mailbox, $msguid) = $this->_resolve_task_identity($prop); | list($uid, $mailbox, $msguid) = $this->_resolve_task_identity($prop); | ||||
$folder = $this->get_folder($list_id); | $folder = $this->get_folder($list_id); | ||||
$success = false; | $success = false; | ||||
if ($folder && ($raw_msg = $this->bonnie_api->rawdata('task', $uid, $rev, $mailbox))) { | if ($folder && ($raw_msg = $this->bonnie_api->rawdata('task', $uid, $rev, $mailbox))) { | ||||
$imap = $this->rc->get_storage(); | $imap = $this->rc->get_storage(); | ||||
// insert $raw_msg as new message | // insert $raw_msg as new message | ||||
if ($imap->save_message($folder->name, $raw_msg, null, false)) { | if ($imap->save_message($folder->name, $raw_msg, null, false)) { | ||||
$success = true; | $success = true; | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | private function _resolve_task_identity($prop) | ||||
$msguid = $rec['_msguid']; | $msguid = $rec['_msguid']; | ||||
$uid = $rec['uid']; | $uid = $rec['uid']; | ||||
} | } | ||||
} | } | ||||
return array($uid, $mailbox, $msguid); | return array($uid, $mailbox, $msguid); | ||||
} | } | ||||
/** | /** | ||||
* Get a list of pending alarms to be displayed to the user | * Get a list of pending alarms to be displayed to the user | ||||
* | * | ||||
* @param integer Current time (unix timestamp) | * @param integer Current time (unix timestamp) | ||||
* @param mixed List of list IDs to show alarms for (either as array or comma-separated string) | * @param mixed List of list IDs to show alarms for (either as array or comma-separated string) | ||||
* @return array A list of alarms, each encoded as hash array with task properties | * @return array A list of alarms, each encoded as hash array with task properties | ||||
* @see tasklist_driver::pending_alarms() | * @see tasklist_driver::pending_alarms() | ||||
*/ | */ | ||||
Show All 13 Lines | public function pending_alarms($time, $lists = null) | ||||
return array(); | return array(); | ||||
if ($lists && is_string($lists)) | if ($lists && is_string($lists)) | ||||
$lists = explode(',', $lists); | $lists = explode(',', $lists); | ||||
$time = $slot + $interval; | $time = $slot + $interval; | ||||
$candidates = array(); | $candidates = array(); | ||||
$query = array(array('tags', '=', 'x-has-alarms'), array('tags', '!=', 'x-complete')); | $query = array( | ||||
array('tags', '=', 'x-has-alarms'), | |||||
array('tags', '!=', 'x-complete') | |||||
); | |||||
$this->_read_lists(); | |||||
foreach ($this->lists as $lid => $list) { | foreach ($this->lists as $lid => $list) { | ||||
// skip lists with alarms disabled | // skip lists with alarms disabled | ||||
if (!$list['showalarms'] || ($lists && !in_array($lid, $lists))) | if (!$list['showalarms'] || ($lists && !in_array($lid, $lists))) | ||||
continue; | continue; | ||||
$folder = $this->get_folder($lid); | $folder = $this->get_folder($lid); | ||||
foreach ($folder->select($query) as $record) { | foreach ($folder->select($query) as $record) { | ||||
if (!($record['valarms'] || $record['alarms']) || $record['status'] == 'COMPLETED' || $record['complete'] == 100) // don't trust query :-) | if (!($record['valarms'] || $record['alarms']) || $record['status'] == 'COMPLETED' || $record['complete'] == 100) // don't trust query :-) | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | private function get_links($uid) | ||||
return $config->get_object_links($uid); | return $config->get_object_links($uid); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
private function save_links($uid, $links) | private function save_links($uid, $links) | ||||
{ | { | ||||
// make sure we have a valid array | |||||
if (empty($links)) { | |||||
$links = array(); | |||||
} | |||||
$config = kolab_storage_config::get_instance(); | $config = kolab_storage_config::get_instance(); | ||||
$remove = array_diff($config->get_object_links($uid), $links); | return $config->save_object_links($uid, (array) $links); | ||||
return $config->save_object_links($uid, $links, $remove); | |||||
} | } | ||||
/** | /** | ||||
* Extract uid + list identifiers from the given input | * Extract uid + list identifiers from the given input | ||||
* | * | ||||
* @param mixed array or string with task identifier(s) | * @param mixed array or string with task identifier(s) | ||||
*/ | */ | ||||
private function _parse_id(&$prop) | private function _parse_id(&$prop) | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | // 'location' => $record['location'], | ||||
'status' => $record['status'], | 'status' => $record['status'], | ||||
'parent_id' => $record['parent_id'] ? $id_prefix . $record['parent_id'] : null, | 'parent_id' => $record['parent_id'] ? $id_prefix . $record['parent_id'] : null, | ||||
'recurrence' => $record['recurrence'], | 'recurrence' => $record['recurrence'], | ||||
'attendees' => $record['attendees'], | 'attendees' => $record['attendees'], | ||||
'organizer' => $record['organizer'], | 'organizer' => $record['organizer'], | ||||
'sequence' => $record['sequence'], | 'sequence' => $record['sequence'], | ||||
'tags' => $record['tags'], | 'tags' => $record['tags'], | ||||
'list' => $list_id, | 'list' => $list_id, | ||||
'links' => $record['links'], | |||||
); | ); | ||||
// we can sometimes skip this expensive operation | // we can sometimes skip this expensive operation | ||||
if ($all) { | if ($all && !array_key_exists('links', $task)) { | ||||
$task['links'] = $this->get_links($task['uid']); | $task['links'] = $this->get_links($task['uid']); | ||||
} | } | ||||
// convert from DateTime to internal date format | // convert from DateTime to internal date format | ||||
if (is_a($record['due'], 'DateTime')) { | if (is_a($record['due'], 'DateTime')) { | ||||
$due = $this->plugin->lib->adjust_timezone($record['due']); | $due = $this->plugin->lib->adjust_timezone($record['due']); | ||||
$task['date'] = $due->format('Y-m-d'); | $task['date'] = $due->format('Y-m-d'); | ||||
if (!$record['due']->_dateonly) | if (!$record['due']->_dateonly) | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | // 'location' => $record['location'], | ||||
} | } | ||||
/** | /** | ||||
* Convert the given task record into a data structure that can be passed to kolab_storage backend for saving | * Convert the given task record into a data structure that can be passed to kolab_storage backend for saving | ||||
* (opposite of self::_to_rcube_event()) | * (opposite of self::_to_rcube_event()) | ||||
*/ | */ | ||||
private function _from_rcube_task($task, $old = array()) | private function _from_rcube_task($task, $old = array()) | ||||
{ | { | ||||
$object = $task; | $object = $task; | ||||
$id_prefix = $task['list'] . ':'; | $id_prefix = $task['list'] . ':'; | ||||
if (!empty($task['date'])) { | if (!empty($task['date'])) { | ||||
$object['due'] = rcube_utils::anytodatetime($task['date'].' '.$task['time'], $this->plugin->timezone); | $object['due'] = rcube_utils::anytodatetime($task['date'].' '.$task['time'], $this->plugin->timezone); | ||||
if (empty($task['time'])) | if (empty($task['time'])) | ||||
$object['due']->_dateonly = true; | $object['due']->_dateonly = true; | ||||
unset($object['date']); | unset($object['date']); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | public function edit_task($task) | ||||
'file' => __FILE__, 'line' => __LINE__, | 'file' => __FILE__, 'line' => __LINE__, | ||||
'message' => "Invalid list identifer to save task: " . print_r($list_id, true)), | 'message' => "Invalid list identifer to save task: " . print_r($list_id, true)), | ||||
true, false); | true, false); | ||||
return false; | return false; | ||||
} | } | ||||
// email links and tags are stored separately | // email links and tags are stored separately | ||||
$links = $task['links']; | $links = $task['links']; | ||||
$tags = $task['tags']; | $tags = $task['tags']; | ||||
unset($task['tags'], $task['links']); | unset($task['tags'], $task['links']); | ||||
// moved from another folder | // moved from another folder | ||||
if ($task['_fromlist'] && ($fromfolder = $this->get_folder($task['_fromlist']))) { | if ($task['_fromlist'] && ($fromfolder = $this->get_folder($task['_fromlist']))) { | ||||
if (!$fromfolder->move($task['uid'], $folder)) | if (!$fromfolder->move($task['uid'], $folder)) | ||||
return false; | return false; | ||||
unset($task['_fromlist']); | unset($task['_fromlist']); | ||||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | public function get_message_related_tasks($headers, $folder) | ||||
return $result; | return $result; | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public function tasklist_edit_form($action, $list, $fieldprop) | public function tasklist_edit_form($action, $list, $fieldprop) | ||||
{ | { | ||||
$this->_read_lists(); | |||||
if ($list['id'] && ($list = $this->lists[$list['id']])) { | if ($list['id'] && ($list = $this->lists[$list['id']])) { | ||||
$folder_name = $this->get_folder($list['id'])->name; // UTF7 | $folder_name = $this->get_folder($list['id'])->name; // UTF7 | ||||
} | } | ||||
else { | else { | ||||
$folder_name = ''; | $folder_name = ''; | ||||
} | } | ||||
$storage = $this->rc->get_storage(); | $storage = $this->rc->get_storage(); | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |