Skip to content

Commit

Permalink
MDL-51998 Forum: Move subscription update button into page (from navbar)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavkav committed Mar 30, 2017
1 parent 216ea39 commit 29f504d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions mod/forum/lang/en/forum.php
Expand Up @@ -286,6 +286,8 @@
$string['longpost'] = 'Long post';
$string['mailnow'] = 'Send forum post notifications with no editing-time delay';
$string['manydiscussions'] = 'Discussions per page';
$string['managesubscriptionsoff'] = 'Finish managing subscriptions';
$string['managesubscriptionson'] = 'Manage subscriptions';
$string['markalldread'] = 'Mark all posts in this discussion read.';
$string['markallread'] = 'Mark all posts in this forum read.';
$string['markasreadonnotification'] = 'When sending forum post notifications';
Expand Down
17 changes: 11 additions & 6 deletions mod/forum/lib.php
Expand Up @@ -6057,17 +6057,22 @@ function forum_update_subscriptions_button($courseid, $forumid) {
global $CFG, $USER;

if (!empty($USER->subscriptionsediting)) {
$string = get_string('turneditingoff');
$string = get_string('managesubscriptionsoff', 'forum');
$edit = "off";
} else {
$string = get_string('turneditingon');
$string = get_string('managesubscriptionson', 'forum');
$edit = "on";
}

return "<form method=\"get\" action=\"$CFG->wwwroot/mod/forum/subscribers.php\">".
"<input type=\"hidden\" name=\"id\" value=\"$forumid\" />".
"<input type=\"hidden\" name=\"edit\" value=\"$edit\" />".
"<input type=\"submit\" value=\"$string\" /></form>";
$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.
Expand Down
9 changes: 8 additions & 1 deletion mod/forum/subscribers.php
Expand Up @@ -104,12 +104,16 @@
if ($edit != -1) {
$USER->subscriptionsediting = $edit;
}
$PAGE->set_button(forum_update_subscriptions_button($course->id, $id));
$updatesubscriptionsbutton = forum_update_subscriptions_button($course->id, $id);
} else {
$updatesubscriptionsbutton = '';
unset($USER->subscriptionsediting);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('forum', 'forum').' '.$strsubscribers);
if (!empty($updatesubscriptionsbutton)) {
echo \html_writer::div($updatesubscriptionsbutton, 'pull-right');
}
if (empty($USER->subscriptionsediting)) {
$subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
Expand All @@ -119,6 +123,9 @@
} else {
echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
}
if (!empty($updatesubscriptionsbutton)) {
echo $updatesubscriptionsbutton;
}
echo $OUTPUT->footer();

/**
Expand Down

0 comments on commit 29f504d

Please sign in to comment.