MDL-28574 webservices: Add new capability for managing all tokens
This commit is contained in:
@@ -103,6 +103,10 @@ switch ($action) {
|
||||
case 'delete':
|
||||
$token = $webservicemanager->get_token_by_id_with_details($tokenid);
|
||||
|
||||
if ($token->creatorid != $USER->id) {
|
||||
require_capability("moodle/webservice:managealltokens", context_system::instance());
|
||||
}
|
||||
|
||||
//Delete the token
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
$webservicemanager->delete_user_ws_token($token->id);
|
||||
|
||||
+1
-1
@@ -455,9 +455,9 @@ $string['useshowadvancedtochange'] = 'Use \'Show advanced\' to change';
|
||||
$string['viewingdefinitionofrolex'] = 'Viewing the definition of role \'{$a}\'';
|
||||
$string['viewrole'] = 'View role details';
|
||||
$string['webservice:createtoken'] = 'Create a web service token';
|
||||
$string['webservice:managealltokens'] = 'Manage all users\' web services';
|
||||
$string['webservice:createmobiletoken'] = 'Create a web service token for mobile access';
|
||||
$string['whydoesuserhavecap'] = 'Why does {$a->fullname} have capability {$a->capability} in context {$a->context}?';
|
||||
$string['whydoesusernothavecap'] = 'Why does {$a->fullname} not have capability {$a->capability} in context {$a->context}?';
|
||||
$string['xroleassignments'] = '{$a}\'s role assignments';
|
||||
$string['xuserswiththerole'] = 'Users with the role "{$a->role}"';
|
||||
|
||||
|
||||
@@ -1845,6 +1845,13 @@ $capabilities = array(
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'moodle/webservice:managealltokens' => array(
|
||||
|
||||
'riskbitmask' => RISK_CONFIG | RISK_DATALOSS | RISK_PERSONAL,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array()
|
||||
),
|
||||
'moodle/webservice:createmobiletoken' => array(
|
||||
|
||||
'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2017072700.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2017072700.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
+4
-9
@@ -418,15 +418,10 @@ 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
|
||||
FROM
|
||||
{external_tokens} t, {user} u, {external_services} s
|
||||
WHERE
|
||||
t.id=? AND t.tokentype = "
|
||||
. EXTERNAL_TOKEN_PERMANENT
|
||||
. " AND s.id = t.externalserviceid AND t.userid = u.id";
|
||||
$token = $DB->get_record_sql($sql, array($tokenid), MUST_EXIST);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user