mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Remove User_Adapter
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
|
||||
class API_OAuth2_Account
|
||||
{
|
||||
@@ -28,7 +29,7 @@ class API_OAuth2_Account
|
||||
|
||||
/**
|
||||
*
|
||||
* @var User_Adapter
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@@ -78,12 +79,12 @@ class API_OAuth2_Account
|
||||
WHERE api_account_id = :api_account_id';
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute([':api_account_id' => $this->id]);
|
||||
$stmt->execute(array(':api_account_id' => $this->id));
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$this->application_id = (int) $row['application_id'];
|
||||
$this->user = User_Adapter::getInstance($row['usr_id'], $app);
|
||||
$this->user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
|
||||
|
||||
$this->api_version = $row['api_version'];
|
||||
$this->revoked = ! ! $row['revoked'];
|
||||
@@ -103,7 +104,7 @@ class API_OAuth2_Account
|
||||
|
||||
/**
|
||||
*
|
||||
* @return User_Adapter
|
||||
* @return User
|
||||
*/
|
||||
public function get_user()
|
||||
{
|
||||
@@ -140,10 +141,10 @@ class API_OAuth2_Account
|
||||
$sql = 'UPDATE api_accounts SET revoked = :revoked
|
||||
WHERE api_account_id = :account_id';
|
||||
|
||||
$params = [
|
||||
$params = array(
|
||||
':revoked' => ($boolean ? '1' : '0')
|
||||
, 'account_id' => $this->id
|
||||
];
|
||||
);
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -208,26 +209,26 @@ class API_OAuth2_Account
|
||||
$sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id';
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(['account_id' => $this->id]);
|
||||
$stmt->execute(array('account_id' => $this->id));
|
||||
$stmt->closeCursor();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static function create(Application $app, User_Adapter $user, API_OAuth2_Application $application)
|
||||
public static function create(Application $app, User $user, API_OAuth2_Application $application)
|
||||
{
|
||||
$sql = 'INSERT INTO api_accounts
|
||||
(api_account_id, usr_id, revoked, api_version, application_id, created)
|
||||
VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)';
|
||||
|
||||
$datetime = new Datetime();
|
||||
$params = [
|
||||
':usr_id' => $user->get_id()
|
||||
$params = array(
|
||||
':usr_id' => $user->getId()
|
||||
, ':application_id' => $application->get_id()
|
||||
, ':api_version' => API_OAuth2_Adapter::API_VERSION
|
||||
, ':revoked' => 0
|
||||
, ':created' => $datetime->format("Y-m-d H:i:s")
|
||||
];
|
||||
);
|
||||
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -238,15 +239,15 @@ class API_OAuth2_Account
|
||||
return new self($app, $account_id);
|
||||
}
|
||||
|
||||
public static function load_with_user(Application $app, API_OAuth2_Application $application, User_Adapter $user)
|
||||
public static function load_with_user(Application $app, API_OAuth2_Application $application, User $user)
|
||||
{
|
||||
$sql = 'SELECT api_account_id FROM api_accounts
|
||||
WHERE usr_id = :usr_id AND application_id = :application_id';
|
||||
|
||||
$params = [
|
||||
":usr_id" => $user->get_id(),
|
||||
$params = array(
|
||||
":usr_id" => $user->getId(),
|
||||
":application_id" => $application->get_id()
|
||||
];
|
||||
);
|
||||
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
Reference in New Issue
Block a user