Commit 3cb70308 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add unread message count to inbox navigation


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 282c36e4
......@@ -1950,6 +1950,11 @@ function main_nav() {
}
function right_nav() {
global $USER;
safe_require('notification', 'internal');
$unread = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
$menu = array(
array(
'path' => 'settings',
......@@ -1961,6 +1966,7 @@ function right_nav() {
'path' => 'inbox',
'url' => 'account/activity',
'title' => get_string('inbox'),
'count' => $unread,
'weight' => 20,
),
array(
......
......@@ -55,7 +55,11 @@ class PluginNotificationInternal extends PluginNotification {
*/
public static function unread_count($userid) {
return count_records('notification_internal_activity', 'usr', $userid, 'read', 0);
static $unreadcount = array();
if (!isset($unreadcount[$userid])) {
$unreadcount[$userid] = count_records('notification_internal_activity', 'usr', $userid, 'read', 0);
}
return $unreadcount[$userid];
}
public static function get_event_subscriptions() {
......
......@@ -621,6 +621,9 @@ div.rbuttons .small-logo {
display: inline;
padding: 0 0.5em;
}
#right-nav li .navcount {
padding: 0 0 0 0.15em;
}
#right-nav li.selected a {
color: #333;
text-decoration: none;
......
......@@ -2,7 +2,7 @@
<div id="right-nav">
<ul>{strip}
{foreach from=$RIGHTNAV item=item}
<li{if $item.selected}{assign var=MAINNAVSELECTED value=$item} class="selected"{/if}><a href="{if $item.url=='account/' && get_config('httpswwwroot')}{$HTTPSWWWROOT}{else}{$WWWROOT}{/if}{$item.url|escape}">{$item.title|escape}</a></li>
<li{if $item.selected}{assign var=MAINNAVSELECTED value=$item} class="selected"{/if}><a href="{if $item.url=='account/' && get_config('httpswwwroot')}{$HTTPSWWWROOT}{else}{$WWWROOT}{/if}{$item.url|escape}">{$item.title|escape}{if $item.count && !$item.selected}<span class="navcount">({$item.count|escape})</span>{/if}</a></li>
{/foreach}
<li><a href="{$WWWROOT}?logout" accesskey="l">{str tag="logout"}</a></li>
{/strip}</ul>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment