file check_defaults.class.php was added on branch MOODLE_19_STABLE on 2008-05-15...
[moodle-linuxchix.git] / group / grouping_form.php
blob161aa0b2621c48ab96e0872d220b039588f6708d
1 <?php //$Id$
3 require_once($CFG->dirroot.'/lib/formslib.php');
5 /// get url variables
6 class grouping_form extends moodleform {
8 // Define the form
9 function definition () {
10 global $USER, $CFG, $COURSE;
12 $mform =& $this->_form;
14 $mform->addElement('text','name', get_string('groupingname', 'group'),'maxlength="254" size="50"');
15 $mform->addRule('name', get_string('required'), 'required', null, 'server');
16 $mform->setType('name', PARAM_MULTILANG);
18 $mform->addElement('htmleditor', 'description', get_string('groupingdescription', 'group'), array('rows'=> '15', 'course' => $COURSE->id, 'cols'=>'45'));
19 $mform->setType('description', PARAM_RAW);
21 $mform->addElement('hidden','id');
22 $mform->setType('id', PARAM_INT);
24 $mform->addElement('hidden', 'courseid');
25 $mform->setType('courseid', PARAM_INT);
27 $this->add_action_buttons();
30 function validation($data, $files) {
31 global $COURSE;
33 $errors = parent::validation($data, $files);
35 $name = trim(stripslashes($data['name']));
36 if ($data['id'] and $grouping = get_record('groupings', 'id', $data['id'])) {
37 if ($grouping->name != $name) {
38 if (groups_get_grouping_by_name($COURSE->id, $name)) {
39 $errors['name'] = get_string('groupingnameexists', 'group', $name);
43 } else if (groups_get_grouping_by_name($COURSE->id, $name)) {
44 $errors['name'] = get_string('groupingnameexists', 'group', $name);
47 return $errors;