[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/group/ -> group_form.php (source)

   1  <?php //$Id: group_form.php,v 1.3.2.2 2007/11/23 22:12:35 skodak Exp $
   2  
   3  require_once($CFG->dirroot.'/lib/formslib.php');
   4  
   5  /// get url variables
   6  class group_form extends moodleform {
   7  
   8      // Define the form
   9      function definition () {
  10          global $USER, $CFG, $COURSE;
  11  
  12          $mform =& $this->_form;
  13  
  14          $mform->addElement('text','name', get_string('groupname', 'group'),'maxlength="254" size="50"');
  15          $mform->addRule('name', get_string('required'), 'required', null, 'client');
  16          $mform->setType('name', PARAM_MULTILANG);
  17  
  18          $mform->addElement('htmleditor', 'description', get_string('groupdescription', 'group'), array('rows'=> '15', 'course' => $COURSE->id, 'cols'=>'45'));
  19          $mform->setType('description', PARAM_RAW);
  20  
  21          $mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey'));
  22          $mform->setHelpButton('enrolmentkey', array('groupenrolmentkey', get_string('enrolmentkey', 'group')), true);
  23          $mform->setType('enrolmentkey', PARAM_RAW);
  24  
  25          $maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
  26  
  27          if (!empty($CFG->gdversion) and $maxbytes) {
  28              $options = array(get_string('no'), get_string('yes'));
  29              $mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);
  30  
  31              $this->set_upload_manager(new upload_manager('imagefile', false, false, null, false, 0, true, true, false));
  32              $mform->addElement('file', 'imagefile', get_string('newpicture', 'group'));
  33              $mform->setHelpButton('imagefile', array ('picture', get_string('helppicture')), true);
  34          }
  35  
  36          $mform->addElement('hidden','id');
  37          $mform->setType('id', PARAM_INT);
  38  
  39          $mform->addElement('hidden','courseid');
  40          $mform->setType('courseid', PARAM_INT);
  41  
  42          $this->add_action_buttons();
  43      }
  44  
  45      function validation($data, $files) {
  46          global $COURSE;
  47  
  48          $errors = parent::validation($data, $files);
  49  
  50          $name = trim(stripslashes($data['name']));
  51          if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
  52              if ($group->name != $name) {
  53                  if (groups_get_group_by_name($COURSE->id,  $name)) {
  54                      $errors['name'] = get_string('groupnameexists', 'group', $name);
  55                  }
  56              }
  57  
  58          } else if (groups_get_group_by_name($COURSE->id, $name)) {
  59              $errors['name'] = get_string('groupnameexists', 'group', $name);
  60          }
  61  
  62          return $errors;
  63      }
  64  
  65      function get_um() {
  66          return $this->_upload_manager;
  67      }
  68  }
  69  
  70  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7