Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/enrol/users_forms.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_users_assign_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         $context    = get_context_instance(CONTEXT_COURSE, $course->id);
00040         $assignable = $this->_customdata['assignable'];
00041         $assignable = array_reverse($assignable, true); // students first
00042 
00043         $ras = get_user_roles($context, $user->id, true);
00044         foreach ($ras as $ra) {
00045             unset($assignable[$ra->roleid]);
00046         }
00047 
00048         $mform->addElement('header','general', fullname($user));
00049 
00050         $mform->addElement('select', 'roleid', get_string('addrole', 'role'), $assignable);
00051 
00052         $mform->addElement('hidden', 'id');
00053         $mform->setType('id', PARAM_INT);
00054 
00055         $mform->addElement('hidden', 'user');
00056         $mform->setType('user', PARAM_INT);
00057 
00058         $mform->addElement('hidden', 'action');
00059         $mform->setType('action', PARAM_ACTION);
00060 
00061         $mform->addElement('hidden', 'ifilter');
00062         $mform->setType('ifilter', PARAM_ALPHA);
00063 
00064         $mform->addElement('hidden', 'page');
00065         $mform->setType('page', PARAM_INT);
00066 
00067         $mform->addElement('hidden', 'perpage');
00068         $mform->setType('perpage', PARAM_INT);
00069 
00070         $mform->addElement('hidden', 'sort');
00071         $mform->setType('sort', PARAM_ALPHA);
00072 
00073         $mform->addElement('hidden', 'dir');
00074         $mform->setType('dir', PARAM_ALPHA);
00075 
00076         $this->add_action_buttons();
00077 
00078         $this->set_data(array('action'=>'assign', 'user'=>$user->id));
00079     }
00080 }
00081 
00082 class enrol_users_addmember_form extends moodleform {
00083     function definition() {
00084         global $CFG, $DB;
00085 
00086         $mform = $this->_form;
00087 
00088         $user     = $this->_customdata['user'];
00089         $course   = $this->_customdata['course'];
00090         $context  = get_context_instance(CONTEXT_COURSE, $course->id);
00091         $allgroups = $this->_customdata['allgroups'];
00092         $usergroups = groups_get_all_groups($course->id, $user->id, 0, 'g.id');
00093 
00094         $options = array();
00095         foreach ($allgroups as $group) {
00096             if (isset($usergroups[$group->id])) {
00097                 continue;
00098             }
00099             $options[$group->id] = $group->name;
00100         }
00101 
00102         $mform->addElement('header','general', fullname($user));
00103 
00104         $mform->addElement('select', 'groupid', get_string('addgroup', 'group'), $options);
00105 
00106         $mform->addElement('hidden', 'id');
00107         $mform->setType('id', PARAM_INT);
00108 
00109         $mform->addElement('hidden', 'user');
00110         $mform->setType('user', PARAM_INT);
00111 
00112         $mform->addElement('hidden', 'action');
00113         $mform->setType('action', PARAM_ACTION);
00114 
00115         $mform->addElement('hidden', 'ifilter');
00116         $mform->setType('ifilter', PARAM_ALPHA);
00117 
00118         $mform->addElement('hidden', 'page');
00119         $mform->setType('page', PARAM_INT);
00120 
00121         $mform->addElement('hidden', 'perpage');
00122         $mform->setType('perpage', PARAM_INT);
00123 
00124         $mform->addElement('hidden', 'sort');
00125         $mform->setType('sort', PARAM_ALPHA);
00126 
00127         $mform->addElement('hidden', 'dir');
00128         $mform->setType('dir', PARAM_ALPHA);
00129 
00130         $this->add_action_buttons();
00131 
00132         $this->set_data(array('action'=>'addmember', 'user'=>$user->id));
00133     }
00134 }
 All Data Structures Namespaces Files Functions Variables Enumerations