From b5ab55ddaf54f41357d9bd425c2f0fa2f3d9ca34 Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 21 Feb 2008 14:12:48 +0000 Subject: [PATCH] MDL-13274, MDL-13215 - improved modedit shared forms, label supports groupmembersonly, removed extra button for labels; mergedfrom MOODEL_19_STABLE --- course/moodleform_mod.php | 49 +++++++++++++++++++++++++-------------- mod/label/mod_form.php | 8 +++---- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 62760e616b..1947afc2b0 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -171,7 +171,7 @@ class moodleform_mod extends moodleform { /** * Adds all the standard elements to a form to edit the settings for an activity module. * - * @param mixed array or object describing supported features - groups, groupings, groupmembersonly + * @param mixed array or object describing supported features - groups, groupings, groupmembersonly, etc. */ function standard_coursemodule_elements($features=null){ global $COURSE, $CFG; @@ -213,10 +213,14 @@ class moodleform_mod extends moodleform { $this->_features->gradecat = true; } - $outcomesused = false; + if (!isset($this->_features->idnumber)) { + $this->_features->idnumber = true; + } + + $outcomesused = false; if (!empty($CFG->enableoutcomes) and $this->_features->outcomes) { if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) { - $outcomesused = true; + $outcomesused = true; $mform->addElement('header', 'modoutcomes', get_string('outcomes', 'grades')); foreach($outcomes as $outcome) { $mform->addElement('advcheckbox', 'outcome_'.$outcome->id, $outcome->get_name()); @@ -254,8 +258,11 @@ class moodleform_mod extends moodleform { } $mform->addElement('modvisible', 'visible', get_string('visible')); - $mform->addElement('text', 'cmidnumber', get_string('idnumbermod')); - $mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true); + + if ($this->_features->idnumber) { + $mform->addElement('text', 'cmidnumber', get_string('idnumbermod')); + $mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true); + } if ($this->_features->gradecat) { $categories = grade_get_categories_menu($COURSE->id, $outcomesused); @@ -297,28 +304,34 @@ class moodleform_mod extends moodleform { /** * Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button. - * - * @param bool $cancel - * @param string $submitlabel - * @param string $submit2label + * + * @param bool $cancel show cancel button + * @param string $submitlabel null means default, false means none, string is label text + * @param string $submit2label null means default, false means none, string is label text * @return void - */ + */ function add_action_buttons($cancel=true, $submitlabel=null, $submit2label=null) { if (is_null($submitlabel)) { $submitlabel = get_string('savechangesanddisplay'); } - + if (is_null($submit2label)) { $submit2label = get_string('savechangesandreturntocourse'); } - + $mform =& $this->_form; - - //when two elements we need a group - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); - + + // elements in a row need a group + $buttonarray = array(); + + if ($submit2label !== false) { + $buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label); + } + + if ($submitlabel !== false) { + $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); + } + if ($cancel) { $buttonarray[] = &$mform->createElement('cancel'); } diff --git a/mod/label/mod_form.php b/mod/label/mod_form.php index 113811686a..12f4cc6b56 100644 --- a/mod/label/mod_form.php +++ b/mod/label/mod_form.php @@ -12,13 +12,13 @@ class mod_label_mod_form extends moodleform_mod { $mform->addRule('content', get_string('required'), 'required', null, 'client'); $mform->setHelpButton('content', array('questions', 'richtext'), false, 'editorhelpbutton'); - $this->standard_hidden_coursemodule_elements(); - - $mform->addElement('modvisible', 'visible', get_string('visible')); + $features = array('groups'=>false, 'groupings'=>false, 'groupmembersonly'=>true, + 'outcomes'=>false, 'gradecat'=>false, 'idnumber'=>false); + $this->standard_coursemodule_elements($features); //------------------------------------------------------------------------------- // buttons - $this->add_action_buttons(); + $this->add_action_buttons(true, false, null); } -- 2.39.5