return $this->getPath() && file_exists( $this->path );
}
+ /**
+ * Returns true if file exists in the repository and can be included in a page.
+ * It would be unsafe to include private images, making public thumbnails inadvertently
+ *
+ * @return boolean Whether file exists in the repository and is includable.
+ * @public
+ */
+ function isVisible() {
+ return $this->exists();
+ }
+
function getTransformScript() {
if ( !isset( $this->transformScript ) ) {
$this->transformScript = false;
*/
abstract class FileRepo {
const DELETE_SOURCE = 1;
+ const FIND_PRIVATE = 1;
const OVERWRITE = 2;
const OVERWRITE_SAME = 4;
*
* @param mixed $time 14-character timestamp, or false for the current version
*/
- function findFile( $title, $time = false ) {
+ function findFile( $title, $time = false, $flags = 0 ) {
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
if ( !$img ) {
# Now try an old version of the file
$img = $this->newFile( $title, $time );
if ( $img->exists() ) {
- return $img;
+ if ( !$img->isDeleted(File::DELETED_FILE) ) {
+ return $img;
+ } else if ( ($flags & FileRepo::FIND_PRIVATE) && $img->userCan(File::DELETED_FILE) ) {
+ return $img;
+ }
}
-
# Now try redirects
$redir = $this->checkRedirect( $title );
if( $redir && $redir->getNamespace() == NS_IMAGE) {
return $img;
}
}
+ return false;
}
/**