~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to admin/tool/uploaduser/user_form.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
defined('MOODLE_INTERNAL') || die();
27
27
 
28
28
require_once $CFG->libdir.'/formslib.php';
29
 
 
 
29
require_once($CFG->dirroot . '/user/editlib.php');
30
30
 
31
31
/**
32
32
 * Upload a file CVS file with user information.
53
53
            $mform->setDefault('delimiter_name', 'comma');
54
54
        }
55
55
 
56
 
        $choices = textlib::get_encodings();
 
56
        $choices = core_text::get_encodings();
57
57
        $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
58
58
        $mform->setDefault('encoding', 'UTF-8');
59
59
 
237
237
        $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
238
238
        $mform->setDefault('autosubscribe', 1);
239
239
 
240
 
        $editors = editors_get_enabled();
241
 
        if (count($editors) > 1) {
242
 
            $choices = array();
243
 
            $choices['0'] = get_string('texteditor');
244
 
            $choices['1'] = get_string('htmleditor');
245
 
            $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
246
 
            $mform->setDefault('htmleditor', 1);
247
 
        } else {
248
 
            $mform->addElement('hidden', 'htmleditor');
249
 
            $mform->setDefault('htmleditor', 1);
250
 
            $mform->setType('htmleditor', PARAM_INT);
251
 
        }
252
 
 
253
 
        $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
 
240
        $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
254
241
        $mform->setType('city', PARAM_TEXT);
255
242
        if (empty($CFG->defaultcity)) {
256
243
            $mform->setDefault('city', $templateuser->city);
257
244
        } else {
258
245
            $mform->setDefault('city', $CFG->defaultcity);
259
246
        }
260
 
        $mform->addRule('city', get_string('required'), 'required');
261
247
 
262
 
        $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
 
248
        $choices = get_string_manager()->get_list_of_countries();
 
249
        $choices = array(''=>get_string('selectacountry').'...') + $choices;
 
250
        $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
263
251
        if (empty($CFG->country)) {
264
252
            $mform->setDefault('country', $templateuser->country);
265
253
        } else {
287
275
        $mform->setType('url', PARAM_URL);
288
276
        $mform->setAdvanced('url');
289
277
 
290
 
        $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
 
278
        $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
291
279
        $mform->setType('idnumber', PARAM_NOTAGS);
292
280
 
293
 
        $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
 
281
        $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
294
282
        $mform->setType('institution', PARAM_TEXT);
295
283
        $mform->setDefault('institution', $templateuser->institution);
296
284
 
297
 
        $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
 
285
        $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
298
286
        $mform->setType('department', PARAM_TEXT);
299
287
        $mform->setDefault('department', $templateuser->department);
300
288
 
306
294
        $mform->setType('phone2', PARAM_NOTAGS);
307
295
        $mform->setAdvanced('phone2');
308
296
 
309
 
        $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
 
297
        $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
310
298
        $mform->setType('address', PARAM_TEXT);
311
299
        $mform->setAdvanced('address');
312
300
 
387
375
 
388
376
        // look for other required data
389
377
        if ($optype != UU_USER_UPDATE) {
390
 
            if (!in_array('firstname', $columns)) {
391
 
                $errors['uutype'] = get_string('missingfield', 'error', 'firstname');
392
 
            }
393
 
 
394
 
            if (!in_array('lastname', $columns)) {
395
 
                if (isset($errors['uutype'])) {
396
 
                    $errors['uutype'] = '';
397
 
                } else {
398
 
                    $errors['uutype'] = ' ';
 
378
            $requiredusernames = useredit_get_required_name_fields();
 
379
            $missing = array();
 
380
            foreach ($requiredusernames as $requiredusername) {
 
381
                if (!in_array($requiredusername, $columns)) {
 
382
                    $missing[] = get_string('missingfield', 'error', $requiredusername);;
399
383
                }
400
 
                $errors['uutype'] .= get_string('missingfield', 'error', 'lastname');
401
 
            }
402
 
 
 
384
            }
 
385
            if ($missing) {
 
386
                $errors['uutype'] = implode('<br />',  $missing);
 
387
            }
403
388
            if (!in_array('email', $columns) and empty($data['email'])) {
404
389
                $errors['email'] = get_string('requiredtemplate', 'tool_uploaduser');
405
390
            }
406
391
        }
407
 
 
408
392
        return $errors;
409
393
    }
410
394