Move revision deletion constants into Revision::
authorDomas Mituzas <midom@users.mediawiki.org>
Tue, 6 Jun 2006 10:54:23 +0000 (10:54 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Tue, 6 Jun 2006 10:54:23 +0000 (10:54 +0000)
includes/Article.php
includes/Export.php
includes/Linker.php
includes/PageHistory.php
includes/Revision.php
includes/SpecialContributions.php
includes/SpecialRevisiondelete.php

index 2b32885..6bffff2 100644 (file)
@@ -445,7 +445,7 @@ class Article {
 
                // FIXME: Horrible, horrible! This content-loading interface just plain sucks.
                // We should instead work with the Revision object when we need it...
-               $this->mContent = $revision->userCan( MW_REV_DELETED_TEXT ) ? $revision->getRawText() : "";
+               $this->mContent = $revision->userCan( Revision::MW_REV_DELETED_TEXT ) ? $revision->getRawText() : "";
                //$this->mContent   = $revision->getText();
 
                $this->mUser      = $revision->getUser();
@@ -815,8 +815,8 @@ class Article {
                                        // FIXME: This would be a nice place to load the 'no such page' text.
                                } else {
                                        $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
-                                       if( $this->mRevision->isDeleted( MW_REV_DELETED_TEXT ) ) {
-                                               if( !$this->mRevision->userCan( MW_REV_DELETED_TEXT ) ) {
+                                       if( $this->mRevision->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
+                                               if( !$this->mRevision->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                                                        $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
                                                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                                                        return;
index d0253eb..cc5b401 100644 (file)
@@ -396,7 +396,7 @@ class XmlDumpWriter {
                $ts = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
                $out .= "      " . wfElement( 'timestamp', null, $ts ) . "\n";
 
-               if( $row->rev_deleted & MW_REV_DELETED_USER ) {
+               if( $row->rev_deleted & Revision::MW_REV_DELETED_USER ) {
                        $out .= "      " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
                } else {
                        $out .= "      <contributor>\n";
@@ -412,13 +412,13 @@ class XmlDumpWriter {
                if( $row->rev_minor_edit ) {
                        $out .=  "      <minor/>\n";
                }
-               if( $row->rev_deleted & MW_REV_DELETED_COMMENT ) {
+               if( $row->rev_deleted & Revision::MW_REV_DELETED_COMMENT ) {
                        $out .= "      " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
                } elseif( $row->rev_comment != '' ) {
                        $out .= "      " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
                }
 
-               if( $row->rev_deleted & MW_REV_DELETED_TEXT ) {
+               if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) {
                        $out .= "      " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
                } elseif( isset( $row->old_text ) ) {
                        // Raw text from the database may have invalid chars
index 44d1799..12cd4bc 100644 (file)
@@ -833,12 +833,12 @@ class Linker {
         * @return string HTML
         */
        function revUserLink( $rev ) {
-               if( $rev->userCan( MW_REV_DELETED_USER ) ) {
+               if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
                        $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() );
                } else {
                        $link = wfMsgHtml( 'rev-deleted-user' );
                }
-               if( $rev->isDeleted( MW_REV_DELETED_USER ) ) {
+               if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
                        return '<span class="history-deleted">' . $link . '</span>';
                }
                return $link;
@@ -850,14 +850,14 @@ class Linker {
         * @return string HTML
         */
        function revUserTools( $rev ) {
-               if( $rev->userCan( MW_REV_DELETED_USER ) ) {
+               if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
                        $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) .
                                ' ' .
                                $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() );
                } else {
                        $link = wfMsgHtml( 'rev-deleted-user' );
                }
-               if( $rev->isDeleted( MW_REV_DELETED_USER ) ) {
+               if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
                        return '<span class="history-deleted">' . $link . '</span>';
                }
                return $link;
@@ -977,13 +977,13 @@ class Linker {
         * @return string HTML
         */
        function revComment( $rev ) {
-               if( $rev->userCan( MW_REV_DELETED_COMMENT ) ) {
+               if( $rev->userCan( Revision::MW_REV_DELETED_COMMENT ) ) {
                        $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() );
                } else {
                        $block = " <span class='comment'>" .
                                wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
                }
-               if( $rev->isDeleted( MW_REV_DELETED_COMMENT ) ) {
+               if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) {
                        return " <span class='history-deleted'>$block</span>";
                }
                return $block;
index 2e70e4d..320d857 100644 (file)
@@ -263,7 +263,7 @@ class PageHistory {
                if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) {
                        $s .= ' <span class="updatedmarker">' .  wfMsgHtml( 'updatedmarker' ) . '</span>';
                }
-               if( $row->rev_deleted & MW_REV_DELETED_TEXT ) {
+               if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) {
                        $s .= ' ' . wfMsgHtml( 'deletedrev' );
                }
                $s .= "</li>\n";
@@ -275,13 +275,13 @@ class PageHistory {
        function revLink( $rev ) {
                global $wgLang;
                $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
-               if( $rev->userCan( MW_REV_DELETED_TEXT ) ) {
+               if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                        $link = $this->mSkin->makeKnownLinkObj(
                                $this->mTitle, $date, "oldid=" . $rev->getId() );
                } else {
                        $link = $date;
                }
-               if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+               if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
                        return '<span class="history-deleted">' . $link . '</span>';
                }
                return $link;
@@ -290,7 +290,7 @@ class PageHistory {
        /** @todo document */
        function curLink( $rev, $latest ) {
                $cur = wfMsgExt( 'cur', array( 'escape') );
-               if( $latest || !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+               if( $latest || !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                        return $cur;
                } else {
                        return $this->mSkin->makeKnownLinkObj(
@@ -313,7 +313,7 @@ class PageHistory {
                                        $last,
                                        "diff=" . $rev->getId() . "&oldid=prev" );
                        }
-               } elseif( !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+               } elseif( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                        return $last;
                } else {
                        return $this->mSkin->makeKnownLinkObj(
@@ -337,7 +337,7 @@ class PageHistory {
 #                              'title' => wfMsgHtml( 'selectolderversionfordiff' )
                        );
 
-                       if( !$rev->userCan( MW_REV_DELETED_TEXT ) ) {
+                       if( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                                $radio['disabled'] = 'disabled';
                        }
 
index e9083a7..7a33612 100644 (file)
@@ -8,18 +8,16 @@
 require_once( 'Database.php' );
 require_once( 'Article.php' );
 
-/** @+ */
-define( 'MW_REV_DELETED_TEXT',       1 );
-define( 'MW_REV_DELETED_COMMENT',    2 );
-define( 'MW_REV_DELETED_USER',       4 );
-define( 'MW_REV_DELETED_RESTRICTED', 8 );
-/** @- */
-
 /**
  * @package MediaWiki
  * @todo document
  */
 class Revision {
+       const MW_REV_DELETED_TEXT       = 1;
+       const MW_REV_DELETED_COMMENT    = 2;
+       const MW_REV_DELETED_USER       = 4;
+       const MW_REV_DELETED_RESTRICTED = 8;
+       
        /**
         * Load a page revision from a given revision ID number.
         * Returns null if no such revision can be found.
@@ -343,7 +341,7 @@ class Revision {
         * @return int
         */
        function getUser() {
-               if( $this->isDeleted( MW_REV_DELETED_USER ) ) {
+               if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) {
                        return 0;
                } else {
                        return $this->mUser;
@@ -363,7 +361,7 @@ class Revision {
         * @return string
         */
        function getUserText() {
-               if( $this->isDeleted( MW_REV_DELETED_USER ) ) {
+               if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) {
                        return "";
                } else {
                        return $this->mUserText;
@@ -383,7 +381,7 @@ class Revision {
         * @return string
         */
        function getComment() {
-               if( $this->isDeleted( MW_REV_DELETED_COMMENT ) ) {
+               if( $this->isDeleted( self::MW_REV_DELETED_COMMENT ) ) {
                        return "";
                } else {
                        return $this->mComment;
@@ -418,7 +416,7 @@ class Revision {
         * @return string
         */
        function getText() {
-               if( $this->isDeleted( MW_REV_DELETED_TEXT ) ) {
+               if( $this->isDeleted( self::MW_REV_DELETED_TEXT ) ) {
                        return "";
                } else {
                        return $this->getRawText();
@@ -729,15 +727,15 @@ class Revision {
        /**
         * Determine if the current user is allowed to view a particular
         * field of this revision, if it's marked as deleted.
-        * @param int $field one of MW_REV_DELETED_TEXT,
-        *                          MW_REV_DELETED_COMMENT,
-        *                          MW_REV_DELETED_USER
+        * @param int $field one of self::MW_REV_DELETED_TEXT,
+        *                          self::MW_REV_DELETED_COMMENT,
+        *                          self::MW_REV_DELETED_USER
         * @return bool
         */
        function userCan( $field ) {
                if( ( $this->mDeleted & $field ) == $field ) {
                        global $wgUser;
-                       $permission = ( $this->mDeleted & MW_REV_DELETED_RESTRICTED ) == MW_REV_DELETED_RESTRICTED
+                       $permission = ( $this->mDeleted & self::MW_REV_DELETED_RESTRICTED ) == self::MW_REV_DELETED_RESTRICTED
                                ? 'hiderevision'
                                : 'deleterevision';
                        wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" );
index 959af08..f09667d 100644 (file)
@@ -391,7 +391,7 @@ function ucListEdit( $sk, $row ) {
                }
 
        }
-       if( $rev->userCan( MW_REV_DELETED_TEXT ) ) {
+       if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) {
                $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
        } else {
                $difftext = '(' . $messages['diff'] . ')';
@@ -401,7 +401,7 @@ function ucListEdit( $sk, $row ) {
        $comment = $sk->revComment( $rev );
        $d = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->rev_timestamp), true );
        
-       if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+       if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
                $d = '<span class="history-deleted">' . $d . '</span>';
        }
 
@@ -412,7 +412,7 @@ function ucListEdit( $sk, $row ) {
        }
 
        $ret = "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}";
-       if( $rev->isDeleted( MW_REV_DELETED_TEXT ) ) {
+       if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) {
                $ret .= ' ' . wfMsgHtml( 'deletedrev' );
        }
        $ret = "<li>$ret</li>\n";
index 7854c22..cf37647 100644 (file)
@@ -46,10 +46,10 @@ class RevisionDeleteForm {
                
                $this->skin = $wgUser->getSkin();
                $this->checks = array(
-                       array( 'revdelete-hide-text', 'wpHideText', MW_REV_DELETED_TEXT ),
-                       array( 'revdelete-hide-comment', 'wpHideComment', MW_REV_DELETED_COMMENT ),
-                       array( 'revdelete-hide-user', 'wpHideUser', MW_REV_DELETED_USER ),
-                       array( 'revdelete-hide-restricted', 'wpHideRestricted', MW_REV_DELETED_RESTRICTED ) );
+                       array( 'revdelete-hide-text', 'wpHideText', Revision::MW_REV_DELETED_TEXT ),
+                       array( 'revdelete-hide-comment', 'wpHideComment', Revision::MW_REV_DELETED_COMMENT ),
+                       array( 'revdelete-hide-user', 'wpHideUser', Revision::MW_REV_DELETED_USER ),
+                       array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::MW_REV_DELETED_RESTRICTED ) );
        }
        
        /**
@@ -222,9 +222,9 @@ class RevisionDeleter {
        function updateRecentChanges( $rev, $bitfield ) {
                $this->db->update( 'recentchanges',
                        array(
-                               'rc_user' => ($bitfield & MW_REV_DELETED_USER) ? 0 : $rev->getUser(),
-                               'rc_user_text' => ($bitfield & MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(),
-                               'rc_comment' => ($bitfield & MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ),
+                               'rc_user' => ($bitfield & Revision::MW_REV_DELETED_USER) ? 0 : $rev->getUser(),
+                               'rc_user_text' => ($bitfield & Revision::MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(),
+                               'rc_comment' => ($bitfield & Revision::MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ),
                        array(
                                'rc_this_oldid' => $rev->getId() ),
                        'RevisionDeleter::updateRecentChanges' );