2009-11-01 12:00:47 +00:00
|
|
|
<?php
|
2012-01-05 09:29:55 +08: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/>.
|
|
|
|
|
2007-03-28 08:40:32 +00:00
|
|
|
|
2009-11-04 06:14:06 +00:00
|
|
|
/**
|
2012-01-05 09:29:55 +08:00
|
|
|
* A form for the creation and editing of groups.
|
2009-11-04 06:14:06 +00:00
|
|
|
*
|
2012-01-05 09:29:55 +08:00
|
|
|
* @copyright 2006 The Open University, N.D.Freear AT open.ac.uk, J.White AT open.ac.uk
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @package core_group
|
2009-11-04 06:14:06 +00:00
|
|
|
*/
|
|
|
|
|
2010-07-11 13:07:24 +00:00
|
|
|
defined('MOODLE_INTERNAL') || die;
|
2010-05-13 02:02:05 +00:00
|
|
|
|
2007-03-28 08:40:32 +00:00
|
|
|
require_once($CFG->dirroot.'/lib/formslib.php');
|
|
|
|
|
2012-01-05 09:29:55 +08:00
|
|
|
/**
|
|
|
|
* Group form class
|
|
|
|
*
|
|
|
|
* @copyright 2006 The Open University, N.D.Freear AT open.ac.uk, J.White AT open.ac.uk
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @package core_group
|
|
|
|
*/
|
2007-08-15 23:51:07 +00:00
|
|
|
class group_form extends moodleform {
|
2007-03-28 08:40:32 +00:00
|
|
|
|
2012-01-05 09:29:55 +08:00
|
|
|
/**
|
|
|
|
* Definition of the form
|
|
|
|
*/
|
2007-03-28 08:40:32 +00:00
|
|
|
function definition () {
|
|
|
|
global $USER, $CFG, $COURSE;
|
|
|
|
|
|
|
|
$mform =& $this->_form;
|
2009-11-04 06:14:06 +00:00
|
|
|
$editoroptions = $this->_customdata['editoroptions'];
|
2007-08-14 00:50:00 +00:00
|
|
|
|
2007-03-29 08:40:08 +00:00
|
|
|
$mform->addElement('text','name', get_string('groupname', 'group'),'maxlength="254" size="50"');
|
2007-08-15 23:51:07 +00:00
|
|
|
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
2007-03-28 08:40:32 +00:00
|
|
|
$mform->setType('name', PARAM_MULTILANG);
|
|
|
|
|
2009-11-04 06:14:06 +00:00
|
|
|
$mform->addElement('editor', 'description_editor', get_string('groupdescription', 'group'), null, $editoroptions);
|
|
|
|
$mform->setType('description_editor', PARAM_RAW);
|
2007-08-14 00:50:00 +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
|
|
|
$mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey', 'group'));
|
2010-07-19 16:42:09 +00:00
|
|
|
$mform->addHelpButton('enrolmentkey', 'enrolmentkey', 'group');
|
2007-03-28 08:40:32 +00:00
|
|
|
$mform->setType('enrolmentkey', PARAM_RAW);
|
2007-08-14 00:50:00 +00:00
|
|
|
|
2010-07-11 13:07:24 +00:00
|
|
|
if (!empty($CFG->gdversion)) {
|
2007-04-04 01:43:31 +00:00
|
|
|
$options = array(get_string('no'), get_string('yes'));
|
|
|
|
$mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);
|
2007-08-14 00:50:00 +00:00
|
|
|
|
2010-06-11 05:10:12 +00:00
|
|
|
$mform->addElement('filepicker', 'imagefile', get_string('newpicture', 'group'));
|
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('imagefile', 'newpicture', 'group');
|
2007-03-28 08:40:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 00:50:00 +00:00
|
|
|
$mform->addElement('hidden','id');
|
|
|
|
$mform->setType('id', PARAM_INT);
|
2007-07-07 14:18:30 +12:00
|
|
|
|
2007-08-14 00:50:00 +00:00
|
|
|
$mform->addElement('hidden','courseid');
|
|
|
|
$mform->setType('courseid', PARAM_INT);
|
2007-03-28 08:40:32 +00:00
|
|
|
|
2007-08-15 23:51:07 +00:00
|
|
|
$this->add_action_buttons();
|
2007-03-28 08:40:32 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 09:29:55 +08:00
|
|
|
/**
|
|
|
|
* Form validation
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @param array $files
|
|
|
|
* @return array $errors An array of errors
|
|
|
|
*/
|
2007-11-23 22:15:07 +00:00
|
|
|
function validation($data, $files) {
|
2008-12-06 21:20:42 +00:00
|
|
|
global $COURSE, $DB, $CFG;
|
2007-08-14 00:50:00 +00:00
|
|
|
|
2007-11-23 22:15:07 +00:00
|
|
|
$errors = parent::validation($data, $files);
|
2007-08-14 00:50:00 +00:00
|
|
|
|
2008-06-01 17:53:25 +00:00
|
|
|
$name = trim($data['name']);
|
2008-06-01 13:09:04 +00:00
|
|
|
if ($data['id'] and $group = $DB->get_record('groups', array('id'=>$data['id']))) {
|
2012-01-21 13:28:20 +01:00
|
|
|
if (textlib::strtolower($group->name) != textlib::strtolower($name)) {
|
2007-08-15 20:33:17 +00:00
|
|
|
if (groups_get_group_by_name($COURSE->id, $name)) {
|
2007-08-15 23:51:07 +00:00
|
|
|
$errors['name'] = get_string('groupnameexists', 'group', $name);
|
2007-08-14 00:50:00 +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
|
|
|
if (!empty($CFG->groupenrolmentkeypolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) {
|
2008-12-06 21:20:42 +00:00
|
|
|
// enforce password policy only if changing password
|
|
|
|
$errmsg = '';
|
|
|
|
if (!check_password_policy($data['enrolmentkey'], $errmsg)) {
|
|
|
|
$errors['enrolmentkey'] = $errmsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-16 15:52:52 +00:00
|
|
|
} else if (groups_get_group_by_name($COURSE->id, $name)) {
|
2007-08-15 23:51:07 +00:00
|
|
|
$errors['name'] = get_string('groupnameexists', 'group', $name);
|
2007-08-14 00:50:00 +00:00
|
|
|
}
|
|
|
|
|
2007-11-23 22:15:07 +00:00
|
|
|
return $errors;
|
2007-08-14 00:50:00 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 09:29:55 +08:00
|
|
|
/**
|
|
|
|
* Get editor options for this form
|
|
|
|
*
|
|
|
|
* @return array An array of options
|
|
|
|
*/
|
2009-11-04 06:14:06 +00:00
|
|
|
function get_editor_options() {
|
|
|
|
return $this->_customdata['editoroptions'];
|
|
|
|
}
|
2007-03-28 08:40:32 +00:00
|
|
|
}
|