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

Mark notifications as read when you click on the subject

parent d1e59d9a
......@@ -32,6 +32,7 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
json_headers();
$markasread = param_integer('markasread', 0);
$quiet = param_integer('quiet', 0);
if ($markasread) {
$count = 0;
......@@ -49,6 +50,9 @@ if ($markasread) {
json_reply('local', get_string('failedtomarkasread', 'activity') . ': ' . $e->getMessage());
}
db_commit();
if ($quiet) {
json_reply(false, null);
}
json_reply(false, array('message' => get_string('markedasread', 'activity'), 'count' => $count));
}
......
......@@ -48,6 +48,9 @@ if ($USER->get('admin')) {
$morestr = get_string('more...');
$star = json_encode(theme_get_url('images/star.png'));
$unread = json_encode(get_string('unread', 'activity'));
$javascript = <<<JAVASCRIPT
var activitylist = new TableRenderer(
'activitylist',
......@@ -127,6 +130,16 @@ function markread(form) {
function showHideMessage(id) {
if (getStyle('message-' + id, 'display') == 'none') {
var unread = getFirstElementByTagAndClassName('input', 'tocheck',
$('message-' + id).parentNode.parentNode);
if (unread) {
var pd = {'markasread':1, 'quiet':1};
pd['unread-'+id] = 1;
sendjsonrequest('index.json.php', pd, 'GET', function(data) {
return !!data.error;
});
swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$unread}}));
}
showElement('message-' + id);
}
else {
......
Supports Markdown
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