From: Matthias Mullie Date: Thu, 2 Jul 2015 12:32:50 +0000 (+0200) Subject: Allow hooks to abort lines in EnhancedRC X-Git-Tag: 1.31.0-rc.0~10873^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=dc3ddcc4a2b5ac55a2e2a5416b496f129412640e;p=lhc%2Fweb%2Fwiklou.git Allow hooks to abort lines in EnhancedRC Bug: T104564 Change-Id: I4a2f97d83f38071984d571773a6b09b6b6643d6d --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 92bc95a098..23df983240 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1300,12 +1300,14 @@ $editToken: The user's edit token. 'EnhancedChangesList::getLogText': to alter, remove or add to the links of a group of changes in EnhancedChangesList. +Hook subscribers can return false to omit this line from recentchanges. $changesList: EnhancedChangesList object &$links: The links that were generated by EnhancedChangesList $block: The RecentChanges objects in that block 'EnhancedChangesListModifyLineData': to alter data used to build a grouped recent change inner line in EnhancedChangesList. +Hook subscribers can return false to omit this line from recentchanges. $changesList: EnhancedChangesList object &$data: An array with all the components that will be joined in order to create the line $block: An array of RecentChange objects in that block diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index fe7deb60dd..9635c1791d 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -378,8 +378,12 @@ class EnhancedChangesList extends ChangesList { $data['tags'] = $this->getTags( $rcObj, $classes ); // give the hook a chance to modify the data - Hooks::run( 'EnhancedChangesListModifyLineData', + $success = Hooks::run( 'EnhancedChangesListModifyLineData', array( $this, &$data, $block, $rcObj ) ); + if ( !$success ) { + // skip entry if hook aborted it + continue; + } $line = ''; if ( isset( $data['recentChangesFlags'] ) ) { @@ -599,8 +603,12 @@ class EnhancedChangesList extends ChangesList { $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers ); // give the hook a chance to modify the data - Hooks::run( 'EnhancedChangesListModifyBlockLineData', + $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData', array( $this, &$data, $rcObj ) ); + if ( !$success ) { + // skip entry if hook aborted it + return ''; + } $line = Html::openElement( 'table', array( 'class' => $classes ) ) . Html::openElement( 'tr' );