API: Overhaul token handling
[lhc/web/wiklou.git] / includes / api / ApiQueryUserInfo.php
index e46baa6..8b7831c 100644 (file)
@@ -52,7 +52,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
        }
 
        protected function getCurrentUserInfo() {
-               global $wgHiddenPrefs, $wgRCMaxAge;
                $user = $this->getUser();
                $result = $this->getResult();
                $vals = array();
@@ -105,6 +104,12 @@ class ApiQueryUserInfo extends ApiQueryBase {
                        $vals['options'] = $user->getOptions();
                }
 
+               if ( isset( $this->prop['preferencestoken'] ) ) {
+                       $p = $this->getModulePrefix();
+                       $this->setWarning(
+                               "{$p}prop=preferencestoken has been deprecated. Please use action=query&meta=tokens instead."
+                       );
+               }
                if ( isset( $this->prop['preferencestoken'] ) &&
                        is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) &&
                        $user->isAllowed( 'editmyoptions' )
@@ -122,7 +127,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
                        $vals['ratelimits'] = $this->getRateLimits();
                }
 
-               if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $wgHiddenPrefs ) ) {
+               if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) ) ) {
                        $vals['realname'] = $user->getRealName();
                }
 
@@ -181,7 +186,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
        }
 
        protected function getRateLimits() {
-               global $wgRateLimits;
                $user = $this->getUser();
                if ( !$user->isPingLimitable() ) {
                        return array(); // No limits
@@ -205,7 +209,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
 
                // Now get the actual limits
                $retval = array();
-               foreach ( $wgRateLimits as $action => $limits ) {
+               foreach ( $this->getConfig()->get( 'RateLimits' ) as $action => $limits ) {
                        foreach ( $categories as $cat ) {
                                if ( isset( $limits[$cat] ) && !is_null( $limits[$cat] ) ) {
                                        $retval[$action][$cat]['hits'] = intval( $limits[$cat][0] );
@@ -254,7 +258,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
                                '  rights           - Lists all the rights the current user has',
                                '  changeablegroups - Lists the groups the current user can add to and remove from',
                                '  options          - Lists all preferences the current user has set',
-                               '  preferencestoken - Get a token to change current user\'s preferences',
+                               '  preferencestoken - DEPRECATED! Get a token to change current user\'s preferences',
                                '  editcount        - Adds the current user\'s edit count',
                                '  ratelimits       - Lists all rate limits applying to the current user',
                                '  realname         - Adds the user\'s real name',
@@ -269,63 +273,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
                );
        }
 
-       public function getResultProperties() {
-               return array(
-                       ApiBase::PROP_LIST => false,
-                       '' => array(
-                               'id' => 'integer',
-                               'name' => 'string',
-                               'anon' => 'boolean'
-                       ),
-                       'blockinfo' => array(
-                               'blockid' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedby' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedbyid' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedreason' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       ),
-                       'hasmsg' => array(
-                               'messages' => 'boolean'
-                       ),
-                       'preferencestoken' => array(
-                               'preferencestoken' => 'string'
-                       ),
-                       'editcount' => array(
-                               'editcount' => 'integer'
-                       ),
-                       'realname' => array(
-                               'realname' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       ),
-                       'email' => array(
-                               'email' => 'string',
-                               'emailauthenticated' => array(
-                                       ApiBase::PROP_TYPE => 'timestamp',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       ),
-                       'registrationdate' => array(
-                               'registrationdate' => array(
-                                       ApiBase::PROP_TYPE => 'timestamp',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       )
-               );
-       }
-
        public function getDescription() {
                return 'Get information about the current user.';
        }