mirror of
https://github.com/moodle/moodle.git
synced 2025-02-08 17:11:49 +01:00
coding style changes MDL-6961
This commit is contained in:
parent
296c2a79e8
commit
0e52f01f0e
@ -6,19 +6,17 @@
|
||||
require_once('lib.php');
|
||||
require_once('post_form.php');
|
||||
|
||||
$reply = optional_param('reply', 0, PARAM_INT);
|
||||
$forum = optional_param('forum', 0, PARAM_INT);
|
||||
$edit = optional_param('edit', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$prune = optional_param('prune', 0, PARAM_INT);
|
||||
$name = optional_param('name', '', PARAM_CLEAN);
|
||||
$reply = optional_param('reply', 0, PARAM_INT);
|
||||
$forum = optional_param('forum', 0, PARAM_INT);
|
||||
$edit = optional_param('edit', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$prune = optional_param('prune', 0, PARAM_INT);
|
||||
$name = optional_param('name', '', PARAM_CLEAN);
|
||||
$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->course = $course->id;
|
||||
$post->forum = $forum->id;
|
||||
$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->userid = $USER->id;
|
||||
$post->message = "";
|
||||
$post->parent = 0;
|
||||
$post->subject = '';
|
||||
$post->userid = $USER->id;
|
||||
$post->message = '';
|
||||
|
||||
$post->groupid = get_current_group($course->id);
|
||||
if ($post->groupid == 0) {
|
||||
@ -158,13 +158,14 @@
|
||||
|
||||
// Load up the $post variable.
|
||||
|
||||
$post->course = $course->id;
|
||||
$post->forum = $forum->id;
|
||||
$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->parent = $parent->id;
|
||||
$post->subject = $parent->subject;
|
||||
$post->userid = $USER->id;
|
||||
$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;
|
||||
// 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,23 +359,25 @@
|
||||
|
||||
if (!empty($name)) { // User has confirmed the prune
|
||||
|
||||
$newdiscussion->course = $discussion->course;
|
||||
$newdiscussion->forum = $discussion->forum;
|
||||
$newdiscussion->name = $name;
|
||||
$newdiscussion->firstpost = $post->id;
|
||||
$newdiscussion->userid = $discussion->userid;
|
||||
$newdiscussion->groupid = $discussion->groupid;
|
||||
$newdiscussion->assessed = $discussion->assessed;
|
||||
$newdiscussion = new object();
|
||||
$newdiscussion->course = $discussion->course;
|
||||
$newdiscussion->forum = $discussion->forum;
|
||||
$newdiscussion->name = $name;
|
||||
$newdiscussion->firstpost = $post->id;
|
||||
$newdiscussion->userid = $discussion->userid;
|
||||
$newdiscussion->groupid = $discussion->groupid;
|
||||
$newdiscussion->assessed = $discussion->assessed;
|
||||
$newdiscussion->usermodified = $post->userid;
|
||||
$newdiscussion->timestart = $discussion->timestart;
|
||||
$newdiscussion->timeend = $discussion->timeend;
|
||||
$newdiscussion->timestart = $discussion->timestart;
|
||||
$newdiscussion->timeend = $discussion->timeend;
|
||||
|
||||
if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
|
||||
error('Could not create new discussion');
|
||||
}
|
||||
|
||||
$newpost->id = $post->id;
|
||||
$newpost->parent = 0;
|
||||
$newpost = new object();
|
||||
$newpost->id = $post->id;
|
||||
$newpost->parent = 0;
|
||||
$newpost->subject = $name;
|
||||
|
||||
if (!update_record("forum_posts", $newpost)) {
|
||||
@ -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()) {
|
||||
|
||||
@ -702,16 +708,16 @@
|
||||
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum);
|
||||
}
|
||||
}
|
||||
$heading=get_string("yourreply", "forum");
|
||||
$heading = get_string("yourreply", "forum");
|
||||
} else {
|
||||
$forum->intro = trim($forum->intro);
|
||||
if (!empty($forum->intro)) {
|
||||
print_simple_box(format_text($forum->intro), 'center');
|
||||
}
|
||||
if ($forum->type == 'qanda') {
|
||||
$heading=get_string('yournewquestion', 'forum');
|
||||
$heading = get_string('yournewquestion', 'forum');
|
||||
} else {
|
||||
$heading=get_string('yournewtopic', 'forum');
|
||||
$heading = get_string('yournewtopic', 'forum');
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
require_once ($CFG->libdir.'/formslib.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"');
|
||||
//later using set_defaults
|
||||
$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)) {
|
||||
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");
|
||||
has_capability('moodle/course:manageactivities', $coursecontext)) {
|
||||
$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"));
|
||||
$timestartgroup=array();
|
||||
$timestartgroup[]=&MoodleQuickForm::createElement('date_selector', 'timestart', get_string('timestartday', 'forum'));
|
||||
$timestartgroup[]=&MoodleQuickForm::createElement('checkbox', 'timestartdisabled', '', get_string('disable'));
|
||||
$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"));
|
||||
$timeendgroup=array();
|
||||
$timeendgroup[]=&MoodleQuickForm::createElement('date_selector', 'timeend', get_string('timeendday', 'forum'));
|
||||
$timeendgroup[]=&MoodleQuickForm::createElement('checkbox', 'timeenddisabled', '', get_string('disable'));
|
||||
$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);
|
||||
@ -75,10 +81,10 @@ class forum_post_form extends moodleform {
|
||||
$mform->setType('timeenddisabled', PARAM_INT);
|
||||
|
||||
}
|
||||
if(isset($post->edit)){
|
||||
$submit_string=get_string('savechanges');
|
||||
}else{
|
||||
$submit_string=get_string('posttoforum', 'forum');
|
||||
if (isset($post->edit)) {
|
||||
$submit_string = get_string('savechanges');
|
||||
} else {
|
||||
$submit_string = get_string('posttoforum', 'forum');
|
||||
}
|
||||
$mform->addElement('submit', 'submit', $submit_string);
|
||||
$renderer->addStopFieldsetElements('submit');
|
||||
@ -109,13 +115,13 @@ class forum_post_form extends moodleform {
|
||||
|
||||
}
|
||||
|
||||
function validation($data){
|
||||
$error=array();
|
||||
function validation($data) {
|
||||
$error = array();
|
||||
if (empty($data['timeenddisabled']) && empty($data['timestartdisabled'])
|
||||
&& $data['timeend'] <= $data['timestart']) {
|
||||
$error['timeendgroup'] = get_string('timestartenderror', 'forum');
|
||||
}
|
||||
return (count($error)==0)?true:$error;
|
||||
return (count($error)==0) ? true : $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user