コード例 #1
0
 /**
  * Defines forms elements
  */
 public function definition()
 {
     global $USER, $CFG;
     $mform = $this->_form;
     $mform->addElement('hidden', 'sessionid');
     $mform->setType('sessionid', PARAM_INT);
     // Adding the "general" fieldset, where all the common settings are showed.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Adding the standard "name" field.
     $mform->addElement('text', 'name', get_string('collaboratename', 'collaborate'), array('size' => '64'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEANHTML);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     // Adding the standard "intro" and "introformat" fields. Note has to be required as description is required by
     // API.
     $this->add_intro_editor(true);
     $time = time();
     // Round time up if necessary.
     $minutes = date('i', $time);
     if ($minutes >= 30) {
         $time += (60 - $minutes) * 60;
     }
     // Remove minutes.
     $time = strtotime(date('Y-m-d H:0', $time));
     // Get timezone to show against start time label.
     $tzones = get_list_of_timezones();
     if (isset($tzones[$USER->timezone])) {
         $tzone = $tzones[$USER->timezone];
     } else {
         $tzone = $tzones[date_default_timezone_get()];
     }
     $tzonestr = ' (' . get_string('timezone', 'mod_collaborate', $tzone) . ')';
     // Start Time.
     $mform->addElement('date_time_selector', 'timestart', get_string('sessionstart', 'mod_collaborate') . $tzonestr);
     $mform->setDefault('timestart', $time);
     $mform->addElement('static', 'sessionstarthelp', '', get_string('sessionstarthelp', 'mod_collaborate'));
     $options = [HOURSECS * 0.5 => get_string('minutes', 'mod_collaborate', '30'), HOURSECS => get_string('hour', 'mod_collaborate'), HOURSECS * 1.5 => get_string('hourminutes', 'mod_collaborate', (object) ['hours' => 1, 'minutes' => 30]), HOURSECS * 2 => get_string('hours', 'mod_collaborate', 2), HOURSECS * 2.5 => get_string('hoursminutes', 'mod_collaborate', (object) ['hours' => 2, 'minutes' => 30]), 9999 => get_string('openended', 'mod_collaborate')];
     $mform->addElement('select', 'duration', get_string('duration', 'mod_collaborate'), $options);
     $mform->setDefault('duration', HOURSECS);
     // Add standard grading elements.
     $this->standard_grading_coursemodule_elements();
     // Add standard elements, common to all modules.
     $this->standard_coursemodule_elements();
     // Add standard buttons, common to all modules.
     $this->add_action_buttons();
 }
コード例 #2
0
 public function test_get_list_of_timezones()
 {
     // Use timezones that are not problematic, this way we may test before
     // and after the big tz rewrite.
     $list = get_list_of_timezones();
     $this->assertDebuggingCalled();
     $this->assertArrayHasKey('Europe/London', $list);
     $this->assertArrayHasKey('Pacific/Auckland', $list);
     $this->assertArrayHasKey('America/New_York', $list);
     $this->assertArrayHasKey('Europe/Berlin', $list);
     $this->assertArrayHasKey('Europe/Prague', $list);
     $this->assertArrayHasKey('Australia/Perth', $list);
     $this->assertArrayHasKey('Australia/Lord_Howe', $list);
 }
コード例 #3
0
<?php

// $Id$
// "locations" settingpage
$temp = new admin_settingpage('locationsettings', get_string('locationsettings', 'admin'));
$options = get_list_of_timezones();
$options[99] = get_string('serverlocaltime');
$temp->add(new admin_setting_configselect('timezone', get_string('timezone', 'admin'), get_string('configtimezone', 'admin'), 99, $options));
$options[99] = get_string('timezonenotforced', 'admin');
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
$options = get_list_of_countries();
$options[0] = get_string('choose') . '...';
$temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0, $options));
$iplookups = array();
if ($plugins = get_list_of_plugins('iplookup')) {
    foreach ($plugins as $plugin) {
        $iplookups[$plugin] = $plugin;
    }
}
$temp->add(new admin_setting_configselect('iplookup', get_string('iplookup', 'admin'), get_string('configiplookup', 'admin'), 'hostip', $iplookups));
$ADMIN->add('location', $temp);
$ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "{$CFG->wwwroot}/{$CFG->admin}/timezoneimport.php"));
コード例 #4
0
function useredit_shared_definition(&$mform, $editoroptions = null)
{
    global $CFG, $USER, $DB;
    $user = $DB->get_record('user', array('id' => $USER->id));
    useredit_load_preferences($user, false);
    $strrequired = get_string('required');
    $nameordercheck = new stdClass();
    $nameordercheck->firstname = 'a';
    $nameordercheck->lastname = 'b';
    if (fullname($nameordercheck) == 'b a') {
        // See MDL-4325
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
    } else {
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
    }
    $mform->addRule('firstname', $strrequired, 'required', null, 'client');
    $mform->setType('firstname', PARAM_NOTAGS);
    $mform->addRule('lastname', $strrequired, 'required', null, 'client');
    $mform->setType('lastname', PARAM_NOTAGS);
    // Do not show email field if change confirmation is pending
    if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
        $notice = get_string('emailchangepending', 'auth', $user);
        $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
        $mform->addElement('static', 'emailpending', get_string('email'), $notice);
    } else {
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
        $mform->addRule('email', $strrequired, 'required', null, 'client');
    }
    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    $choices['1'] = get_string('emaildisplayyes');
    $choices['2'] = get_string('emaildisplaycourse');
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', 2);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', 1);
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', 0);
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', 1);
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', 0);
    }
    $editors = editors_get_enabled();
    if (count($editors) > 1) {
        $choices = array();
        $choices['0'] = get_string('texteditor');
        $choices['1'] = get_string('htmleditor');
        $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('htmleditor', 1);
    } else {
        $mform->addElement('hidden', 'htmleditor');
        $mform->setDefault('htmleditor', 1);
        $mform->setType('htmleditor', PARAM_INT);
    }
    if (empty($CFG->enableajax)) {
        $mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
    } else {
        $choices = array();
        $choices['0'] = get_string('ajaxno');
        $choices['1'] = get_string('ajaxyes');
        $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
        $mform->setDefault('ajax', 0);
    }
    $choices = array();
    $choices['0'] = get_string('screenreaderno');
    $choices['1'] = get_string('screenreaderyes');
    $mform->addElement('select', 'screenreader', get_string('screenreaderuse'), $choices);
    $mform->setDefault('screenreader', 0);
    $mform->addHelpButton('screenreader', 'screenreaderuse');
    $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
    $mform->setType('city', PARAM_MULTILANG);
    $mform->addRule('city', $strrequired, 'required', null, 'client');
    if (!empty($CFG->defaultcity)) {
        $mform->setDefault('city', $CFG->defaultcity);
    }
    $choices = get_string_manager()->get_list_of_countries();
    $choices = array('' => get_string('selectacountry') . '...') + $choices;
    $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
    $mform->addRule('country', $strrequired, 'required', null, 'client');
    if (!empty($CFG->country)) {
        $mform->setDefault('country', $CFG->country);
    }
    $choices = get_list_of_timezones();
    $choices['99'] = get_string('serverlocaltime');
    if ($CFG->forcetimezone != 99) {
        $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
    } else {
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', '99');
    }
    $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
    $mform->setDefault('lang', $CFG->lang);
    if (!empty($CFG->allowuserthemes)) {
        $choices = array();
        $choices[''] = get_string('default');
        $themes = get_list_of_themes();
        foreach ($themes as $key => $theme) {
            if (empty($theme->hidefromselector)) {
                $choices[$key] = $theme->name;
            }
        }
        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
    }
    $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
    $mform->setType('description_editor', PARAM_CLEANHTML);
    $mform->addHelpButton('description_editor', 'userdescription');
    if (!empty($CFG->gdversion) and empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', 0);
        $mform->addElement('filepicker', 'imagefile', get_string('newpicture'), '', array('maxbytes' => get_max_upload_file_size($CFG->maxbytes)));
        $mform->addHelpButton('imagefile', 'newpicture');
        $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
        $mform->setType('imagealt', PARAM_MULTILANG);
    }
    if (!empty($CFG->usetags) and empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_interests', get_string('interests'));
        $mform->addElement('tags', 'interests', get_string('interestslist'), array('display' => 'noofficial'));
        $mform->addHelpButton('interests', 'interestslist');
    }
    /// Moodle optional fields
    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
    $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
    $mform->setType('url', PARAM_URL);
    $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
    $mform->setType('icq', PARAM_NOTAGS);
    $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
    $mform->setType('skype', PARAM_NOTAGS);
    $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
    $mform->setType('aim', PARAM_NOTAGS);
    $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
    $mform->setType('yahoo', PARAM_NOTAGS);
    $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
    $mform->setType('msn', PARAM_NOTAGS);
    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
    $mform->setType('idnumber', PARAM_NOTAGS);
    $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
    $mform->setType('institution', PARAM_MULTILANG);
    $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
    $mform->setType('department', PARAM_MULTILANG);
    $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
    $mform->setType('phone1', PARAM_NOTAGS);
    $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
    $mform->setType('phone2', PARAM_NOTAGS);
    $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
    $mform->setType('address', PARAM_MULTILANG);
}
コード例 #5
0
 public function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     $templateuser = $USER;
     $context = $this->_customdata['context'];
     $mform->addElement('header', 'settingsheader', get_string('toolsettings', 'local_ltiprovider'));
     $tools = array();
     $tools[$context->id] = get_string('course');
     $modinfo = get_fast_modinfo($this->_customdata['courseid']);
     $mods = $modinfo->get_cms();
     foreach ($mods as $mod) {
         $tools[$mod->context->id] = format_string($mod->name);
     }
     $mform->addElement('select', 'contextid', get_string('tooltobeprovide', 'local_ltiprovider'), $tools);
     $mform->setDefault('contextid', $context->id);
     $mform->addElement('checkbox', 'sendgrades', null, get_string('sendgrades', 'local_ltiprovider'));
     $mform->setDefault('sendgrades', 1);
     $mform->addElement('checkbox', 'forcenavigation', null, get_string('forcenavigation', 'local_ltiprovider'));
     $mform->setDefault('forcenavigation', 1);
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'local_ltiprovider'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', 0);
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'local_ltiprovider');
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'local_ltiprovider'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'local_ltiprovider');
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'local_ltiprovider'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'local_ltiprovider');
     $mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'local_ltiprovider'));
     $mform->setDefault('maxenrolled', 0);
     $mform->addHelpButton('maxenrolled', 'maxenrolled', 'local_ltiprovider');
     $mform->setType('maxenrolled', PARAM_INT);
     $assignableroles = get_assignable_roles($context);
     $mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
     $mform->setDefault('croleinst', '3');
     $mform->setAdvanced('croleinst');
     $mform->addElement('select', 'crolelearn', get_string('courserolelearner', 'local_ltiprovider'), $assignableroles);
     $mform->setDefault('crolelearn', '5');
     $mform->setAdvanced('crolelearn');
     $mform->addElement('select', 'aroleinst', get_string('activityroleinstructor', 'local_ltiprovider'), $assignableroles);
     $mform->disabledIf('aroleinst', 'contextid', 'eq', $context->id);
     $mform->setDefault('aroleinst', '3');
     $mform->setAdvanced('aroleinst');
     $mform->addElement('select', 'arolelearn', get_string('activityrolelearner', 'local_ltiprovider'), $assignableroles);
     $mform->disabledIf('arolelearn', 'contextid', 'eq', $context->id);
     $mform->setDefault('arolelearn', '5');
     $mform->setAdvanced('arolelearn');
     $mform->addElement('header', 'remotesystem', get_string('remotesystem', 'local_ltiprovider'));
     $mform->addElement('text', 'secret', get_string('secret', 'local_ltiprovider'), 'maxlength="64" size="25"');
     $mform->setType('secret', PARAM_MULTILANG);
     $mform->setDefault('secret', md5(uniqid(rand(), 1)));
     $mform->addRule('secret', get_string('required'), 'required');
     if (class_exists('textlib')) {
         $textlib = new textlib();
     } else {
         try {
             // for older moodle instances
             $textlib = textlib_get_instance();
         } catch (Exception $e) {
             // updated to use new core_text lib as required by Moodle 2.9
             $textlib = new core_text();
         }
     }
     $choices = $textlib->get_encodings();
     $mform->addElement('select', 'encoding', get_string('remoteencoding', 'local_ltiprovider'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     $mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'local_ltiprovider'));
     $choices = array(0 => get_string('never'), 1 => get_string('always'));
     $mform->addElement('select', 'userprofileupdate', get_string('userprofileupdate', 'local_ltiprovider'), $choices);
     $userprofileupdate = get_config('local_ltiprovider', 'userprofileupdate');
     if ($userprofileupdate != -1) {
         $mform->setDefault('userprofileupdate', $userprofileupdate);
         $mform->freeze('userprofileupdate');
     } else {
         $mform->setDefault('userprofileupdate', 1);
     }
     $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_MULTILANG);
     if (empty($CFG->defaultcity)) {
         $mform->setDefault('city', $templateuser->city);
     } else {
         $mform->setDefault('city', $CFG->defaultcity);
     }
     $mform->addRule('city', get_string('required'), 'required');
     $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
     if (empty($CFG->country)) {
         $mform->setDefault('country', $templateuser->country);
     } else {
         $mform->setDefault('country', $CFG->country);
     }
     $mform->setAdvanced('country');
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->setAdvanced('timezone');
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->setAdvanced('lang');
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', PARAM_MULTILANG);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->setAdvanced('institution');
     $mform->addElement('header', 'memberships', get_string('membershipsettings', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'syncmembers', null, get_string('enablememberssync', 'local_ltiprovider'));
     $mform->disabledIf('syncmembers', 'contextid', 'neq', $context->id);
     $options = array();
     $options[30 * 60] = '30 ' . get_string('minutes');
     $options[60 * 60] = '1 ' . get_string('hour');
     $options[2 * 60 * 60] = '2 ' . get_string('hours');
     $options[6 * 60 * 60] = '6 ' . get_string('hours');
     $options[12 * 60 * 60] = '12 ' . get_string('hours');
     $options[24 * 60 * 60] = '24 ' . get_string('hours');
     $mform->addElement('select', 'syncperiod', get_string('syncperiod', 'local_ltiprovider'), $options);
     $mform->setDefault('syncperiod', 30 * 60);
     $mform->disabledIf('syncperiod', 'contextid', 'neq', $context->id);
     $options = array();
     $options[1] = get_string('enrolandunenrol', 'local_ltiprovider');
     $options[2] = get_string('enrolnew', 'local_ltiprovider');
     $options[3] = get_string('unenrolmissing', 'local_ltiprovider');
     $mform->addElement('select', 'syncmode', get_string('syncmode', 'local_ltiprovider'), $options);
     $mform->setDefault('syncmode', 1);
     $mform->disabledIf('syncmode', 'contextid', 'neq', $context->id);
     $mform->addElement('header', 'layoutandcss', get_string('layoutandcss', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hidepageheader', null, get_string('hidepageheader', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hidepagefooter', null, get_string('hidepagefooter', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hideleftblocks', null, get_string('hideleftblocks', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hiderightblocks', null, get_string('hiderightblocks', 'local_ltiprovider'));
     $mform->setAdvanced('hideleftblocks');
     $mform->setAdvanced('hiderightblocks');
     $editoroptions = array();
     $displayoptions = array('rows' => '4', 'cols' => '');
     $mform->addElement('textarea', 'customcss', get_string('customcss', 'local_ltiprovider'), $displayoptions, $editoroptions);
     $mform->setAdvanced('customcss');
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
 }
コード例 #6
0
 function definition()
 {
     global $CFG, $USER;
     $mform = $this->_form;
     $columns = $this->_customdata['columns'];
     $data = $this->_customdata['data'];
     // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-)
     $templateuser = $USER;
     // upload settings and file
     $mform->addElement('header', 'settingsheader', get_string('settings'));
     $choices = array(UU_USER_ADDNEW => get_string('uuoptype_addnew', 'tool_uploaduser'), UU_USER_ADDINC => get_string('uuoptype_addinc', 'tool_uploaduser'), UU_USER_ADD_UPDATE => get_string('uuoptype_addupdate', 'tool_uploaduser'), UU_USER_UPDATE => get_string('uuoptype_update', 'tool_uploaduser'));
     $mform->addElement('select', 'uutype', get_string('uuoptype', 'tool_uploaduser'), $choices);
     $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth'));
     $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'tool_uploaduser'), $choices);
     $mform->setDefault('uupasswordnew', 1);
     $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_USER_UPDATE);
     $choices = array(UU_UPDATE_NOCHANGES => get_string('nochanges', 'tool_uploaduser'), UU_UPDATE_FILEOVERRIDE => get_string('uuupdatefromfile', 'tool_uploaduser'), UU_UPDATE_ALLOVERRIDE => get_string('uuupdateall', 'tool_uploaduser'), UU_UPDATE_MISSING => get_string('uuupdatemissing', 'tool_uploaduser'));
     $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'tool_uploaduser'), $choices);
     $mform->setDefault('uuupdatetype', UU_UPDATE_NOCHANGES);
     $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDNEW);
     $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDINC);
     $choices = array(0 => get_string('nochanges', 'tool_uploaduser'), 1 => get_string('update'));
     $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'tool_uploaduser'), $choices);
     $mform->setDefault('uupasswordold', 0);
     $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDNEW);
     $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDINC);
     $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0);
     $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3);
     $choices = array(UU_PWRESET_WEAK => get_string('usersweakpassword', 'tool_uploaduser'), UU_PWRESET_NONE => get_string('none'), UU_PWRESET_ALL => get_string('all'));
     if (empty($CFG->passwordpolicy)) {
         unset($choices[UU_PWRESET_WEAK]);
     }
     $mform->addElement('select', 'uuforcepasswordchange', get_string('forcepasswordchange', 'core'), $choices);
     $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'tool_uploaduser'));
     $mform->setDefault('uuallowrenames', 0);
     $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDNEW);
     $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDINC);
     $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'tool_uploaduser'));
     $mform->setDefault('uuallowdeletes', 0);
     $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDNEW);
     $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDINC);
     $mform->addElement('selectyesno', 'uuallowsuspends', get_string('allowsuspends', 'tool_uploaduser'));
     $mform->setDefault('uuallowsuspends', 1);
     $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDNEW);
     $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDINC);
     $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser'));
     $mform->setDefault('uunoemailduplicates', 1);
     $mform->addElement('selectyesno', 'uustandardusernames', get_string('uustandardusernames', 'tool_uploaduser'));
     $mform->setDefault('uustandardusernames', 1);
     $choices = array(UU_BULK_NONE => get_string('no'), UU_BULK_NEW => get_string('uubulknew', 'tool_uploaduser'), UU_BULK_UPDATED => get_string('uubulkupdated', 'tool_uploaduser'), UU_BULK_ALL => get_string('uubulkall', 'tool_uploaduser'));
     $mform->addElement('select', 'uubulk', get_string('uubulk', 'tool_uploaduser'), $choices);
     $mform->setDefault('uubulk', 0);
     // roles selection
     $showroles = false;
     foreach ($columns as $column) {
         if (preg_match('/^type\\d+$/', $column)) {
             $showroles = true;
             break;
         }
     }
     if ($showroles) {
         $mform->addElement('header', 'rolesheader', get_string('roles'));
         $choices = uu_allowed_roles(true);
         $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'tool_uploaduser'), $choices);
         if ($studentroles = get_archetype_roles('student')) {
             foreach ($studentroles as $role) {
                 if (isset($choices[$role->id])) {
                     $mform->setDefault('uulegacy1', $role->id);
                     break;
                 }
             }
             unset($studentroles);
         }
         $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'tool_uploaduser'), $choices);
         if ($editteacherroles = get_archetype_roles('editingteacher')) {
             foreach ($editteacherroles as $role) {
                 if (isset($choices[$role->id])) {
                     $mform->setDefault('uulegacy2', $role->id);
                     break;
                 }
             }
             unset($editteacherroles);
         }
         $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'tool_uploaduser'), $choices);
         if ($teacherroles = get_archetype_roles('teacher')) {
             foreach ($teacherroles as $role) {
                 if (isset($choices[$role->id])) {
                     $mform->setDefault('uulegacy3', $role->id);
                     break;
                 }
             }
             unset($teacherroles);
         }
     }
     // default values
     $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploaduser'));
     $mform->addElement('text', 'username', get_string('uuusernametemplate', 'tool_uploaduser'), 'size="20"');
     $mform->setType('username', PARAM_RAW);
     // No cleaning here. The process verifies it later.
     $mform->addRule('username', get_string('requiredtemplate', 'tool_uploaduser'), 'required', null, 'client');
     $mform->disabledIf('username', 'uutype', 'eq', UU_USER_ADD_UPDATE);
     $mform->disabledIf('username', 'uutype', 'eq', UU_USER_UPDATE);
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $mform->setType('email', PARAM_RAW);
     // No cleaning here. The process verifies it later.
     $mform->disabledIf('email', 'uutype', 'eq', UU_USER_ADD_UPDATE);
     $mform->disabledIf('email', 'uutype', 'eq', UU_USER_UPDATE);
     // only enabled and known to work plugins
     $choices = uu_supported_auths();
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $choices);
     $mform->setDefault('auth', 'manual');
     // manual is a sensible backwards compatible default
     $mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
     $mform->setAdvanced('auth');
     $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     $mform->setAdvanced('mailformat');
     $choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects'));
     $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
     $mform->setDefault('maildigest', 0);
     $mform->setAdvanced('maildigest');
     $choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno'));
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
     $mform->setType('city', PARAM_TEXT);
     if (empty($CFG->defaultcity)) {
         $mform->setDefault('city', $templateuser->city);
     } else {
         $mform->setDefault('city', $CFG->defaultcity);
     }
     $choices = get_string_manager()->get_list_of_countries();
     $choices = array('' => get_string('selectacountry') . '...') + $choices;
     $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
     if (empty($CFG->country)) {
         $mform->setDefault('country', $templateuser->country);
     } else {
         $mform->setDefault('country', $CFG->country);
     }
     $mform->setAdvanced('country');
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->setAdvanced('timezone');
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->setAdvanced('lang');
     $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false);
     $mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions);
     $mform->setType('description', PARAM_CLEANHTML);
     $mform->addHelpButton('description', 'userdescription');
     $mform->setAdvanced('description');
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $mform->setType('url', PARAM_URL);
     $mform->setAdvanced('url');
     $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
     $mform->setType('idnumber', PARAM_NOTAGS);
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
     $mform->setType('institution', PARAM_TEXT);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
     $mform->setType('department', PARAM_TEXT);
     $mform->setDefault('department', $templateuser->department);
     $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone1', PARAM_NOTAGS);
     $mform->setAdvanced('phone1');
     $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
     $mform->setType('phone2', PARAM_NOTAGS);
     $mform->setAdvanced('phone2');
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
     $mform->setType('address', PARAM_TEXT);
     $mform->setAdvanced('address');
     // Next the profile defaults
     profile_definition($mform);
     // hidden fields
     $mform->addElement('hidden', 'iid');
     $mform->setType('iid', PARAM_INT);
     $mform->addElement('hidden', 'previewrows');
     $mform->setType('previewrows', PARAM_INT);
     $this->add_action_buttons(true, get_string('uploadusers', 'tool_uploaduser'));
     $this->set_data($data);
 }
