Changing "private" to "protected" on a few functions in User.php
[lhc/web/wiklou.git] / includes / User.php
index dd6407d..e2cbb81 100644 (file)
@@ -912,7 +912,7 @@ class User {
         *
         * @param $item String
         */
-       private function setItemLoaded( $item ) {
+       protected function setItemLoaded( $item ) {
                if ( is_array( $this->mLoadedItems ) ) {
                        $this->mLoadedItems[$item] = true;
                }
@@ -1807,8 +1807,11 @@ class User {
        }
 
        /**
-        * Return the talk page(s) this user has new messages on.
-        * @return Array of String page URLs
+        * Return the revision and link for the oldest new talk page message for
+        * this user.
+        * Note: This function was designed to accomodate multiple talk pages, but
+        * currently only returns a single link and revision.
+        * @return Array
         */
        public function getNewMessageLinks() {
                $talks = array();
@@ -1828,6 +1831,28 @@ class User {
                return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL(), 'rev' => $rev ) );
        }
 
+       /**
+        * Get the revision ID for the oldest new talk page message for this user
+        * @return Integer or null if there are no new messages
+        */
+       public function getNewMessageRevisionId() {
+               $newMessageRevisionId = null;
+               $newMessageLinks = $this->getNewMessageLinks();
+               if ( $newMessageLinks ) {
+                       // Note: getNewMessageLinks() never returns more than a single link
+                       // and it is always for the same wiki, but we double-check here in
+                       // case that changes some time in the future.
+                       if ( count( $newMessageLinks ) === 1
+                               && $newMessageLinks[0]['wiki'] === wfWikiID()
+                               && $newMessageLinks[0]['rev']
+                       ) {
+                               $newMessageRevision = $newMessageLinks[0]['rev'];
+                               $newMessageRevisionId = $newMessageRevision->getId();
+                       }
+               }
+               return $newMessageRevisionId;
+       }
+
        /**
         * Internal uncached check for new messages
         *
@@ -2791,7 +2816,7 @@ class User {
         */
        public function useNPPatrol() {
                global $wgUseRCPatrol, $wgUseNPPatrol;
-               return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) );
+               return ( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) );
        }
 
        /**
@@ -3263,7 +3288,7 @@ class User {
                        }
                        if ( !$loaded ) {
                                throw new MWException( __METHOD__ . ": hit a key conflict attempting " .
-                                       "to insert a user row, but then it doesn't exist when we select it!" );
+                                       "to insert user '{$this->mName}' row, but it was not present in select!" );
                        }
                        return Status::newFatal( 'userexists' );
                }
@@ -3643,7 +3668,7 @@ class User {
         * @param &$expiration \mixed Accepts the expiration time
         * @return String New token
         */
-       private function confirmationToken( &$expiration ) {
+       protected function confirmationToken( &$expiration ) {
                global $wgUserEmailConfirmationTokenExpiry;
                $now = time();
                $expires = $now + $wgUserEmailConfirmationTokenExpiry;
@@ -3661,7 +3686,7 @@ class User {
         * @param string $token Accepts the email confirmation token
         * @return String New token URL
         */
-       private function confirmationTokenUrl( $token ) {
+       protected function confirmationTokenUrl( $token ) {
                return $this->getTokenUrl( 'ConfirmEmail', $token );
        }
 
@@ -3670,7 +3695,7 @@ class User {
         * @param string $token Accepts the email confirmation token
         * @return String New token URL
         */
-       private function invalidationTokenUrl( $token ) {
+       protected function invalidationTokenUrl( $token ) {
                return $this->getTokenUrl( 'InvalidateEmail', $token );
        }
 
@@ -4482,8 +4507,7 @@ class User {
         *
         * @return array Array of HTML attributes suitable for feeding to
         *   Html::element(), directly or indirectly.  (Don't feed to Xml::*()!
-        *   That will potentially output invalid XHTML 1.0 Transitional, and will
-        *   get confused by the boolean attribute syntax used.)
+        *   That will get confused by the boolean attribute syntax used.)
         */
        public static function passwordChangeInputAttribs() {
                global $wgMinimalPasswordLength;