web-base/core/Api/GetApiKeys.class.php
2020-02-17 00:18:37 +01:00

34 lines
821 B
PHP

<?php
namespace Api;
class GetApiKeys extends Request {
public function __construct($user, $externCall = false) {
parent::__construct($user, $externCall, array());
$this->loginRequired = true;
}
public function execute($values = array()) {
if(!parent::execute($values)) {
return false;
}
$query = "SELECT ApiKey.uid, ApiKey.api_key, ApiKey.valid_until
FROM ApiKey
WHERE ApiKey.user_id = ?
AND ApiKey.valid_until > now()";
$request = new ExecuteSelect($this->user);
$this->success = $request->execute(array("query" => $query, $this->user->getId()));
$this->lastError = $request->getLastError();
if($this->success) {
$this->result["api_keys"] = $request->getResult()['rows'];
}
return $this->success;
}
};
?>