コード例 #7
0
ファイル: editlib.php プロジェクト: helenagarcia90/moodle
function useredit_shared_definition(&$mform, $editoroptions = null, $filemanageroptions = null)
{
    global $CFG, $USER, $DB;
    $user = $DB->get_record('user', array('id' => $USER->id));
    useredit_load_preferences($user, false);
    $strrequired = get_string('required');
    // Add the necessary names.
    foreach (useredit_get_required_name_fields() as $fullname) {
        $mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
        $mform->addRule($fullname, $strrequired, 'required', null, 'client');
        $mform->setType($fullname, PARAM_NOTAGS);
    }
    $enabledusernamefields = useredit_get_enabled_name_fields();
    // Add the enabled additional name fields.
    foreach ($enabledusernamefields as $addname) {
        $mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
        $mform->setType($addname, PARAM_NOTAGS);
    }
    // Do not show email field if change confirmation is pending
    if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
        $notice = get_string('emailchangepending', 'auth', $user);
        $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
        $mform->addElement('static', 'emailpending', get_string('email'), $notice);
    } else {
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
        $mform->addRule('email', $strrequired, 'required', null, 'client');
        $mform->setType('email', PARAM_EMAIL);
    }
    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    $choices['1'] = get_string('emaildisplayyes');
    $choices['2'] = get_string('emaildisplaycourse');
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', 2);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', 1);
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', 0);
    $mform->addHelpButton('maildigest', 'emaildigest');
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', 1);
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', 0);
    }
    $editors = editors_get_enabled();
    if (count($editors) > 1) {
        $choices = array('' => get_string('defaulteditor'));
        $firsteditor = '';
        foreach (array_keys($editors) as $editor) {
            if (!$firsteditor) {
                $firsteditor = $editor;
            }
            $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
        }
        $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('preference_htmleditor', '');
    } else {
        // Empty string means use the first chosen text editor.
        $mform->addElement('hidden', 'preference_htmleditor');
        $mform->setDefault('preference_htmleditor', '');
        $mform->setType('preference_htmleditor', PARAM_PLUGIN);
    }
    $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
    $mform->setType('city', PARAM_TEXT);
    if (!empty($CFG->defaultcity)) {
        $mform->setDefault('city', $CFG->defaultcity);
    }
    $choices = get_string_manager()->get_list_of_countries();
    $choices = array('' => get_string('selectacountry') . '...') + $choices;
    $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
    if (!empty($CFG->country)) {
        $mform->setDefault('country', $CFG->country);
    }
    $choices = get_list_of_timezones();
    $choices['99'] = get_string('serverlocaltime');
    if ($CFG->forcetimezone != 99) {
        $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
    } else {
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', '99');
    }
    $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
    $mform->setDefault('lang', $CFG->lang);
    // Multi-Calendar Support - see MDL-18375.
    $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
    // We do not want to show this option unless there is more than one calendar type to display.
    if (count($calendartypes) > 1) {
        $mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
    }
    if (!empty($CFG->allowuserthemes)) {
        $choices = array();
        $choices[''] = get_string('default');
        $themes = get_list_of_themes();
        foreach ($themes as $key => $theme) {
            if (empty($theme->hidefromselector)) {
                $choices[$key] = get_string('pluginname', 'theme_' . $theme->name);
            }
        }
        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
    }
    $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
    $mform->setType('description_editor', PARAM_CLEANHTML);
    $mform->addHelpButton('description_editor', 'userdescription');
    if (empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
        if (!empty($CFG->enablegravatar)) {
            $mform->addElement('html', html_writer::tag('p', get_string('gravatarenabled')));
        }
        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', 0);
        $mform->addElement('filemanager', 'imagefile', get_string('newpicture'), '', $filemanageroptions);
        $mform->addHelpButton('imagefile', 'newpicture');
        $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
        $mform->setType('imagealt', PARAM_TEXT);
    }
    // Display user name fields that are not currenlty enabled here if there are any.
    $disabledusernamefields = useredit_get_disabled_name_fields($enabledusernamefields);
    if (count($disabledusernamefields) > 0) {
        $mform->addElement('header', 'moodle_additional_names', get_string('additionalnames'));
        foreach ($disabledusernamefields as $allname) {
            $mform->addElement('text', $allname, get_string($allname), 'maxlength="100" size="30"');
            $mform->setType($allname, PARAM_NOTAGS);
        }
    }
    if (!empty($CFG->usetags) and empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_interests', get_string('interests'));
        $mform->addElement('tags', 'interests', get_string('interestslist'), array('display' => 'noofficial'));
        $mform->addHelpButton('interests', 'interestslist');
    }
    /// Moodle optional fields
    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
    $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
    $mform->setType('url', PARAM_URL);
    $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
    $mform->setType('icq', PARAM_NOTAGS);
    $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
    $mform->setType('skype', PARAM_NOTAGS);
    $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
    $mform->setType('aim', PARAM_NOTAGS);
    $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
    $mform->setType('yahoo', PARAM_NOTAGS);
    $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
    $mform->setType('msn', PARAM_NOTAGS);
    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
    $mform->setType('idnumber', PARAM_NOTAGS);
    $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
    $mform->setType('institution', PARAM_TEXT);
    $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
    $mform->setType('department', PARAM_TEXT);
    $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
    $mform->setType('phone1', PARAM_NOTAGS);
    $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
    $mform->setType('phone2', PARAM_NOTAGS);
    $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
    $mform->setType('address', PARAM_TEXT);
}
コード例 #8
0
 function definition()
 {
     global $CFG, $USER;
     //no editors here - we need proper empty fields
     $CFG->htmleditor = null;
     $mform =& $this->_form;
     $columns =& $this->_customdata;
     // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-)
     $templateuser = $USER;
     // upload settings and file
     $mform->addElement('header', 'settingsheader', get_string('settings'));
     $choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'admin'), UU_ADDINC => get_string('uuoptype_addinc', 'admin'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'admin'), UU_UPDATE => get_string('uuoptype_update', 'admin'));
     $mform->addElement('select', 'uutype', get_string('uuoptype', 'admin'), $choices);
     $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth'));
     $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'admin'), $choices);
     $mform->setDefault('uupasswordnew', 0);
     $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_UPDATE);
     $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('uuupdatefromfile', 'admin'), 2 => get_string('uuupdateall', 'admin'), 3 => get_string('uuupdatemissing', 'admin'));
     $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'admin'), $choices);
     $mform->setDefault('uuupdatetype', 0);
     $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDNEW);
     $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDINC);
     $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('update'));
     $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'admin'), $choices);
     $mform->setDefault('uupasswordold', 0);
     $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDNEW);
     $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDINC);
     $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0);
     $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3);
     $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'admin'));
     $mform->setDefault('uuallowrenames', 0);
     $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW);
     $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC);
     $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin'));
     $mform->setDefault('uuallowdeletes', 0);
     $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW);
     $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC);
     $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'admin'));
     $mform->setDefault('uunoemailduplicates', 0);
     $choices = array(0 => get_string('no'), 1 => get_string('uubulknew', 'admin'), 2 => get_string('uubulkupdated', 'admin'), 3 => get_string('uubulkall', 'admin'));
     $mform->addElement('select', 'uubulk', get_string('uubulk', 'admin'), $choices);
     $mform->setDefault('uubulk', 0);
     // roles selection
     $showroles = false;
     foreach ($columns as $column) {
         if (preg_match('/^type\\d+$/', $column)) {
             $showroles = true;
             break;
         }
     }
     if ($showroles) {
         $mform->addElement('header', 'rolesheader', get_string('roles'));
         $choices = uu_allowed_roles(true);
         $choices[0] = get_string('uucoursedefaultrole', 'admin');
         $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'admin'), $choices);
         $mform->setDefault('uulegacy1', 0);
         unset($choices[0]);
         $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'admin'), $choices);
         if ($editteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) {
             $editteacherrole = array_shift($editteacherroles);
             /// Take the first one
             $mform->setDefault('uulegacy2', $editteacherrole->id);
             unset($editteacherroles);
         } else {
             $mform->setDefault('uulegacy2', $CFG->defaultcourseroleid);
         }
         $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'admin'), $choices);
         if ($teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
             $teacherrole = array_shift($teacherroles);
             /// Take the first one
             $mform->setDefault('uulegacy3', $teacherrole->id);
             unset($teacherroles);
         } else {
             $mform->setDefault('uulegacy3', $CFG->defaultcourseroleid);
         }
     }
     // default values
     $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client');
     // only enabled and known to work plugins
     $choices = uu_allowed_auths();
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $choices);
     $mform->setDefault('auth', 'manual');
     // manual is a sensible backwards compatible default
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->setAdvanced('auth');
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $choices = array(0 => get_string('emailenable'), 1 => get_string('emaildisable'));
     $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
     $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     $mform->setAdvanced('mailformat');
     $choices = array(0 => get_string('autosubscribeyes'), 1 => get_string('autosubscribeno'));
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     if ($CFG->htmleditor) {
         $choices = array(0 => get_string('texteditor'), 1 => get_string('htmleditor'));
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     } else {
         $mform->addElement('static', 'htmleditor', get_string('textediting'), get_string('texteditor'));
     }
     $mform->setAdvanced('htmleditor');
     if (empty($CFG->enableajax)) {
         $mform->addElement('static', 'ajax', get_string('ajaxuse'), get_string('ajaxno'));
     } else {
         $choices = array(0 => get_string('ajaxno'), 1 => get_string('ajaxyes'));
         $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
         $mform->setDefault('ajax', 1);
     }
     $mform->setAdvanced('ajax');
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_MULTILANG);
     $mform->setDefault('city', $templateuser->city);
     $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries());
     $mform->setDefault('country', $templateuser->country);
     $mform->setAdvanced('country');
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->setAdvanced('timezone');
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->setAdvanced('lang');
     $mform->addElement('htmleditor', 'description', get_string('userdescription'));
     $mform->setType('description', PARAM_CLEAN);
     $mform->setHelpButton('description', array('text', get_string('helptext')));
     $mform->setAdvanced('description');
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $mform->setAdvanced('url');
     $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
     $mform->setType('idnumber', PARAM_CLEAN);
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', PARAM_MULTILANG);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
     $mform->setType('department', PARAM_MULTILANG);
     $mform->setDefault('department', $templateuser->department);
     $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone1', PARAM_CLEAN);
     $mform->setAdvanced('phone1');
     $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone2', PARAM_CLEAN);
     $mform->setAdvanced('phone2');
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
     $mform->setType('address', PARAM_MULTILANG);
     $mform->setAdvanced('address');
     /// Next the profile defaults
     profile_definition($mform);
     // hidden fields
     $mform->addElement('hidden', 'iid');
     $mform->setType('iid', PARAM_INT);
     $mform->addElement('hidden', 'previewrows');
     $mform->setType('previewrows', PARAM_INT);
     $mform->addElement('hidden', 'readcount');
     $mform->setType('readcount', PARAM_INT);
     $this->add_action_buttons(true, get_string('uploadusers'));
 }
