| | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2009, The Roundcube Dev Team | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | | | See the README file for a full license statement. | |
| | | | | |
| | | | PURPOSE: | |
| | | | Provide functionality of folders management | |
| | |
| | | | Author: Thomas Bruederli <roundcube@gmail.com> | |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-----------------------------------------------------------------------+ |
| | | |
| | | $Id$ |
| | | |
| | | */ |
| | | |
| | | // WARNING: folder names in UI are encoded with RCMAIL_CHARSET |
| | |
| | | |
| | | if ($result) { |
| | | // Handle subscription of protected folder (#1487656) |
| | | if ($CONFIG['protect_default_folders'] == true |
| | | && in_array($mbox, $CONFIG['default_folders']) |
| | | if ($RCMAIL->config->get('protect_default_folders') |
| | | && in_array($mbox, (array)$RCMAIL->config->get('default_folders')) |
| | | ) { |
| | | $OUTPUT->command('disable_subscription', $mbox); |
| | | } |
| | |
| | | } |
| | | else { |
| | | $deleted = $plugin['result']; |
| | | } |
| | | |
| | | // #1488692: update session |
| | | if ($deleted && $_SESSION['mbox'] === $mbox) { |
| | | $RCMAIL->session->remove('mbox'); |
| | | } |
| | | } |
| | | |
| | |
| | | // build table with all folders listed by server |
| | | function rcube_subscription_form($attrib) |
| | | { |
| | | global $RCMAIL, $CONFIG, $OUTPUT; |
| | | global $RCMAIL, $OUTPUT; |
| | | |
| | | list($form_start, $form_end) = get_form_tags($attrib, 'folders'); |
| | | unset($attrib['form']); |
| | |
| | | $a_js_folders = array(); |
| | | $seen = array(); |
| | | $list_folders = array(); |
| | | |
| | | $default_folders = (array) $RCMAIL->config->get('default_folders'); |
| | | $protect_default = $RCMAIL->config->get('protect_default_folders'); |
| | | |
| | | // pre-process folders list |
| | | foreach ($a_unsubscribed as $i => $folder) { |
| | |
| | | $idx = $i + 1; |
| | | $sub_key = array_search($folder['id'], $a_subscribed); |
| | | $subscribed = $sub_key !== false; |
| | | $protected = ($CONFIG['protect_default_folders'] == true && in_array($folder['id'], $CONFIG['default_folders'])); |
| | | $protected = $protect_default && in_array($folder['id'], $default_folders); |
| | | $noselect = false; |
| | | $classes = array($i%2 ? 'even' : 'odd'); |
| | | |
| | |
| | | |
| | | $disabled = (($protected && $subscribed) || $noselect); |
| | | |
| | | // check if the folder is a namespace prefix, then disable subscription option on it |
| | | if (!$disabled && $folder['virtual'] && $folder['level'] == 0 && !empty($namespace)) { |
| | | $fname = $folder['id'] . $delimiter; |
| | | foreach ($namespace as $ns) { |
| | | if (is_array($ns)) { |
| | | foreach ($ns as $item) { |
| | | if ($item[0] === $fname) { |
| | | $disabled = true; |
| | | break 2; |
| | | // Below we will disable subscription option for "virtual" folders |
| | | // according to namespaces, but only if they aren't already subscribed. |
| | | // User should be able to unsubscribe from the folder |
| | | // even if it doesn't exists or is not accessible (OTRS:1000059) |
| | | if (!$subscribed && !$disabled && !empty($namespace) && $folder['virtual']) { |
| | | // check if the folder is a namespace prefix, then disable subscription option on it |
| | | if (!$disabled && $folder['level'] == 0) { |
| | | $fname = $folder['id'] . $delimiter; |
| | | foreach ($namespace as $ns) { |
| | | if (is_array($ns)) { |
| | | foreach ($ns as $item) { |
| | | if ($item[0] === $fname) { |
| | | $disabled = true; |
| | | break 2; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // check if the folder is an other users virtual-root folder, then disable subscription option on it |
| | | if (!$disabled && $folder['virtual'] && $folder['level'] == 1 |
| | | && !empty($namespace) && !empty($namespace['other']) |
| | | ) { |
| | | $parts = explode($delimiter, $folder['id']); |
| | | $fname = $parts[0] . $delimiter; |
| | | foreach ($namespace['other'] as $item) { |
| | | if ($item[0] === $fname) { |
| | | $disabled = true; |
| | | break; |
| | | // check if the folder is an other users virtual-root folder, then disable subscription option on it |
| | | if (!$disabled && $folder['level'] == 1 && !empty($namespace['other'])) { |
| | | $parts = explode($delimiter, $folder['id']); |
| | | $fname = $parts[0] . $delimiter; |
| | | foreach ($namespace['other'] as $item) { |
| | | if ($item[0] === $fname) { |
| | | $disabled = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // check if the folder is shared, then disable subscription option on it |
| | | if (!$disabled && $folder['virtual'] && !empty($namespace)) { |
| | | $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']); |
| | | foreach ($tmp_ns as $item) { |
| | | if (strpos($folder['id'], $item[0]) === 0) { |
| | | $disabled = true; |
| | | break; |
| | | // check if the folder is shared, then disable subscription option on it (if not subscribed already) |
| | | if (!$disabled) { |
| | | $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']); |
| | | foreach ($tmp_ns as $item) { |
| | | if (strpos($folder['id'], $item[0]) === 0) { |
| | | $disabled = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | array('value' => $folder_utf8, 'disabled' => $disabled ? 'disabled' : ''))); |
| | | |
| | | $a_js_folders['rcmrow'.$idx] = array($folder_utf8, |
| | | Q($display_folder), $protected || $folder['virtual']); |
| | | $display_folder, $protected || $folder['virtual']); |
| | | } |
| | | |
| | | $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table)); |
| | | |
| | | $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']); |
| | | $OUTPUT->set_env('subscriptionrows', $a_js_folders); |
| | | $OUTPUT->set_env('defaultfolders', $CONFIG['default_folders']); |
| | | $OUTPUT->set_env('defaultfolders', $default_folders); |
| | | $OUTPUT->set_env('delimiter', $delimiter); |
| | | |
| | | return $form_start . $table->show($attrib) . $form_end; |
| | |
| | | if (!$attrib['id']) |
| | | $attrib['id'] = 'rcmfolderframe'; |
| | | |
| | | $attrib['name'] = $attrib['id']; |
| | | |
| | | $OUTPUT->set_env('contentframe', $attrib['name']); |
| | | $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif'); |
| | | |
| | | return html::iframe($attrib); |
| | | return $OUTPUT->frame($attrib, true); |
| | | } |
| | | |
| | | function rcmail_rename_folder($oldname, $newname) |
| | |
| | | foreach ($a_threaded as $key => $val) { |
| | | if ($key == $oldname) { |
| | | unset($a_threaded[$key]); |
| | | $a_threaded[$newname] = true; |
| | | $a_threaded[$newname] = true; |
| | | } |
| | | else if (preg_match($oldprefix, $key)) { |
| | | unset($a_threaded[$key]); |
| | | $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true; |
| | | $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true; |
| | | } |
| | | } |
| | | $RCMAIL->user->save_prefs(array('message_threading' => $a_threaded)); |
| | | |
| | | // #1488692: update session |
| | | if ($_SESSION['mbox'] === $oldname) { |
| | | $_SESSION['mbox'] = $newname; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | |
| | | |
| | | $OUTPUT->set_pagetitle(rcube_label('folders')); |
| | | $OUTPUT->include_script('list.js'); |
| | | $OUTPUT->set_env('quota', $STORAGE->get_capability('QUOTA')); |
| | | $OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix')); |
| | | if ($STORAGE->get_capability('QUOTA')) { |
| | | $OUTPUT->set_env('quota', true); |
| | | } |
| | | |
| | | // add some labels to client |
| | | $OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting', |