|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00037 abstract class enrol_bulk_enrolment_change_form extends moodleform { 00038 00042 protected function definition() { 00043 $form = $this->_form; 00044 $users = $this->_customdata['users']; 00045 00046 $statusoptions = $this->get_status_options(); 00047 $form->addElement('html', $this->get_users_table($users, $statusoptions)); 00048 $form->addElement('select', 'status', get_string('alterstatus', 'enrol_manual'), $statusoptions, array('optional' => true)); 00049 $form->addElement('date_selector', 'timestart', get_string('altertimestart', 'enrol_manual'), array('optional' => true)); 00050 $form->addElement('date_selector', 'timeend', get_string('altertimeend', 'enrol_manual'), array('optional' => true)); 00051 00052 $this->add_action_buttons(); 00053 } 00054 00059 protected function get_status_options() { 00060 return array(-1 => get_string('nochange', 'enrol'), 00061 ENROL_USER_ACTIVE => get_string('participationactive', 'enrol'), 00062 ENROL_USER_SUSPENDED => get_string('participationsuspended', 'enrol')); 00063 } 00064 00072 protected function get_users_table(array $users, array $statusoptions) { 00073 $table = new html_table(); 00074 $table->head = array( 00075 get_string('name'), 00076 get_string('participationstatus', 'enrol'), 00077 get_string('enroltimestart', 'enrol'), 00078 get_string('enroltimeend', 'enrol'), 00079 ); 00080 $table->data = array(); 00081 foreach ($users as $user) { 00082 foreach ($user->enrolments as $enrolment) { 00083 $input = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'bulkuser[]', 'value' => $user->id)); 00084 $table->data[] = array( 00085 fullname($user).$input, 00086 $statusoptions[$enrolment->status], 00087 (!empty($enrolment->timestart))?userdate($enrolment->timestart):'', 00088 (!empty($enrolment->timeend))?userdate($enrolment->timeend):'', 00089 ); 00090 } 00091 } 00092 return html_writer::table($table); 00093 } 00094 } 00095 00101 abstract class enrol_bulk_enrolment_confirm_form extends enrol_bulk_enrolment_change_form { 00102 00106 protected function definition() { 00107 $form = $this->_form; 00108 $users = $this->_customdata['users']; 00109 $title = $this->_customdata['title']; 00110 $message = $this->_customdata['message']; 00111 $button = $this->_customdata['button']; 00112 00113 $form->addElement('html', $this->get_users_table($users, $this->get_status_options())); 00114 $form->addElement('header', 'ebecf_header', $title); 00115 $form->addElement('html', html_writer::tag('p', $message)); 00116 $this->add_action_buttons(true, $button); 00117 } 00118 }