Used DIRECTORY_SEPARATOR instead of '/' in GitInfo.php
[lhc/web/wiklou.git] / includes / api / ApiQueryWatchlist.php
1 <?php
2 /**
3 *
4 *
5 * Created on Sep 25, 2006
6 *
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * This query action allows clients to retrieve a list of recently modified pages
29 * that are part of the logged-in user's watchlist.
30 *
31 * @ingroup API
32 */
33 class ApiQueryWatchlist extends ApiQueryGeneratorBase {
34
35 public function __construct( $query, $moduleName ) {
36 parent::__construct( $query, $moduleName, 'wl' );
37 }
38
39 public function execute() {
40 $this->run();
41 }
42
43 public function executeGenerator( $resultPageSet ) {
44 $this->run( $resultPageSet );
45 }
46
47 private $fld_ids = false, $fld_title = false, $fld_patrol = false,
48 $fld_flags = false, $fld_timestamp = false, $fld_user = false,
49 $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false,
50 $fld_notificationtimestamp = false, $fld_userid = false,
51 $fld_loginfo = false;
52
53 /**
54 * @param $resultPageSet ApiPageSet
55 * @return void
56 */
57 private function run( $resultPageSet = null ) {
58 $this->selectNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
59
60 $params = $this->extractRequestParams();
61
62 $user = $this->getUser();
63 $wlowner = $this->getWatchlistUser( $params );
64
65 if ( !is_null( $params['prop'] ) && is_null( $resultPageSet ) ) {
66 $prop = array_flip( $params['prop'] );
67
68 $this->fld_ids = isset( $prop['ids'] );
69 $this->fld_title = isset( $prop['title'] );
70 $this->fld_flags = isset( $prop['flags'] );
71 $this->fld_user = isset( $prop['user'] );
72 $this->fld_userid = isset( $prop['userid'] );
73 $this->fld_comment = isset( $prop['comment'] );
74 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
75 $this->fld_timestamp = isset( $prop['timestamp'] );
76 $this->fld_sizes = isset( $prop['sizes'] );
77 $this->fld_patrol = isset( $prop['patrol'] );
78 $this->fld_notificationtimestamp = isset( $prop['notificationtimestamp'] );
79 $this->fld_loginfo = isset( $prop['loginfo'] );
80
81 if ( $this->fld_patrol ) {
82 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
83 $this->dieUsage( 'patrol property is not available', 'patrol' );
84 }
85 }
86 }
87
88 $this->addFields( array(
89 'rc_namespace',
90 'rc_title',
91 'rc_timestamp',
92 'rc_type',
93 'rc_deleted',
94 ) );
95
96 if ( is_null( $resultPageSet ) ) {
97 $this->addFields( array(
98 'rc_cur_id',
99 'rc_this_oldid',
100 'rc_last_oldid',
101 ) );
102
103 $this->addFieldsIf( array( 'rc_type', 'rc_minor', 'rc_bot' ), $this->fld_flags );
104 $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
105 $this->addFieldsIf( 'rc_user_text', $this->fld_user );
106 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
107 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
108 $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
109 $this->addFieldsIf( 'wl_notificationtimestamp', $this->fld_notificationtimestamp );
110 $this->addFieldsIf(
111 array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ),
112 $this->fld_loginfo
113 );
114 } elseif ( $params['allrev'] ) {
115 $this->addFields( 'rc_this_oldid' );
116 } else {
117 $this->addFields( 'rc_cur_id' );
118 }
119
120 $this->addTables( array(
121 'recentchanges',
122 'watchlist',
123 ) );
124
125 $userId = $wlowner->getId();
126 $this->addJoinConds( array( 'watchlist' => array( 'INNER JOIN',
127 array(
128 'wl_user' => $userId,
129 'wl_namespace=rc_namespace',
130 'wl_title=rc_title'
131 )
132 ) ) );
133
134 $db = $this->getDB();
135
136 $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'],
137 $params['start'], $params['end'] );
138 $this->addWhereFld( 'wl_namespace', $params['namespace'] );
139
140 if ( !$params['allrev'] ) {
141 $this->addTables( 'page' );
142 $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', 'rc_cur_id=page_id' ) ) );
143 $this->addWhere( 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG );
144 }
145
146 if ( !is_null( $params['show'] ) ) {
147 $show = array_flip( $params['show'] );
148
149 /* Check for conflicting parameters. */
150 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
151 || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
152 || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
153 || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
154 ) {
155 $this->dieUsageMsg( 'show' );
156 }
157
158 // Check permissions.
159 if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
160 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
161 $this->dieUsage(
162 'You need the patrol right to request the patrolled flag',
163 'permissiondenied'
164 );
165 }
166 }
167
168 /* Add additional conditions to query depending upon parameters. */
169 $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
170 $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
171 $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
172 $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
173 $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
174 $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
175 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
176 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
177 }
178
179 if ( !is_null( $params['type'] ) ) {
180 $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
181 }
182
183 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
184 $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
185 }
186 if ( !is_null( $params['user'] ) ) {
187 $this->addWhereFld( 'rc_user_text', $params['user'] );
188 }
189 if ( !is_null( $params['excludeuser'] ) ) {
190 $this->addWhere( 'rc_user_text != ' . $db->addQuotes( $params['excludeuser'] ) );
191 }
192
193 // This is an index optimization for mysql, as done in the Special:Watchlist page
194 $this->addWhereIf(
195 "rc_timestamp > ''",
196 !isset( $params['start'] ) && !isset( $params['end'] ) && $db->getType() == 'mysql'
197 );
198
199 // Paranoia: avoid brute force searches (bug 17342)
200 if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
201 if ( !$user->isAllowed( 'deletedhistory' ) ) {
202 $bitmask = Revision::DELETED_USER;
203 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
204 $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
205 } else {
206 $bitmask = 0;
207 }
208 if ( $bitmask ) {
209 $this->addWhere( $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask" );
210 }
211 }
212
213 // LogPage::DELETED_ACTION hides the affected page, too. So hide those
214 // entirely from the watchlist, or someone could guess the title.
215 if ( !$user->isAllowed( 'deletedhistory' ) ) {
216 $bitmask = LogPage::DELETED_ACTION;
217 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
218 $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
219 } else {
220 $bitmask = 0;
221 }
222 if ( $bitmask ) {
223 $this->addWhere( $this->getDB()->makeList( array(
224 'rc_type != ' . RC_LOG,
225 $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
226 ), LIST_OR ) );
227 }
228
229 $this->addOption( 'LIMIT', $params['limit'] + 1 );
230
231 $ids = array();
232 $count = 0;
233 $res = $this->select( __METHOD__ );
234
235 foreach ( $res as $row ) {
236 if ( ++$count > $params['limit'] ) {
237 // We've reached the one extra which shows that there are
238 // additional pages to be had. Stop here...
239 $this->setContinueEnumParameter(
240 'start',
241 wfTimestamp( TS_ISO_8601, $row->rc_timestamp )
242 );
243 break;
244 }
245
246 if ( is_null( $resultPageSet ) ) {
247 $vals = $this->extractRowInfo( $row );
248 $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
249 if ( !$fit ) {
250 $this->setContinueEnumParameter( 'start',
251 wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
252 break;
253 }
254 } else {
255 if ( $params['allrev'] ) {
256 $ids[] = intval( $row->rc_this_oldid );
257 } else {
258 $ids[] = intval( $row->rc_cur_id );
259 }
260 }
261 }
262
263 if ( is_null( $resultPageSet ) ) {
264 $this->getResult()->setIndexedTagName_internal(
265 array( 'query', $this->getModuleName() ),
266 'item'
267 );
268 } elseif ( $params['allrev'] ) {
269 $resultPageSet->populateFromRevisionIDs( $ids );
270 } else {
271 $resultPageSet->populateFromPageIDs( $ids );
272 }
273 }
274
275 private function extractRowInfo( $row ) {
276 /* Determine the title of the page that has been changed. */
277 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
278 $user = $this->getUser();
279
280 /* Our output data. */
281 $vals = array();
282
283 $type = intval( $row->rc_type );
284
285 /* Determine what kind of change this was. */
286 switch ( $type ) {
287 case RC_EDIT:
288 $vals['type'] = 'edit';
289 break;
290 case RC_NEW:
291 $vals['type'] = 'new';
292 break;
293 case RC_MOVE:
294 $vals['type'] = 'move';
295 break;
296 case RC_LOG:
297 $vals['type'] = 'log';
298 break;
299 case RC_EXTERNAL:
300 $vals['type'] = 'external';
301 break;
302 case RC_MOVE_OVER_REDIRECT:
303 $vals['type'] = 'move over redirect';
304 break;
305 default:
306 $vals['type'] = $type;
307 }
308
309 $anyHidden = false;
310
311 /* Create a new entry in the result for the title. */
312 if ( $this->fld_title || $this->fld_ids ) {
313 // These should already have been filtered out of the query, but just in case.
314 if ( $type === RC_LOG && ( $row->rc_deleted & LogPage::DELETED_ACTION ) ) {
315 $vals['actionhidden'] = '';
316 $anyHidden = true;
317 }
318 if ( $type !== RC_LOG ||
319 LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user )
320 ) {
321 if ( $this->fld_title ) {
322 ApiQueryBase::addTitleInfo( $vals, $title );
323 }
324 if ( $this->fld_ids ) {
325 $vals['pageid'] = intval( $row->rc_cur_id );
326 $vals['revid'] = intval( $row->rc_this_oldid );
327 $vals['old_revid'] = intval( $row->rc_last_oldid );
328 }
329 }
330 }
331
332 /* Add user data and 'anon' flag, if user is anonymous. */
333 if ( $this->fld_user || $this->fld_userid ) {
334 if ( $row->rc_deleted & Revision::DELETED_USER ) {
335 $vals['userhidden'] = '';
336 $anyHidden = true;
337 }
338 if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
339 if ( $this->fld_userid ) {
340 $vals['userid'] = $row->rc_user;
341 // for backwards compatibility
342 $vals['user'] = $row->rc_user;
343 }
344
345 if ( $this->fld_user ) {
346 $vals['user'] = $row->rc_user_text;
347 }
348
349 if ( !$row->rc_user ) {
350 $vals['anon'] = '';
351 }
352 }
353 }
354
355 /* Add flags, such as new, minor, bot. */
356 if ( $this->fld_flags ) {
357 if ( $row->rc_bot ) {
358 $vals['bot'] = '';
359 }
360 if ( $row->rc_type == RC_NEW ) {
361 $vals['new'] = '';
362 }
363 if ( $row->rc_minor ) {
364 $vals['minor'] = '';
365 }
366 }
367
368 /* Add sizes of each revision. (Only available on 1.10+) */
369 if ( $this->fld_sizes ) {
370 $vals['oldlen'] = intval( $row->rc_old_len );
371 $vals['newlen'] = intval( $row->rc_new_len );
372 }
373
374 /* Add the timestamp. */
375 if ( $this->fld_timestamp ) {
376 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
377 }
378
379 if ( $this->fld_notificationtimestamp ) {
380 $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null )
381 ? ''
382 : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
383 }
384
385 /* Add edit summary / log summary. */
386 if ( $this->fld_comment || $this->fld_parsedcomment ) {
387 if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
388 $vals['commenthidden'] = '';
389 $anyHidden = true;
390 }
391 if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
392 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
393 $vals['comment'] = $row->rc_comment;
394 }
395
396 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
397 $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
398 }
399 }
400 }
401
402 /* Add the patrolled flag */
403 if ( $this->fld_patrol && $row->rc_patrolled == 1 ) {
404 $vals['patrolled'] = '';
405 }
406
407 if ( $this->fld_patrol && ChangesList::isUnpatrolled( $row, $user ) ) {
408 $vals['unpatrolled'] = '';
409 }
410
411 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
412 if ( $row->rc_deleted & LogPage::DELETED_ACTION ) {
413 $vals['actionhidden'] = '';
414 $anyHidden = true;
415 }
416 if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) {
417 $vals['logid'] = intval( $row->rc_logid );
418 $vals['logtype'] = $row->rc_log_type;
419 $vals['logaction'] = $row->rc_log_action;
420 $logEntry = DatabaseLogEntry::newFromRow( (array)$row );
421 ApiQueryLogEvents::addLogParams(
422 $this->getResult(),
423 $vals,
424 $logEntry->getParameters(),
425 $logEntry->getType(),
426 $logEntry->getSubtype(),
427 $logEntry->getTimestamp()
428 );
429 }
430 }
431
432 if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
433 $vals['suppressed'] = '';
434 }
435
436 return $vals;
437 }
438
439 /** Copied from ApiQueryRecentChanges.
440 *
441 * @param string $type
442 * @return string
443 */
444 private function parseRCType( $type ) {
445 if ( is_array( $type ) ) {
446 $retval = array();
447 foreach ( $type as $t ) {
448 $retval[] = $this->parseRCType( $t );
449 }
450
451 return $retval;
452 }
453
454 switch ( $type ) {
455 case 'edit':
456 return RC_EDIT;
457 case 'new':
458 return RC_NEW;
459 case 'log':
460 return RC_LOG;
461 case 'external':
462 return RC_EXTERNAL;
463 default:
464 ApiBase::dieDebug( __METHOD__, "Unknown type '$type'" );
465 }
466 }
467
468 public function getAllowedParams() {
469 return array(
470 'allrev' => false,
471 'start' => array(
472 ApiBase::PARAM_TYPE => 'timestamp'
473 ),
474 'end' => array(
475 ApiBase::PARAM_TYPE => 'timestamp'
476 ),
477 'namespace' => array(
478 ApiBase::PARAM_ISMULTI => true,
479 ApiBase::PARAM_TYPE => 'namespace'
480 ),
481 'user' => array(
482 ApiBase::PARAM_TYPE => 'user',
483 ),
484 'excludeuser' => array(
485 ApiBase::PARAM_TYPE => 'user',
486 ),
487 'dir' => array(
488 ApiBase::PARAM_DFLT => 'older',
489 ApiBase::PARAM_TYPE => array(
490 'newer',
491 'older'
492 )
493 ),
494 'limit' => array(
495 ApiBase::PARAM_DFLT => 10,
496 ApiBase::PARAM_TYPE => 'limit',
497 ApiBase::PARAM_MIN => 1,
498 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
499 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
500 ),
501 'prop' => array(
502 ApiBase::PARAM_ISMULTI => true,
503 ApiBase::PARAM_DFLT => 'ids|title|flags',
504 ApiBase::PARAM_TYPE => array(
505 'ids',
506 'title',
507 'flags',
508 'user',
509 'userid',
510 'comment',
511 'parsedcomment',
512 'timestamp',
513 'patrol',
514 'sizes',
515 'notificationtimestamp',
516 'loginfo',
517 )
518 ),
519 'show' => array(
520 ApiBase::PARAM_ISMULTI => true,
521 ApiBase::PARAM_TYPE => array(
522 'minor',
523 '!minor',
524 'bot',
525 '!bot',
526 'anon',
527 '!anon',
528 'patrolled',
529 '!patrolled',
530 )
531 ),
532 'type' => array(
533 ApiBase::PARAM_ISMULTI => true,
534 ApiBase::PARAM_TYPE => array(
535 'edit',
536 'external',
537 'new',
538 'log',
539 )
540 ),
541 'owner' => array(
542 ApiBase::PARAM_TYPE => 'user'
543 ),
544 'token' => array(
545 ApiBase::PARAM_TYPE => 'string'
546 ),
547 );
548 }
549
550 public function getParamDescription() {
551 $p = $this->getModulePrefix();
552
553 return array(
554 'allrev' => 'Include multiple revisions of the same page within given timeframe',
555 'start' => 'The timestamp to start enumerating from',
556 'end' => 'The timestamp to end enumerating',
557 'namespace' => 'Filter changes to only the given namespace(s)',
558 'user' => 'Only list changes by this user',
559 'excludeuser' => 'Don\'t list changes by this user',
560 'dir' => $this->getDirectionDescription( $p ),
561 'limit' => 'How many total results to return per request',
562 'prop' => array(
563 'Which additional items to get (non-generator mode only).',
564 ' ids - Adds revision ids and page ids',
565 ' title - Adds title of the page',
566 ' flags - Adds flags for the edit',
567 ' user - Adds the user who made the edit',
568 ' userid - Adds user id of whom made the edit',
569 ' comment - Adds comment of the edit',
570 ' parsedcomment - Adds parsed comment of the edit',
571 ' timestamp - Adds timestamp of the edit',
572 ' patrol - Tags edits that are patrolled',
573 ' sizes - Adds the old and new lengths of the page',
574 ' notificationtimestamp - Adds timestamp of when the user was last notified about the edit',
575 ' loginfo - Adds log information where appropriate',
576 ),
577 'show' => array(
578 'Show only items that meet this criteria.',
579 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon"
580 ),
581 'type' => array(
582 'Which types of changes to show',
583 ' edit - Regular page edits',
584 ' external - External changes',
585 ' new - Page creations',
586 ' log - Log entries',
587 ),
588 'owner' => 'The name of the user whose watchlist you\'d like to access',
589 'token' => 'Give a security token (settable in preferences) to ' .
590 'allow access to another user\'s watchlist',
591 );
592 }
593
594 public function getResultProperties() {
595 global $wgLogTypes;
596
597 return array(
598 '' => array(
599 'type' => array(
600 ApiBase::PROP_TYPE => array(
601 'edit',
602 'new',
603 'move',
604 'log',
605 'move over redirect'
606 )
607 )
608 ),
609 'ids' => array(
610 'pageid' => 'integer',
611 'revid' => 'integer',
612 'old_revid' => 'integer'
613 ),
614 'title' => array(
615 'ns' => 'namespace',
616 'title' => 'string'
617 ),
618 'user' => array(
619 'user' => 'string',
620 'anon' => 'boolean'
621 ),
622 'userid' => array(
623 'userid' => 'integer',
624 'anon' => 'boolean'
625 ),
626 'flags' => array(
627 'new' => 'boolean',
628 'minor' => 'boolean',
629 'bot' => 'boolean'
630 ),
631 'patrol' => array(
632 'patrolled' => 'boolean'
633 ),
634 'timestamp' => array(
635 'timestamp' => 'timestamp'
636 ),
637 'sizes' => array(
638 'oldlen' => 'integer',
639 'newlen' => 'integer'
640 ),
641 'notificationtimestamp' => array(
642 'notificationtimestamp' => array(
643 ApiBase::PROP_TYPE => 'timestamp',
644 ApiBase::PROP_NULLABLE => true
645 )
646 ),
647 'comment' => array(
648 'comment' => array(
649 ApiBase::PROP_TYPE => 'string',
650 ApiBase::PROP_NULLABLE => true
651 )
652 ),
653 'parsedcomment' => array(
654 'parsedcomment' => array(
655 ApiBase::PROP_TYPE => 'string',
656 ApiBase::PROP_NULLABLE => true
657 )
658 ),
659 'loginfo' => array(
660 'logid' => array(
661 ApiBase::PROP_TYPE => 'integer',
662 ApiBase::PROP_NULLABLE => true
663 ),
664 'logtype' => array(
665 ApiBase::PROP_TYPE => $wgLogTypes,
666 ApiBase::PROP_NULLABLE => true
667 ),
668 'logaction' => array(
669 ApiBase::PROP_TYPE => 'string',
670 ApiBase::PROP_NULLABLE => true
671 )
672 )
673 );
674 }
675
676 public function getDescription() {
677 return "Get all recent changes to pages in the logged in user's watchlist";
678 }
679
680 public function getPossibleErrors() {
681 return array_merge( parent::getPossibleErrors(), array(
682 array( 'code' => 'bad_wlowner', 'info' => 'Specified user does not exist' ),
683 array(
684 'code' => 'bad_wltoken',
685 'info' => 'Incorrect watchlist token provided -- ' .
686 'please set a correct token in Special:Preferences'
687 ),
688 array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ),
689 array( 'code' => 'patrol', 'info' => 'patrol property is not available' ),
690 array( 'show' ),
691 array(
692 'code' => 'permissiondenied',
693 'info' => 'You need the patrol right to request the patrolled flag'
694 ),
695 array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ),
696 ) );
697 }
698
699 public function getExamples() {
700 return array(
701 'api.php?action=query&list=watchlist',
702 'api.php?action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment',
703 'api.php?action=query&list=watchlist&wlallrev=&wlprop=ids|title|timestamp|user|comment',
704 'api.php?action=query&generator=watchlist&prop=info',
705 'api.php?action=query&generator=watchlist&gwlallrev=&prop=revisions&rvprop=timestamp|user',
706 'api.php?action=query&list=watchlist&wlowner=Bob_Smith&wltoken=123ABC'
707 );
708 }
709
710 public function getHelpUrls() {
711 return 'https://www.mediawiki.org/wiki/API:Watchlist';
712 }
713 }