Checking permissions for $wgUser while doing an edit with another user is not a good...
[lhc/web/wiklou.git] / includes / api / ApiQueryFilearchive.php
index 08a75e3..2964dc8 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-
 /**
- * Created on May 10, 2010
- *
  * API for MediaWiki 1.12+
  *
+ * Created on May 10, 2010
+ *
  * Copyright © 2010 Sam Reed
  * Copyright © 2008 Vasiliev Victor vasilvv@gmail.com,
  * based on ApiQueryAllpages.php
  *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -47,13 +48,12 @@ class ApiQueryFilearchive extends ApiQueryBase {
                if ( !$wgUser->isAllowed( 'deletedhistory' ) ) {
                        $this->dieUsage( 'You don\'t have permission to view deleted file information', 'permissiondenied' );
                }
-       
+
                $db = $this->getDB();
 
                $params = $this->extractRequestParams();
-               
+
                $prop = array_flip( $params['prop'] );
-               $fld_id = isset( $prop['id'] );
                $fld_sha1 = isset( $prop['sha1'] );
                $fld_timestamp = isset( $prop['timestamp'] );
                $fld_user = isset( $prop['user'] );
@@ -63,9 +63,9 @@ class ApiQueryFilearchive extends ApiQueryBase {
                $fld_mime = isset( $prop['mime'] );
                $fld_metadata = isset( $prop['metadata'] );
                $fld_bitdepth = isset( $prop['bitdepth'] );
-               
+
                $this->addTables( 'filearchive' );
-               
+
                $this->addFields( 'fa_name' );
                $this->addFieldsIf( 'fa_storage_key', $fld_sha1 );
                $this->addFieldsIf( 'fa_timestamp', $fld_timestamp );
@@ -117,17 +117,16 @@ class ApiQueryFilearchive extends ApiQueryBase {
 
                $res = $this->select( __METHOD__ );
 
-               $titles = array();
                $count = 0;
                $result = $this->getResult();
-               while ( $row = $db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                // TODO: Security issue - if the user has no right to view next title, it will still be shown
                                $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
                                break;
                        }
-                       
+
                        $file = array();
                        $file['name'] = $row->fa_name;
 
@@ -147,19 +146,19 @@ class ApiQueryFilearchive extends ApiQueryBase {
                                $file['height'] = $row->fa_height;
                                $file['width'] = $row->fa_width;
                        }
-                       if ( $fld_description ){
+                       if ( $fld_description ) {
                                $file['description'] = $row->fa_description;
                        }
-                       if ( $fld_metadata ){
+                       if ( $fld_metadata ) {
                                $file['metadata'] = $row->fa_metadata ? ApiQueryImageInfo::processMetaData( unserialize( $row->fa_metadata ), $result ) : null;
                        }
-                       if ( $fld_bitdepth ){
+                       if ( $fld_bitdepth ) {
                                $file['bitdepth'] = $row->fa_bits;
                        }
                        if ( $fld_mime ) {
                                $file['mime'] = "$row->fa_major_mime/$row->fa_minor_mime";
                        }
-                       
+
                        $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file );
                        if ( !$fit ) {
                                $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
@@ -224,7 +223,18 @@ class ApiQueryFilearchive extends ApiQueryBase {
                        'limit' => 'How many total images to return',
                        'sha1' => "SHA1 hash of image. Overrides {$this->getModulePrefix()}sha1base36",
                        'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki)',
-                       'prop' => 'Which properties to get',
+                       'prop' => array(
+                               'What image information to get:',
+                               ' sha1         - Adds SHA-1 hash for the image',
+                               ' timestamp    - Adds timestamp for the uploaded version',
+                               ' user         - Adds user for uploaded the image version',
+                               ' size         - Adds the size of the image in bytes',
+                               ' dimensions   - Adds the height and width of the image',
+                               ' description  - Adds description the image version',
+                               ' mime         - Adds MIME of the image',
+                               ' metadata     - Lists EXIF metadata for the version of the image',
+                               ' bitdepth     - Adds the bit depth of the version',
+            ),
                );
        }