diff --git a/classes/external/get_users.php b/classes/external/get_users.php index 6d01dd5..f494a5a 100644 --- a/classes/external/get_users.php +++ b/classes/external/get_users.php @@ -59,16 +59,21 @@ public static function execute(string $query, string $capability): array { self::validate_context($context); require_capability('report/customsql:definequeries', $context); - $extrafields = get_extra_user_fields($context); + if (class_exists('\core_user\fields')) { + $extrafields = \core_user\fields::for_identity($context, false)->get_required_fields(); + $fields = \core_user\fields::for_identity($context, false)->with_userpic()->get_sql('u')->selects; + } else { + $extrafields = get_extra_user_fields($context); + $fields = array_merge(['u.id'], preg_split('~\s*,\s*~', + implode(', ', \user_picture::fields('u')), $extrafields)); + } - $fields = array_merge(['u.id'], preg_split('~\s*,\s*~', - \user_picture::fields('u')), $extrafields); $withcapabilityjoin = get_with_capability_join($context, $capability, 'u.id'); [$wherecondition, $whereparams] = users_search_sql($query, 'u', true, $extrafields); [$sort, $sortparams] = users_order_by_sql('u', $query, $context); $users = $DB->get_records_sql(" - SELECT " . implode(', ', $fields) . " + SELECT $fields FROM {user} u JOIN ( diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 18487cb..6718cf3 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -229,9 +229,9 @@ public static function delete_data_for_users(request\approved_userlist $userlist */ protected static function you_or_somebody_else($userid, $user) { if ($userid == $user->id) { - return get_string('privacy_you', 'mod_bookingsystem'); + return get_string('privacy_you', 'report_customsql'); } else { - return get_string('privacy_somebodyelse', 'mod_bookingsystem'); + return get_string('privacy_somebodyelse', 'report_customsql'); } } } diff --git a/edit_form.php b/edit_form.php index 56c303a..dc514ff 100644 --- a/edit_form.php +++ b/edit_form.php @@ -120,10 +120,18 @@ public function definition() { if (!$user) { return false; } + + if (class_exists('\core_user\fields')) { + $extrafields = \core_user\fields::for_identity(\context_system::instance(), + false)->get_required_fields(); + } else { + $extrafields = get_extra_user_fields(context_system::instance()); + } + return $OUTPUT->render_from_template( 'report_customsql/form-user-selector-suggestion', \report_customsql\external\get_users::prepare_result_object( - $user, get_extra_user_fields(context_system::instance())) + $user, $extrafields) ); } ]; diff --git a/templates/form-user-selector-suggestion.mustache b/templates/form-user-selector-suggestion.mustache index e6feba7..72711cc 100644 --- a/templates/form-user-selector-suggestion.mustache +++ b/templates/form-user-selector-suggestion.mustache @@ -32,7 +32,8 @@ * identity concatenated list of identity fields. Example context (json): - { "id": "1", + { + "id": "1", "fullname": "Admin User", "hasidentity": true, "identity": "admin@example.com, 0144114141", diff --git a/templates/form_report_information.mustache b/templates/form_report_information.mustache index 5935bcc..64014dc 100644 --- a/templates/form_report_information.mustache +++ b/templates/form_report_information.mustache @@ -31,9 +31,10 @@ * usermodified Last modified by. Example context (json): - { "timecreated": "Wednesday, 5 May 2021", + { + "timecreated": "Wednesday, 5 May 2021", "timemodified": "Wednesday, 5 May 2021", - "usermodified": "Admin User", + "usermodified": "Admin User" } }}