$use_folder = true; if (strtolower($boxes[$i]["unformatted"]) != "inbox" && $boxes[$i]["unformatted"] != $trash_folder && $boxes[$i]["unformatted"] != $sent_folder && $boxes[$i]["unformatted"] != $draft_folder) { $box = htmlspecialchars($boxes[$i]["unformatted-dm"]); $box2 = str_replace(' ', ' ', htmlspecialchars(imap_utf7_decode_local($boxes[$i]["unformatted-disp"]))); echo " <option value=\"{$box}\">{$box2}</option>\n"; } } echo "</select></tt><br /><br />\n" . '<input type="submit" value="' . _("Unsubscribe") . "\" />\n" . "</form></td>\n"; } else { echo _("No folders were found to unsubscribe from!") . '</td>'; } $boxes_sub = $boxes; /** SUBSCRIBE TO FOLDERS **/ echo html_tag('td', '', 'center', $color[0], 'width="50%"'); if (!$no_list_for_subscribe) { $boxes_all = sqimap_mailbox_list_all($imapConnection); $box = ''; $box2 = ''; for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { $use_folder = true; for ($p = 0; $p < count($boxes); $p++) { if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) { $use_folder = false; continue; } else { if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) { $use_folder = false; } } } if ($use_folder == true) {
/** * Renames a mailbox. */ function sqimap_mailbox_rename($imap_stream, $old_name, $new_name) { if ($old_name != $new_name) { global $delimiter, $imap_server_type, $data_dir, $username; if (substr($old_name, -1) == $delimiter) { $old_name = substr($old_name, 0, strlen($old_name) - 1); $new_name = substr($new_name, 0, strlen($new_name) - 1); $postfix = $delimiter; } else { $postfix = ''; } $boxesall = sqimap_mailbox_list_all($imap_stream); $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name . $postfix); $oldpref_thread = getPref($data_dir, $username, 'thread_' . $old_name . $postfix); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); removePref($data_dir, $username, 'thread_' . $old_name . $postfix); removePref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); sqimap_subscribe($imap_stream, $new_name . $postfix); setPref($data_dir, $username, 'thread_' . $new_name . $postfix, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_name . $postfix, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($old_name, 'rename', $new_name)); $l = strlen($old_name) + 1; $p = 'unformatted'; foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); /* With Cyrus IMAPd >= 2.0 rename is recursive, so don't check for errors here */ if ($imap_server_type == 'cyrus') { $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, false, $response, $message); } $was_subscribed = sqimap_mailbox_is_subscribed($imap_stream, $box[$p]); if ($was_subscribed) { sqimap_unsubscribe($imap_stream, $box[$p]); } $oldpref_thread = getPref($data_dir, $username, 'thread_' . $box[$p]); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $box[$p]); removePref($data_dir, $username, 'thread_' . $box[$p]); removePref($data_dir, $username, 'collapse_folder_' . $box[$p]); if ($was_subscribed) { sqimap_subscribe($imap_stream, $new_sub); } setPref($data_dir, $username, 'thread_' . $new_sub, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_sub, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } } }