// Do course wide subscribe/unsubscribe if requested
if (!is_null($subscribe)) {
if (isguestuser() or !$can_subscribe) {
- // there should not be any links leading to this place, just redirect
- redirect(new moodle_url('/mod/forum/index.php', array('id' => $id)), get_string('subscribeenrolledonly', 'forum'));
+ // There should not be any links leading to this place, just redirect.
+ redirect(
+ new moodle_url('/mod/forum/index.php', array('id' => $id)),
+ get_string('subscribeenrolledonly', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_ERROR
+ );
}
// Can proceed now, the user is not guest and is enrolled
foreach ($modinfo->get_instances_of('forum') as $forumid=>$cm) {
$returnto = forum_go_back_to(new moodle_url('/mod/forum/index.php', array('id' => $course->id)));
$shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
if ($subscribe) {
- redirect($returnto, get_string('nowallsubscribed', 'forum', $shortname), 1);
+ redirect(
+ $returnto,
+ get_string('nowallsubscribed', 'forum', $shortname),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else {
- redirect($returnto, get_string('nowallunsubscribed', 'forum', $shortname), 1);
+ redirect(
+ $returnto,
+ get_string('nowallunsubscribed', 'forum', $shortname),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
}
}
$returnto = "view.php?f={$id}";
}
-redirect($returnto, $updatemessage, 1);
+redirect($returnto, $updatemessage, null, \core\output\notification::NOTIFY_SUCCESS);
$DB->update_record("forum", $forum);
}
- $timemessage = 2;
- if (!empty($message)) { // if we're printing stuff about the file upload
- $timemessage = 4;
- }
-
if ($realpost->userid == $USER->id) {
$message .= '<br />'.get_string("postupdated", "forum");
} else {
$message .= '<br />'.get_string("editedpostupdated", "forum", fullname($realuser));
}
- if ($subscribemessage = forum_post_subscription($fromform, $forum, $discussion)) {
- $timemessage = 4;
- }
+ $subscribemessage = forum_post_subscription($fromform, $forum, $discussion);
if ($forum->type == 'single') {
// Single discussion forums are an exception. We show
// the forum itself since it only has one discussion
$event->add_record_snapshot('forum_discussions', $discussion);
$event->trigger();
- redirect(forum_go_back_to($discussionurl), $message.$subscribemessage, $timemessage);
-
- exit;
-
+ redirect(
+ forum_go_back_to($discussionurl),
+ $message . $subscribemessage,
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else if ($fromform->discussion) { // Adding a new post to an existing discussion
// Before we add this we must check that the user will not exceed the blocking threshold.
$addpost = $fromform;
$addpost->forum=$forum->id;
if ($fromform->id = forum_add_new_post($addpost, $mform_post, $message)) {
- $timemessage = 2;
- if (!empty($message)) { // if we're printing stuff about the file upload
- $timemessage = 4;
- }
-
- if ($subscribemessage = forum_post_subscription($fromform, $forum, $discussion)) {
- $timemessage = 4;
- }
+ $subscribemessage = forum_post_subscription($fromform, $forum, $discussion);
if (!empty($fromform->mailnow)) {
$message .= get_string("postmailnow", "forum");
- $timemessage = 4;
} else {
$message .= '<p>'.get_string("postaddedsuccess", "forum") . '</p>';
$message .= '<p>'.get_string("postaddedtimeleft", "forum", format_time($CFG->maxeditingtime)) . '</p>';
$completion->update_state($cm,COMPLETION_COMPLETE);
}
- redirect(forum_go_back_to($discussionurl), $message.$subscribemessage, $timemessage);
+ redirect(
+ forum_go_back_to($discussionurl),
+ $message . $subscribemessage,
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else {
print_error("couldnotadd", "forum", $errordestination);
$event->add_record_snapshot('forum_discussions', $discussion);
$event->trigger();
- $timemessage = 2;
- if (!empty($message)) { // If we're printing stuff about the file upload.
- $timemessage = 4;
- }
-
if ($fromform->mailnow) {
$message .= get_string("postmailnow", "forum");
- $timemessage = 4;
} else {
$message .= '<p>'.get_string("postaddedsuccess", "forum") . '</p>';
$message .= '<p>'.get_string("postaddedtimeleft", "forum", format_time($CFG->maxeditingtime)) . '</p>';
}
- if ($subscribemessage = forum_post_subscription($fromform, $forum, $discussion)) {
- $timemessage = 6;
- }
+ $subscribemessage = forum_post_subscription($fromform, $forum, $discussion);
} else {
print_error("couldnotadd", "forum", $errordestination);
}
}
// Redirect back to the discussion.
- redirect(forum_go_back_to($redirectto->out()), $message . $subscribemessage, $timemessage);
+ redirect(
+ forum_go_back_to($redirectto->out()),
+ $message . $subscribemessage,
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
}
}
echo $OUTPUT->footer();
exit;
} else {
- // there should not be any links leading to this place, just redirect
- redirect(new moodle_url('/mod/forum/view.php', array('f'=>$id)), get_string('subscribeenrolledonly', 'forum'));
+ // There should not be any links leading to this place, just redirect.
+ redirect(
+ new moodle_url('/mod/forum/view.php', array('f'=>$id)),
+ get_string('subscribeenrolledonly', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_ERROR
+ );
}
}
switch ($mode) {
case FORUM_CHOOSESUBSCRIBE : // 0
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_CHOOSESUBSCRIBE);
- redirect($returnto, get_string("everyonecannowchoose", "forum"), 1);
+ redirect(
+ $returnto,
+ get_string('everyonecannowchoose', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
break;
case FORUM_FORCESUBSCRIBE : // 1
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_FORCESUBSCRIBE);
- redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
+ redirect(
+ $returnto,
+ get_string('everyoneisnowsubscribed', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
break;
case FORUM_INITIALSUBSCRIBE : // 2
if ($forum->forcesubscribe <> FORUM_INITIALSUBSCRIBE) {
}
}
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_INITIALSUBSCRIBE);
- redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
+ redirect(
+ $returnto,
+ get_string('everyoneisnowsubscribed', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
break;
case FORUM_DISALLOWSUBSCRIBE : // 3
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_DISALLOWSUBSCRIBE);
- redirect($returnto, get_string("noonecansubscribenow", "forum"), 1);
+ redirect(
+ $returnto,
+ get_string('noonecansubscribenow', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
break;
default:
print_error(get_string('invalidforcesubscribe', 'forum'));
}
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
- redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
+ redirect(
+ $returnto,
+ get_string('everyoneisnowsubscribed', 'forum'),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
}
$info = new stdClass();
require_sesskey();
if ($discussionid === null) {
if (\mod_forum\subscriptions::unsubscribe_user($user->id, $forum, $context, true)) {
- redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1);
+ redirect(
+ $returnto,
+ get_string('nownotsubscribed', 'forum', $info),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else {
print_error('cannotunsubscribe', 'forum', get_local_referer(false));
}
} else {
if (\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion, $context)) {
$info->discussion = $discussion->name;
- redirect($returnto, get_string("discussionnownotsubscribed", "forum", $info), 1);
+ redirect(
+ $returnto,
+ get_string('discussionnownotsubscribed', 'forum', $info),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else {
print_error('cannotunsubscribe', 'forum', get_local_referer(false));
}
require_sesskey();
if ($discussionid == null) {
\mod_forum\subscriptions::subscribe_user($user->id, $forum, $context, true);
- redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
+ redirect(
+ $returnto,
+ get_string('nowsubscribed', 'forum', $info),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
} else {
$info->discussion = $discussion->name;
\mod_forum\subscriptions::subscribe_user_to_discussion($user->id, $discussion, $context);
- redirect($returnto, get_string("discussionnowsubscribed", "forum", $info), 1);
+ redirect(
+ $returnto,
+ get_string('discussionnowsubscribed', 'forum', $info),
+ null,
+ \core\output\notification::NOTIFY_SUCCESS
+ );
}
}
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I follow "Subscribe to this forum"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test forum name'"
And I should see "Unsubscribe from this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Unsubscribe from this forum"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Unsubscribe from this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Unsubscribe from this forum"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I follow "Subscribe to this forum"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test forum name'"
And I should see "Unsubscribe from this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
When I follow "Unsubscribe from this forum"
- And I follow "Continue"
- Then I should see "Subscribe to this forum"
+ Then I should see "Student One will NOT be notified of new posts in 'Test forum name'"
+ And I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
When I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
Then I should see "Subscribe to this forum"
And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
Then I should see "Subscribe to this forum"
And I should see "Subscribe to this discussion"
And I follow "Subscribe to this forum"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test forum name'"
And I follow "Test post subject one"
And I should see "Unsubscribe from this forum"
And I should see "Unsubscribe from this discussion"
And I follow "Unsubscribe from this discussion"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I follow "Test post subject one"
And I should see "Unsubscribe from this forum"
And I should see "Subscribe to this discussion"
And I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I follow "Test post subject one"
And I should see "Subscribe to this forum"
And I should see "Subscribe to this discussion"
And I follow "Subscribe to this discussion"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And I should see "Subscribe to this forum"
And I should see "Unsubscribe from this discussion"
And I follow "Subscribe to this forum"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test forum name'"
And I follow "Test post subject one"
And I should see "Unsubscribe from this forum"
And I should see "Unsubscribe from this discussion"
And I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I follow "Test post subject one"
And I should see "Subscribe to this forum"
And I should see "Subscribe to this discussion"
Then I should see "Subscribe to this forum"
And I should not see "Unsubscribe from this forum"
And I follow "Subscribe to this forum"
- And I follow "Continue"
+ And I should see "Student One will be notified of new posts in 'Test forum name'"
And I should see "Unsubscribe from this forum"
And I should not see "Subscribe to this forum"
Then I should see "Unsubscribe from this forum"
And I should not see "Subscribe to this forum"
And I follow "Unsubscribe from this forum"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I should see "Subscribe to this forum"
And I should not see "Unsubscribe from this forum"
And I follow "Course 1"
And I follow "Test forum name"
And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject" "table_row"
- And I follow "Continue"
+ And I should see "Student One will NOT be notified of new posts in 'Test post subject' of 'Test forum name'"
And I follow "Test post subject"
When I follow "Reply"
And "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
And I follow "Course 1"
And I follow "Test forum name"
And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject" "table_row"
- And I follow "Continue"
+ And I should see "Student Two will NOT be notified of new posts in 'Test post subject' of 'Test forum name'"
And I follow "Test post subject"
And I follow "Reply"
And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist