Index: trunk/extensions/CollabWatchlist/CollabWatchlist.php |
— | — | @@ -36,15 +36,30 @@ |
37 | 37 | $wgHooks['GetPreferences'][] = 'fnCollabWatchlistPreferences'; |
38 | 38 | |
39 | 39 | function fnCollabWatchlistDbSchema() { |
40 | | - global $wgExtNewTables; |
41 | | - $wgSql = dirname( __FILE__ ) . '/sql/'; |
42 | | - $wgExtNewTables[] = array( 'collabwatchlist', $wgSql . 'collabwatchlist.sql' ); |
43 | | - $wgExtNewTables[] = array( 'collabwatchlistuser', $wgSql . 'collabwatchlistuser.sql' ); |
44 | | - $wgExtNewTables[] = array( 'collabwatchlistcategory', $wgSql . 'collabwatchlistcategory.sql' ); |
45 | | - $wgExtNewTables[] = array( 'collabwatchlistrevisiontag', $wgSql . 'collabwatchlistrevisiontag.sql' ); |
46 | | - $wgExtNewTables[] = array( 'collabwatchlisttag', $wgSql . 'collabwatchlisttag.sql' ); |
47 | | - $wgExtNewFields[] = array( 'change_tag', 'ct_id', $wgSql . 'patch-change_tag_id.sql' ); |
48 | | - return true; |
| 40 | + $wgSql = dirname(__FILE__) . '/sql/'; |
| 41 | + if ( $updater === null ) { // <= 1.16 support |
| 42 | + global $wgExtNewTables; |
| 43 | + $wgExtNewTables[] = array('collabwatchlist', $wgSql . 'collabwatchlist.sql'); |
| 44 | + $wgExtNewTables[] = array('collabwatchlistuser', $wgSql . 'collabwatchlistuser.sql'); |
| 45 | + $wgExtNewTables[] = array('collabwatchlistcategory', $wgSql . 'collabwatchlistcategory.sql'); |
| 46 | + $wgExtNewTables[] = array('collabwatchlistrevisiontag', $wgSql . 'collabwatchlistrevisiontag.sql'); |
| 47 | + $wgExtNewTables[] = array('collabwatchlisttag', $wgSql . 'collabwatchlisttag.sql'); |
| 48 | + $wgExtNewFields[] = array('change_tag', 'ct_id', $wgSql . 'patch-change_tag_id.sql'); |
| 49 | + } else { // >= 1.17 support |
| 50 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlist', |
| 51 | + $wgSql . 'collabwatchlist.sql', true ) ); |
| 52 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistuser', |
| 53 | + $wgSql . 'collabwatchlistuser.sql', true ) ); |
| 54 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistcategory', |
| 55 | + $wgSql . 'collabwatchlistcategory.sql', true ) ); |
| 56 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistrevisiontag', |
| 57 | + $wgSql . 'collabwatchlistrevisiontag.sql', true ) ); |
| 58 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlisttag', |
| 59 | + $wgSql . 'collabwatchlisttag.sql', true ) ); |
| 60 | + $updater->addExtensionUpdate( array( 'modifyField', 'change_tag', 'ct_id', |
| 61 | + $wgSql . 'patch-change_tag_id.sql', true ) ); |
| 62 | + } |
| 63 | + return true; |
49 | 64 | } |
50 | 65 | |
51 | 66 | function fnCollabWatchlistPreferences( $user, &$preferences ) { |
Index: trunk/extensions/CollabWatchlist/includes/SpecialCollabWatchlist.php |
— | — | @@ -1,9 +1,35 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Implements Special:CollabWatchlist |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation; either version 2 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License along |
| 17 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | + * http://www.gnu.org/copyleft/gpl.html |
| 20 | + * |
| 21 | + * @file |
| 22 | + * @ingroup SpecialPage CollabWatchlist |
| 23 | + */ |
3 | 24 | class SpecialCollabWatchlist extends SpecialPage { |
4 | 25 | function __construct() { |
5 | 26 | parent::__construct( 'CollabWatchlist' ); |
6 | 27 | } |
7 | 28 | |
| 29 | + /** |
| 30 | + * Main execution point |
| 31 | + * |
| 32 | + * @param $par Parameter passed to the page |
| 33 | + */ |
8 | 34 | function execute( $par ) { |
9 | 35 | global $wgUser, $wgOut, $wgLang, $wgRequest; |
10 | 36 | global $wgRCShowWatchingUsers; |
— | — | @@ -433,8 +459,14 @@ |
434 | 460 | |
435 | 461 | return wfMsgHtml( $message, $skin->linkKnown( $title, $label, array(), $options ) ); |
436 | 462 | } |
437 | | - |
438 | | - |
| 463 | + |
| 464 | + /** |
| 465 | + * Creates a link for the days query parameter with hours |
| 466 | + * @param $h The number of hours |
| 467 | + * @param $page String: The name of the target page for the link |
| 468 | + * @param $options Mixed: Additional query parameters |
| 469 | + * @return String: Html for the link |
| 470 | + */ |
439 | 471 | function wlHoursLink( $h, $page, $options = array() ) { |
440 | 472 | global $wgUser, $wgLang, $wgContLang; |
441 | 473 | |
— | — | @@ -452,6 +484,13 @@ |
453 | 485 | return $s; |
454 | 486 | } |
455 | 487 | |
| 488 | + /** |
| 489 | + * Creates a link for the days query parameter with days |
| 490 | + * @param $d The number of days |
| 491 | + * @param $page String: The name of the target page for the link |
| 492 | + * @param $options Mixed: Additional query parameters |
| 493 | + * @return String: Html for the link |
| 494 | + */ |
456 | 495 | function wlDaysLink( $d, $page, $options = array() ) { |
457 | 496 | global $wgUser, $wgLang, $wgContLang; |
458 | 497 | |
— | — | @@ -559,6 +598,16 @@ |
560 | 599 | return $tags; |
561 | 600 | } |
562 | 601 | |
| 602 | + /** |
| 603 | + * Constructs the filter SQL clause for the given collaborative watchlist ids. |
| 604 | + * It filters entries which are not relevant for the given watchlists. I.e. |
| 605 | + * entries which don't belong to a category and are not listed explicitly as a |
| 606 | + * page for one of the given watchlists. |
| 607 | + * @param $rl_ids Array: A list of collaborative watchlist ids |
| 608 | + * @param $catNameCol String: The name of the column containing category names |
| 609 | + * @param $pageIdCol String: The name of the column containing page ids |
| 610 | + * @return String: An SQL clause usable in the conditions parameter of $db->select() |
| 611 | + */ |
563 | 612 | function wlGetFilterClauseForCollabWatchlistIds( $rl_ids, $catNameCol, $pageIdCol ) { |
564 | 613 | $excludedCatPageIds = array(); |
565 | 614 | $includedCatPageIds = array(); |
— | — | @@ -583,7 +632,7 @@ |
584 | 633 | $includedPageIds[$row->cat_page_id] = $row->page_title; |
585 | 634 | } |
586 | 635 | } |
587 | | - |
| 636 | + |
588 | 637 | if ( $includedCatPageIds ) { |
589 | 638 | $catTree = new CategoryTreeManip(); |
590 | 639 | $catTree->initialiseFromCategoryNames( array_values( $includedCatPageIds ) ); |
— | — | @@ -601,7 +650,13 @@ |
602 | 651 | } |
603 | 652 | return $collabWatchlistClause; |
604 | 653 | } |
605 | | - |
| 654 | + |
| 655 | + /** |
| 656 | + * Constructs the user filter SQL clause for the given collaborative watchlist ids. |
| 657 | + * It filters entries from the users of the given watchlists. |
| 658 | + * @param $rl_ids Array: A list of collaborative watchlist ids |
| 659 | + * @return String: An SQL clause usable in the conditions parameter of $db->select() |
| 660 | + */ |
606 | 661 | function wlGetFilterClauseListUser( $rl_id ) { |
607 | 662 | $excludedUserIds = array(); |
608 | 663 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -620,6 +675,12 @@ |
621 | 676 | return $clause; |
622 | 677 | } |
623 | 678 | |
| 679 | + /** |
| 680 | + * Runs $db->addQuotes() for each of the strings |
| 681 | + * @param $db Database: The db object to use |
| 682 | + * @param $strings Array: A list of strings to quote |
| 683 | + * @return Array: The $strings quoted by $db->addQuotes() |
| 684 | + */ |
624 | 685 | public static function addQuotes( $db, $strings ) { |
625 | 686 | $result = array(); |
626 | 687 | foreach ( $strings as $string ) { |
Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistEditor.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | $toWatch = array_diff( $wanted, $current ); |
68 | 68 | $toUnwatch = array_diff( $current, $wanted ); |
69 | 69 | $toWatch = $this->watchTitles( $toWatch, $rlId ); |
70 | | - $this->unwatchTitles( $toUnwatch, $rlId ); |
| 70 | + $this->unwatchTitles( $toUnwatch, $rlId, $wgUser ); |
71 | 71 | if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) |
72 | 72 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-raw-done', 'parse' ) ); |
73 | 73 | if ( ( $count = count( $toWatch ) ) > 0 ) { |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | break; |
170 | 170 | } |
171 | 171 | $titles = $this->extractCollabWatchlistCategories( $request->getArray( 'titles' ) ); |
172 | | - $this->unwatchTitles( $titles, $rlId ); |
| 172 | + $this->unwatchTitles( $titles, $rlId, $wgUser ); |
173 | 173 | $output->addHTML( wfMsgExt( 'collabwatchlistedit-normal-done', 'parse', |
174 | 174 | $GLOBALS['wgLang']->formatNum( count( $titles ) ) ) ); |
175 | 175 | $this->showTitles( $titles, $output, $wgUser->getSkin() ); |
— | — | @@ -863,7 +863,7 @@ |
864 | 864 | * @param $titles An array of strings |
865 | 865 | * @param $rlId The id of the collaborative watchlist |
866 | 866 | */ |
867 | | - private function unwatchTitles( $titles, $rlId ) { |
| 867 | + private function unwatchTitles( $titles, $rlId, $user ) { |
868 | 868 | $dbw = wfGetDB( DB_MASTER ); |
869 | 869 | foreach ( $titles as $title ) { |
870 | 870 | $subtract = false; |