コード例 #9
0
ファイル: scheduling.php プロジェクト: jamesmcq/elis
 function definition()
 {
     global $PAGE;
     require_js_files();
     $mform =& $this->_form;
     $page = $this->_customdata;
     $workflow = $page->workflow;
     // Get the workflow data for the timezone to keep the time_selector in line
     $workflowdata = $workflow->unserialize_data(array());
     $mform->addElement('html', '');
     // Add javascript function to toggle the simple/recurring calendar elements
     // Also add a listener to show/hide the simple/calendar elements on page load
     $mform->addElement('html', '<script type="text/javascript">
         function switchCalendar() {
             var showHide = document.getElementsByName("recurrencetype");
             var simple = document.getElementById("id_simplerecurrencegroup");
             var calendar = document.getElementById("id_calendarrecurrencegroup");
             var simplestate = simple.className.indexOf("collapsed") >= 0 ? "collapsed" : "";
             var calendarstate = calendar.className.indexOf("collapsed") >= 0 ? "collapsed" : "";
             if (showHide["0"].checked) {
                 if(showHide["0"].value == \'calendar\')
                 {
                     simple.className = "accesshide collapsible "+simplestate;
                     calendar.className = "clearfix collapsible "+calendarstate;
                 }
                 else
                 {
                     simple.className = "clearfix collapsible "+simplestate;
                     calendar.className = "accesshide collapsible "+calendarstate;
                 }
             }
             else
                 if(showHide["0"].value == \'simple\')
                 {
                     simple.className = "accesshide collapsible "+simplestate;
                     calendar.className = "clearfix collapsible "+calendarstate;
                 }
                 else
                 {
                     simple.className = "clearfix collapsible "+simplestate;
                     calendar.className = "accesshide collapsible "+calendarstate;
                 }
         }
     function initCalendar() {
         YUI().use("yui2-event", function(Y) {
             var YAHOO = Y.YUI2;
             YAHOO.util.Event.onDOMReady(switchCalendar());
         });
     }
     YUI().use("yui2-event", function(Y) {
         var YAHOO = Y.YUI2;
         YAHOO.util.Event.onDOMReady(initCalendar);
     });
     </script>');
     $mform->addElement('hidden', '_wfid', $workflow->id);
     $mform->setType('_wfid', PARAM_INT);
     $mform->addElement('hidden', '_step', scheduling_workflow::STEP_SCHEDULE);
     $mform->setType('_step', PARAM_TEXT);
     $mform->addElement('hidden', 'action', 'save');
     $mform->setType('action', PARAM_TEXT);
     $mform->addElement('html', '<h2>' . htmlspecialchars(get_string('recurrence_description', 'local_elisreports')) . '</h2>');
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', 99);
     $group = array();
     $group[] = $mform->createElement('radio', 'starttype', '', get_string('now', 'local_elisreports'), 0);
     // Add onclick action to toggle the calendar
     $mform->_attributes['onclick'] = 'switchCalendar();';
     $group[] = $mform->createElement('radio', 'starttype', '', get_string('time_on', 'local_elisreports'), 1);
     // Add onclick action to toggle the calendar
     $mform->_attributes['onclick'] = 'switchCalendar();';
     //Set date options: timezone = 0 so it doesn't adjust the time ...
     $date_options = array('timezone' => 0, 'optional' => false, 'startyear' => userdate(time(), '%Y', -13, false), 'stopyear' => 2038, 'applydst' => false);
     $group[] = $mform->createElement('date_selector', 'startdate', '', $date_options);
     $mform->addGroup($group, 'starttype', get_string('start', 'local_elisreports'), '', false);
     $mform->setDefault('starttype', 0);
     $mform->addRule('starttype', get_string('required_field', 'local_elisreports', get_string('start', 'local_elisreports')), 'required', null, 'client');
     $mform->disabledIf('startdate', 'starttype', 'neq', 1);
     $mform->disabledIf('startdate[day]', 'starttype', 'neq', 1);
     $mform->disabledIf('startdate[month]', 'starttype', 'neq', 1);
     $mform->disabledIf('startdate[year]', 'starttype', 'neq', 1);
     $group = array();
     $group[] = $mform->createElement('radio', 'recurrencetype', '', get_string('simple_recurrence', 'local_elisreports'), scheduling_workflow::RECURRENCE_SIMPLE);
     $group[] = $mform->createElement('radio', 'recurrencetype', '', get_string('calendar_recurrence', 'local_elisreports'), scheduling_workflow::RECURRENCE_CALENDAR);
     $mform->addGroup($group, 'recurrencetype', get_string('recurrence', 'local_elisreports'), '', false);
     $mform->setDefault('recurrencetype', scheduling_workflow::RECURRENCE_SIMPLE);
     $mform->addRule('recurrencetype', get_string('required_field', 'local_elisreports', get_string('recurrence', 'local_elisreports')), 'required', null, 'client');
     $mform->addElement('header', 'simplerecurrencegroup', get_string('simple_recurrence_settings', 'local_elisreports'));
     $group = array();
     $group[] = $mform->createElement('radio', 'runtype', '', get_string('indefinitely', 'local_elisreports'), 0);
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('radio', 'runtype', '', get_string('until', 'local_elisreports'), 1);
     $group[] = $mform->createElement('date_selector', 'enddate', '', $date_options);
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('radio', 'runtype', '', '', 2);
     $group[] = $mform->createElement('text', 'runsremaining', '', array('size' => 2));
     $group[] = $mform->createElement('static', '', '', get_string('times', 'local_elisreports'));
     $group[] = $mform->createElement('static', '', '', '<br />&nbsp;&nbsp;&nbsp;&nbsp;' . get_string('every', 'local_elisreports'));
     $group[] = $mform->createElement('text', 'frequency', '', array('size' => 2));
     $options = array(scheduling_workflow::FREQ_HOUR => get_string('freq_hours', 'local_elisreports'), scheduling_workflow::FREQ_DAY => get_string('freq_days', 'local_elisreports'), scheduling_workflow::FREQ_MONTH => get_string('freq_months', 'local_elisreports'));
     $group[] = $mform->createElement('select', 'frequencytype', '', $options);
     $mform->addGroup($group, 'runtype', get_string('runtype', 'local_elisreports'), '', false);
     $mform->disabledIf('enddate', 'runtype', 'neq', 1);
     $mform->disabledIf('enddate[day]', 'runtype', 'neq', 1);
     $mform->disabledIf('enddate[month]', 'runtype', 'neq', 1);
     $mform->disabledIf('enddate[year]', 'runtype', 'neq', 1);
     $mform->disabledIf('runsremaining', 'runtype', 'neq', 2);
     $mform->setType('runsremaining', PARAM_INT);
     $mform->setDefault('runsremaining', 1);
     $mform->disabledIf('frequency', 'runtype', 'neq', 2);
     $mform->disabledIf('frequencytype', 'runtype', 'neq', 2);
     $mform->setType('frequency', PARAM_INT);
     $mform->setDefault('frequency', 1);
     $mform->setDefault('frequencytype', scheduling_workflow::FREQ_DAY);
     $mform->addElement('header', 'calendarrecurrencegroup', get_string('calendar_recurrence_settings', 'local_elisreports'));
     $mform->addElement('date_selector', 'calenddate', get_string('enddate', 'local_elisreports'), array('optional' => true, 'timezone' => 0, 'applydst' => false));
     //Set timezone so it doesn't adjust the time
     $tsoptions = array('timezone' => '0', 'year' => 1971, 'applydst' => false);
     $mform->addElement('time_selector', 'time', get_string('time'), $tsoptions);
     $group = array();
     $group[] = $mform->createElement('radio', 'caldaystype', '', get_string('everyday', 'local_elisreports'), 0);
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('radio', 'caldaystype', '', get_string('weekdays', 'local_elisreports'), 1);
     $group[] = $mform->createElement('static', '', '', '<br />&nbsp;&nbsp;&nbsp;&nbsp;');
     $group[] = $mform->createElement('checkbox', 'dayofweek[1]', '', get_string('mon', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[2]', '', get_string('tue', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[3]', '', get_string('wed', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[4]', '', get_string('thu', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[5]', '', get_string('fri', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[6]', '', get_string('sat', 'calendar'));
     $group[] = $mform->createElement('checkbox', 'dayofweek[7]', '', get_string('sun', 'calendar'));
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('radio', 'caldaystype', '', get_string('monthdays', 'local_elisreports'), 2);
     $group[] = $mform->createElement('text', 'monthdays', '', array('size' => 6));
     $mform->addGroup($group, 'daytype', get_string('days', 'local_elisreports'), '', false);
     $mform->disabledIf('dayofweek[1]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[2]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[3]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[4]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[5]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[6]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('dayofweek[7]', 'caldaystype', 'neq', 1);
     $mform->disabledIf('monthdays', 'caldaystype', 'neq', 2);
     $mform->setType('monthdays', PARAM_TEXT);
     $group = array();
     $group[] = $mform->createElement('advcheckbox', 'allmonths', '', get_string('all'), 1);
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('checkbox', 'month[1]', '', strftime('%b', mktime(0, 0, 0, 1, 1)));
     $group[] = $mform->createElement('checkbox', 'month[2]', '', strftime('%b', mktime(0, 0, 0, 2, 1)));
     $group[] = $mform->createElement('checkbox', 'month[3]', '', strftime('%b', mktime(0, 0, 0, 3, 1)));
     $group[] = $mform->createElement('checkbox', 'month[4]', '', strftime('%b', mktime(0, 0, 0, 4, 1)));
     $group[] = $mform->createElement('checkbox', 'month[5]', '', strftime('%b', mktime(0, 0, 0, 5, 1)));
     $group[] = $mform->createElement('checkbox', 'month[6]', '', strftime('%b', mktime(0, 0, 0, 6, 1)));
     $group[] = $mform->createElement('static', '', '', '<br />');
     $group[] = $mform->createElement('checkbox', 'month[7]', '', strftime('%b', mktime(0, 0, 0, 7, 1)));
     $group[] = $mform->createElement('checkbox', 'month[8]', '', strftime('%b', mktime(0, 0, 0, 8, 1)));
     $group[] = $mform->createElement('checkbox', 'month[9]', '', strftime('%b', mktime(0, 0, 0, 9, 1)));
     $group[] = $mform->createElement('checkbox', 'month[10]', '', strftime('%b', mktime(0, 0, 0, 10, 1)));
     $group[] = $mform->createElement('checkbox', 'month[11]', '', strftime('%b', mktime(0, 0, 0, 11, 1)));
     $group[] = $mform->createElement('checkbox', 'month[12]', '', strftime('%b', mktime(0, 0, 0, 12, 1)));
     $mform->addGroup($group, 'month', get_string('months', 'local_elisreports'), '', false);
     for ($i = 1; $i <= 12; ++$i) {
         $mform->disabledIf("month[{$i}]", 'allmonths', 'checked');
     }
     workflowpage::add_navigation_buttons($mform, scheduling_workflow::STEP_LABEL);
 }
コード例 #10
0
ファイル: editlib.php プロジェクト: r007/PMoodle
function useredit_shared_definition(&$mform)
{
    global $CFG, $USER;
    $user = get_record('user', 'id', $USER->id);
    useredit_load_preferences($user, false);
    $strrequired = get_string('required');
    $nameordercheck = new object();
    $nameordercheck->firstname = 'a';
    $nameordercheck->lastname = 'b';
    if (fullname($nameordercheck) == 'b a') {
        // See MDL-4325
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
    } else {
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
    }
    $mform->addRule('firstname', $strrequired, 'required', null, 'client');
    $mform->setType('firstname', PARAM_NOTAGS);
    $mform->addRule('lastname', $strrequired, 'required', null, 'client');
    $mform->setType('lastname', PARAM_NOTAGS);
    // Do not show email field if change confirmation is pending
    if ($CFG->emailchangeconfirmation && !empty($user->preference_newemail)) {
        $notice = get_string('auth_emailchangepending', 'auth', $user);
        $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth') . '</a>';
        $mform->addElement('static', 'emailpending', get_string('email'), $notice);
    } else {
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
        $mform->addRule('email', $strrequired, 'required', null, 'client');
    }
    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    $choices['1'] = get_string('emaildisplayyes');
    $choices['2'] = get_string('emaildisplaycourse');
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', 2);
    $choices = array();
    $choices['0'] = get_string('emailenable');
    $choices['1'] = get_string('emaildisable');
    $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
    $mform->setDefault('emailenable', 1);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', 1);
    $mform->setAdvanced('mailformat');
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
        $mform->setAdvanced('preference_mailcharset');
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', 0);
    $mform->setAdvanced('maildigest');
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', 1);
    $mform->setAdvanced('autosubscribe');
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', 0);
        $mform->setAdvanced('trackforums');
    }
    if ($CFG->htmleditor) {
        $choices = array();
        $choices['0'] = get_string('texteditor');
        $choices['1'] = get_string('htmleditor');
        $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('htmleditor', 1);
        $mform->setAdvanced('htmleditor');
    }
    if (empty($CFG->enableajax)) {
        $mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
        $mform->setAdvanced('ajaxdisabled');
    } else {
        $choices = array();
        $choices['0'] = get_string('ajaxno');
        $choices['1'] = get_string('ajaxyes');
        $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
        $mform->setDefault('ajax', 0);
        $mform->setAdvanced('ajax');
    }
    $choices = array();
    $choices['0'] = get_string('screenreaderno');
    $choices['1'] = get_string('screenreaderyes');
    $mform->addElement('select', 'screenreader', get_string('screenreaderuse'), $choices);
    $mform->setDefault('screenreader', 0);
    $mform->setAdvanced('screenreader');
    $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="21"');
    $mform->setType('city', PARAM_MULTILANG);
    $mform->addRule('city', $strrequired, 'required', null, 'client');
    $choices = get_list_of_countries();
    $choices = array('' => get_string('selectacountry') . '...') + $choices;
    $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
    $mform->addRule('country', $strrequired, 'required', null, 'client');
    if (!empty($CFG->country)) {
        $mform->setDefault('country', $CFG->country);
    }
    $choices = get_list_of_timezones();
    $choices['99'] = get_string('serverlocaltime');
    if ($CFG->forcetimezone != 99) {
        $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
    } else {
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', '99');
    }
    $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
    $mform->setDefault('lang', $CFG->lang);
    if (!empty($CFG->allowuserthemes)) {
        $choices = array();
        $choices[''] = get_string('default');
        $choices += get_list_of_themes();
        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
        $mform->setAdvanced('theme');
    }
    $mform->addElement('htmleditor', 'description', get_string('userdescription'));
    $mform->setType('description', PARAM_CLEAN);
    $mform->setHelpButton('description', array('text', get_string('helptext')));
    if (!empty($CFG->gdversion)) {
        $mform->addElement('header', 'moodle_picture', get_string('pictureof'));
        //TODO: Accessibility fix fieldset legend
        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', false);
        $mform->addElement('file', 'imagefile', get_string('newpicture'));
        $mform->setHelpButton('imagefile', array('picture', get_string('helppicture')));
        $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
        $mform->setType('imagealt', PARAM_MULTILANG);
    }
    if (!empty($CFG->usetags)) {
        $mform->addElement('header', 'moodle_interests', get_string('interests'));
        $mform->addElement('textarea', 'interests', get_string('interestslist'), 'cols="45" rows="3"');
        $mform->setHelpButton('interests', array('interestslist', get_string('helpinterestslist'), false, true, false));
    }
    /// Moodle optional fields
    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
    $mform->setAdvanced('moodle_optional');
    $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
    $mform->setType('url', PARAM_URL);
    $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
    $mform->setType('icq', PARAM_CLEAN);
    $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
    $mform->setType('skype', PARAM_CLEAN);
    $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
    $mform->setType('aim', PARAM_CLEAN);
    $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
    $mform->setType('yahoo', PARAM_CLEAN);
    $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
    $mform->setType('msn', PARAM_CLEAN);
    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
    $mform->setType('idnumber', PARAM_CLEAN);
    $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
    $mform->setType('institution', PARAM_MULTILANG);
    $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
    $mform->setType('department', PARAM_MULTILANG);
    $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
    $mform->setType('phone1', PARAM_CLEAN);
    $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
    $mform->setType('phone2', PARAM_CLEAN);
    $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
    $mform->setType('address', PARAM_MULTILANG);
}
コード例 #11
0
ファイル: timezone.php プロジェクト: veritech/pare-project
<?php

// $Id: timezone.php,v 1.7 2007/01/03 01:53:52 vyshane Exp $
require_once '../config.php';
$zone = optional_param('zone', '', PARAM_PATH);
//not a path, but it looks like it anyway
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
$strtimezone = get_string("timezone");
$strsavechanges = get_string("savechanges");
$strusers = get_string("users");
$strall = get_string("all");
print_header($strtimezone, $strtimezone, $strtimezone);
print_heading("");
if (!empty($zone) and confirm_sesskey()) {
    $db->debug = true;
    echo "<center>";
    execute_sql("UPDATE {$CFG->prefix}user SET timezone = '{$zone}'");
    $db->debug = false;
    echo "</center>";
    $USER->timezone = $zone;
}
require_once $CFG->dirroot . '/calendar/lib.php';
$timezones = get_list_of_timezones();
echo '<center><form action="timezone.php" method="get">';
echo "{$strusers} ({$strall}): ";
choose_from_menu($timezones, "zone", 99, get_string("serverlocaltime"), "", "99");
echo "<input type=\"hidden\" name=\"sesskey\" value=\"{$USER->sesskey}\" />";
echo "<input type=\"submit\" value=\"{$strsavechanges}\" />";
echo "</form></center>";
print_footer();
コード例 #12
0
ファイル: edit_form.php プロジェクト: anilch/Personel
    public function definition() {
        global $USER, $CFG, $COURSE;

        $mform = & $this->_form;
        $templateuser = $USER;
        $context = $this->_customdata['context'];

        $mform->addElement('header', 'settingsheader', get_string('toolsettings', 'local_ltiprovider'));

        $tools = array();
        $tools[$context->id] = get_string('course');
        get_all_mods($this->_customdata['courseid'], $mods, $modnames, $modnamesplural, $modnamesused);

        foreach ($mods as $mod) {
            $tools[$mod->context->id] = format_string($mod->name);
        }

        $mform->addElement('select', 'contextid', get_string('tooltobeprovide', 'local_ltiprovider'), $tools);
        $mform->setDefault('contextid', $context->id);

        $mform->addElement('checkbox', 'sendgrades', null, get_string('sendgrades', 'local_ltiprovider'));
        $mform->setDefault('sendgrades', 1);

        $mform->addElement('checkbox', 'forcenavigation', null, get_string('forcenavigation', 'local_ltiprovider'));
        $mform->setDefault('forcenavigation', 1);

        $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'local_ltiprovider'), array('optional' => true, 'defaultunit' => 86400));
        $mform->setDefault('enrolperiod', 0);
        $mform->addHelpButton('enrolperiod', 'enrolperiod', 'local_ltiprovider');

        $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'local_ltiprovider'), array('optional' => true));
        $mform->setDefault('enrolstartdate', 0);
        $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'local_ltiprovider');

        $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'local_ltiprovider'), array('optional' => true));
        $mform->setDefault('enrolenddate', 0);
        $mform->addHelpButton('enrolenddate', 'enrolenddate', 'local_ltiprovider');

        $mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'local_ltiprovider'));
        $mform->setDefault('maxenrolled', 0);
        $mform->addHelpButton('maxenrolled', 'maxenrolled', 'local_ltiprovider');
        $mform->setType('maxenrolled', PARAM_INT);

        $assignableroles = get_assignable_roles($context);

        $mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
        $mform->setDefault('croleinst', '3');
        $mform->setAdvanced('croleinst');
        $mform->addElement('select', 'crolelearn', get_string('courserolelearner', 'local_ltiprovider'), $assignableroles);
        $mform->setDefault('crolelearn', '5');
        $mform->setAdvanced('crolelearn');

        $mform->addElement('select', 'aroleinst', get_string('activityroleinstructor', 'local_ltiprovider'), $assignableroles);
        $mform->disabledIf('aroleinst', 'contextid', 'eq', $context->id);
        $mform->setDefault('aroleinst', '3');
        $mform->setAdvanced('aroleinst');
        $mform->addElement('select', 'arolelearn', get_string('activityrolelearner', 'local_ltiprovider'), $assignableroles);
        $mform->disabledIf('arolelearn', 'contextid', 'eq', $context->id);
        $mform->setDefault('arolelearn', '5');
        $mform->setAdvanced('arolelearn');

        $mform->addElement('header', 'remotesystem', get_string('remotesystem', 'local_ltiprovider'));

        $mform->addElement('text', 'secret', get_string('secret', 'local_ltiprovider'), 'maxlength="64" size="25"');
        $mform->setType('secret', PARAM_MULTILANG);
        $mform->setDefault('secret', md5(uniqid(rand(), 1)));
        $mform->addRule('secret', get_string('required'), 'required');

        $textlib = textlib_get_instance();
        $choices = $textlib->get_encodings();
        $mform->addElement('select', 'encoding', get_string('remoteencoding', 'local_ltiprovider'), $choices);
        $mform->setDefault('encoding', 'UTF-8');

        $mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'local_ltiprovider'));

        $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
        $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
        $mform->setDefault('maildisplay', 2);

        $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
        $mform->setType('city', PARAM_MULTILANG);
        if (empty($CFG->defaultcity)) {
            $mform->setDefault('city', $templateuser->city);
        } else {
            $mform->setDefault('city', $CFG->defaultcity);
        }
        $mform->addRule('city', get_string('required'), 'required');

        $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
        if (empty($CFG->country)) {
            $mform->setDefault('country', $templateuser->country);
        } else {
            $mform->setDefault('country', $CFG->country);
        }
        $mform->setAdvanced('country');

        $choices = get_list_of_timezones();
        $choices['99'] = get_string('serverlocaltime');
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', $templateuser->timezone);
        $mform->setAdvanced('timezone');

        $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
        $mform->setDefault('lang', $templateuser->lang);
        $mform->setAdvanced('lang');

        $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
        $mform->setType('institution', PARAM_MULTILANG);
        $mform->setDefault('institution', $templateuser->institution);
        $mform->setAdvanced('institution');

        $mform->addElement('header', 'layoutandcss', get_string('layoutandcss', 'local_ltiprovider'));

        $mform->addElement('checkbox', 'hidepageheader', null, get_string('hidepageheader', 'local_ltiprovider'));
        $mform->addElement('checkbox', 'hidepagefooter', null, get_string('hidepagefooter', 'local_ltiprovider'));
        $mform->addElement('checkbox', 'hideleftblocks', null, get_string('hideleftblocks', 'local_ltiprovider'));
        $mform->addElement('checkbox', 'hiderightblocks', null, get_string('hiderightblocks', 'local_ltiprovider'));
        $mform->setAdvanced('hideleftblocks');
        $mform->setAdvanced('hiderightblocks');

        $editoroptions = array();
        $displayoptions = array('rows' => '4', 'cols' => '');
        $mform->addElement('textarea', 'customcss', get_string('customcss', 'local_ltiprovider'), $displayoptions, $editoroptions);
        $mform->setAdvanced('customcss');

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $mform->addElement('hidden', 'courseid');
        $mform->setType('courseid', PARAM_INT);

        $this->add_action_buttons();
    }
