mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
Merge branch 'w10_MDL-31361_m23_dbunenrol' of git://github.com/skodak/moodle
This commit is contained in:
commit
050bce5f0c
@ -26,3 +26,16 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
/* This is used only when sync suspends users instead of full unenrolment */
|
||||
'enrol/database:unenrol' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['database:unenrol'] = 'Unenrol suspended users';
|
||||
$string['dbencoding'] = 'Database encoding';
|
||||
$string['dbhost'] = 'Database host';
|
||||
$string['dbhost_desc'] = 'Type database server IP address or host name';
|
||||
|
@ -51,6 +51,43 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this plugin allow manual unenrolment of a specific user?
|
||||
* Yes, but only if user suspended...
|
||||
*
|
||||
* @param stdClass $instance course enrol instance
|
||||
* @param stdClass $ue record from user_enrolments table
|
||||
*
|
||||
* @return bool - true means user with 'enrol/xxx:unenrol' may unenrol this user, false means nobody may touch this user enrolment
|
||||
*/
|
||||
public function allow_unenrol_user(stdClass $instance, stdClass $ue) {
|
||||
if ($ue->status == ENROL_USER_SUSPENDED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of the user enrolment actions
|
||||
*
|
||||
* @param course_enrolment_manager $manager
|
||||
* @param stdClass $ue A user enrolment object
|
||||
* @return array An array of user_enrolment_actions
|
||||
*/
|
||||
public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) {
|
||||
$actions = array();
|
||||
$context = $manager->get_context();
|
||||
$instance = $ue->enrolmentinstance;
|
||||
$params = $manager->get_moodlepage()->url->params();
|
||||
$params['ue'] = $ue->id;
|
||||
if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/meta:unenrol', $context)) {
|
||||
$url = new moodle_url('/enrol/unenroluser.php', $params);
|
||||
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces synchronisation of user enrolments with external database,
|
||||
* does not create new courses.
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011112900; // Requires this Moodle version
|
||||
$plugin->version = 2012022700; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2012022300; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_database'; // Full name of the plugin (used for diagnostics)
|
||||
//TODO: should we add cron sync?
|
Loading…
x
Reference in New Issue
Block a user