-echo html_tag( 'tr',
- html_tag( 'td', ' ', 'left', $color[4] )
- ) ."</table>\n";
-
-
-/** UNSUBSCRIBE FOLDERS **/
-echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
- html_tag( 'tr',
- html_tag( 'td', '<b>' . _("Unsubscribe") . '/' . _("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
- ) .
- html_tag( 'tr' ) .
- html_tag( 'td', '', 'center', $color[0], 'width="50%"' );
-
-if ($count_special_folders < count($boxes)) {
- echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"
- . "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
- for ($i = 0; $i < count($boxes); $i++) {
- $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 = $boxes[$i]["unformatted-dm"];
- $box2 = str_replace(' ', ' ',
- imap_utf7_decode_local($boxes[$i]["unformatted-disp"]));
- echo " <OPTION VALUE=\"$box\">$box2\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) {
- $box[$q] = $boxes_all[$i]['unformatted-dm'];
- $box2[$q] = imap_utf7_decode_local($boxes_all[$i]['unformatted-disp']);
- $q++;
+ /** SUBSCRIBE TO FOLDERS **/
+ $boxes_all = sqimap_mailbox_list_all ($imapConnection);
+
+ // here we filter out all boxes we're already subscribed to,
+ // so we keep only the unsubscribed ones.
+ foreach ($boxes_all as $box_a) {
+
+ $use_folder = true;
+ foreach ( $boxes as $box ) {
+ if ($box_a['unformatted'] == $box['unformatted'] ||
+ $box_a['unformatted-dm'] == $folder_prefix ) {
+ $use_folder = false;
+ }
+ }
+
+ if ($use_folder) {
+ $box_enc = sm_encode_html_special_chars($box_a['unformatted-dm']);
+ $box_disp = sm_encode_html_special_chars(imap_utf7_decode_local($box_a['unformatted-disp']));
+ $subbox_option_list[] = array( 'Value' => $box_enc, 'Display' => $box_disp);
+ }