Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/enrol/self/edit_form.php

    r136 r1331  
    4040        $mform->addElement('header', 'header', get_string('pluginname', 'enrol_self'));
    4141
    42         $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     42        $nameattribs = array('size' => '20', 'maxlength' => '255');
     43        $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
    4344        $mform->setType('name', PARAM_TEXT);
     45        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
    4446
    4547        $options = array(ENROL_INSTANCE_ENABLED  => get_string('yes'),
     
    5355        $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED);
    5456
    55         $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'));
     57        $passattribs = array('size' => '20', 'maxlength' => '50');
     58        $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs);
    5659        $mform->addHelpButton('password', 'password', 'enrol_self');
    5760        if (empty($instance->id) and $plugin->get_config('requirepassword')) {
    5861            $mform->addRule('password', get_string('required'), 'required', null, 'client');
    5962        }
     63        $mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server');
    6064
    6165        $options = array(1 => get_string('yes'),
     
    160164
    161165        if ($instance->id) {
    162             if ($data['status'] == ENROL_INSTANCE_ENABLED) {
    163                 if ($instance->password !== $data['password']) {
    164                     $checkpassword = true;
    165                 }
     166            // Check the password if we are enabling the plugin again.
     167            if (($instance->status == ENROL_INSTANCE_DISABLED) && ($data['status'] == ENROL_INSTANCE_ENABLED)) {
     168                $checkpassword = true;
     169            }
     170
     171            // Check the password if the instance is enabled and the password has changed.
     172            if (($data['status'] == ENROL_INSTANCE_ENABLED) && ($instance->password !== $data['password'])) {
     173                $checkpassword = true;
    166174            }
    167175        } else {
    168             if ($data['status'] == ENROL_INSTANCE_ENABLED) {
    169                 $checkpassword = true;
    170             }
     176            $checkpassword = true;
    171177        }
    172178
     
    176182            if ($require and trim($data['password']) === '') {
    177183                $errors['password'] = get_string('required');
    178             } else if ($policy) {
    179                 $errmsg = '';//prevent eclipse warning
     184            } else if (!empty($data['password']) && $policy) {
     185                $errmsg = '';
    180186                if (!check_password_policy($data['password'], $errmsg)) {
    181187                    $errors['password'] = $errmsg;
Note: See TracChangeset for help on using the changeset viewer.