mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-73415 mod_forum: Address the followup issues for forum
This issue is a followup for changes made in forum. And hence addresses the following issues spotted for forum: 1. Bring back the "Forums" header in the search page. 2. Remove the stale function forum_update_subscriptions_button 3. Fix the redirection to activity tab when subscription is changed, in the subscription tab.
This commit is contained in:
parent
0f94f29296
commit
e6a4eb3c36
@ -115,7 +115,7 @@ Feature: Toggle activities visibility from the course page
|
||||
And "Test forum name" activity should be hidden
|
||||
And I click on "Test forum name" "link" in the "Recent activity" "block"
|
||||
And I should see "Test forum name"
|
||||
And I should see "(There are no discussion topics yet in this forum)"
|
||||
And I should see "There are no discussion topics yet in this forum"
|
||||
|
||||
@javascript
|
||||
Scenario: Activities can be made available but not visible on a course page
|
||||
|
@ -22,12 +22,11 @@ Feature: Managers can create courses
|
||||
And I add the "Latest announcements" block
|
||||
And I am on the Announcements "forum activity" page
|
||||
And "Add discussion topic" "link" should exist
|
||||
And "Subscription mode > Forced subscription" "link" should not exist in current page administration
|
||||
And "Subscription mode > Forced subscription" "text" should exist in current page administration
|
||||
And I navigate to "Subscriptions" in current page administration
|
||||
And I should see "Forced subscription"
|
||||
And I log out
|
||||
And I am on the Announcements "forum activity" page logged in as student1
|
||||
And "Add a new topic" "link" should not exist
|
||||
And "Forced subscription" "text" should exist
|
||||
|
||||
Scenario: Create a course from the management interface and return to it
|
||||
Given the following "courses" exist:
|
||||
|
@ -216,7 +216,8 @@ class discussion {
|
||||
'pindiscussion' => null,
|
||||
'neighbourlinks' => $this->get_neighbour_links_html(),
|
||||
'exportdiscussion' => !empty($CFG->enableportfolios) ? $this->get_export_discussion_html($user) : null
|
||||
]
|
||||
],
|
||||
'settingsselector' => true,
|
||||
]);
|
||||
|
||||
$capabilities = (array) $exporteddiscussion['capabilities'];
|
||||
|
@ -39,31 +39,45 @@ class subscription_actionbar implements renderable, templatable {
|
||||
/** @var \stdClass */
|
||||
private $forum;
|
||||
|
||||
/** @var int */
|
||||
private $edit;
|
||||
|
||||
/**
|
||||
* subscription_actionbar constructor.
|
||||
*
|
||||
* @param int $id The forum id.
|
||||
* @param moodle_url $currenturl Current URL.
|
||||
* @param \stdClass $forum The forum object.
|
||||
* @param int $edit This argument decides to show view/manage subscribers view.
|
||||
*/
|
||||
public function __construct(int $id, moodle_url $currenturl, \stdClass $forum) {
|
||||
public function __construct(int $id, moodle_url $currenturl, \stdClass $forum, int $edit) {
|
||||
$this->id = $id;
|
||||
$this->currenturl = $currenturl;
|
||||
$this->forum = $forum;
|
||||
$this->edit = $edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create url select menu for subscription option
|
||||
*
|
||||
* @return url_select the url_select object
|
||||
* @return url_select|null the url_select object
|
||||
*/
|
||||
private function create_subscription_menu(): url_select {
|
||||
private function create_subscription_menu(): ?url_select {
|
||||
// When user is on manage subscription, we don't have to show the subscription selector.
|
||||
if ($this->edit === 1 && !\mod_forum\subscriptions::is_forcesubscribed($this->forum)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sesskey = sesskey();
|
||||
$modeset = \mod_forum\subscriptions::get_subscription_mode($this->forum);
|
||||
$optionallink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 0, 'sesskey' => $sesskey]);
|
||||
$forcedlink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 1, 'sesskey' => $sesskey]);
|
||||
$autolink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 2, 'sesskey' => $sesskey]);
|
||||
$disabledlink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 3, 'sesskey' => $sesskey]);
|
||||
$optionallink = new moodle_url('/mod/forum/subscribe.php',
|
||||
['id' => $this->id, 'mode' => FORUM_CHOOSESUBSCRIBE, 'sesskey' => $sesskey, 'edit' => $this->edit]);
|
||||
$forcedlink = new moodle_url('/mod/forum/subscribe.php',
|
||||
['id' => $this->id, 'mode' => FORUM_FORCESUBSCRIBE, 'sesskey' => $sesskey, 'edit' => $this->edit]);
|
||||
$autolink = new moodle_url('/mod/forum/subscribe.php',
|
||||
['id' => $this->id, 'mode' => FORUM_INITIALSUBSCRIBE, 'sesskey' => $sesskey, 'edit' => $this->edit]);
|
||||
$disabledlink = new moodle_url('/mod/forum/subscribe.php',
|
||||
['id' => $this->id, 'mode' => FORUM_DISALLOWSUBSCRIBE, 'sesskey' => $sesskey, 'edit' => $this->edit]);
|
||||
|
||||
$menu = [
|
||||
$optionallink->out(false) => get_string('subscriptionoptional', 'forum'),
|
||||
@ -104,9 +118,14 @@ class subscription_actionbar implements renderable, templatable {
|
||||
/**
|
||||
* Create view and manage subscribers select menu.
|
||||
*
|
||||
* @return url_select get url_select object.
|
||||
* @return url_select|null get url_select object.
|
||||
*/
|
||||
private function create_view_manage_menu(): url_select {
|
||||
private function create_view_manage_menu(): ?url_select {
|
||||
// If forced subscription is used then no need to show the view.
|
||||
if (\mod_forum\subscriptions::is_forcesubscribed($this->forum)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$viewlink = new moodle_url('/mod/forum/subscribers.php', ['id' => $this->id, 'edit' => 'off']);
|
||||
$managelink = new moodle_url('/mod/forum/subscribers.php', ['id' => $this->id, 'edit' => 'on']);
|
||||
|
||||
@ -115,12 +134,11 @@ class subscription_actionbar implements renderable, templatable {
|
||||
$managelink->out(false) => get_string('managesubscriptionson', 'forum'),
|
||||
];
|
||||
|
||||
if ($this->currenturl->get_param('edit') === 'off') {
|
||||
if ($this->edit === 0) {
|
||||
$this->currenturl = $viewlink;
|
||||
} else {
|
||||
$this->currenturl = $managelink;
|
||||
}
|
||||
|
||||
$urlselect = new url_select($menu, $this->currenturl->out(false), null, 'selectviewandmanagesubscribers');
|
||||
$urlselect->set_label(get_string('subscribers', 'forum'), ['class' => 'accesshide']);
|
||||
return $urlselect;
|
||||
@ -133,12 +151,16 @@ class subscription_actionbar implements renderable, templatable {
|
||||
* @return array data for template
|
||||
*/
|
||||
public function export_for_template(renderer_base $output): array {
|
||||
$data = [];
|
||||
$subscribeoptionselect = $this->create_subscription_menu();
|
||||
$viewmanageselect = $this->create_view_manage_menu();
|
||||
$data = [
|
||||
'subscriptionoptions' => $subscribeoptionselect->export_for_template($output),
|
||||
'viewandmanageselect' => $viewmanageselect->export_for_template($output),
|
||||
];
|
||||
|
||||
if ($subscribeoptionselect) {
|
||||
$data ['subscriptionoptions'] = $subscribeoptionselect->export_for_template($output);
|
||||
}
|
||||
if ($viewmanageselect) {
|
||||
$data['viewandmanageselect'] = $viewmanageselect->export_for_template($output);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -476,3 +476,39 @@ WHERE
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the editing button on subscribers page
|
||||
*
|
||||
* @deprecated since Moodle 4.0
|
||||
* @todo MDL-73956 Final deprecation in Moodle 4.4
|
||||
* @global object
|
||||
* @global object
|
||||
* @param int $courseid
|
||||
* @param int $forumid
|
||||
* @return string
|
||||
*/
|
||||
function forum_update_subscriptions_button($courseid, $forumid): string {
|
||||
global $CFG, $USER;
|
||||
|
||||
debugging('The method forum_update_subscriptions_button() has been deprecated as it is no longer used.' .
|
||||
'The \'Manage subscribers\' button has been replaced with tertiary navigation.', DEBUG_DEVELOPER);
|
||||
|
||||
if (!empty($USER->subscriptionsediting)) {
|
||||
$string = get_string('managesubscriptionsoff', 'forum');
|
||||
$edit = "off";
|
||||
} else {
|
||||
$string = get_string('managesubscriptionson', 'forum');
|
||||
$edit = "on";
|
||||
}
|
||||
|
||||
$subscribers = html_writer::start_tag('form', array('action' => $CFG->wwwroot . '/mod/forum/subscribers.php',
|
||||
'method' => 'get', 'class' => 'form-inline'));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => $string,
|
||||
'class' => 'btn btn-secondary'));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $forumid));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'edit', 'value' => $edit));
|
||||
$subscribers .= html_writer::end_tag('form');
|
||||
|
||||
return $subscribers;
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ if ($node && $post->get_id() != $discussion->get_first_post_id()) {
|
||||
$isnestedv2displaymode = $displaymode == FORUM_MODE_NESTED_V2;
|
||||
$PAGE->set_title("$course->shortname: " . format_string($discussion->get_name()));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_secondary_active_tab('modulepage');
|
||||
$PAGE->activityheader->disable();
|
||||
if ($isnestedv2displaymode) {
|
||||
$PAGE->add_body_class('nested-v2-display-mode reset-style');
|
||||
|
@ -30,6 +30,7 @@ $string['actionsforpost'] = 'Actions for post';
|
||||
$string['addanewdiscussion'] = 'Add discussion topic';
|
||||
$string['addanewquestion'] = 'Add a new question';
|
||||
$string['addanewtopic'] = 'Add a new topic';
|
||||
$string['addreply'] = 'Add reply';
|
||||
$string['addtofavourites'] = 'Star this discussion';
|
||||
$string['advancedsearch'] = 'Advanced search';
|
||||
$string['alldiscussions'] = 'All discussions';
|
||||
@ -224,6 +225,8 @@ $string['duedate_help'] = 'This is when posting in the forum is due. Although th
|
||||
$string['duedatetodisplayincalendar'] = 'Due date to display in calendar';
|
||||
$string['eachuserforum'] = 'Each person posts one discussion';
|
||||
$string['edit'] = 'Edit';
|
||||
$string['editdiscussion'] = 'Edit discussion';
|
||||
$string['editdiscussiontopic'] = 'Edit discussion topic';
|
||||
$string['editedby'] = 'Edited by {$a->name} - original submission {$a->date}';
|
||||
$string['editedpostupdated'] = '{$a}\'s post was updated';
|
||||
$string['editing'] = 'Editing';
|
||||
@ -318,6 +321,7 @@ $string['forumposts'] = 'Forum posts';
|
||||
$string['forum:rate'] = 'Rate posts';
|
||||
$string['forum:replynews'] = 'Reply to announcements';
|
||||
$string['forum:replypost'] = 'Reply to posts';
|
||||
$string['replypostdiscussion'] = 'Reply to discussion';
|
||||
$string['forum:postprivatereply'] = 'Reply privately to posts';
|
||||
$string['forum:readprivatereplies'] = 'View private replies';
|
||||
$string['forums'] = 'Forums';
|
||||
@ -598,6 +602,7 @@ $string['privatereply_help'] = 'A private reply can only be viewed by the author
|
||||
$string['processingdigest'] = 'Processing email digest for user {$a}';
|
||||
$string['processingpost'] = 'Processing post {$a}';
|
||||
$string['prune'] = 'Split';
|
||||
$string['prunediscussion'] = 'Split discussion';
|
||||
$string['prunedpost'] = 'A new discussion has been created from that post';
|
||||
$string['pruneheading'] = 'Split the discussion and move this post to a new discussion';
|
||||
$string['qandaforum'] = 'Q and A forum';
|
||||
|
@ -4255,37 +4255,6 @@ function forum_change_discussionid($postid, $discussionid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the editing button on subscribers page
|
||||
*
|
||||
* @global object
|
||||
* @global object
|
||||
* @param int $courseid
|
||||
* @param int $forumid
|
||||
* @return string
|
||||
*/
|
||||
function forum_update_subscriptions_button($courseid, $forumid) {
|
||||
global $CFG, $USER;
|
||||
|
||||
if (!empty($USER->subscriptionsediting)) {
|
||||
$string = get_string('managesubscriptionsoff', 'forum');
|
||||
$edit = "off";
|
||||
} else {
|
||||
$string = get_string('managesubscriptionson', 'forum');
|
||||
$edit = "on";
|
||||
}
|
||||
|
||||
$subscribers = html_writer::start_tag('form', array('action' => $CFG->wwwroot . '/mod/forum/subscribers.php',
|
||||
'method' => 'get', 'class' => 'form-inline'));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => $string,
|
||||
'class' => 'btn btn-secondary'));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $forumid));
|
||||
$subscribers .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'edit', 'value' => $edit));
|
||||
$subscribers .= html_writer::end_tag('form');
|
||||
|
||||
return $subscribers;
|
||||
}
|
||||
|
||||
// Functions to do with read tracking.
|
||||
|
||||
/**
|
||||
|
@ -450,6 +450,8 @@ if (!empty($forum)) {
|
||||
$PAGE->navbar->add(get_string('delete', 'forum'));
|
||||
$PAGE->set_title($course->shortname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_secondary_active_tab('modulepage');
|
||||
$PAGE->activityheader->disable();
|
||||
|
||||
if ($replycount) {
|
||||
if (!has_capability('mod/forum:deleteanypost', $modcontext)) {
|
||||
@ -552,6 +554,8 @@ if (!empty($forum)) {
|
||||
|
||||
$PAGE->set_cm($cm);
|
||||
$PAGE->set_context($modcontext);
|
||||
$PAGE->set_secondary_active_tab('modulepage');
|
||||
$PAGE->activityheader->disable();
|
||||
|
||||
$prunemform = new mod_forum_prune_form(null, array('prune' => $prune, 'confirm' => $prune));
|
||||
|
||||
@ -632,7 +636,7 @@ if (!empty($forum)) {
|
||||
$course = $DB->get_record('course', array('id' => $forum->course));
|
||||
$subjectstr = format_string($post->subject, true);
|
||||
$PAGE->navbar->add($subjectstr, new moodle_url('/mod/forum/discuss.php', array('d' => $discussion->id)));
|
||||
$PAGE->navbar->add(get_string("prune", "forum"));
|
||||
$PAGE->navbar->add(get_string("prunediscussion", "forum"));
|
||||
$PAGE->set_title(format_string($discussion->name).": ".format_string($post->subject));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
@ -1077,24 +1081,32 @@ if (!empty($discussion->id)) {
|
||||
$PAGE->navbar->add($titlesubject, $urlfactory->get_discussion_view_url_from_discussion($discussionentity));
|
||||
}
|
||||
|
||||
if ($post->parent) {
|
||||
$PAGE->navbar->add(get_string('reply', 'forum'));
|
||||
}
|
||||
|
||||
if ($edit) {
|
||||
$PAGE->navbar->add(get_string('edit', 'forum'));
|
||||
$PAGE->navbar->add(get_string('editdiscussiontopic', 'forum'), $PAGE->url);
|
||||
} else if ($reply) {
|
||||
$PAGE->navbar->add(get_string('addreply', 'forum'));
|
||||
} else {
|
||||
$PAGE->navbar->add(get_string('addanewdiscussion', 'forum'), $PAGE->url);
|
||||
}
|
||||
|
||||
$PAGE->set_title("{$course->shortname}: {$strdiscussionname}{$titlesubject}");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_secondary_active_tab("modulepage");
|
||||
$activityheaderconfig['hidecompletion'] = true;
|
||||
if (!empty($parententity)) {
|
||||
$activityheaderconfig['description'] = '';
|
||||
}
|
||||
$activityheaderconfig['description'] = '';
|
||||
|
||||
// Remove the activity description.
|
||||
$PAGE->activityheader->set_attrs($activityheaderconfig);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($edit) {
|
||||
echo $OUTPUT->heading(get_string('editdiscussiontopic', 'forum'), 2);
|
||||
} else if ($reply) {
|
||||
echo $OUTPUT->heading(get_string('replypostdiscussion', 'forum'), 2);
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('addanewdiscussion', 'forum'), 2);
|
||||
}
|
||||
|
||||
// Checkup.
|
||||
if (!empty($parententity) && !$capabilitymanager->can_view_post($USER, $discussionentity, $parententity)) {
|
||||
print_error('cannotreply', 'forum');
|
||||
|
@ -120,7 +120,9 @@ class mod_forum_renderer extends plugin_renderer_base {
|
||||
$output = '';
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
if (!$users || !is_array($users) || count($users)===0) {
|
||||
$output .= $this->output->heading(get_string("nosubscribers", "forum"));
|
||||
$output .= $this->output->notification(
|
||||
get_string("nosubscribers", "forum"),
|
||||
\core\output\notification::NOTIFY_INFO, false);
|
||||
} else if (!isset($modinfo->instances['forum'][$forum->id])) {
|
||||
$output .= $this->output->heading(get_string("invalidmodule", "error"));
|
||||
} else {
|
||||
|
@ -377,7 +377,7 @@ class summary_table extends table_sql {
|
||||
public function print_nothing_to_display(): void {
|
||||
global $OUTPUT;
|
||||
|
||||
echo $OUTPUT->heading(get_string('nothingtodisplay'), 4);
|
||||
echo $OUTPUT->notification(get_string('nothingtodisplay'), \core\output\notification::NOTIFY_INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,6 @@ if ($download) {
|
||||
\forumreport_summary\event\report_viewed::create($eventparams)->trigger();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('summarytitle', 'forumreport_summary', $title), 2, 'pb-5');
|
||||
|
||||
if (!empty($filters['groups'])) {
|
||||
\core\notification::info(get_string('viewsdisclaimer', 'forumreport_summary'));
|
||||
@ -183,6 +182,7 @@ if ($download) {
|
||||
$forumselect = new single_select($reporturl, 'forumid', $forumselectoptions, $forumid, '');
|
||||
$forumselect->set_label(get_string('forumselectlabel', 'forumreport_summary'));
|
||||
echo $OUTPUT->render($forumselect);
|
||||
echo $OUTPUT->heading(get_string('nodetitle', 'forumreport_summary'), 2, 'pb-5 mt-3');
|
||||
|
||||
// Render the report filters form.
|
||||
$renderer = $PAGE->get_renderer('forumreport_summary');
|
||||
|
@ -223,9 +223,8 @@ echo html_writer::link($url, get_string('advancedsearch', 'forum').'...');
|
||||
|
||||
echo '</div>';
|
||||
|
||||
if (!$PAGE->has_secondary_navigation()) {
|
||||
echo $OUTPUT->heading($strforums, 2);
|
||||
}
|
||||
echo $OUTPUT->heading($strforums, 2);
|
||||
|
||||
echo $OUTPUT->heading("$strsearchresults: $totalcount", 3);
|
||||
|
||||
$url = new moodle_url('search.php', array('search' => $search, 'id' => $course->id, 'perpage' => $perpage));
|
||||
|
@ -40,6 +40,7 @@ $user = optional_param('user', 0, PARAM_INT); // The userid of
|
||||
$discussionid = optional_param('d', null, PARAM_INT); // The discussionid to subscribe.
|
||||
$sesskey = optional_param('sesskey', null, PARAM_RAW);
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
$edit = optional_param('edit', 'off', PARAM_ALPHANUM);
|
||||
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$id));
|
||||
if (!is_null($mode)) {
|
||||
@ -119,26 +120,28 @@ if ($returnurl) {
|
||||
$returnto = $returnurl;
|
||||
}
|
||||
|
||||
$subscribersurl = new moodle_url('/mod/forum/subscribers.php', ['id' => $id, 'edit' => $edit]);
|
||||
|
||||
if (!is_null($mode) and has_capability('mod/forum:managesubscriptions', $context)) {
|
||||
require_sesskey();
|
||||
switch ($mode) {
|
||||
case FORUM_CHOOSESUBSCRIBE : // 0
|
||||
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_CHOOSESUBSCRIBE);
|
||||
redirect(
|
||||
$returnto,
|
||||
$subscribersurl,
|
||||
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,
|
||||
$subscribersurl,
|
||||
get_string('everyoneisnowsubscribed', 'forum'),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
);
|
||||
break;
|
||||
case FORUM_INITIALSUBSCRIBE : // 2
|
||||
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_INITIALSUBSCRIBE);
|
||||
@ -151,20 +154,20 @@ if (!is_null($mode) and has_capability('mod/forum:managesubscriptions', $context
|
||||
}
|
||||
}
|
||||
redirect(
|
||||
$returnto,
|
||||
$subscribersurl,
|
||||
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,
|
||||
$subscribersurl,
|
||||
get_string('noonecansubscribenow', 'forum'),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
);
|
||||
break;
|
||||
default:
|
||||
print_error(get_string('invalidforcesubscribe', 'forum'));
|
||||
@ -172,12 +175,8 @@ if (!is_null($mode) and has_capability('mod/forum:managesubscriptions', $context
|
||||
}
|
||||
|
||||
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
|
||||
redirect(
|
||||
$returnto,
|
||||
get_string('everyoneisnowsubscribed', 'forum'),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
$subscribersurl->param('notification', 'everyoneisnowsubscribed');
|
||||
redirect($subscribersurl);
|
||||
}
|
||||
|
||||
$info = new stdClass();
|
||||
@ -209,11 +208,11 @@ if ($issubscribed) {
|
||||
if ($discussionid === null) {
|
||||
if (\mod_forum\subscriptions::unsubscribe_user($user->id, $forum, $context, true)) {
|
||||
redirect(
|
||||
$returnto,
|
||||
get_string('nownotsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
$returnto,
|
||||
get_string('nownotsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
} else {
|
||||
print_error('cannotunsubscribe', 'forum', get_local_referer(false));
|
||||
}
|
||||
@ -221,11 +220,11 @@ if ($issubscribed) {
|
||||
if (\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion, $context)) {
|
||||
$info->discussion = $discussion->name;
|
||||
redirect(
|
||||
$returnto,
|
||||
get_string('discussionnownotsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
$returnto,
|
||||
get_string('discussionnownotsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
} else {
|
||||
print_error('cannotunsubscribe', 'forum', get_local_referer(false));
|
||||
}
|
||||
@ -262,19 +261,19 @@ if ($issubscribed) {
|
||||
if ($discussionid == null) {
|
||||
\mod_forum\subscriptions::subscribe_user($user->id, $forum, $context, true);
|
||||
redirect(
|
||||
$returnto,
|
||||
get_string('nowsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
$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),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
$returnto,
|
||||
get_string('discussionnowsubscribed', 'forum', $info),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ $url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$id));
|
||||
if ($group !== 0) {
|
||||
$url->param('group', $group);
|
||||
}
|
||||
if ($edit !== 0) {
|
||||
|
||||
if ($edit === 1) {
|
||||
$url->param('edit', 'on');
|
||||
} else {
|
||||
$url->param('edit', 'off');
|
||||
@ -108,7 +109,7 @@ $PAGE->set_heading($COURSE->fullname);
|
||||
$PAGE->set_secondary_active_tab("forumsubscriptions");
|
||||
|
||||
// Output starts from here.
|
||||
$actionbar = new \mod_forum\output\subscription_actionbar($id, $url, $forum);
|
||||
$actionbar = new \mod_forum\output\subscription_actionbar($id, $url, $forum, $edit);
|
||||
$PAGE->activityheader->disable();
|
||||
echo $OUTPUT->header();
|
||||
if (!$PAGE->has_secondary_navigation()) {
|
||||
@ -116,14 +117,16 @@ if (!$PAGE->has_secondary_navigation()) {
|
||||
}
|
||||
echo $forumoutput->subscription_actionbar($actionbar);
|
||||
|
||||
if ($edit === 0) {
|
||||
if ($edit === 1 && !\mod_forum\subscriptions::is_forcesubscribed($forum)) {
|
||||
echo $OUTPUT->heading(get_string('managesubscriptionson', 'forum'), 2);
|
||||
echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('subscribers', 'forum'), 2);
|
||||
$subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
|
||||
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
|
||||
$subscribers = mod_forum_filter_hidden_users($cm, $context, $subscribers);
|
||||
}
|
||||
echo $forumoutput->subscriber_overview($subscribers, $forum, $course);
|
||||
} else {
|
||||
echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -366,9 +366,9 @@
|
||||
{{/can_create_discussion}}
|
||||
{{/state.hasdiscussions}}
|
||||
{{^state.hasdiscussions}}
|
||||
<div class="forumnodiscuss">
|
||||
<div class="forumnodiscuss alert alert-info">
|
||||
{{$no_discussions_text}}
|
||||
({{#str}}nodiscussions, forum{{/str}})
|
||||
{{#str}}nodiscussions, forum{{/str}}
|
||||
{{/no_discussions_text}}
|
||||
</div>
|
||||
{{/state.hasdiscussions}}
|
||||
|
@ -43,6 +43,7 @@
|
||||
"id": 1,
|
||||
"forumid": 1,
|
||||
"istimelocked": false,
|
||||
"settingsselector": true,
|
||||
"settings": {
|
||||
"excludetext": false,
|
||||
"togglemoreicon": false
|
||||
@ -50,24 +51,38 @@
|
||||
}
|
||||
}}
|
||||
<div class="ml-auto dropdown">
|
||||
<a href="#" class="{{^settings.excludetext}}dropdown-toggle{{/settings.excludetext}} btn btn-link {{#settings.togglemoreicon}}btn-icon colour-inherit text-decoration-none d-flex align-items-center justify-content-center{{/settings.togglemoreicon}}"
|
||||
role="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
tabindex="0"
|
||||
aria-controls="forum-action-menu-{{id}}-menu"
|
||||
aria-label="{{#str}}togglediscussionmenu, mod_forum{{/str}}"
|
||||
aria-expanded="false">
|
||||
{{#settings.togglemoreicon}}
|
||||
{{#pix}} i/menu, core{{/pix}}
|
||||
{{/settings.togglemoreicon}}
|
||||
{{^settings.togglemoreicon}}
|
||||
{{#pix}} i/settings, core{{/pix}}
|
||||
{{/settings.togglemoreicon}}
|
||||
{{^settings.excludetext}}
|
||||
{{#settingsselector}}
|
||||
<button class="dropdown-toggle btn btn-outline-secondary"
|
||||
role="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
tabindex="0"
|
||||
aria-controls="forum-action-menu-{{id}}-menu"
|
||||
aria-label="{{#str}}togglediscussionmenu, mod_forum{{/str}}"
|
||||
aria-expanded="false">
|
||||
{{#str}} settings, mod_forum {{/str}}
|
||||
{{/settings.excludetext}}
|
||||
</a>
|
||||
</button>
|
||||
{{/settingsselector}}
|
||||
{{^settingsselector}}
|
||||
<a href="#" class="{{^settings.excludetext}}dropdown-toggle{{/settings.excludetext}} btn btn-link {{#settings.togglemoreicon}}btn-icon colour-inherit text-decoration-none d-flex align-items-center justify-content-center{{/settings.togglemoreicon}}"
|
||||
role="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
tabindex="0"
|
||||
aria-controls="forum-action-menu-{{id}}-menu"
|
||||
aria-label="{{#str}}togglediscussionmenu, mod_forum{{/str}}"
|
||||
aria-expanded="false">
|
||||
{{#settings.togglemoreicon}}
|
||||
{{#pix}} i/menu, core{{/pix}}
|
||||
{{/settings.togglemoreicon}}
|
||||
{{^settings.togglemoreicon}}
|
||||
{{#pix}} i/settings, core{{/pix}}
|
||||
{{/settings.togglemoreicon}}
|
||||
{{^settings.excludetext}}
|
||||
{{#str}} settings, mod_forum {{/str}}
|
||||
{{/settings.excludetext}}
|
||||
</a>
|
||||
{{/settingsselector}}
|
||||
<div class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="forum-action-menu-{{id}}-menu"
|
||||
data-rel="menu-content"
|
||||
|
@ -32,21 +32,17 @@
|
||||
|
||||
<div id="discussion-container-{{uniqid}}" data-content="forum-discussion">
|
||||
{{#html}}
|
||||
{{#hasanyactions}}
|
||||
<div class="d-flex flex-wrap flex-row-reverse mb-3 text-right" data-container="discussion-tools">
|
||||
<div class="pl-1">
|
||||
<div class="discussion-settings-menu">
|
||||
{{> mod_forum/forum_action_menu}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/hasanyactions}}
|
||||
{{{neighbourlinks}}}
|
||||
|
||||
<div class="d-flex flex-wrap mb-1">
|
||||
<div class="d-flex flex-row mb-1">
|
||||
<div>{{{exportdiscussion}}}</div>
|
||||
<div class="{{#exportdiscussion}}ml-2{{/exportdiscussion}}">{{{modeselectorform}}}</div>
|
||||
<div class="ml-2">{{{movediscussion}}}</div>
|
||||
{{#hasanyactions}}
|
||||
<div class="drop-down ml-auto" data-container="discussion-tools">
|
||||
{{> mod_forum/forum_action_menu}}
|
||||
</div>
|
||||
{{/hasanyactions}}
|
||||
</div>
|
||||
{{/html}}
|
||||
|
||||
|
56
mod/forum/tests/behat/forum_activity_breadcrumbs.feature
Normal file
56
mod/forum/tests/behat/forum_activity_breadcrumbs.feature
Normal file
@ -0,0 +1,56 @@
|
||||
@mod @mod_forum @javascript
|
||||
Feature: A teacher or admin can view breadcrumbs in the reply, delete, split, edit and add discussion advanced pages
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher | Teacher | Tom | teacher@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher | C1 | editingteacher |
|
||||
And the following "activity" exists:
|
||||
| course | C1 |
|
||||
| activity | forum |
|
||||
| intro | Test forum description |
|
||||
| name | Test forum name |
|
||||
|
||||
Scenario: A teacher views add discussion topics advanced page
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
And I click on "Add discussion topic" "link"
|
||||
When I click on "Advanced" "button"
|
||||
And I should see "Add discussion topic"
|
||||
Then I should see "Add discussion topic" in the ".breadcrumb" "css_element"
|
||||
And I should see "Test forum name" in the ".breadcrumb" "css_element"
|
||||
|
||||
Scenario: A teacher adds posts and then verifies the breadcrumbs in the links
|
||||
Given I log in as "teacher"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a new discussion to "Test forum name" forum with:
|
||||
| Subject | Test post subject one |
|
||||
| Message | Test post message one |
|
||||
And I reply "Test post subject one" post from "Test forum name" forum with:
|
||||
| Subject | Reply 1 to discussion 1 |
|
||||
| Message | Discussion contents 1, second message |
|
||||
And I should see "Settings" in the "//div[@class='ml-auto dropdown']" "xpath_element"
|
||||
When I follow "Edit"
|
||||
Then I should see "Edit discussion topic"
|
||||
And I should see "Edit discussion topic" in the ".breadcrumb" "css_element"
|
||||
And I should see "Test post subject one" in the ".breadcrumb" "css_element"
|
||||
And I click on "Cancel" "button"
|
||||
And I follow "Delete"
|
||||
And I should not see "Test forum description"
|
||||
And I should see "Delete" in the ".breadcrumb" "css_element"
|
||||
And I click on "Cancel" "button"
|
||||
And I follow "Reply"
|
||||
And I click on "Advanced" "button"
|
||||
And I should not see "Test forum description"
|
||||
And I should see "Reply to discussion"
|
||||
And I should see "Add reply" in the ".breadcrumb" "css_element"
|
||||
And I click on "Cancel" "button"
|
||||
And I follow "Split"
|
||||
And I should not see "Test forum description"
|
||||
And I should see "Split discussion" in the ".breadcrumb" "css_element"
|
||||
And I click on "Cancel" "button"
|
56
mod/forum/tests/behat/forum_subscribers_navigation.feature
Normal file
56
mod/forum/tests/behat/forum_subscribers_navigation.feature
Normal file
@ -0,0 +1,56 @@
|
||||
@mod @mod_forum @javascript
|
||||
Feature: A teacher or admin can view subscriptions tab
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher | Teacher | Tom | teacher@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher | C1 | editingteacher |
|
||||
And the following "activity" exists:
|
||||
| course | C1 |
|
||||
| activity | forum |
|
||||
| intro | Test forum description |
|
||||
| name | Test forum name |
|
||||
|
||||
Scenario: A teacher views view subscribers by default and views the Subscribers heading
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
When I navigate to "Subscriptions" in current page administration
|
||||
Then I should see "View subscribers" in the "//div[@class='urlselect']//option[@selected]" "xpath_element"
|
||||
And I should see "Subscribers"
|
||||
And I should see "There are no subscribers yet for this forum"
|
||||
|
||||
Scenario: A teacher selects forced subscription and subscribers selector is not visible
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
And I navigate to "Subscriptions" in current page administration
|
||||
When I select "Forced subscription" from the "Subscription mode" singleselect
|
||||
And I should see "Everyone is now subscribed to this forum"
|
||||
Then I should not see "View subscribers"
|
||||
And I should not see "Manage subscribers"
|
||||
And I should not see "Manage subscribers"
|
||||
# Now select Optional subscription
|
||||
And I select "Optional subscription" from the "Subscription mode" singleselect
|
||||
And I should see "Everyone can now choose to be subscribed"
|
||||
And I should see "View subscribers"
|
||||
|
||||
Scenario: A teacher selects forced subscription and subscribers selector is not visible
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
And I navigate to "Subscriptions" in current page administration
|
||||
When I select "Manage subscribers" from the "jump" singleselect
|
||||
And I should see "Manage subscribers"
|
||||
Then "Subscription mode" "select" should not exist
|
||||
And I should not see "Optional subscription"
|
||||
And I should not see "Forced subscription"
|
||||
And I should not see "Auto subscription"
|
||||
And I should not see "Subscription disabled"
|
||||
|
||||
Scenario: A teacher selects reports tab and verify the heading
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
And I should see "There are no discussion topics yet in this forum" in the "//div[contains(@class, 'alert-info')]" "xpath_element"
|
||||
And I navigate to "Reports" in current page administration
|
||||
And I should see "Forum summary report"
|
||||
And I should see "Nothing to display" in the "//div[contains(@class, 'alert-info')]" "xpath_element"
|
@ -0,0 +1,27 @@
|
||||
@mod @mod_forum @javascript
|
||||
Feature: A teacher or admin when changes the subscription mode should land in the subscriptions tab
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher | Teacher | Tom | teacher@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher | C1 | editingteacher |
|
||||
And the following "activity" exists:
|
||||
| course | C1 |
|
||||
| activity | forum |
|
||||
| intro | Test forum description |
|
||||
| name | Test forum name |
|
||||
|
||||
Scenario: A teacher views subscriptions tab and changes the subscriptions mode to forced mode and lands in subscription tab
|
||||
Given I am on the "Test forum name" "forum activity" page logged in as teacher
|
||||
And I navigate to "Subscriptions" in current page administration
|
||||
When I select "Forced subscription" from the "Subscription mode" singleselect
|
||||
And I should see "Everyone is now subscribed to this forum"
|
||||
Then I should see "Forced subscription"
|
||||
And I should not see "View subscribers"
|
||||
And I should not see "Manage subscribers"
|
@ -83,7 +83,6 @@ Feature: As a teacher I need to see an accurate list of subscribed users
|
||||
And I should see "Student 1"
|
||||
And I should see "Student 2"
|
||||
And I should see "Student 3"
|
||||
And the "Subscribers" select box should contain "View subscribers"
|
||||
|
||||
Scenario: A forced and hidden forum lists only teachers
|
||||
Given the following "activity" exists:
|
||||
|
@ -46,9 +46,8 @@ Feature: A teacher can control the subscription to a forum
|
||||
| type | general |
|
||||
| forcesubscribe | <initialmode> |
|
||||
When I am on the "Test forum" "forum activity" page logged in as "teacher"
|
||||
And I navigate to "Subscription mode > <updatedmode>" in current page administration
|
||||
And I should see "Are you sure you want to change the subscription mode to <updatedmode>" in the "Confirmation" "dialogue"
|
||||
And I click on "Yes" "button" in the "Confirmation" "dialogue"
|
||||
And I navigate to "Subscriptions" in current page administration
|
||||
And I select "<updatedmode>" from the "Subscription mode" singleselect
|
||||
Then I should see "<updatedmodeconfirmed>"
|
||||
Examples:
|
||||
| initialmode | updatedmode | updatedmodeconfirmed |
|
||||
|
@ -23,6 +23,8 @@ information provided here is intended especially for developers.
|
||||
* forum_print_posts_nested
|
||||
* forum_print_latest_discussions
|
||||
* forum_get_user_grades
|
||||
* The method forum_update_subscriptions_button() has been deprecated as it is no longer used.
|
||||
The 'Manage subscribers' button has been replaced with tertiary navigation.
|
||||
|
||||
=== 3.11 ===
|
||||
|
||||
|
@ -107,11 +107,6 @@ $PAGE->add_body_class('forumtype-' . $forum->get_type());
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->add_header_action(forum_search_form($course, $search));
|
||||
|
||||
// MDL-71915 Will remove this place holder.
|
||||
if (defined('BEHAT_SITE_RUNNING')) {
|
||||
$PAGE->has_secondary_navigation_setter(false);
|
||||
}
|
||||
|
||||
if ($istypesingle && $displaymode == FORUM_MODE_NESTED_V2) {
|
||||
$PAGE->add_body_class('nested-v2-display-mode reset-style');
|
||||
$settingstrigger = $OUTPUT->render_from_template('mod_forum/settings_drawer_trigger', null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user