r99056 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99055‎ | r99056 | r99057 >
Date:21:48, 5 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added challanges query API
Modified paths:
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/api/ApiQueryChallenges.php (added) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.php
@@ -51,6 +51,7 @@
5252
5353 $wgAutoloadClasses['ApiContestQuery'] = dirname( __FILE__ ) . '/api/ApiContestQuery.php';
5454 $wgAutoloadClasses['ApiDeleteContest'] = dirname( __FILE__ ) . '/api/ApiDeleteContest.php';
 55+$wgAutoloadClasses['ApiQueryChallenges'] = dirname( __FILE__ ) . '/api/ApiQueryChallenges.php';
5556 $wgAutoloadClasses['ApiQueryContestants'] = dirname( __FILE__ ) . '/api/ApiQueryContestants.php';
5657 $wgAutoloadClasses['ApiQueryContests'] = dirname( __FILE__ ) . '/api/ApiQueryContests.php';
5758
@@ -90,6 +91,7 @@
9192
9293 // API
9394 $wgAPIModules['deletecontest'] = 'ApiDeleteContest';
 95+$wgAPIListModules['challenges'] = 'ApiQueryChallenges';
9496 $wgAPIListModules['contestants'] = 'ApiQueryContestants';
9597 $wgAPIListModules['contests'] = 'ApiQueryContests';
9698
Index: trunk/extensions/Contest/api/ApiQueryChallenges.php
@@ -0,0 +1,66 @@
 2+<?php
 3+
 4+/**
 5+ * API module to get a list of contest challenges.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiQueryChallenges.php
 10+ * @ingroup Contest
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiQueryChallenges extends ApiContestQuery {
 17+
 18+ protected function getClassName() {
 19+ return 'ContestChallenge';
 20+ }
 21+
 22+ public function __construct( $main, $action ) {
 23+ parent::__construct( $main, $action, 'ch' );
 24+ }
 25+
 26+ /**
 27+ * Handle the API request.
 28+ * Checks for access rights and then let's the parent method do the actual work.
 29+ */
 30+ public function execute() {
 31+ global $wgUser;
 32+
 33+ if ( !$wgUser->isAllowed( 'contestadmin' ) || $wgUser->isBlocked() ) {
 34+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 35+ }
 36+
 37+ parent::execute();
 38+ }
 39+
 40+ /**
 41+ * (non-PHPdoc)
 42+ * @see includes/api/ApiBase#getDescription()
 43+ */
 44+ public function getDescription() {
 45+ return 'API module for querying contest challanges';
 46+ }
 47+
 48+ /**
 49+ * (non-PHPdoc)
 50+ * @see includes/api/ApiBase#getExamples()
 51+ */
 52+ protected function getExamples() {
 53+ return array (
 54+ 'api.php?action=query&list=challenges&chprops=title|text',
 55+ 'api.php?action=query&list=challenges&chcontestid=42&chprops=id|contest_id|title',
 56+ );
 57+ }
 58+
 59+ /**
 60+ * (non-PHPdoc)
 61+ * @see includes/api/ApiBase#getVersion()
 62+ */
 63+ public function getVersion() {
 64+ return __CLASS__ . ': $Id$';
 65+ }
 66+
 67+}
Property changes on: trunk/extensions/Contest/api/ApiQueryChallenges.php
___________________________________________________________________
Added: svn:eol-style
168 + native
Added: svn:keywords
269 + Id

Status & tagging log