Commit b335fdb7 authored by Robert Lyon's avatar Robert Lyon

Bug 1735585: Fixing update of atime on page view

Currently we have a mahara_log function that logs page visits
So I decided we also need a mahara_touch_record($table, $id) function
that updates the 'atime' for a record when called

behatnotneeded

Change-Id: I2f645c8357426112f9edcdd24f1b8b85513cb7cb
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 5ff54fac
......@@ -4541,6 +4541,10 @@ function build_portfolio_search_html(&$data) {
$data->pagination_js = $pagination['javascript'];
}
function mahara_touch_record($table, $id) {
execute_sql("UPDATE " . db_table_name($table) . " SET atime = ? WHERE id = ?", array(db_format_timestamp(time()), $id));
}
function mahara_log($logname, $string) {
error_log('[' . date("Y-m-d h:i:s") . "] $string\n", 3, get_config('dataroot') . 'log/' . $logname . '.log');
}
......
......@@ -366,6 +366,7 @@ $smarty->assign('mrmoduleactive', PluginModuleMultirecipientnotification::is_act
$smarty->display('user/view.tpl');
mahara_touch_record('view', $viewid); // Update record 'atime'
mahara_log('views', "$viewid"); // Log view visits
// Send an invitation to the user to join a group
......
......@@ -91,15 +91,6 @@ if (!can_view_view($view)) {
$errorstr = (param_integer('objection', null)) ? get_string('accessdeniedobjection', 'error') : get_string('accessdenied', 'error');
throw new AccessDeniedException($errorstr);
}
else {
// To save the atime in the db - make it a millisecond in the past
// so it differs from the atime in the View constructor and so triggers
// the saving of the atime change. Can't use $view->set('dirty', true)
// as that will also get the view object to update the mtime which is not
// what we want.
$view->set('atime', (time()) - 1);
$view->commit();
}
// Comment list pagination requires limit/offset params
$limit = param_integer('limit', 10);
......@@ -456,4 +447,5 @@ $smarty->assign('userisowner', ($owner && $owner == $USER->get('id')));
$smarty->display('view/view.tpl');
mahara_touch_record('view', $viewid); // Update record 'atime'
mahara_log('views', "$viewid"); // Log view visits
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