Changeset View
Changeset View
Standalone View
Standalone View
plugins/tasklist/tasklist_ui.php
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | function load_settings() | ||||
$settings['invite_shared'] = (int)$this->rc->config->get('calendar_allow_invite_shared', 0); | $settings['invite_shared'] = (int)$this->rc->config->get('calendar_allow_invite_shared', 0); | ||||
$settings['itip_notify'] = (int)$this->rc->config->get('calendar_itip_send_option', 3); | $settings['itip_notify'] = (int)$this->rc->config->get('calendar_itip_send_option', 3); | ||||
$settings['sort_col'] = $this->rc->config->get('tasklist_sort_col', ''); | $settings['sort_col'] = $this->rc->config->get('tasklist_sort_col', ''); | ||||
$settings['sort_order'] = $this->rc->config->get('tasklist_sort_order', 'asc'); | $settings['sort_order'] = $this->rc->config->get('tasklist_sort_order', 'asc'); | ||||
// get user identity to create default attendee | // get user identity to create default attendee | ||||
foreach ($this->rc->user->list_emails() as $rec) { | foreach ($this->rc->user->list_emails() as $rec) { | ||||
if (!$identity) | if (empty($identity)) { | ||||
$identity = $rec; | $identity = $rec; | ||||
} | |||||
$identity['emails'][] = $rec['email']; | $identity['emails'][] = $rec['email']; | ||||
$settings['identities'][$rec['identity_id']] = $rec['email']; | $settings['identities'][$rec['identity_id']] = $rec['email']; | ||||
} | } | ||||
$identity['emails'][] = $this->rc->user->get_username(); | $identity['emails'][] = $this->rc->user->get_username(); | ||||
$settings['identity'] = array( | $settings['identity'] = array( | ||||
'name' => $identity['name'], | 'name' => $identity['name'], | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | public function tasklists($attrib = array()) | ||||
$html = $this->list_tree_html($tree, $lists, $jsenv, $attrib); | $html = $this->list_tree_html($tree, $lists, $jsenv, $attrib); | ||||
} | } | ||||
else { | else { | ||||
// fall-back to flat folder listing | // fall-back to flat folder listing | ||||
$attrib['class'] .= ' flat'; | $attrib['class'] .= ' flat'; | ||||
$html = ''; | $html = ''; | ||||
foreach ((array)$lists as $id => $prop) { | foreach ((array)$lists as $id => $prop) { | ||||
if ($attrib['activeonly'] && !$prop['active']) | if (!empty($attrib['activeonly']) && empty($prop['active'])) { | ||||
continue; | continue; | ||||
} | |||||
$html .= html::tag('li', array( | $html .= html::tag('li', array( | ||||
'id' => 'rcmlitasklist' . rcube_utils::html_identifier($id), | 'id' => 'rcmlitasklist' . rcube_utils::html_identifier($id), | ||||
'class' => $prop['group'], | 'class' => isset($prop['group']) ? $prop['group'] : null, | ||||
), | ), | ||||
$this->tasklist_list_item($id, $prop, $jsenv, $attrib['activeonly']) | $this->tasklist_list_item($id, $prop, $jsenv, !empty($attrib['activeonly'])) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
$this->rc->output->include_script('treelist.js'); | $this->rc->output->include_script('treelist.js'); | ||||
$this->rc->output->set_env('source', rcube_utils::get_input_value('source', rcube_utils::INPUT_GET)); | $this->rc->output->set_env('source', rcube_utils::get_input_value('source', rcube_utils::INPUT_GET)); | ||||
$this->rc->output->set_env('tasklists', $jsenv); | $this->rc->output->set_env('tasklists', $jsenv); | ||||
Show All 33 Lines | class tasklist_ui | ||||
} | } | ||||
/** | /** | ||||
* Helper method to build a tasklist item (HTML content and js data) | * Helper method to build a tasklist item (HTML content and js data) | ||||
*/ | */ | ||||
public function tasklist_list_item($id, $prop, &$jsenv, $activeonly = false) | public function tasklist_list_item($id, $prop, &$jsenv, $activeonly = false) | ||||
{ | { | ||||
// enrich list properties with settings from the driver | // enrich list properties with settings from the driver | ||||
if (!$prop['virtual']) { | if (empty($prop['virtual'])) { | ||||
unset($prop['user_id']); | unset($prop['user_id']); | ||||
$prop['alarms'] = $this->plugin->driver->alarms; | $prop['alarms'] = $this->plugin->driver->alarms; | ||||
$prop['undelete'] = $this->plugin->driver->undelete; | $prop['undelete'] = $this->plugin->driver->undelete; | ||||
$prop['sortable'] = $this->plugin->driver->sortable; | $prop['sortable'] = $this->plugin->driver->sortable; | ||||
$prop['attachments'] = $this->plugin->driver->attachments; | $prop['attachments'] = $this->plugin->driver->attachments; | ||||
$prop['attendees'] = $this->plugin->driver->attendees; | $prop['attendees'] = $this->plugin->driver->attendees; | ||||
$prop['caldavurl'] = $this->plugin->driver->tasklist_caldav_url($prop); | $prop['caldavurl'] = $this->plugin->driver->tasklist_caldav_url($prop); | ||||
$jsenv[$id] = $prop; | $jsenv[$id] = $prop; | ||||
} | } | ||||
$classes = array('tasklist'); | $classes = array('tasklist'); | ||||
$title = $prop['title'] ?: ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? | $title = ''; | ||||
html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : ''); | |||||
if (!empty($prop['title'])) { | |||||
$title = $prop['title']; | |||||
} | |||||
else if (empty($prop['listname']) || $prop['name'] != $prop['listname'] || strlen($prop['name']) > 25) { | |||||
html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET); | |||||
} | |||||
if ($prop['virtual']) | if (!empty($prop['virtual'])) { | ||||
$classes[] = 'virtual'; | $classes[] = 'virtual'; | ||||
else if (!$prop['editable']) | } | ||||
else if (empty($prop['editable'])) { | |||||
$classes[] = 'readonly'; | $classes[] = 'readonly'; | ||||
if ($prop['subscribed']) | } | ||||
if (!empty($prop['subscribed'])) { | |||||
$classes[] = 'subscribed'; | $classes[] = 'subscribed'; | ||||
if ($prop['class']) | } | ||||
if (!empty($prop['class'])) { | |||||
$classes[] = $prop['class']; | $classes[] = $prop['class']; | ||||
} | |||||
if (!$activeonly || $prop['active']) { | if (!$activeonly || $prop['active']) { | ||||
$label_id = 'tl:' . $id; | $label_id = 'tl:' . $id; | ||||
$chbox = html::tag('input', array( | $chbox = html::tag('input', array( | ||||
'type' => 'checkbox', | 'type' => 'checkbox', | ||||
'name' => '_list[]', | 'name' => '_list[]', | ||||
'value' => $id, | 'value' => $id, | ||||
'checked' => $prop['active'], | 'checked' => $prop['active'], | ||||
'title' => $this->plugin->gettext('activate'), | 'title' => $this->plugin->gettext('activate'), | ||||
'aria-labelledby' => $label_id | 'aria-labelledby' => $label_id | ||||
)); | )); | ||||
return html::div(join(' ', $classes), | return html::div(join(' ', $classes), | ||||
html::a(array('class' => 'listname', 'title' => $title, 'href' => '#', 'id' => $label_id), $prop['listname'] ?: $prop['name']) . | html::a(array('class' => 'listname', 'title' => $title, 'href' => '#', 'id' => $label_id), | ||||
($prop['virtual'] ? '' : $chbox . html::span('actions', | !empty($prop['listname']) ? $prop['listname'] : $prop['name']) . | ||||
($prop['removable'] ? html::a(array('href' => '#', 'class' => 'remove', 'title' => $this->plugin->gettext('removelist')), ' ') : '') | (!empty($prop['virtual']) ? '' : $chbox . html::span('actions', | ||||
(!empty($prop['removable']) ? html::a(array('href' => '#', 'class' => 'remove', 'title' => $this->plugin->gettext('removelist')), ' ') : '') | |||||
. html::a(array('href' => '#', 'class' => 'quickview', 'title' => $this->plugin->gettext('focusview'), 'role' => 'checkbox', 'aria-checked' => 'false'), ' ') | . html::a(array('href' => '#', 'class' => 'quickview', 'title' => $this->plugin->gettext('focusview'), 'role' => 'checkbox', 'aria-checked' => 'false'), ' ') | ||||
. (isset($prop['subscribed']) ? html::a(array('href' => '#', 'class' => 'subscribed', 'title' => $this->plugin->gettext('tasklistsubscribe'), 'role' => 'checkbox', 'aria-checked' => $prop['subscribed'] ? 'true' : 'false'), ' ') : '') | . (isset($prop['subscribed']) ? html::a(array('href' => '#', 'class' => 'subscribed', 'title' => $this->plugin->gettext('tasklistsubscribe'), 'role' => 'checkbox', 'aria-checked' => $prop['subscribed'] ? 'true' : 'false'), ' ') : '') | ||||
) | ) | ||||
) | ) | ||||
); | ); | ||||
} | } | ||||
return ''; | return ''; | ||||
Show All 23 Lines | function tasklist_select($attrib = array()) | ||||
if (empty($attrib['name'])) { | if (empty($attrib['name'])) { | ||||
$attrib['name'] = 'list'; | $attrib['name'] = 'list'; | ||||
} | } | ||||
$attrib['is_escaped'] = true; | $attrib['is_escaped'] = true; | ||||
$select = new html_select($attrib); | $select = new html_select($attrib); | ||||
$default = null; | $default = null; | ||||
if (!empty($attrib['extra'])) { | |||||
foreach ((array) $attrib['extra'] as $id => $name) { | foreach ((array) $attrib['extra'] as $id => $name) { | ||||
$select->add($name, $id); | $select->add($name, $id); | ||||
} | } | ||||
} | |||||
foreach ((array)$this->plugin->driver->get_lists() as $id => $prop) { | foreach ((array) $this->plugin->driver->get_lists() as $id => $prop) { | ||||
if ($prop['editable'] || strpos($prop['rights'], 'i') !== false) { | if (!empty($prop['editable']) || strpos($prop['rights'], 'i') !== false) { | ||||
$select->add($prop['name'], $id); | $select->add($prop['name'], $id); | ||||
if (!$default || $prop['default']) | if (!$default || !empty($prop['default'])) { | ||||
$default = $id; | $default = $id; | ||||
} | } | ||||
} | } | ||||
} | |||||
return $select->show($default); | return $select->show($default); | ||||
} | } | ||||
function tasklist_editform($action, $list = array()) | function tasklist_editform($action, $list = array()) | ||||
{ | { | ||||
$this->action = $action; | $this->action = $action; | ||||
$this->list = $list; | $this->list = $list; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | */ | ||||
/** | /** | ||||
* Interactive UI element to add/remove tags | * Interactive UI element to add/remove tags | ||||
*/ | */ | ||||
function tags_editline($attrib) | function tags_editline($attrib) | ||||
{ | { | ||||
$attrib += array('id' => 'rcmtasktagsedit'); | $attrib += array('id' => 'rcmtasktagsedit'); | ||||
$this->register_gui_object('edittagline', $attrib['id']); | $this->register_gui_object('edittagline', $attrib['id']); | ||||
$input = new html_inputfield(array('name' => 'tags[]', 'class' => 'tag', 'size' => $attrib['size'], 'tabindex' => $attrib['tabindex'])); | $input = new html_inputfield(array( | ||||
'name' => 'tags[]', | |||||
'class' => 'tag', | |||||
'size' => !empty($attrib['size']) ? $attrib['size'] : null, | |||||
'tabindex' => isset($attrib['tabindex']) ? $attrib['tabindex'] : null, | |||||
)); | |||||
unset($attrib['tabindex']); | unset($attrib['tabindex']); | ||||
return html::div($attrib, $input->show('')); | return html::div($attrib, $input->show('')); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
function attendees_list($attrib = array()) | function attendees_list($attrib = array()) | ||||
Show All 23 Lines | // $table->add_header('role', $this->plugin->gettext('role')); | ||||
return $table->show($attrib); | return $table->show($attrib); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
function attendees_form($attrib = array()) | function attendees_form($attrib = array()) | ||||
{ | { | ||||
$input = new html_inputfield(array('name' => 'participant', 'id' => 'edit-attendee-name', 'size' => $attrib['size'], 'class' => 'form-control')); | $input = new html_inputfield(array( | ||||
$textarea = new html_textarea(array('name' => 'comment', 'id' => 'edit-attendees-comment', | 'name' => 'participant', | ||||
'rows' => 4, 'cols' => 55, 'title' => $this->plugin->gettext('itipcommenttitle'), 'class' => 'form-control')); | 'id' => 'edit-attendee-name', | ||||
'size' => !empty($attrib['size']) ? $attrib['size'] : null, | |||||
'class' => 'form-control' | |||||
)); | |||||
$textarea = new html_textarea(array( | |||||
'name' => 'comment', | |||||
'id' => 'edit-attendees-comment', | |||||
'rows' => 4, | |||||
'cols' => 55, | |||||
'title' => $this->plugin->gettext('itipcommenttitle'), | |||||
'class' => 'form-control' | |||||
)); | |||||
return html::div($attrib, | return html::div($attrib, | ||||
html::div('form-searchbar', $input->show() . " " . | html::div('form-searchbar', $input->show() . " " . | ||||
html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-add', 'value' => $this->plugin->gettext('addattendee'))) | html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-add', 'value' => $this->plugin->gettext('addattendee'))) | ||||
// . " " . html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-schedule', 'value' => $this->plugin->gettext('scheduletime').'...')) | // . " " . html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-schedule', 'value' => $this->plugin->gettext('scheduletime').'...')) | ||||
) . | ) . | ||||
html::p('attendees-commentbox', html::label('edit-attendees-comment', $this->plugin->gettext('itipcomment')) . $textarea->show()) | html::p('attendees-commentbox', html::label('edit-attendees-comment', $this->plugin->gettext('itipcomment')) . $textarea->show()) | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
function edit_attendees_notify($attrib = array()) | function edit_attendees_notify($attrib = array()) | ||||
{ | { | ||||
$checkbox = new html_checkbox(array('name' => '_notify', 'id' => 'edit-attendees-donotify', 'value' => 1, 'class' => 'pretty-checkbox')); | $checkbox = new html_checkbox(array('name' => '_notify', 'id' => 'edit-attendees-donotify', 'value' => 1, 'class' => 'pretty-checkbox')); | ||||
return html::div($attrib, html::label(null, $checkbox->show(1) . ' ' . $this->plugin->gettext('sendnotifications'))); | return html::div($attrib, html::label(null, $checkbox->show(1) . ' ' . $this->plugin->gettext('sendnotifications'))); | ||||
} | } | ||||
/** | /** | ||||
* Form for uploading and importing tasks | * Form for uploading and importing tasks | ||||
*/ | */ | ||||
function tasks_import_form($attrib = array()) | function tasks_import_form($attrib = array()) | ||||
{ | { | ||||
if (!$attrib['id']) { | if (empty($attrib['id'])) { | ||||
$attrib['id'] = 'rcmImportForm'; | $attrib['id'] = 'rcmImportForm'; | ||||
} | } | ||||
// Get max filesize, enable upload progress bar | // Get max filesize, enable upload progress bar | ||||
$max_filesize = $this->rc->upload_init(); | $max_filesize = $this->rc->upload_init(); | ||||
$accept = '.ics, text/calendar, text/x-vcalendar, application/ics'; | $accept = '.ics, text/calendar, text/x-vcalendar, application/ics'; | ||||
if (class_exists('ZipArchive', false)) { | if (class_exists('ZipArchive', false)) { | ||||
$accept .= ', .zip, application/zip'; | $accept .= ', .zip, application/zip'; | ||||
} | } | ||||
$input = new html_inputfield(array( | $input = new html_inputfield(array( | ||||
'id' => 'importfile', | 'id' => 'importfile', | ||||
'type' => 'file', | 'type' => 'file', | ||||
'name' => '_data', | 'name' => '_data', | ||||
'size' => $attrib['uploadfieldsize'], | 'size' => !empty($attrib['uploadfieldsize']) ? $attrib['uploadfieldsize'] : null, | ||||
'accept' => $accept | 'accept' => $accept | ||||
)); | )); | ||||
$html = html::div('form-section form-group row', | $html = html::div('form-section form-group row', | ||||
html::label(array('class' => 'col-sm-4 col-form-label', 'for' => 'importfile'), rcube::Q($this->rc->gettext('importfromfile'))) | html::label(array('class' => 'col-sm-4 col-form-label', 'for' => 'importfile'), rcube::Q($this->rc->gettext('importfromfile'))) | ||||
. html::div('col-sm-8', $input->show() | . html::div('col-sm-8', $input->show() | ||||
. html::div('hint', $this->rc->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))) | . html::div('hint', $this->rc->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))) | ||||
); | ); | ||||
Show All 17 Lines | function tasks_import_form($attrib = array()) | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Form to select options for exporting tasks | * Form to select options for exporting tasks | ||||
*/ | */ | ||||
function tasks_export_form($attrib = array()) | function tasks_export_form($attrib = array()) | ||||
{ | { | ||||
if (!$attrib['id']) { | if (empty($attrib['id'])) { | ||||
$attrib['id'] = 'rcmTaskExportForm'; | $attrib['id'] = 'rcmTaskExportForm'; | ||||
} | } | ||||
$html .= html::div('form-section form-group row', | $html = html::div('form-section form-group row', | ||||
html::label(array('for' => 'task-export-list', 'class' => 'col-sm-4 col-form-label'), $this->plugin->gettext('list')) | html::label(array('for' => 'task-export-list', 'class' => 'col-sm-4 col-form-label'), $this->plugin->gettext('list')) | ||||
. html::div('col-sm-8', $this->tasklist_select(array( | . html::div('col-sm-8', $this->tasklist_select(array( | ||||
'name' => 'source', | 'name' => 'source', | ||||
'id' => 'task-export-list', | 'id' => 'task-export-list', | ||||
'extra' => array('' => '- ' . $this->plugin->gettext('currentview') . ' -'), | 'extra' => array('' => '- ' . $this->plugin->gettext('currentview') . ' -'), | ||||
))) | ))) | ||||
); | ); | ||||
Show All 34 Lines |