コード例 #13
0
ファイル: uploaduser_form.php プロジェクト: nuckey/moodle
    function definition (){
        global $CFG, $USER;

        $mform   =& $this->_form;
        $columns =& $this->_customdata;

        // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-)
        $templateuser = $USER;

        // upload settings and file
        $mform->addElement('header', 'settingsheader', get_string('settings'));
        $mform->addElement('static', 'uutypelabel', get_string('uuoptype', 'admin') );

        $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth'));
        $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'admin'), $choices);
        $mform->setDefault('uupasswordnew', 1);
        $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_UPDATE);

        $choices = array(0 => get_string('nochanges', 'admin'),
                         1 => get_string('uuupdatefromfile', 'admin'),
                         2 => get_string('uuupdateall', 'admin'),
                         3 => get_string('uuupdatemissing', 'admin'));
        $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'admin'), $choices);
        $mform->setDefault('uuupdatetype', 0);
        $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDNEW);
        $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDINC);

        $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('update'));
        $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'admin'), $choices);
        $mform->setDefault('uupasswordold', 0);
        $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDNEW);
        $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDINC);
        $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0);
        $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3);

        $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'admin'));
        $mform->setDefault('uuallowrenames', 0);
        $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW);
        $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC);

        $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin'));
        $mform->setDefault('uuallowdeletes', 0);
        $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW);
        $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC);

        $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'admin'));
        $mform->setDefault('uunoemailduplicates', 1);

        $choices = array(0 => get_string('no'),
                         1 => get_string('uubulknew', 'admin'),
                         2 => get_string('uubulkupdated', 'admin'),
                         3 => get_string('uubulkall', 'admin'));
        $mform->addElement('select', 'uubulk', get_string('uubulk', 'admin'), $choices);
        $mform->setDefault('uubulk', 0);

        // roles selection
        $showroles = false;
        foreach ($columns as $column) {
            if (preg_match('/^type\d+$/', $column)) {
                $showroles = true;
                break;
            }
        }
        if ($showroles) {
            $mform->addElement('header', 'rolesheader', get_string('roles'));

            $choices = uu_allowed_roles(true);

            $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'admin'), $choices);
            if ($studentroles = get_archetype_roles('student')) {
                foreach ($studentroles as $role) {
                    if (isset($choices[$role->id])) {
                        $mform->setDefault('uulegacy1', $role->id);
                        break;
                    }
                }
                unset($studentroles);
            }

            $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'admin'), $choices);
            if ($editteacherroles = get_archetype_roles('editingteacher')) {
                foreach ($editteacherroles as $role) {
                    if (isset($choices[$role->id])) {
                        $mform->setDefault('uulegacy2', $role->id);
                        break;
                    }
                }
                unset($editteacherroles);
            }

            $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'admin'), $choices);
            if ($teacherroles = get_archetype_roles('teacher')) {
                foreach ($teacherroles as $role) {
                    if (isset($choices[$role->id])) {
                        $mform->setDefault('uulegacy3', $role->id);
                        break;
                    }
                }
                unset($teacherroles);
            }
        }

        // default values
        $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));

        $mform->addElement('text', 'username', get_string('username'), 'size="20"');
        $mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client');

        // only enabled and known to work plugins
        $choices = uu_allowed_auths();
        $mform->addElement('select', 'auth', get_string('chooseauthmethod','auth'), $choices);
        $mform->setDefault('auth', 'manual'); // manual is a sensible backwards compatible default
        $mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
        $mform->setAdvanced('auth');

        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');

        $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
        $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
        $mform->setDefault('maildisplay', 2);

        $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
        $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
        $mform->setDefault('mailformat', 1);
        $mform->setAdvanced('mailformat');

        $choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects'));
        $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
        $mform->setDefault('maildigest', 0);
        $mform->setAdvanced('maildigest');

        $choices = array(0 => get_string('autosubscribeyes'), 1 => get_string('autosubscribeno'));
        $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
        $mform->setDefault('autosubscribe', 1);

        $editors = editors_get_enabled();
        if (count($editors) > 1) {
            $choices = array();
            $choices['0'] = get_string('texteditor');
            $choices['1'] = get_string('htmleditor');
            $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
            $mform->setDefault('htmleditor', 1);
        } else {
            $mform->addElement('hidden', 'htmleditor');
            $mform->setDefault('htmleditor', 1);
            $mform->setType('htmleditor', PARAM_INT);
        }

        if (empty($CFG->enableajax)) {
            $mform->addElement('static', 'ajax', get_string('ajaxuse'), get_string('ajaxno'));
        } else {
            $choices = array( 0 => get_string('ajaxno'), 1 => get_string('ajaxyes'));
            $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
            $mform->setDefault('ajax', 1);
        }
        $mform->setAdvanced('ajax');

        $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
        $mform->setType('city', PARAM_MULTILANG);
        if (empty($CFG->defaultcity)) {
            $mform->setDefault('city', $templateuser->city);
        } else {
            $mform->setDefault('city', $CFG->defaultcity);
        }

        $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
        if (empty($CFG->country)) {
            $mform->setDefault('country', $templateuser->country);
        } else {
            $mform->setDefault('country', $CFG->country);
        }
        $mform->setAdvanced('country');

        $choices = get_list_of_timezones();
        $choices['99'] = get_string('serverlocaltime');
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', $templateuser->timezone);
        $mform->setAdvanced('timezone');

        $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
        $mform->setDefault('lang', $templateuser->lang);
        $mform->setAdvanced('lang');

        $editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
        $mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions);
        $mform->setType('description', PARAM_CLEANHTML);
        $mform->addHelpButton('description', 'userdescription');
        $mform->setAdvanced('description');

        $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
        $mform->setAdvanced('url');

        $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
        $mform->setType('idnumber', PARAM_NOTAGS);

        $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
        $mform->setType('institution', PARAM_MULTILANG);
        $mform->setDefault('institution', $templateuser->institution);

        $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
        $mform->setType('department', PARAM_MULTILANG);
        $mform->setDefault('department', $templateuser->department);

        $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
        $mform->setType('phone1', PARAM_NOTAGS);
        $mform->setAdvanced('phone1');

        $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
        $mform->setType('phone2', PARAM_NOTAGS);
        $mform->setAdvanced('phone2');

        $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
        $mform->setType('address', PARAM_MULTILANG);
        $mform->setAdvanced('address');

        // Next the profile defaults
        profile_definition($mform);

        // hidden fields
        $mform->addElement('hidden', 'iid');
        $mform->setType('iid', PARAM_INT);

        $mform->addElement('hidden', 'previewrows');
        $mform->setType('previewrows', PARAM_INT);

        $mform->addElement('hidden', 'readcount');
        $mform->setType('readcount', PARAM_INT);

        $mform->addElement('hidden', 'uutype');
        $mform->setType('uutype', PARAM_INT);

        $this->add_action_buttons(true, get_string('uploadusers', 'admin'));
    }
