function definition() { $mform = $this->_form; list($instance, $plugin, $context) = $this->_customdata; $mform->addElement('header', 'header', get_string('pluginname', 'enrol_leap')); $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $mform->addElement('select', 'status', get_string('status', 'enrol_leap'), $options); $mform->addHelpButton('status', 'status', 'enrol_leap'); $mform->setDefault('status', $plugin->get_config('status')); if ($instance->id) { $roles = get_default_enrol_roles($context, $instance->roleid); } else { $roles = get_default_enrol_roles($context, $plugin->get_config('roleid')); } $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles); $mform->setDefault('roleid', $plugin->get_config('roleid')); $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_leap'), array('optional' => true, 'defaultunit' => 86400)); $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod')); $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_leap'); $options = array(0 => get_string('no'), 1 => get_string('expirynotifyenroller', 'core_enrol'), 2 => get_string('expirynotifyall', 'core_enrol')); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), array('optional' => false, 'defaultunit' => 86400)); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); if (enrol_accessing_via_instance($instance)) { $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), get_string('instanceeditselfwarningtext', 'core_enrol')); } $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol')); $this->set_data($instance); }
function definition() { $mform = $this->_form; list($instance, $plugin, $context) = $this->_customdata; $mform->addElement('header', 'header', get_string('pluginname', 'enrol_ipay')); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol')); $mform->setType('name', PARAM_TEXT); $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $mform->addElement('select', 'status', get_string('status', 'enrol_ipay'), $options); $mform->setDefault('status', $plugin->get_config('status')); $mform->addElement('text', 'businessname', get_string('businessname', 'enrol_ipay')); $mform->setType('businessname', PARAM_TEXT); // test if i can see business name $mform->setDefault('businessname', $plugin->get_config('businessname')); //this faetches from the configured setings the business name $mform->addElement('text', 'cost', get_string('cost', 'enrol_ipay'), array('size' => 4)); $mform->setType('cost', PARAM_RAW); // Use unformat_float to get real value. $mform->setDefault('cost', format_float($plugin->get_config('cost'), 2, true)); $ipaycurrencies = $plugin->get_currencies(); $mform->addElement('select', 'currency', get_string('currency', 'enrol_ipay'), $ipaycurrencies); $mform->setDefault('currency', $plugin->get_config('currency')); if ($instance->id) { $roles = get_default_enrol_roles($context, $instance->roleid); } else { $roles = get_default_enrol_roles($context, $plugin->get_config('roleid')); } $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_ipay'), $roles); $mform->setDefault('roleid', $plugin->get_config('roleid')); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_ipay'), array('optional' => true, 'defaultunit' => 86400)); $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod')); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_ipay'); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_ipay'), array('optional' => true)); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_ipay'); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_ipay'), array('optional' => true)); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_ipay'); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); if (enrol_accessing_via_instance($instance)) { $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), get_string('instanceeditselfwarningtext', 'core_enrol')); } $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol')); $this->set_data($instance); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { global $CFG; // Merge these two settings to one value for the single selection element. if ($instance->notifyall and $instance->expirynotify) { $instance->expirynotify = 2; } unset($instance->notifyall); $nameattribs = array('size' => '20', 'maxlength' => '255'); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server'); $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options); $mform->addHelpButton('status', 'status', 'enrol_self'); $options = $this->get_newenrols_options(); $mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options); $mform->addHelpButton('customint6', 'newenrols', 'enrol_self'); $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED); $passattribs = array('size' => '20', 'maxlength' => '50'); $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs); $mform->addHelpButton('password', 'password', 'enrol_self'); if (empty($instance->id) and $this->get_config('requirepassword')) { $mform->addRule('password', get_string('required'), 'required', null, 'client'); } $mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server'); $options = $this->get_groupkey_options(); $mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options); $mform->addHelpButton('customint1', 'groupkey', 'enrol_self'); $roles = $this->extend_assignable_roles($context, $instance->roleid); $mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles); $options = array('optional' => true, 'defaultunit' => 86400); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), $options); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self'); $options = $this->get_expirynotify_options(); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $options = array('optional' => false, 'defaultunit' => 86400); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), $options); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), $options); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self'); $options = $this->get_longtimenosee_options(); $mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options); $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self'); $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self')); $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self'); $mform->setType('customint3', PARAM_INT); require_once $CFG->dirroot . '/cohort/lib.php'; $cohorts = array(0 => get_string('no')); $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0); if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) { $c = $DB->get_record('cohort', array('id' => $instance->customint5), 'id, name, idnumber, contextid, visible', IGNORE_MISSING); if ($c) { // Current cohort was not found because current user can not see it. Still keep it. $allcohorts[$instance->customint5] = $c; } } foreach ($allcohorts as $c) { $cohorts[$c->id] = format_string($c->name, true, array('context' => context::instance_by_id($c->contextid))); if ($c->idnumber) { $cohorts[$c->id] .= ' [' . s($c->idnumber) . ']'; } } if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) { // Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol. $cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5); } if (count($cohorts) > 1) { $mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts); $mform->addHelpButton('customint5', 'cohortonly', 'enrol_self'); } else { $mform->addElement('hidden', 'customint5'); $mform->setType('customint5', PARAM_INT); $mform->setConstant('customint5', 0); } $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self')); $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self'); $options = array('cols' => '60', 'rows' => '8'); $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), $options); $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self'); if (enrol_accessing_via_instance($instance)) { $warntext = get_string('instanceeditselfwarningtext', 'core_enrol'); $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext); } }
function definition() { global $DB; $mform = $this->_form; list($instance, $plugin, $context) = $this->_customdata; $mform->addElement('header', 'header', get_string('pluginname', 'enrol_self')); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol')); $mform->setType('name', PARAM_TEXT); $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options); $mform->addHelpButton('status', 'status', 'enrol_self'); $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options); $mform->addHelpButton('customint6', 'newenrols', 'enrol_self'); $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED); $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self')); $mform->addHelpButton('password', 'password', 'enrol_self'); if (empty($instance->id) and $plugin->get_config('requirepassword')) { $mform->addRule('password', get_string('required'), 'required', null, 'client'); } $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options); $mform->addHelpButton('customint1', 'groupkey', 'enrol_self'); $roles = $this->extend_assignable_roles($context, $instance->roleid); $mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), array('optional' => true, 'defaultunit' => 86400)); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self'); $options = array(0 => get_string('no'), 1 => get_string('expirynotifyenroller', 'core_enrol'), 2 => get_string('expirynotifyall', 'core_enrol')); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), array('optional' => false, 'defaultunit' => 86400)); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), array('optional' => true)); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self'); $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), array('optional' => true)); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self'); $options = array(0 => get_string('never'), 1800 * 3600 * 24 => get_string('numdays', '', 1800), 1000 * 3600 * 24 => get_string('numdays', '', 1000), 365 * 3600 * 24 => get_string('numdays', '', 365), 180 * 3600 * 24 => get_string('numdays', '', 180), 150 * 3600 * 24 => get_string('numdays', '', 150), 120 * 3600 * 24 => get_string('numdays', '', 120), 90 * 3600 * 24 => get_string('numdays', '', 90), 60 * 3600 * 24 => get_string('numdays', '', 60), 30 * 3600 * 24 => get_string('numdays', '', 30), 21 * 3600 * 24 => get_string('numdays', '', 21), 14 * 3600 * 24 => get_string('numdays', '', 14), 7 * 3600 * 24 => get_string('numdays', '', 7)); $mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options); $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self'); $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self')); $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self'); $mform->setType('customint3', PARAM_INT); $cohorts = array(0 => get_string('no')); list($sqlparents, $params) = $DB->get_in_or_equal($context->get_parent_context_ids(), SQL_PARAMS_NAMED); $params['current'] = $instance->customint5; $sql = "SELECT id, name, idnumber, contextid\n FROM {cohort}\n WHERE contextid {$sqlparents} OR id = :current\n ORDER BY name ASC, idnumber ASC"; $rs = $DB->get_recordset_sql($sql, $params); foreach ($rs as $c) { $ccontext = context::instance_by_id($c->contextid); if ($c->id != $instance->customint5 and !has_capability('moodle/cohort:view', $ccontext)) { continue; } $cohorts[$c->id] = format_string($c->name, true, array('context' => $context)); if ($c->idnumber) { $cohorts[$c->id] .= ' [' . s($c->idnumber) . ']'; } } if (!isset($cohorts[$instance->customint5])) { // Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol. $cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5); } $rs->close(); if (count($cohorts) > 1) { $mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts); $mform->addHelpButton('customint5', 'cohortonly', 'enrol_self'); } else { $mform->addElement('hidden', 'customint5'); $mform->setType('customint5', PARAM_INT); $mform->setConstant('customint5', 0); } $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self')); $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self'); $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), array('cols' => '60', 'rows' => '8')); $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self'); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); if (enrol_accessing_via_instance($instance)) { $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), get_string('instanceeditselfwarningtext', 'core_enrol')); } $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol')); $this->set_data($instance); }
$displayname = $plugin->get_instance_name($instance); $users = $DB->count_records('user_enrolments', array('enrolid'=>$instance->id)); if ($users) { $message = markdown_to_html(get_string('deleteinstanceconfirm', 'enrol', array('name'=>$displayname, 'users'=>$users))); } else { $message = markdown_to_html(get_string('deleteinstancenousersconfirm', 'enrol', array('name'=>$displayname))); } echo $OUTPUT->confirm($message, $yesurl, $PAGE->url); echo $OUTPUT->footer(); die(); } else if ($action === 'disable') { $instance = $instances[$instanceid]; $plugin = $plugins[$instance->enrol]; if ($instance->status != ENROL_INSTANCE_DISABLED) { if (enrol_accessing_via_instance($instance)) { if (!$confirm2) { $yesurl = new moodle_url('/enrol/instances.php', array('id'=>$course->id, 'action'=>'disable', 'instance'=>$instance->id, 'confirm2'=>1, 'sesskey'=>sesskey())); $displayname = $plugin->get_instance_name($instance); $message = markdown_to_html(get_string('disableinstanceconfirmself', 'enrol', array('name'=>$displayname))); echo $OUTPUT->header(); echo $OUTPUT->confirm($message, $yesurl, $PAGE->url); echo $OUTPUT->footer(); die(); } } $plugin->update_status($instance, ENROL_INSTANCE_DISABLED); redirect($PAGE->url); } } else if ($action === 'enable') {
function definition() { global $DB; $mform = $this->_form; list($instance, $plugin, $context) = $this->_customdata; $mform->addElement('header', 'header', get_string('pluginname', 'enrol_self')); $nameattribs = array('size' => '20', 'maxlength' => '255'); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server'); $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options); $mform->addHelpButton('status', 'status', 'enrol_self'); $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options); $mform->addHelpButton('customint6', 'newenrols', 'enrol_self'); $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED); $passattribs = array('size' => '20', 'maxlength' => '50'); $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs); $mform->addHelpButton('password', 'password', 'enrol_self'); if (empty($instance->id) and $plugin->get_config('requirepassword')) { $mform->addRule('password', get_string('required'), 'required', null, 'client'); } $mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server'); $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options); $mform->addHelpButton('customint1', 'groupkey', 'enrol_self'); $roles = $this->extend_assignable_roles($context, $instance->roleid); $mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), array('optional' => true, 'defaultunit' => 86400)); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self'); $options = array(0 => get_string('no'), 1 => get_string('expirynotifyenroller', 'core_enrol'), 2 => get_string('expirynotifyall', 'core_enrol')); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), array('optional' => false, 'defaultunit' => 86400)); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), array('optional' => true)); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self'); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), array('optional' => true)); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self'); $options = array(0 => get_string('never'), 1800 * 3600 * 24 => get_string('numdays', '', 1800), 1000 * 3600 * 24 => get_string('numdays', '', 1000), 365 * 3600 * 24 => get_string('numdays', '', 365), 180 * 3600 * 24 => get_string('numdays', '', 180), 150 * 3600 * 24 => get_string('numdays', '', 150), 120 * 3600 * 24 => get_string('numdays', '', 120), 90 * 3600 * 24 => get_string('numdays', '', 90), 60 * 3600 * 24 => get_string('numdays', '', 60), 30 * 3600 * 24 => get_string('numdays', '', 30), 21 * 3600 * 24 => get_string('numdays', '', 21), 14 * 3600 * 24 => get_string('numdays', '', 14), 7 * 3600 * 24 => get_string('numdays', '', 7)); $mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options); $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self'); $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self')); $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self'); $mform->setType('customint3', PARAM_INT); $cohorts = array(0 => get_string('no')); $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0); if ($instance->customint5 && !isset($allcohorts[$instance->customint5]) && ($c = $DB->get_record('cohort', array('id' => $instance->customint5), 'id, name, idnumber, contextid, visible', IGNORE_MISSING))) { // Current cohort was not found because current user can not see it. Still keep it. $allcohorts[$instance->customint5] = $c; } foreach ($allcohorts as $c) { $cohorts[$c->id] = format_string($c->name, true, array('context' => context::instance_by_id($c->contextid))); if ($c->idnumber) { $cohorts[$c->id] .= ' [' . s($c->idnumber) . ']'; } } if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) { // Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol. $cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5); } if (count($cohorts) > 1) { $mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts); $mform->addHelpButton('customint5', 'cohortonly', 'enrol_self'); } else { $mform->addElement('hidden', 'customint5'); $mform->setType('customint5', PARAM_INT); $mform->setConstant('customint5', 0); } $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self')); $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self'); $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), array('cols' => '60', 'rows' => '8')); $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self'); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); if (enrol_accessing_via_instance($instance)) { $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), get_string('instanceeditselfwarningtext', 'core_enrol')); } $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol')); $this->set_data($instance); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { $mform->addElement('text', 'name', get_string('custominstancename', 'enrol')); $mform->setType('name', PARAM_TEXT); $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_paypal'), $options); $mform->setDefault('status', $this->get_config('status')); $mform->addElement('text', 'cost', get_string('cost', 'enrol_paypal'), array('size' => 4)); $mform->setType('cost', PARAM_RAW); $mform->setDefault('cost', format_float($this->get_config('cost'), 2, true)); $paypalcurrencies = $this->get_currencies(); $mform->addElement('select', 'currency', get_string('currency', 'enrol_paypal'), $paypalcurrencies); $mform->setDefault('currency', $this->get_config('currency')); $roles = $this->get_roleid_options($instance, $context); $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_paypal'), $roles); $mform->setDefault('roleid', $this->get_config('roleid')); $options = array('optional' => true, 'defaultunit' => 86400); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_paypal'), $options); $mform->setDefault('enrolperiod', $this->get_config('enrolperiod')); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_paypal'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_paypal'), $options); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_paypal'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_paypal'), $options); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_paypal'); if (enrol_accessing_via_instance($instance)) { $warningtext = get_string('instanceeditselfwarningtext', 'core_enrol'); $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warningtext); } }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options); $mform->addHelpButton('status', 'status', 'enrol_manual'); $mform->setDefault('status', $this->get_config('status')); $roles = $this->get_roleid_options($instance, $context); $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles); $mform->setDefault('roleid', $this->get_config('roleid')); $options = array('optional' => true, 'defaultunit' => 86400); $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options); $mform->setDefault('enrolperiod', $this->get_config('enrolperiod')); $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual'); $options = $this->get_expirynotify_options(); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $options = array('optional' => false, 'defaultunit' => 86400); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); if (enrol_accessing_via_instance($instance)) { $warntext = get_string('instanceeditselfwarningtext', 'core_enrol'); $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext); } }