removed redundant return
[moodle.git] / mod / forum / mod_form.php
CommitLineData
535e0ab6 1<?php
2require_once ($CFG->libdir.'/formslib.php');
3class forum_mod_form extends moodleform_mod {
4
5 function definition() {
6
a02c77dc 7 global $CFG, $FORUM_TYPES, $COURSE;
535e0ab6 8 $mform =& $this->_form;
9 $renderer =& $mform->defaultRenderer();
535e0ab6 10
11//-------------------------------------------------------------------------------
12 $mform->addElement('header', 'general', get_string('general', 'form'));
13
14 $mform->addElement('text', 'name', get_string('forumname', 'forum'));
15 $mform->setType('name', PARAM_TEXT);
16 $mform->addRule('name', null, 'required', null, 'client');
17
18 asort($FORUM_TYPES);
19 $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $FORUM_TYPES);
20 $mform->setHelpButton('type', array('forumtype', get_string('forumtype', 'forum'), 'forum'));
21 $mform->setDefault('type', 'general');
22
23 $mform->addElement('htmleditor', 'intro', get_string('forumintro', 'forum'));
24 $mform->setType('intro', PARAM_RAW);
25 $mform->addRule('intro', get_string('required'), 'required', null, 'client');
26
27 $options = array();
28 $options[0] = get_string('no');
29 $options[1] = get_string('yesforever', 'forum');
30 $options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum');
31 $options[FORUM_DISALLOWSUBSCRIBE] = get_string('disallowsubscribe','forum');
32 $mform->addElement('select', 'forcesubscribe', get_string('forcesubscribeq', 'forum'), $options);
33 $mform->setHelpButton('forcesubscribe', array('subscription2', get_string('forcesubscribeq', 'forum'), 'forum'));
34
35 $options = array();
36 $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum');
37 $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum');
38 $options[FORUM_TRACKING_ON] = get_string('trackingon', 'forum');
39 $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options);
40 $mform->setHelpButton('trackingtype', array('trackingtype', get_string('trackingtype', 'forum'), 'forum'));
41
a02c77dc 42 $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
535e0ab6 43 $choices[1] = get_string('uploadnotallowed');
a02c77dc 44 $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
535e0ab6 45 $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices);
46 $mform->setHelpButton('maxbytes', array('maxattachmentsize', get_string('maxattachmentsize', 'forum'), 'forum'));
47 $mform->setDefault('maxbytes', $CFG->forum_maxbytes);
48
49 if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
a02c77dc 50//-------------------------------------------------------------------------------
535e0ab6 51 $mform->addElement('header', '', get_string('rss'));
52 $choices = array();
53 $choices[0] = get_string('none');
54 $choices[1] = get_string('discussions', 'forum');
55 $choices[2] = get_string('posts', 'forum');
56 $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices);
57 $mform->setHelpButton('rsstype', array('rsstype', get_string('rsstype'), 'forum'));
58
59 $choices = array();
60 $choices[0] = '0';
61 $choices[1] = '1';
62 $choices[2] = '2';
63 $choices[3] = '3';
64 $choices[4] = '4';
65 $choices[5] = '5';
66 $choices[10] = '10';
67 $choices[15] = '15';
68 $choices[20] = '20';
69 $choices[25] = '25';
70 $choices[30] = '30';
71 $choices[40] = '40';
72 $choices[50] = '50';
73 $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices);
74 $mform->setHelpButton('rssarticles', array('rssarticles', get_string('rssarticles'), 'forum'));
75 }
76
a02c77dc 77//-------------------------------------------------------------------------------
535e0ab6 78 $mform->addElement('header', '', get_string('grade'));
a02c77dc 79 $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'forum') , get_string('ratingsuse', 'forum'));
535e0ab6 80
a02c77dc 81 $mform->addElement('modgrade', 'scale', get_string('grade'), false);
6e372b25 82 $mform->addDependency('scale', 'assessed');
83
84 $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum'));
85 $mform->addDependency('ratingtime', 'assessed');
535e0ab6 86
87 $mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
6e372b25 88 $mform->addDependency('assesstimestart', 'assessed');
89 $mform->addDependency('assesstimestart', 'ratingtime');
535e0ab6 90
91 $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
6e372b25 92 $mform->addDependency('assesstimefinish', 'assessed');
93 $mform->addDependency('assesstimefinish', 'ratingtime');
94
535e0ab6 95
a02c77dc 96//-------------------------------------------------------------------------------
535e0ab6 97 $mform->addElement('header', '', get_string('blockafter', 'forum'));
98 $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
99 $mform->setType('warnafter', PARAM_INT);
100 $mform->setDefault('warnafter', '0');
101 $mform->addRule('warnafter', null, 'required', null, 'client');
102 $mform->addRule('warnafter', null, 'numeric', null, 'client');
103 $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'),'forum'));
104
105 $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum'));
106 $mform->setType('blockafter', PARAM_INT);
107 $mform->setDefault('blockafter', '0');
108 $mform->addRule('blockafter', null, 'required', null, 'client');
109 $mform->addRule('blockafter', null, 'numeric', null, 'client');
110 $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'),'forum'));
111
112 $options = array();
113 $options[0] = get_string('blockperioddisabled','forum');
114 $options[60*60*24] = '1 '.get_string('day');
115 $options[60*60*24*2] = '2 '.get_string('days');
116 $options[60*60*24*3] = '3 '.get_string('days');
117 $options[60*60*24*4] = '4 '.get_string('days');
118 $options[60*60*24*5] = '5 '.get_string('days');
119 $options[60*60*24*6] = '6 '.get_string('days');
120 $options[60*60*24*7] = '1 '.get_string('week');
121 $mform->addElement('select', 'blockperiod', get_string("blockperiod", "forum") , $options);
122 $mform->setHelpButton('blockperiod', array('manageposts', get_string('blockperiod', 'forum'),'forum'));
123
a02c77dc 124//-------------------------------------------------------------------------------
535e0ab6 125 $this->standard_coursemodule_elements();
126
127 $buttonarray=array();
128 $buttonarray[] = &MoodleQuickForm::createElement('submit', 'submit', get_string('savechanges'));
129 $buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel'));
130 $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
131 $renderer->addStopFieldsetElements('buttonar');
132 }
133
134 function definition_after_data(){
135 $mform =& $this->_form;
136 $type=&$mform->getElement('type');
d24206d6 137 $typevalue=$mform->getElementValue('type');
138 //we don't want to have these appear as possible selections in the form but
139 //we want the form to display them if they are set.
140 if ($typevalue[0]=='news'){
141 $type->addOption(get_string('namenews', 'forum'), 'news');
142 $type->freeze();
143 $type->setPersistantFreeze(true);
144 }
145 if ($typevalue[0]=='social'){
146 $type->addOption(get_string('namesocial', 'forum'), 'social');
535e0ab6 147 $type->freeze();
148 $type->setPersistantFreeze(true);
149 }
150 }
151
152
153
154}
155?>