Example #1
0
function menuBarNotification()
{
    global $user;
    dbGetNotificationsForUser($user->uid);
    // displaying the number of unread notifications that the user has inside of a box which is displayed in the CROMA menu bar
    $markup = '<a href="?q=viewAllNotifications" style="color:#ffffff"><div class="tooltip" style="vertical-align:center; color:#ffffff; background-color:#8e2115; padding:0px 5px 0px 5px; margin: 4px 0px 0px 0px; border-style:solid; border-color:#ffffff; border-width:2px 2px 2px 2px">' . ($num = dbGetNumNotificationsForUser($user->uid));
    // displaying what the "number in the box" means via a span class --> this shows up when you hover over the "box"
    $markup .= '<span class="tooltiptext">' . $num;
    $markup .= $num == 1 ? ' notification' : ' notifications';
    $markup .= '</span></div></a>';
    return array('#markup' => $markup);
}
Example #2
0
function viewAllNotifications()
{
    global $user;
    $UID = $user->uid;
    // create page header, table, and dismiss all notifications button
    $timezone = $user->timezone;
    $notifications = dbGetNotificationsForUser($user->uid);
    $markup = '<table><tr><td style="text-align:left"><h1><b>View All Notifications</b></h1></td>';
    $markup .= '<td style="text-align:right"><a href="?q=dismissAllNotifications"><button>';
    $markup .= 'Dismiss All</button></a></td></tr></table>';
    // if user has no notifications
    if (empty($notifications)) {
        $markup .= '<table class="infoTable"><th></th><tr><td style="text-align:center" colspan="10"><em>No New Notifications!</em></td></tr></table>';
        $_SESSION['notificationNIDsShown'] = array();
    } else {
        // if user has notifications
        $markup .= '<table class="infoTable"><tr><th>Associated Picture</th><th>Notification Content</th><th></th></tr>';
        foreach ($notifications as $notification) {
            // used to prevent lack of page refresh issues
            $_SESSION['notificationNIDsShown'][] = $notification['NID'];
            $rawDate = $notification['dateTargeted'];
            $rawDate = dbDateSQL2PHP($rawDate);
            $date = date(TIME_FORMAT, $rawDate);
            $markup .= "<tr><td>";
            // generates picture for notification
            if (!empty($notification['FID'])) {
                $FID = $notification['FID'];
                $file = file_load($FID);
                $uri = $file->uri;
                $variables = array('style_name' => 'all_notifications', 'path' => $uri, 'width' => '150', 'height' => '150');
                $image = theme_image_style($variables);
                $markup .= $image;
            }
            $markup .= '</td><td style="width:50% . "text-align:center">';
            $markup .= '<br><b>' . $date . "</b><br>";
            $markup .= '<i>' . $notification['message'] . "</i><br><br></td>";
            $markup .= '<td>';
            // buttons for viewing or dismissing a notification
            if ($notification['bttnLink'] != null && $notification['bttnTitle'] != null) {
                $markup .= "<a href=\"{$notification['bttnLink']}\">";
                $markup .= '<button type="button">' . $notification['bttnTitle'] . '</button>';
            }
            $markup .= '<a href="?q=dismissNotification/' . $notification['NID'] . '&allnote">';
            $markup .= '<button type="button"><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a>' . '&nbsp' . '&nbsp';
            $markup .= '</td></tr>';
        }
        $markup .= '</td></tr></table>';
    }
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}