Exemple #1
0
 /**
  * Check for sufficient permissions to execute
  * @param ApiBase $module An Api module
  */
 protected function checkExecutePermissions($module)
 {
     $user = $this->getUser();
     if ($module->isReadMode() && !User::isEveryoneAllowed('read') && !$user->isAllowed('read')) {
         $this->dieUsageMsg('readrequired');
     }
     if ($module->isWriteMode()) {
         if (!$this->mEnableWrite) {
             $this->dieUsageMsg('writedisabled');
         }
         if (!$user->isAllowed('writeapi')) {
             $this->dieUsageMsg('writerequired');
         }
         if (wfReadOnly()) {
             $this->dieReadOnly();
         }
     }
     // Allow extensions to stop execution for arbitrary reasons.
     $message = false;
     if (!Hooks::run('ApiCheckCanExecute', array($module, $user, &$message))) {
         $this->dieUsageMsg($message);
     }
 }
Exemple #2
0
 /**
  * Check for sufficient permissions to execute
  * @param ApiBase $module An Api module
  */
 protected function checkExecutePermissions($module)
 {
     $user = $this->getUser();
     if ($module->isReadMode() && !User::isEveryoneAllowed('read') && !$user->isAllowed('read')) {
         $this->dieUsageMsg('readrequired');
     }
     if ($module->isWriteMode()) {
         if (!$this->mEnableWrite) {
             $this->dieUsageMsg('writedisabled');
         } elseif (!$user->isAllowed('writeapi')) {
             $this->dieUsageMsg('writerequired');
         } elseif ($this->getRequest()->getHeader('Promise-Non-Write-API-Action')) {
             $this->dieUsage("Promise-Non-Write-API-Action HTTP header cannot be sent to write API modules", 'promised-nonwrite-api');
         }
         $this->checkReadOnly($module);
     }
     // Allow extensions to stop execution for arbitrary reasons.
     $message = false;
     if (!Hooks::run('ApiCheckCanExecute', array($module, $user, &$message))) {
         $this->dieUsageMsg($message);
     }
 }