<?php
-
-/**
+/*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
* http://www.gnu.org/copyleft/gpl.html
*/
+/**
+ * This file is the entry point for all API queries. It begins by checking
+ * whether the API is enabled on this wiki; if not, it informs the user that
+ * s/he should set $wgEnableAPI to true and exits. Otherwise, it constructs
+ * a new ApiMain using the parameter passed to it as an argument in the URL
+ * ('?action=') and with write-enabled set to the value of $wgEnableWriteAPI
+ * as specified in LocalSettings.php. It then invokes "execute()" on the
+ * ApiMain object instance, which produces output in the format sepecified
+ * in the URL.
+ */
+
// Initialise common code
require (dirname(__FILE__) . '/includes/WebStart.php');
die(-1);
}
+/* Construct an ApiMain with the arguments passed via the URL. What we get back
+ * is some form of an ApiMain, possibly even one that produces an error message,
+ * but we don't care here, as that is handled by the ctor.
+ */
$processor = new ApiMain($wgRequest, $wgEnableWriteAPI);
+
+// Generate the output.
$processor->execute();
+// Log what the user did, for book-keeping purposes.
wfProfileOut('api.php');
wfLogProfilingData();
?>
const PARAM_MAX2 = 4;
const PARAM_MIN = 5;
- const LIMIT_BIG1 = 500; // Fast query, user's limit
- const LIMIT_BIG2 = 5000; // Fast query, bot's limit
- const LIMIT_SML1 = 50; // Slow query, user's limit
- const LIMIT_SML2 = 500; // Slow query, bot's limit
+ const LIMIT_BIG1 = 500; // Fast query, std user limit
+ const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit
+ const LIMIT_SML1 = 50; // Slow query, std user limit
+ const LIMIT_SML2 = 500; // Slow query, bot/sysop limit
private $mMainModule, $mModuleName, $mParamPrefix;
$this->dieUsage("$varname may not be less than $min (set to $value)", $varname);
}
- if ($this->getMain()->isBot()) {
+ if ($this->getMain()->isBot() || $this->getMain()->isSysop()) {
if ($value > $botMax) {
- $this->dieUsage("$varname may not be over $botMax (set to $value) for bots", $varname);
+ $this->dieUsage("$varname may not be over $botMax (set to $value) for bots or sysops", $varname);
}
}
elseif ($value > $max) {
private $mResult, $mShowVersions, $mEnableWrite, $mRequest, $mInternalMode, $mSquidMaxage;
/**
- * Constructor
+ * Constructs an instance of ApiMain that utilizes the module and format specified by $request.
+ *
* @param $request object - if this is an instance of FauxRequest, errors are thrown and no printing occurs
* @param $enableWrite bool should be set to true if the api may modify data
*/
private $mIsBot = null;
+ private $mIsSysop = null;
+
/**
* Returns true if the currently logged in user is a bot, false otherwise
*/
}
return $this->mIsBot;
}
+
+ /**
+ * Similar to isBot(), this method returns true if the logged in user is
+ * a sysop, and false if not.
+ */
+ public function isSysop() {
+ if (!isset ($this->mIsSysop)) {
+ global $wgUser;
+ $this->mIsSysop = in_array( 'sysop',
+ $wgUser->getGroups());
+ }
+
+ return $this->mIsSysop;
+ }
public function getShowVersions() {
return $this->mShowVersions;