Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/enrol/self/editenrolment_form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once("$CFG->libdir/formslib.php");
00030 
00031 class enrol_self_user_enrolment_form extends moodleform {
00032     function definition() {
00033         global $CFG, $DB;
00034 
00035         $mform = $this->_form;
00036 
00037         $user   = $this->_customdata['user'];
00038         $course = $this->_customdata['course'];
00039         $ue     = $this->_customdata['ue'];
00040 
00041         $mform->addElement('header','general', '');
00042 
00043         $options = array(ENROL_USER_ACTIVE    => get_string('participationactive', 'enrol'),
00044                          ENROL_USER_SUSPENDED => get_string('participationsuspended', 'enrol'));
00045         if (isset($options[$ue->status])) {
00046             $mform->addElement('select', 'status', get_string('participationstatus', 'enrol'), $options);
00047         }
00048 
00049         $mform->addElement('date_selector', 'timestart', get_string('enroltimestart', 'enrol'), array('optional' => true));
00050 
00051         $mform->addElement('date_selector', 'timeend', get_string('enroltimeend', 'enrol'), array('optional' => true));
00052 
00053         $mform->addElement('hidden', 'ue');
00054         $mform->setType('ue', PARAM_INT);
00055 
00056         $mform->addElement('hidden', 'ifilter');
00057         $mform->setType('ifilter', PARAM_ALPHA);
00058 
00059         $this->add_action_buttons();
00060 
00061         $this->set_data(array(
00062             'ue' => $ue->id,
00063             'status' => $ue->status,
00064             'timestart' => $ue->timestart,
00065             'timeend' => $ue->timeend
00066         ));
00067     }
00068 
00069     function validation($data, $files) {
00070         $errors = parent::validation($data, $files);
00071 
00072         if (!empty($data['timestart']) and !empty($data['timeend'])) {
00073             if ($data['timestart'] >= $data['timeend']) {
00074                 $errors['timestart'] = get_string('error');
00075                 $errors['timeend'] = get_string('error');
00076             }
00077         }
00078 
00079         return $errors;
00080     }
00081 }
 All Data Structures Namespaces Files Functions Variables Enumerations