Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -263,6 +263,19 @@ |
264 | 264 | 'right-aftv5-see-deleted-feedback' => 'View deleted feedback', |
265 | 265 | 'right-aftv5-see-hidden-feedback' => 'View hidden feedback', |
266 | 266 | |
| 267 | + // Log types |
| 268 | + 'articlefeedbackv5-log-name' => 'Article Feedback Activity Log', |
| 269 | + 'articlefeedbackv5-log-header' => 'This is the log of activity taken on feedback items collected for articles using Article Feedback.', |
| 270 | + 'articlefeedbackv5-log-oversight' => 'changed the feedback [[$1]] status to oversight', |
| 271 | + 'articlefeedbackv5-log-unoversight' => 'removed the oversight [[$1]] status from feedback', |
| 272 | + 'articlefeedbackv5-log-hidden' => 'hid the feedback [[$1]]', |
| 273 | + 'articlefeedbackv5-log-unhidden' => 'unhid the feedback [[$1]]', |
| 274 | + 'articlefeedbackv5-log-decline' => 'declined oversight request from the feedback [[$1]]', |
| 275 | + 'articlefeedbackv5-log-request' => 'requested oversight on the feedback [[$1]]', |
| 276 | + 'articlefeedbackv5-log-unrequest' => 'removed the requested oversight on the feedback [[$1]]', |
| 277 | + 'articlefeedbackv5-log-flag' => 'flagged the feedback [[$1]] as abuse', |
| 278 | + 'articlefeedbackv5-log-unflag' => 'unflagged the feedback [[$1]] as abuse', |
| 279 | + |
267 | 280 | /* EmailCapture */ |
268 | 281 | 'articlefeedbackv5-emailcapture-response-body' => 'Hello! |
269 | 282 | |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -287,3 +287,17 @@ |
288 | 288 | $wgAvailableRights[] = 'aftv5-delete-feedback'; |
289 | 289 | $wgAvailableRights[] = 'aftv5-see-deleted-feedback'; |
290 | 290 | $wgAvailableRights[] = 'aftv5-see-hidden-feedback'; |
| 291 | + |
| 292 | +// Logging |
| 293 | +$wgLogTypes[] = 'articlefeedbackv5'; |
| 294 | +$wgLogNames['articlefeedbackv5'] = 'articlefeedbackv5-log-name'; |
| 295 | +$wgLogHeaders['articlefeedbackv5'] = 'articlefeedbackv5-log-header'; |
| 296 | +$wgLogActions['articlefeedbackv5/oversight'] = 'articlefeedbackv5-log-oversight'; |
| 297 | +$wgLogActions['articlefeedbackv5/unoversight'] = 'articlefeedbackv5-log-unoversight'; |
| 298 | +$wgLogActions['articlefeedbackv5/hidden'] = 'articlefeedbackv5-log-hidden'; |
| 299 | +$wgLogActions['articlefeedbackv5/unhidden'] = 'articlefeedbackv5-log-unhidden'; |
| 300 | +$wgLogActions['articlefeedbackv5/decline'] = 'articlefeedbackv5-log-decline'; |
| 301 | +$wgLogActions['articlefeedbackv5/request'] = 'articlefeedbackv5-log-request'; |
| 302 | +$wgLogActions['articlefeedbackv5/unrequest'] = 'articlefeedbackv5-log-unrequest'; |
| 303 | +$wgLogActions['articlefeedbackv5/flag'] = 'articlefeedbackv5-log-flag'; |
| 304 | +$wgLogActions['articlefeedbackv5/unflag'] = 'articlefeedbackv5-log-unflag'; |
\ No newline at end of file |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | public function execute() { |
26 | 26 | $params = $this->extractRequestParams(); |
27 | 27 | $pageId = $params['pageid']; |
| 28 | + $feedbackId = $params['feedbackid']; |
28 | 29 | $flag = $params['flagtype']; |
29 | 30 | $direction = isset( $params['direction'] ) ? $params['direction'] : 'increase'; |
30 | 31 | $counts = array( 'increment' => array(), 'decrement' => array() ); |
— | — | @@ -32,15 +33,16 @@ |
33 | 34 | $results = array(); |
34 | 35 | $helpful = null; |
35 | 36 | $error = null; |
36 | | - $where = array( 'af_id' => $params['feedbackid'] ); |
| 37 | + $where = array( 'af_id' => $feedbackId ); |
37 | 38 | |
38 | 39 | # load feedback record, bail if we don't have one |
39 | | - $record = $this->fetchRecord( $params['feedbackid'] ); |
| 40 | + $record = $this->fetchRecord( $feedbackId ); |
40 | 41 | |
41 | 42 | if ( $record === false || !$record->af_id ) { |
42 | 43 | // no-op, because this is already broken |
43 | 44 | $error = 'articlefeedbackv5-invalid-feedback-id'; |
44 | 45 | } elseif ( in_array( $flag, $flags ) ) { |
| 46 | + |
45 | 47 | $count = null; |
46 | 48 | switch( $flag ) { |
47 | 49 | case 'hide': |
— | — | @@ -159,6 +161,13 @@ |
160 | 162 | |
161 | 163 | // If the query worked... |
162 | 164 | if( $success ) { |
| 165 | + |
| 166 | + // Log the feedback activity entry via the utils method |
| 167 | + $activity = $this->getActivity( $flag, $direction ); |
| 168 | + |
| 169 | + // TODO: when activities have notes attached, they need to be fed as the last parameter |
| 170 | + ApiArticleFeedbackv5Utils::logActivity( $activity , $pageId, $feedbackId, 'placeholder activity notes' ); |
| 171 | + |
163 | 172 | // Update the filter count rollups. |
164 | 173 | ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] ); |
165 | 174 | ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] ); |
— | — | @@ -193,6 +202,7 @@ |
194 | 203 | __METHOD__ |
195 | 204 | ); |
196 | 205 | } |
| 206 | + |
197 | 207 | } |
198 | 208 | |
199 | 209 | // Conditional formatting for abuse flag |
— | — | @@ -336,6 +346,47 @@ |
337 | 347 | } |
338 | 348 | |
339 | 349 | /** |
| 350 | + * Figures out which activity happened so it can be logged correctly |
| 351 | + * |
| 352 | + * @param $flag string type of flag sent to the form |
| 353 | + * @param $direction string type of direction sent to the form |
| 354 | + * @return string name of activity to log |
| 355 | + */ |
| 356 | + protected function getActivity($flag, $direction) { |
| 357 | + |
| 358 | + // handle flag as abuse / remove abuse flag |
| 359 | + if ( 'abuse' == $flag && 'increase' == $direction) { |
| 360 | + return 'flag'; |
| 361 | + } elseif ( 'abuse' == $flag && 'decrease' == $direction) { |
| 362 | + return 'unflag'; |
| 363 | + } |
| 364 | + |
| 365 | + // handle hide as hidden, unhidden |
| 366 | + if ( 'hide' == $flag && 'increase' == $direction) { |
| 367 | + return 'hidden'; |
| 368 | + } elseif ( 'hide' == $flag && 'decrease' == $direction) { |
| 369 | + return 'unhidden'; |
| 370 | + } |
| 371 | + |
| 372 | + // handle delete as oversight, unoversight |
| 373 | + if ( 'delete' == $flag && 'increase' == $direction) { |
| 374 | + return 'oversight'; |
| 375 | + } elseif ( 'delete' == $flag && 'decrease' == $direction) { |
| 376 | + return 'unoversight'; |
| 377 | + } |
| 378 | + |
| 379 | + // handle oversight as request and unrequest oversighting |
| 380 | + if ( 'oversight' == $flag && 'increase' == $direction) { |
| 381 | + return 'request'; |
| 382 | + } elseif ( 'oversight' == $flag && 'decrease' == $direction) { |
| 383 | + return 'unrequest'; |
| 384 | + } |
| 385 | + |
| 386 | + // TODO: how is "decline oversight" handled? |
| 387 | + // how should fall out the bottom here be handled? a simple "feedback altered"? |
| 388 | + } |
| 389 | + |
| 390 | + /** |
340 | 391 | * Gets the version info |
341 | 392 | * |
342 | 393 | * @return string the SVN version info |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -215,4 +215,36 @@ |
216 | 216 | |
217 | 217 | $dbw->commit(); |
218 | 218 | } |
| 219 | + |
| 220 | + /** |
| 221 | + * Adds an activity item to the global log under the articlefeedbackv5 |
| 222 | + * |
| 223 | + * @param $type string the type of activity we'll be logging |
| 224 | + * @param $pageId int the id of the page so we can look it up |
| 225 | + * @param $itemId int the id of the feedback item, used to build permalinks |
| 226 | + * @param $notes string any notes that were stored with the activity |
| 227 | + */ |
| 228 | + public static function logActivity( $type, $pageId, $itemId, $notes) { |
| 229 | + |
| 230 | + // These are our valid activity log actions |
| 231 | + $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden', |
| 232 | + 'decline', 'request', 'unrequest','flag','unflag' ); |
| 233 | + |
| 234 | + // if we do not have a valid action, return immediately |
| 235 | + if ( !in_array( $type, $valid )) { |
| 236 | + return; |
| 237 | + } |
| 238 | + |
| 239 | + // create a title for the page |
| 240 | + $page = Title::newFromID( $pageId ); |
| 241 | + $title = $page->getPartialURL(); |
| 242 | + |
| 243 | + // to build our permalink, use the feedback entry key |
| 244 | + $title = SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$title/$itemId" ); |
| 245 | + |
| 246 | + $log = new LogPage( 'articlefeedbackv5' ); |
| 247 | + // comments become the notes section from the feedback |
| 248 | + $log->addEntry( $type, $title, $notes ); |
| 249 | + } |
219 | 250 | } |
| 251 | + |