Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -30,6 +30,10 @@ |
31 | 31 | * |
32 | 32 | */ |
33 | 33 | class LogPage { |
| 34 | + const DELETED_ACTION = 1; |
| 35 | + const DELETED_COMMENT = 2; |
| 36 | + const DELETED_USER = 4; |
| 37 | + const DELETED_RESTRICTED = 8; |
34 | 38 | /* @access private */ |
35 | 39 | var $type, $action, $comment, $params, $target; |
36 | 40 | /* @acess public */ |
— | — | @@ -311,6 +315,40 @@ |
312 | 316 | return $messages[$flag]; |
313 | 317 | } |
314 | 318 | |
| 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 | + } |
315 | 347 | } |
316 | 348 | |
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 ); |