mirror of
https://github.com/moodle/moodle.git
synced 2025-02-09 01:21:57 +01:00
coding style changes MDL-6961
This commit is contained in:
parent
296c2a79e8
commit
0e52f01f0e
@ -15,10 +15,8 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
|
||||
|
||||
$page_params=array('reply'=>$reply,
|
||||
'forum'=>$forum,
|
||||
'edit'=>$edit); //these page_params will be passed as hidden variables
|
||||
//later in the form.
|
||||
//these page_params will be passed as hidden variables later in the form.
|
||||
$page_params = array('reply'=>$reply, 'forum'=>$forum, 'edit'=>$edit);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
@ -72,6 +70,7 @@
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
require_login(0, false); // Script is useless unless they're logged in
|
||||
|
||||
if (!empty($forum)) { // User is starting a new discussion in a forum
|
||||
@ -103,13 +102,14 @@
|
||||
|
||||
// Load up the $post variable.
|
||||
|
||||
$post = new object();
|
||||
$post->course = $course->id;
|
||||
$post->forum = $forum->id;
|
||||
$post->discussion = 0; // ie discussion # not defined yet
|
||||
$post->parent = 0;
|
||||
$post->subject = "";
|
||||
$post->subject = '';
|
||||
$post->userid = $USER->id;
|
||||
$post->message = "";
|
||||
$post->message = '';
|
||||
|
||||
$post->groupid = get_current_group($course->id);
|
||||
if ($post->groupid == 0) {
|
||||
@ -158,13 +158,14 @@
|
||||
|
||||
// Load up the $post variable.
|
||||
|
||||
$post = new object();
|
||||
$post->course = $course->id;
|
||||
$post->forum = $forum->id;
|
||||
$post->discussion = $parent->discussion;
|
||||
$post->parent = $parent->id;
|
||||
$post->subject = $parent->subject;
|
||||
$post->userid = $USER->id;
|
||||
$post->message = "";
|
||||
$post->message = '';
|
||||
|
||||
$strre = get_string('re', 'forum');
|
||||
if (!(substr($post->subject, 0, strlen($strre)) == $strre)) {
|
||||
@ -172,6 +173,7 @@
|
||||
}
|
||||
|
||||
unset($SESSION->fromdiscussion);
|
||||
|
||||
} else if (!empty($edit)) { // User is editing their own post
|
||||
|
||||
if (! $post = forum_get_post_full($edit)) {
|
||||
@ -208,12 +210,14 @@
|
||||
error("You can't edit other people's posts!");
|
||||
}
|
||||
|
||||
|
||||
// Load up the $post variable.
|
||||
$post->edit = $edit;
|
||||
|
||||
$post->course = $course->id;
|
||||
$post->forum = $forum->id;
|
||||
|
||||
trusttext_prepare_edit($post->message, $post->format, can_use_html_editor(), $modcontext);
|
||||
|
||||
unset($SESSION->fromdiscussion);
|
||||
|
||||
|
||||
@ -355,6 +359,7 @@
|
||||
|
||||
if (!empty($name)) { // User has confirmed the prune
|
||||
|
||||
$newdiscussion = new object();
|
||||
$newdiscussion->course = $discussion->course;
|
||||
$newdiscussion->forum = $discussion->forum;
|
||||
$newdiscussion->name = $name;
|
||||
@ -370,6 +375,7 @@
|
||||
error('Could not create new discussion');
|
||||
}
|
||||
|
||||
$newpost = new object();
|
||||
$newpost->id = $post->id;
|
||||
$newpost->parent = 0;
|
||||
$newpost->subject = $name;
|
||||
@ -419,7 +425,7 @@
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $forum->course);
|
||||
}
|
||||
|
||||
$mform_post = new forum_post_form('post.php', compact('coursecontext', 'forum', 'post'));
|
||||
$mform_post = new forum_post_form('post.php', array('coursecontext'=>$coursecontext, 'forum'=>$forum, 'post'=>$post));
|
||||
|
||||
if ($fromform = $mform_post->data_submitted()) {
|
||||
|
||||
@ -732,8 +738,6 @@
|
||||
(!empty($USER->autosubscribe));
|
||||
|
||||
|
||||
trusttext_prepare_edit($post->message, $post->format, can_use_html_editor(), $modcontext);
|
||||
|
||||
$mform_post->set_defaults(array( 'general'=>$heading,
|
||||
'subject'=>$post->subject,
|
||||
'message'=>$post->message,
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class forum_post_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
@ -8,46 +10,47 @@ class forum_post_form extends moodleform {
|
||||
$mform =& $this->_form;
|
||||
$renderer =& $mform->defaultRenderer();
|
||||
|
||||
extract($this->_customdata);
|
||||
$coursecontext = $this->_customdata['coursecontext'];
|
||||
$forum = $this->_customdata['forum'];
|
||||
$post = $this->_customdata['post'];
|
||||
|
||||
|
||||
$mform->addElement('header', 'general', '');//fill in the data depending on page params
|
||||
//later using set_defaults
|
||||
$mform->addElement('text', 'subject', get_string("subject", "forum"), 'size="60"');
|
||||
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="60"');
|
||||
$mform->setType('subject', PARAM_TEXT);
|
||||
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
|
||||
|
||||
$mform->addElement('htmleditor', 'message', get_string("message", "forum"));
|
||||
$mform->addElement('htmleditor', 'message', get_string('message', 'forum'));
|
||||
$mform->setType('message', PARAM_RAW);
|
||||
$mform->addRule('message', get_string('required'), 'required', null, 'client');
|
||||
|
||||
$mform->addElement('format', 'format', get_string('format'));
|
||||
$mform->setHelpButton('format', array("textformat", get_string("helpformatting")));
|
||||
$mform->setHelpButton('format', array('textformat', get_string('helpformatting')));
|
||||
|
||||
|
||||
if (isset($forum->id) && forum_is_forcesubscribed($forum->id)) {
|
||||
|
||||
$mform->addElement('static', 'subscribemessage', get_string("subscription", "forum"), get_string("everyoneissubscribed", "forum"));
|
||||
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
|
||||
$mform->addElement('hidden', 'subscribe');
|
||||
$mform->setHelpButton('subscribemessage', array("subscription", get_string("subscription", "forum"), "forum"));
|
||||
$mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
|
||||
|
||||
} else if (isset($forum->forcesubscribe)&& $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE ||
|
||||
has_capability('moodle/course:manageactivities', $coursecontext)) {
|
||||
unset($options);
|
||||
$options[0] = get_string("subscribestop", "forum");
|
||||
$options[1] = get_string("subscribestart", "forum");
|
||||
$options = array();
|
||||
$options[0] = get_string('subscribestop', 'forum');
|
||||
$options[1] = get_string('subscribestart', 'forum');
|
||||
|
||||
$mform->addElement('select', 'subscribe', get_string("subscription", "forum"), $options);
|
||||
$mform->setHelpButton('subscribe', array("subscription", get_string("subscription", "forum"), "forum"));
|
||||
$mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
|
||||
$mform->setHelpButton('subscribe', array('subscription', get_string('subscription', 'forum'), 'forum'));
|
||||
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
|
||||
$mform->addElement('static', 'subscribemessage', get_string("subscription", "forum"), get_string('disallowsubscribe', 'forum'));
|
||||
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
|
||||
$mform->addElement('hidden', 'subscribe');
|
||||
$mform->setHelpButton('subscribemessage', array("subscription", get_string("subscription", "forum"), "forum"));
|
||||
$mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
|
||||
}
|
||||
|
||||
if (empty($post->id)
|
||||
&& has_capability('moodle/course:manageactivities', $coursecontext)) {
|
||||
$mform->addElement('checkbox', 'mailnow', get_string("mailnow", "forum"));
|
||||
if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
|
||||
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
|
||||
}
|
||||
|
||||
if (!isset($discussion->timestart)) {
|
||||
@ -57,17 +60,20 @@ class forum_post_form extends moodleform {
|
||||
$discussion->timeend = 0;
|
||||
}
|
||||
if (!empty($CFG->forum_enabletimedposts) && !$post->parent) {
|
||||
$mform->addElement('header','', get_string("displayperiod", "forum"));
|
||||
$mform->addElement('header', '', get_string('displayperiod', 'forum'));
|
||||
|
||||
$timestartgroup = array();
|
||||
$timestartgroup[] = &MoodleQuickForm::createElement('date_selector', 'timestart', get_string('timestartday', 'forum'));
|
||||
$timestartgroup[] = &MoodleQuickForm::createElement('checkbox', 'timestartdisabled', '', get_string('disable'));
|
||||
$mform->addGroup($timestartgroup, 'timestartgroup', get_string('displaystart', 'forum'), ' ', false);
|
||||
$mform->setHelpButton('timestartgroup', array("displayperiod", get_string("displayperiod", "forum"), "forum"));
|
||||
$mform->setHelpButton('timestartgroup', array('displayperiod', get_string('displayperiod', 'forum'), 'forum'));
|
||||
|
||||
$timeendgroup = array();
|
||||
$timeendgroup[] = &MoodleQuickForm::createElement('date_selector', 'timeend', get_string('timeendday', 'forum'));
|
||||
$timeendgroup[] = &MoodleQuickForm::createElement('checkbox', 'timeenddisabled', '', get_string('disable'));
|
||||
$mform->addGroup($timeendgroup, 'timeendgroup', get_string('displayend', 'forum'), ' ', false);
|
||||
$mform->setHelpButton('timeendgroup', array("displayperiod", get_string("displayperiod", "forum"), "forum"));
|
||||
$mform->setHelpButton('timeendgroup', array('displayperiod', get_string('displayperiod', 'forum'), 'forum'));
|
||||
|
||||
} else {
|
||||
$mform->addElement('hidden', 'timestartdisabled', '1');
|
||||
$mform->setType('timestartdisabled', PARAM_INT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user