initial commit
This commit is contained in:
commit
63e569c6ca
9 changed files with 369 additions and 0 deletions
58
classes/get_global_roles.php
Normal file
58
classes/get_global_roles.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->dirroot . '/lib/externallib.php';
|
||||
|
||||
class local_lara_get_global_roles extends external_api
|
||||
{
|
||||
/**
|
||||
* Parameter description for get_global_roles().
|
||||
*
|
||||
* @return external_function_parameters.
|
||||
*/
|
||||
public static function get_global_roles_parameters()
|
||||
{
|
||||
return new external_function_parameters([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return roleinformation.
|
||||
*
|
||||
* This function returns a userid and the roleids of that user.
|
||||
*
|
||||
* @return array Array of arrays with role informations.
|
||||
*/
|
||||
public static function get_global_roles()
|
||||
{
|
||||
global $DB;
|
||||
// require_once "$CFG->dirroot/group/lib.php";
|
||||
|
||||
$roles = $DB->get_records('role_assignments', ['contextid' => '1']);
|
||||
|
||||
print $roles;
|
||||
|
||||
$roleIds = [];
|
||||
foreach ($roles as $role) {
|
||||
$cl = new stdClass();
|
||||
$cl->roleid = ($role->roleid);
|
||||
$cl->userid = ($role->userid);
|
||||
array_push($roleIds, $cl);
|
||||
}
|
||||
|
||||
return $roleIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter description for get_global_roles().
|
||||
*
|
||||
* @return external_description
|
||||
*/
|
||||
public static function get_global_roles_returns()
|
||||
{
|
||||
return new external_multiple_structure(
|
||||
new external_single_structure([
|
||||
'userid' => new external_value(PARAM_INT, 'user id'),
|
||||
'roleid' => new external_value(PARAM_INT, 'role id'),
|
||||
]));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue