Example #1
0
 public function __construct(ApiBase $query, $moduleName, $paramPrefix = '')
 {
     parent::__construct($query->getMain(), $moduleName, $paramPrefix);
     $this->mQueryModule = $query;
     $this->mDb = null;
     $this->resetQueryParams();
 }
Example #2
0
	/**
	 * Constructor
	 * @param $dbSource ApiBase Module implementing getDB().
	 *        Allows PageSet to reuse existing db connection from the shared state like ApiQuery.
	 * @param int $flags Zero or more flags like DISABLE_GENERATORS
	 * @param int $defaultNamespace the namespace to use if none is specified by a prefix.
	 * @since 1.21 accepts $flags instead of two boolean values
	 */
	public function __construct( ApiBase $dbSource, $flags = 0, $defaultNamespace = NS_MAIN ) {
		parent::__construct( $dbSource->getMain(), $dbSource->getModuleName() );
		$this->mDbSource = $dbSource;
		$this->mAllowGenerator = ( $flags & ApiPageSet::DISABLE_GENERATORS ) == 0;
		$this->mDefaultNamespace = $defaultNamespace;

		$this->profileIn();
		$this->mParams = $this->extractRequestParams();
		$this->mResolveRedirects = $this->mParams['redirects'];
		$this->mConvertTitles = $this->mParams['converttitles'];
		$this->profileOut();
	}
Example #3
0
 /**
  * @param $query ApiBase
  * @param $moduleName
  * @return GenericMetricBase
  *
  */
 function __construct(ApiBase $query, $moduleName)
 {
     parent::__construct($query->getMain(), $moduleName);
 }
 /**
  * Pass API parameter on to the login form when using
  * API account creation.
  *
  * @param ApiBase $apiModule
  * @param LoginForm $loginForm
  * @return hook return value
  */
 public static function addNewAccountApiForm($apiModule, $loginForm)
 {
     global $wgRequest;
     $main = $apiModule->getMain();
     if ($main->getVal('ignoreantispoof') !== null) {
         $wgRequest->setVal('wpIgnoreAntiSpoof', '1');
         // Suppress "unrecognized parameter" warning:
         $main->getVal('wpIgnoreAntiSpoof');
     }
     return true;
 }
 /**
  * Validate "centralauthtoken", and disable certain modules that make no
  * sense with "centralauthtoken".
  * @param ApiBase $module API module
  * @param User $user User
  * @param array &$message Error message key and params
  * @return bool
  */
 static function onApiCheckCanExecute($module, $user, &$message)
 {
     global $wgCentralAuthCookies;
     if (!$wgCentralAuthCookies) {
         return true;
     }
     if (self::hasApiToken()) {
         $module->getMain()->getVal('centralauthtoken');
         # Mark used
         $apiCentralUser = self::getApiCentralUser(true);
         $centralUser = CentralAuthUser::getInstance($user);
         if (!$apiCentralUser || !$centralUser || $apiCentralUser->getId() !== $centralUser->getId()) {
             // Bad design, API.
             ApiBase::$messageMap['centralauth-api-badtoken'] = array('code' => 'badtoken', 'info' => 'The centralauthtoken is not valid');
             $message = array('centralauth-api-badtoken');
             return false;
         }
         if ($module instanceof ApiLogin || $module instanceof ApiLogout) {
             // Bad design, API.
             ApiBase::$messageMap['centralauth-api-blacklistedmodule'] = array('code' => 'badparams', 'info' => 'The module "$1" may not be used with centralauthtoken');
             $message = array('centralauth-api-blacklistedmodule', $module->getModuleName());
             return false;
         }
     }
     return true;
 }
 public function __construct(ApiBase $query, $moduleName)
 {
     parent::__construct($query->getMain(), $moduleName);
     $this->numberOfActiveEditors = 100;
 }
 public function __construct(ApiBase $query, $moduleName)
 {
     parent::__construct($query->getMain(), $moduleName);
     $this->normaliseQueryParameters();
 }