merge latest master into Wikidata branch
[lhc/web/wiklou.git] / includes / WikiPage.php
index b1dd910..511f83a 100644 (file)
@@ -604,11 +604,13 @@ class WikiPage extends Page implements IDBAccessObject {
         *      Revision::FOR_PUBLIC       to be displayed to all users
         *      Revision::FOR_THIS_USER    to be displayed to $wgUser
         *      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
         * @return Content|null The content of the current revision
         *
         * @since 1.21
         */
-       public function getContent( $audience = Revision::FOR_PUBLIC ) {
+       public function getContent( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
                        return $this->mLastRevision->getContent( $audience );
@@ -621,17 +623,18 @@ class WikiPage extends Page implements IDBAccessObject {
         *
         * @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
         * @return String|false The text of the current revision
         * @deprecated as of 1.21, getContent() should be used instead.
         */
-       public function getText( $audience = Revision::FOR_PUBLIC ) { #@todo: deprecated, replace usage!
+       public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { #@todo: deprecated, replace usage!
                wfDeprecated( __METHOD__, '1.21' );
-
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
-                       return $this->mLastRevision->getText( $audience );
+                       return $this->mLastRevision->getText( $audience, $user );
                }
                return false;
        }
@@ -672,14 +675,16 @@ class WikiPage extends Page implements IDBAccessObject {
        /**
         * @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
         * @return int user ID for the user that made the last article revision
         */
-       public function getUser( $audience = Revision::FOR_PUBLIC ) {
+       public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
-                       return $this->mLastRevision->getUser( $audience );
+                       return $this->mLastRevision->getUser( $audience, $user );
                } else {
                        return -1;
                }
@@ -689,14 +694,16 @@ class WikiPage extends Page implements IDBAccessObject {
         * Get the User object of the user who created the page
         * @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
         * @return User|null
         */
-       public function getCreator( $audience = Revision::FOR_PUBLIC ) {
+       public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $revision = $this->getOldestRevision();
                if ( $revision ) {
-                       $userName = $revision->getUserText( $audience );
+                       $userName = $revision->getUserText( $audience, $user );
                        return User::newFromName( $userName, false );
                } else {
                        return null;
@@ -706,14 +713,16 @@ class WikiPage extends Page implements IDBAccessObject {
        /**
         * @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
         * @return string username of the user that made the last article revision
         */
-       public function getUserText( $audience = Revision::FOR_PUBLIC ) {
+       public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
-                       return $this->mLastRevision->getUserText( $audience );
+                       return $this->mLastRevision->getUserText( $audience, $user );
                } else {
                        return '';
                }
@@ -722,14 +731,16 @@ class WikiPage extends Page implements IDBAccessObject {
        /**
         * @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
         * @return string Comment stored for the last article revision
         */
-       public function getComment( $audience = Revision::FOR_PUBLIC ) {
+       public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
-                       return $this->mLastRevision->getComment( $audience );
+                       return $this->mLastRevision->getComment( $audience, $user );
                } else {
                        return '';
                }