Merge "Added LogEntryBase::extractParams/makeParamBlob"
[lhc/web/wiklou.git] / includes / api / ApiQueryUsers.php
index 84326a2..52636cc 100644 (file)
@@ -58,6 +58,7 @@ class ApiQueryUsers extends ApiQueryBase {
         * 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)
+        * @deprecated since 1.24
         * @return array Array of tokenname => function
         */
        protected function getTokenFunctions() {
@@ -66,20 +67,22 @@ class ApiQueryUsers extends ApiQueryBase {
                        return $this->tokenFunctions;
                }
 
-               // If we're in JSON callback mode, no tokens can be obtained
-               if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+               // If we're in a mode that breaks the same-origin policy, no tokens can
+               // be obtained
+               if ( $this->lacksSameOriginSecurity() ) {
                        return array();
                }
 
                $this->tokenFunctions = array(
                        'userrights' => array( 'ApiQueryUsers', 'getUserrightsToken' ),
                );
-               wfRunHooks( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) );
+               Hooks::run( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) );
 
                return $this->tokenFunctions;
        }
 
        /**
+        * @deprecated since 1.24
         * @param User $user
         * @return string
         */
@@ -193,6 +196,7 @@ class ApiQueryUsers extends ApiQueryBase {
                                        $data[$name]['blockid'] = $row->ipb_id;
                                        $data[$name]['blockedby'] = $row->ipb_by_text;
                                        $data[$name]['blockedbyid'] = $row->ipb_by;
+                                       $data[$name]['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
                                        $data[$name]['blockreason'] = $row->ipb_reason;
                                        $data[$name]['blockexpiry'] = $row->ipb_expiry;
                                }
@@ -274,19 +278,6 @@ class ApiQueryUsers extends ApiQueryBase {
                $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
        }
 
-       /**
-        * Gets all the groups that a user is automatically a member of (implicit groups)
-        *
-        * @deprecated since 1.20; call User::getAutomaticGroups() directly.
-        * @param User $user
-        * @return array
-        */
-       public static function getAutoGroups( $user ) {
-               wfDeprecated( __METHOD__, '1.20' );
-
-               return $user->getAutomaticGroups();
-       }
-
        public function getCacheMode( $params ) {
                if ( isset( $params['token'] ) ) {
                        return 'private';
@@ -317,39 +308,20 @@ class ApiQueryUsers extends ApiQueryBase {
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'token' => array(
+                               ApiBase::PARAM_DEPRECATED => true,
                                ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
                                ApiBase::PARAM_ISMULTI => true
                        ),
                );
        }
 
-       public function getParamDescription() {
+       protected function getExamplesMessages() {
                return array(
-                       'prop' => array(
-                               'What pieces of information to include',
-                               '  blockinfo      - Tags if the user is blocked, by whom, and for what reason',
-                               '  groups         - Lists all the groups the user(s) belongs to',
-                               '  implicitgroups - Lists all the groups a user is automatically a member of',
-                               '  rights         - Lists all the rights the user(s) has',
-                               '  editcount      - Adds the user\'s edit count',
-                               '  registration   - Adds the user\'s registration timestamp',
-                               '  emailable      - Tags if the user can and wants to receive ' .
-                                       'email through [[Special:Emailuser]]',
-                               '  gender         - Tags the gender of the user. Returns "male", "female", or "unknown"',
-                       ),
-                       'users' => 'A list of users to obtain the same information for',
-                       'token' => 'Which tokens to obtain for each user',
+                       'action=query&list=users&ususers=Example&usprop=groups|editcount|gender'
+                               => 'apihelp-query+users-example-simple',
                );
        }
 
-       public function getDescription() {
-               return 'Get information about a list of users.';
-       }
-
-       public function getExamples() {
-               return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount|gender';
-       }
-
        public function getHelpUrls() {
                return 'https://www.mediawiki.org/wiki/API:Users';
        }