From 37484d2d3e4a4bbba2151fd441c526b7607c5eff Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 12 Mar 2008 22:27:25 +0000 Subject: [PATCH] * Merge in log_deleted constants * Add userCan() and isDeleted() --- includes/LogPage.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/includes/LogPage.php b/includes/LogPage.php index 0f7c169ecd..8522980eec 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -30,6 +30,10 @@ * */ class LogPage { + const DELETED_ACTION = 1; + const DELETED_COMMENT = 2; + const DELETED_USER = 4; + const DELETED_RESTRICTED = 8; /* @access private */ var $type, $action, $comment, $params, $target; /* @acess public */ @@ -311,6 +315,40 @@ 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 $event->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; + } +} +/** + * Aliases for backwards compatibility with 1.6 + */ +define( 'MW_LOG_DELETED_ACTION', LogPage::DELETED_ACTION ); +define( 'MW_LOG_DELETED_USER', LogPage::DELETED_USER ); +define( 'MW_LOG_DELETED_COMMENT', LogPage::DELETED_COMMENT ); +define( 'MW_LOG_DELETED_RESTRICTED', LogPage::DELETED_RESTRICTED ); -- 2.20.1