function definition() { global $CFG, $COURSE, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('forumintro', 'forum')); $forumtypes = forum_get_forum_types(); core_collator::asort($forumtypes, core_collator::SORT_STRING); $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forumtypes); $mform->addHelpButton('type', 'forumtype', 'forum'); $mform->setDefault('type', 'general'); // Attachments and word count. $mform->addElement('header', 'attachmentswordcounthdr', get_string('attachmentswordcount', 'forum')); $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, 0, $CFG->forum_maxbytes); $choices[1] = get_string('uploadnotallowed'); $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices); $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'forum'); $mform->setDefault('maxbytes', $CFG->forum_maxbytes); $choices = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 20 => 20, 50 => 50, 100 => 100); $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'forum'), $choices); $mform->addHelpButton('maxattachments', 'maxattachments', 'forum'); $mform->setDefault('maxattachments', $CFG->forum_maxattachments); $mform->addElement('selectyesno', 'displaywordcount', get_string('displaywordcount', 'forum')); $mform->addHelpButton('displaywordcount', 'displaywordcount', 'forum'); $mform->setDefault('displaywordcount', 0); // Subscription and tracking. $mform->addElement('header', 'subscriptionandtrackinghdr', get_string('subscriptionandtracking', 'forum')); $options = array(); $options[FORUM_CHOOSESUBSCRIBE] = get_string('subscriptionoptional', 'forum'); $options[FORUM_FORCESUBSCRIBE] = get_string('subscriptionforced', 'forum'); $options[FORUM_INITIALSUBSCRIBE] = get_string('subscriptionauto', 'forum'); $options[FORUM_DISALLOWSUBSCRIBE] = get_string('subscriptiondisabled', 'forum'); $mform->addElement('select', 'forcesubscribe', get_string('subscriptionmode', 'forum'), $options); $mform->addHelpButton('forcesubscribe', 'subscriptionmode', 'forum'); $options = array(); $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum'); $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum'); if ($CFG->forum_allowforcedreadtracking) { $options[FORUM_TRACKING_FORCED] = get_string('trackingon', 'forum'); } $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options); $mform->addHelpButton('trackingtype', 'trackingtype', 'forum'); $default = $CFG->forum_trackingtype; if (!$CFG->forum_allowforcedreadtracking && $default == FORUM_TRACKING_FORCED) { $default = FORUM_TRACKING_OPTIONAL; } $mform->setDefault('trackingtype', $default); if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) { //------------------------------------------------------------------------------- $mform->addElement('header', 'rssheader', get_string('rss')); $choices = array(); $choices[0] = get_string('none'); $choices[1] = get_string('discussions', 'forum'); $choices[2] = get_string('posts', 'forum'); $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices); $mform->addHelpButton('rsstype', 'rsstype', 'forum'); if (isset($CFG->forum_rsstype)) { $mform->setDefault('rsstype', $CFG->forum_rsstype); } $choices = array(); $choices[0] = '0'; $choices[1] = '1'; $choices[2] = '2'; $choices[3] = '3'; $choices[4] = '4'; $choices[5] = '5'; $choices[10] = '10'; $choices[15] = '15'; $choices[20] = '20'; $choices[25] = '25'; $choices[30] = '30'; $choices[40] = '40'; $choices[50] = '50'; $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices); $mform->addHelpButton('rssarticles', 'rssarticles', 'forum'); $mform->disabledIf('rssarticles', 'rsstype', 'eq', '0'); if (isset($CFG->forum_rssarticles)) { $mform->setDefault('rssarticles', $CFG->forum_rssarticles); } } $mform->addElement('header', 'discussionlocking', get_string('discussionlockingheader', 'forum')); $options = [0 => get_string('discussionlockingdisabled', 'forum'), 1 * DAYSECS => get_string('numday', 'core', 1), 1 * WEEKSECS => get_string('numweek', 'core', 1), 2 * WEEKSECS => get_string('numweeks', 'core', 2), 30 * DAYSECS => get_string('nummonth', 'core', 1), 60 * DAYSECS => get_string('nummonths', 'core', 2), 90 * DAYSECS => get_string('nummonths', 'core', 3), 180 * DAYSECS => get_string('nummonths', 'core', 6), 1 * YEARSECS => get_string('numyear', 'core', 1)]; $mform->addElement('select', 'lockdiscussionafter', get_string('lockdiscussionafter', 'forum'), $options); $mform->addHelpButton('lockdiscussionafter', 'lockdiscussionafter', 'forum'); $mform->disabledIf('lockdiscussionafter', 'type', 'eq', 'single'); //------------------------------------------------------------------------------- $mform->addElement('header', 'blockafterheader', get_string('blockafter', 'forum')); $options = array(); $options[0] = get_string('blockperioddisabled', 'forum'); $options[60 * 60 * 24] = '1 ' . get_string('day'); $options[60 * 60 * 24 * 2] = '2 ' . get_string('days'); $options[60 * 60 * 24 * 3] = '3 ' . get_string('days'); $options[60 * 60 * 24 * 4] = '4 ' . get_string('days'); $options[60 * 60 * 24 * 5] = '5 ' . get_string('days'); $options[60 * 60 * 24 * 6] = '6 ' . get_string('days'); $options[60 * 60 * 24 * 7] = '1 ' . get_string('week'); $mform->addElement('select', 'blockperiod', get_string('blockperiod', 'forum'), $options); $mform->addHelpButton('blockperiod', 'blockperiod', 'forum'); $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); $mform->setType('blockafter', PARAM_INT); $mform->setDefault('blockafter', '0'); $mform->addRule('blockafter', null, 'numeric', null, 'client'); $mform->addHelpButton('blockafter', 'blockafter', 'forum'); $mform->disabledIf('blockafter', 'blockperiod', 'eq', 0); $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); $mform->setType('warnafter', PARAM_INT); $mform->setDefault('warnafter', '0'); $mform->addRule('warnafter', null, 'numeric', null, 'client'); $mform->addHelpButton('warnafter', 'warnafter', 'forum'); $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0); $coursecontext = context_course::instance($COURSE->id); plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_forum'); //------------------------------------------------------------------------------- $this->standard_grading_coursemodule_elements(); $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); }
function definition() { global $CFG, $COURSE, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $forum_types = forum_get_forum_types(); asort($forum_types); $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forum_types); $mform->addHelpButton('type', 'forumtype', 'forum'); $mform->setDefault('type', 'general'); $this->add_intro_editor(true, get_string('forumintro', 'forum')); $options = array(); $options[FORUM_CHOOSESUBSCRIBE] = get_string('subscriptionoptional', 'forum'); $options[FORUM_FORCESUBSCRIBE] = get_string('subscriptionforced', 'forum'); $options[FORUM_INITIALSUBSCRIBE] = get_string('subscriptionauto', 'forum'); $options[FORUM_DISALLOWSUBSCRIBE] = get_string('subscriptiondisabled', 'forum'); $mform->addElement('select', 'forcesubscribe', get_string('subscriptionmode', 'forum'), $options); $mform->addHelpButton('forcesubscribe', 'subscriptionmode', 'forum'); $options = array(); $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum'); $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum'); $options[FORUM_TRACKING_ON] = get_string('trackingon', 'forum'); $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options); $mform->addHelpButton('trackingtype', 'trackingtype', 'forum'); $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); $choices[1] = get_string('uploadnotallowed'); $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')'; $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices); $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'forum'); $mform->setDefault('maxbytes', $CFG->forum_maxbytes); $choices = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 50, 100); $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'forum'), $choices); $mform->addHelpButton('maxattachments', 'maxattachments', 'forum'); $mform->setDefault('maxattachments', $CFG->forum_maxattachments); if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) { //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('rss')); $choices = array(); $choices[0] = get_string('none'); $choices[1] = get_string('discussions', 'forum'); $choices[2] = get_string('posts', 'forum'); $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices); $mform->addHelpButton('rsstype', 'rsstype', 'forum'); $choices = array(); $choices[0] = '0'; $choices[1] = '1'; $choices[2] = '2'; $choices[3] = '3'; $choices[4] = '4'; $choices[5] = '5'; $choices[10] = '10'; $choices[15] = '15'; $choices[20] = '20'; $choices[25] = '25'; $choices[30] = '30'; $choices[40] = '40'; $choices[50] = '50'; $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices); $mform->addHelpButton('rssarticles', 'rssarticles', 'forum'); } //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('blockafter', 'forum')); $options = array(); $options[0] = get_string('blockperioddisabled', 'forum'); $options[60 * 60 * 24] = '1 ' . get_string('day'); $options[60 * 60 * 24 * 2] = '2 ' . get_string('days'); $options[60 * 60 * 24 * 3] = '3 ' . get_string('days'); $options[60 * 60 * 24 * 4] = '4 ' . get_string('days'); $options[60 * 60 * 24 * 5] = '5 ' . get_string('days'); $options[60 * 60 * 24 * 6] = '6 ' . get_string('days'); $options[60 * 60 * 24 * 7] = '1 ' . get_string('week'); $mform->addElement('select', 'blockperiod', get_string('blockperiod', 'forum'), $options); $mform->addHelpButton('blockperiod', 'blockperiod', 'forum'); $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); $mform->setType('blockafter', PARAM_INT); $mform->setDefault('blockafter', '0'); $mform->addRule('blockafter', null, 'numeric', null, 'client'); $mform->addHelpButton('blockafter', 'blockafter', 'forum'); $mform->disabledIf('blockafter', 'blockperiod', 'eq', 0); $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); $mform->setType('warnafter', PARAM_INT); $mform->setDefault('warnafter', '0'); $mform->addRule('warnafter', null, 'numeric', null, 'client'); $mform->addHelpButton('warnafter', 'warnafter', 'forum'); $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0); //------------------------------------------------------------------------------- $this->standard_grading_coursemodule_elements(); $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); }
function definition() { global $CFG, $COURSE; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size' => '64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $forum_types = forum_get_forum_types(); asort($forum_types); $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forum_types); $mform->setHelpButton('type', array('forumtype', get_string('forumtype', 'forum'), 'forum')); $mform->setDefault('type', 'general'); $mform->addElement('htmleditor', 'intro', get_string('forumintro', 'forum')); $mform->setType('intro', PARAM_RAW); $mform->addRule('intro', get_string('required'), 'required', null, 'client'); $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton'); $options = array(); $options[0] = get_string('no'); $options[1] = get_string('yesforever', 'forum'); $options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum'); $options[FORUM_DISALLOWSUBSCRIBE] = get_string('disallowsubscribe', 'forum'); $mform->addElement('select', 'forcesubscribe', get_string('forcesubscribeq', 'forum'), $options); $mform->setHelpButton('forcesubscribe', array('subscription2', get_string('forcesubscribeq', 'forum'), 'forum')); $options = array(); $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum'); $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum'); $options[FORUM_TRACKING_ON] = get_string('trackingon', 'forum'); $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options); $mform->setHelpButton('trackingtype', array('trackingtype', get_string('trackingtype', 'forum'), 'forum')); $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); $choices[1] = get_string('uploadnotallowed'); $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')'; $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices); $mform->setHelpButton('maxbytes', array('maxattachmentsize', get_string('maxattachmentsize', 'forum'), 'forum')); $mform->setDefault('maxbytes', $CFG->forum_maxbytes); if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) { //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('rss')); $choices = array(); $choices[0] = get_string('none'); $choices[1] = get_string('discussions', 'forum'); $choices[2] = get_string('posts', 'forum'); $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices); $mform->setHelpButton('rsstype', array('rsstype', get_string('rsstype'), 'forum')); $choices = array(); $choices[0] = '0'; $choices[1] = '1'; $choices[2] = '2'; $choices[3] = '3'; $choices[4] = '4'; $choices[5] = '5'; $choices[10] = '10'; $choices[15] = '15'; $choices[20] = '20'; $choices[25] = '25'; $choices[30] = '30'; $choices[40] = '40'; $choices[50] = '50'; $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices); $mform->setHelpButton('rssarticles', array('rssarticles', get_string('rssarticles'), 'forum')); } //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('grade')); $mform->addElement('select', 'assessed', get_string('aggregatetype', 'forum'), forum_get_aggregate_types()); $mform->setDefault('assessed', 0); $mform->setHelpButton('assessed', array('assessaggregate', get_string('aggregatetype', 'forum'), 'forum')); $mform->addElement('modgrade', 'scale', get_string('grade'), false); $mform->disabledIf('scale', 'assessed', 'eq', 0); $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum')); $mform->disabledIf('ratingtime', 'assessed', 'eq', 0); $mform->addElement('date_time_selector', 'assesstimestart', get_string('from')); $mform->disabledIf('assesstimestart', 'assessed', 'eq', 0); $mform->disabledIf('assesstimestart', 'ratingtime'); $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to')); $mform->disabledIf('assesstimefinish', 'assessed', 'eq', 0); $mform->disabledIf('assesstimefinish', 'ratingtime'); //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('blockafter', 'forum')); $options = array(); $options[0] = get_string('blockperioddisabled', 'forum'); $options[60 * 60 * 24] = '1 ' . get_string('day'); $options[60 * 60 * 24 * 2] = '2 ' . get_string('days'); $options[60 * 60 * 24 * 3] = '3 ' . get_string('days'); $options[60 * 60 * 24 * 4] = '4 ' . get_string('days'); $options[60 * 60 * 24 * 5] = '5 ' . get_string('days'); $options[60 * 60 * 24 * 6] = '6 ' . get_string('days'); $options[60 * 60 * 24 * 7] = '1 ' . get_string('week'); $mform->addElement('select', 'blockperiod', get_string("blockperiod", "forum"), $options); $mform->setHelpButton('blockperiod', array('manageposts', get_string('blockperiod', 'forum'), 'forum')); $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); $mform->setType('blockafter', PARAM_INT); $mform->setDefault('blockafter', '0'); $mform->addRule('blockafter', null, 'numeric', null, 'client'); $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'), 'forum')); $mform->disabledIf('blockafter', 'blockperiod', 'eq', 0); $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); $mform->setType('warnafter', PARAM_INT); $mform->setDefault('warnafter', '0'); $mform->addRule('warnafter', null, 'numeric', null, 'client'); $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'), 'forum')); $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0); //------------------------------------------------------------------------------- $features = new stdClass(); $features->groups = true; $features->groupings = true; $features->groupmembersonly = true; $this->standard_coursemodule_elements($features); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); }