function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_apply'));
     $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_apply'), $options);
     //$mform->addHelpButton('status', 'status', 'enrol_apply');
     $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('textarea', 'customtext1', get_string('editdescription', 'enrol_apply'));
     $mform->addElement('select', 'customint1', get_string('show_standard_user_profile', 'enrol_apply'), $options);
     $mform->setDefault('customint1', $plugin->get_config('customint1'));
     $mform->addElement('select', 'customint2', get_string('show_extra_user_profile', 'enrol_apply'), $options);
     $mform->setDefault('customint2', $plugin->get_config('customint2'));
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
 public function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_license'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_license'), $options);
     $mform->addHelpButton('status', 'status', 'enrol_license');
     $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('role', 'enrol_license'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('roleid'));
     $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_license'), $options);
     $mform->setDefault('customint2', $plugin->get_config('longtimenosee'));
     $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_license');
     $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_license'));
     $mform->setDefault('customint4', $plugin->get_config('sendcoursewelcomemessage'));
     $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_license');
     $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_license'), array('cols' => '60', 'rows' => '8'));
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
Beispiel #3
0
 function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_manual'));
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
     $mform->addHelpButton('status', 'status', 'enrol_manual');
     $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_manual'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
     $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
     $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');
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
Beispiel #4
0
 function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_paypal'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_paypal'), $options);
     $mform->setDefault('status', $plugin->get_config('status'));
     $mform->addElement('text', 'cost', get_string('cost', 'enrol_paypal'), array('size' => 4));
     $mform->setDefault('cost', $plugin->get_config('cost'));
     $paypalcurrencies = array('USD' => 'US Dollars', 'EUR' => 'Euros', 'JPY' => 'Japanese Yen', 'GBP' => 'British Pounds', 'CAD' => 'Canadian Dollars', 'AUD' => 'Australian Dollars');
     $mform->addElement('select', 'currency', get_string('currency', 'enrol_paypal'), $paypalcurrencies);
     $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_paypal'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('roleid'));
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_paypal'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_paypal');
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_paypal'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_paypal');
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_paypal'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_paypal');
     $mform->addElement('hidden', 'id');
     $mform->addElement('hidden', 'courseid');
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
Beispiel #5
0
 function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_alipay'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_alipay'), $options);
     $mform->setDefault('status', $plugin->get_config('status'));
     $mform->addElement('text', 'cost', get_string('cost', 'enrol_alipay'), array('size' => 4));
     $mform->setDefault('cost', $plugin->get_config('cost'));
     $alipaycurrencies = array('RMB' => 'China Yuan');
     $mform->addElement('select', 'currency', get_string('currency', 'enrol_alipay'), $alipaycurrencies);
     $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_alipay'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('roleid'));
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_alipay'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_alipay'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_alipay'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addElement('hidden', 'id');
     $mform->addElement('hidden', 'courseid');
     $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_attributes'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $mform->setType('name', PARAM_TEXT);
     if ($instance->id) {
         $roles = get_default_enrol_roles($context, $instance->roleid);
     } else {
         $roles = get_default_enrol_roles($context, $plugin->get_config('default_roleid'));
     }
     $mform->addElement('select', 'roleid', get_string('role'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('default_roleid'));
     $mform->addElement('textarea', 'customtext1', get_string('attrsyntax', 'enrol_attributes'), array('cols' => '60', 'rows' => '8'));
     $mform->addHelpButton('customtext1', 'attrsyntax', 'enrol_attributes');
     $mform->addElement('checkbox', 'customint1', get_string('removewhenexpired', 'enrol_attributes'));
     $mform->addHelpButton('customint1', 'removewhenexpired', 'enrol_attributes');
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $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_globalclassroom'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_globalclassroom'), $options);
     $mform->setDefault('status', $plugin->get_config('status'));
     $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_globalclassroom'));
     $mform->addHelpButton('password', 'password', 'enrol_globalclassroom');
     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_globalclassroom'), $options);
     $mform->addHelpButton('customint1', 'groupkey', 'enrol_globalclassroom');
     $mform->setDefault('customint1', $plugin->get_config('groupkey'));
     $options = array(1 => get_string('yes'), 0 => get_string('no'));
     $mform->addElement('select', 'customchar1', get_string('freeformembers', 'enrol_globalclassroom'), $options);
     $mform->setDefault('customchar1', $plugin->get_config('freeformembers'));
     $mform->addElement('text', 'cost', get_string('cost', 'enrol_globalclassroom'), array('size' => 4));
     $mform->setDefault('cost', $plugin->get_config('cost'));
     $paypalcurrencies = array('USD' => 'US Dollars', 'EUR' => 'Euros', 'JPY' => 'Japanese Yen', 'GBP' => 'British Pounds', 'CAD' => 'Canadian Dollars', 'AUD' => 'Australian Dollars');
     $mform->addElement('select', 'currency', get_string('currency', 'enrol_globalclassroom'), $paypalcurrencies);
     $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_globalclassroom'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('roleid'));
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_globalclassroom'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_globalclassroom'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_globalclassroom'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $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_globalclassroom'), $options);
     $mform->setDefault('customint2', $plugin->get_config('longtimenosee'));
     $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_globalclassroom');
     $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_globalclassroom'));
     $mform->setDefault('customint3', $plugin->get_config('maxenrolled'));
     $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_globalclassroom');
     $mform->setType('customint3', PARAM_INT);
     $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_globalclassroom'));
     $mform->setDefault('customint4', $plugin->get_config('sendcoursewelcomemessage'));
     $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_globalclassroom');
     $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_globalclassroom'), array('cols' => '60', 'rows' => '8'));
     $mform->addElement('hidden', 'id');
     $mform->addElement('hidden', 'courseid');
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
Beispiel #8
0
 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);
 }
