diff options
author | Demon <chadh@wikimedia.org> | 2012-06-04 20:41:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2012-06-04 20:41:52 +0000 |
commit | 1dc986a90ff464bc3826f0006e488e39ad0e016d (patch) | |
tree | edfb518f514446f82d2167e5fc18fb546f0c2452 /includes | |
parent | bae670cf03d81b8128ba7aadcfaa61d3b381cf2c (diff) | |
parent | 9f6afeab0dbdf6895645d42f5c68266742ebb9b7 (diff) | |
download | mediawikicore-1dc986a90ff464bc3826f0006e488e39ad0e016d.tar.gz mediawikicore-1dc986a90ff464bc3826f0006e488e39ad0e016d.zip |
Merge "[FileRepo] Made getDescription() respect *_deleted fields."
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Export.php | 7 | ||||
-rw-r--r-- | includes/ImagePage.php | 2 | ||||
-rw-r--r-- | includes/Revision.php | 8 | ||||
-rw-r--r-- | includes/filerepo/file/File.php | 15 | ||||
-rw-r--r-- | includes/filerepo/file/LocalFile.php | 12 |
5 files changed, 34 insertions, 10 deletions
diff --git a/includes/Export.php b/includes/Export.php index 9debbb5ed6c8..6c47e341fd74 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -789,10 +789,15 @@ class XmlDumpWriter { } else { $contents = ''; } + if ( $file->isDeleted( File::DELETED_COMMENT ) ) { + $comment = Xml::element( 'comment', array( 'deleted' => 'deleted' ) ); + } else { + $comment = Xml::elementClean( 'comment', null, $file->getDescription() ); + } return " <upload>\n" . $this->writeTimestamp( $file->getTimestamp() ) . $this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) . - " " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" . + " " . $comment . "\n" . " " . Xml::element( 'filename', null, $file->getName() ) . "\n" . $archiveName . " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" . diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 63e9894d7322..b1a505758a5b 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -990,7 +990,7 @@ class ImageHistoryList extends ContextSource { $img = $iscur ? $file->getName() : $file->getArchiveName(); $userId = $file->getUser( 'id' ); $userText = $file->getUser( 'text' ); - $description = $file->getDescription(); + $description = $file->getDescription( File::FOR_THIS_USER, $user ); $local = $this->current->isLocal(); $row = $selected = ''; diff --git a/includes/Revision.php b/includes/Revision.php index 6dbd808a54ac..6b8aabc64047 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -598,7 +598,7 @@ class Revision { * * @param $audience Integer: one of: * Revision::FOR_PUBLIC to be displayed to all users - * Revision::FOR_THIS_USER to be displayed to $wgUser + * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the ID regardless of permissions * @param $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter @@ -630,7 +630,7 @@ class Revision { * * @param $audience Integer: one of: * Revision::FOR_PUBLIC to be displayed to all users - * Revision::FOR_THIS_USER to be displayed to $wgUser + * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions * @param $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter @@ -670,7 +670,7 @@ class Revision { * * @param $audience Integer: one of: * Revision::FOR_PUBLIC to be displayed to all users - * Revision::FOR_THIS_USER to be displayed to $wgUser + * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions * @param $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter @@ -748,7 +748,7 @@ class Revision { * * @param $audience Integer: one of: * Revision::FOR_PUBLIC to be displayed to all users - * Revision::FOR_THIS_USER to be displayed to $wgUser + * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions * @param $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 2d6b21883603..065679a87afd 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -63,6 +63,11 @@ abstract class File { const DELETE_SOURCE = 1; + // Audience options for File::getDescription() + const FOR_PUBLIC = 1; + const FOR_THIS_USER = 2; + const RAW = 3; + /** * Some member variables can be lazy-initialised using __get(). The * initialisation function for these variables is always a function named @@ -1565,12 +1570,18 @@ abstract class File { } /** - * Get discription of file revision + * Get description of file revision * STUB * + * @param $audience Integer: one of: + * File::FOR_PUBLIC to be displayed to all users + * File::FOR_THIS_USER to be displayed to the given user + * File::RAW get the description regardless of permissions + * @param $user User object to check for, only if FOR_THIS_USER is passed + * to the $audience parameter * @return string */ - function getDescription() { + function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) { return null; } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index cc66649fe6e2..d9ba9be8adc3 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1467,9 +1467,17 @@ class LocalFile extends File { /** * @return string */ - function getDescription() { + function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) { $this->load(); - return $this->description; + if ( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) { + return ''; + } elseif ( $audience == self::FOR_THIS_USER + && !$this->userCan( self::DELETED_COMMENT, $user ) ) + { + return ''; + } else { + return $this->description; + } } /** |