Skip to content

Commit

Permalink
MDL-67748 admin: Respect the viewfullnames cap at manage tokens table
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Mar 15, 2021
1 parent b389393 commit a7f6934
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webservice/classes/token_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class token_table extends \table_sql {
*/
protected $showalltokens;

/** @var bool $hasviewfullnames Does the user have the viewfullnames capability. */
protected $hasviewfullnames;

/**
* Sets up the table.
* @param int $id The id of the table
Expand All @@ -56,6 +59,7 @@ public function __construct($id) {

// Can we see tokens created by all users?
$this->showalltokens = has_capability('moodle/webservice:managealltokens', $context);
$this->hasviewfullnames = has_capability('moodle/site:viewfullnames', $context);

// Define the headers and columns.
$headers = [];
Expand Down Expand Up @@ -131,7 +135,7 @@ public function col_fullname($data) {
global $OUTPUT;

$userprofilurl = new \moodle_url('/user/profile.php', ['id' => $data->userid]);
$content = \html_writer::link($userprofilurl, fullname($data));
$content = \html_writer::link($userprofilurl, fullname($data, $this->hasviewfullnames));

// Make up list of capabilities that the user is missing for the given webservice.
$webservicemanager = new \webservice();
Expand Down Expand Up @@ -183,7 +187,7 @@ public function col_creatorlastname($data) {
}

$creatorprofileurl = new \moodle_url('/user/profile.php', ['id' => $data->creatorid]);
return \html_writer::link($creatorprofileurl, fullname((object)$user));
return \html_writer::link($creatorprofileurl, fullname((object)$user, $this->hasviewfullnames));
}

/**
Expand Down

0 comments on commit a7f6934

Please sign in to comment.