+ private $tokenFunctions, $prop;
+
+ public function __construct( $query, $moduleName ) {
+ parent::__construct( $query, $moduleName, 'us' );
+ }
+
+ /**
+ * Get an array mapping token names to their handler functions.
+ * The prototype for a token function is func($user)
+ * it should return a token or false (permission denied)
+ * @return Array tokenname => function
+ */
+ protected function getTokenFunctions() {
+ // Don't call the hooks twice
+ if ( isset( $this->tokenFunctions ) ) {
+ return $this->tokenFunctions;
+ }
+
+ // If we're in JSON callback mode, no tokens can be obtained
+ if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ return array();
+ }
+
+ $this->tokenFunctions = array(
+ 'userrights' => array( 'ApiQueryUsers', 'getUserrightsToken' ),
+ );
+ wfRunHooks( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) );
+ return $this->tokenFunctions;
+ }
+
+ public static function getUserrightsToken( $user ) {
+ global $wgUser;
+ // Since the permissions check for userrights is non-trivial,
+ // don't bother with it here
+ return $wgUser->editToken( $user->getName() );