plugins/kolab_folders
Thomas Brüderli
bruederli at kolabsys.com
Tue Sep 23 11:42:38 CEST 2014
plugins/kolab_folders/kolab_folders.js | 40 +++++----------------------
plugins/kolab_folders/kolab_folders.php | 30 ++++++++++++++++----
plugins/kolab_folders/localization/en_US.inc | 1
3 files changed, 33 insertions(+), 38 deletions(-)
New commits:
commit f0b205cb2e6ca3efb5c069afff88847259eb8ddc
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Tue Sep 23 11:37:45 2014 +0200
Add subtype 'confidential' to event and task folders; refactored subtype selector handling in JS (#3451)
diff --git a/plugins/kolab_folders/kolab_folders.js b/plugins/kolab_folders/kolab_folders.js
index ac50543..b9d9225 100644
--- a/plugins/kolab_folders/kolab_folders.js
+++ b/plugins/kolab_folders/kolab_folders.js
@@ -50,47 +50,23 @@ window.rcmail && rcmail.env.action == 'folders' && rcmail.addEventListener('init
});
window.rcmail && rcmail.env.action != 'folders' && $(document).ready(function() {
- // IE doesn't allow setting OPTION's display/visibility
- // We'll need to remove SELECT's options, see below
- if (bw.ie) {
- rcmail.env.subtype_html = $('#_subtype').html();
- }
-
// Add onchange handler for folder type SELECT, and call it on form init
$('#_ctype').change(function() {
var type = $(this).val(),
sub = $('#_subtype'),
- subtype = sub.val();
+ subtypes = rcmail.env.kolab_folder_subtypes[type] || {};
- // For IE we need to revert the whole SELECT to the original state
- if (bw.ie) {
- sub.html(rcmail.env.subtype_html).val(subtype);
- }
+ // reset subtype selector
+ sub.html('<option value=""></option>');
- // For non-mail folders we must hide mail-specific subtypes
- $('option', sub).each(function() {
- var opt = $(this), val = opt.val();
- if (val == '')
- return;
- // there's no mail.default
- if (val == 'default' && type != 'mail') {
- opt.show();
- return;
- };
-
- if (type == 'mail' && val != 'default')
- opt.show();
- else if (bw.ie)
- opt.remove();
- else
- opt.hide();
+ // append available subtypes for the given folder type
+ $.each(subtypes, function(val, label) {
+ $('<option>').attr('value', val).text(label).appendTo(sub);
});
// And re-set subtype
- if (type != 'mail' && subtype != '' && subtype != 'default') {
- sub.val('');
- }
- }).change();
+ sub.val(rcmail.env.kolab_folder_subtype);
+ });
});
function kolab_folders_filter(filter)
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 510388c..fbffa34 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -27,7 +27,17 @@ class kolab_folders extends rcube_plugin
public $task = '?(?!login).*';
public $types = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration', 'file', 'freebusy');
- public $mail_types = array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail');
+ public $subtypes = array(
+ 'mail' => array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail'),
+ 'event' => array('default', 'confidential'),
+ 'task' => array('default', 'confidential'),
+ 'journal' => array('default'),
+ 'note' => array('default'),
+ 'contact' => array('default'),
+ 'configuration' => array('default'),
+ 'file' => array('default'),
+ 'freebusy' => array('default'),
+ );
public $act_types = array('event', 'task');
private $rc;
@@ -248,6 +258,7 @@ class kolab_folders extends rcube_plugin
// build type SELECT fields
$type_select = new html_select(array('name' => '_ctype', 'id' => '_ctype'));
$sub_select = new html_select(array('name' => '_subtype', 'id' => '_subtype'));
+ $sub_select->add('', '');
foreach ($this->types as $type) {
$type_select->add($this->gettext('foldertype'.$type), $type);
@@ -257,10 +268,14 @@ class kolab_folders extends rcube_plugin
$type_select->add($ctype, $ctype);
}
- $sub_select->add('', '');
- $sub_select->add($this->gettext('default'), 'default');
- foreach ($this->mail_types as $type) {
- $sub_select->add($this->gettext($type), $type);
+ $sub_types = array();
+ foreach ($this->subtypes as $ftype => $subtypes) {
+ $sub_types[$ftype] = array_combine($subtypes, array_map(array($this, 'gettext'), $subtypes));
+
+ // fill options for the current folder type
+ if ($ftype == $ctype || $ftype == $new_ctype) {
+ $sub_select->add(array_values($sub_types[$ftype]), $subtypes);
+ }
}
$args['form']['props']['fieldsets']['settings']['content']['foldertype'] = array(
@@ -269,6 +284,9 @@ class kolab_folders extends rcube_plugin
. $sub_select->show(isset($new_subtype) ? $new_subtype : $subtype),
);
+ $this->rc->output->set_env('kolab_folder_subtypes', $sub_types);
+ $this->rc->output->set_env('kolab_folder_subtype', isset($new_subtype) ? $new_subtype : $subtype);
+
return $args;
}
@@ -312,7 +330,7 @@ class kolab_folders extends rcube_plugin
}
}
// Subtype sanity-checks
- else if ($subtype && ($ctype != 'mail' || !in_array($subtype, $this->mail_types))) {
+ else if ($subtype && (!($subtypes = $this->subtypes[$ctype]) || !in_array($subtype, $subtypes))) {
$subtype = '';
}
diff --git a/plugins/kolab_folders/localization/en_US.inc b/plugins/kolab_folders/localization/en_US.inc
index 0d8d86c..0910d9d 100644
--- a/plugins/kolab_folders/localization/en_US.inc
+++ b/plugins/kolab_folders/localization/en_US.inc
@@ -28,6 +28,7 @@ $labels['sentitems'] = 'Sent';
$labels['outbox'] = 'Outbox';
$labels['wastebasket'] = 'Trash';
$labels['junkemail'] = 'Junk';
+$labels['confidential'] = 'Confidential';
$messages['defaultfolderexists'] = 'There is already default folder of specified type';
More information about the commits
mailing list