Merge "Add PreferencesFormPreSave hook"
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index cab5690..ca8c219 100644 (file)
@@ -111,6 +111,9 @@ class FileRepo {
         */
        protected $abbrvThreshold;
 
+       /** @var string The URL of the repo's favicon, if any  */
+       protected $favicon;
+
        /**
         * Factory functions for creating new files
         * Override these in the base class
@@ -147,7 +150,7 @@ class FileRepo {
                $optionalSettings = array(
                        'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
                        'thumbScriptUrl', 'pathDisclosureProtection', 'descriptionCacheExpiry',
-                       'scriptExtension'
+                       'scriptExtension', 'favicon'
                );
                foreach ( $optionalSettings as $var ) {
                        if ( isset( $info[$var] ) ) {
@@ -416,7 +419,7 @@ class FileRepo {
         *   ignoreRedirect: If true, do not follow file redirects
         *   private:        If true, return restricted (deleted) files if the current
         *                   user is allowed to view them. Otherwise, such files will not
-        *                   be found.
+        *                   be found. If a User object, use that user instead of the current.
         * @return File|bool False on failure
         */
        public function findFile( $title, $options = array() ) {
@@ -439,7 +442,11 @@ class FileRepo {
                        if ( $img && $img->exists() ) {
                                if ( !$img->isDeleted( File::DELETED_FILE ) ) {
                                        return $img; // always OK
-                               } elseif ( !empty( $options['private'] ) && $img->userCan( File::DELETED_FILE ) ) {
+                               } elseif ( !empty( $options['private'] ) &&
+                                       $img->userCan( File::DELETED_FILE,
+                                               $options['private'] instanceof User ? $options['private'] : null
+                                       )
+                               ) {
                                        return $img;
                                }
                        }
@@ -536,7 +543,11 @@ class FileRepo {
                        if ( $img && $img->exists() ) {
                                if ( !$img->isDeleted( File::DELETED_FILE ) ) {
                                        return $img; // always OK
-                               } elseif ( !empty( $options['private'] ) && $img->userCan( File::DELETED_FILE ) ) {
+                               } elseif ( !empty( $options['private'] ) &&
+                                       $img->userCan( File::DELETED_FILE,
+                                               $options['private'] instanceof User ? $options['private'] : null
+                                       )
+                               ) {
                                        return $img;
                                }
                        }
@@ -1845,7 +1856,7 @@ class FileRepo {
 
                $optionalSettings = array(
                        'url', 'thumbUrl', 'initialCapital', 'descBaseUrl', 'scriptDirUrl', 'articleUrl',
-                       'fetchDescription', 'descriptionCacheExpiry', 'scriptExtension'
+                       'fetchDescription', 'descriptionCacheExpiry', 'scriptExtension', 'favicon'
                );
                foreach ( $optionalSettings as $k ) {
                        if ( isset( $this->$k ) ) {