MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Various enrol UI forms
|
|
|
|
*
|
|
|
|
* @package core
|
|
|
|
* @subpackage enrol
|
|
|
|
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2010-07-31 20:30:29 +00:00
|
|
|
defined('MOODLE_INTERNAL') || die();
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
require_once("$CFG->libdir/formslib.php");
|
|
|
|
|
|
|
|
class enrol_users_assign_form extends moodleform {
|
|
|
|
function definition() {
|
2010-07-07 02:46:34 +00:00
|
|
|
global $CFG, $DB;
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
$mform = $this->_form;
|
|
|
|
|
|
|
|
$user = $this->_customdata['user'];
|
|
|
|
$course = $this->_customdata['course'];
|
2012-07-23 16:08:41 +08:00
|
|
|
$context = context_course::instance($course->id);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$assignable = $this->_customdata['assignable'];
|
|
|
|
$assignable = array_reverse($assignable, true); // students first
|
|
|
|
|
|
|
|
$ras = get_user_roles($context, $user->id, true);
|
|
|
|
foreach ($ras as $ra) {
|
|
|
|
unset($assignable[$ra->roleid]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$mform->addElement('header','general', fullname($user));
|
|
|
|
|
|
|
|
$mform->addElement('select', 'roleid', get_string('addrole', 'role'), $assignable);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'id');
|
|
|
|
$mform->setType('id', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'user');
|
|
|
|
$mform->setType('user', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'action');
|
2012-05-11 13:42:27 +08:00
|
|
|
$mform->setType('action', PARAM_ALPHANUMEXT);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
$mform->addElement('hidden', 'ifilter');
|
|
|
|
$mform->setType('ifilter', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'page');
|
|
|
|
$mform->setType('page', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'perpage');
|
|
|
|
$mform->setType('perpage', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'sort');
|
|
|
|
$mform->setType('sort', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'dir');
|
|
|
|
$mform->setType('dir', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$this->add_action_buttons();
|
|
|
|
|
|
|
|
$this->set_data(array('action'=>'assign', 'user'=>$user->id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class enrol_users_addmember_form extends moodleform {
|
|
|
|
function definition() {
|
2010-07-07 02:46:34 +00:00
|
|
|
global $CFG, $DB;
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
$mform = $this->_form;
|
|
|
|
|
|
|
|
$user = $this->_customdata['user'];
|
|
|
|
$course = $this->_customdata['course'];
|
2012-07-23 16:08:41 +08:00
|
|
|
$context = context_course::instance($course->id, IGNORE_MISSING);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$allgroups = $this->_customdata['allgroups'];
|
|
|
|
$usergroups = groups_get_all_groups($course->id, $user->id, 0, 'g.id');
|
|
|
|
|
|
|
|
$options = array();
|
|
|
|
foreach ($allgroups as $group) {
|
|
|
|
if (isset($usergroups[$group->id])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$options[$group->id] = $group->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
$mform->addElement('header','general', fullname($user));
|
|
|
|
|
|
|
|
$mform->addElement('select', 'groupid', get_string('addgroup', 'group'), $options);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'id');
|
|
|
|
$mform->setType('id', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'user');
|
|
|
|
$mform->setType('user', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'action');
|
2012-05-11 13:42:27 +08:00
|
|
|
$mform->setType('action', PARAM_ALPHANUMEXT);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
$mform->addElement('hidden', 'ifilter');
|
|
|
|
$mform->setType('ifilter', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'page');
|
|
|
|
$mform->setType('page', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'perpage');
|
|
|
|
$mform->setType('perpage', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'sort');
|
|
|
|
$mform->setType('sort', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'dir');
|
|
|
|
$mform->setType('dir', PARAM_ALPHA);
|
|
|
|
|
|
|
|
$this->add_action_buttons();
|
|
|
|
|
|
|
|
$this->set_data(array('action'=>'addmember', 'user'=>$user->id));
|
|
|
|
}
|
2013-03-27 14:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form that lets users filter the enrolled user list.
|
|
|
|
*/
|
|
|
|
class enrol_users_filter_form extends moodleform {
|
|
|
|
function definition() {
|
|
|
|
global $CFG, $DB;
|
|
|
|
|
|
|
|
$manager = $this->_customdata['manager'];
|
|
|
|
|
|
|
|
$mform = $this->_form;
|
|
|
|
|
|
|
|
// Text search box.
|
|
|
|
$mform->addElement('text', 'search', get_string('search'));
|
2013-04-02 11:57:12 +01:00
|
|
|
$mform->setType('search', PARAM_RAW);
|
2013-03-27 14:56:20 +00:00
|
|
|
|
|
|
|
// Filter by enrolment plugin type.
|
|
|
|
$mform->addElement('select', 'ifilter', get_string('enrolmentinstances', 'enrol'),
|
|
|
|
array(0 => get_string('all')) + (array)$manager->get_enrolment_instance_names());
|
|
|
|
|
|
|
|
// Role select dropdown includes all roles, but using course-specific
|
|
|
|
// names if applied. The reason for not restricting to roles that can
|
|
|
|
// be assigned at course level is that upper-level roles display in the
|
|
|
|
// enrolments table so it makes sense to let users filter by them.
|
|
|
|
$allroles = get_all_roles($manager->get_context());
|
|
|
|
$rolenames = array();
|
|
|
|
foreach ($allroles as $id => $role) {
|
|
|
|
$rolenames[$id] = $role->name;
|
|
|
|
}
|
|
|
|
$mform->addElement('select', 'role', get_string('role'),
|
|
|
|
array(0 => get_string('all')) + $rolenames);
|
|
|
|
|
|
|
|
// Submit button does not use add_action_buttons because that adds
|
|
|
|
// another fieldset which causes the CSS style to break in an unfixable
|
|
|
|
// way due to fieldset quirks.
|
|
|
|
$group = array();
|
|
|
|
$group[] = $mform->createElement('submit', 'submitbutton', get_string('filter'));
|
|
|
|
$group[] = $mform->createElement('submit', 'resetbutton', get_string('reset'));
|
|
|
|
$mform->addGroup($group, 'buttons', '', ' ', false);
|
|
|
|
|
|
|
|
// Add hidden fields required by page.
|
|
|
|
$mform->addElement('hidden', 'id', $this->_customdata['id']);
|
2013-04-02 11:57:12 +01:00
|
|
|
$mform->setType('id', PARAM_INT);
|
2013-03-27 14:56:20 +00:00
|
|
|
}
|
|
|
|
}
|