2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2010-05-13 02:02:05 +00:00
|
|
|
|
|
|
|
if (!defined('MOODLE_INTERNAL')) {
|
|
|
|
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
|
|
|
}
|
|
|
|
|
2007-05-02 09:33:56 +00:00
|
|
|
require_once $CFG->libdir.'/formslib.php';
|
|
|
|
|
2007-11-02 08:41:05 +00:00
|
|
|
class admin_uploaduser_form1 extends moodleform {
|
2007-05-02 09:33:56 +00:00
|
|
|
function definition (){
|
2007-11-01 19:37:25 +00:00
|
|
|
global $CFG, $USER;
|
|
|
|
|
2007-05-02 09:33:56 +00:00
|
|
|
$mform =& $this->_form;
|
|
|
|
|
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);
|
|
|
|
|
2010-02-05 07:30:53 +00:00
|
|
|
$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);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class admin_uploaduser_form2 extends moodleform {
|
|
|
|
function definition (){
|
|
|
|
global $CFG, $USER;
|
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform =& $this->_form;
|
|
|
|
$columns =& $this->_customdata;
|
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'));
|
2010-02-05 07:30:53 +00:00
|
|
|
$mform->addElement('static', 'uutypelabel', get_string('uuoptype', 'admin') );
|
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);
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uupasswordnew', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
$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);
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uuupdatetype', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
$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);
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uupasswordold', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
$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'));
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uuallowrenames', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW);
|
|
|
|
$mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC);
|
|
|
|
|
|
|
|
$mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin'));
|
2007-11-05 09:36:46 +00:00
|
|
|
$mform->setDefault('uuallowdeletes', 0);
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW);
|
|
|
|
$mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC);
|
|
|
|
|
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
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
$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);
|
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
|
|
|
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client');
|
2007-08-20 08:51:35 +00:00
|
|
|
|
2007-11-05 00:43:37 +00:00
|
|
|
// only enabled and known to work plugins
|
|
|
|
$choices = uu_allowed_auths();
|
|
|
|
$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-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
|
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('emailenable'), 1 => get_string('emaildisable'));
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
|
|
|
|
|
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');
|
|
|
|
|
2007-11-01 19:37:25 +00:00
|
|
|
$choices = array(0 => get_string('autosubscribeyes'), 1 => 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);
|
|
|
|
$mform->setDefault('city', $templateuser->city);
|
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());
|
2007-08-20 08:51:35 +00:00
|
|
|
$mform->setDefault('country', $templateuser->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);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'readcount');
|
|
|
|
$mform->setType('readcount', PARAM_INT);
|
2007-11-02 08:41:05 +00:00
|
|
|
|
2010-02-05 07:30:53 +00:00
|
|
|
$mform->addElement('hidden', 'uutype');
|
|
|
|
$mform->setType('uutype', 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'));
|
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() {
|
2007-11-05 00:43:37 +00:00
|
|
|
$mform =& $this->_form;
|
|
|
|
$columns =& $this->_customdata;
|
|
|
|
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
if ($mform->elementExists($column)) {
|
|
|
|
$mform->removeElement($column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Server side validation.
|
|
|
|
*/
|
2007-11-23 22:15:07 +00:00
|
|
|
function validation($data, $files) {
|
|
|
|
$errors = parent::validation($data, $files);
|
2007-11-05 00:43:37 +00:00
|
|
|
$columns =& $this->_customdata;
|
|
|
|
$optype = $data['uutype'];
|
|
|
|
|
|
|
|
// detect if password column needed in file
|
|
|
|
if (!in_array('password', $columns)) {
|
|
|
|
switch ($optype) {
|
|
|
|
case UU_UPDATE:
|
|
|
|
if (!empty($data['uupasswordold'])) {
|
|
|
|
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UU_ADD_UPDATE:
|
|
|
|
if (empty($data['uupasswordnew'])) {
|
|
|
|
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
if (!empty($data['uupasswordold'])) {
|
|
|
|
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UU_ADDNEW:
|
|
|
|
case UU_ADDINC:
|
|
|
|
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
|
|
|
|
if ($optype != UU_UPDATE) {
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array('city', $columns) and empty($data['city'])) {
|
|
|
|
$errors['city'] = get_string('required');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
if ($data !== null) {
|
|
|
|
$data->descriptionformat = $data->description['format'];
|
|
|
|
$data->description = $data->description['text'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2007-05-02 09:33:56 +00:00
|
|
|
}
|
2009-11-01 10:57:00 +00:00
|
|
|
|
2010-01-13 06:23:54 +00:00
|
|
|
class admin_uploaduser_form3 extends moodleform {
|
|
|
|
function definition (){
|
|
|
|
global $CFG, $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
|
|
|
$mform =& $this->_form;
|
2010-01-13 06:23:54 +00:00
|
|
|
$this->add_action_buttons(false, get_string('uploadnewfile'));
|
|
|
|
}
|
|
|
|
}
|