Merge branch 'replace_users' of https://github.com/nlegoff/Phraseanet into nlegoff-replace_users

Conflicts:
	lib/classes/ACL.php
	lib/classes/User/Adapter.php
	lib/classes/eventsmanager/notify/autoregister.php
	lib/classes/eventsmanager/notify/order.php
	lib/classes/eventsmanager/notify/orderdeliver.php
	lib/classes/eventsmanager/notify/ordernotdelivered.php
	lib/classes/eventsmanager/notify/push.php
	lib/classes/eventsmanager/notify/register.php
	lib/classes/eventsmanager/notify/validate.php
	lib/classes/eventsmanager/notify/validationdone.php
	lib/classes/eventsmanager/notify/validationreminder.php
	lib/classes/module/report/add.php
	lib/classes/module/report/edit.php
	lib/classes/module/report/push.php
	lib/classes/module/report/sent.php
	lib/classes/module/report/validate.php
	lib/classes/record/preview.php
This commit is contained in:
Romain Neutron
2014-02-20 18:02:27 +01:00
393 changed files with 30866 additions and 7165 deletions

View File

@@ -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;
@@ -83,7 +84,7 @@ class API_OAuth2_Account
$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()
{
@@ -214,7 +215,7 @@ class API_OAuth2_Account
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)
@@ -222,7 +223,7 @@ class API_OAuth2_Account
$datetime = new Datetime();
$params = [
':usr_id' => $user->get_id()
':usr_id' => $user->getId()
, ':application_id' => $application->get_id()
, ':api_version' => API_OAuth2_Adapter::API_VERSION
, ':revoked' => 0
@@ -238,13 +239,13 @@ 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(),
":usr_id" => $user->getId(),
":application_id" => $application->get_id()
];

View File

@@ -222,7 +222,7 @@ class API_OAuth2_Adapter extends OAuth2
, 'client_id' => $token->get_account()->get_application()->get_client_id()
, 'session_id' => $token->get_session_id()
, 'revoked' => ($token->get_account()->is_revoked() ? '1' : '0')
, 'usr_id' => $token->get_account()->get_user()->get_id()
, 'usr_id' => $token->get_account()->get_user()->getId()
, 'oauth_token' => $token->get_value()
];
@@ -506,7 +506,7 @@ class API_OAuth2_Adapter extends OAuth2
throw new logicalException("Client property must be set before update an account");
try {
$user = User_Adapter::getInstance($usr_id, $this->app);
$user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$account = API_OAuth2_Account::load_with_user($this->app, $this->client, $user);
} catch (\Exception $e) {
$account = $this->createAccount($usr_id);
@@ -522,7 +522,7 @@ class API_OAuth2_Adapter extends OAuth2
*/
private function createAccount($usr_id)
{
$user = User_Adapter::getInstance($usr_id, $this->app);
$user = $this->app['manipulator.user']->getRepository()->find($usr_id);
return API_OAuth2_Account::create($this->app, $user, $this->client);
}

View File

@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Alchemy\Phrasea\Model\Entities\User;
class API_OAuth2_Application
{
@@ -41,7 +42,7 @@ class API_OAuth2_Application
/**
*
* @var User_Adapter
* @var User
*/
protected $creator;
@@ -145,7 +146,7 @@ class API_OAuth2_Application
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$this->creator = ! $row['creator'] ? null : User_Adapter::getInstance($row['creator'], $this->app);
$this->creator = ! $row['creator'] ? null : $this->app['manipulator.user']->getRepository()->find($row['creator']);
$this->type = $row['type'];
$this->name = $row['name'];
$this->description = $row['description'];
@@ -173,7 +174,7 @@ class API_OAuth2_Application
/**
*
* @return User_Adapter
* @return User
*/
public function get_creator()
{
@@ -518,16 +519,16 @@ class API_OAuth2_Application
/**
*
* @param User_Adapter $user
* @param User $user
* @return API_OAuth2_Account
*/
public function get_user_account(user_adapter $user)
public function get_user_account(User $user)
{
$sql = 'SELECT api_account_id FROM api_accounts
WHERE usr_id = :usr_id AND application_id = :id';
$params = [
':usr_id' => $user->get_id()
':usr_id' => $user->getId()
, ':id' => $this->id
];
@@ -588,11 +589,11 @@ class API_OAuth2_Application
/**
*
* @param Application $app
* @param User_Adapter $user
* @param User $user
* @param type $name
* @return API_OAuth2_Application
*/
public static function create(Application $app, User_Adapter $user = null, $name)
public static function create(Application $app, User $user = null, $name)
{
$sql = '
INSERT INTO api_applications (
@@ -609,7 +610,7 @@ class API_OAuth2_Application
$client_token = API_OAuth2_Token::generate_token();
$params = [
':usr_id' => $user ? $user->get_id() : null,
':usr_id' => $user ? $user->getId() : null,
':name' => $name,
':client_id' => $client_token,
':client_secret' => $client_secret,
@@ -655,14 +656,14 @@ class API_OAuth2_Application
return new self($app, $row['application_id']);
}
public static function load_dev_app_by_user(Application $app, User_Adapter $user)
public static function load_dev_app_by_user(Application $app, User $user)
{
$sql = 'SELECT a.application_id
FROM api_applications a, api_accounts b
WHERE a.creator = :usr_id AND a.application_id = b.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':usr_id' => $user->get_id()]);
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -674,14 +675,14 @@ class API_OAuth2_Application
return $apps;
}
public static function load_app_by_user(Application $app, user_adapter $user)
public static function load_app_by_user(Application $app, User $user)
{
$sql = 'SELECT a.application_id
FROM api_accounts a, api_applications c
WHERE usr_id = :usr_id AND c.application_id = a.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':usr_id' => $user->get_id()]);
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -693,7 +694,7 @@ class API_OAuth2_Application
return $apps;
}
public static function load_authorized_app_by_user(Application $app, user_adapter $user)
public static function load_authorized_app_by_user(Application $app, User $user)
{
$sql = '
SELECT a.application_id
@@ -702,7 +703,7 @@ class API_OAuth2_Application
AND revoked = 0';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':usr_id' => $user->get_id()]);
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();