/**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->addElement('hidden', 'classid');
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('auto_enrol_cluster_curriculum', 'block_curr_admin'), null, array('0', '1'));
     $mform->setDefault('autoenrol', '1');
     $mform->setHelpButton('autoenrol', array('clustercurriculumform/autoenrol', get_string('auto_enrol', 'block_curr_admin'), 'block_curr_admin'));
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'userid');
     $mform->setType('userid', PARAM_INT);
     $mform->addElement('hidden', 'clusterid');
     $mform->setType('clusterid', PARAM_INT);
     $this->add_action_buttons();
     parent::definition();
 }
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $data = $this->_customdata[0];
     $mform->addElement('hidden', 'id');
     $limit_group[] = $mform->addElement('static', 'lbl_classlimit', get_string('class_limit', 'block_curr_admin') . ':', $data->limit);
     $mform->addElement('static', 'lbl_enroled', get_string('enroled', 'block_curr_admin') . ': ', $data->enroled);
     $mform->addElement('static', 'lbl_num_waitlist', get_string('num_waitlist', 'block_curr_admin') . ': ', $data->waitlisted);
     $mform->addElement('static', 'lbl_enrol_confirmation', '', get_string('enrol_confirmation', 'block_curr_admin', $data->a));
     $this->add_action_buttons(true, get_string('enrol', 'block_curr_admin'));
 }
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $data = $this->_customdata[0];
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $limit_group[] = $mform->addElement('static', 'lbl_classlimit', get_string('class_limit', 'local_elisprogram') . ':', $data->limit);
     $mform->addElement('static', 'lbl_enroled', get_string('enroled', 'local_elisprogram') . ': ', $data->enroled);
     $mform->addElement('static', 'lbl_num_waitlist', get_string('num_waitlist', 'local_elisprogram') . ': ', $data->waitlisted);
     $mform->addElement('static', 'lbl_enrol_confirmation', '', get_string('enrol_confirmation', 'local_elisprogram', $data->a));
     $this->add_action_buttons(true, get_string('btn_waitlist_add', 'local_elisprogram'));
 }
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->setType('trackid', PARAM_INT);
     $mform->addElement('hidden', 'clusterid');
     $mform->setType('clusterid', PARAM_INT);
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('usersettrack_auto_enrol', 'local_elisprogram'), null, array('0', '1'));
     $mform->setDefault('autoenrol', '1');
     $mform->addHelpButton('autoenrol', 'usersettrackform:autoenrol', 'local_elisprogram');
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'userid');
     $mform->addElement('hidden', 'clusterid');
     $mform->addElement('advcheckbox', 'autoenrol', get_string('cluster_manual_autoenrol_label', 'block_curr_admin'));
     $mform->addElement('static', '', '', get_string('cluster_manual_autoenrol_help', 'block_curr_admin'));
     $mform->addElement('advcheckbox', 'leader', get_string('cluster_manual_leader_label', 'block_curr_admin'));
     $mform->addElement('static', '', '', get_string('cluster_manual_leader_help', 'block_curr_admin'));
     $this->add_action_buttons();
     parent::definition();
 }
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     if (!empty($this->_customdata['students'])) {
         $student_list = $this->_customdata['students'];
         $mform->addElement('header', 'waitlistaddform', get_string('waitinglistform_title', 'block_curr_admin'));
         foreach ($student_list as $student) {
             $mform->addElement('hidden', 'userid[' . $student->userid . ']', $student->userid);
             $mform->addElement('hidden', 'classid[' . $student->userid . ']', $student->classid);
             $mform->addElement('hidden', 'enrolmenttime[' . $student->userid . ']', $student->enrolmenttime);
             $enrol_options = array();
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('yes'), 1);
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('no'), 0);
             $context = get_context_instance(CONTEXT_SYSTEM);
             if (has_capability('block/curr_admin:overrideclasslimit', $context)) {
                 $mform->addElement('hidden', 'grade[' . $student->userid . ']', $student->grade);
                 $mform->addElement('hidden', 'credits[' . $student->credits . ']', $student->credits);
                 $mform->addElement('hidden', 'locked[' . $student->locked . ']', $student->locked);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('over_enrol', 'block_curr_admin'), 2);
             }
             $user = new user($student->userid);
             $name = new object();
             $name->name = $user->to_string();
             $name->username = $user->username;
             $mform->addGroup($enrol_options, 'options[' . $student->userid . ']', get_string('add_to_waitinglist', 'block_curr_admin', $name), '', false);
         }
     } else {
         if (!empty($this->_customdata['student_ids'])) {
             $student_id = $this->_customdata['student_ids'];
             foreach ($student_id as $id => $student) {
                 $mform->addElement('hidden', 'userid[' . $id . ']');
                 $mform->addElement('hidden', 'classid[' . $id . ']');
                 $mform->addElement('hidden', 'enrolmenttime[' . $id . ']');
                 $enrol_options = array();
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('yes'), 1);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('no'), 0);
                 $context = get_context_instance(CONTEXT_SYSTEM);
                 if (has_capability('block/curr_admin:overrideclasslimit', $context)) {
                     $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('over_enrol', 'block_curr_admin'), 2);
                 }
                 $name = 'no name';
                 $mform->addGroup($enrol_options, 'options[' . $id . ']', $name, '', false);
             }
         }
     }
     $mform->addElement('hidden', 'id');
     $mform->addElement('submit', 'submitbutton', 'Save');
 }
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->addElement('hidden', 'classid');
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('auto_enrol_long', 'block_curr_admin'), null, array('0', '1'));
     $mform->setHelpButton('autoenrol', array('trackassignmentform/autoenrol', get_string('auto_enrol', 'block_curr_admin'), 'block_curr_admin'));
     if (isset($this->_customdata['obj'])) {
         $trackid = $this->_customdata['obj']->trackid;
         $aid = $this->_customdata['obj']->id;
         $mform->addElement('static', 'enrolall', null, "<button onclick=\"location.href=&quot;index.php?s=trkcls&amp;action=enrolall&amp;id={$trackid}&amp;association_id={$aid}&quot;; return false\"/>" . get_string('enrol_all_users_now', 'block_curr_admin') . '</button>');
     }
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG, $DB;
     parent::definition();
     $strrequired = get_string('required');
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $shortname = $mform->addElement('text', 'shortname', get_string('shortname', 'elisprogram_usetclassify'));
     $mform->setType('shortname', PARAM_TEXT);
     if (empty($this->_customdata['obj'])) {
         $mform->addRule('shortname', $strrequired, 'required', null, 'client');
     } else {
         $shortname->freeze();
     }
     $mform->addElement('text', 'name', get_string('name', 'elisprogram_usetclassify'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     $mform->addElement('advcheckbox', 'param_autoenrol_curricula', get_string('autoenrol_curricula', 'elisprogram_usetclassify'));
     $mform->addElement('advcheckbox', 'param_autoenrol_tracks', get_string('autoenrol_tracks', 'elisprogram_usetclassify'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groups', get_string('autoenrol_groups', 'elisprogram_usetclassify'));
     $mform->addHelpButton('param_autoenrol_groups', 'usersetclassificationform:autoenrol_groups', 'elisprogram_usetclassify');
     $mform->addElement('advcheckbox', 'param_autoenrol_groupings', get_string('autoenrol_groupings', 'elisprogram_usetclassify'));
     $mform->addHelpButton('param_autoenrol_groupings', 'usersetclassificationform:autoenrol_groupings', 'elisprogram_usetclassify');
     // Add option for Alfresco shared organization space creation (if Alfresco code is present)
     if (file_exists($CFG->dirroot . '/repository/elisfiles/lib.php') && $DB->record_exists('config_plugins', array('plugin' => 'elisfiles'))) {
         $mform->addElement('advcheckbox', 'param_elis_files_shared_folder', get_string('elis_files_shared_folder', 'elisprogram_usetclassify'));
         $mform->addHelpButton('param_elis_files_shared_folder', 'usersetclassificationform:elis_files_shared_folder', 'elisprogram_usetclassify');
     }
     $recs = $DB->get_recordset(usersetclassification::TABLE, null, 'name ASC', 'shortname, name');
     //                                                  ($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0)
     $options = array('' => get_string('same_classification', 'elisprogram_usetclassify'));
     foreach ($recs as $rec) {
         $options[$rec->shortname] = $rec->name;
     }
     unset($recs);
     $mform->addElement('select', 'param_child_classification', get_string('child_classification', 'elisprogram_usetclassify'), $options);
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG, $CURMAN;
     parent::definition();
     $strrequired = get_string('required');
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('hidden', PARAM_INT);
     $shortname = $mform->addElement('text', 'shortname', get_string('shortname', 'crlm_cluster_classification'));
     if (empty($this->_customdata['obj'])) {
         $mform->addRule('shortname', $strrequired, 'required', null, 'client');
     } else {
         $shortname->freeze();
     }
     $mform->addElement('text', 'name', get_string('name', 'crlm_cluster_classification'));
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     $mform->addElement('advcheckbox', 'param_autoenrol_curricula', get_string('autoenrol_curricula', 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_tracks', get_string('autoenrol_tracks', 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groups', get_string('autoenrol_groups', 'crlm_cluster_classification'));
     $mform->setHelpButton('param_autoenrol_groups', array('autoenrol_groups', get_string('autoenrol_groups', 'crlm_cluster_classification'), 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groupings', get_string('autoenrol_groupings', 'crlm_cluster_classification'));
     $mform->setHelpButton('param_autoenrol_groupings', array('autoenrol_groupings', get_string('autoenrol_groupings', 'crlm_cluster_classification'), 'crlm_cluster_classification'));
     // Add option for Alfresco shared organization space creation (if Alfresco code is present)
     if (file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php') && record_exists('block', 'name', 'repository')) {
         $mform->addElement('advcheckbox', 'param_alfresco_shared_folder', get_string('alfresco_shared_folder', 'crlm_cluster_classification'));
         $button = array('alfresco_shared_folder', get_string('alfresco_shared_folder', 'crlm_cluster_classification'), 'crlm_cluster_classification');
         $mform->setHelpButton('param_alfresco_shared_folder', $button);
     }
     $recs = $CURMAN->db->get_records(CLUSTERCLASSTABLE, '', '', 'name ASC', 'shortname, name');
     $options = array('' => get_string('same_classification', 'crlm_cluster_classification'));
     if ($recs) {
         foreach ($recs as $rec) {
             $options[$rec->shortname] = $rec->name;
         }
     }
     $mform->addElement('select', 'param_child_classification', get_string('child_classification', 'crlm_cluster_classification'), $options);
     $this->add_action_buttons();
 }
 function freeze()
 {
     if (isset($this->_form->_elementIndex['autocreate'])) {
         $this->_form->removeElement('autocreate');
     }
     parent::freeze();
 }
 public function definition()
 {
     global $CURMAN, $CFG;
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'confirm');
     $mform->setDefault('confirm', md5($this->_customdata['obj']->id));
     $radioarray = array();
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('deletesubs', 'block_curr_admin'), 1);
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('promotesubs', 'block_curr_admin'), 2);
     $mform->addGroup($radioarray, 'deletesubs', '', '<br />', false);
     $mform->setDefault('deletesubs', 2);
     $this->add_action_buttons();
 }
 function freeze()
 {
     // Add completion status information
     $counts = $this->_customdata['obj']->get_completion_counts();
     $counttext = "Passed: {$counts[2]}, Failed: {$counts[1]}, In Progress: {$counts[0]}";
     $this->_form->addElement('static', 'test', get_string('completion_status', 'block_curr_admin'), $counttext);
     parent::freeze();
 }
 function validation($data, $files)
 {
     global $CFG, $CURMAN;
     $errors = parent::validation($data, $files);
     // Use a default for 'id' if we're doing an add
     if (!$data['id']) {
         $data['id'] = 0;
     }
     if (!empty($data['username'])) {
         if (!$this->check_unique(USRTABLE, 'username', $data['username'], $data['id'])) {
             $errors['username_group'] = get_string('badusername', 'block_curr_admin');
         }
     } else {
         if (!$data['id'] && empty($data['id_same_user'])) {
             $errors['username_group'] = get_string('required');
         }
     }
     if (!empty($data['idnumber'])) {
         if (!$this->check_unique(USRTABLE, 'idnumber', $data['idnumber'], $data['id'])) {
             $errors['idnumber'] = get_string('badidnumber', 'block_curr_admin');
         }
     }
     // Validate the supplied email addresses as best we can...
     if (!empty($data['email'])) {
         if (!$this->check_unique(USRTABLE, 'email', $data['email'], $data['id'])) {
             $errors['email'] = get_string('emailexists');
         }
     }
     if (!empty($data['email2'])) {
         if (!$this->check_unique(USRTABLE, 'email', $data['email2'], $data['id'])) {
             $errors['email2'] = get_string('emailexists');
         }
     }
     if (!empty($data['contactemail'])) {
         if (!$this->check_unique(USRTABLE, 'email', $data['contactemail'], $data['id'])) {
             $errors['contactemail'] = get_string('emailexists');
         }
     }
     // validate custom profile fields
     $fields = field::get_for_context_level(context_level_base::get_custom_context_level('user', 'block_curr_admin'));
     $fields = $fields ? $fields : array();
     if ($data['id']) {
         $context = get_context_instance(context_level_base::get_custom_context_level('user', 'block_curr_admin'), $data['id']);
         $contextid = $context->id;
     } else {
         $contextid = 0;
     }
     foreach ($fields as $field) {
         $field = new field($field);
         $key = "field_{$field->shortname}";
         if ($field->multivalued) {
             $manual = new field_owner($field->owners['manual']);
             $fielddata = isset($data[$key]) ? $data[$key] : array();
             if ($manual->param_required) {
                 if (empty($fielddata)) {
                     $errors[$key] = get_string('required');
                 } else {
                     if (!empty($manual->param_options)) {
                         $options = explode("\n", $manual->param_options);
                         array_walk($options, 'trim_cr');
                         // TBD: defined below
                         foreach ($fielddata as $entry) {
                             if (!in_array($entry, $options)) {
                                 $errors[$key] = get_string('required');
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!isset($errors[$key]) && $field->forceunique && $contextid) {
                 $where = "contextid != {$contextid} AND fieldid = {$field->id}";
                 if ($recs = get_records_select($field->data_table(), $where, 'contextid, data')) {
                     $curcontext = -1;
                     $vals = null;
                     foreach ($recs as $rec) {
                         if ($curcontext != $rec->contextid) {
                             if (!empty($vals)) {
                                 $adif = array_diff($vals, $fielddata);
                                 if (empty($adif)) {
                                     $errors[$key] = get_string('valuealreadyused');
                                     // TBD^^^ "[These/This combination of] values already uesd!"
                                     $vals = null;
                                     break;
                                 }
                             }
                             $curcontext = $rec->contextid;
                             $vals = array();
                         }
                         $vals[] = $rec->data;
                     }
                     if (!empty($vals)) {
                         $adif = array_diff($vals, $fielddata);
                         if (empty($adif)) {
                             $errors[$key] = get_string('valuealreadyused');
                             // TBD^^^ "[These/This combination of] values already uesd!"
                         }
                     }
                 }
             }
         } else {
             if ($field->forceunique) {
                 // NON-MULTIVALUED case
                 $fielddata = $CURMAN->db->get_record($field->data_table(), 'fieldid', $field->id, 'data', $data[$key]);
                 //print_object($fielddata);
                 if ($fielddata && $fielddata->contextid != $contextid) {
                     $errors[$key] = get_string('valuealreadyused');
                 }
             }
         }
     }
     return $errors;
 }
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (intval($data['catalog_collapse_count']) <= 0) {
         $errors['catalog_collapse_count'] = get_string('error_catalog_collapse_count', 'block_curr_admin');
     }
     if (intval($data['num_block_icons']) <= 0) {
         $errors['num_block_icons'] = get_string('error_num_block_icons', 'block_curr_admin');
     }
     return $errors;
 }
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     //config data setup
     $dataSet = array('curriculumid', 'courseid', 'id', 'availableCorequisites', 'existingCorequisites', 'association_id');
     foreach ($dataSet as $d) {
         if (isset($this->_customdata[$d])) {
             $data->{$d} = $this->_customdata[$d];
         } else {
             $data->{$d} = null;
         }
     }
     //add elements
     $mform->addElement('hidden', 'curriculum');
     $mform->setType('curriculum', PARAM_INT);
     $mform->addElement('hidden', 'course');
     $mform->setType('course', PARAM_INT);
     $mform->addElement('hidden', 'association_id', $data->association_id);
     $mform->setType('association_id', PARAM_INT);
     $mform->addElement('header', 'curriculumcourseeditform', get_string('edit_course_corequisites', 'block_curr_admin'));
     $select =& $mform->addElement('select', 'coreqs', get_string('available_course_corequisites', 'block_curr_admin'), $data->availableCorequisites);
     $select->setMultiple(true);
     $select =& $mform->addElement('select', 'scoreqs', get_string('existing_course_corequisites', 'block_curr_admin'), $data->existingCorequisites);
     $select->setMultiple(true);
     $mform->addElement('checkbox', 'add_to_curriculum', get_string('add_coreq_to_curriculum', 'block_curr_admin'));
     $group = array();
     $group[] =& $mform->createElement('submit', 'add', get_string('add_coreq', 'block_curr_admin'));
     $group[] =& $mform->createElement('submit', 'remove', get_string('remove_coreq', 'block_curr_admin'));
     $mform->addGroup($group, 'submitbuttons', '', '', false);
     $mform->addElement('cancel', 'exit', get_string('exit', 'block_curr_admin'));
 }
Exemple #17
0
 function validation($data, $files)
 {
     global $CFG, $DB;
     $errors = parent::validation($data, $files);
     // Use a default for 'id' if we're doing an add
     if (!$data['id']) {
         $data['id'] = 0;
     }
     if (!empty($data['username'])) {
         if (!$this->check_unique(user::TABLE, 'username', $data['username'], $data['id'])) {
             $errors['username_group'] = get_string('badusername', 'local_elisprogram');
         }
     } else {
         if (!$data['id'] && empty($data['id_same_user'])) {
             $errors['username_group'] = get_string('required');
         }
     }
     if (!empty($data['idnumber'])) {
         if (!$this->check_unique(user::TABLE, 'idnumber', $data['idnumber'], $data['id'])) {
             $errors['idnumber'] = get_string('badidnumber', 'local_elisprogram');
         } else {
             //make sure we don't set up an idnumber that is related to a non-linked Moodle user
             require_once elispm::lib('data/usermoodle.class.php');
             if (!($muserid = $DB->get_field(usermoodle::TABLE, 'muserid', array('cuserid' => $data['id'])))) {
                 $muserid = 0;
             }
             if (!$this->check_unique('user', 'idnumber', $data['idnumber'], $muserid)) {
                 $errors['idnumber'] = get_string('badidnumbermoodle', 'local_elisprogram');
             }
         }
     }
     // Validate the supplied email addresses as best we can...
     if (!empty($data['email'])) {
         if (!$this->check_unique(user::TABLE, 'email', $data['email'], $data['id'])) {
             $errors['email'] = get_string('emailexists');
         }
     }
     if (!empty($data['email2'])) {
         if (!$this->check_unique(user::TABLE, 'email', $data['email2'], $data['id'])) {
             $errors['email2'] = get_string('emailexists');
         }
     }
     if (!empty($data['contactemail'])) {
         if (!$this->check_unique(user::TABLE, 'email', $data['contactemail'], $data['id'])) {
             $errors['contactemail'] = get_string('emailexists');
         }
     }
     $errors += parent::validate_custom_fields($data, 'user');
     return $errors;
 }
Exemple #18
0
 /**
  * Display HTML
  *
  * This function works around the limitations of the moodle forms by printing html
  * directly.  This allows for more custom designed forms.
  */
 function display()
 {
     if ($this->_layout == 'custom') {
         print implode("\n", $this->_html);
     } else {
         parent::display();
     }
 }
 function validation($data, $files)
 {
     global $CURMAN;
     $errors = parent::validation($data, $files);
     if ($CURMAN->db->record_exists_select(CRSTABLE, "idnumber = '{$data['idnumber']}'" . ($data['id'] ? " AND id != {$data['id']}" : ''))) {
         $errors['idnumber'] = get_string('idnumber_already_used', 'block_curr_admin');
     }
     return $errors;
 }
 /**
  * Definition after data method to modify form based on form data
  *
  * @uses $DB
  * @uses $PAGE
  */
 function definition_after_data()
 {
     global $DB, $PAGE;
     parent::definition_after_data();
     $mform =& $this->_form;
     // Disable shortname if user context and Moodle shortname exists
     $level = $this->_customdata['level'];
     $shortname = $mform->getElementValue('shortname');
     $requireshortname = true;
     if ($level == 'user') {
         // user custom field from Moodle
         if (!empty($shortname) && $DB->record_exists('user_info_field', array('shortname' => $shortname))) {
             $mform->freeze('shortname');
             // ELIS-8329: 2.4 freeze seems to remove element from data!
             $mform->setDefault('shortname', $shortname);
             $requireshortname = false;
         }
     }
     if ($requireshortname) {
         $mform->addRule('shortname', get_string('required'), 'required', null, 'client');
     }
     // Check for specific plugin definition_after_data functions
     $plugins = core_component::get_plugin_list('elisfields');
     foreach ($plugins as $plugin => $dir) {
         if (is_readable(elis::plugin_file("elisfields_{$plugin}", 'custom_fields.php'))) {
             include_once elis::plugin_file("elisfields_{$plugin}", 'custom_fields.php');
             if (function_exists("{$plugin}_field_edit_form_definition_after_data")) {
                 call_user_func("{$plugin}_field_edit_form_definition_after_data", $mform, $level, $shortname);
             }
         }
     }
     $td = $mform->getElementValue('defaultdata_menu');
     if (!isset($td)) {
         return;
     }
     if (!is_array($td)) {
         $td = array($td);
     }
     array_walk($td, array($this, 'trim_crlf'));
     $dt = $mform->getElementValue('datatype');
     if (!empty($dt) && is_array($dt)) {
         // If it's an array just get first value!
         foreach ($dt as $val) {
             $dt = $val;
             break;
         }
     }
     $mform->addElement('html', '<script type="text/javascript">
     function setmenudefaults() {
         var myselected = [' . ($dt == 'char' || $dt == 'text' ? '"' . implode('", "', $td) . '"' : implode(', ', $td)) . '];
         var defaultdata_menu = document.getElementById("id_defaultdata_menu");
         var inputtags = document.getElementsByTagName("input");
         for (var i = 0; i < myselected.length; ++i) {
             var j;
             for (j = 0; j < defaultdata_menu.options.length; ++j) {
                 //alert("checking: "+ myselected[i] +" == "+ parseFloat(defaultdata_menu.options[j].value));
                 if ((typeof(myselected[i]) == "string" &&
                     myselected[i] == defaultdata_menu.options[j].value)
                     || (typeof(myselected[i]) == "number" &&
                     myselected[i] == parseFloat(defaultdata_menu.options[j].value))) {
                     //alert("menu default match");
                     defaultdata_menu.options[j].selected = "selected";
                 }
             }
             for (j = 0; j < inputtags.length; ++j) {
                 //alert("checking for radios with value = "+ myselected[i] + "; current: input = "+ inputtags[j].type + ", value = "+ inputtags[j].value + " type == radio ? "+ (inputtags[j].type == "radio") + "; value == ? "+ (inputtags[j].value == myselected[i]));
                 if (inputtags[j].type == "radio" &&
                     inputtags[j].value == myselected[i]) {
                     //alert("radio default match");
                     inputtags[j].checked = "checked";
                     break;
                 }
             }
         }
     }
     YUI().use("yui2-base", "yui2-yahoo", function(Y) {
         if (Y.YUI2.env.ua.ie <= 8) {
             window.setTimeout(setmenudefaults, 2000); // ugly for IE8
         } else if (window.attachEvent) {
             window.attachEvent("onload", setmenudefaults);
         } else if (window.addEventListener) {
             window.addEventListener("DOMContentLoaded", setmenudefaults, false);
         } else {
             window.setTimeout(setmenudefaults, 2000); // rare fallback
         }
     });
     </script>');
     // $PAGE->requires->js_init_call() didn't work in IE8 w/ domready=true
 }
 function set_data($default_values, $slashed = false)
 {
     $default_values = clone $default_values;
     parent::set_data($default_values, $slashed);
 }
Exemple #22
0
 /**
  * Completion form validation method
  *
  * @param array $data array of ("fieldname"=>value) of submitted data
  * @param array $files array of uploaded files "element_name"=>tmp_file_path
  * @uses  $DB
  * @return array associative array of error messages, indexed by form element
  */
 function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $course = $this->_customdata['course'];
     $params = array($course->id, $data['idnumber']);
     $sql = 'courseid = ? AND idnumber = ?';
     if (!empty($data['elemid'])) {
         $sql .= ' AND id != ?';
         $params[] = $data['elemid'];
     }
     if ($DB->record_exists_select(coursecompletion::TABLE, $sql, $params)) {
         $errors['idnumber'] = get_string('idnumber_already_used', 'local_elisprogram');
     }
     return $errors;
 }
