2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2011-02-26 15:16:51 +01:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bulk user upload forms
|
|
|
|
*
|
|
|
|
* @package core
|
|
|
|
* @subpackage admin
|
|
|
|
* @copyright 2007 Dan Poltawski
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
2010-05-13 02:02:05 +00:00
|
|
|
|
2007-05-02 09:33:56 +00:00
|
|
|
require_once $CFG->libdir.'/formslib.php';
|
|
|
|
|
2007-11-01 19:37:25 +00:00
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
/**
|
|
|
|
* Upload a file CVS file with user information.
|
|
|
|
*
|
|
|
|
* @package core
|
|
|
|
* @subpackage admin
|
|
|
|
* @copyright 2007 Petr Skoda {@link http://skodak.org}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
class admin_uploaduser_form1 extends moodleform {
|
|
|
|
function definition () {
|
|
|
|
$mform = $this->_form;
|
2007-05-02 09:33:56 +00:00
|
|
|
|
2007-11-02 08:41:05 +00:00
|
|
|
$mform->addElement('header', 'settingsheader', get_string('upload'));
|
2007-11-01 19:37:25 +00:00
|
|
|
|
2010-06-04 04:08:56 +00:00
|
|
|
$mform->addElement('filepicker', 'userfile', get_string('file'));
|
2007-05-02 09:33:56 +00:00
|
|
|
$mform->addRule('userfile', null, 'required');
|
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$choices = csv_import_reader::get_delimiter_list();
|
|
|
|
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'admin'), $choices);
|
2007-11-02 08:41:05 +00:00
|
|
|
if (array_key_exists('cfg', $choices)) {
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->setDefault('delimiter_name', 'cfg');
|
2010-04-10 17:40:58 +00:00
|
|
|
} else if (get_string('listsep', 'langconfig') == ';') {
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->setDefault('delimiter_name', 'semicolon');
|
2007-11-02 08:41:05 +00:00
|
|
|
} else {
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->setDefault('delimiter_name', 'comma');
|
2007-11-02 08:41:05 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 19:37:25 +00:00
|
|
|
$textlib = textlib_get_instance();
|
|
|
|
$choices = $textlib->get_encodings();
|
|
|
|
$mform->addElement('select', 'encoding', get_string('encoding', 'admin'), $choices);
|
|
|
|
$mform->setDefault('encoding', 'UTF-8');
|
|
|
|
|
2007-11-02 08:41:05 +00:00
|
|
|
$choices = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
|
|
|
|
$mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'admin'), $choices);
|
|
|
|
$mform->setType('previewrows', PARAM_INT);
|
|
|
|
|
MDL-21695 Upload pictures and upload users - strings cleanup and fixing
Strings related to users uploading moved into admin.php component. Fixed
calling of new help strings. Fixed incorrect strings call.
The script also copies instructions from two previous commits as I
forgot that the commit must touch some string file to being parsed by
amos.
AMOS BEGIN
HLP uploadusers3.html,[uploadusers_help,core_admin]
HLP uploadusers2.html,[uploadusers_help,core_admin]
HLP uploadusers.html,[uploadusers_help,core_admin]
HLP uploadpictures.html,[uploadpictures_help,core_admin]
MOV [uploadusers,core],[uploadusers,core_admin]
MOV [uploadusers_help,core],[uploadusers_help,core_admin]
HLP cookies.html,[cookiesenabled_help,core]
HLP overrides.html,[overridepermissions_help,core_role]
HLP permissions.html,[permission_help,core_role]
AMOS END
2010-05-17 15:16:33 +00:00
|
|
|
$this->add_action_buttons(false, get_string('uploadusers', 'admin'));
|
2007-11-02 08:41:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify user upload details
|
|
|
|
*
|
|
|
|
* @package core
|
|
|
|
* @subpackage admin
|
|
|
|
* @copyright 2007 Petr Skoda {@link http://skodak.org}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
2007-11-02 08:41:05 +00:00
|
|
|
class admin_uploaduser_form2 extends moodleform {
|
2011-02-26 15:16:51 +01:00
|
|
|
function definition () {
|
2007-11-02 08:41:05 +00:00
|
|
|
global $CFG, $USER;
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform = $this->_form;
|
|
|
|
$columns = $this->_customdata['columns'];
|
|
|
|
$data = $this->_customdata['data'];
|
2007-11-02 08:41:05 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
// I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-)
|
2007-11-02 08:41:05 +00:00
|
|
|
$templateuser = $USER;
|
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// upload settings and file
|
2007-11-02 08:41:05 +00:00
|
|
|
$mform->addElement('header', 'settingsheader', get_string('settings'));
|
2011-02-26 15:16:51 +01:00
|
|
|
|
|
|
|
$choices = array(UU_USER_ADDNEW => get_string('uuoptype_addnew', 'admin'),
|
|
|
|
UU_USER_ADDINC => get_string('uuoptype_addinc', 'admin'),
|
|
|
|
UU_USER_ADD_UPDATE => get_string('uuoptype_addupdate', 'admin'),
|
|
|
|
UU_USER_UPDATE => get_string('uuoptype_update', 'admin'));
|
|
|
|
$mform->addElement('select', 'uutype', get_string('uuoptype', 'admin'), $choices);
|
2007-11-01 19:37:25 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth'));
|
|
|
|
$mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'admin'), $choices);
|
2010-11-05 08:41:53 +00:00
|
|
|
$mform->setDefault('uupasswordnew', 1);
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_USER_UPDATE);
|
2007-11-05 00:43:37 +00:00
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
$choices = array(UU_UPDATE_NOCHANGES => get_string('nochanges', 'admin'),
|
|
|
|
UU_UPDATE_FILEOVERRIDE => get_string('uuupdatefromfile', 'admin'),
|
|
|
|
UU_UPDATE_ALLOVERRIDE => get_string('uuupdateall', 'admin'),
|
|
|
|
UU_UPDATE_MISSING => get_string('uuupdatemissing', 'admin'));
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'admin'), $choices);
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->setDefault('uuupdatetype', UU_UPDATE_NOCHANGES);
|
|
|
|
$mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDNEW);
|
|
|
|
$mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDINC);
|
2007-11-05 00:43:37 +00:00
|
|
|
|
|
|
|
$choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('update'));
|
|
|
|
$mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'admin'), $choices);
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uupasswordold', 0);
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDNEW);
|
|
|
|
$mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDINC);
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0);
|
|
|
|
$mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3);
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
$choices = array(UU_PWRESET_WEAK => get_string('usersweakpassword', 'admin'),
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'admin'));
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uuallowrenames', 0);
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDNEW);
|
|
|
|
$mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDINC);
|
2007-11-05 00:43:37 +00:00
|
|
|
|
|
|
|
$mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin'));
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uuallowdeletes', 0);
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDNEW);
|
|
|
|
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDINC);
|
2007-11-05 00:43:37 +00:00
|
|
|
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'admin'));
|
2010-02-05 07:30:53 +00:00
|
|
|
$mform->setDefault('uunoemailduplicates', 1);
|
2007-11-05 09:36:46 +00:00
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->addElement('selectyesno', 'uustandardusernames', get_string('uustandardusernames', 'admin'));
|
|
|
|
$mform->setDefault('uustandardusernames', 1);
|
|
|
|
|
|
|
|
$choices = array(UU_BULK_NONE => get_string('no'),
|
|
|
|
UU_BULK_NEW => get_string('uubulknew', 'admin'),
|
|
|
|
UU_BULK_UPDATED => get_string('uubulkupdated', 'admin'),
|
|
|
|
UU_BULK_ALL => get_string('uubulkall', 'admin'));
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('select', 'uubulk', get_string('uubulk', 'admin'), $choices);
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uubulk', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// roles selection
|
2007-11-05 00:43:37 +00:00
|
|
|
$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);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if ($studentroles = get_archetype_roles('student')) {
|
|
|
|
foreach ($studentroles as $role) {
|
|
|
|
if (isset($choices[$role->id])) {
|
|
|
|
$mform->setDefault('uulegacy1', $role->id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($studentroles);
|
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
|
|
|
|
$mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'admin'), $choices);
|
2010-03-31 07:41:31 +00:00
|
|
|
if ($editteacherroles = get_archetype_roles('editingteacher')) {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
foreach ($editteacherroles as $role) {
|
|
|
|
if (isset($choices[$role->id])) {
|
|
|
|
$mform->setDefault('uulegacy2', $role->id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
unset($editteacherroles);
|
|
|
|
}
|
2007-11-01 19:37:25 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'admin'), $choices);
|
2010-03-31 07:41:31 +00:00
|
|
|
if ($teacherroles = get_archetype_roles('teacher')) {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
foreach ($teacherroles as $role) {
|
|
|
|
if (isset($choices[$role->id])) {
|
|
|
|
$mform->setDefault('uulegacy3', $role->id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
unset($teacherroles);
|
|
|
|
}
|
|
|
|
}
|
2007-11-01 19:37:25 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// default values
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
|
2007-11-05 00:43:37 +00:00
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform->addElement('text', 'username', get_string('uuusernametemplate', 'admin'), 'size="20"');
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client');
|
2011-02-26 15:16:51 +01:00
|
|
|
$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->disabledIf('email', 'uutype', 'eq', UU_USER_ADD_UPDATE);
|
|
|
|
$mform->disabledIf('email', 'uutype', 'eq', UU_USER_UPDATE);
|
2007-08-20 08:51:35 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
// only enabled and known to work plugins
|
2011-02-26 15:16:51 +01:00
|
|
|
$choices = uu_supported_auths();
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('select', 'auth', get_string('chooseauthmethod','auth'), $choices);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setDefault('auth', 'manual'); // manual is a sensible backwards compatible default
|
2010-05-06 16:56:04 +00:00
|
|
|
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('auth');
|
2007-05-02 09:33:56 +00:00
|
|
|
|
2007-11-01 19:37:25 +00:00
|
|
|
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
|
|
|
|
$mform->setDefault('maildisplay', 2);
|
|
|
|
|
2007-11-01 19:37:25 +00:00
|
|
|
$choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
|
|
|
|
$mform->setDefault('mailformat', 1);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('mailformat');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
2008-01-29 16:22:02 +00:00
|
|
|
$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');
|
|
|
|
|
2011-03-16 20:00:06 +01:00
|
|
|
$choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno'));
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
|
|
|
|
$mform->setDefault('autosubscribe', 1);
|
|
|
|
|
2010-07-10 12:12:59 +00:00
|
|
|
$editors = editors_get_enabled();
|
|
|
|
if (count($editors) > 1) {
|
|
|
|
$choices = array();
|
|
|
|
$choices['0'] = get_string('texteditor');
|
|
|
|
$choices['1'] = get_string('htmleditor');
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
|
|
|
|
$mform->setDefault('htmleditor', 1);
|
2007-11-01 19:37:25 +00:00
|
|
|
} else {
|
2010-07-10 12:12:59 +00:00
|
|
|
$mform->addElement('hidden', 'htmleditor');
|
|
|
|
$mform->setDefault('htmleditor', 1);
|
|
|
|
$mform->setType('htmleditor', PARAM_INT);
|
2007-08-20 08:51:35 +00:00
|
|
|
}
|
2007-11-01 19:37:25 +00:00
|
|
|
|
|
|
|
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');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
|
|
|
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
|
|
|
|
$mform->setType('city', PARAM_MULTILANG);
|
2011-02-15 08:59:53 +01:00
|
|
|
if (empty($CFG->defaultcity)) {
|
|
|
|
$mform->setDefault('city', $templateuser->city);
|
|
|
|
} else {
|
|
|
|
$mform->setDefault('city', $CFG->defaultcity);
|
|
|
|
}
|
2011-07-06 15:13:16 +08:00
|
|
|
$mform->addRule('city', get_string('required'), 'required');
|
2007-11-01 19:37:25 +00:00
|
|
|
|
2010-04-14 14:27:10 +00:00
|
|
|
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
|
2011-02-15 08:59:53 +01:00
|
|
|
if (empty($CFG->country)) {
|
|
|
|
$mform->setDefault('country', $templateuser->country);
|
|
|
|
} else {
|
|
|
|
$mform->setDefault('country', $CFG->country);
|
|
|
|
}
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('country');
|
2007-05-02 09:33:56 +00:00
|
|
|
|
2007-08-20 08:51:35 +00:00
|
|
|
$choices = get_list_of_timezones();
|
|
|
|
$choices['99'] = get_string('serverlocaltime');
|
|
|
|
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
|
|
|
|
$mform->setDefault('timezone', $templateuser->timezone);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('timezone');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
2010-04-14 09:45:49 +00:00
|
|
|
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->setDefault('lang', $templateuser->lang);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('lang');
|
|
|
|
|
2009-11-04 06:14:06 +00:00
|
|
|
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
|
|
|
|
$mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions);
|
|
|
|
$mform->setType('description', PARAM_CLEANHTML);
|
MDL-21695 Migrating the usage of root help files so far re-worded
AMOS BEGIN
HLP forcepasswordchange.html,[forcepasswordchange_help,core]
HLP interestslist.html,[interestslist_help,core]
HLP newpassword.html,[newpassword_help,core]
HLP permissions.html,[permissions_help,core_role]
HLP picture.html,[newpicture_help,core]
HLP picture.html,[newpicture_help,core_group]
HLP roles.html,[roles_help,core_role]
AMOS END
2010-05-06 21:27:58 +00:00
|
|
|
$mform->addHelpButton('description', 'userdescription');
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('description');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
|
|
|
$mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('url');
|
|
|
|
|
|
|
|
$mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
|
2010-09-02 18:25:30 +00:00
|
|
|
$mform->setType('idnumber', PARAM_NOTAGS);
|
2007-08-20 08:51:35 +00:00
|
|
|
|
|
|
|
$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"');
|
2010-09-02 18:25:30 +00:00
|
|
|
$mform->setType('phone1', PARAM_NOTAGS);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('phone1');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
2008-03-26 02:58:16 +00:00
|
|
|
$mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
|
2010-09-02 18:25:30 +00:00
|
|
|
$mform->setType('phone2', PARAM_NOTAGS);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('phone2');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
|
|
|
$mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
|
|
|
|
$mform->setType('address', PARAM_MULTILANG);
|
2007-11-01 19:37:25 +00:00
|
|
|
$mform->setAdvanced('address');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// Next the profile defaults
|
2007-11-05 00:43:37 +00:00
|
|
|
profile_definition($mform);
|
2007-11-02 08:41:05 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// hidden fields
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addElement('hidden', 'iid');
|
|
|
|
$mform->setType('iid', PARAM_INT);
|
2007-11-02 08:41:05 +00:00
|
|
|
|
|
|
|
$mform->addElement('hidden', 'previewrows');
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->setType('previewrows', PARAM_INT);
|
|
|
|
|
MDL-21695 Upload pictures and upload users - strings cleanup and fixing
Strings related to users uploading moved into admin.php component. Fixed
calling of new help strings. Fixed incorrect strings call.
The script also copies instructions from two previous commits as I
forgot that the commit must touch some string file to being parsed by
amos.
AMOS BEGIN
HLP uploadusers3.html,[uploadusers_help,core_admin]
HLP uploadusers2.html,[uploadusers_help,core_admin]
HLP uploadusers.html,[uploadusers_help,core_admin]
HLP uploadpictures.html,[uploadpictures_help,core_admin]
MOV [uploadusers,core],[uploadusers,core_admin]
MOV [uploadusers_help,core],[uploadusers_help,core_admin]
HLP cookies.html,[cookiesenabled_help,core]
HLP overrides.html,[overridepermissions_help,core_role]
HLP permissions.html,[permission_help,core_role]
AMOS END
2010-05-17 15:16:33 +00:00
|
|
|
$this->add_action_buttons(true, get_string('uploadusers', 'admin'));
|
2011-02-26 15:16:51 +01:00
|
|
|
|
|
|
|
$this->set_data($data);
|
2007-05-02 09:33:56 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
/**
|
|
|
|
* Form tweaks that depend on current data.
|
|
|
|
*/
|
2007-11-02 08:41:05 +00:00
|
|
|
function definition_after_data() {
|
2011-02-26 15:16:51 +01:00
|
|
|
$mform = $this->_form;
|
|
|
|
$columns = $this->_customdata['columns'];
|
2007-11-05 00:43:37 +00:00
|
|
|
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
if ($mform->elementExists($column)) {
|
|
|
|
$mform->removeElement($column);
|
|
|
|
}
|
|
|
|
}
|
2011-02-26 15:16:51 +01:00
|
|
|
|
|
|
|
if (!in_array('password', $columns)) {
|
|
|
|
// password resetting makes sense only if password specified in csv file
|
|
|
|
if ($mform->elementExists('uuforcepasswordchange')) {
|
|
|
|
$mform->removeElement('uuforcepasswordchange');
|
|
|
|
}
|
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Server side validation.
|
|
|
|
*/
|
2007-11-23 22:15:07 +00:00
|
|
|
function validation($data, $files) {
|
|
|
|
$errors = parent::validation($data, $files);
|
2011-02-26 15:16:51 +01:00
|
|
|
$columns = $this->_customdata['columns'];
|
2007-11-05 00:43:37 +00:00
|
|
|
$optype = $data['uutype'];
|
|
|
|
|
|
|
|
// detect if password column needed in file
|
|
|
|
if (!in_array('password', $columns)) {
|
|
|
|
switch ($optype) {
|
2011-02-26 15:16:51 +01:00
|
|
|
case UU_USER_UPDATE:
|
2007-11-05 00:43:37 +00:00
|
|
|
if (!empty($data['uupasswordold'])) {
|
|
|
|
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
case UU_USER_ADD_UPDATE:
|
2007-11-05 00:43:37 +00:00
|
|
|
if (empty($data['uupasswordnew'])) {
|
|
|
|
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
if (!empty($data['uupasswordold'])) {
|
|
|
|
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
case UU_USER_ADDNEW:
|
2010-11-05 08:41:53 +00:00
|
|
|
if (empty($data['uupasswordnew'])) {
|
|
|
|
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
2011-02-26 15:16:51 +01:00
|
|
|
case UU_USER_ADDINC:
|
2007-11-05 00:43:37 +00:00
|
|
|
if (empty($data['uupasswordnew'])) {
|
|
|
|
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 08:41:05 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
// look for other required data
|
2011-02-26 15:16:51 +01:00
|
|
|
if ($optype != UU_USER_UPDATE) {
|
2007-11-05 00:43:37 +00:00
|
|
|
if (!in_array('firstname', $columns)) {
|
|
|
|
$errors['uutype'] = get_string('missingfield', 'error', 'firstname');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array('lastname', $columns)) {
|
|
|
|
if (isset($errors['uutype'])) {
|
|
|
|
$errors['uutype'] = '';
|
|
|
|
} else {
|
|
|
|
$errors['uutype'] = ' ';
|
2007-11-02 08:41:05 +00:00
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
$errors['uutype'] .= get_string('missingfield', 'error', 'lastname');
|
2007-11-02 08:41:05 +00:00
|
|
|
}
|
2007-11-05 00:43:37 +00:00
|
|
|
|
|
|
|
if (!in_array('email', $columns) and empty($data['email'])) {
|
|
|
|
$errors['email'] = get_string('requiredtemplate', 'admin');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-23 22:15:07 +00:00
|
|
|
return $errors;
|
2007-11-02 08:41:05 +00:00
|
|
|
}
|
2009-11-04 06:14:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to reformat the data from the editor component
|
|
|
|
*
|
|
|
|
* @return stdClass
|
|
|
|
*/
|
|
|
|
function get_data() {
|
|
|
|
$data = parent::get_data();
|
|
|
|
|
2011-02-26 15:16:51 +01:00
|
|
|
if ($data !== null and isset($data->description)) {
|
2009-11-04 06:14:06 +00:00
|
|
|
$data->descriptionformat = $data->description['format'];
|
|
|
|
$data->description = $data->description['text'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2007-05-02 09:33:56 +00:00
|
|
|
}
|