*Replace crappy BeforeWatchlist hook
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 21 Dec 2008 21:31:06 +0000 (21:31 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 21 Dec 2008 21:31:06 +0000 (21:31 +0000)
*Updated LQT accordingly
*Will add flaggedrevs function to this shortly

docs/hooks.txt
includes/specials/SpecialWatchlist.php

index 41f5587..8f34d95 100644 (file)
@@ -505,13 +505,6 @@ rendered inline in wiki pages or galleries in category pages.
 &$parser: Parser object
 &$ig: ImageGallery object
 
-'BeforeWatchlist': Override watchlist display or add extra SQL clauses.
-$nondefaults: Assoc array with the following keys:
-              days, hideOwn, hideBots, hideMinor, namespace
-$wgUser: wgUser.
-&$hookSql: a string which will be inserted without sanitation into the SQL query
-           used to get the watchlist, at the end of the WHERE part.
-
 'BlockIp': before an IP address or user is blocked
 $block: the Block object about to be saved
 $user: the user _doing_ the block (not the one being blocked)
@@ -1239,7 +1232,7 @@ $list: list (array) of core special pages
 $opts: FormOptions for this request
 
 'SpecialRecentChangesQuery': called when building sql query for SpecialRecentChanges
-&$conds: array of where conditionals for query
+&$conds: array of WHERE conditionals for query
 &$tables: array of tables to be queried
 &$join_conds: join conditions for the tables
 $opts: FormOptions for this request
@@ -1258,6 +1251,12 @@ $term: string of search term
 'SpecialVersionExtensionTypes': called when generating the extensions credits, use this to change the tables headers
 $extTypes: associative array of extensions types
 
+'SpecialWatchlistQuery': called when building sql query for SpecialWatchlist
+&$conds: array of WHERE conditionals for query
+&$tables: array of tables to be queried
+&$join_conds: join conditions for the tables
+&$fields: array of query fields
+
 'TitleArrayFromResult': called when creating an TitleArray object from a database result
 &$titleArray: set this to an object to override the default object returned
 $res: database result used to create the object
index a25ec25..61dd6b3 100644 (file)
@@ -128,17 +128,12 @@ function wfSpecialWatchlist( $par ) {
        wfAppendToArrayIfNotDefault( 'namespace', $nameSpace     , $defaults, $nondefaults);
        wfAppendToArrayIfNotDefault( 'hidePatrolled', (int)$hidePatrolled, $defaults, $nondefaults );
 
-       $hookSql = "";
-       if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) {
-               return;
-       }
-
-       if($nitems == 0) {
+       if( $nitems == 0 ) {
                $wgOut->addWikiMsg( 'nowatchlist' );
                return;
        }
 
-       if ( $days <= 0 ) {
+       if( $days <= 0 ) {
                $andcutoff = '';
        } else {
                $andcutoff = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
@@ -217,7 +212,8 @@ function wfSpecialWatchlist( $par ) {
        if( $andHideAnons ) $conds[] = $andHideAnons;
        if( $andHidePatrolled ) $conds[] = $andHidePatrolled;
        if( $nameSpaceClause ) $conds[] = $nameSpaceClause;
-       if( $hookSql ) $conds[] = $hookSql;
+       
+       wfRunHooks('SpecialWatchlistQuery', array(&$conds,&$tables,&$join_conds,&$fields) );
        
        $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
        $numRows = $dbr->numRows( $res );