/** * Checks that the user is in the sandbox. Also handles special overrides * mainly used for integration testing. * * @return bool */ protected function hasPermissionToUse() { global $wgTranslateTestUsers; $request = $this->getRequest(); $user = $this->getUser(); if (in_array($user->getName(), $wgTranslateTestUsers, true)) { if ($request->getVal('integrationtesting') === 'activatestash') { $user->addGroup('translate-sandboxed'); return true; } elseif ($request->getVal('integrationtesting') === 'deactivatestash') { $user->removeGroup('translate-sandboxed'); $this->stash->deleteTranslations($user); return false; } } if (!TranslateSandbox::isSandboxed($user)) { return false; } return true; }
/** * Whitelisting for certain API modules. See also enforcePermissions. * Hook: ApiCheckCanExecute */ public static function onApiCheckCanExecute(ApiBase $module, User $user, &$message) { $whitelist = array('ApiTranslationStash', 'ApiOptions'); if (TranslateSandbox::isSandboxed($user)) { $class = get_class($module); if ($module->isWriteMode() && !in_array($class, $whitelist, true)) { $message = 'writerequired'; return false; } } return true; }