r99006 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99005‎ | r99006 | r99007 >
Date:14:22, 5 October 2011
Author:reedy
Status:ok
Tags:
Comment:
MFT r99005
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/UserDailyContribs/UserDailyContribs.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/UserDailyContribs/api/ApiUserDailyContribs.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/UserDailyContribs/api/ApiUserDailyContribs.php
@@ -1,4 +1,4 @@
2 -<?php
 2+<?php
33
44 class ApiUserDailyContribs extends ApiBase {
55
@@ -8,17 +8,18 @@
99
1010 $userName = $params['user'];
1111 $days = $params['daysago'];
12 - $user = User::newFromName($userName);
 12+ $user = User::newFromName( $userName );
 13+
1314 if ( !$user ) {
14 - $this->dieUsage( 'Specified user does not exist', 'bad_user' );
 15+ $this->dieUsage( 'Invalid username', 'bad_user' );
1516 }
16 -
 17+
1718 $now = time();
1819 $result->addValue( $this->getModuleName() ,
1920 'id', $user->getId() );
2021 // returns date of registration in YYYYMMDDHHMMSS format
2122 $result->addValue( $this->getModuleName() ,
22 - 'registration', $user->getRegistration() ? '0' : $user->getRegistration() );
 23+ 'registration', !$user->getRegistration() ? '0' : $user->getRegistration() );
2324 // returns number of edits since daysago param
2425 $result->addValue( $this->getModuleName() ,
2526 'timeFrameEdits', getUserEditCountSince( $now - ($days * 60 *60 *24), $user ) );
@@ -30,13 +31,12 @@
3132 public function getAllowedParams() {
3233 return array(
3334 'user' => array(
34 - ApiBase::PARAM_TYPE => 'user',
35 - ),
 35+ ApiBase::PARAM_TYPE => 'user',
 36+ ),
3637 'daysago' => array(
3738 ApiBase::PARAM_TYPE => 'integer',
3839 ApiBase::PARAM_MIN => 0,
39 - ),
40 -
 40+ ),
4141 );
4242 }
4343
@@ -51,6 +51,12 @@
5252 return 'Get the total number of user edits, time of registration, and edits in a given timeframe';
5353 }
5454
 55+ public function getPossibleErrors() {
 56+ return array_merge( parent::getPossibleErrors(), array(
 57+ array( 'code' => 'bad_user', 'info' => 'Invalid username' )
 58+ ) );
 59+ }
 60+
5561 protected function getExamples() {
5662 return 'api.php?action=userdailycontribs&user=WikiSysop&daysago=5';
5763 }
@@ -58,5 +64,5 @@
5965 public function getVersion() {
6066 return __CLASS__ . ': $Id$';
6167 }
62 -
 68+
6369 }
\ No newline at end of file
Index: branches/wmf/1.18wmf1/extensions/UserDailyContribs/UserDailyContribs.php
@@ -1,12 +1,12 @@
22 <?php
33 /**
44 * User Daily Contributions extension
5 - *
 5+ *
66 * This extension adds a step to saving an article that incriments a counter for a user's activity in a given day.
7 - *
 7+ *
88 * @file
99 * @ingroup Extensions
10 - *
 10+ *
1111 * @author Nimish Gautam <ngautam@wikimedia.org>
1212 * @author Trevor Parscal <tparscal@wikimedia.org>
1313 * @license GPL v2 or later
@@ -35,11 +35,12 @@
3636 * Get the number of revisions a user has made since a given time
3737 *
3838 * @param $time beginning timestamp
 39+ * @param $user User
3940 * @return number of revsions this user has made
4041 */
4142 function getUserEditCountSince( $time = null, User $user = null ) {
4243 global $wgUser;
43 -
 44+
4445 // Fallback on current user
4546 if ( is_null( $user ) ) {
4647 $user = $wgUser;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99005http://en.wikipedia.org/w/api.php?action=userdailycontribs&amp;user=WikiSysop......reedy14:19, 5 October 2011

Status & tagging log