Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -51,7 +51,6 @@ |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function run($resultPageSet = null) { |
55 | | - |
56 | 55 | $db = $this->getDB(); |
57 | 56 | |
58 | 57 | $params = $this->extractRequestParams(); |
— | — | @@ -97,6 +96,29 @@ |
98 | 97 | $this->dieUsage('prlevel may not be used without prtype', 'params'); |
99 | 98 | } |
100 | 99 | |
| 100 | + // Only allow watched page filtering if the user has the 'unwatchedpages' permission |
| 101 | + // $wgMiserMode disables this |
| 102 | + global $wgUser, $wgMiserMode; |
| 103 | + if ($wgUser->isAllowed('unwatchedpages') && !$wgMiserMode) { |
| 104 | + if($params['filterwatched'] != 'all') { |
| 105 | + $this->addTables('watchlist'); |
| 106 | + $this->addJoinConds(array('watchlist' => array('LEFT JOIN', array( |
| 107 | + 'wl_namespace = page_namespace', |
| 108 | + 'wl_title = page_title')))); |
| 109 | + } |
| 110 | + if($params['filterwatched'] == 'unwatched') { |
| 111 | + $this->addWhere('wl_title IS NULL'); |
| 112 | + } |
| 113 | + else if ($params['filterwatched'] == 'watched') { |
| 114 | + $this->addWhere('wl_title IS NOT NULL'); |
| 115 | + } |
| 116 | + } |
| 117 | + else if($params['filterwatched'] != 'all') { |
| 118 | + if($wgMiserMode) |
| 119 | + $this->setWarning('apfilterwatched is disabled on this wiki for performance reasons'); |
| 120 | + else |
| 121 | + $this->setWarning('You don\'t have permission to filter by watched status'); |
| 122 | + } |
101 | 123 | if($params['filterlanglinks'] == 'withoutlanglinks') { |
102 | 124 | $this->addTables('langlinks'); |
103 | 125 | $this->addJoinConds(array('langlinks' => array('LEFT JOIN', 'page_id=ll_from'))); |
— | — | @@ -108,7 +130,7 @@ |
109 | 131 | $forceNameTitleIndex = false; |
110 | 132 | } |
111 | 133 | if ($forceNameTitleIndex) |
112 | | - $this->addOption('USE INDEX', 'name_title'); |
| 134 | + $this->addOption('USE INDEX', array('page' => 'name_title')); |
113 | 135 | |
114 | 136 | if (is_null($resultPageSet)) { |
115 | 137 | $this->addFields(array ( |
— | — | @@ -206,6 +228,14 @@ |
207 | 229 | 'all' |
208 | 230 | ), |
209 | 231 | ApiBase :: PARAM_DFLT => 'all' |
| 232 | + ), |
| 233 | + 'filterwatched' => array( |
| 234 | + ApiBase :: PARAM_TYPE => array( |
| 235 | + 'watched', |
| 236 | + 'unwatched', |
| 237 | + 'all' |
| 238 | + ), |
| 239 | + ApiBase :: PARAM_DFLT => 'all' |
210 | 240 | ) |
211 | 241 | ); |
212 | 242 | } |
— | — | @@ -222,6 +252,7 @@ |
223 | 253 | 'prtype' => 'Limit to protected pages only', |
224 | 254 | 'prlevel' => 'The protection level (must be used with apprtype= parameter)', |
225 | 255 | 'filterlanglinks' => 'Filter based on whether a page has langlinks', |
| 256 | + 'filterwatched' => 'Filter based on whther a page is watched (requires \'unwatchedpages\' right)', |
226 | 257 | 'limit' => 'How many total pages to return.' |
227 | 258 | ); |
228 | 259 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -530,6 +530,7 @@ |
531 | 531 | * Added flag "top" to list=usercontribs if the user is the last contributor to |
532 | 532 | the page |
533 | 533 | * list=exturlusage in "list all links" mode can now filter by protocol |
| 534 | +* (bug 14020) Added apfilterwatched parameter to list=allpages |
534 | 535 | |
535 | 536 | === Languages updated in 1.13 === |
536 | 537 | |