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