Commit 27a3550b authored by Penny Leach's avatar Penny Leach
Browse files

tweaks to recent activity

parent 5f5dc05f
...@@ -33,12 +33,13 @@ json_headers(); ...@@ -33,12 +33,13 @@ json_headers();
$markasread = param_integer('markasread', 0); $markasread = param_integer('markasread', 0);
if ($markasread) { if ($markasread) {
$count = 0;
db_begin(); db_begin();
try { try {
foreach ($_GET as $k => $v) { foreach ($_GET as $k => $v) {
if (preg_match('/^unread\-(\d+)$/',$k,$m)) { if (preg_match('/^unread\-(\d+)$/',$k,$m)) {
set_field('notification_internal_activity', 'read', 1, 'id', $m[1]); set_field('notification_internal_activity', 'read', 1, 'id', $m[1]);
$count++;
} }
} }
} }
...@@ -48,7 +49,7 @@ if ($markasread) { ...@@ -48,7 +49,7 @@ if ($markasread) {
echo json_encode($data); echo json_encode($data);
} }
db_commit(); db_commit();
$data = array('success' => 1); $data = array('success' => 1, 'count' => $count);
echo json_encode($data); echo json_encode($data);
exit; exit;
} }
...@@ -80,16 +81,17 @@ $data = array(); ...@@ -80,16 +81,17 @@ $data = array();
$star = theme_get_image_path('star.png'); $star = theme_get_image_path('star.png');
$unread = get_string('unread', 'activity'); $unread = get_string('unread', 'activity');
foreach ($records as $r) { foreach ($records as &$r) {
$r['date'] = format_date(strtotime($r['ctime'])); $r['date'] = format_date(strtotime($r['ctime']));
$r['type'] = get_string('type' . $r['type'], 'activity');
} }
$activity = array( $activity = array(
'count' => $count, 'count' => $count,
'offset' => $offset, 'offset' => $offset,
'limit' => $limit, 'limit' => $limit,
'data' => $records, 'data' => $records,
'star' => $star, 'star' => $star,
'unread' => $unread, 'unread' => $unread,
); );
......
...@@ -46,9 +46,10 @@ var activitylist = new TableRenderer( ...@@ -46,9 +46,10 @@ var activitylist = new TableRenderer(
} }
return TD(null,r.message); return TD(null,r.message);
}, },
'type',
'ctime', 'ctime',
function (r, d) { function (r, d) {
if (r.read == 0) { if (r.read == 1) {
return TD(null,IMG({'src' : d.star, 'alt' : d.unread})); return TD(null,IMG({'src' : d.star, 'alt' : d.unread}));
} }
return TD(null); return TD(null);
...@@ -94,8 +95,10 @@ function markread(form) { ...@@ -94,8 +95,10 @@ function markread(form) {
var d = loadJSONDoc('index.json.php', pd); var d = loadJSONDoc('index.json.php', pd);
d.addCallbacks(function (data) { d.addCallbacks(function (data) {
if (data.success) { if (data.success) {
$('messagediv').innerHTML = '$readsave'; if (data.count > 0) {
activitylist.doupdate(); $('messagediv').innerHTML = '$readsave';
activitylist.doupdate();
}
} }
if (data.error) { if (data.error) {
$('messagediv').innerHTML = '$readsavefail(' + data.error + ')'; $('messagediv').innerHTML = '$readsavefail(' + data.error + ')';
......
...@@ -36,7 +36,7 @@ $string['typeobjectionable'] = 'Objectionable content'; ...@@ -36,7 +36,7 @@ $string['typeobjectionable'] = 'Objectionable content';
$string['typevirusrepeat'] = 'Virus flat repeat'; $string['typevirusrepeat'] = 'Virus flat repeat';
$string['typevirusrelease'] = 'Virus flag release'; $string['typevirusrelease'] = 'Virus flag release';
$string['type'] = 'Activity type: '; $string['type'] = 'Activity type';
$string['attime'] = 'at'; $string['attime'] = 'at';
$string['prefsdescr'] = 'For options other than Activity log, notifications will still go into the Activity log, but will be automatically marked as read'; $string['prefsdescr'] = 'For options other than Activity log, notifications will still go into the Activity log, but will be automatically marked as read';
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<div class="content"> <div class="content">
<form method="post"> <form method="post">
{str section='activity' tag='type'} {str section='activity' tag='type'}:
<select name="type" onChange="{$typechange}"> <select name="type" onChange="{$typechange}">
<option value="all">{str section='activity' tag='alltypes'}</option> <option value="all">{str section='activity' tag='alltypes'}</option>
{foreach from=$types item='type'} {foreach from=$types item='type'}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th>{str section='activity' tag='type'}</th>
<th>{str section='activity' tag='date'}</th> <th>{str section='activity' tag='date'}</th>
<th>{str section='activity' tag='read'}</th> <th>{str section='activity' tag='read'}</th>
<th>{str section='activity' tag='markasread'} [<a href="" onClick="{$selectall}">{str section='activity' tag='selectall'}</a>]</th> <th>{str section='activity' tag='markasread'} [<a href="" onClick="{$selectall}">{str section='activity' tag='selectall'}</a>]</th>
......
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