コード例 #14
0
 function definition()
 {
     global $CFG;
     $templateuser = $this->_customdata;
     if (empty($templateuser)) {
         if (!($templateuser = get_admin())) {
             error('Could not find site admin');
         }
     }
     $mform =& $this->_form;
     $mform->addElement('file', 'userfile', get_string('file'));
     $mform->addRule('userfile', null, 'required');
     $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $modules = get_list_of_plugins('auth');
     $auth_options = array();
     foreach ($modules as $module) {
         $auth_options[$module] = get_string("auth_{$module}" . "title", "auth");
     }
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
     $mform->setDefault('auth', $templateuser->auth);
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $choices = array(get_string('emaildisplayno'), get_string('emaildisplayyes'), get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $choices = array(get_string('emailenable'), get_string('emaildisable'));
     $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
     $choices = array(get_string('textformat'), get_string('htmlformat'));
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     $choices = array(get_string('autosubscribeyes'), get_string('autosubscribeno'));
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     if ($CFG->htmleditor) {
         $choices = array(get_string('texteditor'), get_string('htmleditor'));
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     }
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_MULTILANG);
     $mform->setDefault('city', $templateuser->city);
     $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries());
     $mform->setDefault('country', $templateuser->country);
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->addElement('htmleditor', 'description', get_string('userdescription'));
     $mform->setType('description', PARAM_CLEAN);
     $mform->setHelpButton('description', array('text', get_string('helptext')));
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', PARAM_MULTILANG);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
     $mform->setType('department', PARAM_MULTILANG);
     $mform->setDefault('department', $templateuser->department);
     $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone1', PARAM_CLEAN);
     $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone2', PARAM_CLEAN);
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
     $mform->setType('address', PARAM_MULTILANG);
     $mform->addElement('header', 'settingsheader', get_string('settings'));
     $choices = array(get_string('infilefield', 'auth'), get_string('createpasswordifneeded', 'auth'));
     $mform->addElement('select', 'createpassword', get_string('passwordhandling', 'auth'), $choices);
     $mform->addElement('selectyesno', 'updateaccounts', get_string('updateaccounts', 'admin'));
     $mform->addElement('selectyesno', 'allowrenames', get_string('allowrenames', 'admin'));
     $choices = array(get_string('addcounter', 'admin'), get_string('skipuser', 'admin'));
     $mform->addElement('select', 'duplicatehandling', get_string('newusernamehandling', 'admin'), $choices);
     $this->add_action_buttons(false, get_string('uploadusers'));
 }
