42a29eee9794357ec78e6482dde3b67638babe72
6 * Provides some functions for use in left_main.php and templates. Do not echo
7 * output from these functions!
9 * @copyright © 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
13 * @subpackage templates
17 * Recursively iterates a mailboxes object to get the cummulative count of
18 * messages for all folderes below the current mailbox.
20 * @param object $boxes Object of the class mailboxes
21 * @param string $type Whether to fetch unseen only or all messages
25 function getMessageCount ($boxes, $type='total') {
29 // The Trash folder isn't counted...
30 if ($boxes->mailboxname_full
== $trash_folder)
34 if (strtolower($type) == 'unseen')
36 else $field = 'total';
39 $count +
= !empty($boxes->{$field}) ?
$boxes->{$field} : 0;
40 for ($j = 0; $j <count($boxes->mbxs
); $j++
) {
41 $count +
= getMessageCount($boxes->mbxs
[$j], $type);
48 * Recursively iterates a mailboxes object to build a data structure that is
49 * easy for template authors to work with.
51 * @param object $boxes Object of the class mailboxes
55 function getBoxStructure ($boxes) {
56 global $data_dir, $username, $icon_theme_path;
63 $mailbox = $boxes->mailboxname_full
;
64 $mailboxURL = urlencode($mailbox);
67 $box['MailboxFullName'] = $mailbox;
68 $box['MailboxName'] = $boxes->mailboxname_sub
;
69 $box['MessageCount'] = !empty($boxes->total
) ?
$boxes->total
: 0;
70 $box['UnreadCount'] = !empty($boxes->unseen
) ?
$boxes->unseen
: 0;
72 // Needed in case user enables cummulative message counts
73 $box['CummulativeMessageCount'] = getMessageCount($boxes, 'total');
74 $box['CummulativeUnreadCount'] = getMessageCount($boxes, 'unseen');
76 $box['ViewLink'] = array( 'Target' => 'right',
77 'URL' => 'right_main.php?PG_SHOWALL=0&startMessage=1&mailbox='.$mailboxURL
80 $box['IsRecent'] = isset($boxes->recent
) && $boxes->recent
;
81 $box['IsSpecial'] = isset($boxes->is_special
) && $boxes->is_special
;
82 $box['IsRoot'] = isset($boxes->is_root
) && $boxes->is_root
;
83 $box['IsNoSelect'] = isset($boxes->is_noselect
) && $boxes->is_noselect
;
85 $box['IsInbox'] = isset($boxes->is_inbox
) && $boxes->is_inbox
;
86 $box['IsSent'] = isset($boxes->is_sent
) && $boxes->is_sent
;
87 $box['IsTrash'] = isset($boxes->is_trash
) && $boxes->is_trash
;
88 $box['IsDraft'] = isset($boxes->is_draft
) && $boxes->is_draft
;
89 $box['IsNoInferiors'] = isset($boxes->is_noinferiors
) && $boxes->is_noinferiors
;
91 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
92 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
93 $collapse = (int)$collapse == SM_BOX_COLLAPSED
;
94 $box['IsCollapsed'] = $collapse;
97 * Check for an image needed here. If the file exists in $icon_theme_path
98 * assume the template provides all icons. If not, we will use the
99 * SQM default images. If icons have been disabled, $icon_theme_path
103 $text_icon = $box['IsCollapsed'] ?
'+' : '-';
104 $icon_file = $box['IsCollapsed'] ?
'plus.png' : 'minus.png';
105 $icon_alt = $box['IsCollapsed'] ?
'Expand Box' : 'Collapse Box';
106 $icon = getIcon($icon_theme_path, $icon_file, $text_icon, $icon_alt);
108 $box['CollapseLink'] = array ( 'Target' => 'left',
109 'URL' => 'left_main.php?'.($box['IsCollapsed'] ?
'unfold' : 'fold') .'='.$mailboxURL,
110 'Icon' => $icon .' '
113 $box['ChildBoxes'] = array();
114 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
115 $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs
[$i]);