| Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_primary_keys.sql |
| — | — | @@ -0,0 +1,8 @@ |
| | 2 | +-- Remove unnecessary primary key columns |
| | 3 | + |
| | 4 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistcategory |
| | 5 | + DROP COLUMN rlc_id; |
| | 6 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag |
| | 7 | + DROP COLUMN rrt_id; |
| | 8 | +ALTER TABLE /*$wgDBprefix*/collabwatchlisttag |
| | 9 | + DROP COLUMN rt_id; |
| Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_primary_keys.sql |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 10 | + native |
| Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_rename_fields.sql |
| — | — | @@ -0,0 +1,20 @@ |
| | 2 | +-- Rename misnamed fields |
| | 3 | + |
| | 4 | +ALTER TABLE /*$wgDBprefix*/collabwatchlist |
| | 5 | + CHANGE rl_id cw_id integer unsigned NOT NULL AUTO_INCREMENT; |
| | 6 | +ALTER TABLE /*$wgDBprefix*/collabwatchlist |
| | 7 | + CHANGE rl_name cw_name varbinary(255) NOT NULL; |
| | 8 | +ALTER TABLE /*$wgDBprefix*/collabwatchlist |
| | 9 | + CHANGE rl_start cw_start binary(14) NOT NULL default ''; |
| | 10 | + |
| | 11 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag |
| | 12 | + CHANGE rl_id cw_id integer unsigned NOT NULL; |
| | 13 | + |
| | 14 | +ALTER TABLE /*$wgDBprefix*/collabwatchlisttag |
| | 15 | + CHANGE rl_id cw_id integer unsigned NOT NULL; |
| | 16 | + |
| | 17 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistuser |
| | 18 | + CHANGE rl_id cw_id integer unsigned NOT NULL; |
| | 19 | + |
| | 20 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistcategory |
| | 21 | + CHANGE rl_id cw_id integer unsigned NOT NULL; |
| Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_rename_fields.sql |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 22 | + native |
| Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistrevisiontag.sql |
| — | — | @@ -3,21 +3,21 @@ |
| 4 | 4 | -- Replace /*$wgDBprefix*/ with the proper prefix |
| 5 | 5 | -- Replace /*$wgDBTableOptions*/ with the correct options |
| 6 | 6 | |
| | 7 | +-- Associates a specific tag (ct_tag) with a recent changes entry (ct_rc_id) |
| | 8 | +-- and a specific collabwatchlist (cw_id) |
| 7 | 9 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistrevisiontag ( |
| 8 | | - -- The id of this entry |
| 9 | | - rrt_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 10 | 10 | -- See change_tag.ct_tag |
| 11 | 11 | ct_tag varbinary(255) NOT NULL, |
| 12 | 12 | -- See change_tag.ct_rc_id |
| 13 | 13 | ct_rc_id int NOT NULL default 0, |
| 14 | | - -- Foreign key to collabwatchlist.rl_id |
| 15 | | - rl_id integer unsigned NOT NULL, |
| | 14 | + -- Foreign key to collabwatchlist.cw_id |
| | 15 | + cw_id integer unsigned NOT NULL, |
| 16 | 16 | -- Foreign key to user.user_id |
| 17 | 17 | user_id int(10) unsigned NOT NULL, |
| 18 | 18 | |
| 19 | 19 | -- Comment for the tag |
| 20 | | - rrt_comment varchar(255), |
| | 20 | + rrt_comment varchar(255) |
| 21 | 21 | |
| 22 | | - UNIQUE KEY (ct_tag, ct_rc_id, rl_id) |
| 23 | 22 | ) /*$wgDBTableOptions*/; |
| | 23 | + |
| | 24 | +CREATE UNIQUE INDEX ct_tag on /*$wgDBprefix*/collabwatchlistrevisiontag (ct_tag, ct_rc_id, cw_id); |
| \ No newline at end of file |
| Index: trunk/extensions/CollabWatchlist/sql/collabwatchlisttag.sql |
| — | — | @@ -3,16 +3,15 @@ |
| 4 | 4 | -- Replace /*$wgDBprefix*/ with the proper prefix |
| 5 | 5 | -- Replace /*$wgDBTableOptions*/ with the correct options |
| 6 | 6 | |
| | 7 | +-- Add table defining the tags which are allowed on a collab watchlist |
| 7 | 8 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlisttag ( |
| 8 | | - -- The id of this entry |
| 9 | | - rt_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 10 | | - -- Foreign key to collabwatchlist.rl_id |
| 11 | | - rl_id integer unsigned NOT NULL, |
| | 9 | + -- Foreign key to collabwatchlist.cw_id |
| | 10 | + cw_id integer unsigned NOT NULL, |
| 12 | 11 | -- The name of the collabwatchlist tag (unique) |
| 13 | 12 | rt_name varbinary(255) NOT NULL, |
| 14 | 13 | -- Description of the tag |
| 15 | | - rt_description tinyblob NOT NULL default '', |
| | 14 | + rt_description tinyblob NOT NULL default '' |
| 16 | 15 | |
| 17 | | - UNIQUE KEY (rl_id, rt_name) |
| 18 | | -) /*$wgDBTableOptions*/; |
| \ No newline at end of file |
| | 16 | +) /*$wgDBTableOptions*/; |
| | 17 | + |
| | 18 | +CREATE UNIQUE INDEX cw_id ON /*$wgDBprefix*/collabwatchlisttag (cw_id, rt_name); |
| \ No newline at end of file |
| Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_noctid.sql |
| — | — | @@ -1,6 +1,4 @@ |
| 2 | 2 | -- Remove the ct_id column which was introduced in a previous revision |
| 3 | 3 | |
| 4 | 4 | ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag |
| 5 | 5 | ADD ct_tag varbinary(255) NOT NULL; |
| Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistcategory.sql |
| — | — | @@ -5,10 +5,8 @@ |
| 6 | 6 | |
| 7 | 7 | -- Add table defining the categories for collaborative watchlists |
| 8 | 8 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistcategory ( |
| 9 | | - -- The id of this entry |
| 10 | | - rlc_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 11 | | - -- Foreign key to collabwatchlist.rl_id |
| 12 | | - rl_id integer unsigned NOT NULL, |
| | 9 | + -- Foreign key to collabwatchlist.cw_id |
| | 10 | + cw_id integer unsigned NOT NULL, |
| 13 | 11 | -- Foreign key to page.page_id |
| 14 | 12 | cat_page_id integer unsigned NOT NULL, |
| 15 | 13 | -- Whether the category is subtracted from or added to the collaborative watchlist |
| Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_enum.sql |
| — | — | @@ -0,0 +1,15 @@ |
| | 2 | +-- Remove enums |
| | 3 | + |
| | 4 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistuser |
| | 5 | + ADD COLUMN rlu_type_new integer NOT NULL DEFAULT 1; |
| | 6 | +UPDATE /*$wgDBprefix*/collabwatchlistuser |
| | 7 | + SET rlu_type_new = 1 WHERE rlu_type = 'OWNER' OR rlu_type = 1; |
| | 8 | +UPDATE /*$wgDBprefix*/collabwatchlistuser |
| | 9 | + SET rlu_type_new = 2 WHERE rlu_type = 'USER' OR rlu_type = 2; |
| | 10 | +UPDATE /*$wgDBprefix*/collabwatchlistuser |
| | 11 | + SET rlu_type_new = 3 WHERE rlu_type = 'TRUSTED_EDITOR' OR rlu_type = 3; |
| | 12 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistuser |
| | 13 | + DROP COLUMN rlu_type; |
| | 14 | +ALTER TABLE /*$wgDBprefix*/collabwatchlistuser |
| | 15 | + CHANGE rlu_type_new rlu_type integer NOT NULL DEFAULT 1; |
| | 16 | + |
| Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_enum.sql |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 17 | + native |
| Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistuser.sql |
| — | — | @@ -7,11 +7,12 @@ |
| 8 | 8 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistuser ( |
| 9 | 9 | -- The id of this entry |
| 10 | 10 | rlu_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 11 | | - -- Foreign key to collabwatchlist.rl_id |
| 12 | | - rl_id integer unsigned NOT NULL, |
| | 11 | + -- Foreign key to collabwatchlist.cw_id |
| | 12 | + cw_id integer unsigned NOT NULL, |
| 13 | 13 | -- Foreign key to user.user_id |
| 14 | 14 | user_id int(10) unsigned NOT NULL, |
| 15 | | - |
| 16 | 15 | -- Type of user |
| 17 | | - rlu_type ENUM("OWNER", "USER", "TRUSTED_EDITOR") DEFAULT "OWNER" |
| 18 | | -) /*$wgDBTableOptions*/; |
| \ No newline at end of file |
| | 16 | + rlu_type integer NOT NULL DEFAULT 1 |
| | 17 | +) /*$wgDBTableOptions*/; |
| | 18 | + |
| | 19 | +CREATE UNIQUE INDEX rl_id ON /*$wgDBprefix*/collabwatchlistuser (rl_id, user_id); |
| \ No newline at end of file |
| Index: trunk/extensions/CollabWatchlist/sql/collabwatchlist.sql |
| — | — | @@ -7,11 +7,11 @@ |
| 8 | 8 | -- Add table defining a collaborative watchlist |
| 9 | 9 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlist ( |
| 10 | 10 | -- The id of the collaborative watchlist |
| 11 | | - rl_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| | 11 | + cw_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 12 | 12 | -- The name of the collaborative watchlist (unique) |
| 13 | | - rl_name varbinary(255) NOT NULL, |
| | 13 | + cw_name varbinary(255) NOT NULL, |
| 14 | 14 | -- Starting date in standard YMDHMS form. |
| 15 | | - rl_start binary(14) NOT NULL default '', |
| | 15 | + cw_start binary(14) NOT NULL default '' |
| | 16 | +) /*$wgDBTableOptions*/; |
| 16 | 17 | |
| 17 | | - UNIQUE KEY (rl_name) |
| 18 | | -) /*$wgDBTableOptions*/; |
| \ No newline at end of file |
| | 18 | +CREATE UNIQUE INDEX cw_name ON /*$wgDBprefix*/collabwatchlist (cw_name); |
| Index: trunk/extensions/CollabWatchlist/tests/CollabWatchlistTest.php |
| — | — | @@ -1,6 +1,9 @@ |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | 4 | class CollabWatchlistTest extends PHPUnit_Framework_TestCase { |
| | 5 | + protected function setUp() { |
| | 6 | + $this->markTestSkipped('Manually only'); |
| | 7 | + } |
| 5 | 8 | public function testCategoryTree() { |
| 6 | 9 | /* Workaround for eclipse xdebug |
| 7 | 10 | $path = '/usr/share/php'; |
| Index: trunk/extensions/CollabWatchlist/CollabWatchlist.php |
| — | — | @@ -8,6 +8,26 @@ |
| 9 | 9 | exit( 1 ); |
| 10 | 10 | } |
| 11 | 11 | |
| | 12 | +/** |
| | 13 | + * Toggles the recursive category scan. If you disable that, users |
| | 14 | + * will not be able to watch edits on pages belonging to subcategories |
| | 15 | + * of categories on their collaborative watchlist. |
| | 16 | + * You might want to disable that, as it causes quite a bit of database |
| | 17 | + * and (if enabled) cache load and size. |
| | 18 | + */ |
| | 19 | +$wgCollabWatchlistRecursiveCatScan = true; |
| | 20 | +/** |
| | 21 | + * The depth of the category tree we are building. |
| | 22 | + * This is only relevant if $wgCollabWatchlistRecursiveCatScan is enabled |
| | 23 | + * -1 means infinite |
| | 24 | + * 0 fetches no child categories at all |
| | 25 | + */ |
| | 26 | +$wgCollabWatchlistRecursiveCatMaxDepth = -1; |
| | 27 | +/** |
| | 28 | + * The name of the page to show to users who don't have the necessary |
| | 29 | + * privileges to show a page belonging to this extension. |
| | 30 | + */ |
| | 31 | +$wgCollabWatchlistPermissionDeniedPage = 'CollabWatchlistPermissionDenied'; |
| 12 | 32 | |
| 13 | 33 | $wgExtensionCredits['specialpage'][] = array( |
| 14 | 34 | 'path' => __FILE__, |
| — | — | @@ -24,6 +44,8 @@ |
| 25 | 45 | $wgExtensionMessagesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.i18n.php'; |
| 26 | 46 | $wgExtensionAliasesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.alias.php'; |
| 27 | 47 | |
| | 48 | +$wgAutoloadClasses['CollabWatchlistHooks'] = "$wgDir/CollabWatchlist.hooks.php"; |
| | 49 | +$wgAutoloadClasses['CollabWatchlist'] = "$wgDir/CollabWatchlist.class.php"; |
| 28 | 50 | $wgAutoloadClasses['SpecialCollabWatchlist'] = $wgCollabWatchlistIncludes . 'SpecialCollabWatchlist.php'; |
| 29 | 51 | $wgAutoloadClasses['CollabWatchlistChangesList'] = $wgCollabWatchlistIncludes . 'CollabWatchlistChangesList.php'; |
| 30 | 52 | $wgAutoloadClasses['CategoryTreeManip'] = $wgCollabWatchlistIncludes . 'CategoryTreeManip.php'; |
| — | — | @@ -42,79 +64,6 @@ |
| 43 | 65 | $wgSpecialPages['Collabwatchlist'] = 'SpecialCollabWatchlist'; # Let MediaWiki know about your new special page. |
| 44 | 66 | $wgSpecialPageGroups['Collabwatchlist'] = 'other'; |
| 45 | 67 | |
| 46 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'fnCollabWatchlistDbSchema'; |
| 47 | | -$wgHooks['GetPreferences'][] = 'fnCollabWatchlistPreferences'; |
| 48 | | - |
| 49 | | -function fnCollabWatchlistDbSchema( $updater = null ) { |
| 50 | | - $sqlDir = dirname(__FILE__) . '/sql/'; |
| 51 | | - if ( $updater === null ) { // <= 1.16 support |
| 52 | | - global $wgExtNewTables, $wgExtNewFields; |
| 53 | | - $wgExtNewTables[] = array('collabwatchlist', $sqlDir . 'collabwatchlist.sql'); |
| 54 | | - $wgExtNewTables[] = array('collabwatchlistuser', $sqlDir . 'collabwatchlistuser.sql'); |
| 55 | | - $wgExtNewTables[] = array('collabwatchlistcategory', $sqlDir . 'collabwatchlistcategory.sql'); |
| 56 | | - $wgExtNewTables[] = array('collabwatchlistrevisiontag', $sqlDir . 'collabwatchlistrevisiontag.sql'); |
| 57 | | - $wgExtNewTables[] = array('collabwatchlisttag', $sqlDir . 'collabwatchlisttag.sql'); |
| 58 | | - $wgExtNewFields[] = array('collabwatchlistrevisiontag', 'ct_rc_id', $sqlDir . 'patch-collabwatchlist_noctid.sql'); |
| 59 | | - } else { // >= 1.17 support |
| 60 | | - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlist', |
| 61 | | - $sqlDir . 'collabwatchlist.sql', true ) ); |
| 62 | | - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistuser', |
| 63 | | - $sqlDir . 'collabwatchlistuser.sql', true ) ); |
| 64 | | - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistcategory', |
| 65 | | - $sqlDir . 'collabwatchlistcategory.sql', true ) ); |
| 66 | | - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistrevisiontag', |
| 67 | | - $sqlDir . 'collabwatchlistrevisiontag.sql', true ) ); |
| 68 | | - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlisttag', |
| 69 | | - $sqlDir . 'collabwatchlisttag.sql', true ) ); |
| 70 | | - $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistrevisiontag', 'ct_rc_id', |
| 71 | | - $sqlDir . 'patch-collabwatchlist_noctid.sql', true ) ); |
| 72 | | - } |
| 73 | | - return true; |
| 74 | | -} |
| 75 | | - |
| 76 | | -function fnCollabWatchlistPreferences( $user, &$preferences ) { |
| 77 | | - $preferences['collabwatchlisthidelistuser'] = array( |
| 78 | | - 'type' => 'toggle', |
| 79 | | - 'label-message' => 'tog-collabwatchlisthidelistusers', |
| 80 | | - 'section' => 'watchlist/advancedwatchlist', |
| 81 | | - ); |
| 82 | | - return true; |
| 83 | | -} |
| 84 | | - |
| 85 | | -// You might want to disable that, as it causes quite a bit of database |
| 86 | | -// and (if enabled) cache load and size |
| 87 | | -$wgCollabWatchlistRecursiveCatScan = true; |
| 88 | | -// The depth of the category tree we are building. -1 means infinite |
| 89 | | -// 0 fetches no child categories at all |
| 90 | | -$wgCollabWatchlistRecursiveCatMaxDepth = -1; |
| 91 | | -$wgCollabWatchlistNSPrefix = 'CollabWatchlist'; |
| 92 | | -$wgCollabWatchlistPermissionDeniedPage = 'CollabWatchlistPermissionDenied'; |
| 93 | | - |
| 94 | | -# Unit tests |
| 95 | | -$wgHooks['UnitTestsList'][] = 'efCollabWatchlistUnitTests'; |
| 96 | | - |
| 97 | | -function efCollabWatchlistUnitTests( &$files ) { |
| 98 | | - $files[] = dirname( __FILE__ ) . '/tests/CollabWatchlistTest.php'; |
| 99 | | - return true; |
| 100 | | -} |
| 101 | | - |
| 102 | | -/**#@+ |
| 103 | | - * Collaborative watchlist user types |
| 104 | | - * This defines constants for the collabwatchlistuser.rlu_type |
| 105 | | - */ |
| 106 | | -define( 'COLLABWATCHLISTUSER_OWNER', 'OWNER' ); // owners are allowed to edit the list |
| 107 | | -define( 'COLLABWATCHLISTUSER_OWNER_TEXT', 'Owner' ); // owners are allowed to edit the list |
| 108 | | -define( 'COLLABWATCHLISTUSER_USER', 'USER' ); // users are allowed to view the list and tag edits |
| 109 | | -define( 'COLLABWATCHLISTUSER_USER_TEXT', 'User' ); // users are allowed to view the list and tag edits |
| 110 | | -define( 'COLLABWATCHLISTUSER_TRUSTED_EDITOR', 'TRUSTED_EDITOR' ); // trusted editors are used to filter edits which don't require a review |
| 111 | | -define( 'COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT', 'TrustedEditor' ); // trusted editors are used to filter edits which don't require a review |
| 112 | | - |
| 113 | | -function fnCollabWatchlistUserTypeToText( $userType ) { |
| 114 | | - if ( $userType === COLLABWATCHLISTUSER_OWNER ) |
| 115 | | - return COLLABWATCHLISTUSER_OWNER_TEXT; |
| 116 | | - if ( $userType === COLLABWATCHLISTUSER_USER ) |
| 117 | | - return COLLABWATCHLISTUSER_USER_TEXT; |
| 118 | | - if ( $userType === COLLABWATCHLISTUSER_TRUSTED_EDITOR ) |
| 119 | | - return COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT; |
| 120 | | -} |
| 121 | | -/**#@-*/ |
| | 68 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'CollabWatchlistHooks::onLoadExtensionSchemaUpdates'; |
| | 69 | +$wgHooks['GetPreferences'][] = 'CollabWatchlistHooks::onGetPreferences'; |
| | 70 | +$wgHooks['UnitTestsList'][] = 'CollabWatchlistHooks::onUnitTestsList'; |
| Index: trunk/extensions/CollabWatchlist/includes/SpecialCollabWatchlist.php |
| — | — | @@ -168,7 +168,7 @@ |
| 169 | 169 | $recentchanges = $dbr->tableName( 'recentchanges' ); |
| 170 | 170 | |
| 171 | 171 | $nitems = $dbr->selectField( 'collabwatchlistcategory', 'COUNT(*)', |
| 172 | | - $collabWatchlist == 0 ? array() : array( 'rl_id' => $collabWatchlist |
| | 172 | + $collabWatchlist == 0 ? array() : array( 'cw_id' => $collabWatchlist |
| 173 | 173 | ), __METHOD__ ); |
| 174 | 174 | if ( $nitems == 0 ) { |
| 175 | 175 | $wgOut->addWikiMsg( 'nowatchlist' ); |
| — | — | @@ -459,28 +459,28 @@ |
| 460 | 460 | |
| 461 | 461 | /** Returns an array of maps representing collab watchlist tags. The following fields are present |
| 462 | 462 | * in each map: |
| 463 | | - * - rl_id Id of the collaborative watchlist |
| | 463 | + * - cw_id Id of the collaborative watchlist |
| 464 | 464 | * - ct_tag Name of the tag |
| 465 | 465 | * - collabwatchlistrevisiontag.user_id User which set the tag |
| 466 | 466 | * - user_name Username of the user which set the tag |
| 467 | 467 | * - rrt_comment Collabwatchlist tag comment |
| 468 | 468 | * @param $rev_id |
| 469 | | - * @param $rl_ids |
| | 469 | + * @param $cw_ids |
| 470 | 470 | * @return unknown_type |
| 471 | 471 | */ |
| 472 | | - function wlTagsForRevision( $rev_id, $rl_ids = array(), $filterTags = array() ) { |
| | 472 | + function wlTagsForRevision( $rev_id, $cw_ids = array(), $filterTags = array() ) { |
| 473 | 473 | // Some DB stuff |
| 474 | 474 | $dbr = wfGetDB( DB_SLAVE ); |
| 475 | 475 | $cond = array(); |
| 476 | | - if ( isset( $rl_ids ) && !( count( $rl_ids ) == 1 && $rl_ids[0] == 0 ) ) { |
| 477 | | - $cond = array( "rl_id" => $rl_ids ); |
| | 476 | + if ( isset( $cw_ids ) && !( count( $cw_ids ) == 1 && $cw_ids[0] == 0 ) ) { |
| | 477 | + $cond = array( "cw_id" => $cw_ids ); |
| 478 | 478 | } |
| 479 | 479 | if ( isset( $filterTags ) && count( $filterTags ) > 0 ) { |
| 480 | 480 | $cond[] = "ct_tag not in (" . $dbr->makeList( $filterTags ) . ")"; |
| 481 | 481 | } |
| 482 | 482 | // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| 483 | 483 | $res = $dbr->select( array( 'change_tag', 'collabwatchlistrevisiontag', 'user' ), # Tables |
| 484 | | - array( 'rl_id', 'collabwatchlistrevisiontag.ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment' ), # Fields |
| | 484 | + array( 'cw_id', 'collabwatchlistrevisiontag.ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment' ), # Fields |
| 485 | 485 | array( 'change_tag.ct_rev_id' => $rev_id ) + $cond, # Conditions |
| 486 | 486 | __METHOD__, array(), |
| 487 | 487 | # Join conditions |
| — | — | @@ -500,12 +500,12 @@ |
| 501 | 501 | * It filters entries which are not relevant for the given watchlists. I.e. |
| 502 | 502 | * entries which don't belong to a category and are not listed explicitly as a |
| 503 | 503 | * page for one of the given watchlists. |
| 504 | | - * @param $rl_ids Array: A list of collaborative watchlist ids |
| | 504 | + * @param $cw_ids Array: A list of collaborative watchlist ids |
| 505 | 505 | * @param $catNameCol String: The name of the column containing category names |
| 506 | 506 | * @param $pageIdCol String: The name of the column containing page ids |
| 507 | 507 | * @return String: An SQL clause usable in the conditions parameter of $db->select() |
| 508 | 508 | */ |
| 509 | | - function wlGetFilterClauseForCollabWatchlistIds( $rl_ids, $catNameCol, $pageIdCol ) { |
| | 509 | + function wlGetFilterClauseForCollabWatchlistIds( $cw_ids, $catNameCol, $pageIdCol ) { |
| 510 | 510 | global $wgCollabWatchlistRecursiveCatScan; |
| 511 | 511 | $excludedCatPageIds = array(); |
| 512 | 512 | $includedCatPageIds = array(); |
| — | — | @@ -513,10 +513,10 @@ |
| 514 | 514 | $dbr = wfGetDB( DB_SLAVE ); |
| 515 | 515 | $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistcategory', 'page' ), # Tables |
| 516 | 516 | array( 'cat_page_id', 'page_title', 'page_namespace', 'subtract' ), # Fields |
| 517 | | - $rl_ids != 0 ? array( 'collabwatchlist.rl_id' => $rl_ids ) : array(), # Conditions |
| | 517 | + $cw_ids != 0 ? array( 'collabwatchlist.cw_id' => $cw_ids ) : array(), # Conditions |
| 518 | 518 | __METHOD__, array(), |
| 519 | 519 | # Join conditions |
| 520 | | - array( 'collabwatchlistcategory' => array( 'JOIN', 'collabwatchlist.rl_id = collabwatchlistcategory.rl_id' ), |
| | 520 | + array( 'collabwatchlistcategory' => array( 'JOIN', 'collabwatchlist.cw_id = collabwatchlistcategory.cw_id' ), |
| 521 | 521 | 'page' => array( 'JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id' ) ) |
| 522 | 522 | ); |
| 523 | 523 | foreach ( $res as $row ) { |
| — | — | @@ -553,15 +553,15 @@ |
| 554 | 554 | /** |
| 555 | 555 | * Constructs the user filter SQL clause for the given collaborative watchlist ids. |
| 556 | 556 | * It filters entries from the users of the given watchlists. |
| 557 | | - * @param $rl_ids Array: A list of collaborative watchlist ids |
| | 557 | + * @param $cw_ids Array: A list of collaborative watchlist ids |
| 558 | 558 | * @return String: An SQL clause usable in the conditions parameter of $db->select() |
| 559 | 559 | */ |
| 560 | | - function wlGetFilterClauseListUser( $rl_id ) { |
| | 560 | + function wlGetFilterClauseListUser( $cw_id ) { |
| 561 | 561 | $excludedUserIds = array(); |
| 562 | 562 | $dbr = wfGetDB( DB_SLAVE ); |
| 563 | 563 | $res = $dbr->select( 'collabwatchlistuser', # Tables |
| 564 | 564 | 'user_id', # Fields |
| 565 | | - array( 'collabwatchlistuser.rl_id' => $rl_id ) # Conditions |
| | 565 | + array( 'collabwatchlistuser.cw_id' => $cw_id ) # Conditions |
| 566 | 566 | ); |
| 567 | 567 | $clause = ''; |
| 568 | 568 | foreach ( $res as $row ) { |
| Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistChangesList.php |
| — | — | @@ -180,7 +180,7 @@ |
| 181 | 181 | |
| 182 | 182 | /** Insert links to user page, user talk page and eventually a blocking link */ |
| 183 | 183 | $userLink = $this->skin->userLink( $tagRow['user_id'], $tagRow['user_name'] ); |
| 184 | | - $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl( $wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['rl_id'], $tag, $attr['rc_id'] ); |
| | 184 | + $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl( $wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['cw_id'], $tag, $attr['rc_id'] ); |
| 185 | 185 | $delTagLink = Xml::element( 'a', array( 'href' => $delTagTarget, 'class' => 'mw-collabwatchlist-unsettag-' . $tag ), wfMsg( 'collabwatchlist-unset-tag' ) ); |
| 186 | 186 | $displayTags[] = $collabwatchlistTag . ' ' . $delTagLink . ' ' . $userLink; |
| 187 | 187 | } |
| — | — | @@ -286,7 +286,7 @@ |
| 287 | 287 | $options = array(); |
| 288 | 288 | foreach ( $tagsAndInfo as $tagName => $info ) { |
| 289 | 289 | $optionsAll[] = Xml::option( $tagName . ' ' . $info['rt_description'], $tagName ); |
| 290 | | - foreach ( $info['rl_ids'] as $rlId ) { |
| | 290 | + foreach ( $info['cw_ids'] as $rlId ) { |
| 291 | 291 | $options[$rlId][] = Xml::option( $tagName, $tagName ); |
| 292 | 292 | } |
| 293 | 293 | } |
| — | — | @@ -322,7 +322,7 @@ |
| 323 | 323 | * |
| 324 | 324 | * The info is an array with the following keys: |
| 325 | 325 | * 'rt_description' The description of the tag |
| 326 | | - * 'rl_ids' An array of collab watchlist ids the tag belongs to |
| | 326 | + * 'cw_ids' An array of collab watchlist ids the tag belongs to |
| 327 | 327 | * @param array $rlIds A list of collab watchlist ids |
| 328 | 328 | * @return array Mapping from tag name to info |
| 329 | 329 | */ |
| — | — | @@ -332,16 +332,16 @@ |
| 333 | 333 | } |
| 334 | 334 | $dbr = wfGetDB( DB_SLAVE ); |
| 335 | 335 | $res = $dbr->select( array( 'collabwatchlisttag' ), # Tables |
| 336 | | - array( 'rt_name', 'rt_description', 'rl_id' ), # Fields |
| 337 | | - array( 'rl_id' => $rlIds ), # Conditions |
| | 336 | + array( 'rt_name', 'rt_description', 'cw_id' ), # Fields |
| | 337 | + array( 'cw_id' => $rlIds ), # Conditions |
| 338 | 338 | __METHOD__ |
| 339 | 339 | ); |
| 340 | 340 | $list = array(); |
| 341 | 341 | foreach ( $res as $row ) { |
| 342 | 342 | if ( array_key_exists( $row->rt_name, $list ) ) { |
| 343 | | - $list[$row->rt_name]['rl_ids'][] = $row->rl_id; |
| | 343 | + $list[$row->rt_name]['cw_ids'][] = $row->cw_id; |
| 344 | 344 | } else { |
| 345 | | - $list[$row->rt_name] = array( 'rt_description' => $row->rt_description, 'rl_ids' => array( $row->rl_id ) ); |
| | 345 | + $list[$row->rt_name] = array( 'rt_description' => $row->rt_description, 'cw_ids' => array( $row->cw_id ) ); |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | return $list; |
| — | — | @@ -354,20 +354,22 @@ |
| 355 | 355 | * @param array $member_types A list of allowed membership types |
| 356 | 356 | * @return array Mapping from collab watchlist id to its name |
| 357 | 357 | */ |
| 358 | | - public static function getCollabWatchlistIdAndName( $user_id, $member_types = array( COLLABWATCHLISTUSER_OWNER, COLLABWATCHLISTUSER_USER ) ) { |
| | 358 | + public static function getCollabWatchlistIdAndName( $user_id, $member_types = NULL ) { |
| 359 | 359 | global $wgDBprefix; |
| | 360 | + if ( is_null($member_types) ) |
| | 361 | + $member_types = array( CollabWatchlist::$USER_OWNER, CollabWatchlist::$USER_USER ); |
| 360 | 362 | $dbr = wfGetDB( DB_SLAVE ); |
| 361 | 363 | $list = array(); |
| 362 | 364 | // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array() |
| 363 | 365 | $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistuser' ), # Tables |
| 364 | | - array( $wgDBprefix . 'collabwatchlist.rl_id', 'rl_name' ), # Fields |
| | 366 | + array( $wgDBprefix . 'collabwatchlist.cw_id', 'cw_name' ), # Fields |
| 365 | 367 | array( 'rlu_type' => $member_types, $wgDBprefix . 'collabwatchlistuser.user_id' => $user_id ), # Conditions |
| 366 | 368 | __METHOD__, array(), |
| 367 | 369 | # Join conditions |
| 368 | | - array( 'collabwatchlistuser' => array( 'JOIN', $wgDBprefix . 'collabwatchlist.rl_id = ' . $wgDBprefix . 'collabwatchlistuser.rl_id' ) ) |
| | 370 | + array( 'collabwatchlistuser' => array( 'JOIN', $wgDBprefix . 'collabwatchlist.cw_id = ' . $wgDBprefix . 'collabwatchlistuser.cw_id' ) ) |
| 369 | 371 | ); |
| 370 | 372 | foreach ( $res as $row ) { |
| 371 | | - $list[$row->rl_id] = $row->rl_name; |
| | 373 | + $list[$row->cw_id] = $row->cw_name; |
| 372 | 374 | } |
| 373 | 375 | return $list; |
| 374 | 376 | } |
| Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistEditor.php |
| — | — | @@ -94,7 +94,7 @@ |
| 95 | 95 | } |
| 96 | 96 | $wanted = $this->extractCollabWatchlistUsers( $request->getText( 'titles' ) ); |
| 97 | 97 | $current = $this->getCollabWatchlistUsers( $rlId ); |
| 98 | | - $isOwnerCb = create_function( '$a', 'return stripos($a, "' . COLLABWATCHLISTUSER_OWNER_TEXT . ' ' . '") === 0;' ); |
| | 98 | + $isOwnerCb = create_function( '$a', 'return stripos($a, "' . CollabWatchlist::$USER_OWNER_TEXT . ' ' . '") === 0;' ); |
| 99 | 99 | $wantedOwners = array_filter( $wanted, $isOwnerCb ); |
| 100 | 100 | if ( count( $wantedOwners ) < 1 ) { |
| 101 | 101 | // Make sure there is at least one owner left |
| — | — | @@ -179,7 +179,7 @@ |
| 180 | 180 | $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl(); |
| 181 | 181 | if ( $request->wasPosted() ) { |
| 182 | 182 | $rlId = $request->getInt( 'collabwatchlist', -1 ); |
| 183 | | - if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) { |
| | 183 | + if ( ! $this->checkPermissions( $wgUser, $rlId, array( CollabWatchlist::$USER_USER, CollabWatchlist::$USER_OWNER ) ) ) { |
| 184 | 184 | $output->redirect( $permissionDeniedTarget ); |
| 185 | 185 | break; |
| 186 | 186 | } |
| — | — | @@ -206,7 +206,7 @@ |
| 207 | 207 | break; |
| 208 | 208 | case self::UNSET_TAGS: |
| 209 | 209 | $rlId = $request->getInt( 'collabwatchlist', -1 ); |
| 210 | | - if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) { |
| | 210 | + if ( ! $this->checkPermissions( $wgUser, $rlId, array( CollabWatchlist::$USER_USER, CollabWatchlist::$USER_OWNER ) ) ) { |
| 211 | 211 | $output->redirect( $permissionDeniedTarget ); |
| 212 | 212 | break; |
| 213 | 213 | } |
| — | — | @@ -261,19 +261,25 @@ |
| 262 | 262 | * @param $memberTypes Which types of members are allowed |
| 263 | 263 | * @return bool |
| 264 | 264 | */ |
| 265 | | - private function checkToken( $request, $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) { |
| | 265 | + private function checkToken( $request, $user, $rlId, $memberTypes = NULL ) { |
| | 266 | + if ( is_null($member_types) ) |
| | 267 | + $member_types = array( CollabWatchlist::$USER_OWNER ); |
| | 268 | + |
| 266 | 269 | $tokenOk = $user->matchEditToken( $request->getVal( 'token' ), 'watchlistedit' ) && $request->getVal( 'collabwatchlist' ) !== 0; |
| 267 | 270 | if ( $tokenOk === false ) |
| 268 | 271 | return $tokenOk; |
| 269 | 272 | return $this->checkPermissions( $user, $rlId, $memberTypes ); |
| 270 | 273 | } |
| 271 | 274 | |
| 272 | | - private function checkPermissions( $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) { |
| | 275 | + private function checkPermissions( $user, $rlId, $memberTypes = NULL ) { |
| | 276 | + if ( is_null($member_types) ) |
| | 277 | + $member_types = array( CollabWatchlist::$USER_OWNER ); |
| | 278 | + |
| 273 | 279 | // Check permissions |
| 274 | 280 | $dbr = wfGetDB( DB_MASTER ); |
| 275 | 281 | $res = $dbr->select( 'collabwatchlistuser', |
| 276 | 282 | 'COUNT(*) AS count', |
| 277 | | - array( 'rl_id' => $rlId, 'user_id' => $user->getId(), 'rlu_type' => $memberTypes ), |
| | 283 | + array( 'cw_id' => $rlId, 'user_id' => $user->getId(), 'rlu_type' => $memberTypes ), |
| 278 | 284 | __METHOD__ |
| 279 | 285 | ); |
| 280 | 286 | $row = $dbr->fetchObject( $res ); |
| — | — | @@ -313,22 +319,22 @@ |
| 314 | 320 | } |
| 315 | 321 | |
| 316 | 322 | private function extractTypeTypeTextAndUsername( $typeAndUsernameStr ) { |
| 317 | | - $type = COLLABWATCHLISTUSER_USER; |
| 318 | | - $typeText = COLLABWATCHLISTUSER_USER_TEXT; |
| | 323 | + $type = CollabWatchlist::$USER_USER; |
| | 324 | + $typeText = CollabWatchlist::$USER_USER_TEXT; |
| 319 | 325 | $text = trim( $typeAndUsernameStr ); |
| 320 | 326 | $titleText = $text; |
| 321 | | - if ( stripos( $text, COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) === 0 ) { |
| 322 | | - $type = COLLABWATCHLISTUSER_OWNER; |
| 323 | | - $typeText = COLLABWATCHLISTUSER_OWNER_TEXT; |
| 324 | | - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) ) ); |
| 325 | | - } else if ( stripos( $text, COLLABWATCHLISTUSER_USER_TEXT . ' ' ) === 0 ) { |
| 326 | | - $type = COLLABWATCHLISTUSER_USER; |
| 327 | | - $typeText = COLLABWATCHLISTUSER_USER_TEXT; |
| 328 | | - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_USER_TEXT . ' ' ) ) ); |
| 329 | | - } else if ( stripos( $text, COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) === 0 ) { |
| 330 | | - $type = COLLABWATCHLISTUSER_TRUSTED_EDITOR; |
| 331 | | - $typeText = COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT; |
| 332 | | - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) ) ); |
| | 327 | + if ( stripos( $text, CollabWatchlist::$USER_OWNER_TEXT . ' ' ) === 0 ) { |
| | 328 | + $type = CollabWatchlist::$USER_OWNER; |
| | 329 | + $typeText = CollabWatchlist::$USER_OWNER_TEXT; |
| | 330 | + $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_OWNER_TEXT . ' ' ) ) ); |
| | 331 | + } else if ( stripos( $text, CollabWatchlist::$USER_USER_TEXT . ' ' ) === 0 ) { |
| | 332 | + $type = CollabWatchlist::$USER_USER; |
| | 333 | + $typeText = CollabWatchlist::$USER_USER_TEXT; |
| | 334 | + $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_USER_TEXT . ' ' ) ) ); |
| | 335 | + } else if ( stripos( $text, CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT . ' ' ) === 0 ) { |
| | 336 | + $type = CollabWatchlist::$USER_TRUSTED_EDITOR; |
| | 337 | + $typeText = CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT; |
| | 338 | + $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT . ' ' ) ) ); |
| 333 | 339 | } |
| 334 | 340 | return array( $type, $typeText, $titleText ); |
| 335 | 341 | } |
| — | — | @@ -454,7 +460,7 @@ |
| 455 | 461 | */ |
| 456 | 462 | private function countCollabWatchlistCategories( $rlId ) { |
| 457 | 463 | $dbr = wfGetDB( DB_MASTER ); |
| 458 | | - $res = $dbr->select( 'collabwatchlistcategory', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ ); |
| | 464 | + $res = $dbr->select( 'collabwatchlistcategory', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ ); |
| 459 | 465 | $row = $dbr->fetchObject( $res ); |
| 460 | 466 | return $row->count; |
| 461 | 467 | } |
| — | — | @@ -467,7 +473,7 @@ |
| 468 | 474 | */ |
| 469 | 475 | private function countCollabWatchlistUsers( $rlId ) { |
| 470 | 476 | $dbr = wfGetDB( DB_MASTER ); |
| 471 | | - $res = $dbr->select( 'collabwatchlistuser', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ ); |
| | 477 | + $res = $dbr->select( 'collabwatchlistuser', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ ); |
| 472 | 478 | $row = $dbr->fetchObject( $res ); |
| 473 | 479 | return $row->count; |
| 474 | 480 | } |
| — | — | @@ -480,7 +486,7 @@ |
| 481 | 487 | */ |
| 482 | 488 | private function countCollabWatchlistTags( $rlId ) { |
| 483 | 489 | $dbr = wfGetDB( DB_MASTER ); |
| 484 | | - $res = $dbr->select( 'collabwatchlisttag', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ ); |
| | 490 | + $res = $dbr->select( 'collabwatchlisttag', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ ); |
| 485 | 491 | $row = $dbr->fetchObject( $res ); |
| 486 | 492 | return $row->count; |
| 487 | 493 | } |
| — | — | @@ -493,7 +499,7 @@ |
| 494 | 500 | */ |
| 495 | 501 | private function countCollabWatchlistSetTags( $rlId ) { |
| 496 | 502 | $dbr = wfGetDB( DB_MASTER ); |
| 497 | | - $res = $dbr->select( 'collabwatchlistrevisiontag', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ ); |
| | 503 | + $res = $dbr->select( 'collabwatchlistrevisiontag', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ ); |
| 498 | 504 | $row = $dbr->fetchObject( $res ); |
| 499 | 505 | return $row->count; |
| 500 | 506 | } |
| — | — | @@ -512,7 +518,7 @@ |
| 513 | 519 | array( 'collabwatchlistcategory', 'page' ), |
| 514 | 520 | array( 'page_title', 'page_namespace', 'subtract' ), |
| 515 | 521 | array( |
| 516 | | - 'rl_id' => $rlId, |
| | 522 | + 'cw_id' => $rlId, |
| 517 | 523 | ), |
| 518 | 524 | __METHOD__, array(), |
| 519 | 525 | # Join conditions |
| — | — | @@ -542,7 +548,7 @@ |
| 543 | 549 | array( 'collabwatchlistuser', 'user' ), |
| 544 | 550 | array( 'user_name', 'rlu_type' ), |
| 545 | 551 | array( |
| 546 | | - 'rl_id' => $rlId, |
| | 552 | + 'cw_id' => $rlId, |
| 547 | 553 | ), |
| 548 | 554 | __METHOD__, array(), |
| 549 | 555 | # Join conditions |
| — | — | @@ -550,7 +556,7 @@ |
| 551 | 557 | ); |
| 552 | 558 | if ( $res->numRows() > 0 ) { |
| 553 | 559 | foreach ( $res as $row ) { |
| 554 | | - $typeText = fnCollabWatchlistUserTypeToText( $row->rlu_type ); |
| | 560 | + $typeText = Collabwatchlist::userTypeToText( $row->rlu_type ); |
| 555 | 561 | $list[] = $typeText . ' ' . $row->user_name; |
| 556 | 562 | } |
| 557 | 563 | } |
| — | — | @@ -571,7 +577,7 @@ |
| 572 | 578 | array( 'collabwatchlisttag' ), |
| 573 | 579 | array( 'rt_name', 'rt_description' ), |
| 574 | 580 | array( |
| 575 | | - 'rl_id' => $rlId, |
| | 581 | + 'cw_id' => $rlId, |
| 576 | 582 | ), __METHOD__ |
| 577 | 583 | ); |
| 578 | 584 | if ( $res->numRows() > 0 ) { |
| — | — | @@ -598,7 +604,7 @@ |
| 599 | 605 | array( 'collabwatchlistcategory', 'page' ), |
| 600 | 606 | array( 'page_title', 'page_namespace', 'page_id', 'page_len', 'page_is_redirect', 'subtract' ), |
| 601 | 607 | array( |
| 602 | | - 'rl_id' => $rlId, |
| | 608 | + 'cw_id' => $rlId, |
| 603 | 609 | ), |
| 604 | 610 | __METHOD__, array(), |
| 605 | 611 | # Join conditions |
| — | — | @@ -704,7 +710,7 @@ |
| 705 | 711 | */ |
| 706 | 712 | private function clearCollabWatchlist( $rlId ) { |
| 707 | 713 | $dbw = wfGetDB( DB_MASTER ); |
| 708 | | - $dbw->delete( 'collabwatchlistcategory', array( 'rl_id' => $rlId ), __METHOD__ ); |
| | 714 | + $dbw->delete( 'collabwatchlistcategory', array( 'cw_id' => $rlId ), __METHOD__ ); |
| 709 | 715 | } |
| 710 | 716 | |
| 711 | 717 | /** |
| — | — | @@ -731,7 +737,7 @@ |
| 732 | 738 | $titleObj = Title::newFromText( $titleText ); |
| 733 | 739 | if ( $titleObj instanceof Title && $titleObj->exists() ) { |
| 734 | 740 | $rows[] = array( |
| 735 | | - 'rl_id' => $rlId, |
| | 741 | + 'cw_id' => $rlId, |
| 736 | 742 | 'cat_page_id' => $titleObj->getArticleID(), |
| 737 | 743 | 'subtract' => $subtract, |
| 738 | 744 | ); |
| — | — | @@ -759,7 +765,7 @@ |
| 760 | 766 | $user = User::newFromName( $titleText ); |
| 761 | 767 | if ( $user instanceof User && $user->getId() !== 0 ) { |
| 762 | 768 | $rows[] = array( |
| 763 | | - 'rl_id' => $rlId, |
| | 769 | + 'cw_id' => $rlId, |
| 764 | 770 | 'user_id' => $user->getId(), |
| 765 | 771 | 'rlu_type' => $type, |
| 766 | 772 | ); |
| — | — | @@ -789,7 +795,7 @@ |
| 790 | 796 | } |
| 791 | 797 | } |
| 792 | 798 | // Add the tagged revisions to the collaborative watchlist |
| 793 | | - $sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_rc_id, ct_tag, rl_id, user_id, rrt_comment) |
| | 799 | + $sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_rc_id, ct_tag, cw_id, user_id, rrt_comment) |
| 794 | 800 | SELECT ct_rc_id, ct_tag, ' . $dbw->strencode( $rlId ) . ',' . |
| 795 | 801 | $dbw->strencode( $userId ) . ',' . |
| 796 | 802 | $dbw->addQuotes( $comment ) . ' FROM change_tag WHERE ct_tag = ? AND ct_rc_id '; |
| — | — | @@ -844,7 +850,7 @@ |
| 845 | 851 | $rows = array(); |
| 846 | 852 | foreach ( $titles as $title => $description ) { |
| 847 | 853 | $rows[] = array( |
| 848 | | - 'rl_id' => $rlId, |
| | 854 | + 'cw_id' => $rlId, |
| 849 | 855 | 'rt_name' => $title, |
| 850 | 856 | 'rt_description' => $description, |
| 851 | 857 | ); |
| — | — | @@ -876,7 +882,7 @@ |
| 877 | 883 | $dbw->delete( |
| 878 | 884 | 'collabwatchlistcategory', |
| 879 | 885 | array( |
| 880 | | - 'rl_id' => $rlId, |
| | 886 | + 'cw_id' => $rlId, |
| 881 | 887 | 'cat_page_id' => $title->getArticleID(), |
| 882 | 888 | 'subtract' => $subtract, |
| 883 | 889 | ), |
| — | — | @@ -906,7 +912,7 @@ |
| 907 | 913 | $dbw->delete( |
| 908 | 914 | 'collabwatchlistuser', |
| 909 | 915 | array( |
| 910 | | - 'rl_id' => $rlId, |
| | 916 | + 'cw_id' => $rlId, |
| 911 | 917 | 'user_id' => $user->getId(), |
| 912 | 918 | 'rlu_type' => $type, |
| 913 | 919 | ), |
| — | — | @@ -932,7 +938,7 @@ |
| 933 | 939 | $dbw->delete( |
| 934 | 940 | 'collabwatchlisttag', |
| 935 | 941 | array( |
| 936 | | - 'rl_id' => $rlId, |
| | 942 | + 'cw_id' => $rlId, |
| 937 | 943 | 'rt_name' => $title, |
| 938 | 944 | ), |
| 939 | 945 | __METHOD__ |
| — | — | @@ -1003,11 +1009,11 @@ |
| 1004 | 1010 | $dbw = wfGetDB( DB_MASTER ); |
| 1005 | 1011 | $dbw->begin(); |
| 1006 | 1012 | try { |
| 1007 | | - $rl_id = $dbw->nextSequenceValue( 'collabwatchlist_rl_id_seq' ); |
| | 1013 | + $cw_id = $dbw->nextSequenceValue( 'collabwatchlist_cw_id_seq' ); |
| 1008 | 1014 | $dbw->insert( 'collabwatchlist', array( |
| 1009 | | - 'rl_id' => $rl_id, |
| 1010 | | - 'rl_name' => $name, |
| 1011 | | - 'rl_start' => wfTimestamp( TS_ISO_8601 ), |
| | 1015 | + 'cw_id' => $cw_id, |
| | 1016 | + 'cw_name' => $name, |
| | 1017 | + 'cw_start' => wfTimestamp( TS_ISO_8601 ), |
| 1012 | 1018 | ), __METHOD__, 'IGNORE' ); |
| 1013 | 1019 | |
| 1014 | 1020 | $affected = $dbw->affectedRows(); |
| — | — | @@ -1019,9 +1025,9 @@ |
| 1020 | 1026 | $rlu_id = $dbw->nextSequenceValue( 'collabwatchlistuser_rlu_id_seq' ); |
| 1021 | 1027 | $dbw->insert( 'collabwatchlistuser', array( |
| 1022 | 1028 | 'rlu_id' => $rlu_id, |
| 1023 | | - 'rl_id' => $newid, |
| | 1029 | + 'cw_id' => $newid, |
| 1024 | 1030 | 'user_id' => $wgUser->getId(), |
| 1025 | | - 'rlu_type' => COLLABWATCHLISTUSER_OWNER, |
| | 1031 | + 'rlu_type' => CollabWatchlist::$USER_OWNER, |
| 1026 | 1032 | ), __METHOD__, 'IGNORE' ); |
| 1027 | 1033 | $affected = $dbw->affectedRows(); |
| 1028 | 1034 | if ( ! $affected ) { |
| — | — | @@ -1042,19 +1048,19 @@ |
| 1043 | 1049 | $dbw->begin(); |
| 1044 | 1050 | try { |
| 1045 | 1051 | $dbw->delete( 'collabwatchlistrevisiontag', array( |
| 1046 | | - 'rl_id' => $rlId, |
| | 1052 | + 'cw_id' => $rlId, |
| 1047 | 1053 | ), __METHOD__ ); |
| 1048 | 1054 | $dbw->delete( 'collabwatchlisttag', array( |
| 1049 | | - 'rl_id' => $rlId, |
| | 1055 | + 'cw_id' => $rlId, |
| 1050 | 1056 | ), __METHOD__ ); |
| 1051 | 1057 | $dbw->delete( 'collabwatchlistcategory', array( |
| 1052 | | - 'rl_id' => $rlId, |
| | 1058 | + 'cw_id' => $rlId, |
| 1053 | 1059 | ), __METHOD__ ); |
| 1054 | 1060 | $dbw->delete( 'collabwatchlistuser', array( |
| 1055 | | - 'rl_id' => $rlId, |
| | 1061 | + 'cw_id' => $rlId, |
| 1056 | 1062 | ), __METHOD__ ); |
| 1057 | 1063 | $dbw->delete( 'collabwatchlist', array( |
| 1058 | | - 'rl_id' => $rlId, |
| | 1064 | + 'cw_id' => $rlId, |
| 1059 | 1065 | ), __METHOD__ ); |
| 1060 | 1066 | $affected = $dbw->affectedRows(); |
| 1061 | 1067 | if ( ! $affected ) { |
| Index: trunk/extensions/CollabWatchlist/CollabWatchlist.hooks.php |
| — | — | @@ -0,0 +1,47 @@ |
| | 2 | +<?php |
| | 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | + die(); |
| | 5 | +} |
| | 6 | + |
| | 7 | +/** Provides hooks for the CollabWatchlist extension |
| | 8 | + * @author fhackenberger |
| | 9 | + */ |
| | 10 | +class CollabWatchlistHooks { |
| | 11 | + /** Provide info for the DB schem upgrade framework */ |
| | 12 | + public static function onLoadExtensionSchemaUpdates( $updater ) { |
| | 13 | + $sqlDir = dirname(__FILE__) . '/sql/'; |
| | 14 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlist', |
| | 15 | + $sqlDir . 'collabwatchlist.sql', true ) ); |
| | 16 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistuser', |
| | 17 | + $sqlDir . 'collabwatchlistuser.sql', true ) ); |
| | 18 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistcategory', |
| | 19 | + $sqlDir . 'collabwatchlistcategory.sql', true ) ); |
| | 20 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistrevisiontag', |
| | 21 | + $sqlDir . 'collabwatchlistrevisiontag.sql', true ) ); |
| | 22 | + $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlisttag', |
| | 23 | + $sqlDir . 'collabwatchlisttag.sql', true ) ); |
| | 24 | + $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistrevisiontag', 'ct_rc_id', |
| | 25 | + $sqlDir . 'patch-collabwatchlist_noctid.sql', true ) ); |
| | 26 | + $updater->addExtensionUpdate( array( 'addField', 'collabwatchlist', 'cw_id', |
| | 27 | + $sqlDir . 'patch-collabwatchlist_rename_fields.sql', true ) ); |
| | 28 | + $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistuser', 'rlu_type', |
| | 29 | + $sqlDir . 'patch-collabwatchlist_remove_enum.sql', true ) ); |
| | 30 | + $updater->addExtensionUpdate( array( 'modifyField', 'collabwatchlisttag', 'rt_id', |
| | 31 | + $sqlDir . 'patch-collabwatchlist_remove_primary_keys.sql', true ) ); |
| | 32 | + return true; |
| | 33 | + } |
| | 34 | + |
| | 35 | + public static function onGetPreferences( $user, &$preferences ) { |
| | 36 | + $preferences['collabwatchlisthidelistuser'] = array( |
| | 37 | + 'type' => 'toggle', |
| | 38 | + 'label-message' => 'tog-collabwatchlisthidelistusers', |
| | 39 | + 'section' => 'watchlist/advancedwatchlist', |
| | 40 | + ); |
| | 41 | + return true; |
| | 42 | + } |
| | 43 | + |
| | 44 | + public static function onUnitTestsList( &$files ) { |
| | 45 | + $files[] = dirname( __FILE__ ) . '/tests/CollabWatchlistTest.php'; |
| | 46 | + return true; |
| | 47 | + } |
| | 48 | +} |
| Property changes on: trunk/extensions/CollabWatchlist/CollabWatchlist.hooks.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 49 | + native |
| Index: trunk/extensions/CollabWatchlist/CollabWatchlist.class.php |
| — | — | @@ -0,0 +1,35 @@ |
| | 2 | +<?php |
| | 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| | 4 | + die(); |
| | 5 | +} |
| | 6 | + |
| | 7 | +/** Provides hooks for the CollabWatchlist extension |
| | 8 | + * @author fhackenberger |
| | 9 | + */ |
| | 10 | +class CollabWatchlist { |
| | 11 | + /** |
| | 12 | + * Collaborative watchlist user types |
| | 13 | + * Defines constants for the collabwatchlistuser.rlu_type |
| | 14 | + */ |
| | 15 | + /** owners are allowed to edit the list */ |
| | 16 | + public static $USER_OWNER = 1; |
| | 17 | + /** owners are allowed to edit the list */ |
| | 18 | + public static $USER_OWNER_TEXT = 'Owner'; |
| | 19 | + /** users are allowed to view the list and tag edits */ |
| | 20 | + public static $USER_USER = 2; |
| | 21 | + /** users are allowed to view the list and tag edits */ |
| | 22 | + public static $USER_USER_TEXT = 'User'; |
| | 23 | + /** trusted editors are used to filter edits which don't require a review */ |
| | 24 | + public static $USER_TRUSTED_EDITOR = 3; |
| | 25 | + /** trusted editors are used to filter edits which don't require a review */ |
| | 26 | + public static $USER_TRUSTED_EDITOR_TEXT = 'TrustedEditor'; |
| | 27 | + |
| | 28 | + public static function userTypeToText( $userType ) { |
| | 29 | + if ( $userType === CollabWatchlist::$USER_OWNER ) |
| | 30 | + return CollabWatchlist::$USER_OWNER_TEXT; |
| | 31 | + if ( $userType === CollabWatchlist::$USER_USER ) |
| | 32 | + return CollabWatchlist::$USER_USER_TEXT; |
| | 33 | + if ( $userType === CollabWatchlist::$USER_TRUSTED_EDITOR ) |
| | 34 | + return CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT; |
| | 35 | + } |
| | 36 | +} |
| Property changes on: trunk/extensions/CollabWatchlist/CollabWatchlist.class.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 37 | + native |
| Index: trunk/extensions/CollabWatchlist/mediawiki_core.patch.99863 |
| — | — | @@ -0,0 +1,124 @@ |
| | 2 | +Index: includes/ChangesList.php |
| | 3 | +=================================================================== |
| | 4 | +--- includes/ChangesList.php (revision 99863) |
| | 5 | +@@ -763,6 +763,44 @@ |
| | 6 | + return $ret; |
| | 7 | + } |
| | 8 | + |
| | 9 | ++ protected function insertDiffAndHistLinks( &$s, &$rc ) { |
| | 10 | ++ $s .= ' ('. $rc->difflink; |
| | 11 | ++ $this->insertHistLink($s, $rc, $rc->getTitle()); |
| | 12 | ++ $s .= ')'; |
| | 13 | ++ } |
| | 14 | ++ |
| | 15 | ++ protected function insertHistLink( &$s, &$rc, $title, $params = array(), $sep = NULL ) { |
| | 16 | ++ $params['action'] = 'history'; |
| | 17 | ++ $s .= isset($sep) ? $sep : $this->message['pipe-separator'] . |
| | 18 | ++ Linker::linkKnown( |
| | 19 | ++ $title, |
| | 20 | ++ $this->message['hist'], |
| | 21 | ++ array(), |
| | 22 | ++ $params |
| | 23 | ++ ); |
| | 24 | ++ } |
| | 25 | ++ |
| | 26 | ++ protected function insertBeforeRCFlags( &$r, &$rcObj ) { |
| | 27 | ++ |
| | 28 | ++ } |
| | 29 | ++ |
| | 30 | ++ protected function insertBeforeRCFlagsBlock( &$r, &$block ) { |
| | 31 | ++ |
| | 32 | ++ } |
| | 33 | ++ |
| | 34 | ++ protected function insertCurrAndLastLinks( &$s, &$rc ) { |
| | 35 | ++ $s .= ' ('; |
| | 36 | ++ $s .= $rc->curlink; |
| | 37 | ++ $s .= $this->message['pipe-separator']; |
| | 38 | ++ $s .= $rc->lastlink; |
| | 39 | ++ $s .= ')'; |
| | 40 | ++ } |
| | 41 | ++ |
| | 42 | ++ protected function insertUserAndTalkLinks( &$s, &$rc ) { |
| | 43 | ++ $s .= $rc->userlink; |
| | 44 | ++ $s .= $rc->usertalklink; |
| | 45 | ++ } |
| | 46 | ++ |
| | 47 | + /** |
| | 48 | + * Enhanced RC group |
| | 49 | + */ |
| | 50 | +@@ -850,7 +888,7 @@ |
| | 51 | + . "<a href='#' title='$closeTitle'>{$this->downArrow()}</a>" |
| | 52 | + . "</span></span>"; |
| | 53 | + $r .= "<td>$tl</td>"; |
| | 54 | +- |
| | 55 | ++ $this->insertBeforeRCFlagsBlock($r, $block); |
| | 56 | + # Main line |
| | 57 | + $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array( |
| | 58 | + 'newpage' => $isnew, |
| | 59 | +@@ -910,15 +948,8 @@ |
| | 60 | + $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')'; |
| | 61 | + } else { |
| | 62 | + $params = $queryParams; |
| | 63 | +- $params['action'] = 'history'; |
| | 64 | +- |
| | 65 | +- $r .= $this->message['pipe-separator'] . |
| | 66 | +- Linker::linkKnown( |
| | 67 | +- $block[0]->getTitle(), |
| | 68 | +- $this->message['hist'], |
| | 69 | +- array(), |
| | 70 | +- $params |
| | 71 | +- ) . ')'; |
| | 72 | ++ $this->insertHistLink($r, $rcObj, $block[0]->getTitle(), $params); |
| | 73 | ++ $r .= ')'; |
| | 74 | + } |
| | 75 | + $r .= ' . . '; |
| | 76 | + |
| | 77 | +@@ -955,6 +986,7 @@ |
| | 78 | + |
| | 79 | + #$r .= '<tr><td valign="top">'.$this->spacerArrow(); |
| | 80 | + $r .= '<tr><td></td><td class="mw-enhanced-rc">'; |
| | 81 | ++ $this->insertBeforeRCFlags( $r, $rcObj ); |
| | 82 | + $r .= $this->recentChangesFlags( array( |
| | 83 | + 'newpage' => $rcObj->mAttribs['rc_new'], |
| | 84 | + 'minor' => $rcObj->mAttribs['rc_minor'], |
| | 85 | +@@ -992,11 +1024,7 @@ |
| | 86 | + $r .= $link . '</span>'; |
| | 87 | + |
| | 88 | + if ( !$type == RC_LOG || $type == RC_NEW ) { |
| | 89 | +- $r .= ' ('; |
| | 90 | +- $r .= $rcObj->curlink; |
| | 91 | +- $r .= $this->message['pipe-separator']; |
| | 92 | +- $r .= $rcObj->lastlink; |
| | 93 | +- $r .= ')'; |
| | 94 | ++ $this->insertCurrAndLastLinks( $r, $rcObj ); |
| | 95 | + } |
| | 96 | + $r .= ' . . '; |
| | 97 | + |
| | 98 | +@@ -1009,8 +1037,7 @@ |
| | 99 | + $r .= $this->insertLogEntry( $rcObj ); |
| | 100 | + } else { |
| | 101 | + # User links |
| | 102 | +- $r .= $rcObj->userlink; |
| | 103 | +- $r .= $rcObj->usertalklink; |
| | 104 | ++ $this->insertUserAndTalkLinks( $r, $rcObj ); |
| | 105 | + $r .= $this->insertComment( $rcObj ); |
| | 106 | + } |
| | 107 | + |
| | 108 | +@@ -1097,6 +1124,7 @@ |
| | 109 | + Html::openElement( 'tr' ); |
| | 110 | + |
| | 111 | + $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow(); |
| | 112 | ++ $this->insertBeforeRCFlags( $r, $rcObj ); |
| | 113 | + # Flag and Timestamp |
| | 114 | + if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) { |
| | 115 | + $r .= '    '; // 4 flags -> 4 spaces |
| | 116 | +@@ -1137,7 +1165,7 @@ |
| | 117 | + if ( $type == RC_LOG ) { |
| | 118 | + $r .= $this->insertLogEntry( $rcObj ); |
| | 119 | + } else { |
| | 120 | +- $r .= ' '.$rcObj->userlink . $rcObj->usertalklink; |
| | 121 | ++ $this->insertUserAndTalkLinks($r, $rcObj); |
| | 122 | + $r .= $this->insertComment( $rcObj ); |
| | 123 | + $r .= $this->insertRollback( $r, $rcObj ); |
| | 124 | + } |