Merge branch 'MDL-53634-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
+7
-14
@@ -48,7 +48,6 @@ require_course_login($course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
|
||||
unset($SESSION->fromdiscussion);
|
||||
|
||||
$params = array(
|
||||
@@ -77,8 +76,7 @@ $stremaildigest = get_string('emaildigest');
|
||||
|
||||
$searchform = forum_search_form($course);
|
||||
|
||||
// Start of the table for General Forums
|
||||
|
||||
// Start of the table for General Forums.
|
||||
$generaltable = new html_table();
|
||||
$generaltable->head = array ($strforum, $strdescription, $strdiscussions);
|
||||
$generaltable->align = array ('left', 'left', 'center');
|
||||
@@ -501,20 +499,15 @@ echo $OUTPUT->footer();
|
||||
* @return string
|
||||
*/
|
||||
function forum_index_get_forum_subscription_selector($forum) {
|
||||
global $OUTPUT;
|
||||
global $OUTPUT, $PAGE;
|
||||
|
||||
if ($forum->cansubscribe || $forum->issubscribed) {
|
||||
$digestoptionsselector = new single_select(new moodle_url('/mod/forum/maildigest.php', [
|
||||
'id' => $forum->id,
|
||||
'backtoindex' => 1,
|
||||
]),
|
||||
'maildigest',
|
||||
forum_get_user_digest_options(),
|
||||
$forum->maildigest !== null ? $forum->maildigest : -1,
|
||||
'');
|
||||
$digestoptionsselector->method = 'post';
|
||||
if ($forum->maildigest === null) {
|
||||
$forum->maildigest = -1;
|
||||
}
|
||||
|
||||
return $OUTPUT->render($digestoptionsselector);
|
||||
$renderer = $PAGE->get_renderer('mod_forum');
|
||||
return $OUTPUT->render($renderer->render_digest_options($forum, $forum->maildigest));
|
||||
} else {
|
||||
// This user can subscribe to some forums. Add the empty fields.
|
||||
return '';
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
subscribersto,mod_forum
|
||||
postmailinfo,mod_forum
|
||||
emaildigestupdated,mod_forum
|
||||
emaildigestupdated_default,mod_forum
|
||||
emaildigest_0,mod_forum
|
||||
emaildigest_1,mod_forum
|
||||
emaildigest_2,mod_forum
|
||||
|
||||
@@ -195,11 +195,6 @@ $string['emaildigesttype_help'] = 'The type of notification that you will receiv
|
||||
* Digest - complete posts - you will receive one digest e-mail per day containing the complete contents of each forum post;
|
||||
* Digest - subjects only - you will receive one digest e-mail per day containing just the subject of each forum post.
|
||||
';
|
||||
$string['emaildigestupdated'] = 'The e-mail digest option was changed to \'{$a->maildigesttitle}\' for the forum \'{$a->forum}\'. {$a->maildigestdescription}';
|
||||
$string['emaildigestupdated_default'] = 'Your default profile setting of \'{$a->maildigesttitle}\' was used for the forum \'{$a->forum}\'. {$a->maildigestdescription}.';
|
||||
$string['emaildigest_0'] = 'You will receive one e-mail per forum post.';
|
||||
$string['emaildigest_1'] = 'You will receive one digest e-mail per day containing the complete contents of each forum post.';
|
||||
$string['emaildigest_2'] = 'You will receive one digest e-mail per day containing the subject of each forum post.';
|
||||
$string['emptymessage'] = 'Something was wrong with your post. Perhaps you left it blank, or the attachment was too big. Your changes have NOT been saved.';
|
||||
$string['erroremptymessage'] = 'Post message cannot be empty';
|
||||
$string['erroremptysubject'] = 'Post subject cannot be empty.';
|
||||
@@ -542,3 +537,8 @@ $string['subscribersto'] = 'Subscribers to "{$a->name}"';
|
||||
$string['postmailinfo'] = 'This is a copy of a message posted on the {$a} website.
|
||||
|
||||
To reply click on this link:';
|
||||
$string['emaildigestupdated'] = 'The e-mail digest option was changed to \'{$a->maildigesttitle}\' for the forum \'{$a->forum}\'. {$a->maildigestdescription}';
|
||||
$string['emaildigestupdated_default'] = 'Your default profile setting of \'{$a->maildigesttitle}\' was used for the forum \'{$a->forum}\'. {$a->maildigestdescription}.';
|
||||
$string['emaildigest_0'] = 'You will receive one e-mail per forum post.';
|
||||
$string['emaildigest_1'] = 'You will receive one digest e-mail per day containing the complete contents of each forum post.';
|
||||
$string['emaildigest_2'] = 'You will receive one digest e-mail per day containing the subject of each forum post.';
|
||||
|
||||
@@ -7992,3 +7992,30 @@ function forum_is_author_hidden($post, $forum) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage inplace editable saves.
|
||||
*
|
||||
* @param string $itemtype The type of item.
|
||||
* @param int $itemid The ID of the item.
|
||||
* @param mixed $newvalue The new value
|
||||
* @return string
|
||||
*/
|
||||
function mod_forum_inplace_editable($itemtype, $itemid, $newvalue) {
|
||||
global $DB, $PAGE;
|
||||
|
||||
if ($itemtype === 'digestoptions') {
|
||||
// The itemid is the forumid.
|
||||
$forum = $DB->get_record('forum', array('id' => $itemid), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$PAGE->set_context($context);
|
||||
require_login($course, false, $cm);
|
||||
forum_set_user_maildigest($forum, $newvalue);
|
||||
|
||||
$renderer = $PAGE->get_renderer('mod_forum');
|
||||
return $renderer->render_digest_options($forum, $newvalue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,4 +203,27 @@ class mod_forum_renderer extends plugin_renderer_base {
|
||||
public function forum_post_template() {
|
||||
return 'forum_post';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the inplace_editable used to select forum digest options.
|
||||
*
|
||||
* @param stdClass $forum The forum to create the editable for.
|
||||
* @param int $value The current value for this user
|
||||
* @return inplace_editable
|
||||
*/
|
||||
public function render_digest_options($forum, $value) {
|
||||
$options = forum_get_user_digest_options();
|
||||
$editable = new \core\output\inplace_editable(
|
||||
'mod_forum',
|
||||
'digestoptions',
|
||||
$forum->id,
|
||||
true,
|
||||
$options[$value],
|
||||
$value
|
||||
);
|
||||
|
||||
$editable->set_type_select($options);
|
||||
|
||||
return $editable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user