Index: trunk/extensions/SemanticWatchlist/api/ApiDeleteWatchlistGroup.php |
— | — | @@ -11,6 +11,8 @@ |
12 | 12 | * |
13 | 13 | * @licence GNU GPL v3+ |
14 | 14 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + * |
| 16 | + * TODO: delete changes |
15 | 17 | */ |
16 | 18 | class ApiDeleteWatchlistGroup extends ApiBase { |
17 | 19 | |
— | — | @@ -63,6 +65,22 @@ |
64 | 66 | ) |
65 | 67 | ); |
66 | 68 | |
| 69 | + foreach ( $setsForGroup as $set ) { |
| 70 | + $changes = $dbr->select( |
| 71 | + 'swl_changes', |
| 72 | + array( 'change_id' ), |
| 73 | + array( 'change_set_id' => $set->spg_set_id ) |
| 74 | + ); |
| 75 | + |
| 76 | + foreach ( $changes as $change ) { |
| 77 | + $dbr->select( // TODO |
| 78 | + 'swl_changes_per_set', |
| 79 | + array( 'change_id' ), |
| 80 | + array( 'change_set_id' => $set->spg_set_id ) |
| 81 | + ); |
| 82 | + } |
| 83 | + } |
| 84 | + |
67 | 85 | // Find all edits linked to this group. |
68 | 86 | $editsForGroup = $dbr->select( |
69 | 87 | array( 'swl_sets_per_group', 'swl_sets_per_edit' ), |
Index: trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php |
— | — | @@ -24,8 +24,15 @@ |
25 | 25 | // Get the requests parameters. |
26 | 26 | $params = $this->extractRequestParams(); |
27 | 27 | |
28 | | - $this->setupChangeSetQuery( $params['userid'], $params['limit'], $params['continue'] ); |
| 28 | + if ( !( isset( $params['userid'] ) XOR isset( $params['groupids'] ) ) ) { |
| 29 | + $this->dieUsage( wfMsgExt( 'swl-err-userid-xor-groupids' ), 'userid-xor-groupids' ); |
| 30 | + } |
29 | 31 | |
| 32 | + $isUserFilter = isset( $params['userid'] ); |
| 33 | + $filter = $isUserFilter ? $params['userid'] : $params['groupids']; |
| 34 | + |
| 35 | + $this->setupChangeSetQuery( $filter, $isUserFilter, $params['limit'], $params['continue'] ); |
| 36 | + |
30 | 37 | $sets = $this->select( __METHOD__ ); |
31 | 38 | $count = 0; |
32 | 39 | $resultSets = array(); |
— | — | @@ -60,19 +67,31 @@ |
61 | 68 | * Gets a list of change sets belonging to any of the watchlist groups |
62 | 69 | * watched by the user, newest first. |
63 | 70 | * |
64 | | - * @param integer $userId |
| 71 | + * @param mixed $filter User ID or array of group IDs |
| 72 | + * @param boolean $isUserFilter |
65 | 73 | * @param integer $limit |
66 | 74 | * @param string $continue |
67 | 75 | */ |
68 | | - protected function setupChangeSetQuery( $userId, $limit, $continue ) { |
69 | | - $this->addTables( array( 'swl_edits', 'swl_sets_per_edit', 'swl_sets_per_group', 'swl_users_per_group' ) ); |
| 76 | + protected function setupChangeSetQuery( $filter, $isUserFilter, $limit, $continue ) { |
| 77 | + $tables = array( 'swl_edits', 'swl_sets_per_edit', 'swl_sets_per_group' ); |
| 78 | + |
| 79 | + if ( $isUserFilter ) { |
| 80 | + $tables[] = 'swl_users_per_group'; |
| 81 | + } |
| 82 | + |
| 83 | + $this->addTables( $tables ); |
70 | 84 | |
71 | 85 | $this->addJoinConds( array( |
72 | 86 | 'swl_sets_per_edit' => array( 'INNER JOIN', array( 'edit_id=spe_edit_id' ) ), |
73 | 87 | 'swl_sets_per_group' => array( 'INNER JOIN', array( 'spe_set_id=spg_set_id' ) ), |
74 | | - 'swl_users_per_group' => array( 'INNER JOIN', array( 'spg_group_id=upg_group_id' ) ), |
75 | 88 | ) ); |
76 | 89 | |
| 90 | + if ( $isUserFilter ) { |
| 91 | + $this->addJoinConds( array( |
| 92 | + 'swl_users_per_group' => array( 'INNER JOIN', array( 'spg_group_id=upg_group_id' ) ), |
| 93 | + ) ); |
| 94 | + } |
| 95 | + |
77 | 96 | $this->addFields( array( |
78 | 97 | 'spe_set_id', |
79 | 98 | 'edit_user_name', |
— | — | @@ -82,7 +101,7 @@ |
83 | 102 | ) ); |
84 | 103 | |
85 | 104 | $this->addWhere( array( |
86 | | - 'upg_user_id' => $userId |
| 105 | + ( $isUserFilter ? 'upg_user_id' : 'spg_group_id' ) => $filter |
87 | 106 | ) ); |
88 | 107 | |
89 | 108 | $this->addOption( 'DISTINCT' ); |
— | — | @@ -111,15 +130,18 @@ |
112 | 131 | return array ( |
113 | 132 | 'userid' => array( |
114 | 133 | ApiBase::PARAM_TYPE => 'integer', |
115 | | - ApiBase::PARAM_REQUIRED => true, |
116 | 134 | ), |
| 135 | + 'groupids' => array( |
| 136 | + ApiBase::PARAM_TYPE => 'integer', |
| 137 | + ApiBase::PARAM_ISMULTI => true, |
| 138 | + ), |
117 | 139 | 'limit' => array( |
118 | 140 | ApiBase :: PARAM_DFLT => 20, |
119 | 141 | ApiBase :: PARAM_TYPE => 'limit', |
120 | 142 | ApiBase :: PARAM_MIN => 1, |
121 | 143 | ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
122 | 144 | ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
123 | | - ), |
| 145 | + ), |
124 | 146 | 'continue' => null, |
125 | 147 | ); |
126 | 148 | } |
— | — | @@ -131,6 +153,7 @@ |
132 | 154 | public function getParamDescription() { |
133 | 155 | return array ( |
134 | 156 | 'userid' => 'The ID of the user for which to return semantic watchlist data.', |
| 157 | + 'groupids' => 'The IDs of the groups for which to return semantic watchlist data.', |
135 | 158 | 'continue' => 'Offset number from where to continue the query', |
136 | 159 | 'limit' => 'Max amount of words to return', |
137 | 160 | ); |
— | — | @@ -141,7 +164,7 @@ |
142 | 165 | * @see includes/api/ApiBase#getDescription() |
143 | 166 | */ |
144 | 167 | public function getDescription() { |
145 | | - return 'Returns a list of modified properties per page for a persons semantic watchlist.'; |
| 168 | + return 'Returns a list of sets of changes for the either specified user of specified group(s).'; |
146 | 169 | } |
147 | 170 | |
148 | 171 | /** |
— | — | @@ -162,6 +185,8 @@ |
163 | 186 | return array ( |
164 | 187 | 'api.php?action=query&list=semanticwatchlist&swuserid=1', |
165 | 188 | 'api.php?action=query&list=semanticwatchlist&swuserid=1&swlimit=42&swcontinue=20110514143957-9001', |
| 189 | + 'api.php?action=query&list=semanticwatchlist&swgroupids=1', |
| 190 | + 'api.php?action=query&list=semanticwatchlist&swgroupids=1|42&swlimit=34', |
166 | 191 | ); |
167 | 192 | } |
168 | 193 | |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -63,6 +63,9 @@ |
64 | 64 | 'swl-prefs-namespace-label' => "'''$1''': {{PLURAL:$2|property|properties}} $3 from namespace ''$4''", |
65 | 65 | 'swl-prefs-concept-label' => "'''$1''': {{PLURAL:$2|property|properties}} $3 from concept ''$4''", |
66 | 66 | 'swl-prefs-emailnofity' => 'E-mail me on changes to properties I am watching', |
| 67 | + |
| 68 | + // API |
| 69 | + 'swl-err-userid-xor-groupids' => 'Either the userid or the groupids parameter needs to be specified, but not both.', |
67 | 70 | ); |
68 | 71 | |
69 | 72 | /** Message documentation (Message documentation) |