Beispiel #9
0
 function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_manual'));
     $mform->addElement('advcheckbox', enrol_elis_plugin::ENROL_FROM_COURSE_CATALOG_DB, get_string(enrol_elis_plugin::ENROL_FROM_COURSE_CATALOG_CONFIG, 'enrol_elis'));
     $mform->setDefault(enrol_elis_plugin::ENROL_FROM_COURSE_CATALOG_DB, $plugin->get_config(enrol_elis_plugin::ENROL_FROM_COURSE_CATALOG_CONFIG));
     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('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
 /**
  * Define the form.
  * 
  * @global moodle_database $DB
  */
 public function definition()
 {
     global $DB;
     /** @var moodle_form $mform */
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', 'Mandatory Enrolment');
     // Roles
     $roles = get_default_enrol_roles($context, $instance->id ? $instance->roleid : null);
     $mform->addElement('select', 'roleid', 'Role', $roles);
     $mform->setDefault('roleid', $plugin->get_config('default_roleid'));
     // Hidden values for convenience
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     // Buttons
     $this->add_action_buttons();
     $this->set_data($instance);
 }
Beispiel #11
0
 /**
  * @param $instance
  * @param $plugin
  * @param $context
  *
  * @throws coding_exception
  */
 protected function add_general_section($instance, $plugin, $context)
 {
     global $CFG, $OUTPUT;
     $this->_form->addElement('header', 'generalsection', get_string('general', 'enrol_autoenrol'));
     $this->_form->setExpanded('generalsection');
     $img = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('logo', 'enrol_autoenrol'), 'alt' => 'AutoEnrol Logo', 'title' => 'AutoEnrol Logo'));
     $img = html_writer::div($img, null, array('style' => 'text-align:center;margin: 1em 0;'));
     $this->_form->addElement('html', $img);
     $this->_form->addElement('static', 'description', html_writer::tag('strong', get_string('warning', 'enrol_autoenrol')), get_string('warning_message', 'enrol_autoenrol'));
     $this->_form->addElement('text', 'customchar2', get_string('instancename', 'enrol_autoenrol'));
     $this->_form->setType('customchar2', PARAM_TEXT);
     $this->_form->setDefault('customchar2', '');
     $this->_form->addHelpButton('customchar2', 'instancename', 'enrol_autoenrol');
     if ($instance->id) {
         $roles = get_default_enrol_roles($context, $instance->roleid);
     } else {
         $roles = get_default_enrol_roles($context, $plugin->get_config('roleid'));
     }
     $this->_form->addElement('select', 'customint3', get_string('role', 'enrol_autoenrol'), $roles);
     $this->_form->setAdvanced('customint3');
     $this->_form->addHelpButton('customint3', 'role', 'enrol_autoenrol');
     if (!has_capability('enrol/autoenrol:method', $context)) {
         $this->_form->disabledIf('customint3', 'customint2');
     }
     $this->_form->setDefault('customint3', $plugin->get_config('defaultrole'));
     $this->_form->setType('customint3', PARAM_INT);
     $method = array(get_string('m_course', 'enrol_autoenrol'), get_string('m_site', 'enrol_autoenrol'));
     $this->_form->addElement('select', 'customint1', get_string('method', 'enrol_autoenrol'), $method);
     if (!has_capability('enrol/autoenrol:method', $context)) {
         $this->_form->disabledIf('customint1', 'customint2');
     }
     $this->_form->setAdvanced('customint1');
     $this->_form->setType('customint1', PARAM_INT);
     $this->_form->addHelpButton('customint1', 'method', 'enrol_autoenrol');
     $this->_form->addElement('selectyesno', 'customint8', get_string('alwaysenrol', 'enrol_autoenrol'));
     $this->_form->setAdvanced('customint8');
     $this->_form->setType('customint8', PARAM_INT);
     $this->_form->setDefault('customint8', 0);
     $this->_form->addHelpButton('customint8', 'alwaysenrol', 'enrol_autoenrol');
 }
