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();

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Request;
use Silex\Application;
@@ -242,7 +243,7 @@ interface API_V1_Interface
* Parameters :
*
*/
public function search_publications(Request $request, User_Adapter $user);
public function search_publications(Request $request, User $user);
/**
* Route : /publications/PUBLICATION_ID/remove/FORMAT/
@@ -264,11 +265,11 @@ interface API_V1_Interface
* PUBLICATION_ID : required INT
*
*/
public function get_publication(Request $request, $publication_id, User_Adapter $user);
public function get_publication(Request $request, $publication_id, User $user);
public function get_publications(Request $request, User_Adapter $user);
public function get_publications(Request $request, User $user);
public function get_feed_entry(Request $request, $entry, User_Adapter $user);
public function get_feed_entry(Request $request, $entry, User $user);
/**
* Route : /users/search/FORMAT/
*

View File

@@ -23,6 +23,7 @@ use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Model\Entities\FeedItem;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\Task;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UserQuery;
use Alchemy\Phrasea\Model\Entities\ValidationData;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
@@ -658,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract
}
$session = new Alchemy\Phrasea\Model\Entities\LazaretSession();
$session->setUsrId($app['authentication']->getUser()->get_id());
$session->setUser($app['authentication']->getUser());
$app['EM']->persist($session);
$app['EM']->flush();
@@ -783,8 +784,8 @@ class API_V1_adapter extends API_V1_Abstract
}
$usr_id = null;
if ($file->getSession()->getUser($this->app)) {
$usr_id = $file->getSession()->getUser($this->app)->get_id();
if ($file->getSession()->getUser()) {
$usr_id = $file->getSession()->getUser()->getId();
}
$session = [
@@ -876,7 +877,7 @@ class API_V1_adapter extends API_V1_Abstract
$search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage, $options);
$userQuery = new UserQuery();
$userQuery->setUsrId($this->app['authentication']->getUser()->get_id());
$userQuery->setUser($this->app['authentication']->getUser());
$userQuery->setQuery($query);
$this->app['EM']->persist($userQuery);
@@ -1226,7 +1227,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
$usr_id = $this->app['authentication']->getUser()->get_id();
$usr_id = $this->app['authentication']->getUser()->getId();
$result->set_datas(['baskets' => $this->list_baskets($usr_id)]);
@@ -1271,7 +1272,7 @@ class API_V1_adapter extends API_V1_Abstract
}
$Basket = new Basket();
$Basket->setOwner($this->app['authentication']->getUser());
$Basket->setUser($this->app['authentication']->getUser());
$Basket->setName($name);
$this->app['EM']->persist($Basket);
@@ -1309,10 +1310,10 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
$result->set_datas(
[
"basket" => $this->list_basket($basket),
"basket_elements" => $this->list_basket_content($basket)
]
[
"basket" => $this->list_basket($basket),
"basket_elements" => $this->list_basket_content($basket)
]
);
return $result;
@@ -1357,23 +1358,23 @@ class API_V1_adapter extends API_V1_Abstract
foreach ($basket_element->getValidationDatas() as $validation_datas) {
$participant = $validation_datas->getParticipant();
$user = $participant->getUser($this->app);
$user = $participant->getUser();
/* @var $validation_datas ValidationData */
$choices[] = [
'validation_user' => [
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'usr_id' => $user->getId(),
'usr_name' => $user->getDisplayName(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(),
'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(),
'readonly' => $user->getId() != $this->app['authentication']->getUser()->getId(),
],
'agreement' => $validation_datas->getAgreement(),
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(),
];
if ($user->get_id() == $this->app['authentication']->getUser()->get_id()) {
if ($user->getId() == $this->app['authentication']->getUser()->getId()) {
$agreement = $validation_datas->getAgreement();
$note = null === $validation_datas->getNote() ? '' : $validation_datas->getNote();
}
@@ -1434,10 +1435,10 @@ class API_V1_adapter extends API_V1_Abstract
* List all avalaible feeds
*
* @param Request $request
* @param User_Adapter $user
* @param User $user
* @return API_V1_result
*/
public function search_publications(Request $request, User_Adapter $user)
public function search_publications(Request $request, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1467,10 +1468,10 @@ class API_V1_adapter extends API_V1_Abstract
*
* @param Request $request
* @param int $publication_id
* @param User_Adapter $user
* @param User $user
* @return API_V1_result
*/
public function get_publication(Request $request, $publication_id, User_Adapter $user)
public function get_publication(Request $request, $publication_id, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1495,7 +1496,7 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
public function get_publications(Request $request, User_Adapter $user)
public function get_publications(Request $request, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1518,7 +1519,7 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
public function get_feed_entry(Request $request, $entry_id, User_Adapter $user)
public function get_feed_entry(Request $request, $entry_id, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1777,7 +1778,7 @@ class API_V1_adapter extends API_V1_Abstract
'created_on' => $basket->getCreated()->format(DATE_ATOM),
'description' => (string) $basket->getDescription(),
'name' => $basket->getName(),
'pusher_usr_id' => $basket->getPusherId(),
'pusher_usr_id' => $basket->getPusher() ? $basket->getPusher()->getId() : null,
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
'unread' => !$basket->getIsRead(),
'validation_basket' => !!$basket->getValidation()
@@ -1788,15 +1789,15 @@ class API_V1_adapter extends API_V1_Abstract
foreach ($basket->getValidation()->getParticipants() as $participant) {
/* @var $participant ValidationParticipant */
$user = $participant->getUser($this->app);
$user = $participant->getUser();
$users[] = [
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'usr_id' => $user->getId(),
'usr_name' => $user->getDisplayName(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(),
'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(),
'readonly' => $user->getId() != $this->app['authentication']->getUser()->getId(),
];
}
@@ -1811,7 +1812,7 @@ class API_V1_adapter extends API_V1_Abstract
'validation_users' => $users,
'expires_on' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()),
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(),
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser())->getIsConfirmed(),
'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()),
], $ret
);