Commit fce7f8e5 authored by Robert Lyon's avatar Robert Lyon
Browse files

Passing the objection=1 param to the objection url (Bug #1444925)



To allow us to show a more detailed error message if site admin (not
belonging to the group) goes to review an objectionable group page
or group forum topic that has already been sorted out.

Change-Id: If4785528bfe29736542972adce7609cdb0522248
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit a4f1dfe8)
parent baa371f8
......@@ -1051,7 +1051,7 @@ class ActivityTypeInteractionForumReportPost extends ActivityTypePlugin {
$post->posttime = strftime(get_string('strftimedaydatetime'), $post->ctime);
$post->textbody = trim(html2text($post->body));
$post->htmlbody = clean_html($post->body);
$this->url = 'interaction/forum/topic.php?id=' . $post->topicid . '&post=' . $this->postid;
$this->url = 'interaction/forum/topic.php?id=' . $post->topicid . '&post=' . $this->postid . '&objection=1';
$this->add_urltext(array(
'key' => 'Topic',
......
......@@ -57,7 +57,9 @@ $maxindentdepth = isset($forumconfig['maxindent']) ? $forumconfig['maxindent']->
if (!$membership
&& !get_field('group', 'public', 'id', $topic->groupid)) {
throw new GroupAccessDeniedException(get_string('cantviewtopic', 'interaction.forum'));
$objection = param_integer('objection', 0);
$errorstr = ($objection) ? get_string('accessdeniedobjection', 'error') : get_string('cantviewtopic', 'interaction.forum');
throw new GroupAccessDeniedException($errorstr, $objection);
}
$topic->canedit = ($moderator || user_can_edit_post($topic->poster, $topic->ctime)) && $ineditwindow;
......
......@@ -87,6 +87,7 @@ $string['notfound'] = 'Not found';
$string['notfoundexception'] = 'The page you are looking for could not be found.';
$string['accessdenied'] = 'Access denied';
$string['accessdeniedobjection'] = 'Access denied - The objection has already been resolved by another administrator.';
$string['accessdeniedexception'] = 'You do not have access to view this page.';
$string['viewnotfoundexceptiontitle'] = 'Page not found';
......
......@@ -913,10 +913,10 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
}
if (empty($this->artefact)) {
$this->url = $this->view->get_url(false);
$this->url = $this->view->get_url(false) . '&objection=1';
}
else {
$this->url = 'artefact/artefact.php?artefact=' . $this->artefact->get('id') . '&view=' . $this->view->get('id');
$this->url = 'artefact/artefact.php?artefact=' . $this->artefact->get('id') . '&view=' . $this->view->get('id') . '&objection=1';
}
if (empty($this->strings->subject)) {
......@@ -948,14 +948,14 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
return get_string_from_language(
$user->lang, 'objectionablecontentviewtext', 'activity',
$this->view->get('title'), display_default_name($this->reporter), $ctime,
$this->message, $this->view->get_url(), $reporterurl
$this->message, $this->view->get_url() . "&objection=1", $reporterurl
);
}
else {
return get_string_from_language(
$user->lang, 'objectionablecontentviewartefacttext', 'activity',
$this->view->get('title'), $this->artefact->get('title'), display_default_name($this->reporter), $ctime,
$this->message, $this->view->get_url(), $reporterurl
$this->message, $this->view->get_url() . "&objection=1", $reporterurl
);
}
}
......@@ -970,7 +970,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
return get_string_from_language(
$user->lang, 'objectionablecontentviewhtml', 'activity',
$viewtitle, $reportername, $ctime,
$message, $this->view->get_url(), $viewtitle,
$message, $this->view->get_url() . "&objection=1", $viewtitle,
$reporterurl, $reportername
);
}
......@@ -978,7 +978,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
return get_string_from_language(
$user->lang, 'objectionablecontentviewartefacthtml', 'activity',
$viewtitle, hsc($this->artefact->get('title')), $reportername, $ctime,
$message, $this->view->get_url(), $viewtitle,
$message, $this->view->get_url() . "&objection=1", $viewtitle,
$reporterurl, $reportername
);
}
......
......@@ -915,7 +915,12 @@ class GroupAccessDeniedException extends AccessDeniedException {
$group = group_current_group();
if ($group->jointype == 'open'
|| get_record('group_member_invite', 'group', GROUP, 'member', $USER->get('id'))) {
$SESSION->add_error_msg(get_string('notmembermayjoin', 'group', $group->name));
$message = get_string('notmembermayjoin', 'group', $group->name);
// Error code equals 1 if we have objection=1 in url
if ($this->getCode() == '1') {
$message .= ' ' . get_string('accessdeniedobjection', 'error');
}
$SESSION->add_error_msg($message);
$next = substr($_SERVER['REQUEST_URI'], strlen(get_mahara_install_subdirectory()) - 1);
$goto = group_homepage_url($group);
$goto .= (strpos($goto, '?') ? '&' : '?') . 'next=' . urlencode($next);
......
......@@ -113,8 +113,13 @@ function objection_form_cancel_submit(Pieform $form) {
function notrude_form() {
global $USER, $view, $artefact;
$owner = $view->get('owner');
if (!(($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)))
|| ($view->get('group') && $USER->get('admin')))) {
if (!
(
($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)))
|| ($view->get('group') && $USER->get('admin'))
|| ($view->get('group') && group_user_access($view->get('group'), $USER->get('id')) == 'admin')
)
) {
return;
}
......
......@@ -67,7 +67,8 @@ if (!isset($view)) {
}
if (!can_view_view($view)) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
$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
......
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