From: Aaron Schulz Date: Wed, 2 Apr 2008 17:11:58 +0000 (+0000) Subject: Move isDeleted and userCan functions X-Git-Tag: 1.31.0-rc.0~48664 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=c9ca9117584e47835afe821e9fbb518fd38e2cdc;p=lhc%2Fweb%2Fwiklou.git Move isDeleted and userCan functions --- diff --git a/includes/LogEventList.php b/includes/LogEventList.php index 67fbd136dd..b460a39df9 100644 --- a/includes/LogEventList.php +++ b/includes/LogEventList.php @@ -158,7 +158,7 @@ class LogEventList { $linkCache =& LinkCache::singleton(); $linkCache->addLinkObj( $title ); // User links - if( LogPage::isDeleted($row,LogPage::DELETED_USER) ) { + if( self::isDeleted($row,LogPage::DELETED_USER) ) { $userLink = '' . wfMsgHtml( 'rev-deleted-user' ) . ''; } else { $userLink = $this->skin->userLink( $row->log_user, $row->user_name ) . @@ -167,7 +167,7 @@ class LogEventList { // Comment if( $row->log_action == 'create2' ) { $comment = ''; // Suppress from old account creations, useless and can contain incorrect links - } else if( LogPage::isDeleted($row,LogPage::DELETED_COMMENT) ) { + } else if( self::isDeleted($row,LogPage::DELETED_COMMENT) ) { $comment = '' . wfMsgHtml('rev-deleted-comment') . ''; } else { $comment = $wgContLang->getDirMark() . $this->skin->commentBlock( $row->log_comment ); @@ -275,7 +275,7 @@ class LogEventList { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); // If event was hidden from sysops - if( !LogPage::userCan( $row, Revision::DELETED_RESTRICTED ) ) { + if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) { $del = $this->message['rev-delundel']; } else if( $row->log_type == 'suppress' ) { // No one should be hiding from the oversight log @@ -283,7 +283,7 @@ class LogEventList { } else { $del = $this->skin->makeKnownLinkObj( $revdel, $this->message['rev-delundel'], 'logid='.$row->log_id ); // Bolden oversighted content - if( LogPage::isDeleted( $row, Revision::DELETED_RESTRICTED ) ) + if( self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) ) $del = "$del"; } return "($del)"; @@ -310,6 +310,35 @@ class LogEventList { } return false; } + + /** + * Determine if the current user is allowed to view a particular + * field of this log row, if it's marked as deleted. + * @param Row $row + * @param int $field + * @return bool + */ + public static function userCan( $row, $field ) { + if( ( $row->log_deleted & $field ) == $field ) { + global $wgUser; + $permission = ( $row->log_deleted & LogPage::DELETED_RESTRICTED ) == LogPage::DELETED_RESTRICTED + ? 'hiderevision' + : 'deleterevision'; + wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" ); + return $wgUser->isAllowed( $permission ); + } else { + return true; + } + } + + /** + * int $field one of DELETED_* bitfield constants + * @param Row $row + * @return bool + */ + public static function isDeleted( $row, $field ) { + return ($row->log_deleted & $field) == $field; + } } /** diff --git a/includes/LogPage.php b/includes/LogPage.php index 77d754bfe6..0a3537c4c2 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -312,35 +312,6 @@ class LogPage { } return $messages[$flag]; } - - /** - * Determine if the current user is allowed to view a particular - * field of this log row, if it's marked as deleted. - * @param Row $row - * @param int $field - * @return bool - */ - public static function userCan( $row, $field ) { - if( ( $row->log_deleted & $field ) == $field ) { - global $wgUser; - $permission = ( $row->log_deleted & self::DELETED_RESTRICTED ) == self::DELETED_RESTRICTED - ? 'hiderevision' - : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $row->log_deleted\n" ); - return $wgUser->isAllowed( $permission ); - } else { - return true; - } - } - - /** - * int $field one of DELETED_* bitfield constants - * @param Row $row - * @return bool - */ - public static function isDeleted( $row, $field ) { - return ($row->log_deleted & $field) == $field; - } } /** diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index 419d89a561..f3a4ee12c1 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -469,7 +469,7 @@ class RevisionDeleteForm { if( !isset( $logRows[$logid] ) || $logRows[$logid]->log_type=='suppress' ) { $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); return; - } else if( !LogPage::userCan( $logRows[$logid],Revision::DELETED_RESTRICTED) ) { + } else if( !LogEventList::userCan( $logRows[$logid],Revision::DELETED_RESTRICTED) ) { // If an event is hidden from sysops if( $action != 'submit') { $wgOut->permissionRequired( 'hiderevision' ); @@ -629,7 +629,7 @@ class RevisionDeleteForm { $loglink = $this->skin->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ), wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) ); // Action text - if( !LogPage::userCan($row,LogPage::DELETED_ACTION) ) { + if( !LogEventList::userCan($row,LogPage::DELETED_ACTION) ) { $action = '' . wfMsgHtml('rev-deleted-event') . ''; } else { $action = LogPage::actionText( $row->log_type, $row->log_action, $title, @@ -639,12 +639,12 @@ class RevisionDeleteForm { } // User links $userLink = $this->skin->userLink( $row->log_user, User::WhoIs($row->log_user) ); - if( LogPage::isDeleted($row,LogPage::DELETED_USER) ) { + if( LogEventList::isDeleted($row,LogPage::DELETED_USER) ) { $userLink = '' . $userLink . ''; } // Comment $comment = $wgContLang->getDirMark() . $this->skin->commentBlock( $row->log_comment ); - if( LogPage::isDeleted($row,LogPage::DELETED_COMMENT) ) { + if( LogEventList::isDeleted($row,LogPage::DELETED_COMMENT) ) { $comment = '' . $comment . ''; } return "
  • ($loglink) $date $userLink $action $comment
  • "; @@ -1080,7 +1080,7 @@ class RevisionDeleter { if( !isset($logRows[$logid]) ) { $success = false; continue; // Must exist - } else if( !LogPage::userCan($logRows[$logid], Revision::DELETED_RESTRICTED) + } else if( !LogEventList::userCan($logRows[$logid], Revision::DELETED_RESTRICTED) || $logRows[$logid]->log_type == 'suppress' ) { // Don't hide from oversight log!!! $userAllowedAll=false;