Skip to content

Commit

Permalink
Revert external API changes while we still support older versions
Browse files Browse the repository at this point in the history
This reverts commit 0a47d77.
  • Loading branch information
timhunt committed Dec 13, 2023
1 parent af4c030 commit e98d62a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
40 changes: 19 additions & 21 deletions classes/external/get_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

namespace report_customsql\external;

use core_external\external_api;
use core_external\external_description;
use core_external\external_function_parameters;
use core_external\external_multiple_structure;
use core_external\external_single_structure;
use core_external\external_value;
defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->libdir . '/externallib.php');

/**
* Web service used by form autocomplete to get a list of users with a given capability.
Expand All @@ -30,16 +28,16 @@
* @copyright 2020 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class get_users extends external_api {
class get_users extends \external_api {
/**
* Parameter declaration.
*
* @return external_function_parameters Parameters
* @return \external_function_parameters Parameters
*/
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters([
'query' => new external_value(PARAM_RAW, 'Contents of the search box.'),
'capability' => new external_value(PARAM_CAPABILITY, 'Return only users with this capability in the system context.'),
public static function execute_parameters(): \external_function_parameters {
return new \external_function_parameters([
'query' => new \external_value(PARAM_RAW, 'Contents of the search box.'),
'capability' => new \external_value(PARAM_CAPABILITY, 'Return only users with this capability in the system context.'),
]);
}

Expand Down Expand Up @@ -138,16 +136,16 @@ public static function prepare_result_object(\stdClass $user, array $extrafields
/**
* Returns type for declaration.
*
* @return external_description Result type
* @return \external_description Result type
*/
public static function execute_returns(): external_description {
return new external_multiple_structure(
new external_single_structure([
'id' => new external_value(PARAM_INT, 'User id.'),
'fullname' => new external_value(PARAM_RAW, 'User full name.'),
'identity' => new external_value(PARAM_RAW, 'Additional user identifying info.'),
'hasidentity' => new external_value(PARAM_BOOL, 'Whether identity is non-blank.'),
'profileimageurlsmall' => new external_value(PARAM_RAW, 'URL of the user profile image.'),
public static function execute_returns(): \external_description {
return new \external_multiple_structure(
new \external_single_structure([
'id' => new \external_value(PARAM_INT, 'User id.'),
'fullname' => new \external_value(PARAM_RAW, 'User full name.'),
'identity' => new \external_value(PARAM_RAW, 'Additional user identifying info.'),
'hasidentity' => new \external_value(PARAM_BOOL, 'Whether identity is non-blank.'),
'profileimageurlsmall' => new \external_value(PARAM_RAW, 'URL of the user profile image.'),
]));
}
}
1 change: 1 addition & 0 deletions tests/external/external_get_users_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* @category external
* @copyright 2020 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @runTestsInSeparateProcesses
*/
class external_get_users_test extends \externallib_advanced_testcase {

Expand Down

0 comments on commit e98d62a

Please sign in to comment.