r44682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44681‎ | r44682 | r44683 >
Date:19:20, 16 December 2008
Author:aaron
Status:ok
Tags:
Comment:
*Add missing 'reblock' check and message setting
*Move right checks to typeAction to make the code prettier
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogEventsList.php
@@ -253,7 +253,7 @@
254254 // Add review links and such...
255255 if( ($this->flags & self::NO_ACTION_LINK) || ($row->log_deleted & LogPage::DELETED_ACTION) ) {
256256 // Action text is suppressed...
257 - } else if( self::typeAction($row,'move','move') && !empty($paramArray[0]) && $wgUser->isAllowed( 'move' ) ) {
 257+ } else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) {
258258 $destTitle = Title::newFromText( $paramArray[0] );
259259 if( $destTitle ) {
260260 $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
@@ -264,11 +264,11 @@
265265 '&wpMovetalk=0' ) . ')';
266266 }
267267 // Show undelete link
268 - } else if( self::typeAction($row,array('delete','suppress'),'delete') && $wgUser->isAllowed( 'delete' ) ) {
 268+ } else if( self::typeAction($row,array('delete','suppress'),'delete','delete') ) {
269269 $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ),
270270 $this->message['undeletelink'], 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')';
271271 // Show unblock/change block link
272 - } else if( self::typeAction( $row, array( 'block', 'suppress' ), 'block' ) && $wgUser->isAllowed( 'block' ) ) {
 272+ } else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) {
273273 $revert = '(' .
274274 $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
275275 $this->message['unblocklink'],
@@ -289,13 +289,13 @@
290290 'action=unprotect' ) . ')';
291291 }
292292 // Show unmerge link
293 - } else if ( self::typeAction($row,'merge','merge') ) {
 293+ } else if( self::typeAction($row,'merge','merge','mergehistory') ) {
294294 $merge = SpecialPage::getTitleFor( 'Mergehistory' );
295295 $revert = '(' . $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'],
296296 wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(),
297297 'mergepoint' => $paramArray[1] ) ) ) . ')';
298298 // If an edit was hidden from a page give a review link to the history
299 - } else if( self::typeAction($row,array('delete','suppress'),'revision') && $wgUser->isAllowed( 'deleterevision' ) ) {
 299+ } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
300300 if( count($paramArray) == 2 ) {
301301 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
302302 // Different revision types use different URL params...
@@ -310,7 +310,7 @@
311311 'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
312312 }
313313 // Hidden log items, give review link
314 - } else if( self::typeAction($row,array('delete','suppress'),'event') && $wgUser->isAllowed( 'deleterevision' ) ) {
 314+ } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
315315 if( count($paramArray) == 1 ) {
316316 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
317317 $Ids = explode( ',', $paramArray[0] );
@@ -376,12 +376,18 @@
377377 * @param $row Row
378378 * @param $type Mixed: string/array
379379 * @param $action Mixed: string/array
 380+ * @param $right string
380381 * @return bool
381382 */
382 - public static function typeAction( $row, $type, $action ) {
 383+ public static function typeAction( $row, $type, $action, $right='' ) {
383384 $match = is_array($type) ? in_array($row->log_type,$type) : $row->log_type == $type;
384385 if( $match ) {
385 - $match = is_array($action) ? in_array($row->log_action,$action) : $row->log_action == $action;
 386+ $match = is_array($action) ?
 387+ in_array($row->log_action,$action) : $row->log_action == $action;
 388+ if( $match && $right ) {
 389+ global $wgUser;
 390+ $match = $wgUser->isAllowed( $right );
 391+ }
386392 }
387393 return $match;
388394 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2902,6 +2902,7 @@
29032903 'suppress/event' => 'logdelete-logentry',
29042904 'suppress/delete' => 'suppressedarticle',
29052905 'suppress/block' => 'blocklogentry',
 2906+ 'suppress/reblock' => 'reblock-logentry',
29062907 );
29072908
29082909 /**

Status & tagging log