Index: trunk/extensions/CongressLookup/CongressLookup.php |
— | — | @@ -50,6 +50,10 @@ |
51 | 51 | |
52 | 52 | $dir = dirname( __FILE__ ) . '/'; |
53 | 53 | |
| 54 | +//API |
| 55 | +$wgAutoloadClasses['ApiCongressLookup'] = $dir . 'ApiCongressLookup.php'; |
| 56 | +$wgAPIModules['congresslookup'] = 'ApiCongressLookup'; |
| 57 | + |
54 | 58 | $wgAutoloadClasses['SpecialCongressLookup'] = $dir . 'SpecialCongressLookup.php'; |
55 | 59 | $wgAutoloadClasses['CongressLookupDB'] = $dir . 'CongressLookup.db.php'; |
56 | 60 | $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 |
1 | 84 | + native |