From f6f7b710b3a7be8a2c7909b5e51aeee30fc4dda9 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 9 Apr 2014 11:12:50 +0200 Subject: [PATCH] Include sharing (acl) tab in task list edit dialog --- .../drivers/kolab/tasklist_kolab_driver.php | 137 ++++++++++++++++-- plugins/tasklist/drivers/tasklist_driver.php | 6 +- plugins/tasklist/localization/de_CH.inc | 1 + plugins/tasklist/localization/de_DE.inc | 1 + plugins/tasklist/localization/en_US.inc | 1 + plugins/tasklist/skins/larry/tasklist.css | 17 +++ .../skins/larry/templates/kolabacl.html | 26 ++++ .../skins/larry/templates/mainview.html | 9 +- plugins/tasklist/tasklist.js | 88 ++++++----- plugins/tasklist/tasklist.php | 7 +- plugins/tasklist/tasklist_ui.php | 5 +- 11 files changed, 242 insertions(+), 56 deletions(-) create mode 100644 plugins/tasklist/skins/larry/templates/kolabacl.html diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php index f3d101ca..89de0890 100644 --- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php +++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php @@ -50,6 +50,8 @@ class tasklist_kolab_driver extends tasklist_driver if (kolab_storage::$version == '2.0') { $this->alarm_absolute = false; } + + $this->plugin->register_action('folder-acl', array($this, 'folder_acl')); } /** @@ -863,21 +865,132 @@ class tasklist_kolab_driver extends tasklist_driver /** * */ - public function tasklist_edit_form($fieldprop) + public function tasklist_edit_form($action, $list, $fieldprop) { - $select = kolab_storage::folder_selector('task', array('name' => 'parent', 'id' => 'taskedit-parentfolder'), null); - $fieldprop['parent'] = array( - 'id' => 'taskedit-parentfolder', - 'label' => $this->plugin->gettext('parentfolder'), - 'value' => $select->show(''), - ); - - $formfields = array(); - foreach (array('name','parent','showalarms') as $f) { - $formfields[$f] = $fieldprop[$f]; + if ($list['id'] && ($list = $this->lists[$list['id']])) { + $folder_name = $this->folders[$list['id']]->name; // UTF7 + } + else { + $folder_name = ''; } - return parent::tasklist_edit_form($formfields); + $storage = $this->rc->get_storage(); + $delim = $storage->get_hierarchy_delimiter(); + $form = array(); + + if (strlen($folder_name)) { + $path_imap = explode($delim, $folder_name); + array_pop($path_imap); // pop off name part + $path_imap = implode($path_imap, $delim); + + $options = $storage->folder_info($folder_name); + } + else { + $path_imap = ''; + } + + $hidden_fields[] = array('name' => 'oldname', 'value' => $folder_name); + + // folder name (default field) + $input_name = new html_inputfield(array('name' => 'name', 'id' => 'taskedit-tasklistame', 'size' => 20)); + $fieldprop['name']['value'] = $input_name->show($list['editname'], array('disabled' => ($options['norename'] || $options['protected']))); + + // prevent user from moving folder + if (!empty($options) && ($options['norename'] || $options['protected'])) { + $hidden_fields[] = array('name' => 'parent', 'value' => $path_imap); + } + else { + $select = kolab_storage::folder_selector('task', array('name' => 'parent', 'id' => 'taskedit-parentfolder'), $folder_name); + $fieldprop['parent'] = array( + 'id' => 'taskedit-parentfolder', + 'label' => $this->plugin->gettext('parentfolder'), + 'value' => $select->show($path_imap), + ); + } + + // General tab + $form['properties'] = array( + 'name' => $this->rc->gettext('properties'), + 'fields' => array(), + ); + + foreach (array('name','parent','showalarms') as $f) { + $form['properties']['fields'][$f] = $fieldprop[$f]; + } + + // add folder ACL tab + if ($action != 'form-new') { + $form['sharing'] = array( + 'name' => Q($this->plugin->gettext('tabsharing')), + 'content' => html::tag('iframe', array( + 'src' => $this->rc->url(array('_action' => 'folder-acl', '_folder' => $folder_name, 'framed' => 1)), + 'width' => '100%', + 'height' => 280, + 'border' => 0, + 'style' => 'border:0'), + '') + ); + } + + $form_html = ''; + if (is_array($hidden_fields)) { + foreach ($hidden_fields as $field) { + $hiddenfield = new html_hiddenfield($field); + $form_html .= $hiddenfield->show() . "\n"; + } + } + + // create form output + foreach ($form as $tab) { + if (is_array($tab['fields']) && empty($tab['content'])) { + $table = new html_table(array('cols' => 2)); + foreach ($tab['fields'] as $col => $colprop) { + $colprop['id'] = '_'.$col; + $label = !empty($colprop['label']) ? $colprop['label'] : $this->plugin->gettext($col); + + $table->add('title', html::label($colprop['id'], Q($label))); + $table->add(null, $colprop['value']); + } + $content = $table->show(); + } + else { + $content = $tab['content']; + } + + if (!empty($content)) { + $form_html .= html::tag('fieldset', null, html::tag('legend', null, Q($tab['name'])) . $content) . "\n"; + } + } + + return $form_html; } + /** + * Handler to render ACL form for a notes folder + */ + public function folder_acl() + { + $this->plugin->require_plugin('acl'); + $this->rc->output->add_handler('folderacl', array($this, 'folder_acl_form')); + $this->rc->output->send('tasklist.kolabacl'); + } + + /** + * Handler for ACL form template object + */ + public function folder_acl_form() + { + $folder = rcube_utils::get_input_value('_folder', RCUBE_INPUT_GPC); + + if (strlen($folder)) { + $storage = $this->rc->get_storage(); + $options = $storage->folder_info($folder); + + // get sharing UI from acl plugin + $acl = $this->rc->plugins->exec_hook('folder_form', + array('form' => array(), 'options' => $options, 'name' => $folder)); + } + + return $acl['form']['sharing']['content'] ?: html::div('hint', $this->plugin->gettext('aclnorights')); + } } diff --git a/plugins/tasklist/drivers/tasklist_driver.php b/plugins/tasklist/drivers/tasklist_driver.php index cc9a409e..9e6fee82 100644 --- a/plugins/tasklist/drivers/tasklist_driver.php +++ b/plugins/tasklist/drivers/tasklist_driver.php @@ -260,10 +260,12 @@ abstract class tasklist_driver * Build the edit/create form for lists. * This gives the drivers the opportunity to add more list properties * - * @param array List with form fields to be rendered + * @param string The action called this form + * @param array Tasklist properties + * @param array List with form fields to be rendered * @return string HTML content of the form */ - public function tasklist_edit_form($formfields) + public function tasklist_edit_form($action, $list, $formfields) { $html = ''; foreach ($formfields as $field) { diff --git a/plugins/tasklist/localization/de_CH.inc b/plugins/tasklist/localization/de_CH.inc index c35bc5d1..5974fbc3 100644 --- a/plugins/tasklist/localization/de_CH.inc +++ b/plugins/tasklist/localization/de_CH.inc @@ -54,3 +54,4 @@ $labels['invalidstartduedates'] = 'Beginn der Aufgabe darf nicht grösser als da $labels['deletetasktconfirm'] = 'Möchten Sie diese Aufgabe wirklich löschen?'; $labels['deleteparenttasktconfirm'] = 'Möchten Sie diese Aufgabe inklusive aller Teilaufgaben wirklich löschen?'; $labels['deletelistconfirm'] = 'Möchten Sie diese Liste mit allen Aufgaben wirklich löschen?'; +$labels['aclnorights'] = 'Der Zugriff auf diese Liste erfordert Administrator-Rechte.'; diff --git a/plugins/tasklist/localization/de_DE.inc b/plugins/tasklist/localization/de_DE.inc index 11a92d35..6eee452c 100644 --- a/plugins/tasklist/localization/de_DE.inc +++ b/plugins/tasklist/localization/de_DE.inc @@ -53,3 +53,4 @@ $labels['invalidstartduedates'] = 'Das Anfangsdatum muss vor dem Fälligkeitsdat $labels['deletetasktconfirm'] = 'Diese Aufgabe wirklich löschen?'; $labels['deleteparenttasktconfirm'] = 'Diese Aufgabe wirklich mit allen Teilaufgaben löschen?'; $labels['deletelistconfirm'] = 'Diese Aufgabenliste wirklich mit allen Aufgaben löschen?'; +$labels['aclnorights'] = 'Der Zugriff auf diese Liste erfordert Administrator-Rechte.'; diff --git a/plugins/tasklist/localization/en_US.inc b/plugins/tasklist/localization/en_US.inc index ae414034..6fc7ce16 100644 --- a/plugins/tasklist/localization/en_US.inc +++ b/plugins/tasklist/localization/en_US.inc @@ -69,3 +69,4 @@ $labels['deletetasktconfirm'] = 'Do you really want to delete this task?'; $labels['deleteparenttasktconfirm'] = 'Do you really want to delete this task and all its subtasks?'; $labels['deletelistconfirm'] = 'Do you really want to delete this list with all its tasks?'; $labels['deletelistconfirmrecursive'] = 'Do you really want to delete this list with all its sub-lists and tasks?'; +$labels['aclnorights'] = 'You do not have administrator rights on this task list.'; diff --git a/plugins/tasklist/skins/larry/tasklist.css b/plugins/tasklist/skins/larry/tasklist.css index 5798db89..3d0da623 100644 --- a/plugins/tasklist/skins/larry/tasklist.css +++ b/plugins/tasklist/skins/larry/tasklist.css @@ -834,6 +834,23 @@ label.block { outline: none; } +.tasklistview .uidialog .tabbed { + margin: -12px -8px 0 -8px; + min-width: 600px; +} + +.tasklistview .uidialog .propform fieldset.tab { + display: block; + background: #efefef; + margin-top: 0.5em; + padding: 0.5em 1em; + min-height: 290px; +} + +.tasklistview .uidialog .propform #taskedit-tasklistame { + width: 20em; +} + /** * Styles of the tagedit inputsforms diff --git a/plugins/tasklist/skins/larry/templates/kolabacl.html b/plugins/tasklist/skins/larry/templates/kolabacl.html new file mode 100644 index 00000000..1cf26fc7 --- /dev/null +++ b/plugins/tasklist/skins/larry/templates/kolabacl.html @@ -0,0 +1,26 @@ + + + +<roundcube:object name="pagetitle" /> + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/tasklist/skins/larry/templates/mainview.html b/plugins/tasklist/skins/larry/templates/mainview.html index 03557bbe..9b5a3a68 100644 --- a/plugins/tasklist/skins/larry/templates/mainview.html +++ b/plugins/tasklist/skins/larry/templates/mainview.html @@ -146,7 +146,8 @@
- + +