foreach ($authinstances as $authinstance) { if ($USER->can_edit_institution($authinstance->name)) { $options[$authinstance->id] = $authinstance->displayname . ': ' . $authinstance->instancename; $INSTITUTIONNAME[$authinstance->name] = $authinstance->displayname; } } if ($USER->get('admin')) { $definst = get_field('auth_instance', 'id', 'institution', 'mahara'); $default = $definst ? $definst : key($options); } else { $default = key($options); } $authinstanceelement = array('type' => 'select', 'title' => get_string('institution'), 'description' => get_string('uploadcsvinstitution', 'admin'), 'options' => $options, 'defaultvalue' => $default); } $prefs = (object) expected_account_preferences(); $form = array('name' => 'uploadcsv', 'plugintype' => 'core', 'pluginname' => 'admin', 'elements' => array('authinstance' => $authinstanceelement, 'quota' => array('type' => 'bytes', 'title' => get_string('filequota1', 'admin'), 'description' => get_string('filequotadescription', 'admin'), 'rules' => array('integer' => true, 'minvalue' => 0), 'defaultvalue' => get_config_plugin('artefact', 'file', 'defaultquota')), 'file' => array('type' => 'file', 'title' => get_string('csvfile', 'admin'), 'description' => get_string('csvfiledescription', 'admin'), 'accept' => '.csv, text/csv, application/csv, text/comma-separated-values', 'rules' => array('required' => true)), 'forcepasswordchange' => array('type' => 'checkbox', 'title' => get_string('forceuserstochangepassword', 'admin'), 'description' => get_string('forceuserstochangepassworddescription', 'admin'), 'defaultvalue' => true), 'emailusers' => array('type' => 'checkbox', 'title' => get_string('emailusersaboutnewaccount', 'admin'), 'description' => get_string('emailusersaboutnewaccountdescription', 'admin'), 'defaultvalue' => true), 'updateusers' => array('type' => 'checkbox', 'title' => get_string('updateusers', 'admin'), 'description' => get_string('updateusersdescription', 'admin'), 'defaultvalue' => false), 'accountprefs' => array('type' => 'fieldset', 'legend' => get_string('accountoptionsdesc', 'account'), 'collapsible' => true, 'collapsed' => true, 'elements' => general_account_prefs_form_elements($prefs)), 'progress_meter_token' => array('type' => 'hidden', 'value' => 'uploaduserscsv', 'readonly' => TRUE), 'submit' => array('type' => 'submit', 'value' => get_string('uploadcsv', 'admin')))); if ($maxcsvlines = get_config('maxusercsvlines')) { $form['elements']['file']['description'] .= ' ' . get_string('csvmaxusersdescription', 'admin', get_string('nusers', 'mahara', $maxcsvlines)); } unset($prefs); if (!($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride'))) { $form['elements']['quota'] = array('type' => 'text', 'disabled' => true, 'title' => get_string('filequota1', 'admin'), 'description' => get_string('filequotadescription', 'admin'), 'value' => display_size(get_config_plugin('artefact', 'file', 'defaultquota'))); } /** * The CSV file is parsed here so validation errors can be returned to the * user. The data from a successful parsing is stored in the <var>$CVSDATA</var> * array so it can be accessed by the submit function * * @param Pieform $form The form to validate * @param array $values The values submitted */
if ($authinstance->authname != 'internal') { $external = true; } } } } $elements = array('firstname' => array('type' => 'text', 'title' => get_string('firstname'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'lastname' => array('type' => 'text', 'title' => get_string('lastname'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'email' => array('type' => 'text', 'title' => get_string('email'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'leap2afile' => array('type' => 'file', 'class' => 'leap2aupload', 'title' => ''), 'username' => array('type' => 'text', 'title' => get_string('username'), 'rules' => array('required' => true, 'maxlength' => 236)), 'password' => array('type' => 'password', 'title' => get_string('password'), 'rules' => array('required' => true)), 'staff' => array('type' => 'switchbox', 'title' => get_string('sitestaff', 'admin'), 'ignore' => !$USER->get('admin')), 'admin' => array('type' => 'switchbox', 'title' => get_string('siteadmin', 'admin'), 'ignore' => !$USER->get('admin')), 'quota' => array('type' => 'bytes', 'title' => get_string('filequota1', 'admin'), 'rules' => array('integer' => true, 'minvalue' => 0), 'defaultvalue' => get_config_plugin('artefact', 'file', 'defaultquota')), 'authinstance' => array('type' => 'select', 'title' => get_string('institution'), 'options' => $options, 'defaultvalue' => 1, 'rules' => array('required' => true), 'ignore' => !$authinstancecount), 'institutionadmin' => array('type' => 'switchbox', 'class' => 'last', 'title' => get_string('institutionadministrator', 'admin'), 'ignore' => !$authinstancecount), 'submit' => array('type' => 'submit', 'value' => get_string('createuser', 'admin'), 'class' => 'btn-success btn-lg btn-block mtm')); if (!$USER->get('admin')) { unset($elements['authinstance']['defaultvalue']); } if (!($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride'))) { $elements['quota'] = array('type' => 'text', 'disabled' => true, 'title' => get_string('filequota1', 'admin'), 'description' => get_string('filequotadescription', 'admin'), 'value' => display_size(get_config_plugin('artefact', 'file', 'defaultquota'))); } // Add general account options $prefs = (object) expected_account_preferences(); $elements = array_merge($elements, general_account_prefs_form_elements($prefs)); unset($prefs); $form = pieform(array('name' => 'adduser', 'class' => 'panel panel-default panel-body pts', 'autofocus' => false, 'template' => 'adduser.php', 'templatedir' => pieform_template_dir('adduser.php'), 'plugintype' => 'core', 'pluginname' => 'admin', 'class' => 'form-condensed', 'elements' => $elements)); function adduser_validate(Pieform $form, $values) { global $USER, $TRANSPORTER; $authobj = AuthFactory::create($values['authinstance']); $institution = $authobj->institution; // Institutional admins can only set their own institutions' authinstances if (!$USER->get('admin') && !$USER->is_institutional_admin($authobj->institution)) { $form->set_error('authinstance', get_string('notadminforinstitution', 'admin')); return; } $institution = new Institution($authobj->institution); // Don't exceed max user accounts for the institution if ($institution->isFull()) {
<div class="modal-header"> <button class="deletebutton close" name="action_removeblockinstance_id_80" data-dismiss="modal-docked" aria-label="Close"> <span class="times">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title blockinstance-header text-inline general-account-options-title" id="general-account-options-label"><?php echo get_string('accountoptionsdesc', 'account'); ?> </h4> </div> <div class="modal-body"> <?php // Render account preferences with a renderer (inside this template :D) $accountprefs = (object) expected_account_preferences(); $accountprefs = array_keys(general_account_prefs_form_elements($accountprefs)); $fieldset_elements = array(); foreach ($accountprefs as $p) { $fieldset_elements[] = $elements[$p]; } $accountoptions_fieldset = array('name' => 'generalaccountoptions', 'type' => 'fieldset', 'class' => 'last', 'elements' => $fieldset_elements); $this->include_plugin('renderer', $this->data['renderer']); $this->include_plugin('element', 'fieldset'); $this->build_element_html($accountoptions_fieldset); echo pieform_render_element($this, $accountoptions_fieldset); echo $hidden_elements; ?> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div>