r99050 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99049‎ | r99050 | r99051 >
Date:20:40, 5 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added contestants query API
Modified paths:
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/api/ApiQueryContestants.php (added) (history)
  • /trunk/extensions/Contest/api/ApiQueryContests.php (modified) (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['ApiQueryContestants'] = dirname( __FILE__ ) . '/api/ApiQueryContestants.php';
5556 $wgAutoloadClasses['ApiQueryContests'] = dirname( __FILE__ ) . '/api/ApiQueryContests.php';
5657
5758 $wgAutoloadClasses['Contest'] = dirname( __FILE__ ) . '/includes/Contest.class.php';
@@ -89,6 +90,7 @@
9091
9192 // API
9293 $wgAPIModules['deletecontest'] = 'ApiDeleteContest';
 94+$wgAPIListModules['contestants'] = 'ApiQueryContestants';
9395 $wgAPIListModules['contests'] = 'ApiQueryContests';
9496
9597 // Hooks
Index: trunk/extensions/Contest/api/ApiQueryContests.php
@@ -50,11 +50,15 @@
5151 */
5252 protected function getExamples() {
5353 return array (
54 - 'api.php?action=query&list=contests&props=id|name',
 54+ 'api.php?action=query&list=contests&coprops=id|name',
5555 'api.php?action=query&list=contests&costatus=1',
5656 );
5757 }
5858
 59+ /**
 60+ * (non-PHPdoc)
 61+ * @see includes/api/ApiBase#getVersion()
 62+ */
5963 public function getVersion() {
6064 return __CLASS__ . ': $Id$';
6165 }
Index: trunk/extensions/Contest/api/ApiQueryContestants.php
@@ -0,0 +1,66 @@
 2+<?php
 3+
 4+/**
 5+ * API module to get a list of contestants.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ApiQueryContestants.php
 10+ * @ingroup Contest
 11+ * @ingroup API
 12+ *
 13+ * @licence GNU GPL v3+
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class ApiQueryContestants extends ApiContestQuery {
 17+
 18+ protected function getClassName() {
 19+ return 'ContestContestant';
 20+ }
 21+
 22+ public function __construct( $main, $action ) {
 23+ parent::__construct( $main, $action, 'ct' );
 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 contestants';
 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=contestants&ctprops=id|user_id|contest_id|rating',
 55+ 'api.php?action=query&list=contestants&ctprops=id|rating&ctcontestid=42',
 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/ApiQueryContestants.php
___________________________________________________________________
Added: svn:eol-style
168 + native
Added: svn:keywords
269 + Id

Status & tagging log