r31890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31889‎ | r31890 | r31891 >
Date:22:27, 12 March 2008
Author:aaron
Status:old
Tags:
Comment:
* Merge in log_deleted constants
* Add userCan() and isDeleted()
Modified paths:
  • /trunk/phase3/includes/LogPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogPage.php
@@ -30,6 +30,10 @@
3131 *
3232 */
3333 class LogPage {
 34+ const DELETED_ACTION = 1;
 35+ const DELETED_COMMENT = 2;
 36+ const DELETED_USER = 4;
 37+ const DELETED_RESTRICTED = 8;
3438 /* @access private */
3539 var $type, $action, $comment, $params, $target;
3640 /* @acess public */
@@ -311,6 +315,40 @@
312316 return $messages[$flag];
313317 }
314318
 319+ /**
 320+ * Determine if the current user is allowed to view a particular
 321+ * field of this log row, if it's marked as deleted.
 322+ * @param Row $row
 323+ * @param int $field
 324+ * @return bool
 325+ */
 326+ public static function userCan( $row, $field ) {
 327+ if( ( $row->log_deleted & $field ) == $field ) {
 328+ global $wgUser;
 329+ $permission = ( $row->log_deleted & self::DELETED_RESTRICTED ) == self::DELETED_RESTRICTED
 330+ ? 'hiderevision'
 331+ : 'deleterevision';
 332+ wfDebug( "Checking for $permission due to $field match on $event->log_deleted\n" );
 333+ return $wgUser->isAllowed( $permission );
 334+ } else {
 335+ return true;
 336+ }
 337+ }
 338+
 339+ /**
 340+ * int $field one of DELETED_* bitfield constants
 341+ * @param Row $row
 342+ * @return bool
 343+ */
 344+ public static function isDeleted( $row, $field ) {
 345+ return ($row->log_deleted & $field) == $field;
 346+ }
315347 }
316348
317 -
 349+/**
 350+ * Aliases for backwards compatibility with 1.6
 351+ */
 352+define( 'MW_LOG_DELETED_ACTION', LogPage::DELETED_ACTION );
 353+define( 'MW_LOG_DELETED_USER', LogPage::DELETED_USER );
 354+define( 'MW_LOG_DELETED_COMMENT', LogPage::DELETED_COMMENT );
 355+define( 'MW_LOG_DELETED_RESTRICTED', LogPage::DELETED_RESTRICTED );

Status & tagging log