Commit 047ae8ff authored by Robert Lyon's avatar Robert Lyon

Bug 1636599: Avoid infinite redirect with user journals pages

Where a user has multiple journals but has account preference for multiple blogs turned off. To test: Add multiple blogs to a user then in db set the user preference for multiple blogs to off. Logout and login again as the user and go to the journals page. behatnotneeded Change-Id: I2612e8d9d8c2adde5e35d972269b70353de6c9aa Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz> (cherry picked from commit a93742d2)
parent 52abb658
......@@ -80,9 +80,17 @@ list($blogs->count, $blogs->data) = ArtefactTypeBlog::get_blog_list($blogs->limi
if (empty($blogs->institution) && empty($blogs->group)) {
if (!$USER->get_account_preference('multipleblogs')) {
$extra = !empty($institution) ? '?institution=' . $institution : '';
$extra = !empty($group) ? '?group=' . $group : '';
redirect(get_config('wwwroot') . 'artefact/blog/view/index.php' . $extra);
// Check to see if the user has multiple blogs anyway
$records = get_records_select_array('artefact', "artefacttype = 'blog' AND \"owner\" = ?", array($USER->get('id')), 'id ASC');
if ($records && count($records) > 1) {
set_account_preference($USER->get('id'), 'multipleblogs', 1);
$USER->set_account_preference('multipleblogs', 1);
}
else {
$extra = !empty($institution) ? '?institution=' . $institution : '';
$extra = !empty($group) ? '?group=' . $group : '';
redirect(get_config('wwwroot') . 'artefact/blog/view/index.php' . $extra);
}
}
}
......
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