r113456 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113455‎ | r113456 | r113457 >
Date:06:21, 9 March 2012
Author:santhosh
Status:ok
Tags:
Comment:
Stylize
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -26,7 +26,7 @@
2727 * a piece of feedback
2828 *
2929 * A feedback request consists of
30 - * 1.
 30+ * 1.
3131 */
3232 public function execute() {
3333
@@ -63,13 +63,13 @@
6464 // no-op, because this is already broken
6565 $error = 'articlefeedbackv5-invalid-feedback-id';
6666
67 - } elseif ( 'delete' == $flag && $wgUser->isAllowed( 'aftv5-delete-feedback' )) {
 67+ } elseif ( 'delete' == $flag && $wgUser->isAllowed( 'aftv5-delete-feedback' ) ) {
6868
6969 // deleting means to "mark as oversighted" and "delete" it
7070 // oversighting also auto-hides the item
7171
7272 // increase means "oversight this"
73 - if( $direction == 'increase' ) {
 73+ if ( $direction == 'increase' ) {
7474 $activity = 'oversight';
7575
7676 // delete
@@ -81,16 +81,16 @@
8282 // delete specific filters
8383 $filters['deleted'] = 1;
8484 $filters['notdeleted'] = -1;
85 - if (true == $record->af_is_undeleted ) {
 85+ if ( true == $record->af_is_undeleted ) {
8686 $filters['undeleted'] = -1;
8787 }
8888
8989 // This is data for the "hidden by, oversighted by" red line
90 - $results['oversight-user'] = ApiArticleFeedbackv5Utils::getUserLink($wgUser);
 90+ $results['oversight-user'] = ApiArticleFeedbackv5Utils::getUserLink( $wgUser );
9191 $results['oversight-timestamp'] = wfTimestamp( TS_RFC2822, $timestamp );
9292
9393 // autohide if not hidden
94 - if (false == $record->af_is_hidden ) {
 94+ if ( false == $record->af_is_hidden ) {
9595 $update['af_is_hidden'] = true;
9696 $update['af_is_unhidden'] = false;
9797 $filters = $this->changeFilterCounts( $record, $filters, 'hide' );
@@ -101,7 +101,7 @@
102102 // tell front-end autohiding was done
103103 $results['autohidden'] = 1;
104104 // This is data for the "hidden by, oversighted by" red line
105 - $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
 105+ $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
106106 $results['hide-timestamp'] = wfTimestamp( TS_RFC2822, $timestamp );
107107 }
108108
@@ -118,10 +118,10 @@
119119 $filters['notdeleted'] = 1;
120120 }
121121
122 - } elseif ( 'hide' == $flag && $wgUser->isAllowed( 'aftv5-hide-feedback' )) {
 122+ } elseif ( 'hide' == $flag && $wgUser->isAllowed( 'aftv5-hide-feedback' ) ) {
123123
124124 // increase means "hide this"
125 - if( $direction == 'increase' ) {
 125+ if ( $direction == 'increase' ) {
126126 $activity = 'hidden';
127127
128128 // hide
@@ -133,7 +133,7 @@
134134 $filters = $this->changeFilterCounts( $record, $filters, 'hide' );
135135
136136 // This is data for the "hidden by, oversighted by" red line
137 - $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink($wgUser);
 137+ $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink( $wgUser );
138138 $results['hide-timestamp'] = wfTimestamp( TS_RFC2822, $timestamp );
139139
140140 } else {
@@ -146,7 +146,7 @@
147147 $filters = $this->changeFilterCounts( $record, $filters, 'show' );
148148 }
149149
150 - } elseif( 'resetoversight' === $flag && $wgUser->isAllowed( 'aftv5-delete-feedback' )) {
 150+ } elseif ( 'resetoversight' === $flag && $wgUser->isAllowed( 'aftv5-delete-feedback' ) ) {
151151
152152 $activity = 'decline';
153153 // oversight request count becomes 0
@@ -155,11 +155,11 @@
156156 $update['af_is_declined'] = true;
157157 $filters['declined'] = 1;
158158 // if the oversight count was greater then 1
159 - if(0 < $record->af_oversight_count) {
 159+ if ( 0 < $record->af_oversight_count ) {
160160 $filters['needsoversight'] = -1;
161161 }
162162
163 - } elseif( 'abuse' === $flag) {
 163+ } elseif ( 'abuse' === $flag ) {
164164
165165 // Conditional formatting for abuse flag
166166 global $wgArticleFeedbackv5AbusiveThreshold,
@@ -168,28 +168,28 @@
169169 $results['abuse_count'] = $record->af_abuse_count;
170170
171171 // Make the abuse count in the result reflect this vote.
172 - if( $direction == 'increase' ) {
173 - $results['abuse_count']++;
174 - } else {
175 - $results['abuse_count']--;
 172+ if ( $direction == 'increase' ) {
 173+ $results['abuse_count']++;
 174+ } else {
 175+ $results['abuse_count']--;
176176 }
177177 // no negative numbers
178 - $results['abuse_count'] = max(0, $results['abuse_count']);
 178+ $results['abuse_count'] = max( 0, $results['abuse_count'] );
179179
180180 // Return a flag in the JSON, that turns the link red.
181 - if( $results['abuse_count'] >= $wgArticleFeedbackv5AbusiveThreshold ) {
 181+ if ( $results['abuse_count'] >= $wgArticleFeedbackv5AbusiveThreshold ) {
182182 $results['abusive'] = 1;
183183 }
184184
185185 // Adding a new abuse flag: abusive++
186 - if($direction == 'increase') {
 186+ if ( $direction == 'increase' ) {
187187 $activity = 'flag';
188188 $filters['abusive'] = 1;
189189 // NOTE: we are bypassing traditional sql escaping here
190190 $update[] = "af_abuse_count = af_abuse_count + 1";
191191
192192 // Auto-hide after threshold flags
193 - if( $record->af_abuse_count > $wgArticleFeedbackv5HideAbuseThreshold
 193+ if ( $record->af_abuse_count > $wgArticleFeedbackv5HideAbuseThreshold
194194 && false == $record->af_is_hidden ) {
195195 // hide
196196 $update['af_is_hidden'] = true;
@@ -205,20 +205,20 @@
206206 // tell front-end autohiding was done
207207 $results['autohidden'] = 1;
208208 // This is data for the "hidden by, oversighted by" red line
209 - $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
 209+ $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
210210 $results['hide-timestamp'] = wfTimestamp( TS_RFC2822, $timestamp );
211211 }
212212 }
213 -
 213+
214214 // Removing the last abuse flag: abusive--
215 - elseif($direction == 'decrease') {
 215+ elseif ( $direction == 'decrease' ) {
216216 $activity = 'unflag';
217217 $filters['abusive'] = -1;
218218 // NOTE: we are bypassing traditional sql escaping here
219219 $update[] = "af_abuse_count = GREATEST(CONVERT(af_abuse_count, SIGNED) -1, 0)";
220220
221221 // Un-hide if we don't have 5 flags anymore
222 - if( $record->af_abuse_count == 5 && true == $record->af_is_hidden ) {
 222+ if ( $record->af_abuse_count == 5 && true == $record->af_is_hidden ) {
223223 $update['af_is_hidden'] = false;
224224 $update['af_is_unhidden'] = true;
225225
@@ -232,16 +232,16 @@
233233 }
234234
235235 // NOTE: this is actually request/unrequest oversight and works similar to abuse
236 - } elseif( 'oversight' === $flag && $wgUser->isAllowed( 'aftv5-hide-feedback' )) {
 236+ } elseif ( 'oversight' === $flag && $wgUser->isAllowed( 'aftv5-hide-feedback' ) ) {
237237
238 - if($direction == 'increase') {
 238+ if ( $direction == 'increase' ) {
239239 $activity = 'request';
240240 $filters['needsoversight'] = 1;
241241 // NOTE: we are bypassing traditional sql escaping here
242242 $update[] = "af_oversight_count = af_oversight_count + 1";
243243
244244 // autohide if not hidden
245 - if (false == $record->af_is_hidden ) {
 245+ if ( false == $record->af_is_hidden ) {
246246 $update['af_is_hidden'] = true;
247247 $update['af_is_unhidden'] = false;
248248 // 0 is used for "autohidden" purposes, we'll explicitly set it to overwrite last hider
@@ -253,17 +253,17 @@
254254 // tell front-end autohiding was done
255255 $results['autohidden'] = 1;
256256 // This is data for the "hidden by, oversighted by" red line
257 - $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
 257+ $results['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
258258 $results['hide-timestamp'] = wfTimestamp( TS_RFC2822, $timestamp );
259259 }
260260
261261 // IF the previous setting was 0, send an email
262 - if ( $record->af_oversight_count < 1) {
 262+ if ( $record->af_oversight_count < 1 ) {
263263
264264 $this->sendOversightEmail( $record->af_page_id , $feedbackId );
265265
266266 }
267 - } elseif($direction == 'decrease') {
 267+ } elseif ( $direction == 'decrease' ) {
268268 $activity = 'unrequest';
269269 $filters['needsoversight'] = -1;
270270 // NOTE: we are bypassing traditional sql escaping here
@@ -274,7 +274,7 @@
275275 }
276276
277277 // helpful and unhelpful flagging
278 - } elseif( 'unhelpful' === $flag || 'helpful' === $flag) {
 278+ } elseif ( 'unhelpful' === $flag || 'helpful' === $flag ) {
279279
280280 $results['toggle'] = $toggle;
281281 $helpful = $record->af_helpful_count;
@@ -282,10 +282,10 @@
283283
284284 // if toggle is on, we are decreasing one and increasing the other atomically
285285 // means one less http request and the counts don't mess up
286 - if (true == $toggle) {
 286+ if ( true == $toggle ) {
287287
288 - if( ( ($flag == 'helpful' && $direction == 'increase' )
289 - || ($flag == 'unhelpful' && $direction == 'decrease' ) )
 288+ if ( ( ( $flag == 'helpful' && $direction == 'increase' )
 289+ || ( $flag == 'unhelpful' && $direction == 'decrease' ) )
290290 ) {
291291 // NOTE: we are bypassing traditional sql escaping here
292292 $update[] = "af_helpful_count = af_helpful_count + 1";
@@ -293,8 +293,8 @@
294294 $helpful++;
295295 $unhelpful--;
296296
297 - } elseif ( ( ($flag == 'unhelpful' && $direction == 'increase' )
298 - || ($flag == 'helpful' && $direction == 'decrease' ) )
 297+ } elseif ( ( ( $flag == 'unhelpful' && $direction == 'increase' )
 298+ || ( $flag == 'helpful' && $direction == 'decrease' ) )
299299 ) {
300300 // NOTE: we are bypassing traditional sql escaping here
301301 $update[] = "af_unhelpful_count = af_unhelpful_count + 1";
@@ -305,11 +305,11 @@
306306
307307 } else {
308308
309 - if ( 'unhelpful' === $flag && $direction == 'increase') {
 309+ if ( 'unhelpful' === $flag && $direction == 'increase' ) {
310310 // NOTE: we are bypassing traditional sql escaping here
311311 $update[] = "af_unhelpful_count = af_unhelpful_count + 1";
312312 $unhelpful++;
313 - } elseif ( 'unhelpful' === $flag && $direction == 'decrease') {
 313+ } elseif ( 'unhelpful' === $flag && $direction == 'decrease' ) {
314314 // NOTE: we are bypassing traditional sql escaping here
315315 $update[] = "af_unhelpful_count = GREATEST(0, CONVERT(af_unhelpful_count, SIGNED) - 1)";
316316 $unhelpful--;
@@ -328,31 +328,31 @@
329329 $netHelpfulness = $helpful - $unhelpful;
330330
331331 // increase helpful OR decrease unhelpful
332 - if( ( ($flag == 'helpful' && $direction == 'increase' )
333 - || ($flag == 'unhelpful' && $direction == 'decrease' ) )
 332+ if ( ( ( $flag == 'helpful' && $direction == 'increase' )
 333+ || ( $flag == 'unhelpful' && $direction == 'decrease' ) )
334334 ) {
335335 // net was -1: no longer unhelpful
336 - if( $netHelpfulness == -1 ) {
 336+ if ( $netHelpfulness == -1 ) {
337337 $filters['unhelpful'] = -1;
338338 }
339 -
 339+
340340 // net was 0: now helpful
341 - if( $netHelpfulness == 0 ) {
 341+ if ( $netHelpfulness == 0 ) {
342342 $filters['helpful'] = 1;
343343 }
344344 }
345345
346346 // increase unhelpful OR decrease unhelpful
347 - if( ( ($flag == 'unhelpful' && $direction == 'increase' )
348 - || ($flag == 'helpful' && $direction == 'decrease' ) )
 347+ if ( ( ( $flag == 'unhelpful' && $direction == 'increase' )
 348+ || ( $flag == 'helpful' && $direction == 'decrease' ) )
349349 ) {
350350 // net was 1: no longer helpful
351 - if( $netHelpfulness == 1 ) {
 351+ if ( $netHelpfulness == 1 ) {
352352 $filters['helpful'] = -1;
353353 }
354 -
 354+
355355 // net was 0: now unhelpful
356 - if( $netHelpfulness == 0 ) {
 356+ if ( $netHelpfulness == 0 ) {
357357 $filters['unhelpful'] = 1;
358358 }
359359 }
@@ -362,7 +362,7 @@
363363 }
364364
365365 // we were valid
366 - if ( !isset($error) ) {
 366+ if ( !isset( $error ) ) {
367367
368368 $success = $dbw->update(
369369 'aft_article_feedback',
@@ -377,27 +377,27 @@
378378 $dbw->commit(); // everything went well, so we commit our db changes
379379
380380 // helpfulness counts are NOT logged, no activity is set
381 - if (isset($activity)) {
 381+ if ( isset( $activity ) ) {
382382 ApiArticleFeedbackv5Utils::logActivity( $activity , $pageId, $feedbackId, $notes );
383383 }
384384
385385 // handle implicit hide/show logging
386386 if ( isset( $implicit_hide ) && $implicit_hide ) {
387 - ApiArticleFeedbackv5Utils::logActivity( 'hidden' , $pageId, $feedbackId, '', true);
 387+ ApiArticleFeedbackv5Utils::logActivity( 'hidden' , $pageId, $feedbackId, '', true );
388388 }
389389
390390 // Update helpful/unhelpful display count after submission.
391391 if ( $flag == 'helpful' || $flag == 'unhelpful' ) {
392392
393393 // no negative numbers please
394 - $helpful = max(0, $helpful);
395 - $unhelpful = max(0, $unhelpful);
 394+ $helpful = max( 0, $helpful );
 395+ $unhelpful = max( 0, $unhelpful );
396396
397 - $results['helpful'] = wfMessage(
 397+ $results['helpful'] = wfMessage(
398398 'articlefeedbackv5-form-helpful-votes',
399399 $helpful, $unhelpful
400400 )->escaped();
401 -
 401+
402402 // Update net_helpfulness after flagging as helpful/unhelpful.
403403 $dbw->update(
404404 'aft_article_feedback',
@@ -449,7 +449,7 @@
450450 'af_is_undeleted',
451451 'af_is_declined',
452452 'af_has_comment',
453 - 'af_oversight_count'),
 453+ 'af_oversight_count' ),
454454 array( 'af_id' => $id )
455455 );
456456 return $record;
@@ -468,7 +468,7 @@
469469 // all, deleted, undeleted, and notdeleted
470470
471471 // use -1 (decrement) for hide, 1 for increment (show) - default is hide
472 - switch($action) {
 472+ switch( $action ) {
473473 case 'show':
474474 $int = 1;
475475 // if we're showing, this will increment
@@ -476,7 +476,7 @@
477477 break;
478478 default:
479479 // if we're hiding, and was unhidden, decrement
480 - if(true == $record->af_is_unhidden) {
 480+ if ( true == $record->af_is_unhidden ) {
481481 $filters['unhidden'] = -1;
482482 }
483483 $int = -1;
@@ -488,18 +488,18 @@
489489 $filters['invisible'] = -$int; // opposite of int
490490
491491 // comment
492 - if(true == $record->af_has_comment) {
 492+ if ( true == $record->af_has_comment ) {
493493 $filters['comment'] = $int;
494494 }
495495
496496 // abusive
497 - if( $record->af_abuse_count > 1 ) {
 497+ if ( $record->af_abuse_count > 1 ) {
498498 $filters['abusive'] = $int;
499499 }
500500 // helpful and unhelpful
501 - if( $record->af_net_helpfulness > 1 ) {
 501+ if ( $record->af_net_helpfulness > 1 ) {
502502 $filters['helpful'] = $int;
503 - } elseif( $record->af_net_helpfulness < 1 ) {
 503+ } elseif ( $record->af_net_helpfulness < 1 ) {
504504 $filters['unhelpful'] = $int;
505505 }
506506
@@ -618,7 +618,7 @@
619619 * @param int $page_id page id to grab info on
620620 * @param int $feedback_id identifier for the feedback item
621621 */
622 - protected function sendOversightEmail( $page_id, $feedback_id) {
 622+ protected function sendOversightEmail( $page_id, $feedback_id ) {
623623 global $wgUser;
624624
625625 // jobs need a title object
@@ -650,7 +650,7 @@
651651 'user_url' => $user_page->getCanonicalUrl(),
652652 'page_name' => $title_object->getText(),
653653 'page_url' => $title_object->getCanonicalUrl(),
654 - 'permalink' => $permalink->getCanonicalUrl());
 654+ 'permalink' => $permalink->getCanonicalUrl() );
655655
656656 $job = new ArticleFeedbackv5MailerJob( $title_object, $params );
657657 $job->insert();
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
@@ -109,7 +109,7 @@
110110
111111 // Per Fabrice 1/25, FeedbackPage only cares about option 1, so
112112 // don't bother updating the rollups if this is a different one.
113 - if( $bucket == 1 ) {
 113+ if ( $bucket == 1 ) {
114114 $this->updateRollupTables( $pageId, $revisionId, $userAnswers );
115115 $this->updateFilterCounts( $dbw, $pageId, $userAnswers );
116116 }
@@ -284,7 +284,7 @@
285285 public function updateFilterCounts( $dbw, $pageId, $answers ) {
286286
287287 // a new item should be in all and visible by default, increment those counters
288 - $filters = array( 'all' => 1, 'visible' => 1, 'notdeleted' => 1);
 288+ $filters = array( 'all' => 1, 'visible' => 1, 'notdeleted' => 1 );
289289
290290 // if this record has a comment attached then increment comment as well
291291 // notice we do not need to walk the entire array, since any one hit
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -95,11 +95,11 @@
9696 // This is in memcache so I don't feel that bad re-fetching it.
9797 // Needed to join in the comment and rating tables, for filtering
9898 // and sorting, respectively.
99 - foreach( ApiArticleFeedbackv5Utils::getFields() as $field ) {
100 - if( $field['afi_bucket_id'] == 1 && $field['afi_name'] == 'comment' ) {
 99+ foreach ( ApiArticleFeedbackv5Utils::getFields() as $field ) {
 100+ if ( $field['afi_bucket_id'] == 1 && $field['afi_name'] == 'comment' ) {
101101 $commentField = $field['afi_id'];
102102 }
103 - if( $field['afi_bucket_id'] == 1 && $field['afi_name'] == 'found' ) {
 103+ if ( $field['afi_bucket_id'] == 1 && $field['afi_name'] == 'found' ) {
104104 $ratingField = $field['afi_id'];
105105 }
106106 }
@@ -107,26 +107,26 @@
108108 // Build ORDER BY clause.
109109 switch( $sort ) {
110110 case 'helpful':
111 - $sortField = 'af_net_helpfulness';
 111+ $sortField = 'af_net_helpfulness';
112112 $order = "af_net_helpfulness $direction, af_id $direction";
113 - $continueSql = "(af_net_helpfulness $continueDirection ".intVal( $continue )
114 - ." OR (af_net_helpfulness = ".intVal( $continue )
115 - ." AND af_id $continueDirection ".intval( $continueId ).") )";
 113+ $continueSql = "(af_net_helpfulness $continueDirection " . intVal( $continue )
 114+ . " OR (af_net_helpfulness = " . intVal( $continue )
 115+ . " AND af_id $continueDirection " . intval( $continueId ) . ") )";
116116 break;
117117 case 'rating':
118118 # TODO: null ratings don't seem to show up at all. Need to sort that one out.
119119 $sortField = 'rating';
120120 $order = "yes_no $direction, af_id $direction";
121 - $continueSql = "(rating.aa_response_boolean $continueDirection ".intVal( $continue )
122 - ." OR (rating.aa_response_boolean = ".intVal( $continue )
123 - ." AND af_id $continueDirection ".intval( $continueId ).") )";
 121+ $continueSql = "(rating.aa_response_boolean $continueDirection " . intVal( $continue )
 122+ . " OR (rating.aa_response_boolean = " . intVal( $continue )
 123+ . " AND af_id $continueDirection " . intval( $continueId ) . ") )";
124124 break;
125125 case 'age':
126126 # Default field, fall through
127127 default:
128 - $sortField = 'af_id';
 128+ $sortField = 'af_id';
129129 $order = "af_id $direction";
130 - $continueSql = "af_id $continueDirection ".intVal( $continue );
 130+ $continueSql = "af_id $continueDirection " . intVal( $continue );
131131 break;
132132 }
133133
@@ -162,17 +162,17 @@
163163 $where,
164164 __METHOD__,
165165 array(
166 - 'LIMIT' => ($limit + 1),
 166+ 'LIMIT' => ( $limit + 1 ),
167167 'ORDER BY' => $order
168168 ),
169169 array(
170170 'rating' => array(
171171 'LEFT JOIN',
172 - 'rating.aa_feedback_id = af_id AND rating.aa_field_id = '.intval( $ratingField )
 172+ 'rating.aa_feedback_id = af_id AND rating.aa_field_id = ' . intval( $ratingField )
173173 ),
174174 'comment' => array(
175175 'LEFT JOIN',
176 - 'comment.aa_feedback_id = af_id AND comment.aa_field_id = '.intval( $commentField )
 176+ 'comment.aa_feedback_id = af_id AND comment.aa_field_id = ' . intval( $commentField )
177177 )
178178 )
179179 );
@@ -180,7 +180,7 @@
181181 foreach ( $id_query as $id ) {
182182 $ids[$id->af_id] = $id->af_id;
183183 // Get the continue values from the last counted item.
184 - if( count( $ids ) == $limit ) {
 184+ if ( count( $ids ) == $limit ) {
185185 $this->continue = $id->$sortField;
186186 $this->continueId = $id->af_id;
187187 }
@@ -252,7 +252,7 @@
253253 foreach ( $rows as $row ) {
254254 if ( !array_key_exists( $row->af_id, $ids ) ) {
255255 continue; // something has gone dreadfully wrong actually
256 - } elseif ( !is_array( $ids[$row->af_id] )) {
 256+ } elseif ( !is_array( $ids[$row->af_id] ) ) {
257257 $ids[$row->af_id] = array();
258258 $ids[$row->af_id][0] = $row;
259259 $ids[$row->af_id][0]->user_name = $row->user_name ? $row->user_name : $row->af_user_ip;
@@ -271,12 +271,12 @@
272272
273273 // Never show hidden or deleted posts unless specifically requested
274274 // and user has access.
275 - if( !in_array( $filter, $deletedFilters )
 275+ if ( !in_array( $filter, $deletedFilters )
276276 || !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
277277 $where[] = 'af_is_deleted IS FALSE';
278278 }
279279
280 - if( !in_array( $filter, $hiddenFilters )
 280+ if ( !in_array( $filter, $hiddenFilters )
281281 || !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
282282 $where[] = 'af_is_hidden IS FALSE';
283283 }
@@ -357,7 +357,7 @@
358358 if ( $can_vote ) {
359359 $footer_links .= Html::element( 'span', array(
360360 'class' => 'articleFeedbackv5-helpful-caption'
361 - ), wfMessage( 'articlefeedbackv5-form-helpful-label' )->text()
 361+ ), wfMessage( 'articlefeedbackv5-form-helpful-label' )->text()
362362 )
363363 . Html::element( 'a', array(
364364 'id' => "articleFeedbackv5-helpful-link-$id",
@@ -371,9 +371,9 @@
372372 $footer_links .= Html::element( 'span', array(
373373 'class' => 'articleFeedbackv5-helpful-votes',
374374 'id' => "articleFeedbackv5-helpful-votes-$id"
375 - ), wfMessage( 'articlefeedbackv5-form-helpful-votes',
 375+ ), wfMessage( 'articlefeedbackv5-form-helpful-votes',
376376 $wgLang->formatNum( $record[0]->af_helpful_count ),
377 - $wgLang->formatNum( $record[0]->af_unhelpful_count )
 377+ $wgLang->formatNum( $record[0]->af_unhelpful_count )
378378 )->text() );
379379 $footer_links .= Html::closeElement( 'div' );
380380 if ( $can_flag ) {
@@ -433,7 +433,7 @@
434434 }
435435
436436 // !can delete == request oversight
437 - if ( $can_hide && !$can_delete) {
 437+ if ( $can_hide && !$can_delete ) {
438438 if ( $record[0]->af_oversight_count > 0 ) {
439439 $msg = 'unoversight';
440440 $class = 'unrequestoversight';
@@ -457,7 +457,7 @@
458458 'id' => "articleFeedbackv5-declineoversight-link-$id",
459459 'class' => "articleFeedbackv5-declineoversight-link",
460460 'href' => '#',
461 - ), wfMessage( "articlefeedbackv5-form-decline")->text() ) );
 461+ ), wfMessage( "articlefeedbackv5-form-decline" )->text() ) );
462462 }
463463
464464 if ( $record[0]->af_is_deleted > 0 ) {
@@ -499,12 +499,12 @@
500500 );
501501 if ( $record[0]->af_is_hidden ) {
502502
503 - $attributes['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink($record[0]->af_hide_user_id, $default_user);
 503+ $attributes['hide-user'] = ApiArticleFeedbackv5Utils::getUserLink( $record[0]->af_hide_user_id, $default_user );
504504 $attributes['hide-timestamp'] = wfTimestamp( TS_RFC2822, $record[0]->af_hide_timestamp );
505505 }
506506 if ( $record[0]->af_is_deleted ) {
507507
508 - $attributes['oversight-user'] = ApiArticleFeedbackv5Utils::getUserLink($record[0]->af_oversight_user_id, $default_user);
 508+ $attributes['oversight-user'] = ApiArticleFeedbackv5Utils::getUserLink( $record[0]->af_oversight_user_id, $default_user );
509509 $attributes['oversight-timestamp'] = wfTimestamp( TS_RFC2822, $record[0]->af_oversight_timestamp );
510510 }
511511
@@ -515,7 +515,7 @@
516516 . $content
517517 . $footer_links
518518 . Html::closeElement( 'div' )
519 - //. $details
 519+ // . $details
520520 . $tools
521521 . Html::closeElement( 'div' );
522522 }
@@ -524,21 +524,21 @@
525525 global $wgLang;
526526 $id = $record->af_id;
527527 $title = $record->page_title;
528 -
 528+
529529 $blocks = array(
530530 array( 'total' => 60 * 60 * 24 * 365, 'name' => 'years' ),
531 - array( 'total' => 60 * 60 * 24 * 30, 'name' => 'months'),
532 - array( 'total' => 60 * 60 * 24 * 7, 'name' => 'weeks'),
533 - array( 'total' => 60 * 60 * 24, 'name' => 'days'),
534 - array( 'total' => 60 * 60, 'name' => 'hours'),
535 - array( 'total' => 60, 'name' => 'minutes') );
536 -
 531+ array( 'total' => 60 * 60 * 24 * 30, 'name' => 'months' ),
 532+ array( 'total' => 60 * 60 * 24 * 7, 'name' => 'weeks' ),
 533+ array( 'total' => 60 * 60 * 24, 'name' => 'days' ),
 534+ array( 'total' => 60 * 60, 'name' => 'hours' ),
 535+ array( 'total' => 60, 'name' => 'minutes' ) );
 536+
537537 $since = wfTimestamp( TS_UNIX ) - wfTimestamp( TS_UNIX, $record->af_created );
538538 $displayTime = 0;
539539 $displayBlock = '';
540 -
 540+
541541 // get the largest time block, 1 minute 35 seconds -> 2 minutes
542 - for( $i = 0, $count = count( $blocks ); $i < $count; $i++ ) {
 542+ for ( $i = 0, $count = count( $blocks ); $i < $count; $i++ ) {
543543 $seconds = $blocks[$i]['total'];
544544 $displayTime = floor( $since / $seconds );
545545
@@ -549,10 +549,10 @@
550550 if ( ( $since % $seconds ) >= ( $seconds / 2 ) ) {
551551 $displayTime++;
552552
553 - //advance to upper unit if possible, eg, 24 hours to 1 day
554 - if ( isset( $blocks[$i-1] ) && $displayTime * $seconds == $blocks[$i-1]['total'] ) {
 553+ // advance to upper unit if possible, eg, 24 hours to 1 day
 554+ if ( isset( $blocks[$i -1] ) && $displayTime * $seconds == $blocks[$i -1]['total'] ) {
555555 $displayTime = 1;
556 - $displayBlock = $blocks[$i-1]['name'];
 556+ $displayBlock = $blocks[$i -1]['name'];
557557 }
558558 }
559559 break;
@@ -583,13 +583,13 @@
584584 )
585585 . Html::closeElement( 'span' );
586586 }
587 -
588587
 588+
589589 private function renderBucket1( $record ) {
590590 if ( $record['found']->aa_response_boolean == 1 ) {
591591 $msg = 'articlefeedbackv5-form1-header-found';
592592 $class = 'positive';
593 - } elseif( $record['found']->aa_response_boolean !== null ) {
 593+ } elseif ( $record['found']->aa_response_boolean !== null ) {
594594 $msg = 'articlefeedbackv5-form1-header-not-found';
595595 $class = 'negative';
596596 } else {
@@ -716,7 +716,7 @@
717717
718718 private function feedbackHead( $message, $class, $record, $extra = '' ) {
719719 $name = htmlspecialchars( $record->user_name );
720 - if( $record->af_user_ip ) {
 720+ if ( $record->af_user_ip ) {
721721 // Anonymous user, go to contributions page.
722722 $title = SpecialPage::getTitleFor( 'Contributions', $record->user_name );
723723 } else {
@@ -726,10 +726,10 @@
727727
728728 // If user page doesn't exist, go someplace else.
729729 // Use the contributions page for now, but it's really up to Fabrice.
730 - if( !$title->exists() ) {
 730+ if ( !$title->exists() ) {
731731 $title = SpecialPage::getTitleFor( 'Contributions', $record->user_name );
732732 }
733 -
 733+
734734 $details = Html::openElement( 'span', array(
735735 'class' => 'articleFeedbackv5-comment-details-updates'
736736 ) );
@@ -741,11 +741,11 @@
742742 );
743743 $details .= Html::closeElement( 'span' );
744744
745 - return Html::openElement( 'h3', array( 'class' => $class) )
 745+ return Html::openElement( 'h3', array( 'class' => $class ) )
746746 . Html::element( 'span', array( 'class' => 'icon' ) )
747747 . Html::rawElement( 'span',
748748 array( 'class' => 'result' ),
749 - wfMessage( $message, $name )->rawParams(
 749+ wfMessage( $message, $name )->rawParams(
750750 Linker::link( $title, $name )
751751 )->escaped()
752752 )
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
@@ -162,11 +162,11 @@
163163 public static function updateFilterCounts( $dbw, $pageId, $filters ) {
164164
165165 // Don't do anything unless we have filters to process.
166 - if( empty( $filters ) || count($filters) < 1 ) {
167 - return;
 166+ if ( empty( $filters ) || count( $filters ) < 1 ) {
 167+ return;
168168 }
169169
170 - foreach ( $filters as $filter => $direction) {
 170+ foreach ( $filters as $filter => $direction ) {
171171 $rows[] = array(
172172 'afc_page_id' => $pageId,
173173 'afc_filter_name' => $filter,
@@ -183,8 +183,8 @@
184184 array( 'IGNORE' )
185185 );
186186
187 - foreach ( $filters as $filter => $direction) {
188 - $value = ($direction > 0) ? 'afc_filter_count + 1' : 'GREATEST(0, CONVERT(afc_filter_count, SIGNED) - 1)';
 187+ foreach ( $filters as $filter => $direction ) {
 188+ $value = ( $direction > 0 ) ? 'afc_filter_count + 1' : 'GREATEST(0, CONVERT(afc_filter_count, SIGNED) - 1)';
189189
190190 # Update each row with the new count.
191191 $dbw->update(
@@ -209,14 +209,14 @@
210210 * @param $notes string any notes that were stored with the activity
211211 * @param $auto boolean true if this was an "automatic" action, if so the log doer is changed
212212 */
213 - public static function logActivity( $type, $pageId, $itemId, $notes, $auto = false) {
 213+ public static function logActivity( $type, $pageId, $itemId, $notes, $auto = false ) {
214214
215215 // These are our valid activity log actions
216216 $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden',
217 - 'decline', 'request', 'unrequest','flag','unflag' );
 217+ 'decline', 'request', 'unrequest', 'flag', 'unflag' );
218218
219219 // if we do not have a valid action, return immediately
220 - if ( !in_array( $type, $valid )) {
 220+ if ( !in_array( $type, $valid ) ) {
221221 return;
222222 }
223223
@@ -224,7 +224,7 @@
225225 $title_object = Title::newFromID( $pageId );
226226
227227 // no title object? no page? well then no logging
228 - if (!$title_object) {
 228+ if ( !$title_object ) {
229229 return;
230230 }
231231
@@ -240,11 +240,11 @@
241241 $notes = $wgLang->truncate( $notes, $wgArticleFeedbackv5MaxActivityNoteLength );
242242
243243 // if this is an automatic action, we create our special extension doer and send
244 - if ($auto) {
 244+ if ( $auto ) {
245245 $default_user = wfMessage( 'articlefeedbackv5-default-user' )->text();
246246 $doer = User::newFromName( $default_user );
247247 // I cannot see how this could fail, but if it does do not log
248 - if (!$doer) {
 248+ if ( !$doer ) {
249249 return;
250250 }
251251 } else {
@@ -253,7 +253,7 @@
254254
255255 $log = new LogPage( 'articlefeedbackv5' );
256256 // comments become the notes section from the feedback
257 - $log->addEntry( $type, $permalink, $notes, array(), $doer);
 257+ $log->addEntry( $type, $permalink, $notes, array(), $doer );
258258
259259 // update our log count by 1
260260 $dbw = wfGetDB( DB_MASTER );
@@ -278,9 +278,9 @@
279279 * @param string $user_ip (name works too)
280280 * @return anchor tag link to user
281281 */
282 - public static function getUserLink($user_id, $user_ip = null) {
 282+ public static function getUserLink( $user_id, $user_ip = null ) {
283283 // if $user is not an object
284 - if ( !($user_id instanceof User) ){
 284+ if ( !( $user_id instanceof User ) ) {
285285 $userId = (int) $user_id;
286286 if ( $userId !== 0 ) { // logged-in users
287287 $user = User::newFromId( $userId );
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php
@@ -32,13 +32,13 @@
3333
3434 // If we can't hide, we can't see activity, return an empty string
3535 // front-end should never let you get here, but just in case
36 - if( !$wgUser->isAllowed( 'aftv5-hide-feedback' )) {
 36+ if ( !$wgUser->isAllowed( 'aftv5-hide-feedback' ) ) {
3737 $this->dieUsage( "You don't have permission to hide feedback", 'permissiondenied' );
3838 }
3939
4040 // These are our valid activity log actions
4141 $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden',
42 - 'decline', 'request', 'unrequest','flag','unflag' );
 42+ 'decline', 'request', 'unrequest', 'flag', 'unflag' );
4343
4444 // get our parameter information
4545 $params = $this->extractRequestParams();
@@ -50,19 +50,19 @@
5151 // fetch our activity database information
5252 $feedback = $this->fetchFeedback( $feedbackId );
5353 // if this is false, this is bad feedback - move along
54 - if( !$feedback ) {
 54+ if ( !$feedback ) {
5555 $this->dieUsage( "Feedback does not exist", 'invalidfeedbackid' );
5656 }
5757
5858 // get the string title for the page
5959 $page = Title::newFromID( $feedback->af_page_id );
60 - if( !$page ) {
 60+ if ( !$page ) {
6161 $this->dieUsage( "Page for feedback does not exist", 'invalidfeedbackid' );
6262 }
6363 $title = $page->getDBKey();
6464
6565 // get our activities
66 - $activities = $this->fetchActivity( $title, $feedbackId, $limit, $continue);
 66+ $activities = $this->fetchActivity( $title, $feedbackId, $limit, $continue );
6767
6868 // generate our html
6969 $html = '';
@@ -75,49 +75,49 @@
7676 $html .= Html::openElement( 'div', array(
7777 'class' => 'articleFeedbackv5-activity-pane'
7878 ) );
79 -
 79+
8080 // <div class="articleFeedbackv5-activity-feedback">
8181 $html .= Html::openElement( 'div', array(
8282 'class' => 'articleFeedbackv5-activity-feedback'
8383 ) );
84 -
 84+
8585 // <div>Feedback Post #{$feedbackid} by {$user_link}</div>
8686 $html .= Html::openElement( 'div', array() );
8787 $html .= wfMessage( 'articlefeedbackv5-activity-feedback-info',
88 - array($feedback->af_id))
89 - ->rawParams(ApiArticleFeedbackv5Utils::getUserLink($feedback->af_user_id, $feedback->af_user_ip))
 88+ array( $feedback->af_id ) )
 89+ ->rawParams( ApiArticleFeedbackv5Utils::getUserLink( $feedback->af_user_id, $feedback->af_user_ip ) )
9090 ->text();
9191 $html .= Html::closeElement( 'div' );
92 -
93 - //<div>Posted on {$date} (UTC)</div>
 92+
 93+ // <div>Posted on {$date} (UTC)</div>
9494 $html .= Html::element( 'div', array(),
9595 wfMessage( 'articlefeedbackv5-activity-feedback-date',
96 - array( $wgLang->timeanddate( $feedback->af_created ) ))->text() );
97 -
 96+ array( $wgLang->timeanddate( $feedback->af_created ) ) )->text() );
 97+
9898 // <div class="articleFeedbackv5-activity-feedback-permalink">
9999 $html .= Html::openElement( 'div', array(
100100 'class' => 'articleFeedbackv5-activity-feedback-permalink'
101101 ) );
102 -
 102+
103103 // <a href="{$permalink}">permalink</a>
104104 $html .= Linker::link(
105 - SpecialPage::getTitleFor( 'ArticleFeedbackv5', $title . '/'. $feedback->af_id ),
106 - wfMessage( 'articlefeedbackv5-activity-permalink' )->text());
107 -
 105+ SpecialPage::getTitleFor( 'ArticleFeedbackv5', $title . '/' . $feedback->af_id ),
 106+ wfMessage( 'articlefeedbackv5-activity-permalink' )->text() );
 107+
108108 // </div> for class="articleFeedbackv5-activity-feedback-permalink"
109109 $html .= Html::closeElement( 'div' );
110 -
 110+
111111 // </div> for class="articleFeedbackv5-activity-feedback"
112112 $html .= Html::closeElement( 'div' );
113 -
114 - //<div class="articleFeedbackv5-activity-count">$n actions on this post</div>
115 - $html .= Html::element( 'div', array('class' => 'articleFeedbackv5-activity-count'),
 113+
 114+ // <div class="articleFeedbackv5-activity-count">$n actions on this post</div>
 115+ $html .= Html::element( 'div', array( 'class' => 'articleFeedbackv5-activity-count' ),
116116 wfMessage( 'articlefeedbackv5-activity-count' )->numParams( $feedback->af_activity_count )->text() );
117 -
 117+
118118 // </div> for class="articleFeedbackv5-activity-pane"
119119 $html .= Html::closeElement( 'div' );
120 -
121 - //<div class="articleFeedbackv5-activity-log-items">
 120+
 121+ // <div class="articleFeedbackv5-activity-log-items">
122122 $html .= Html::openElement( 'div', array(
123123 'class' => 'articleFeedbackv5-activity-log-items'
124124 ) );
@@ -126,17 +126,17 @@
127127 $count = 0;
128128
129129 // divs of activity items
130 - foreach($activities as $item) {
 130+ foreach ( $activities as $item ) {
131131
132132 // if we do not have a valid action, skip this item
133 - if ( !in_array( $item->log_action, $valid )) {
 133+ if ( !in_array( $item->log_action, $valid ) ) {
134134 continue;
135135 }
136136
137137 $count++;
138138
139139 // figure out if we have more if we have another row past our limit
140 - if($count > $limit) {
 140+ if ( $count > $limit ) {
141141 break;
142142 }
143143
@@ -150,30 +150,30 @@
151151 // or the $user $did_something_on $date : $comment
152152 // because the colon hanging around would look utterly stupid
153153
154 - if ($item->log_comment == '') {
 154+ if ( $item->log_comment == '' ) {
155155 $html .= wfMessage( 'articlefeedbackv5-activity-item' )
156156 ->rawParams(
157 - ApiArticleFeedbackv5Utils::getUserLink($item->log_user, $item->log_user_text),
 157+ ApiArticleFeedbackv5Utils::getUserLink( $item->log_user, $item->log_user_text ),
158158 Html::element( 'span', array(
159159 'class' => 'articleFeedbackv5-activity-item-action'
160160 ),
161161 wfMessage( 'articlefeedbackv5-activity-' . $item->log_action,
162 - array())->text()),
163 - $wgLang->timeanddate( $item->log_timestamp ))
 162+ array() )->text() ),
 163+ $wgLang->timeanddate( $item->log_timestamp ) )
164164 ->text();
165165 } else {
166166 $html .= wfMessage( 'articlefeedbackv5-activity-item-comment' )
167167 ->rawParams(
168 - ApiArticleFeedbackv5Utils::getUserLink($item->log_user, $item->log_user_text),
 168+ ApiArticleFeedbackv5Utils::getUserLink( $item->log_user, $item->log_user_text ),
169169 Html::element( 'span', array(
170170 'class' => 'articleFeedbackv5-activity-item-action'
171171 ),
172172 wfMessage( 'articlefeedbackv5-activity-' . $item->log_action,
173 - array())->text()),
 173+ array() )->text() ),
174174 $wgLang->timeanddate( $item->log_timestamp ),
175175 Html::element( 'span',
176 - array('class' => 'articlefeedbackv5-activity-notes'),
177 - $item->log_comment))
 176+ array( 'class' => 'articlefeedbackv5-activity-notes' ),
 177+ $item->log_comment ) )
178178 ->text();
179179 }
180180
@@ -181,8 +181,8 @@
182182 $html .= Html::closeElement( 'div' );
183183 }
184184
185 - //optional <a href="#" class="articleFeedbackv5-activity-more">Show more Activity</a>
186 - if ($count > $limit) {
 185+ // optional <a href="#" class="articleFeedbackv5-activity-more">Show more Activity</a>
 186+ if ( $count > $limit ) {
187187 $html .= Html::element( 'a', array(
188188 'class' => "articleFeedbackv5-activity-more",
189189 'href' => '#',
@@ -191,19 +191,19 @@
192192
193193 // </div> for class="acticleFeedbackv5-activity-log-items"
194194 $html .= Html::closeElement( 'div' );
195 -
 195+
196196 // finally add our generated html data
197197 $result->addValue( $this->getModuleName(), 'limit', $limit );
198198 $result->addValue( $this->getModuleName(), 'activity', $html );
199199
200200 // continue only goes in if it's not empty
201 - if ($count > $limit) {
 201+ if ( $count > $limit ) {
202202 $this->setContinueEnumParameter( 'continue', $this->getContinue( $item ) );
203203 }
204204 }
205205
206206 /**
207 - * Gets some base feedback information
 207+ * Gets some base feedback information
208208 *
209209 * @param int $feedbackId identifier for the feedback item we are fetching activity for
210210 * @return int total number of activity items for feedback item
@@ -218,7 +218,7 @@
219219 'af_user_id',
220220 'af_user_ip',
221221 'af_created',
222 - 'af_activity_count'),
 222+ 'af_activity_count' ),
223223 array(
224224 'af_id' => $feedbackId,
225225 ),
@@ -241,7 +241,7 @@
242242 * @param mixed $continue used for offsets
243243 * @return array db record rows
244244 */
245 - protected function fetchActivity( $title, $feedbackId, $limit = 25, $continue = null) {
 245+ protected function fetchActivity( $title, $feedbackId, $limit = 25, $continue = null ) {
246246
247247 $where = array (
248248 'log_type' => 'articlefeedbackv5',
@@ -260,7 +260,7 @@
261261 'log_user',
262262 'log_user_text',
263263 'log_title',
264 - 'log_comment'),
 264+ 'log_comment' ),
265265 $where,
266266 __METHOD__,
267267 array(

Status & tagging log