コード例 #15
0
ファイル: version1.class.php プロジェクト: jamesmcq/elis
 /**
  * Validates that core user fields are set to valid values, if they are set
  * on the import record
  *
  * @param string $action One of 'create' or 'update'
  * @param object $record The import record
  *
  * @return boolean true if the record validates correctly, otherwise false
  */
 function validate_core_user_data($action, $record, $filename)
 {
     global $CFG;
     //make sure auth plugin refers to a valid plugin
     $auths = get_plugin_list('auth');
     if (!$this->validate_fixed_list($record, 'auth', array_keys($auths))) {
         $identifier = $this->mappings['auth'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->auth}\" is not a valid auth plugin.", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     // Make sure password satisfies the site password policy (but allow "changeme" which will trigger forced password change).
     if (isset($record->password)) {
         $errmsg = '';
         if ($record->password != 'changeme' && !check_password_policy($record->password, $errmsg)) {
             $identifier = $this->mappings['password'];
             $this->fslogger->log_failure("{$identifier} value of \"{$record->password}\" does not conform to your site's password policy.", 0, $filename, $this->linenumber, $record, "user");
             return false;
         }
     }
     //make sure email is in user@domain.ext format
     if ($action == 'create') {
         if (!validate_email($record->email)) {
             $identifier = $this->mappings['email'];
             $this->fslogger->log_failure("{$identifier} value of \"{$record->email}\" is not a valid email address.", 0, $filename, $this->linenumber, $record, "user");
             return false;
         }
     }
     //make sure maildigest is one of the available values
     if (!$this->validate_fixed_list($record, 'maildigest', array(0, 1, 2))) {
         $identifier = $this->mappings['maildigest'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->maildigest}\" is not one of the available options (0, 1, 2).", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure autosubscribe is one of the available values
     if (!$this->validate_fixed_list($record, 'autosubscribe', array(0, 1), array('no' => 0, 'yes' => 1))) {
         $identifier = $this->mappings['autosubscribe'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->autosubscribe}\" is not one of the available options (0, 1).", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure trackforums can only be set if feature is enabled
     if (isset($record->trackforums)) {
         if (empty($CFG->forum_trackreadposts)) {
             $this->fslogger->log_failure("Tracking unread posts is currently disabled on this site.", 0, $filename, $this->linenumber, $record, "user");
             return false;
         }
     }
     //make sure trackforums is one of the available values
     if (!$this->validate_fixed_list($record, 'trackforums', array(0, 1), array('no' => 0, 'yes' => 1))) {
         $identifier = $this->mappings['trackforums'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->trackforums}\" is not one of the available options (0, 1).", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure screenreader is one of the available values
     if (!$this->validate_fixed_list($record, 'screenreader', array(0, 1), array('no' => 0, 'yes' => 1))) {
         $identifier = $this->mappings['screenreader'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->screenreader}\" is not one of the available options (0, 1).", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure country refers to a valid country code
     $countries = get_string_manager()->get_list_of_countries();
     if (!$this->validate_fixed_list($record, 'country', array_keys($countries), array_flip($countries))) {
         $identifier = $this->mappings['country'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->country}\" is not a valid country or country code.", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure timezone can only be set if feature is enabled
     if (isset($record->timezone)) {
         if ($CFG->forcetimezone != 99 && $record->timezone != $CFG->forcetimezone) {
             $identifier = $this->mappings['timezone'];
             $this->fslogger->log_failure("{$identifier} value of \"{$record->timezone}\" is not consistent with forced timezone value of \"{$CFG->forcetimezone}\" on your site.", 0, $filename, $this->linenumber, $record, "user");
             return false;
         }
     }
     //make sure timezone refers to a valid timezone offset
     $timezones = get_list_of_timezones();
     if (!$this->validate_fixed_list($record, 'timezone', array_keys($timezones))) {
         $identifier = $this->mappings['timezone'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->timezone}\" is not a valid timezone.", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure theme can only be set if feature is enabled
     if (isset($record->theme)) {
         if (empty($CFG->allowuserthemes)) {
             $this->fslogger->log_failure("User themes are currently disabled on this site.", 0, $filename, $this->linenumber, $record, "user");
             return false;
         }
     }
     //make sure theme refers to a valid theme
     if ($this->themes == array()) {
         //lazy-loading of themes, store to save time
         $this->themes = get_list_of_themes();
     }
     if (!$this->validate_fixed_list($record, 'theme', array_keys($this->themes))) {
         $identifier = $this->mappings['theme'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->theme}\" is not a valid theme.", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     //make sure lang refers to a valid language
     $languages = get_string_manager()->get_list_of_translations();
     if (!$this->validate_fixed_list($record, 'lang', array_keys($languages))) {
         $identifier = $this->mappings['lang'];
         $this->fslogger->log_failure("{$identifier} value of \"{$record->lang}\" is not a valid language code.", 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     return true;
 }
コード例 #16
0
ファイル: global_settings.php プロジェクト: songchin/Cacti
			"default" => "0",
			"array" => array( "0" => __("Disabled"), "1" => __("Enabled"))
			),
		"i18n_timezone_support" => array(
			"friendly_name" => __("Time Zone Support"),
			"description" => __("Choose \"enabled\" to setup another time zone. If the time zone can not be modified system time zone will be used automatically."),
			"method" => "drop_array",
			"default" => "0",
			"array" => array( "0" => __("Disabled"), "1" => __("Enabled"))
			),
		"i18n_default_timezone" => array(
			"friendly_name" => __("Default Time Zone"),
			"description" => __("Default time zone for this system."),
			"method" => "drop_array",
			"default" => "0",
			"array" => get_list_of_timezones()
			),
		),
	"snmp" => array(
		"snmp_header" => array(
			"friendly_name" => __("SNMP Defaults"),
			"method" => "spacer",
			),
		"snmp_ver" => array(
			"friendly_name" => __("SNMP Version"),
			"description" => __("Default SNMP version for all new devices."),
			"method" => "drop_array",
			"default" => "1",
			"array" => $snmp_versions,
			),
		"snmp_community" => array(