-
Improvement
-
Resolution: Fixed
-
Blocker
-
2.0.1
-
MOODLE_20_STABLE
-
MOODLE_20_STABLE
-
git@github.com:mouneyrac/moodle.git
-
MDL-26250-final6 -
Something like that (I'm just writing this on the fly, need to finish):
moodle_enrol_users:
------------------
public static function enrol_users_parameters() {
|
return new external_function_parameters(
|
array(
|
'enrolments' => new external_multiple_structure(
|
new external_single_structure(
|
array(
|
'roleid' => new external_value(PARAM_INT, 'Role to assign to the user'),
|
'userid' => new external_value(PARAM_INT, 'The user that is going to be enrolled'),
|
'contextid' => new external_value(PARAM_INT, 'The context to enrol the user role in'),
|
)
|
)
|
)
|
)
|
);
|
}
|
|
/**
|
* Manual enrolment of users
|
*
|
* @param array $enrolments An array of manual user enrolment
|
* @return null
|
*/
|
public static function enrol_users($enrolments) {
|
global $DB, $USER;
|
|
$params = self::validate_parameters(self::enrol_users_parameters(), array('enrolments'=>$enrolments));
|
|
$transaction = $DB->start_delegated_transaction();
|
|
foreach ($params['enrolments'] as $enrolment) {
|
// Ensure the current user is allowed to run this function in the enrolment context
|
$context = get_context_instance_by_id($enrolment['contextid']);
|
self::validate_context($context);
|
require_capability('moodle/role:assign', $context); //TODO: there is probably a capability related to enrolment, look for it and check on it it.
|
|
$instance = $DB->get_record('enrol', array('courseid' => $context->instanceid, 'enrol' => 'manual'));
|
$enrol = enrol_get_plugin('manual');
|
$enrol->enrol_user($instance, $enrolment['userid'], $enrolment['roleid']);
|
|
//TODO: maybe return a array of success/fail
|
}
|
|
$transaction->allow_commit();
|
}
|
|
/**
|
* Returns description of method result value
|
* @return external_description
|
*/
|
public static function enrol_users_returns() {
|
return null;
|
}
|
|
- has a non-specific relationship to
-
MDL-27388 bugs on testwebservice page for web service function that enrols users to a certain course
- Closed
-
MDL-27320 Create a cache system for the external function manual_enrol_users
- Closed
- has been marked as being related by
-
MDL-27229 start_delegated_transaction break xmlrpc/soap because of print_debug() function
- Closed
-
MDL-27321 user_can_assign($context, $targetroleid) seems incomplete
- Closed
- is blocked by
-
MDL-26822 enrol_user() does not use $status param
- Closed