$unseen_type = 1; } } if (empty($unseen_notify)) { if (!empty($default_unseen_notify)) { $unseen_notify = $default_unseen_notify; } else { $unseen_notify = 0; } } /** * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond */ $boxes = sqimap_mailbox_tree($imapConnection, $mailboxes, $show_only_subscribed_folders); $mailbox_structure = getBoxStructure($boxes); $oTemplate->assign('clock', $clock); $oTemplate->assign('mailboxes', $mailbox_structure); /* * Build an array to pass user prefs to the template in order to avoid using * globals, which are dirty, filthy things in templates. :) */ $settings = array(); #$settings['imapConnection'] = $imapConnection; $settings['templateID'] = $sTemplateID; $settings['unreadNotificationEnabled'] = $unseen_notify != 1; $settings['unreadNotificationAllFolders'] = $unseen_notify == 3; $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2; $settings['unreadNotificationCummulative'] = $unseen_cum == 1; $settings['useSpecialFolderColor'] = $use_special_folder_color; $settings['messageRecyclingEnabled'] = $move_to_trash;
/** * Recursively iterates a mailboxes object to build a data structure that is * easy for template authors to work with. FIXME: well.... why not document that data structure here? * * @param object $boxes Object of the class mailboxes * @author Steve Brown * @since 1.5.2 */ function getBoxStructure($boxes) { global $data_dir, $username, $icon_theme_path; // Stop condition if (empty($boxes)) { return array(); } $mailbox = $boxes->mailboxname_full; $mailboxURL = urlencode($mailbox); $box = array(); $box['MailboxFullName'] = $mailbox; $box['MailboxName'] = $boxes->mailboxname_sub; $box['MessageCount'] = !empty($boxes->total) ? $boxes->total : 0; $box['UnreadCount'] = !empty($boxes->unseen) ? $boxes->unseen : 0; // Needed in case user enables cummulative message counts $box['CummulativeMessageCount'] = getMessageCount($boxes, 'total'); $box['CummulativeUnreadCount'] = getMessageCount($boxes, 'unseen'); $box['ViewLink'] = array('Target' => 'right', 'URL' => 'right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=' . $mailboxURL); $box['IsRecent'] = isset($boxes->recent) && $boxes->recent; $box['IsSpecial'] = isset($boxes->is_special) && $boxes->is_special; $box['IsRoot'] = isset($boxes->is_root) && $boxes->is_root; $box['IsNoSelect'] = isset($boxes->is_noselect) && $boxes->is_noselect; $box['IsInbox'] = isset($boxes->is_inbox) && $boxes->is_inbox; $box['IsSent'] = isset($boxes->is_sent) && $boxes->is_sent; $box['IsTrash'] = isset($boxes->is_trash) && $boxes->is_trash; $box['IsDraft'] = isset($boxes->is_draft) && $boxes->is_draft; $box['IsNoInferiors'] = isset($boxes->is_noinferiors) && $boxes->is_noinferiors; $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); $collapse = $collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse; $collapse = (int) $collapse == SM_BOX_COLLAPSED; $box['IsCollapsed'] = $collapse; /* * Check for an image needed here. If the file exists in $icon_theme_path * assume the template provides all icons. If not, we will use the * SQM default images. If icons have been disabled, $icon_theme_path * will be NULL. */ $text_icon = $box['IsCollapsed'] ? '+' : '-'; $icon_file = $box['IsCollapsed'] ? 'plus.png' : 'minus.png'; $icon_alt = $box['IsCollapsed'] ? 'Expand Box' : 'Collapse Box'; $icon = getIcon($icon_theme_path, $icon_file, $text_icon, $icon_alt); $box['CollapseLink'] = array('Target' => 'left', 'URL' => 'left_main.php?' . ($box['IsCollapsed'] ? 'unfold' : 'fold') . '=' . $mailboxURL, 'Icon' => $icon . ' '); $box['ChildBoxes'] = array(); for ($i = 0; $i < count($boxes->mbxs); $i++) { $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs[$i]); } // if plugins want to add some text or link after the folder name in // the folder list, they should add to the "ExtraOutput" array element // in $box (remember, it's passed through the hook by reference) -- making // sure to play nice with other plugins by *concatenating* to "ExtraOutput" // and NOT by overwriting it // // known users of this hook: // empty_folders // do_hook('left_main_after_each_folder', $box); return $box; }