initial commit

This commit is contained in:
MIN (Sebastian von Minckwitz) 2024-12-12 09:41:03 +01:00
commit 63e569c6ca
9 changed files with 369 additions and 0 deletions

View 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'),
]));
}
}