next up previous contents
Next: Openmeetings 安裝 Up: 自動設定用戶國別 Previous: 國別自動設定   Contents

限制用戶更動國別

  1. 既然已修改 moodle 系統為取用戶登入 IP 自動判斷國別,就不希望用戶自行修改國別。因此,修改程式 editlib.php 限制用戶選擇國別。
    [root@dywang moodle23]# diff -urN ../moodle/user/editlib.php user/editlib.php
    --- ../moodle/user/editlib.php	2012-06-26 01:15:38.000000000 +0800
    +++ user/editlib.php	2015-03-05 10:39:39.612411949 +0800
    
  2. 取消「縣市」必要輸入之設定。
    @@ -225,18 +225,19 @@
     
         $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);
    -    }
    
  3. 取消「選擇國家」必要選擇之設定,並改成直接顯示用戶國別名。
         $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);
    -    }
    +    $mform->addElement('static', 'countryName', get_string('country'), $choices[$USER->country]);
     
         $choices = get_list_of_timezones();
         $choices['99'] = get_string('serverlocaltime');
    
  4. 加入「系別」為必要輸入欄位。
    @@ -321,6 +322,10 @@
     
         $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
         $mform->setType('department', PARAM_MULTILANG);
    +    $mform->addRule('department', $strrequired, 'required', null, 'client'); //dywang
    +    if (!empty($CFG->department)) {
    +        $mform->setDefault('department', $CFG->defaultdepartment);
    +    }
     
         $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
         $mform->setType('phone1', PARAM_NOTAGS);
    


2017-08-04