Commit fe517036 authored by Penny Leach's avatar Penny Leach
Browse files

added the You are logged in as & unread messages notification stuff

to header
parent 41fcb358
......@@ -105,6 +105,17 @@ function markread(form) {
if (data.count > 0) {
$('messagediv').innerHTML = '$readsave';
activitylist.doupdate();
var oldcount = parseInt($('headerunreadmessagecount').innerHTML);
var newcount = (oldcount - data.count);
var messagenode = $('headerunreadmessages');
if (newcount == 1) { // jump through hoops to change between plural and singular
messagenode.innerHTML = get_string('unreadmessage');
}
else {
messagenode.innerHTML = get_string('unreadmessages');
}
$('headerunreadmessagecount').innerHTML = newcount;
}
}
if (data.error) {
......
......@@ -226,6 +226,9 @@ $string['myaddressbook'] = 'My Addressbook';
$string['mycommunities'] = 'My Communities';
$string['myownedcommunities'] = 'My Owned Communities';
$string['mygroups'] = 'My Groups';
$string['youareloggedinas'] = 'You are logged in as %s';
$string['unreadmessages'] = 'unread messages';
$string['unreadmessage'] = 'unread message';
// mycontacts
......
......@@ -185,6 +185,7 @@ EOF;
$smarty->assign('LOGGEDIN', $USER->is_logged_in());
if ($USER->is_logged_in()) {
$smarty->assign('MAINNAV', main_nav());
$smarty->assign('LOGGEDINSTR', get_loggedin_string());
}
$smarty->assign_by_ref('USER', $USER);
......@@ -210,6 +211,8 @@ function jsstrings() {
'requiredfieldempty',
'unknownerror',
'loading',
'unreadmessages',
'unreadmessage',
),
),
'tablerenderer' => array(
......@@ -1142,5 +1145,24 @@ function searchform() {
));
}
function get_loggedin_string() {
global $USER;
safe_require('notification', 'internal');
$count = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
if ($count == 1) {
$key = 'unreadmessage';
}
else {
$key = 'unreadmessages';
}
// these spans are here so that on the ajax page that marks messages as read, the contents can be updated.
$str = get_string('youareloggedinas', 'mahara', display_name($USER)) .
' (<a href="' . get_config('wwwroot') . 'account/activity/">' .
'<span id="headerunreadmessagecount">' . $count . '</span> ' .
'<span id="headerunreadmessages">' . get_string($key) . '</span></a>)';
return $str;
}
?>
......@@ -48,6 +48,15 @@ class PluginNotificationInternal extends PluginNotification {
insert_record('notification_internal_activity', $toinsert);
}
/**
* this method is only implemented in internal & is used for the header
*/
public static function unread_count($userid) {
return count_records('notification_internal_activity', 'usr', $userid, 'read', 0);
}
}
?>
......@@ -54,6 +54,7 @@
{/if}
<div id="logo"><a href="{$WWWROOT}"><img src="{image_path imagelocation='images/logo.gif'}" border="0" alt=""></a></div>
<h1 class="hiddenStructure"><a href="{$WWWROOT}">{$heading|default:"Mahara"|escape}</a></h1>
<div id="loggedinstring">{$LOGGEDINSTR}</div>
</div>
</div>
<div id="mainwrapper">
......
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