mirror of
https://github.com/moodle/moodle.git
synced 2025-02-22 02:49:53 +01:00
MDL-83959 webservice: relax retrieval of token external service info.
The report performs a `LEFT JOIN` on the external service table/entity so we need to account for that in column callbacks and actions. Also the shortname field is nullable, so account for that too.
This commit is contained in:
parent
0888a6d324
commit
074eca0726
@ -91,10 +91,9 @@ class service extends base {
|
||||
))
|
||||
->add_joins($this->get_joins())
|
||||
->set_type(column::TYPE_TEXT)
|
||||
->add_field("{$tokenalias}.name")
|
||||
->add_field("{$tokenalias}.shortname")
|
||||
->add_fields("{$tokenalias}.name, {$tokenalias}.shortname")
|
||||
->set_is_sortable(true)
|
||||
->add_callback(static function(string $value, \stdClass $row): string {
|
||||
->add_callback(static function(?string $value, \stdClass $row): string {
|
||||
$output = $value;
|
||||
$output .= \html_writer::tag('div', format_text($row->shortname), [
|
||||
'class' => 'small text-muted',
|
||||
|
@ -141,9 +141,10 @@ class tokens extends system_report {
|
||||
"{$entityservicealias}.id",
|
||||
"{$entityservicealias}.shortname",
|
||||
]))
|
||||
->add_callback(static function(string $value, \stdClass $row): string {
|
||||
->add_callback(static function($value, \stdClass $row): string {
|
||||
global $OUTPUT;
|
||||
$missingcapabilities = self::get_missing_capabilities((int)$row->userid, (int)$row->id, $row->shortname);
|
||||
|
||||
$missingcapabilities = self::get_missing_capabilities((int) $row->userid, (int) $row->id, (string) $row->shortname);
|
||||
if (empty($missingcapabilities)) {
|
||||
return '';
|
||||
}
|
||||
|
@ -454,11 +454,14 @@ class webservice {
|
||||
*/
|
||||
public function get_token_by_id_with_details($tokenid) {
|
||||
global $DB;
|
||||
|
||||
$sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.creatorid
|
||||
FROM {external_tokens} t, {user} u, {external_services} s
|
||||
WHERE t.id=? AND t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id";
|
||||
$token = $DB->get_record_sql($sql, array($tokenid, EXTERNAL_TOKEN_PERMANENT), MUST_EXIST);
|
||||
return $token;
|
||||
FROM {external_tokens} t
|
||||
LEFT JOIN {user} u ON u.id = t.userid
|
||||
LEFT JOIN {external_services} s ON s.id = t.externalserviceid
|
||||
WHERE t.id = ? AND t.tokentype = ?";
|
||||
|
||||
return $DB->get_record_sql($sql, [$tokenid, EXTERNAL_TOKEN_PERMANENT], MUST_EXIST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user