Exemple #23
0
 public function definition()
 {
     global $CURMAN, $CFG;
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'confirm');
     $mform->setDefault('confirm', 1);
     $mform->setType('confirm', PARAM_INT);
     $radioarray = array();
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('deletesubs', 'local_elisprogram'), 1);
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('promotesubs', 'local_elisprogram'), 0);
     $mform->addGroup($radioarray, 'deletesubs', '', '<br />', false);
     $mform->setDefault('deletesubs', 0);
     $this->add_action_buttons();
 }
Exemple #24
0
 function freeze()
 {
     // Add completion status information
     $obj = new pmclass($this->_customdata['obj']);
     $counts = $obj->get_completion_counts();
     $counttext = "Passed: {$counts[2]}, Failed: {$counts[1]}, In Progress: {$counts[0]}";
     $this->_form->addElement('static', 'test', get_string('completion_status', 'local_elisprogram'), $counttext);
     parent::freeze();
 }
 /**
  * Overridden to specially handle timetocomplete and frequency fields.
  */
 function get_data($slashed = false)
 {
     $data = parent::get_data($slashed);
     if (!empty($data)) {
         $datedelta = new datedelta($data->timetocomplete);
         $data->timetocomplete = $datedelta->getDateString();
         $datedelta = new datedelta($data->frequency);
         $data->frequency = $datedelta->getDateString();
     }
     return $data;
 }
