| | |
| | | | program/steps/settings/folders.inc | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland | |
| | | | Copyright (C) 2005-2009, The Roundcube Dev Team | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | PURPOSE: | |
| | |
| | | |
| | | // Handle virtual (non-existing) folders |
| | | if (!$result && $IMAP->get_error_code() == -1 && |
| | | strpos($IMAP->get_error_str(), '[TRYCREATE]') |
| | | $IMAP->get_response_code() == rcube_imap::TRYCREATE |
| | | ) { |
| | | $result = $IMAP->create_mailbox($mbox, true); |
| | | if ($result) { |
| | |
| | | } |
| | | } |
| | | |
| | | if ($result) |
| | | if ($result) { |
| | | // Handle subscription of protected folder (#1487656) |
| | | if ($CONFIG['protect_default_folders'] == true |
| | | && in_array($mbox, $CONFIG['default_imap_folders']) |
| | | ) { |
| | | $OUTPUT->command('disable_subscription', $mbox); |
| | | } |
| | | |
| | | $OUTPUT->show_message('foldersubscribed', 'confirmation'); |
| | | } |
| | | else |
| | | $OUTPUT->show_message('errorsaving', 'error'); |
| | | rcmail_display_server_error('errorsaving'); |
| | | } |
| | | } |
| | | |
| | |
| | | if ($result) |
| | | $OUTPUT->show_message('folderunsubscribed', 'confirmation'); |
| | | else |
| | | $OUTPUT->show_message('errorsaving', 'error'); |
| | | rcmail_display_server_error('errorsaving'); |
| | | } |
| | | } |
| | | |
| | | // delete an existing mailbox |
| | | else if ($RCMAIL->action == 'delete-folder') |
| | | { |
| | | $a_mboxes = $IMAP->list_unsubscribed(); |
| | | $delimiter = $IMAP->get_hierarchy_delimiter(); |
| | | |
| | | $mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true); |
| | | $mbox = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP'); |
| | | |
| | | // get folder's children or all folders if the name contains special characters |
| | | $delimiter = $IMAP->get_hierarchy_delimiter(); |
| | | if ((strpos($mbox, '%') === false) && (strpos($mbox, '*') === false)) |
| | | $a_mboxes = $IMAP->list_unsubscribed('', $mbox.$delimiter.'*'); |
| | | else |
| | | $a_mboxes = $IMAP->list_unsubscribed(); |
| | | |
| | | if (strlen($mbox)) |
| | | $deleted = $IMAP->delete_mailbox(array($mbox)); |
| | | $deleted = $IMAP->delete_mailbox($mbox); |
| | | |
| | | if ($OUTPUT->ajax_call && $deleted) { |
| | | // Remove folder rows |
| | | // Remove folder and subfolders rows |
| | | $OUTPUT->command('remove_folder_row', $mbox_utf8); |
| | | foreach ($a_mboxes as $folder) { |
| | | if (preg_match('/^'. preg_quote($mbox.$delimiter, '/') .'/', $folder)) { |
| | |
| | | $OUTPUT->command('set_quota', rcmail_quota_content()); |
| | | } |
| | | else if (!$deleted) { |
| | | $OUTPUT->show_message('errorsaving', 'error'); |
| | | rcmail_display_server_error('errorsaving'); |
| | | } |
| | | } |
| | | |
| | |
| | | // subfolders |
| | | for ($x=sizeof($folderlist)-1; $x>=0; $x--) { |
| | | if (preg_match($regexp, $folderlist[$x])) { |
| | | $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); |
| | | $foldersplit = explode($delimiter, $folderlist[$x]); |
| | | $level = count($foldersplit) - 1; |
| | | $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); |
| | | $foldersplit = explode($delimiter, $IMAP->mod_mailbox($folderlist[$x])); |
| | | $level = count($foldersplit) - 1; |
| | | $display_rename = str_repeat(' ', $level) |
| | | . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); |
| | | |
| | | $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF7-IMAP') : false; |
| | | |
| | | |
| | | $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF7-IMAP'), |
| | | rcube_charset_convert($folderlist[$x], 'UTF7-IMAP'), $display_rename, $before); |
| | | } |
| | | } |
| | | |
| | | $index = array_search($name, $folderlist); |
| | | $name = $IMAP->mod_mailbox($name); |
| | | $foldersplit = explode($delimiter, $name); |
| | | $level = count($foldersplit) - 1; |
| | | $level = count($foldersplit) - 1; |
| | | $display_rename = str_repeat(' ', $level) . rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'); |
| | | $index = array_search($name, $folderlist); |
| | | $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; |
| | | $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF7-IMAP') : false; |
| | | |
| | | $OUTPUT->command('replace_folder_row', $oldname_utf8, |
| | | rcube_charset_convert($name, 'UTF7-IMAP'), $display_rename, $before); |
| | | $OUTPUT->command('replace_folder_row', $oldname_utf8, $name_utf8, $display_rename, $before); |
| | | } |
| | | else if (!$rename) { |
| | | $OUTPUT->show_message('errorsaving', 'error'); |
| | | rcmail_display_server_error('errorsaving'); |
| | | } |
| | | } |
| | | |
| | |
| | | $OUTPUT->command('show_folder', $mbox_utf8, null, true); |
| | | } |
| | | else { |
| | | $OUTPUT->show_message('errorsaving', 'error'); |
| | | rcmail_display_server_error('errorsaving'); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if ($size !== false) { |
| | | $OUTPUT->command('folder_size_update', show_bytes($size)); |
| | | } |
| | | else { |
| | | rcmail_display_server_error(); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // pre-process folders list |
| | | foreach ($a_unsubscribed as $i => $folder) { |
| | | $foldersplit = explode($delimiter, $folder); |
| | | $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); |
| | | $folder_id = $folder; |
| | | $folder = $IMAP->mod_mailbox($folder); |
| | | $foldersplit = explode($delimiter, $folder); |
| | | $name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); |
| | | $parent_folder = join($delimiter, $foldersplit); |
| | | $level = count($foldersplit); |
| | | $level = count($foldersplit); |
| | | |
| | | // add any necessary "virtual" parent folders |
| | | if ($parent_folder && !$seen[$parent_folder]) { |
| | | if ($parent_folder && !isset($seen[$parent_folder])) { |
| | | for ($i=1; $i<=$level; $i++) { |
| | | $ancestor_folder = join($delimiter, array_slice($foldersplit, 0, $i)); |
| | | if ($ancestor_folder && !$seen[$ancestor_folder]++) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // Handle properly INBOX.INBOX situation |
| | | if (isset($seen[$folder])) { |
| | | continue; |
| | | } |
| | | |
| | | $seen[$folder]++; |
| | | |
| | | $list_folders[] = array( |
| | | 'id' => $folder, |
| | | 'id' => $folder_id, |
| | | 'name' => $name, |
| | | 'level' => $level, |
| | | ); |
| | |
| | | $noselect = in_array('\\Noselect', $opts); |
| | | } |
| | | |
| | | $disabled = (($protected && $subscribed) || $noselect); |
| | | |
| | | $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes))); |
| | | |
| | | $table->add('name', $display_folder); |
| | | $table->add('subscribed', $checkbox_subscribe->show(($subscribed ? $folder_utf8 : ''), |
| | | array('value' => $folder_utf8, 'disabled' => ($protected || $noselect) ? 'disabled' : ''))); |
| | | array('value' => $folder_utf8, 'disabled' => $disabled ? 'disabled' : ''))); |
| | | |
| | | $a_js_folders['rcmrow'.$idx] = array($folder_utf8, Q($display_folder), $protected || $folder['virtual']); |
| | | $a_js_folders['rcmrow'.$idx] = array($folder_utf8, |
| | | Q($display_folder), $protected || $folder['virtual']); |
| | | } |
| | | |
| | | $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table)); |