mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 00:20:37 +01:00
Merge branch 'MDL-48309-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
commit
783d96c6da
@ -105,6 +105,8 @@ $string['configshortpost'] = 'Any post under this length (in characters not incl
|
||||
$string['configtrackingtype'] = 'Default setting for read tracking.';
|
||||
$string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.';
|
||||
$string['configusermarksread'] = 'If \'yes\', the user must manually mark a post as read. If \'no\', when the post is viewed it is marked as read.';
|
||||
$string['confirmsubscribediscussion'] = 'Do you really want to subscribe to discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?';
|
||||
$string['confirmunsubscribediscussion'] = 'Do you really want to unsubscribe from discussion \'{$a->discussion}\' in forum \'{$a->forum}\'?';
|
||||
$string['confirmsubscribe'] = 'Do you really want to subscribe to forum \'{$a}\'?';
|
||||
$string['confirmunsubscribe'] = 'Do you really want to unsubscribe from forum \'{$a}\'?';
|
||||
$string['couldnotadd'] = 'Could not add your post due to an unknown error';
|
||||
@ -445,6 +447,7 @@ $string['smallmessage'] = '{$a->user} posted in {$a->forumname}';
|
||||
$string['startedby'] = 'Started by';
|
||||
$string['subject'] = 'Subject';
|
||||
$string['subscribe'] = 'Subscribe to this forum';
|
||||
$string['subscribediscussion'] = 'Subscribe to this discussion';
|
||||
$string['subscribeall'] = 'Subscribe everyone to this forum';
|
||||
$string['subscribeenrolledonly'] = 'Sorry, only enrolled users are allowed to subscribe to forum post notifications.';
|
||||
$string['subscribed'] = 'Subscribed';
|
||||
|
@ -7047,6 +7047,11 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
$PAGE->cm->context = context_module::instance($PAGE->cm->instance);
|
||||
}
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
if (!empty($params['d'])) {
|
||||
$discussionid = $params['d'];
|
||||
}
|
||||
|
||||
// for some actions you need to be enrolled, beiing admin is not enough sometimes here
|
||||
$enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
|
||||
$activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
|
||||
@ -7102,13 +7107,28 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
}
|
||||
|
||||
if ($cansubscribe) {
|
||||
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject)) {
|
||||
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, null, $PAGE->cm)) {
|
||||
$linktext = get_string('unsubscribe', 'forum');
|
||||
} else {
|
||||
$linktext = get_string('subscribe', 'forum');
|
||||
}
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'sesskey'=>sesskey()));
|
||||
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
|
||||
if (isset($discussionid)) {
|
||||
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, $discussionid, $PAGE->cm)) {
|
||||
$linktext = get_string('unsubscribediscussion', 'forum');
|
||||
} else {
|
||||
$linktext = get_string('subscribediscussion', 'forum');
|
||||
}
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array(
|
||||
'id' => $forumobject->id,
|
||||
'sesskey' => sesskey(),
|
||||
'd' => $discussionid,
|
||||
'returnurl' => $PAGE->url->out(),
|
||||
));
|
||||
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
|
||||
|
@ -51,6 +51,10 @@ if ($user !== 0) {
|
||||
if (!is_null($sesskey)) {
|
||||
$url->param('sesskey', $sesskey);
|
||||
}
|
||||
if (!is_null($discussionid)) {
|
||||
$url->param('d', $discussionid);
|
||||
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid), '*', MUST_EXIST);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$forum = $DB->get_record('forum', array('id' => $id), '*', MUST_EXIST);
|
||||
@ -147,12 +151,23 @@ $info->name = fullname($user);
|
||||
$info->forum = format_string($forum->name);
|
||||
|
||||
if ($issubscribed) {
|
||||
if (is_null($sesskey)) { // we came here via link in email
|
||||
if (is_null($sesskey)) {
|
||||
// We came here via link in email.
|
||||
$PAGE->set_title($course->shortname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('confirmunsubscribe', 'forum', format_string($forum->name)),
|
||||
new moodle_url($PAGE->url, array('sesskey' => sesskey())), new moodle_url('/mod/forum/view.php', array('f' => $id)));
|
||||
|
||||
$viewurl = new moodle_url('/mod/forum/view.php', array('f' => $id));
|
||||
if ($discussionid) {
|
||||
$a = new stdClass();
|
||||
$a->forum = format_string($forum->name);
|
||||
$a->discussion = format_string($discussion->name);
|
||||
echo $OUTPUT->confirm(get_string('confirmunsubscribediscussion', 'forum', $a),
|
||||
$PAGE->url, $viewurl);
|
||||
} else {
|
||||
echo $OUTPUT->confirm(get_string('confirmunsubscribe', 'forum', format_string($forum->name)),
|
||||
$PAGE->url, $viewurl);
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
@ -164,7 +179,6 @@ if ($issubscribed) {
|
||||
print_error('cannotunsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
} else {
|
||||
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid));
|
||||
if (\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion, $context)) {
|
||||
$info->discussion = $discussion->name;
|
||||
redirect($returnto, get_string("discussionnownotsubscribed", "forum", $info), 1);
|
||||
@ -180,12 +194,23 @@ if ($issubscribed) {
|
||||
if (!has_capability('mod/forum:viewdiscussion', $context)) {
|
||||
print_error('noviewdiscussionspermission', 'forum', $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
if (is_null($sesskey)) { // we came here via link in email
|
||||
if (is_null($sesskey)) {
|
||||
// We came here via link in email.
|
||||
$PAGE->set_title($course->shortname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('confirmsubscribe', 'forum', format_string($forum->name)),
|
||||
new moodle_url($PAGE->url, array('sesskey' => sesskey())), new moodle_url('/mod/forum/view.php', array('f' => $id)));
|
||||
|
||||
$viewurl = new moodle_url('/mod/forum/view.php', array('f' => $id));
|
||||
if ($discussionid) {
|
||||
$a = new stdClass();
|
||||
$a->forum = format_string($forum->name);
|
||||
$a->discussion = format_string($discussion->name);
|
||||
echo $OUTPUT->confirm(get_string('confirmsubscribediscussion', 'forum', $a),
|
||||
$PAGE->url, $viewurl);
|
||||
} else {
|
||||
echo $OUTPUT->confirm(get_string('confirmsubscribe', 'forum', format_string($forum->name)),
|
||||
$PAGE->url, $viewurl);
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
@ -194,7 +219,6 @@ if ($issubscribed) {
|
||||
\mod_forum\subscriptions::subscribe_user($user->id, $forum, $context, true);
|
||||
redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
|
||||
} else {
|
||||
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid));
|
||||
$info->discussion = $discussion->name;
|
||||
\mod_forum\subscriptions::subscribe_user_to_discussion($user->id, $discussion, $context);
|
||||
redirect($returnto, get_string("discussionnowsubscribed", "forum", $info), 1);
|
||||
|
@ -304,3 +304,49 @@ Feature: A user can control their own subscription preferences for a discussion
|
||||
And I follow "Test post subject one"
|
||||
And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist
|
||||
And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist
|
||||
|
||||
Scenario: A user can toggle their subscription preferences when viewing a discussion
|
||||
Given I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Forum type | Standard forum for general use |
|
||||
| Description | Test forum description |
|
||||
| Subscription mode | Optional subscription |
|
||||
And I add a new discussion to "Test forum name" forum with:
|
||||
| Subject | Test post subject one |
|
||||
| Message | Test post message one |
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test forum name"
|
||||
When I follow "Test post subject one"
|
||||
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 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 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 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 "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 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 follow "Test post subject one"
|
||||
And I should see "Subscribe to this forum"
|
||||
And I should see "Subscribe to this discussion"
|
||||
|
Loading…
x
Reference in New Issue
Block a user