r95301 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95300‎ | r95301 | r95302 >
Date:07:50, 23 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added base of API modules
Modified paths:
  • /trunk/extensions/Survey/api/ApiAddSurvey.php (modified) (history)
  • /trunk/extensions/Survey/api/ApiDeleteSurvey.php (modified) (history)
  • /trunk/extensions/Survey/api/ApiEditSurvey.php (modified) (history)
  • /trunk/extensions/Survey/api/ApiQuerySurveys.php (modified) (history)
  • /trunk/extensions/Survey/api/ApiSubmitSurvey.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/api/ApiDeleteSurvey.php
@@ -0,0 +1,63 @@
 2+<?php
 3+
 4+/**
 5+ * API module to delete surveys.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiDeleteSurvey.php
 10+ * @ingroup Survey
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiDeleteSurvey extends ApiBase {
 17+
 18+ public function __construct( $main, $action ) {
 19+ parent::__construct( $main, $action );
 20+ }
 21+
 22+ public function execute() {
 23+ global $wgUser;
 24+
 25+ if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
 26+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 27+ }
 28+
 29+ $params = $this->extractRequestParams();
 30+
 31+ }
 32+
 33+ public function getAllowedParams() {
 34+ return array(
 35+ );
 36+ }
 37+
 38+ public function getParamDescription() {
 39+ return array(
 40+ );
 41+ }
 42+
 43+ public function getDescription() {
 44+ return array(
 45+ ''
 46+ );
 47+ }
 48+
 49+ public function getPossibleErrors() {
 50+ return array_merge( parent::getPossibleErrors(), array(
 51+ ) );
 52+ }
 53+
 54+ protected function getExamples() {
 55+ return array(
 56+ 'api.php?action=deletesurvey&',
 57+ );
 58+ }
 59+
 60+ public function getVersion() {
 61+ return __CLASS__ . ': $Id$';
 62+ }
 63+
 64+}
Property changes on: trunk/extensions/Survey/api/ApiDeleteSurvey.php
___________________________________________________________________
Added: svn:keywords
165 + Id
Index: trunk/extensions/Survey/api/ApiSubmitSurvey.php
@@ -0,0 +1,63 @@
 2+<?php
 3+
 4+/**
 5+ * API module to submit surveys.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiSubmitSurvey.php
 10+ * @ingroup Survey
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiSubmitSurvey extends ApiBase {
 17+
 18+ public function __construct( $main, $action ) {
 19+ parent::__construct( $main, $action );
 20+ }
 21+
 22+ public function execute() {
 23+ global $wgUser;
 24+
 25+ if ( !$wgUser->isAllowed( 'surveysubmit' ) || $wgUser->isBlocked() ) {
 26+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 27+ }
 28+
 29+ $params = $this->extractRequestParams();
 30+
 31+ }
 32+
 33+ public function getAllowedParams() {
 34+ return array(
 35+ );
 36+ }
 37+
 38+ public function getParamDescription() {
 39+ return array(
 40+ );
 41+ }
 42+
 43+ public function getDescription() {
 44+ return array(
 45+ ''
 46+ );
 47+ }
 48+
 49+ public function getPossibleErrors() {
 50+ return array_merge( parent::getPossibleErrors(), array(
 51+ ) );
 52+ }
 53+
 54+ protected function getExamples() {
 55+ return array(
 56+ 'api.php?action=submitsurvey&',
 57+ );
 58+ }
 59+
 60+ public function getVersion() {
 61+ return __CLASS__ . ': $Id$';
 62+ }
 63+
 64+}
Property changes on: trunk/extensions/Survey/api/ApiSubmitSurvey.php
___________________________________________________________________
Added: svn:keywords
165 + Id
Index: trunk/extensions/Survey/api/ApiEditSurvey.php
@@ -0,0 +1,63 @@
 2+<?php
 3+
 4+/**
 5+ * API module to edit surveys.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiEditSurvey.php
 10+ * @ingroup Survey
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiEditSurvey extends ApiBase {
 17+
 18+ public function __construct( $main, $action ) {
 19+ parent::__construct( $main, $action );
 20+ }
 21+
 22+ public function execute() {
 23+ global $wgUser;
 24+
 25+ if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
 26+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 27+ }
 28+
 29+ $params = $this->extractRequestParams();
 30+
 31+ }
 32+
 33+ public function getAllowedParams() {
 34+ return array(
 35+ );
 36+ }
 37+
 38+ public function getParamDescription() {
 39+ return array(
 40+ );
 41+ }
 42+
 43+ public function getDescription() {
 44+ return array(
 45+ ''
 46+ );
 47+ }
 48+
 49+ public function getPossibleErrors() {
 50+ return array_merge( parent::getPossibleErrors(), array(
 51+ ) );
 52+ }
 53+
 54+ protected function getExamples() {
 55+ return array(
 56+ 'api.php?action=editsurvey&',
 57+ );
 58+ }
 59+
 60+ public function getVersion() {
 61+ return __CLASS__ . ': $Id$';
 62+ }
 63+
 64+}
Property changes on: trunk/extensions/Survey/api/ApiEditSurvey.php
___________________________________________________________________
Added: svn:keywords
165 + Id
Index: trunk/extensions/Survey/api/ApiAddSurvey.php
@@ -0,0 +1,63 @@
 2+<?php
 3+
 4+/**
 5+ * API module to add surveys.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiAddSurvey.php
 10+ * @ingroup Survey
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiAddSurvey extends ApiBase {
 17+
 18+ public function __construct( $main, $action ) {
 19+ parent::__construct( $main, $action );
 20+ }
 21+
 22+ public function execute() {
 23+ global $wgUser;
 24+
 25+ if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
 26+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 27+ }
 28+
 29+ $params = $this->extractRequestParams();
 30+
 31+ }
 32+
 33+ public function getAllowedParams() {
 34+ return array(
 35+ );
 36+ }
 37+
 38+ public function getParamDescription() {
 39+ return array(
 40+ );
 41+ }
 42+
 43+ public function getDescription() {
 44+ return array(
 45+ ''
 46+ );
 47+ }
 48+
 49+ public function getPossibleErrors() {
 50+ return array_merge( parent::getPossibleErrors(), array(
 51+ ) );
 52+ }
 53+
 54+ protected function getExamples() {
 55+ return array(
 56+ 'api.php?action=addsurvey&',
 57+ );
 58+ }
 59+
 60+ public function getVersion() {
 61+ return __CLASS__ . ': $Id$';
 62+ }
 63+
 64+}
Property changes on: trunk/extensions/Survey/api/ApiAddSurvey.php
___________________________________________________________________
Added: svn:keywords
165 + Id
Index: trunk/extensions/Survey/api/ApiQuerySurveys.php
@@ -0,0 +1,101 @@
 2+<?php
 3+
 4+/**
 5+ * API module to get a list of surveys.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiQuerySurveys.php
 10+ * @ingroup Surveys
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiQuerySurveys extends ApiQueryBase {
 17+
 18+ public function __construct( $main, $action ) {
 19+ parent :: __construct( $main, $action, 'su' );
 20+ }
 21+
 22+ /**
 23+ * Retrieve the specil words from the database.
 24+ */
 25+ public function execute() {
 26+ global $wgUser;
 27+
 28+ if ( $wgUser->isBlocked() ) {
 29+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 30+ }
 31+
 32+ // Get the requests parameters.
 33+ $params = $this->extractRequestParams();
 34+
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see includes/api/ApiBase#getAllowedParams()
 40+ */
 41+ public function getAllowedParams() {
 42+ return array (
 43+ 'surveyids' => array(
 44+ ApiBase::PARAM_TYPE => 'integer',
 45+ ),
 46+ 'limit' => array(
 47+ ApiBase :: PARAM_DFLT => 20,
 48+ ApiBase :: PARAM_TYPE => 'limit',
 49+ ApiBase :: PARAM_MIN => 1,
 50+ ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
 51+ ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
 52+ ),
 53+ 'continue' => null,
 54+ );
 55+
 56+ }
 57+
 58+ /**
 59+ * (non-PHPdoc)
 60+ * @see includes/api/ApiBase#getParamDescription()
 61+ */
 62+ public function getParamDescription() {
 63+ return array (
 64+ 'surveyids' => 'The IDs of the surveys to return',
 65+ 'continue' => 'Offset number from where to continue the query',
 66+ 'limit' => 'Max amount of words to return',
 67+ );
 68+ }
 69+
 70+ /**
 71+ * (non-PHPdoc)
 72+ * @see includes/api/ApiBase#getDescription()
 73+ */
 74+ public function getDescription() {
 75+ return '';
 76+ }
 77+
 78+ /**
 79+ * (non-PHPdoc)
 80+ * @see includes/api/ApiBase#getPossibleErrors()
 81+ */
 82+ public function getPossibleErrors() {
 83+ return array_merge( parent::getPossibleErrors(), array(
 84+
 85+ ) );
 86+ }
 87+
 88+ /**
 89+ * (non-PHPdoc)
 90+ * @see includes/api/ApiBase#getExamples()
 91+ */
 92+ protected function getExamples() {
 93+ return array (
 94+ 'api.php?action=query&list=surveys&',
 95+ );
 96+ }
 97+
 98+ public function getVersion() {
 99+ return __CLASS__ . ': $Id$';
 100+ }
 101+
 102+}
Property changes on: trunk/extensions/Survey/api/ApiQuerySurveys.php
___________________________________________________________________
Added: svn:keywords
1103 + Id

Follow-up revisions

RevisionCommit summaryAuthorDate
r95302fu r95301jeroendedauw08:00, 23 August 2011

Status & tagging log