r109326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109325‎ | r109326 | r109327 >
Date:06:42, 18 January 2012
Author:raindrift
Status:ok (Comments)
Tags:
Comment:
API for congress lookup errort reporting
Modified paths:
  • /trunk/extensions/CongressLookup/ApiCongressLookup.php (added) (history)
  • /trunk/extensions/CongressLookup/CongressLookup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CongressLookup/CongressLookup.php
@@ -50,6 +50,10 @@
5151
5252 $dir = dirname( __FILE__ ) . '/';
5353
 54+//API
 55+$wgAutoloadClasses['ApiCongressLookup'] = $dir . 'ApiCongressLookup.php';
 56+$wgAPIModules['congresslookup'] = 'ApiCongressLookup';
 57+
5458 $wgAutoloadClasses['SpecialCongressLookup'] = $dir . 'SpecialCongressLookup.php';
5559 $wgAutoloadClasses['CongressLookupDB'] = $dir . 'CongressLookup.db.php';
5660 $wgExtensionMessagesFiles['CongressLookup'] = $dir . 'CongressLookup.i18n.php';
Index: trunk/extensions/CongressLookup/ApiCongressLookup.php
@@ -0,0 +1,82 @@
 2+<?php
 3+
 4+/**
 5+ * API module that records problems with Congress
 6+ */
 7+class ApiCongressLookup extends ApiBase {
 8+ public function __construct( $main, $action ) {
 9+ parent::__construct( $main, $action );
 10+ }
 11+
 12+ public function execute() {
 13+
 14+ $params = $this->extractRequestParams();
 15+
 16+ $res = array();
 17+
 18+ $dbw = wfGetDb( DB_MASTER );
 19+
 20+ $res = $dbw->insert(
 21+ 'cl_errors',
 22+ array(
 23+ 'cle_zip' => $params['zip'],
 24+ 'cc_comment' => $params['comment']
 25+ ),
 26+ __METHOD__,
 27+ array()
 28+ );
 29+
 30+ $this->getResult()->addValue( null, $this->getModuleName(), 'OK' );
 31+ }
 32+
 33+ public function mustBePosted() {
 34+ return true;
 35+ }
 36+
 37+ public function isWriteMode() {
 38+ return true;
 39+ }
 40+
 41+ public function getAllowedParams() {
 42+ return array(
 43+ 'zip' => array(
 44+ ApiBase::PARAM_TYPE => 'integer',
 45+ ApiBase::PARAM_REQUIRED => true
 46+ ),
 47+ 'comment' => array(
 48+ ApiBase::PARAM_TYPE => 'string',
 49+ ApiBase::PARAM_REQUIRED => true
 50+ ),
 51+ 'token' => null,
 52+ );
 53+ }
 54+
 55+ public function getParamDescription() {
 56+ return array(
 57+ 'zip' => 'the zipcode with a problem',
 58+ 'comment' => 'whatever the user has to say about that problem',
 59+ );
 60+ }
 61+
 62+ public function getDescription() {
 63+ return 'Record errors regarding congressional representative lookups';
 64+ }
 65+
 66+ public function needsToken() {
 67+ return true;
 68+ }
 69+
 70+ public function getTokenSalt() {
 71+ return '';
 72+ }
 73+
 74+ public function getVersion() {
 75+ return __CLASS__ . ': $Id: $';
 76+ }
 77+
 78+ private function checkPermission( $user ) {
 79+ if ( $user->isBlocked( false ) ) {
 80+ $this->dieUsageMsg( array( 'blockedtext' ) );
 81+ }
 82+ }
 83+}
Property changes on: trunk/extensions/CongressLookup/ApiCongressLookup.php
___________________________________________________________________
Added: svn:eol-style
184 + native

Comments

#Comment by Aaron Schulz (talk | contribs)   07:00, 18 January 2012

Module should include 'problem' in the name...

Status & tagging log