tasklist: Fix various issues with DAV driver, store alarms option in folder properties
This commit is contained in:
parent
7d2672fba7
commit
f2547d87fe
3 changed files with 12 additions and 34 deletions
|
@ -79,7 +79,6 @@ class tasklist_caldav_driver extends tasklist_driver
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->lists;
|
return $this->lists;
|
||||||
|
@ -88,13 +87,13 @@ class tasklist_caldav_driver extends tasklist_driver
|
||||||
/**
|
/**
|
||||||
* 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') {
|
||||||
$norename = false;
|
$norename = false;
|
||||||
$editable = true;
|
$editable = true;
|
||||||
$rights = 'lrswikxtea';
|
$rights = 'lrswikxtea';
|
||||||
$alarms = true;
|
$alarms = !isset($folder->attributes['alarms']) || $folder->attributes['alarms'];
|
||||||
} else {
|
} else {
|
||||||
$alarms = false;
|
$alarms = false;
|
||||||
$rights = 'lr';
|
$rights = 'lr';
|
||||||
|
@ -302,6 +301,7 @@ class tasklist_caldav_driver extends tasklist_driver
|
||||||
public function create_list(&$prop)
|
public function create_list(&$prop)
|
||||||
{
|
{
|
||||||
$prop['type'] = 'task';
|
$prop['type'] = 'task';
|
||||||
|
$prop['alarms'] = !empty($prop['showalarms']);
|
||||||
|
|
||||||
$id = $this->storage->folder_update($prop);
|
$id = $this->storage->folder_update($prop);
|
||||||
|
|
||||||
|
@ -309,22 +309,12 @@ class tasklist_caldav_driver extends tasklist_driver
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefs['kolab_tasklists'] = $this->rc->config->get('kolab_tasklists', []);
|
|
||||||
|
|
||||||
if (isset($prop['showalarms'])) {
|
|
||||||
$prefs['kolab_tasklists'][$id]['showalarms'] = $prop['showalarms'] ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($prefs['kolab_tasklists'][$id])) {
|
|
||||||
$this->rc->user->save_prefs($prefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// force page reload to properly render folder hierarchy
|
// force page reload to properly render folder hierarchy
|
||||||
if (!empty($prop['parent'])) {
|
if (!empty($prop['parent'])) {
|
||||||
$prop['_reload'] = true;
|
$prop['_reload'] = true;
|
||||||
} else {
|
} else {
|
||||||
$folder = $this->get_folder($id);
|
$prop += $this->_read_lists(true)[$id] ?? [];
|
||||||
$prop += $this->folder_props($folder, []);
|
unset($prop['type'], $prop['alarms']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
@ -346,23 +336,12 @@ class tasklist_caldav_driver extends tasklist_driver
|
||||||
if (!empty($prop['id'])) {
|
if (!empty($prop['id'])) {
|
||||||
$id = $prop['id'];
|
$id = $prop['id'];
|
||||||
$prop['type'] = 'task';
|
$prop['type'] = 'task';
|
||||||
|
$prop['alarms'] = !empty($prop['showalarms']);
|
||||||
|
|
||||||
if ($this->storage->folder_update($prop) !== false) {
|
if ($this->storage->folder_update($prop) !== false) {
|
||||||
$prefs['kolab_tasklists'] = $this->rc->config->get('kolab_tasklists', []);
|
$prop += $this->_read_lists(true)[$id] ?? [];
|
||||||
|
unset($prop['type'], $prop['alarms']);
|
||||||
|
|
||||||
if (isset($prop['showalarms'])) {
|
|
||||||
$prefs['kolab_tasklists'][$id]['showalarms'] = $prop['showalarms'] ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($prefs['kolab_tasklists'][$id])) {
|
|
||||||
$this->rc->user->save_prefs($prefs);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
// force page reload if folder name/hierarchy changed
|
|
||||||
if ($newfolder != $prop['oldname']) {
|
|
||||||
$prop['_reload'] = true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3179,8 +3179,10 @@ function rcube_tasklist_ui(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.tasklists[id] && li) {
|
if (me.tasklists[id] && li) {
|
||||||
|
prop = $.extend({}, me.tasklists[id], prop);
|
||||||
delete me.tasklists[id];
|
delete me.tasklists[id];
|
||||||
me.tasklists[prop.id] = prop;
|
me.tasklists[prop.id] = prop;
|
||||||
|
|
||||||
$(li).find('input').first().val(prop.id);
|
$(li).find('input').first().val(prop.id);
|
||||||
$(li).find('.listname').first().html(Q(prop.name));
|
$(li).find('.listname').first().html(Q(prop.name));
|
||||||
tasklists_widget.update(id, {id: prop.id, html: $(li).children().first()});
|
tasklists_widget.update(id, {id: prop.id, html: $(li).children().first()});
|
||||||
|
|
|
@ -1009,10 +1009,6 @@ class tasklist extends rcube_plugin
|
||||||
|
|
||||||
unset($list['_token']);
|
unset($list['_token']);
|
||||||
|
|
||||||
if (isset($list['showalarms'])) {
|
|
||||||
$list['showalarms'] = intval($list['showalarms']);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'form-new':
|
case 'form-new':
|
||||||
case 'form-edit':
|
case 'form-edit':
|
||||||
|
@ -1021,7 +1017,7 @@ class tasklist extends rcube_plugin
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'new':
|
case 'new':
|
||||||
$list += ['showalarms' => true, 'active' => true, 'editable' => true];
|
$list += ['showalarms' => !empty($list['showalarms']), 'active' => true, 'editable' => true];
|
||||||
if ($insert_id = $this->driver->create_list($list)) {
|
if ($insert_id = $this->driver->create_list($list)) {
|
||||||
$list['id'] = $insert_id;
|
$list['id'] = $insert_id;
|
||||||
if (empty($list['_reload'])) {
|
if (empty($list['_reload'])) {
|
||||||
|
@ -1036,6 +1032,7 @@ class tasklist extends rcube_plugin
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$list['oldid'] = $list['id'];
|
$list['oldid'] = $list['id'];
|
||||||
|
$list['showalarms'] = !empty($list['showalarms']);
|
||||||
if ($success = $this->driver->edit_list($list)) {
|
if ($success = $this->driver->edit_list($list)) {
|
||||||
$this->rc->output->command('plugin.update_tasklist', $list);
|
$this->rc->output->command('plugin.update_tasklist', $list);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue