code cleanup
This commit is contained in:
@@ -44,7 +44,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
@@ -81,7 +81,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Api\Contact {
|
||||
parent::__construct($user, $externalCall, $parameters);
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -292,7 +292,7 @@ namespace Api\File {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -450,7 +450,7 @@ namespace Api\File {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ namespace Api\File {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -551,7 +551,7 @@ namespace Api\File {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -653,7 +653,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -826,7 +826,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -891,7 +891,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -946,7 +946,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1017,7 +1017,7 @@ namespace Api\File {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Api\Groups {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Api\Groups {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace Api\Groups {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Api\Language {
|
||||
parent::__construct($user, $externalCall, array());
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace Api\Language {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Api\Mail {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace Api\Mail {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Api\Notifications {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ namespace Api\Notifications {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace Api\Notifications {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,14 +8,22 @@ class ArrayType extends Parameter {
|
||||
public int $elementType;
|
||||
public int $canBeOne;
|
||||
|
||||
public function __construct($name, $elementType = Parameter::TYPE_MIXED, $canBeOne=false, $optional = FALSE, $defaultValue = NULL) {
|
||||
/**
|
||||
* ArrayType constructor.
|
||||
* @param string $name the name of the parameter
|
||||
* @param int $elementType element type inside the array, for example, allow only integer values (Parameter::TYPE_INT)
|
||||
* @param bool $canBeOne true, if a single element can be passed inside the request (e.g. array=1 instead of array[]=1). Will be automatically casted to an array
|
||||
* @param bool $optional true if the parameter is optional
|
||||
* @param array|null $defaultValue the default value to use, if the parameter is not given
|
||||
*/
|
||||
public function __construct(string $name, int $elementType = Parameter::TYPE_MIXED, bool $canBeOne = false, bool $optional = FALSE, ?array $defaultValue = NULL) {
|
||||
$this->elementType = $elementType;
|
||||
$this->elementParameter = new Parameter('', $elementType);
|
||||
$this->canBeOne = $canBeOne;
|
||||
parent::__construct($name, Parameter::TYPE_ARRAY, $optional, $defaultValue);
|
||||
}
|
||||
|
||||
public function parseParam($value) {
|
||||
public function parseParam($value): bool {
|
||||
if(!is_array($value)) {
|
||||
if (!$this->canBeOne) {
|
||||
return false;
|
||||
@@ -38,12 +46,12 @@ class ArrayType extends Parameter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
public function getTypeName(): string {
|
||||
$elementType = $this->elementParameter->getTypeName();
|
||||
return parent::getTypeName() . "($elementType)";
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
public function toString(): string {
|
||||
$typeName = $this->getTypeName();
|
||||
$str = "$typeName $this->name";
|
||||
$defaultValue = (is_null($this->value) ? 'NULL' : (is_array($this->value) ? '[' . implode(",", $this->value) . ']' : $this->value));
|
||||
|
||||
@@ -26,11 +26,11 @@ class Parameter {
|
||||
|
||||
public string $name;
|
||||
public $value;
|
||||
public $optional;
|
||||
public bool $optional;
|
||||
public int $type;
|
||||
public string $typeName;
|
||||
|
||||
public function __construct($name, $type, $optional = FALSE, $defaultValue = NULL) {
|
||||
public function __construct(string $name, int $type, bool $optional = FALSE, $defaultValue = NULL) {
|
||||
$this->name = $name;
|
||||
$this->optional = $optional;
|
||||
$this->value = $defaultValue;
|
||||
@@ -38,11 +38,11 @@ class Parameter {
|
||||
$this->typeName = $this->getTypeName();
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
public function getTypeName(): string {
|
||||
return ($this->type >= 0 && $this->type < count(Parameter::names)) ? Parameter::names[$this->type] : "INVALID";
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
public function toString(): string {
|
||||
$typeName = Parameter::names[$this->type];
|
||||
|
||||
$str = "$typeName $this->name";
|
||||
@@ -54,7 +54,7 @@ class Parameter {
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function parseType($value) {
|
||||
public static function parseType($value): int {
|
||||
if(is_array($value))
|
||||
return Parameter::TYPE_ARRAY;
|
||||
else if(is_numeric($value) && intval($value) == $value)
|
||||
@@ -77,7 +77,7 @@ class Parameter {
|
||||
return Parameter::TYPE_STRING;
|
||||
}
|
||||
|
||||
public function parseParam($value) {
|
||||
public function parseParam($value): bool {
|
||||
switch($this->type) {
|
||||
case Parameter::TYPE_INT:
|
||||
if(is_numeric($value) && intval($value) == $value) {
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace Api\Parameter;
|
||||
class StringType extends Parameter {
|
||||
|
||||
public int $maxLength;
|
||||
public function __construct($name, $maxLength = -1, $optional = FALSE, $defaultValue = NULL) {
|
||||
public function __construct(string $name, int $maxLength = -1, bool $optional = FALSE, ?string $defaultValue = NULL) {
|
||||
$this->maxLength = $maxLength;
|
||||
parent::__construct($name, Parameter::TYPE_STRING, $optional, $defaultValue);
|
||||
}
|
||||
|
||||
public function parseParam($value) {
|
||||
public function parseParam($value): bool {
|
||||
if(!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
@@ -23,12 +23,12 @@ class StringType extends Parameter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
public function getTypeName(): string {
|
||||
$maxLength = ($this->maxLength > 0 ? "($this->maxLength)" : "");
|
||||
return parent::getTypeName() . $maxLength;
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
public function toString(): string {
|
||||
$typeName = $this->getTypeName();
|
||||
$str = "$typeName $this->name";
|
||||
$defaultValue = (is_null($this->value) ? 'NULL' : $this->value);
|
||||
|
||||
@@ -16,7 +16,7 @@ class PatchSQL extends Request {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Api\Permission {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace Api\Permission {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Api\Permission {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,33 +41,34 @@ class Request {
|
||||
|
||||
protected function forbidMethod($method) {
|
||||
if (($key = array_search($method, $this->allowedMethods)) !== false) {
|
||||
unset($this->allowedMethods[$key]);
|
||||
unset($this->allowedMethods[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseParams($values) {
|
||||
public function parseParams($values): bool {
|
||||
|
||||
foreach($this->params as $name => $param) {
|
||||
foreach ($this->params as $name => $param) {
|
||||
$value = $values[$name] ?? NULL;
|
||||
|
||||
$isEmpty = (is_string($value) && strlen($value) === 0) || (is_array($value) && empty($value));
|
||||
if(!$param->optional && (is_null($value) || $isEmpty)) {
|
||||
if (!$param->optional && (is_null($value) || $isEmpty)) {
|
||||
return $this->createError("Missing parameter: $name");
|
||||
}
|
||||
|
||||
if(!is_null($value) && !$isEmpty) {
|
||||
if(!$param->parseParam($value)) {
|
||||
if (!is_null($value) && !$isEmpty) {
|
||||
if (!$param->parseParam($value)) {
|
||||
$value = print_r($value, true);
|
||||
return $this->createError("Invalid Type for parameter: $name '$value' (Required: " . $param->getTypeName() . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function parseVariableParams($values) {
|
||||
foreach($values as $name => $value) {
|
||||
if(isset($this->params[$name])) continue;
|
||||
foreach ($values as $name => $value) {
|
||||
if (isset($this->params[$name])) continue;
|
||||
$type = Parameter\Parameter::parseType($value);
|
||||
$param = new Parameter\Parameter($name, $type, true);
|
||||
$param->parseParam($value);
|
||||
@@ -75,19 +76,19 @@ class Request {
|
||||
}
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
$this->params = $this->aDefaultParams;
|
||||
$this->success = false;
|
||||
$this->result = array();
|
||||
$this->lastError = '';
|
||||
|
||||
if($this->user->isLoggedIn()) {
|
||||
if ($this->user->isLoggedIn()) {
|
||||
$this->result['logoutIn'] = $this->user->getSession()->getExpiresSeconds();
|
||||
}
|
||||
|
||||
if($this->externalCall) {
|
||||
if ($this->externalCall) {
|
||||
$values = $_REQUEST;
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SERVER["CONTENT_TYPE"]) && in_array("application/json", explode(";", $_SERVER["CONTENT_TYPE"]))) {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SERVER["CONTENT_TYPE"]) && in_array("application/json", explode(";", $_SERVER["CONTENT_TYPE"]))) {
|
||||
$jsonData = json_decode(file_get_contents('php://input'), true);
|
||||
if ($jsonData) {
|
||||
$values = array_merge($values, $jsonData);
|
||||
@@ -99,34 +100,34 @@ class Request {
|
||||
}
|
||||
}
|
||||
|
||||
if($this->isDisabled) {
|
||||
if ($this->isDisabled) {
|
||||
$this->lastError = "This function is currently disabled.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->externalCall && !$this->isPublic) {
|
||||
if ($this->externalCall && !$this->isPublic) {
|
||||
$this->lastError = 'This function is private.';
|
||||
header('HTTP 1.1 403 Forbidden');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!in_array($_SERVER['REQUEST_METHOD'], $this->allowedMethods)) {
|
||||
if (!in_array($_SERVER['REQUEST_METHOD'], $this->allowedMethods)) {
|
||||
$this->lastError = 'This method is not allowed';
|
||||
header('HTTP 1.1 405 Method Not Allowed');
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->externalCall) {
|
||||
if ($this->externalCall) {
|
||||
$apiKeyAuthorized = false;
|
||||
|
||||
// Logged in or api key authorized?
|
||||
if ($this->loginRequired) {
|
||||
if(isset($values['api_key']) && $this->apiKeyAllowed) {
|
||||
if (isset($values['api_key']) && $this->apiKeyAllowed) {
|
||||
$apiKey = $values['api_key'];
|
||||
$apiKeyAuthorized = $this->user->authorize($apiKey);
|
||||
}
|
||||
|
||||
if(!$this->user->isLoggedIn() && !$apiKeyAuthorized) {
|
||||
if (!$this->user->isLoggedIn() && !$apiKeyAuthorized) {
|
||||
$this->lastError = 'You are not logged in.';
|
||||
header('HTTP 1.1 401 Unauthorized');
|
||||
return false;
|
||||
@@ -134,7 +135,7 @@ class Request {
|
||||
}
|
||||
|
||||
// CSRF Token
|
||||
if($this->csrfTokenRequired && $this->user->isLoggedIn()) {
|
||||
if ($this->csrfTokenRequired && $this->user->isLoggedIn()) {
|
||||
// csrf token required + external call
|
||||
// if it's not a call with API_KEY, check for csrf_token
|
||||
if (!isset($values["csrf_token"]) || strcmp($values["csrf_token"], $this->user->getSession()->getCsrfToken()) !== 0) {
|
||||
@@ -155,13 +156,15 @@ class Request {
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->parseParams($values))
|
||||
if (!$this->parseParams($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->variableParamCount)
|
||||
if ($this->variableParamCount) {
|
||||
$this->parseVariableParams($values);
|
||||
}
|
||||
|
||||
if(!$this->user->getSQL()->isConnected()) {
|
||||
if (!$this->user->getSQL()->isConnected()) {
|
||||
$this->lastError = $this->user->getSQL()->getLastError();
|
||||
return false;
|
||||
}
|
||||
@@ -171,23 +174,39 @@ class Request {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function createError($err) {
|
||||
protected function createError($err): bool {
|
||||
$this->success = false;
|
||||
$this->lastError = $err;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getParam($name) {
|
||||
return isset($this->params[$name]) ? $this->params[$name]->value : NULL;
|
||||
return $this->params[$name] ?? NULL;
|
||||
}
|
||||
|
||||
public function isPublic() { return $this->isPublic; }
|
||||
public function getLastError() { return $this->lastError; }
|
||||
public function getResult() { return $this->result; }
|
||||
public function success() { return $this->success; }
|
||||
public function loginRequired() { return $this->loginRequired; }
|
||||
public function isExternalCall() { return $this->externalCall; }
|
||||
public function clearError() { $this->success = true; $this->lastError = ""; }
|
||||
public function isPublic(): bool {
|
||||
return $this->isPublic;
|
||||
}
|
||||
|
||||
public function getLastError(): string {
|
||||
return $this->lastError;
|
||||
}
|
||||
|
||||
public function getResult(): array {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function success(): bool {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function loginRequired(): bool {
|
||||
return $this->loginRequired;
|
||||
}
|
||||
|
||||
public function isExternalCall(): bool {
|
||||
return $this->externalCall;
|
||||
}
|
||||
|
||||
private function getMethod() {
|
||||
$class = str_replace("\\", "/", get_class($this));
|
||||
@@ -195,7 +214,7 @@ class Request {
|
||||
return $class;
|
||||
}
|
||||
|
||||
public function getJsonResult() {
|
||||
public function getJsonResult(): string {
|
||||
$this->result['success'] = $this->success;
|
||||
$this->result['msg'] = $this->lastError;
|
||||
return json_encode($this->result);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Api\Routes {
|
||||
parent::__construct($user, $externalCall, array());
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace Api\Routes {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Api\Settings {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace Api\Settings {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class Stats extends Request {
|
||||
return ($this->success ? $res[0]["count"] : $this->success);
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Api {
|
||||
protected function userExists(?string $username, ?string $email) {
|
||||
|
||||
$conditions = array();
|
||||
if (!is_null($username) && !empty($username)) {
|
||||
if ($username) {
|
||||
$conditions[] = new Compare("User.name", $username);
|
||||
}
|
||||
|
||||
if (!is_null($email) && !empty($email)) {
|
||||
if ($email) {
|
||||
$conditions[] = new Compare("User.email", $email);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace Api\User {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ namespace Api\User {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ namespace Api\User {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -586,7 +586,7 @@ namespace Api\User {
|
||||
return $this->createError(L('Wrong username or password'));
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -648,7 +648,7 @@ namespace Api\User {
|
||||
$this->apiKeyAllowed = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -804,7 +804,7 @@ namespace Api\User {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -847,7 +847,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -945,7 +945,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -986,7 +986,7 @@ namespace Api\User {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class VerifyCaptcha extends Request {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Api\Visitors {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace Api\Visitors {
|
||||
}
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user