/** * 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; }
function displayNotification() { include_once "includes/mail.include.php"; processNotifications(); $id = isset($_SESSION['sid']) ? $_SESSION['sid'] : $_SESSION['mid']; $scientist = isset($_SESSION['sid']); // find the number of unread notifications $notifications = getNotificationCount($id, $scientist); // find the number of unread messages; $unreadMessages = getMessageCount($id, $scientist)['unread']; if ($notifications > 0 || $unreadMessages > 0) { echo "<div id='warnmessage'>\n"; if ($notifications > 0) { echo "" . _("Attention: You have") . " {$notifications} " . _("new notifications") . ". <a href='notifications.php'> " . _("View") . "</a>.<br>"; } if ($unreadMessages > 0) { echo "" . _("Attention: You have") . " {$unreadMessages} " . _("new messages") . ". <a href='inbox.php'> " . _("View") . "</a>.<br>"; } echo "</div>\n"; echo "<br />\n"; } $query = "UPDATE Notifications SET status = 1 WHERE status = 0 AND mid = " . $_SESSION['mid'] . ";"; $result = mysql_query($query); }
&topic=<?php echo $row['id']; ?> "><?php echo $row['titre']; ?> </a></td> <td> <?php $firstPost = getFirstPost($conn, $row['forum'], $row['id']); echo var_dump($firstPost); //echo '<a href="message.php?id=' . $firstPost['id'] . '&forum=' . $row['forum'] . '">' . $firstPost['auteur'] . '</a>'; ?> </td> <td><?php echo getMessageCount($conn, $row['forum'], $row['id']); ?> </td> <td> <?php $lastPost = getLastPost($conn, $row['forum'], $row['id']); echo var_dump($lastPost); //echo '<a href="message.php?id=' . $lastPost['id'] . '&forum=' . $row['forum'] . '">' . $lastPost['tms'] . '</a>'; ?> </td> </tr> <?php } ?> </table>
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'unread'; $scientist = isset($_SESSION['sid']); header('Content-type: application/json'); if (isset($_REQUEST['markRead'])) { if (markMessageRead(mysql_real_escape_string($_REQUEST['markRead']), $id)) { $response = '{ "success": "Message marked as read." }'; } else { $response = '{ "error": "Message status change failed." }'; } } else { if (isset($_REQUEST['count'])) { $count = getMessageCount($id, $scientist); $response = json_encode(array('count' => $count)); } else { if ($scientist) { $messages = getScientistMessages($id); } else { $messages = getMotherMessages($id); } $count = getMessageCount($id, $scientist); $response = json_encode(array('messages' => $messages, 'count' => $count)); } } if ($jsonp) { echo "{$callback}("; } echo $response; if ($jsonp) { echo ")"; } }