From ed1d212ae2daea5e4bd043417610177093e99f19 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sat, 16 Jan 2016 03:03:51 -0500 Subject: [PATCH] Improved SVG cleanup code --- program/steps/settings/folders.inc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 51 insertions(+), 7 deletions(-) diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index 19c4457..034b807 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -1,6 +1,6 @@ <?php -/* +/** +-----------------------------------------------------------------------+ | program/steps/settings/folders.inc | | | @@ -181,8 +181,9 @@ // register UI objects $OUTPUT->add_handlers(array( - 'foldersubscription' => 'rcube_subscription_form', + 'foldersubscription' => 'rcmail_subscription_form', 'folderframe' => 'rcmail_folder_frame', + 'folderfilter' => 'rcmail_folder_filter', 'quotadisplay' => array($RCMAIL, 'quota_display'), )); @@ -190,7 +191,7 @@ // build table with all folders listed by server -function rcube_subscription_form($attrib) +function rcmail_subscription_form($attrib) { global $RCMAIL, $OUTPUT; @@ -264,11 +265,10 @@ $js_folders = array(); $folders = array(); - $collapsed = $RCMAIL->config->get('collapsed_folders'); + $collapsed = (string) $RCMAIL->config->get('collapsed_folders'); // create list of available folders foreach ($list_folders as $i => $folder) { - $idx = $i + 1; $sub_key = array_search($folder['id'], $a_subscribed); $subscribed = $sub_key !== false; $protected = $protect_default && isset($special_folders[$folder['id']]); @@ -285,7 +285,7 @@ // Check \Noselect flag (of existing folder) if (!$protected && in_array($folder['id'], $a_unsubscribed)) { $attrs = $STORAGE->folder_attributes($folder['id']); - $noselect = in_array('\\Noselect', $attrs); + $noselect = in_array_nocase('\\Noselect', $attrs); } $disabled = (($protected && $subscribed) || $noselect); @@ -373,7 +373,7 @@ array_unshift($plugin['list'], $root); - for ($i = 0, $length = count($plugin['list'])-1; $i<$length; $i++) { + for ($i = 0, $length = count($plugin['list']); $i<$length; $i++) { $folders[] = rcmail_folder_tree_element($plugin['list'], $i, $js_folders); } @@ -424,6 +424,50 @@ return $OUTPUT->frame($attrib, true); } +function rcmail_folder_filter($attrib) +{ + global $RCMAIL; + + $storage = $RCMAIL->get_storage(); + $namespace = $storage->get_namespace(); + + if (empty($namespace['personal']) && empty($namespace['shared']) && empty($namespace['other'])) { + return ''; + } + + if (!$attrib['id']) { + $attrib['id'] = 'rcmfolderfilter'; + } + + $attrib['onchange'] = rcmail_output::JS_OBJECT_NAME . '.folder_filter(this.value)'; + + $roots = array(); + $select = new html_select($attrib); + $select->add($RCMAIL->gettext('all'), '---'); + + foreach (array_keys($namespace) as $type) { + foreach ((array)$namespace[$type] as $ns) { + $root = rtrim($ns[0], $ns[1]); + $label = $RCMAIL->gettext('namespace.' . $type); + + if (count($namespace[$type]) > 1) { + $label .= ' (' . rcube_charset::convert($root, 'UTF7-IMAP', RCUBE_CHARSET) . ')'; + } + + $select->add($label, $root); + + if (strlen($root)) { + $roots[] = $root; + } + } + } + + $RCMAIL->output->add_gui_object('foldersfilter', $attrib['id']); + $RCMAIL->output->set_env('ns_roots', $roots); + + return $select->show(); +} + function rcmail_rename_folder($oldname, $newname) { global $RCMAIL; -- Gitblit v1.9.1