Exemple #26
0
 public function definition()
 {
     global $DB;
     parent::definition();
     $mform =& $this->_form;
     if (!empty($this->_customdata['students'])) {
         $student_list = $this->_customdata['students'];
         $mform->addElement('header', 'waitlistaddform', get_string('waitinglistform_title', 'local_elisprogram'));
         foreach ($student_list as $student) {
             $mform->addElement('hidden', 'userid[' . $student->userid . ']', $student->userid);
             $mform->setType('userid[' . $student->userid . ']', PARAM_INT);
             $mform->addElement('hidden', 'classid[' . $student->userid . ']', $student->classid);
             $mform->setType('classid[' . $student->userid . ']', PARAM_INT);
             $mform->addElement('hidden', 'enrolmenttime[' . $student->userid . ']', $student->enrolmenttime);
             $mform->setType('enrolmenttime[' . $student->userid . ']', PARAM_INT);
             $enrol_options = array();
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('yes'), 1);
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('no'), 0);
             $context = context_system::instance();
             if (has_capability('local/elisprogram:overrideclasslimit', $context)) {
                 $mform->addElement('hidden', 'grade[' . $student->userid . ']', $student->grade);
                 $mform->setType('grade[' . $student->userid . ']', PARAM_INT);
                 $mform->addElement('hidden', 'credits[' . $student->credits . ']', $student->credits);
                 $mform->setType('credits[' . $student->credits . ']', PARAM_INT);
                 $mform->addElement('hidden', 'locked[' . $student->locked . ']', $student->locked);
                 $mform->setType('locked[' . $student->locked . ']', PARAM_INT);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('over_enrol', 'local_elisprogram'), 2);
             }
             $user = new stdClass();
             $user->name = '?';
             if ($tmpuser = new user($student->userid)) {
                 $tmpuser->load();
                 $user = $tmpuser->to_object();
                 $user->name = $tmpuser->moodle_fullname();
             }
             $mform->addGroup($enrol_options, 'options[' . $student->userid . ']', get_string('add_to_waitinglist', 'local_elisprogram', $user), array('&nbsp;&nbsp;&nbsp;'), false);
         }
     } else {
         if (!empty($this->_customdata['student_ids'])) {
             $student_id = $this->_customdata['student_ids'];
             foreach ($student_id as $id => $student) {
                 $mform->addElement('hidden', 'userid[' . $id . ']');
                 $mform->setType('userid[' . $id . ']', PARAM_INT);
                 $mform->addElement('hidden', 'classid[' . $id . ']');
                 $mform->setType('classid[' . $id . ']', PARAM_INT);
                 $mform->addElement('hidden', 'enrolmenttime[' . $id . ']');
                 $mform->setType('enrolmenttime[' . $id . ']', PARAM_INT);
                 $enrol_options = array();
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('yes'), 1);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('no'), 0);
                 $context = context_system::instance();
                 if (has_capability('local/elisprogram:overrideclasslimit', $context)) {
                     $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('over_enrol', 'local_elisprogram'), 2);
                 }
                 $name = 'no name';
                 $mform->addGroup($enrol_options, 'options[' . $id . ']', $name, '', false);
             }
         }
     }
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('submit', 'submitbutton', 'Save');
 }