/** * Called to define this moodle form * * @return void */ public function definition() { global $CFG, $DB, $OUTPUT; $mform =& $this->_form; $mform->addElement('header', 'general', get_string('general', 'form')); // Types cannot be changed. Check if it's already set. if (!empty($this->current->id)) { $typename = \mod_webexactivity\meeting::get_meeting_type_name($this->current->type); $mform->addElement('static', 'typestatic', get_string('meetingtype', 'webexactivity'), $typename); } else { $meetingtypes = \mod_webexactivity\meeting::get_available_types($this->context); if (count($meetingtypes) == 0) { throw new \coding_exception('There are no valid meeting types for this user. Admin must fix.'); } else { if (count($meetingtypes) == 1) { $keys = array_keys($meetingtypes); $type = array_pop($keys); $mform->addElement('static', 'typestatic', get_string('meetingtype', 'webexactivity'), $meetingtypes[$type]); $mform->addElement('hidden', 'type', $type); } else { $mform->addElement('select', 'type', get_string('meetingtype', 'webexactivity'), $meetingtypes); $mform->setDefault('type', get_config('webexactivity', 'defaultmeetingtype')); } } $mform->setType('type', PARAM_INT); } $mform->addElement('text', 'name', get_string('webexactivityname', 'webexactivity'), array('size' => '64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $this->add_intro_editor(false); $mform->addElement('date_time_selector', 'starttime', get_string('starttime', 'webexactivity')); $mform->addRule('starttime', null, 'required', null, 'client'); $duration = array(); $duration[] =& $mform->createElement('text', 'duration', '', array('size' => '4')); $duration[] =& $mform->createElement('static', 'durationname', '', '(' . get_string('minutes') . ')'); $mform->addGroup($duration, 'durationgroup', get_string('duration', 'webexactivity'), array(' '), false); $mform->setType('duration', PARAM_INT); $mform->addRule('durationgroup', null, 'required', null, 'client'); $mform->setDefault('duration', 20); $mform->addHelpButton('durationgroup', 'duration', 'webexactivity'); $mform->addElement('passwordunmask', 'password', get_string('meetingpassword', 'webexactivity')); $mform->setType('password', PARAM_TEXT); $mform->addRule('password', null, 'maxlength', 16, 'client'); $req = get_config('webexactivity', 'requiremeetingpassword'); if ($req) { $mform->addRule('password', null, 'required', null, 'client'); } $mform->addElement('header', 'additionalsettings', get_string('additionalsettings', 'webexactivity')); $mform->addElement('checkbox', 'studentdownload', get_string('studentdownload', 'webexactivity')); $mform->setDefault('studentdownload', 1); $mform->addHelpButton('studentdownload', 'studentdownload', 'webexactivity'); $mform->addElement('checkbox', 'longavailability', get_string('longavailability', 'webexactivity')); $mform->setDefault('longavailability', 0); $mform->addHelpButton('longavailability', 'longavailability', 'webexactivity'); $mform->addElement('date_time_selector', 'endtime', get_string('availabilityendtime', 'webexactivity')); $mform->setDefault('endtime', time() + 3600 * 24 * 14); $mform->addRule('starttime', null, 'required', null, 'client'); $mform->disabledIf('endtime', 'longavailability'); $this->standard_coursemodule_elements(); $this->add_action_buttons(); }