Beispiel #12
0
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Cohort enrolment plugin settings and default values
 *
 * @package    enrol_mnet
 * @copyright  2010 David Mudrak <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    //--- general settings -----------------------------------------------------------------------------------
    $settings->add(new admin_setting_heading('enrol_mnet_settings', '', get_string('pluginname_desc', 'enrol_mnet')));
    //--- enrol instance defaults ----------------------------------------------------------------------------
    if (!during_initial_install()) {
        $options = get_default_enrol_roles(context_system::instance());
        $student = get_archetype_roles('student');
        $student = reset($student);
        $settings->add(new admin_setting_configselect_with_advanced('enrol_mnet/roleid', get_string('defaultrole', 'role'), '', array('value' => $student->id, 'adv' => true), $options));
    }
}
Beispiel #13
0
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Cohort enrolment plugin settings and presets.
 *
 * @package    enrol
 * @subpackage cohort
 * @copyright  2010 Petr Skoda {@link http://skodak.org}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    //--- general settings -----------------------------------------------------------------------------------
    $settings->add(new admin_setting_heading('enrol_cohort_settings', '', get_string('pluginname_desc', 'enrol_cohort')));
    //--- enrol instance defaults ----------------------------------------------------------------------------
    if (!during_initial_install()) {
        $options = get_default_enrol_roles(get_context_instance(CONTEXT_SYSTEM));
        $student = get_archetype_roles('student');
        $student = reset($student);
        $settings->add(new admin_setting_configselect('enrol_cohort/roleid', get_string('defaultrole', 'role'), '', $student->id, $options));
        $options = array(ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'));
        $settings->add(new admin_setting_configselect('enrol_cohort/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_UNENROL, $options));
    }
}
Beispiel #14
0
 /**
  * Returns an array of available roles
  * @return array of availble roles
  */
 function get_roles()
 {
     $context = context_system::instance();
     $roles = array(0 => get_string('anyrole', 'filters')) + get_default_enrol_roles($context);
     return $roles;
 }
 /**
  * Test default enrol roles.
  */
 public function test_get_default_enrol_roles()
 {
     $this->resetAfterTest();
     $course = $this->getDataGenerator()->create_course();
     $coursecontext = context_course::instance($course->id);
     $id2 = create_role('New student role', 'student2', 'New student description', 'student');
     set_role_contextlevels($id2, array(CONTEXT_COURSE));
     $allroles = get_all_roles();
     $expected = array($id2 => $allroles[$id2]);
     foreach (get_role_archetypes() as $archetype) {
         $defaults = get_default_contextlevels($archetype);
         if (in_array(CONTEXT_COURSE, $defaults)) {
             $roles = get_archetype_roles($archetype);
             foreach ($roles as $role) {
                 $expected[$role->id] = $role;
             }
         }
     }
     $roles = get_default_enrol_roles($coursecontext);
     foreach ($allroles as $role) {
         $this->assertEquals(isset($expected[$role->id]), isset($roles[$role->id]));
         if (isset($roles[$role->id])) {
             $this->assertSame(role_get_name($role, $coursecontext), $roles[$role->id]);
         }
     }
 }
 /**
  * Returns an array of available roles
  * @return array of availble roles
  */
 function get_roles()
 {
     $context = get_context_instance(CONTEXT_SYSTEM);
     $roles = array(0 => get_string('anyrole', 'filters')) + get_default_enrol_roles($context);
     return $roles;
 }
/**
 * Setups the object used in the notice strings for when a user is accepting
 * a site invitation.
 *
 * @param object $invitation
 * @return object
 */
function prepare_notice_object($invitation)
{
    global $CFG, $course, $DB;
    $noticeobject = new stdClass();
    $noticeobject->email = $invitation->email;
    $noticeobject->coursefullname = $course->fullname;
    $noticeobject->supportemail = $CFG->supportemail;
    // Get role name for use in acceptance message.
    //role name is no longer defined in `role` table. It is scattered around database.
    $context = context_course::instance($course->id);
    $roles = get_default_enrol_roles($context);
    //fetching roles using API
    if (array_key_exists($invitation->roleid, $roles)) {
        //Normally we should have roles here
        $noticeobject->rolename = $roles[$invitation->roleid];
    } else {
        //In case something gone wrong we will do this the old way
        $role = $DB->get_record('role', array('id' => $invitation->roleid));
        $noticeobject->rolename = $role->name;
        //empty in new Moodle versions
        // role description is not used anywhere in plugin
        // and is also empty in new Moodle versions
        $noticeobject->roledescription = strip_tags($role->description);
    }
    return $noticeobject;
}
Beispiel #18
0
 /**
  * Return an array of valid options for the roleid.
  *
  * @param stdClass $instance
  * @param context $context
  * @return array
  */
 protected function get_roleid_options($instance, $context)
 {
     if ($instance->id) {
         $roles = get_default_enrol_roles($context, $instance->roleid);
     } else {
         $roles = get_default_enrol_roles($context, $this->get_config('roleid'));
     }
     return $roles;
 }