From: Roan Kattouw Date: Thu, 10 Sep 2009 13:44:49 +0000 (+0000) Subject: API: Make it possible to fetch userrights tokens for interwiki users; make Userrights... X-Git-Tag: 1.31.0-rc.0~39805 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=9e78c71b1e969623f94c34b4a95e830a6a6f5a81;p=lhc%2Fweb%2Fwiklou.git API: Make it possible to fetch userrights tokens for interwiki users; make UserrightsPage::fetchUser() static --- diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index d3d4b609d2..9ae63c41e9 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -170,9 +170,26 @@ if (!defined('MEDIAWIKI')) { } // Second pass: add result data to $retval foreach($goodNames as $u) { - if(!isset($data[$u])) - $data[$u] = array('name' => $u, 'missing' => ''); - else { + if(!isset($data[$u])) { + $data[$u] = array('name' => $u); + $iwUser = UserrightsPage::fetchUser($u); + if($iwUser instanceof UserRightsProxy) { + $data[$u]['interwiki'] = ''; + if(!is_null($params['token'])) + { + $tokenFunctions = $this->getTokenFunctions(); + foreach($params['token'] as $t) + { + $val = call_user_func($tokenFunctions[$t], $iwUser); + if($val === false) + $this->setWarning("Action '$t' is not allowed for the current user"); + else + $data[$u][$t . 'token'] = $val; + } + } + } else + $data[$u]['missing'] = ''; + } else { if(isset($this->prop['groups']) && isset($data[$u]['groups'])) $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g'); } diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 47eb60f941..b2a2825f40 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -45,8 +45,7 @@ class ApiUserrights extends ApiBase { if(is_null($params['token'])) $this->dieUsageMsg(array('missingparam', 'token')); - $form = new UserrightsPage; - $user = $form->fetchUser($params['user']); + $user = UserrightsPage::fetchUser($params['user']); if($user instanceof WikiErrorMsg) $this->dieUsageMsg(array_merge( (array)$user->getMessageKey(), diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 10c5dd34f8..ac121918a2 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -272,7 +272,7 @@ class UserrightsPage extends SpecialPage { * Side effects: error output for invalid access * @return mixed User, UserRightsProxy, or WikiErrorMsg */ - function fetchUser( $username ) { + public static function fetchUser( $username ) { global $wgUser, $wgUserrightsInterwikiDelimiter; $parts = explode( $wgUserrightsInterwikiDelimiter, $username );