Delete references to usr.usr_id field in entities

Conflicts:
	lib/Alchemy/Phrasea/Controller/Prod/Push.php
	lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
	lib/conf.d/migrations.yml

Conflicts:
	lib/Alchemy/Phrasea/ACL/BasketACL.php
	lib/Alchemy/Phrasea/Authentication/Authenticator.php
	lib/Alchemy/Phrasea/Controller/Prod/Order.php
	lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
	lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
	lib/Alchemy/Phrasea/Controller/Root/Session.php
	lib/Alchemy/Phrasea/Model/Entities/Basket.php
	lib/Alchemy/Phrasea/Model/Entities/BasketElement.php
	lib/Alchemy/Phrasea/Model/Entities/Feed.php
	lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php
	lib/Alchemy/Phrasea/Model/Entities/FtpExport.php
	lib/Alchemy/Phrasea/Model/Entities/Session.php
	lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php
	lib/Alchemy/Phrasea/Model/Entities/UsrList.php
	lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php
	lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php
	lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php
	lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php
	lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php
	lib/classes/API/V1/adapter.php
	templates/mobile/lightbox/sc_note.html.twig
	templates/web/admin/connected-users.html.twig
	templates/web/admin/publications/fiche.html.twig
	templates/web/lightbox/IE6/agreement_box.html.twig
	templates/web/lightbox/agreement_box.html.twig
	templates/web/lightbox/basket_content_report.html.twig
	templates/web/lightbox/sc_note.html.twig
	templates/web/prod/WorkZone/Browser/Basket.html.twig
	templates/web/prod/WorkZone/Browser/Results.html.twig
	templates/web/prod/WorkZone/Macros.html.twig
	templates/web/prod/actions/Feedback/List-Share.html.twig
	templates/web/prod/actions/Feedback/ListsMacros.html.twig
	templates/web/prod/orders/order_box.html.twig
	templates/web/prod/orders/order_item.html.twig
	templates/web/prod/upload/lazaret.html.twig
	tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php
This commit is contained in:
Nicolas Le Goff
2013-11-18 12:58:49 +01:00
parent 0e1203f595
commit 26bd977d5f
82 changed files with 623 additions and 601 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class DeleteUsrIdFieldMigration extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("DROP INDEX unique_owner ON UsrListOwners");
$this->addSql("ALTER TABLE UsrListOwners DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_owner ON UsrListOwners (user_id, id)");
$this->addSql("ALTER TABLE FtpCredential DROP usrId");
$this->addSql("DROP INDEX usr_id ON Sessions");
$this->addSql("ALTER TABLE Sessions DROP usr_id");
$this->addSql("ALTER TABLE Baskets DROP usr_id");
$this->addSql("DROP INDEX user_story ON StoryWZ");
$this->addSql("ALTER TABLE StoryWZ DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX user_story ON StoryWZ (user_id, sbas_id, record_id)");
$this->addSql("ALTER TABLE UserNotificationSettings DROP usr_id");
$this->addSql("ALTER TABLE UserSettings DROP usr_id");
$this->addSql("ALTER TABLE Orders DROP usr_id");
$this->addSql("ALTER TABLE UserQueries DROP usr_id");
$this->addSql("ALTER TABLE LazaretSessions DROP usr_id");
$this->addSql("ALTER TABLE ValidationParticipants DROP usr_id");
$this->addSql("ALTER TABLE FeedPublishers DROP usr_id");
$this->addSql("ALTER TABLE AggregateTokens DROP usr_id");
$this->addSql("ALTER TABLE FtpExports DROP usr_id");
$this->addSql("DROP INDEX unique_provider_per_user ON UsrAuthProviders");
$this->addSql("ALTER TABLE UsrAuthProviders DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_provider_per_user ON UsrAuthProviders (user_id, provider)");
$this->addSql("ALTER TABLE FeedTokens DROP usr_id");
$this->addSql("DROP INDEX unique_usr_per_list ON UsrListsContent");
$this->addSql("ALTER TABLE UsrListsContent DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_usr_per_list ON UsrListsContent (user_id, list_id)");
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE AggregateTokens ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE Baskets ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FeedPublishers ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FeedTokens ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FtpCredential ADD usrId INT NOT NULL");
$this->addSql("ALTER TABLE FtpExports ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE LazaretSessions ADD usr_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE Orders ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE Sessions ADD usr_id INT NOT NULL");
$this->addSql("CREATE INDEX usr_id ON Sessions (usr_id)");
$this->addSql("DROP INDEX user_story ON StoryWZ");
$this->addSql("ALTER TABLE StoryWZ ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX user_story ON StoryWZ (usr_id, sbas_id, record_id)");
$this->addSql("ALTER TABLE UserNotificationSettings ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE UserQueries ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE UserSettings ADD usr_id INT NOT NULL");
$this->addSql("DROP INDEX unique_provider_per_user ON UsrAuthProviders");
$this->addSql("ALTER TABLE UsrAuthProviders ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_provider_per_user ON UsrAuthProviders (usr_id, provider)");
$this->addSql("DROP INDEX unique_owner ON UsrListOwners");
$this->addSql("ALTER TABLE UsrListOwners ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_owner ON UsrListOwners (usr_id, id)");
$this->addSql("DROP INDEX unique_usr_per_list ON UsrListsContent");
$this->addSql("ALTER TABLE UsrListsContent ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_usr_per_list ON UsrListsContent (usr_id, list_id)");
$this->addSql("ALTER TABLE ValidationParticipants ADD usr_id INT NOT NULL");
}
}

View File

@@ -24,7 +24,7 @@ class BasketACL
if ($basket->getValidation()) { if ($basket->getValidation()) {
foreach ($basket->getValidation()->getParticipants() as $participant) { foreach ($basket->getValidation()->getParticipants() as $participant) {
if ($participant->getUsrId() === $user->getId()) { if ($participant->getUser()->getId() === $user->getId()) {
return true; return true;
} }
} }
@@ -35,6 +35,6 @@ class BasketACL
public function isOwner(Basket $basket, User $user) public function isOwner(Basket $basket, User $user)
{ {
return $basket->getUsrId() === $user->getId(); return $basket->getUser()->getId() === $user->getId();
} }
} }

View File

@@ -70,7 +70,7 @@ class Authenticator
->setBrowserVersion($this->browser->getVersion()) ->setBrowserVersion($this->browser->getVersion())
->setPlatform($this->browser->getPlatform()) ->setPlatform($this->browser->getPlatform())
->setUserAgent($this->browser->getUserAgent()) ->setUserAgent($this->browser->getUserAgent())
->setUsrId($user->getId()); ->setUser($user);
$this->em->persist($session); $this->em->persist($session);
$this->em->flush(); $this->em->flush();
@@ -105,7 +105,7 @@ class Authenticator
throw new RuntimeException('Unable to refresh the session, it does not exist anymore'); throw new RuntimeException('Unable to refresh the session, it does not exist anymore');
} }
if (null === $user = $this->app['manipulator.user']->getRepository()->find($session->getUsrId())) { if (null === $user = $session->getUser()) {
throw new RuntimeException('Unable to refresh the session'); throw new RuntimeException('Unable to refresh the session');
} }

View File

@@ -52,7 +52,7 @@ class Publications implements ControllerProviderInterface
$feed = new Feed(); $feed = new Feed();
$publisher->setFeed($feed); $publisher->setFeed($feed);
$publisher->setUsrId($app['authentication']->getUser()->getId()); $publisher->setUser($app['authentication']->getUser());
$publisher->setIsOwner(true); $publisher->setIsOwner(true);
$feed->addPublisher($publisher); $feed->addPublisher($publisher);
@@ -197,7 +197,7 @@ class Publications implements ControllerProviderInterface
$feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id);
$publisher = new FeedPublisher(); $publisher = new FeedPublisher();
$publisher->setUsrId($user->getId()); $publisher->setUser($user);
$publisher->setFeed($feed); $publisher->setFeed($feed);
$feed->addPublisher($publisher); $feed->addPublisher($publisher);
@@ -226,7 +226,7 @@ class Publications implements ControllerProviderInterface
$app->abort(404, "Feed Publisher not found"); $app->abort(404, "Feed Publisher not found");
} }
$user = $publisher->getUser($app); $user = $publisher->getUser();
if ($feed->isPublisher($user) && !$feed->isOwner($user)) { if ($feed->isPublisher($user) && !$feed->isOwner($user)) {
$feed->removePublisher($publisher); $feed->removePublisher($publisher);

View File

@@ -812,7 +812,7 @@ class Users implements ControllerProviderInterface
$NewUser = $app['manipulator.user']->createUser($curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail']); $NewUser = $app['manipulator.user']->createUser($curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail']);
$ftpCredential = new FtpCredential(); $ftpCredential = new FtpCredential();
$ftpCredential->setUsrId($NewUser->getId()); $ftpCredential->setUser($NewUser);
if (isset($curUser['activeFTP'])) { if (isset($curUser['activeFTP'])) {
$ftpCredential->setActive((int) $curUser['activeFTP']); $ftpCredential->setActive((int) $curUser['activeFTP']);

View File

@@ -111,7 +111,7 @@ class Baskets implements ControllerProviderInterface
try { try {
$basket = new Basket(); $basket = new Basket();
$basket->setName($request->request->get('p0')); $basket->setName($request->request->get('p0'));
$basket->setOwner($app['authentication']->getUser()); $basket->setuser($app['authentication']->getUser());
$app['EM']->persist($basket); $app['EM']->persist($basket);
$app['EM']->flush(); $app['EM']->flush();

View File

@@ -91,7 +91,7 @@ class Root implements ControllerProviderInterface
$result = $app['phraseanet.SE']->query($query, ($currentPage - 1) * $perPage, $perPage, $options); $result = $app['phraseanet.SE']->query($query, ($currentPage - 1) * $perPage, $perPage, $options);
$userQuery = new UserQuery(); $userQuery = new UserQuery();
$userQuery->setUsrId($app['authentication']->getUser()->getId()); $userQuery->setUser($app['authentication']->getUser());
$userQuery->setQuery($query); $userQuery->setQuery($query);
$app['EM']->persist($userQuery); $app['EM']->persist($userQuery);

View File

@@ -118,7 +118,7 @@ class BasketController implements ControllerProviderInterface
$Basket = new BasketEntity(); $Basket = new BasketEntity();
$Basket->setName($request->request->get('name', '')); $Basket->setName($request->request->get('name', ''));
$Basket->setOwner($app['authentication']->getUser()); $Basket->setUser($app['authentication']->getUser());
$Basket->setDescription($request->request->get('desc')); $Basket->setDescription($request->request->get('desc'));
$app['EM']->persist($Basket); $app['EM']->persist($Basket);

View File

@@ -94,7 +94,7 @@ class Order implements ControllerProviderInterface
if (!$records->isEmpty()) { if (!$records->isEmpty()) {
$order = new OrderEntity(); $order = new OrderEntity();
$order->setUsrId($app['authentication']->getUser()->getId()); $order->setUser($app['authentication']->getUser());
$order->setDeadline((null !== $deadLine = $request->request->get('deadline')) ? new \DateTime($deadLine) : $deadLine); $order->setDeadline((null !== $deadLine = $request->request->get('deadline')) ? new \DateTime($deadLine) : $deadLine);
$order->setOrderUsage($request->request->get('use', '')); $order->setOrderUsage($request->request->get('use', ''));
foreach ($records as $key => $record) { foreach ($records as $key => $record) {
@@ -144,7 +144,7 @@ class Order implements ControllerProviderInterface
try { try {
$app['events-manager']->trigger('__NEW_ORDER__', [ $app['events-manager']->trigger('__NEW_ORDER__', [
'order_id' => $order->getId(), 'order_id' => $order->getId(),
'usr_id' => $order->getUsrId() 'usr_id' => $order->getUser()->getId()
]); ]);
$success = true; $success = true;
@@ -237,19 +237,15 @@ class Order implements ControllerProviderInterface
public function sendOrder(Application $app, Request $request, $order_id) public function sendOrder(Application $app, Request $request, $order_id)
{ {
$success = false; $success = false;
$order = $app['EM']->getRepository('Phraseanet:Order')->find($order_id); if (null === $order = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->find($order_id)) {
if (null === $order) {
throw new NotFoundHttpException('Order not found'); throw new NotFoundHttpException('Order not found');
} }
$dest_user = $app['manipulator.user']->getRepository()->find($order->getUsrId());
$basket = $order->getBasket(); $basket = $order->getBasket();
if (null === $basket) { if (null === $basket) {
$basket = new Basket(); $basket = new Basket();
$basket->setName($app->trans('Commande du %date%', ['%date%' => $order->getCreatedOn()->format('Y-m-d')])); $basket->setName($app->trans('Commande du %date%', ['%date%' => $order->getCreatedOn()->format('Y-m-d')]));
$basket->setOwner($dest_user); $basket->setUser($order->getUser());
$basket->setPusher($app['authentication']->getUser()); $basket->setPusher($app['authentication']->getUser());
$app['EM']->persist($basket); $app['EM']->persist($basket);
@@ -274,7 +270,7 @@ class Order implements ControllerProviderInterface
$basket->addElement($basketElement); $basket->addElement($basketElement);
$n++; $n++;
$app['acl']->get($dest_user)->grant_hd_on($record, $app['authentication']->getUser(), 'order'); $app['acl']->get($basket->getUser())->grant_hd_on($record, $app['authentication']->getUser(), 'order');
} }
} }
@@ -285,7 +281,7 @@ class Order implements ControllerProviderInterface
$app['events-manager']->trigger('__ORDER_DELIVER__', [ $app['events-manager']->trigger('__ORDER_DELIVER__', [
'ssel_id' => $order->getBasket()->getId(), 'ssel_id' => $order->getBasket()->getId(),
'from' => $app['authentication']->getUser()->getId(), 'from' => $app['authentication']->getUser()->getId(),
'to' => $dest_user->getId(), 'to' => $order->getUser()->getId(),
'n' => $n 'n' => $n
]); ]);
} }
@@ -347,7 +343,7 @@ class Order implements ControllerProviderInterface
$app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [ $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [
'from' => $app['authentication']->getUser()->getId(), 'from' => $app['authentication']->getUser()->getId(),
'to' => $order->getUsrId(), 'to' => $order->getUser()->getId(),
'n' => $n 'n' => $n
]); ]);
} }

View File

@@ -57,7 +57,7 @@ class Push implements ControllerProviderInterface
/* @var $entry UsrListEntry */ /* @var $entry UsrListEntry */
$entries[] = [ $entries[] = [
'Id' => $entry->getId(), 'Id' => $entry->getId(),
'User' => $userFormatter($entry->getUser($app)) 'User' => $userFormatter($entry->getUser())
]; ];
} }
@@ -185,7 +185,7 @@ class Push implements ControllerProviderInterface
$Basket = new Basket(); $Basket = new Basket();
$Basket->setName($push_name); $Basket->setName($push_name);
$Basket->setDescription($push_description); $Basket->setDescription($push_description);
$Basket->setOwner($user_receiver); $Basket->setUser($user_receiver);
$Basket->setPusher($app['authentication']->getUser()); $Basket->setPusher($app['authentication']->getUser());
$Basket->setIsRead(false); $Basket->setIsRead(false);
@@ -299,7 +299,7 @@ class Push implements ControllerProviderInterface
$Basket = new Basket(); $Basket = new Basket();
$Basket->setName($validation_name); $Basket->setName($validation_name);
$Basket->setDescription($validation_description); $Basket->setDescription($validation_description);
$Basket->setOwner($app['authentication']->getUser()); $Basket->setUser($app['authentication']->getUser());
$Basket->setIsRead(false); $Basket->setIsRead(false);
$app['EM']->persist($Basket); $app['EM']->persist($Basket);
@@ -495,7 +495,7 @@ class Push implements ControllerProviderInterface
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
if ($list) { if ($list) {
$datas = $listFormatter($list); $datas = $listFormatter($list);
@@ -617,7 +617,7 @@ class Push implements ControllerProviderInterface
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
$query = new \User_Query($app); $query = new \User_Query($app);

View File

@@ -73,7 +73,7 @@ class Query implements ControllerProviderInterface
$result = $app['phraseanet.SE']->query($query, (($page - 1) * $perPage), $perPage, $options); $result = $app['phraseanet.SE']->query($query, (($page - 1) * $perPage), $perPage, $options);
$userQuery = new UserQuery(); $userQuery = new UserQuery();
$userQuery->setUsrId($app['authentication']->getUser()->getId()); $userQuery->setUser($app['authentication']->getUser());
$userQuery->setQuery($result->getQuery()); $userQuery->setQuery($result->getQuery());
$app['EM']->persist($userQuery); $app['EM']->persist($userQuery);

View File

@@ -158,7 +158,7 @@ class Upload implements ControllerProviderInterface
$collection = \collection::get_from_base_id($app, $base_id); $collection = \collection::get_from_base_id($app, $base_id);
$lazaretSession = new LazaretSession(); $lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($app['authentication']->getUser()->getId()); $lazaretSession->setUser($app['authentication']->getUser());
$app['EM']->persist($lazaretSession); $app['EM']->persist($lazaretSession);

View File

@@ -195,7 +195,7 @@ class UsrLists implements ControllerProviderInterface
{ {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
$entries = new ArrayCollection(); $entries = new ArrayCollection();
$owners = new ArrayCollection(); $owners = new ArrayCollection();
@@ -253,7 +253,7 @@ class UsrLists implements ControllerProviderInterface
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) {
throw new ControllerException($app->trans('You are not authorized to do this')); throw new ControllerException($app->trans('You are not authorized to do this'));
@@ -284,9 +284,9 @@ class UsrLists implements ControllerProviderInterface
try { try {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_ADMIN) {
throw new ControllerException($app->trans('You are not authorized to do this')); throw new ControllerException($app->trans('You are not authorized to do this'));
} }
@@ -318,10 +318,10 @@ class UsrLists implements ControllerProviderInterface
try { try {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
/* @var $list UsrList */ /* @var $list UsrList */
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_EDITOR) {
throw new ControllerException($app->trans('You are not authorized to do this')); throw new ControllerException($app->trans('You are not authorized to do this'));
} }
@@ -360,10 +360,10 @@ class UsrLists implements ControllerProviderInterface
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
/* @var $list UsrList */ /* @var $list UsrList */
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_EDITOR) {
throw new ControllerException($app->trans('You are not authorized to do this')); throw new ControllerException($app->trans('You are not authorized to do this'));
} }
@@ -424,10 +424,10 @@ class UsrLists implements ControllerProviderInterface
try { try {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
/* @var $list UsrList */ /* @var $list UsrList */
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_ADMIN) {
$list = null; $list = null;
throw new \Exception($app->trans('You are not authorized to do this')); throw new \Exception($app->trans('You are not authorized to do this'));
} }
@@ -454,21 +454,21 @@ class UsrLists implements ControllerProviderInterface
try { try {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
/* @var $list UsrList */ /* @var $list UsrList */
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_EDITOR) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_EDITOR) {
throw new ControllerException($app->trans('You are not authorized to do this')); throw new ControllerException($app->trans('You are not authorized to do this'));
} }
$new_owner = $app['manipulator.user']->getRepository()->find($usr_id); $new_owner = $app['manipulator.user']->getRepository()->find($usr_id);
if ($list->hasAccess($new_owner, $app)) { if ($list->hasAccess($new_owner)) {
if ($new_owner->getId() == $app['authentication']->getUser()->getId()) { if ($new_owner->getId() == $app['authentication']->getUser()->getId()) {
throw new ControllerException('You can not downgrade your Admin right'); throw new ControllerException('You can not downgrade your Admin right');
} }
$owner = $list->getOwner($new_owner, $app); $owner = $list->getOwner($new_owner);
} else { } else {
$owner = new UsrListOwner(); $owner = new UsrListOwner();
$owner->setList($list); $owner->setList($list);
@@ -510,10 +510,10 @@ class UsrLists implements ControllerProviderInterface
try { try {
$repository = $app['EM']->getRepository('Phraseanet:UsrList'); $repository = $app['EM']->getRepository('Phraseanet:UsrList');
$list = $repository->findUserListByUserAndId($app, $app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
/* @var $list UsrList */ /* @var $list UsrList */
if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_ADMIN) {
throw new \Exception($app->trans('You are not authorized to do this')); throw new \Exception($app->trans('You are not authorized to do this'));
} }

View File

@@ -309,7 +309,7 @@ class Login implements ControllerProviderInterface
->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); ->findWithProviderAndId($token->getProvider()->getId(), $token->getId());
if (null !== $userAuthProvider) { if (null !== $userAuthProvider) {
$this->postAuthProcess($app, $userAuthProvider->getUser($app)); $this->postAuthProcess($app, $userAuthProvider->getUser());
if (null !== $redirect = $request->query->get('redirect')) { if (null !== $redirect = $request->query->get('redirect')) {
$redirection = '../' . $redirect; $redirection = '../' . $redirect;
@@ -466,7 +466,7 @@ class Login implements ControllerProviderInterface
$usrAuthProvider = new UsrAuthProvider(); $usrAuthProvider = new UsrAuthProvider();
$usrAuthProvider->setDistantId($provider->getToken()->getId()); $usrAuthProvider->setDistantId($provider->getToken()->getId());
$usrAuthProvider->setProvider($provider->getId()); $usrAuthProvider->setProvider($provider->getId());
$usrAuthProvider->setUsrId($user->getId()); $usrAuthProvider->setUser($user);
try { try {
$provider->logout(); $provider->logout();
@@ -856,7 +856,7 @@ class Login implements ControllerProviderInterface
/* @var $participant ValidationParticipant */ /* @var $participant ValidationParticipant */
$validationSession = $participant->getSession(); $validationSession = $participant->getSession();
$participantId = $participant->getUsrId(); $participantId = $participant->getUser()->getId();
$basketId = $validationSession->getBasket()->getId(); $basketId = $validationSession->getBasket()->getId();
try { try {
@@ -927,7 +927,7 @@ class Login implements ControllerProviderInterface
->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); ->findWithProviderAndId($token->getProvider()->getId(), $token->getId());
if (null !== $userAuthProvider) { if (null !== $userAuthProvider) {
$this->postAuthProcess($app, $userAuthProvider->getUser($app)); $this->postAuthProcess($app, $userAuthProvider->getUser());
if (null !== $redirect = $request->query->get('redirect')) { if (null !== $redirect = $request->query->get('redirect')) {
$redirection = '../' . $redirect; $redirection = '../' . $redirect;
@@ -1058,7 +1058,7 @@ class Login implements ControllerProviderInterface
$baskets = $repo->findBy(['usr_id' => $inviteUsrId]); $baskets = $repo->findBy(['usr_id' => $inviteUsrId]);
foreach ($baskets as $basket) { foreach ($baskets as $basket) {
$basket->setUsrId($user->getId()); $basket->setUser($user);
$app['EM']->persist($basket); $app['EM']->persist($basket);
} }
} }

View File

@@ -64,7 +64,7 @@ class RSSFeeds implements ControllerProviderInterface
$controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) { $controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) {
$token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(["value" => $token]); $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(["value" => $token]);
$user = $app['manipulator.user']->getRepository()->find($token->getUsrId()); $user = $token->getUser();
$feeds = $app['EM']->getRepository('Phraseanet:Feed')->getAllForUser($app['acl']->get($user)); $feeds = $app['EM']->getRepository('Phraseanet:Feed')->getAllForUser($app['acl']->get($user));

View File

@@ -138,7 +138,7 @@ class Session implements ControllerProviderInterface
$app->abort(404, 'Unknown session'); $app->abort(404, 'Unknown session');
} }
if ($session->getUsrId() !== $app['authentication']->getUser()->getId()) { if ($session->getUser()->getId() !== $app['authentication']->getUser()->getId()) {
$app->abort(403, 'Unauthorized'); $app->abort(403, 'Unauthorized');
} }

View File

@@ -27,9 +27,12 @@ class AggregateToken
private $id; private $id;
/** /**
* @ORM\Column(type="integer", name="usr_id") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usrId; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string", length=12, nullable=true) * @ORM\Column(type="string", length=12, nullable=true)
@@ -47,26 +50,23 @@ class AggregateToken
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return AggregateToken * @return AggregateToken
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usrId = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usrId; return $this->user;
} }
/** /**
@@ -91,4 +91,5 @@ class AggregateToken
{ {
return $this->value; return $this->value;
} }
} }

View File

@@ -43,9 +43,12 @@ class Basket
private $description; private $description;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
@@ -155,38 +158,23 @@ class Basket
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return Basket * @return Basket
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
public function setOwner(\User_Adapter $user)
{
$this->setUsrId($user->getId());
}
public function getOwner(Application $app)
{
if ($this->getUsrId()) {
return \User_Adapter::getInstance($this->getUsrId(), $app);
}
} }
/** /**

View File

@@ -283,7 +283,7 @@ class BasketElement
public function getUserValidationDatas(\User_Adapter $user, Application $app) public function getUserValidationDatas(\User_Adapter $user, Application $app)
{ {
foreach ($this->validation_datas as $validationData) { foreach ($this->validation_datas as $validationData) {
if ($validationData->getParticipant($app)->getUser($app)->getId() == $user->getId()) { if ($validationData->getParticipant($app)->getUser()->getId() == $user->getId()) {
return $validationData; return $validationData;
} }
} }

View File

@@ -278,16 +278,16 @@ class Feed implements FeedInterface
} }
/** /**
* Returns a boolean indicating whether the given User_Adapter is the owner of the feed. * Returns a boolean indicating whether the given user is the owner of the feed.
* *
* @param User $user * @param User $user
* *
* @return boolean * @return boolean
*/ */
public function isOwner(\User_Adapter $user) public function isOwner(User $user)
{ {
$owner = $this->getOwner(); $owner = $this->getOwner();
if ($owner !== null && $user->getId() === $owner->getUsrId()) { if ($owner !== null && $user->getId() === $owner->getUser()->getId()) {
return true; return true;
} }
@@ -372,16 +372,16 @@ class Feed implements FeedInterface
} }
/** /**
* Returns a boolean indicating whether the given User_Adapter is a publisher of the feed. * Returns a boolean indicating whether the given user is a publisher of the feed.
* *
* @param User $user * @param User $user
* *
* @return boolean * @return boolean
*/ */
public function isPublisher(\User_Adapter $user) public function isPublisher(User $user)
{ {
foreach ($this->getPublishers() as $publisher) { foreach ($this->getPublishers() as $publisher) {
if ($publisher->getUsrId() == $user->getId()) { if ($publisher->getUser()->getId() == $user->getId()) {
return true; return true;
} }
} }
@@ -390,16 +390,16 @@ class Feed implements FeedInterface
} }
/** /**
* Returns an instance of FeedPublisher matching to the given User_Adapter * Returns an instance of FeedPublisher matching to the given user.
* *
* @param User $user * @param User $user
* *
* @return FeedPublisher * @return FeedPublisher
*/ */
public function getPublisher(\User_Adapter $user) public function getPublisher(User $user)
{ {
foreach ($this->getPublishers() as $publisher) { foreach ($this->getPublishers() as $publisher) {
if ($publisher->getUsrId() == $user->getId()) { if ($publisher->gteUser()->getId() == $user->getId()) {
return $publisher; return $publisher;
} }
} }
@@ -451,14 +451,14 @@ class Feed implements FeedInterface
} }
/** /**
* Returns a boolean indicating whether the given User_Adapter has access to the feed * Returns a boolean indicating whether the given user has access to the feed.
* *
* @param User $user * @param User $user
* @param Application $app * @param Application $app
* *
* @return boolean * @return boolean
*/ */
public function hasAccess(\User_Adapter $user, Application $app) public function hasAccess(User $user, Application $app)
{ {
if ($this->getCollection($app) instanceof collection) { if ($this->getCollection($app) instanceof collection) {
return $app['acl']->get($user)->has_access_to_base($this->collection->get_base_id()); return $app['acl']->get($user)->has_access_to_base($this->collection->get_base_id());
@@ -548,12 +548,12 @@ class Feed implements FeedInterface
* *
* Returns a boolean indicating whether a given user has access to the feed * Returns a boolean indicating whether a given user has access to the feed
* *
* @param \User_Adapter $user * @param User $user
* @param \Alchemy\Phrasea\Application $app * @param \Alchemy\Phrasea\Application $app
* *
* @return boolean * @return boolean
*/ */
public function isAccessible(\User_Adapter $user, Application $app) public function isAccessible(User $user, Application $app)
{ {
$coll = $this->getCollection($app); $coll = $this->getCollection($app);
if ($this->isPublic() if ($this->isPublic()

View File

@@ -313,16 +313,16 @@ class FeedEntry
} }
/** /**
* Returns a boolean indicating whether the given User_Adapter is the publisher of the entry. * Returns a boolean indicating whether the given User is the publisher of the entry.
* *
* @param User $user * @param User $user
* *
* @return boolean * @return boolean
*/ */
public function isPublisher(\User_Adapter $user) public function isPublisher(User $user)
{ {
if ($this->publisher) { if ($this->publisher) {
if ($this->publisher->getUsrId() === $user->getId()) { if ($this->publisher->getUser()->getId() === $user->getId()) {
return true; return true;
} }
} }

View File

@@ -29,9 +29,12 @@ class FeedPublisher
private $id; private $id;
/** /**
* @ORM\Column(type="integer", name="usr_id") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usrId; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
@@ -61,26 +64,23 @@ class FeedPublisher
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return FeedPublisher * @return FeedPublisher
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usrId = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usrId; return $this->user;
} }
/** /**
@@ -129,18 +129,6 @@ class FeedPublisher
return $this->feed; return $this->feed;
} }
/**
* Get user
*
* @return \User_Adapter
*/
public function getUser(Application $app)
{
$user = \User_Adapter::getInstance($this->getUsrId(), $app);
return $user;
}
/** /**
* Set created_on * Set created_on
* *

View File

@@ -27,9 +27,12 @@ class FeedToken
private $id; private $id;
/** /**
* @ORM\Column(type="integer", name="usr_id") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usrId; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string", length=12, nullable=true) * @ORM\Column(type="string", length=12, nullable=true)
@@ -53,26 +56,23 @@ class FeedToken
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return FeedToken * @return FeedToken
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usrId = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usrId; return $this->user;
} }
/** /**

View File

@@ -27,11 +27,6 @@ class FtpCredential
*/ */
private $id; private $id;
/**
* @ORM\Column(type="integer")
*/
private $usrId;
/** /**
* @ORM\OneToOne(targetEntity="User", inversedBy="ftpCredential") * @ORM\OneToOne(targetEntity="User", inversedBy="ftpCredential")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
@@ -97,22 +92,6 @@ class FtpCredential
return $this->id; return $this->id;
} }
/**
* @return integer
*/
public function getUsrId()
{
return $this->usrId;
}
/**
* @param integer $usrId
*/
public function setUsrId($usrId)
{
$this->usrId = $usrId;
}
/** /**
* @return User * @return User
*/ */

View File

@@ -90,9 +90,12 @@ class FtpExport
private $textMailReceiver; private $textMailReceiver;
/** /**
* @ORM\Column(type="integer", name="usr_id") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usrId; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
@@ -141,6 +144,26 @@ class FtpExport
return $this->id; return $this->id;
} }
/**
* @param User $user
*
* @return FtpExport
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/** /**
* Set crash * Set crash
* *
@@ -441,54 +464,6 @@ class FtpExport
return $this->textMailReceiver; return $this->textMailReceiver;
} }
/**
* Set usrId
*
* @param integer $usrId
*
* @return FtpExport
*/
public function setUsrId($usrId)
{
$this->usrId = $usrId;
return $this;
}
/**
* Get usrId
*
* @return integer
*/
public function getUsrId()
{
return $this->usrId;
}
/**
* Get user
*
* @return \User_Adapter
*/
public function getUser(Application $app)
{
return \User_Adapter::getInstance($this->getUsr_id(), $app);
}
/**
* Set user
*
* @param User $user
*
* @return FtpExport
*/
public function setUser(\User_Adapter $user)
{
$this->setUsrId($user->getId());
return $this;
}
/** /**
* Set foldertocreate * Set foldertocreate
* *

View File

@@ -29,9 +29,12 @@ class LazaretSession
private $id; private $id;
/** /**
* @ORM\Column(type="integer", nullable=true) * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @Gedmo\Timestampable(on="create") * @Gedmo\Timestampable(on="create")
@@ -70,44 +73,23 @@ class LazaretSession
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return LazaretSession * @return LazaretSession
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
/**
* Get user
*
* @return \User_Adapter
*/
public function getUser(Application $app)
{
$user = null;
try {
$user = \User_Adapter::getInstance($this->usr_id, $app);
} catch (\Exception $e) {
}
return $user;
} }
/** /**

View File

@@ -29,9 +29,12 @@ class Order
private $id; private $id;
/** /**
* @ORM\Column(type="integer", name="usr_id") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usrId; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string", length=2048, name="order_usage") * @ORM\Column(type="string", length=2048, name="order_usage")
@@ -83,26 +86,23 @@ class Order
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return Order * @return Order
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usrId = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usrId; return $this->user;
} }
/** /**
@@ -184,20 +184,6 @@ class Order
return $this->elements; return $this->elements;
} }
/**
* Returns the user matching to the usr_id property.
*
* @param Application $app
*
* @return User_Adapter
*/
public function getUser(Application $app)
{
if ($this->getUsrId()) {
return \User_Adapter::getInstance($this->getUsrId(), $app);
}
}
/** /**
* Set todo * Set todo
* *

View File

@@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
/** /**
* @ORM\Table(name="Sessions", indexes={@ORM\index(name="usr_id", columns={"usr_id"})}) * @ORM\Table(name="Sessions")
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\SessionRepository") * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\SessionRepository")
*/ */
class Session class Session
@@ -29,9 +29,12 @@ class Session
private $id; private $id;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string", length=512) * @ORM\Column(type="string", length=512)
@@ -114,39 +117,24 @@ class Session
return $this->id; return $this->id;
} }
public function setUser(\User_Adapter $user)
{
return $this->setUsrId($user->getId());
}
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return Session * @return Session
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
public function getUser(Application $app)
{
if ($this->getUsrId()) {
return \User_Adapter::getInstance($this->getUsrId(), $app);
}
}
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
} }
/** /**

View File

@@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
/** /**
* @ORM\Table(name="StoryWZ", uniqueConstraints={@ORM\UniqueConstraint(name="user_story", columns={"usr_id", "sbas_id", "record_id"})}) * @ORM\Table(name="StoryWZ", uniqueConstraints={@ORM\UniqueConstraint(name="user_story", columns={"user_id", "sbas_id", "record_id"})})
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\StoryWZRepository") * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\StoryWZRepository")
*/ */
class StoryWZ class StoryWZ
@@ -40,9 +40,12 @@ class StoryWZ
private $record_id; private $record_id;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @Gedmo\Timestampable(on="create") * @Gedmo\Timestampable(on="create")
@@ -116,40 +119,24 @@ class StoryWZ
$this->setRecordId($record->get_record_id()); $this->setRecordId($record->get_record_id());
$this->setSbasId($record->get_sbas_id()); $this->setSbasId($record->get_sbas_id());
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return StoryWZ * @return StoryWZ
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
public function setUser(\User_Adapter $user)
{
$this->setUsrId($user->getId());
}
public function getUser(Application $app)
{
if ($this->getUsrId()) {
return \User_Adapter::getInstance($this->getUsrId(), $app);
}
} }
/** /**

View File

@@ -31,11 +31,6 @@ class UserNotificationSetting
*/ */
private $id; private $id;
/**
* @ORM\Column(type="integer", name="usr_id")
*/
private $usrId;
/** /**
* @ORM\ManyToOne(targetEntity="User", inversedBy="notificationSettings") * @ORM\ManyToOne(targetEntity="User", inversedBy="notificationSettings")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
@@ -92,26 +87,6 @@ class UserNotificationSetting
return $this; return $this;
} }
/**
* @return integer
*/
public function getUsrId()
{
return $this->usrId;
}
/**
* @param integer $usrId
*
* @return UserSetting
*/
public function setUsrId($usrId)
{
$this->usrId = $usrId;
return $this;
}
/** /**
* @return string * @return string
*/ */

View File

@@ -27,11 +27,6 @@ class UserQuery
*/ */
private $id; private $id;
/**
* @ORM\Column(type="integer", name="usr_id")
*/
private $usrId;
/** /**
* @ORM\ManyToOne(targetEntity="User", inversedBy="queries") * @ORM\ManyToOne(targetEntity="User", inversedBy="queries")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
@@ -57,22 +52,6 @@ class UserQuery
return $this->id; return $this->id;
} }
/**
* @return integer
*/
public function getUsrId()
{
return $this->usrId;
}
/**
* @param integer $usrId
*/
public function setUsrId($usrId)
{
$this->usrId = $usrId;
}
/** /**
* @return User * @return User
*/ */

View File

@@ -31,11 +31,6 @@ class UserSetting
*/ */
private $id; private $id;
/**
* @ORM\Column(type="integer", name="usr_id")
*/
private $usrId;
/** /**
* @ORM\ManyToOne(targetEntity="User", inversedBy="settings") * @ORM\ManyToOne(targetEntity="User", inversedBy="settings")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
@@ -92,26 +87,6 @@ class UserSetting
return $this; return $this;
} }
/**
* @return integer
*/
public function getUsrId()
{
return $this->usrId;
}
/**
* @param integer $usrId
*
* @return UserSetting
*/
public function setUsrId($usrId)
{
$this->usrId = $usrId;
return $this;
}
/** /**
* @return string * @return string
*/ */

View File

@@ -17,7 +17,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
/** /**
* @ORM\Table(name="UsrAuthProviders", uniqueConstraints={ * @ORM\Table(name="UsrAuthProviders", uniqueConstraints={
* @ORM\UniqueConstraint(name="unique_provider_per_user", columns={"usr_id", "provider"}), * @ORM\UniqueConstraint(name="unique_provider_per_user", columns={"user_id", "provider"}),
* @ORM\UniqueConstraint(name="provider_ids", columns={"provider", "distant_id"}) * @ORM\UniqueConstraint(name="provider_ids", columns={"provider", "distant_id"})
* }) * })
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrAuthProviderRepository") * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrAuthProviderRepository")
@@ -32,9 +32,12 @@ class UsrAuthProvider
private $id; private $id;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string", length=32) * @ORM\Column(type="string", length=32)
@@ -69,31 +72,23 @@ class UsrAuthProvider
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId * @return usrAuthprovider
* @return UsrAuthProvider
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
public function getUser(Application $app)
{
return \User_Adapter::getInstance($this->usr_id, $app);
} }
/** /**

View File

@@ -209,10 +209,10 @@ class UsrList
return $this->entries; return $this->entries;
} }
public function hasAccess(\User_Adapter $user, Application $app) public function hasAccess(User $user)
{ {
foreach ($this->getOwners() as $owner) { foreach ($this->getOwners() as $owner) {
if ($owner->getUser($app)->getId() == $user->getId()) { if ($owner->getUser()->getId() == $user->getId()) {
return true; return true;
} }
} }
@@ -222,13 +222,13 @@ class UsrList
/** /**
* *
* @param \User_Adapter $user * @param User $user
* @return UsrListOwner * @return UsrListOwner
*/ */
public function getOwner(\User_Adapter $user, Application $app) public function getOwner(User $user)
{ {
foreach ($this->getOwners() as $owner) { foreach ($this->getOwners() as $owner) {
if ($owner->getUser($app)->getId() == $user->getId()) { if ($owner->getUser()->getId() == $user->getId()) {
return $owner; return $owner;
} }
} }
@@ -246,7 +246,7 @@ class UsrList
{ {
return $this->entries->exists( return $this->entries->exists(
function ($key, $entry) use ($user, $app) { function ($key, $entry) use ($user, $app) {
return $entry->getUser($app)->getId() === $user->getId(); return $entry->getUser()->getId() === $user->getId();
} }
); );
} }

View File

@@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
/** /**
* @ORM\Table(name="UsrListsContent", uniqueConstraints={@ORM\UniqueConstraint(name="unique_usr_per_list", columns={"usr_id", "list_id"})}) * @ORM\Table(name="UsrListsContent", uniqueConstraints={@ORM\UniqueConstraint(name="unique_usr_per_list", columns={"user_id", "list_id"})})
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrListEntryRepository") * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrListEntryRepository")
*/ */
class UsrListEntry class UsrListEntry
@@ -29,9 +29,12 @@ class UsrListEntry
private $id; private $id;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @Gedmo\Timestampable(on="create") * @Gedmo\Timestampable(on="create")
@@ -62,36 +65,23 @@ class UsrListEntry
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId
* @return UsrListEntry * @return UsrListEntry
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
public function getUser(Application $app)
{
return \User_Adapter::getInstance($this->getUsrId(), $app);
}
public function setUser(\User_Adapter $user)
{
return $this->setUsrId($user->getId());
} }
/** /**

View File

@@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
/** /**
* @ORM\Table(name="UsrListOwners", uniqueConstraints={@ORM\UniqueConstraint(name="unique_owner", columns={"usr_id", "id"})}) * @ORM\Table(name="UsrListOwners", uniqueConstraints={@ORM\UniqueConstraint(name="unique_owner", columns={"user_id", "id"})})
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrListOwnerRepository") * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrListOwnerRepository")
*/ */
class UsrListOwner class UsrListOwner
@@ -33,9 +33,12 @@ class UsrListOwner
private $id; private $id;
/** /**
* @ORM\Column(type="integer") * @ORM\ManyToOne(targetEntity="User")
*/ * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $usr_id; *
* @return User
**/
private $user;
/** /**
* @ORM\Column(type="string") * @ORM\Column(type="string")
@@ -71,36 +74,23 @@ class UsrListOwner
} }
/** /**
* Set usr_id * @param User $user
* *
* @param integer $usrId * @return UsrListowner
* @return UsrListOwner
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
public function setUser(\User_Adapter $user)
{
return $this->setUsrId($user->getId());
}
public function getUser(Application $app)
{
return \User_Adapter::getInstance($this->getUsrId(), $app);
} }
/** /**

View File

@@ -27,11 +27,6 @@ class ValidationParticipant
*/ */
private $id; private $id;
/**
* @ORM\Column(type="integer")
*/
private $usr_id;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
*/ */
@@ -87,43 +82,31 @@ class ValidationParticipant
} }
/** /**
* Set usr_id * @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* *
* @param integer $usrId * @return User
* @return ValidationParticipant **/
private $user;
/**
* @param User $user
*
* @return AggregateToken
*/ */
public function setUsrId($usrId) public function setUser(User $user)
{ {
$this->usr_id = $usrId; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get usr_id * @return User
*
* @return integer
*/ */
public function getUsrId() public function getUser()
{ {
return $this->usr_id; return $this->user;
}
/**
*
* @param \User_Adapter $user
* @return ValidationParticipant
*/
public function setUser(\User_Adapter $user)
{
$this->usr_id = $user->getId();
return $this;
}
public function getUser(Application $app)
{
return \User_Adapter::getInstance($this->getUsrId(), $app);
} }
/** /**

View File

@@ -284,7 +284,7 @@ class ValidationSession
public function getParticipant(\User_Adapter $user, Application $app) public function getParticipant(\User_Adapter $user, Application $app)
{ {
foreach ($this->getParticipants() as $participant) { foreach ($this->getParticipants() as $participant) {
if ($participant->getUser($app)->getId() == $user->getId()) { if ($participant->getUser()->getId() == $user->getId()) {
return $participant; return $participant;
} }
} }

View File

@@ -187,7 +187,7 @@ class UserManipulator implements ManipulatorInterface
public function addUserSetting(User $user, $name, $value) public function addUserSetting(User $user, $name, $value)
{ {
$userSetting = new UserSetting(); $userSetting = new UserSetting();
$userSetting->setUsrId($user->getId()); $userSetting->setUser($user);
$userSetting->setName($name); $userSetting->setName($name);
$userSetting->setValue($value); $userSetting->setValue($value);
$user->addSetting($userSetting); $user->addSetting($userSetting);
@@ -207,7 +207,7 @@ class UserManipulator implements ManipulatorInterface
$notifSetting = new UserNotificationSetting(); $notifSetting = new UserNotificationSetting();
$notifSetting->setName($name); $notifSetting->setName($name);
$notifSetting->setValue($value); $notifSetting->setValue($value);
$notifSetting->setUsrId($user->getId()); $notifSetting->setUsrId($user);
$user->addNotificationSettings($notifSetting); $user->addNotificationSettings($notifSetting);
$this->manager->update($user); $this->manager->update($user);
@@ -224,7 +224,7 @@ class UserManipulator implements ManipulatorInterface
$userQuery = new UserQuery(); $userQuery = new UserQuery();
$userQuery->setUser($user); $userQuery->setUser($user);
$userQuery->setQuery($query); $userQuery->setQuery($query);
$userQuery->setUsrId($user->getId()); $userQuery->setUser($user);
$user->addQuery($userQuery); $user->addQuery($userQuery);

View File

@@ -141,7 +141,7 @@ class BasketRepository extends EntityRepository
throw new NotFoundHttpException(_('Basket is not found')); throw new NotFoundHttpException(_('Basket is not found'));
} }
if ($basket->getOwner($app)->getId() != $user->getId()) { if ($basket->getUser()->getId() != $user->getId()) {
$participant = false; $participant = false;
if ($basket->getValidation() && !$requireOwner) { if ($basket->getValidation() && !$requireOwner) {

View File

@@ -84,7 +84,7 @@ class StoryWZRepository extends EntityRepository
throw new NotFoundHttpException('Story not found'); throw new NotFoundHttpException('Story not found');
} }
if ($story->getUser($app)->getId() !== $user->getId()) { if ($story->getUser()->getId() !== $user->getId()) {
throw new AccessDeniedHttpException('You have not access to ths story'); throw new AccessDeniedHttpException('You have not access to ths story');
} }
} else { } else {

View File

@@ -55,7 +55,7 @@ class UsrListRepository extends EntityRepository
* @param type $list_id * @param type $list_id
* @return UsrList * @return UsrList
*/ */
public function findUserListByUserAndId(Application $app, User $user, $list_id) public function findUserListByUserAndId(User $user, $list_id)
{ {
$list = $this->find($list_id); $list = $this->find($list_id);
@@ -64,7 +64,7 @@ class UsrListRepository extends EntityRepository
throw new NotFoundHttpException('List is not found.'); throw new NotFoundHttpException('List is not found.');
} }
if ( ! $list->hasAccess($user, $app)) { if ( ! $list->hasAccess($user)) {
throw new AccessDeniedHttpException('You have not access to this list.'); throw new AccessDeniedHttpException('You have not access to this list.');
} }

View File

@@ -0,0 +1,78 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class DeleteUsrIdFieldMigration extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("DROP INDEX unique_owner ON UsrListOwners");
$this->addSql("ALTER TABLE UsrListOwners DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_owner ON UsrListOwners (user_id, id)");
$this->addSql("ALTER TABLE FtpCredential DROP usrId");
$this->addSql("DROP INDEX usr_id ON Sessions");
$this->addSql("ALTER TABLE Sessions DROP usr_id");
$this->addSql("ALTER TABLE Baskets DROP usr_id");
$this->addSql("DROP INDEX user_story ON StoryWZ");
$this->addSql("ALTER TABLE StoryWZ DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX user_story ON StoryWZ (user_id, sbas_id, record_id)");
$this->addSql("ALTER TABLE UserNotificationSettings DROP usr_id");
$this->addSql("ALTER TABLE UserSettings DROP usr_id");
$this->addSql("ALTER TABLE Orders DROP usr_id");
$this->addSql("ALTER TABLE UserQueries DROP usr_id");
$this->addSql("ALTER TABLE LazaretSessions DROP usr_id");
$this->addSql("ALTER TABLE ValidationParticipants DROP usr_id");
$this->addSql("ALTER TABLE FeedPublishers DROP usr_id");
$this->addSql("ALTER TABLE AggregateTokens DROP usr_id");
$this->addSql("ALTER TABLE FtpExports DROP usr_id");
$this->addSql("DROP INDEX unique_provider_per_user ON UsrAuthProviders");
$this->addSql("ALTER TABLE UsrAuthProviders DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_provider_per_user ON UsrAuthProviders (user_id, provider)");
$this->addSql("ALTER TABLE FeedTokens DROP usr_id");
$this->addSql("DROP INDEX unique_usr_per_list ON UsrListsContent");
$this->addSql("ALTER TABLE UsrListsContent DROP usr_id");
$this->addSql("CREATE UNIQUE INDEX unique_usr_per_list ON UsrListsContent (user_id, list_id)");
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE AggregateTokens ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE Baskets ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FeedPublishers ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FeedTokens ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE FtpCredential ADD usrId INT NOT NULL");
$this->addSql("ALTER TABLE FtpExports ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE LazaretSessions ADD usr_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE Orders ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE Sessions ADD usr_id INT NOT NULL");
$this->addSql("CREATE INDEX usr_id ON Sessions (usr_id)");
$this->addSql("DROP INDEX user_story ON StoryWZ");
$this->addSql("ALTER TABLE StoryWZ ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX user_story ON StoryWZ (usr_id, sbas_id, record_id)");
$this->addSql("ALTER TABLE UserNotificationSettings ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE UserQueries ADD usr_id INT NOT NULL");
$this->addSql("ALTER TABLE UserSettings ADD usr_id INT NOT NULL");
$this->addSql("DROP INDEX unique_provider_per_user ON UsrAuthProviders");
$this->addSql("ALTER TABLE UsrAuthProviders ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_provider_per_user ON UsrAuthProviders (usr_id, provider)");
$this->addSql("DROP INDEX unique_owner ON UsrListOwners");
$this->addSql("ALTER TABLE UsrListOwners ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_owner ON UsrListOwners (usr_id, id)");
$this->addSql("DROP INDEX unique_usr_per_list ON UsrListsContent");
$this->addSql("ALTER TABLE UsrListsContent ADD usr_id INT NOT NULL");
$this->addSql("CREATE UNIQUE INDEX unique_usr_per_list ON UsrListsContent (usr_id, list_id)");
$this->addSql("ALTER TABLE ValidationParticipants ADD usr_id INT NOT NULL");
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class UserFieldMigration extends AbstractMigration
{
public function doUpSql(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE UsrListOwners ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE UsrListOwners ADD CONSTRAINT FK_54E9FE23A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_54E9FE23A76ED395 ON UsrListOwners (user_id)");
$this->addSql("ALTER TABLE Sessions ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE Sessions ADD CONSTRAINT FK_6316FF45A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_6316FF45A76ED395 ON Sessions (user_id)");
$this->addSql("ALTER TABLE Baskets ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE Baskets ADD CONSTRAINT FK_13461873A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_13461873A76ED395 ON Baskets (user_id)");
$this->addSql("ALTER TABLE StoryWZ ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE StoryWZ ADD CONSTRAINT FK_E0D2CBAEA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_E0D2CBAEA76ED395 ON StoryWZ (user_id)");
$this->addSql("ALTER TABLE Orders ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE Orders ADD CONSTRAINT FK_E283F8D8A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_E283F8D8A76ED395 ON Orders (user_id)");
$this->addSql("ALTER TABLE LazaretSessions ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE LazaretSessions ADD CONSTRAINT FK_40A81317A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_40A81317A76ED395 ON LazaretSessions (user_id)");
$this->addSql("ALTER TABLE ValidationParticipants ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE ValidationParticipants ADD CONSTRAINT FK_17850D7BA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_17850D7BA76ED395 ON ValidationParticipants (user_id)");
$this->addSql("ALTER TABLE FeedPublishers ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE FeedPublishers ADD CONSTRAINT FK_31AFAB2A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_31AFAB2A76ED395 ON FeedPublishers (user_id)");
$this->addSql("ALTER TABLE AggregateTokens ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE AggregateTokens ADD CONSTRAINT FK_4232BC51A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_4232BC51A76ED395 ON AggregateTokens (user_id)");
$this->addSql("ALTER TABLE FtpExports ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE FtpExports ADD CONSTRAINT FK_CFCEEE7AA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_CFCEEE7AA76ED395 ON FtpExports (user_id)");
$this->addSql("ALTER TABLE UsrAuthProviders ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE UsrAuthProviders ADD CONSTRAINT FK_947F003FA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_947F003FA76ED395 ON UsrAuthProviders (user_id)");
$this->addSql("ALTER TABLE FeedTokens ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE FeedTokens ADD CONSTRAINT FK_9D1CA848A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_9D1CA848A76ED395 ON FeedTokens (user_id)");
$this->addSql("ALTER TABLE UsrListsContent ADD user_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE UsrListsContent ADD CONSTRAINT FK_661B8B9A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
$this->addSql("CREATE INDEX IDX_661B8B9A76ED395 ON UsrListsContent (user_id)");
}
public function doDownSql(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE AggregateTokens DROP FOREIGN KEY FK_4232BC51A76ED395");
$this->addSql("DROP INDEX IDX_4232BC51A76ED395 ON AggregateTokens");
$this->addSql("ALTER TABLE AggregateTokens DROP user_id");
$this->addSql("ALTER TABLE Baskets DROP FOREIGN KEY FK_13461873A76ED395");
$this->addSql("DROP INDEX IDX_13461873A76ED395 ON Baskets");
$this->addSql("ALTER TABLE Baskets DROP user_id");
$this->addSql("ALTER TABLE FeedPublishers DROP FOREIGN KEY FK_31AFAB2A76ED395");
$this->addSql("DROP INDEX IDX_31AFAB2A76ED395 ON FeedPublishers");
$this->addSql("ALTER TABLE FeedPublishers DROP user_id");
$this->addSql("ALTER TABLE FeedTokens DROP FOREIGN KEY FK_9D1CA848A76ED395");
$this->addSql("DROP INDEX IDX_9D1CA848A76ED395 ON FeedTokens");
$this->addSql("ALTER TABLE FeedTokens DROP user_id");
$this->addSql("ALTER TABLE FtpExports DROP FOREIGN KEY FK_CFCEEE7AA76ED395");
$this->addSql("DROP INDEX IDX_CFCEEE7AA76ED395 ON FtpExports");
$this->addSql("ALTER TABLE FtpExports DROP user_id");
$this->addSql("ALTER TABLE LazaretSessions DROP FOREIGN KEY FK_40A81317A76ED395");
$this->addSql("DROP INDEX IDX_40A81317A76ED395 ON LazaretSessions");
$this->addSql("ALTER TABLE LazaretSessions DROP user_id");
$this->addSql("ALTER TABLE Orders DROP FOREIGN KEY FK_E283F8D8A76ED395");
$this->addSql("DROP INDEX IDX_E283F8D8A76ED395 ON Orders");
$this->addSql("ALTER TABLE Orders DROP user_id");
$this->addSql("ALTER TABLE Sessions DROP FOREIGN KEY FK_6316FF45A76ED395");
$this->addSql("DROP INDEX IDX_6316FF45A76ED395 ON Sessions");
$this->addSql("ALTER TABLE Sessions DROP user_id");
$this->addSql("ALTER TABLE StoryWZ DROP FOREIGN KEY FK_E0D2CBAEA76ED395");
$this->addSql("DROP INDEX IDX_E0D2CBAEA76ED395 ON StoryWZ");
$this->addSql("ALTER TABLE StoryWZ DROP user_id");
$this->addSql("ALTER TABLE UsrAuthProviders DROP FOREIGN KEY FK_947F003FA76ED395");
$this->addSql("DROP INDEX IDX_947F003FA76ED395 ON UsrAuthProviders");
$this->addSql("ALTER TABLE UsrAuthProviders DROP user_id");
$this->addSql("ALTER TABLE UsrListOwners DROP FOREIGN KEY FK_54E9FE23A76ED395");
$this->addSql("DROP INDEX IDX_54E9FE23A76ED395 ON UsrListOwners");
$this->addSql("ALTER TABLE UsrListOwners DROP user_id");
$this->addSql("ALTER TABLE UsrListsContent DROP FOREIGN KEY FK_661B8B9A76ED395");
$this->addSql("DROP INDEX IDX_661B8B9A76ED395 ON UsrListsContent");
$this->addSql("ALTER TABLE UsrListsContent DROP user_id");
$this->addSql("ALTER TABLE ValidationParticipants DROP FOREIGN KEY FK_17850D7BA76ED395");
$this->addSql("DROP INDEX IDX_17850D7BA76ED395 ON ValidationParticipants");
$this->addSql("ALTER TABLE ValidationParticipants DROP user_id");
}
}

View File

@@ -659,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract
} }
$session = new Alchemy\Phrasea\Model\Entities\LazaretSession(); $session = new Alchemy\Phrasea\Model\Entities\LazaretSession();
$session->setUsrId($app['authentication']->getUser()->getId()); $session->setUser($app['authentication']->getUser());
$app['EM']->persist($session); $app['EM']->persist($session);
$app['EM']->flush(); $app['EM']->flush();
@@ -784,8 +784,8 @@ class API_V1_adapter extends API_V1_Abstract
} }
$usr_id = null; $usr_id = null;
if ($file->getSession()->getUser($this->app)) { if ($file->getSession()->getUser()) {
$usr_id = $file->getSession()->getUser($this->app)->getId(); $usr_id = $file->getSession()->getUser()->getId();
} }
$session = [ $session = [
@@ -877,7 +877,7 @@ class API_V1_adapter extends API_V1_Abstract
$search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage, $options); $search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage, $options);
$userQuery = new UserQuery(); $userQuery = new UserQuery();
$userQuery->setUsrId($this->app['authentication']->getUser()->getId()); $userQuery->setUser($this->app['authentication']->getUser());
$userQuery->setQuery($query); $userQuery->setQuery($query);
$this->app['EM']->persist($userQuery); $this->app['EM']->persist($userQuery);
@@ -1272,7 +1272,7 @@ class API_V1_adapter extends API_V1_Abstract
} }
$Basket = new Basket(); $Basket = new Basket();
$Basket->setOwner($this->app['authentication']->getUser()); $Basket->setUser($this->app['authentication']->getUser());
$Basket->setName($name); $Basket->setName($name);
$this->app['EM']->persist($Basket); $this->app['EM']->persist($Basket);
@@ -1369,7 +1369,7 @@ class API_V1_adapter extends API_V1_Abstract
foreach ($basket_element->getValidationDatas() as $validation_datas) { foreach ($basket_element->getValidationDatas() as $validation_datas) {
$participant = $validation_datas->getParticipant(); $participant = $validation_datas->getParticipant();
$user = $participant->getUser($this->app); $user = $participant->getUser();
/* @var $validation_datas ValidationData */ /* @var $validation_datas ValidationData */
$choices[] = [ $choices[] = [
'validation_user' => [ 'validation_user' => [
@@ -1814,7 +1814,7 @@ class API_V1_adapter extends API_V1_Abstract
foreach ($basket->getValidation()->getParticipants() as $participant) { foreach ($basket->getValidation()->getParticipants() as $participant) {
/* @var $participant ValidationParticipant */ /* @var $participant ValidationParticipant */
$user = $participant->getUser($this->app); $user = $participant->getUser();
$users[] = [ $users[] = [
'usr_id' => $user->getId(), 'usr_id' => $user->getId(),

View File

@@ -72,7 +72,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
$datas = $domXML->saveXml(); $datas = $domXML->saveXml();
//Sender //Sender
if (null !== $user = $lazaretFile->getSession()->getUser($this->app)) { if (null !== $user = $lazaretFile->getSession()->getUser()) {
$sender = $domXML->createElement('sender'); $sender = $domXML->createElement('sender');
$sender->appendChild($domXML->createTextNode($user->getDisplayName())); $sender->appendChild($domXML->createTextNode($user->getDisplayName()));
$root->appendChild($sender); $root->appendChild($sender);

View File

@@ -201,7 +201,7 @@ class patch_320alpha4b implements patchInterface
$feed->addPublisher($publisher); $feed->addPublisher($publisher);
$publisher->setFeed($feed); $publisher->setFeed($feed);
$publisher->setOwner(true); $publisher->setOwner(true);
$publisher->setUsrId($user->getId()); $publisher->setUser($user);
if ($homelink) { if ($homelink) {
$feed->setPublic(true); $feed->setPublic(true);

View File

@@ -111,8 +111,10 @@ class patch_370alpha7a implements patchInterface
$borderFile = new \Alchemy\Phrasea\Border\File($app, $media, $collection); $borderFile = new \Alchemy\Phrasea\Border\File($app, $media, $collection);
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$lazaretSession = new LazaretSession(); $lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($row['usr_id']); $lazaretSession->setUser($user);
$lazaretFile = new LazaretFile(); $lazaretFile = new LazaretFile();
$lazaretFile->setBaseId($row['base_id']); $lazaretFile->setBaseId($row['base_id']);

View File

@@ -80,9 +80,11 @@ class patch_380alpha11a implements patchInterface
$updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']); $updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']);
} }
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$session = new Session(); $session = new Session();
$session $session
->setUsrId($row['usr_id']) ->setUser($user)
->setUserAgent($row['user_agent']) ->setUserAgent($row['user_agent'])
->setUpdated($updated) ->setUpdated($updated)
->setToken($row['token']) ->setToken($row['token'])

View File

@@ -70,6 +70,8 @@ class patch_390alpha1a implements patchInterface
$em = $app['EM']; $em = $app['EM'];
foreach ($rs as $row) { foreach ($rs as $row) {
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$credential = new FtpCredential(); $credential = new FtpCredential();
$credential->setActive($row['activeFTP']); $credential->setActive($row['activeFTP']);
$credential->setAddress($row['addrFTP']); $credential->setAddress($row['addrFTP']);
@@ -79,7 +81,7 @@ class patch_390alpha1a implements patchInterface
$credential->setPassword($row['pwdFTP']); $credential->setPassword($row['pwdFTP']);
$credential->setReceptionFolder($row['destFTP']); $credential->setReceptionFolder($row['destFTP']);
$credential->setRepositoryPrefixName($row['prefixFTPfolder']); $credential->setRepositoryPrefixName($row['prefixFTPfolder']);
$credential->setUsrId($row['usr_id']); $credential->setUser($user);
$em->persist($credential); $em->persist($credential);

View File

@@ -92,8 +92,10 @@ class patch_390alpha1b implements patchInterface
$todo = $stmt->fetch(\PDO::FETCH_ASSOC); $todo = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$order = new Order(); $order = new Order();
$order->setUsrId($row['usr_id']) $order->setUser($user)
->setTodo($todo['todo']) ->setTodo($todo['todo'])
->setOrderUsage($row['usage']) ->setOrderUsage($row['usage'])
->setDeadline(new \DateTime($row['deadline'])) ->setDeadline(new \DateTime($row['deadline']))

View File

@@ -73,9 +73,11 @@ class patch_390alpha3a implements patchInterface
$em = $app['EM']; $em = $app['EM'];
foreach ($rs as $row) { foreach ($rs as $row) {
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$userQuery = new UserQuery(); $userQuery = new UserQuery();
$userQuery->setQuery($row['query']); $userQuery->setQuery($row['query']);
$userQuery->setUsrId($row['usr_id']); $userQuery->setUser($user);
$em->persist($userQuery); $em->persist($userQuery);

View File

@@ -77,10 +77,12 @@ class patch_390alpha4a implements patchInterface
continue; continue;
} }
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$userSetting = new UserSetting(); $userSetting = new UserSetting();
$userSetting->setName($row['prop']); $userSetting->setName($row['prop']);
$userSetting->setValue($row['value']); $userSetting->setValue($row['value']);
$userSetting->setUsrId($row['usr_id']); $userSetting->setUser($user);
$em->persist($userSetting); $em->persist($userSetting);

View File

@@ -74,10 +74,12 @@ class patch_390alpha5a implements patchInterface
$em = $app['EM']; $em = $app['EM'];
foreach ($rs as $row) { foreach ($rs as $row) {
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$userSetting = new UserNotificationSetting(); $userSetting = new UserNotificationSetting();
$userSetting->setName($row['prop']); $userSetting->setName($row['prop']);
$userSetting->setValue($row['value']); $userSetting->setValue($row['value']);
$userSetting->setUsrId($row['usr_id']); $userSetting->setUser($user);
$em->persist($userSetting); $em->persist($userSetting);

View File

@@ -133,12 +133,14 @@ class patch_390alpha7a implements patchInterface
$fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC); $fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($fpRes as $fpRow) { foreach ($fpRes as $fpRow) {
$user = $app['manipulator.user']->getRepository()->find($fpRow['usr_id']);
$feedPublisher = new FeedPublisher(); $feedPublisher = new FeedPublisher();
$feedPublisher->setFeed($feed); $feedPublisher->setFeed($feed);
$feed->addPublisher($feedPublisher); $feed->addPublisher($feedPublisher);
$feedPublisher->setCreatedOn(new \DateTime($fpRow['created_on'])); $feedPublisher->setCreatedOn(new \DateTime($fpRow['created_on']));
$feedPublisher->setIsOwner((Boolean) $fpRow['owner']); $feedPublisher->setIsOwner((Boolean) $fpRow['owner']);
$feedPublisher->setUsrId($fpRow['usr_id']); $feedPublisher->setUser($user);
$feStmt->execute([':feed_id' => $row['id'], ':publisher_id' => $fpRow['id']]); $feStmt->execute([':feed_id' => $row['id'], ':publisher_id' => $fpRow['id']]);
$feRes = $feStmt->fetchAll(\PDO::FETCH_ASSOC); $feRes = $feStmt->fetchAll(\PDO::FETCH_ASSOC);
@@ -177,10 +179,12 @@ class patch_390alpha7a implements patchInterface
$ftRes = $ftStmt->fetchAll(\PDO::FETCH_ASSOC); $ftRes = $ftStmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($ftRes as $ftRow) { foreach ($ftRes as $ftRow) {
$user = $app['manipulator.user']->getRepository()->find($ftRow['usr_id']);
$token = new FeedToken(); $token = new FeedToken();
$token->setFeed($feed); $token->setFeed($feed);
$feed->addToken($token); $feed->addToken($token);
$token->setUsrId($ftRow['usr_id']); $token->setUser($user);
$token->setValue($ftRow['token']); $token->setValue($ftRow['token']);
$em->persist($token); $em->persist($token);
@@ -204,8 +208,10 @@ class patch_390alpha7a implements patchInterface
$faRes = $faStmt->fetchAll(\PDO::FETCH_ASSOC); $faRes = $faStmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($faRes as $faRow) { foreach ($faRes as $faRow) {
$user = $app['manipulator.user']->getRepository()->find($faRow['usr_id']);
$token = new AggregateToken(); $token = new AggregateToken();
$token->setUsrId($faRow['usr_id']); $token->setUser($user);
$token->setValue($faRow['token']); $token->setValue($faRow['token']);
$em->persist($token); $em->persist($token);

View File

@@ -42,3 +42,9 @@ migrations:
migration13: migration13:
version: ftp-export version: ftp-export
class: Alchemy\Phrasea\Setup\DoctrineMigrations\FtpExportMigration class: Alchemy\Phrasea\Setup\DoctrineMigrations\FtpExportMigration
migration14:
version: user-field
class: Alchemy\Phrasea\Setup\DoctrineMigrations\UserFieldMigration
migration15:
version: usrid-field-delete
class: Alchemy\Phrasea\Setup\DoctrineMigrations\DeleteUsrIdFieldMigration

View File

@@ -1,5 +1,5 @@
{% for validationDatas in basket_element.getValidationDatas() %} {% for validationDatas in basket_element.getValidationDatas() %}
{% set is_mine = validationDatas.getParticipant().getUser(app).getId() == app['authentication'].getUser().getId() %} {% set is_mine = validationDatas.getParticipant().getUser().getId() == app['authentication'].getUser().getId() %}
{% if validationDatas.getNote() != '' or (validationDatas.getAgreement() is not null and is_mine) %} {% if validationDatas.getNote() != '' or (validationDatas.getAgreement() is not null and is_mine) %}
<li> <li>
<h3 style="text-align:left;"> <h3 style="text-align:left;">
@@ -7,7 +7,7 @@
<img style="vertical-align:middle;" <img style="vertical-align:middle;"
src="/skins/lightbox/{% if validationDatas.getAgreement() == true %}agree.png{% else %}disagree.png{% endif %}" /> src="/skins/lightbox/{% if validationDatas.getAgreement() == true %}agree.png{% else %}disagree.png{% endif %}" />
{% endif %} {% endif %}
{{ validationDatas.getParticipant().getUser(app).getDisplayName() }} {{ validationDatas.getParticipant().getUser().getDisplayName() }}
</h3> </h3>
{% if validationDatas.getNote() != '' %} {% if validationDatas.getNote() != '' %}
<p style="text-align:left;">{{ 'validation:: note' | trans }} : {{ validationDatas.getNote()|nl2br }}</p> <p style="text-align:left;">{{ 'validation:: note' | trans }} : {{ validationDatas.getNote()|nl2br }}</p>

View File

@@ -1,6 +1,6 @@
{% macro tooltip_connected_users(row) %} {% macro tooltip_connected_users(row) %}
{% set user = row.getUser(app) %} {% set user = row.getUser() %}
<span id="tooltip-usr"> <span id="tooltip-usr">
<table id="tabledescexp" cellpadding="0" cellspacing="0"> <table id="tabledescexp" cellpadding="0" cellspacing="0">
<tr> <tr>
@@ -102,9 +102,9 @@
<tr title="{{ _self.tooltip_connected_users(row) | e }}" class="{% if loop.index is odd %}odd{% else %}even{% endif %} usrTips" id="TREXP_{{ row.getId()}}"> <tr title="{{ _self.tooltip_connected_users(row) | e }}" class="{% if loop.index is odd %}odd{% else %}even{% endif %} usrTips" id="TREXP_{{ row.getId()}}">
{% if row.getId() == app['session'].get('session_id') %} {% if row.getId() == app['session'].get('session_id') %}
<td style="color:#ff0000"><i>{{ row.getUser(app).getDisplayName() }}</i></td> <td style="color:#ff0000"><i>{{ row.getUser().getDisplayName() }}</i></td>
{% else %} {% else %}
<td>{{ row.getUser(app).getDisplayName() }}</td> <td>{{ row.getUser().getDisplayName() }}</td>
{% endif %} {% endif %}
<td> <td>

View File

@@ -140,13 +140,13 @@
{% for publisher in feed.getPublishers() %} {% for publisher in feed.getPublishers() %}
<tr class="{% if loop.index is odd %}odd{% else %}even{% endif %}"> <tr class="{% if loop.index is odd %}odd{% else %}even{% endif %}">
<td valign="center" align="left"> <td valign="center" align="left">
{{ publisher.getUsrId() }} {{ publisher.getUser().getId() }}
</td> </td>
<td valign="center" align="left"> <td valign="center" align="left">
{{ publisher.getUser(app).getDisplayName() }} {{ publisher.getUser().getDisplayName() }}
</td> </td>
<td valign="center" align="left"> <td valign="center" align="left">
{{ publisher.getUser(app).getEmail() }} {{ publisher.getUser().getEmail() }}
</td> </td>
<td valign="center" align="center"> <td valign="center" align="center">
{% if publisher.isOwner() == true %} {% if publisher.isOwner() == true %}

View File

@@ -18,7 +18,7 @@
</div> </div>
<ul style="margin:10px 0 0 20px;width:200px;"> <ul style="margin:10px 0 0 20px;width:200px;">
{% for validation_data in basket_element.getValidationDatas() %} {% for validation_data in basket_element.getValidationDatas() %}
{% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or validation_data.getParticipant().getUser(app) == app['authentication'].getUser() %} {% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or validation_data.getParticipant().getUser() == app['authentication'].getUser() %}
{% if validation_data.getAgreement() == true %} {% if validation_data.getAgreement() == true %}
{% set classuser = 'agree' %} {% set classuser = 'agree' %}
{% elseif validation_data.getAgreement() is null %} {% elseif validation_data.getAgreement() is null %}
@@ -26,7 +26,7 @@
{% else %} {% else %}
{% set classuser = 'disagree' %} {% set classuser = 'disagree' %}
{% endif %} {% endif %}
{% set participant = validation_data.getParticipant().getUser(app) %} {% set participant = validation_data.getParticipant().getUser() %}
<li class="{% if participant.getId() == app['authentication'].getUser().getId() %}me{% endif %} {{classuser}} userchoice">{{participant.getDisplayName()}}</li> <li class="{% if participant.getId() == app['authentication'].getUser().getId() %}me{% endif %} {{classuser}} userchoice">{{participant.getDisplayName()}}</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@@ -16,7 +16,7 @@
<div>{{ basket.getValidation().getValidationString(app, app['authentication'].getUser()) }}</div> <div>{{ basket.getValidation().getValidationString(app, app['authentication'].getUser()) }}</div>
<ul> <ul>
{% for choice in basket_element.getValidationDatas() %} {% for choice in basket_element.getValidationDatas() %}
{% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or choice.getParticipant().getUser(app) == app['authentication'].getUser() %} {% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or choice.getParticipant().getUser() == app['authentication'].getUser() %}
{% if choice.getAgreement() == true %} {% if choice.getAgreement() == true %}
{% set classuser = 'agree' %} {% set classuser = 'agree' %}
{% elseif choice.getAgreement() is null %} {% elseif choice.getAgreement() is null %}
@@ -24,7 +24,7 @@
{% else %} {% else %}
{% set classuser = 'disagree' %} {% set classuser = 'disagree' %}
{% endif %} {% endif %}
{% set participant = choice.getParticipant().getUser(app) %} {% set participant = choice.getParticipant().getUser() %}
<li class="{% if participant.getId() == app['authentication'].getUser().getId() %}me{% endif %} {{classuser}} userchoice">{{participant.getDisplayName()}}</li> <li class="{% if participant.getId() == app['authentication'].getUser().getId() %}me{% endif %} {{classuser}} userchoice">{{participant.getDisplayName()}}</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@@ -33,7 +33,7 @@
{% set imguser = '<img src="/skins/lightbox/disagree.png" />' %} {% set imguser = '<img src="/skins/lightbox/disagree.png" />' %}
{% set styleuser = '' %} {% set styleuser = '' %}
{% endif %} {% endif %}
<b style="{{styleuser}}">{{imguser|raw}} {{validationDatas.getParticipant().getUser(app).getDisplayName()}}</b> <b style="{{styleuser}}">{{imguser|raw}} {{validationDatas.getParticipant().getUser().getDisplayName()}}</b>
{% if validationDatas.getNote() != '' %} {% if validationDatas.getNote() != '' %}
: {{validationDatas.getNote()|nl2br}} : {{validationDatas.getNote()|nl2br}}
{% endif %} {% endif %}

View File

@@ -8,9 +8,9 @@
<hr/> <hr/>
{% for validationDatas in basket_element.getValidationDatas() %} {% for validationDatas in basket_element.getValidationDatas() %}
{% if validationDatas.getNote() != '' %} {% if validationDatas.getNote() != '' %}
<div class="note_wrapper ui-corner-all {% if validationDatas.getParticipant().getUser(app).getId() == app['authentication'].getUser().getId() %}my_note{% endif %} "> <div class="note_wrapper ui-corner-all {% if validationDatas.getParticipant().getUser().getId() == app['authentication'].getUser().getId() %}my_note{% endif %} ">
<span class="note_author title15"> <span class="note_author title15">
{{validationDatas.getParticipant().getUser(app).getDisplayName()}} {{validationDatas.getParticipant().getUser().getDisplayName()}}
</span> : {{ validationDatas.getNote()|nl2br }} </span> : {{ validationDatas.getNote()|nl2br }}
</div> </div>
{% endif %} {% endif %}

View File

@@ -58,9 +58,9 @@
{% set list_participants = list_participants ~ ', ' %} {% set list_participants = list_participants ~ ', ' %}
{% endif %} {% endif %}
{% set list_participants = list_participants ~ '<a class="UserTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : Participant.getUser(app).getId() }) ~ '" href="/user/' {% set list_participants = list_participants ~ '<a class="UserTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : Participant.getUser().getId() }) ~ '" href="/user/'
~ Participant.getUser(app).getId() ~ '/">' ~ Participant.getUser().getId() ~ '/">'
~ Participant.getUser(app).getDisplayName ~ Participant.getUser().getDisplayName
~ '</a>' %} ~ '</a>' %}
{% endfor %} {% endfor %}
{% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %} {% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %}

View File

@@ -84,8 +84,8 @@
{% set list_participants = list_participants ~ ', ' %} {% set list_participants = list_participants ~ ', ' %}
{% endif %} {% endif %}
{% set list_participants = list_participants ~ '<a class="UserTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : Participant.getUser(app).getId() }) ~ '" href="/user/' ~ Participant.getUser(app).getId() ~ '/">' %} {% set list_participants = list_participants ~ '<a class="UserTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : Participant.getUser().getId() }) ~ '" href="/user/' ~ Participant.getUser().getId() ~ '/">' %}
{% set list_participants = list_participants ~ Participant.getUser(app).getDisplayName %} {% set list_participants = list_participants ~ Participant.getUser().getDisplayName %}
{% set list_participants = list_participants ~ '</a>' %} {% set list_participants = list_participants ~ '</a>' %}
{% endfor %} {% endfor %}
{% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %} {% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %}

View File

@@ -353,9 +353,9 @@
<td style="width:100%;"> <td style="width:100%;">
<table style=width:100%> <table style=width:100%>
{% for choice in basket_element.getValidationDatas() %} {% for choice in basket_element.getValidationDatas() %}
{% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or choice.getParticipant().getUser(app) == app['authentication'].getUser() %} {% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or choice.getParticipant().getUser() == app['authentication'].getUser() %}
<tr> <tr>
<td> {{ choice.getParticipant().getUser(app).getDisplayName() }} </td> <td> {{ choice.getParticipant().getUser().getDisplayName() }} </td>
<td> <td>
{% if choice.getParticipant().getCanAgree() %} {% if choice.getParticipant().getCanAgree() %}
{% if choice.getAgreement() == true %} {% if choice.getAgreement() == true %}

View File

@@ -29,11 +29,11 @@
<img src="/skins/icons/user.png"/> <img src="/skins/icons/user.png"/>
</td> </td>
<td style="width:150px;padding:5px;"> <td style="width:150px;padding:5px;">
{{ owner.getUser(app).getDisplayName() }} {{ owner.getUser().getDisplayName() }}
<input type="hidden" name="usr_id" value="{{ owner.getUser(app).getId() }}" /> <input type="hidden" name="usr_id" value="{{ owner.getUser().getId() }}" />
</td> </td>
<td style="padding-right:10px;min-width:100px;"> <td style="padding-right:10px;min-width:100px;">
{% if app['authentication'].getUser().ggetId()== owner.getUser(app).gegetId()} {% if app['authentication'].getUser().ggetId()== owner.getUser().gegetId()}
{% if owner.getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %} {% if owner.getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %}
{{ 'You are Admin' | trans }} {{ 'You are Admin' | trans }}
{% endif %} {% endif %}
@@ -53,7 +53,7 @@
{% endif %} {% endif %}
</td> </td>
<td style="width:15px"> <td style="width:15px">
{% if app['authentication'].getUser().getgetId() owner.getUser(app).getId() %} {% if app['authentication'].getUser().getgetId() owner.getUser().getId() %}
<a href="#" class="deleter"> <a href="#" class="deleter">
<img src="/skins/prod/Push/close_badge.png" title="{{ 'Remove' | trans }}"/> <img src="/skins/prod/Push/close_badge.png" title="{{ 'Remove' | trans }}"/>
</a> </a>

View File

@@ -176,7 +176,7 @@
{% macro badgeReadonly(entry, role) %} {% macro badgeReadonly(entry, role) %}
<div class="badge"> <div class="badge">
<input type="hidden" value="{{ entry.getUser(app).getId() }}" name="id"> <input type="hidden" value="{{ entry.getUser().getId() }}" name="id">
{% if role >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if role >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<a class="deleter" href="#"> <a class="deleter" href="#">
<img src="/skins/prod/Push/close_badge.png"> <img src="/skins/prod/Push/close_badge.png">
@@ -188,7 +188,7 @@
<img src="/skins/icons/user.png"/> <img src="/skins/icons/user.png"/>
</td> </td>
<td class="infos" > <td class="infos" >
<span class="name">{{ entry.getUser(app).getDisplayName() }}</span> <span class="name">{{ entry.getUser().getDisplayName() }}</span>
<span class="subtite"></span> <span class="subtite"></span>
</td> </td>
</tr> </tr>

View File

@@ -5,7 +5,7 @@
<table style="height: 40px;"> <table style="height: 40px;">
<tr> <tr>
<td style="white-space:nowrap;"> <td style="white-space:nowrap;">
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<form class="form-inline" method="POST" name="SaveName" action="{{ path('prod_lists_list_update', { 'list_id' : list.getId() }) }}"> <form class="form-inline" method="POST" name="SaveName" action="{{ path('prod_lists_list_update', { 'list_id' : list.getId() }) }}">
<label>{{ 'List Name' | trans }}</label> <label>{{ 'List Name' | trans }}</label>
<input type="text" name="name" style="margin: 0 5px;" value="{{ list.getName() }}"/> <input type="text" name="name" style="margin: 0 5px;" value="{{ list.getName() }}"/>
@@ -16,14 +16,14 @@
{% endif %} {% endif %}
</td> </td>
<td style="text-align:right;white-space:nowrap;"> <td style="text-align:right;white-space:nowrap;">
{% if list.getOwner(app['authentication'].getUser(), app).getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %} {% if list.getOwner(app['authentication'].getUser()).getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %}
<a href="{{ path('prod_lists_list_share', { 'list_id' : list.getId() }) }}" title="{{ 'Share the list' | trans }}" class="list_sharer"> <a href="{{ path('prod_lists_list_share', { 'list_id' : list.getId() }) }}" title="{{ 'Share the list' | trans }}" class="list_sharer">
<img src="/skins/prod/Push/list-icon.png" /> <img src="/skins/prod/Push/list-icon.png" />
{{ "Set sharing permission" | trans }} {{ "Set sharing permission" | trans }}
</a> </a>
{% endif %} {% endif %}
</td> </td>
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %}
<td style="text-align:right;white-space:nowrap;width:150px;"> <td style="text-align:right;white-space:nowrap;width:150px;">
<button class="deleter btn btn-inverse"> <button class="deleter btn btn-inverse">
{{ 'Delete' | trans }} {{ 'Delete' | trans }}
@@ -40,20 +40,20 @@
<p> <p>
{% set length = '<span class="counter current">' ~ list.getEntries().count() ~ '</span>' %} {% set length = '<span class="counter current">' ~ list.getEntries().count() ~ '</span>' %}
{% trans with {'%length%' : length} %}%length% peoples{% endtrans %} {% trans with {'%length%' : length} %}%length% peoples{% endtrans %}
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<button class="EditToggle btn btn-inverse">{{ 'Edit' | trans }}</button> <button class="EditToggle btn btn-inverse">{{ 'Edit' | trans }}</button>
{% endif %} {% endif %}
</p> </p>
</div> </div>
<div class="PNB" style="top:35px;overflow:auto;"> <div class="PNB" style="top:35px;overflow:auto;">
{% set role = list.getOwner(app['authentication'].getUser(), app).getRole() %} {% set role = list.getOwner(app['authentication'].getUser()).getRole() %}
{% for entry in list.getEntries() %} {% for entry in list.getEntries() %}
{{ ListsMacros.badgeReadonly(entry, role) }} {{ ListsMacros.badgeReadonly(entry, role) }}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</div> </div>
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<div class="PNB content readwrite grey-bg" style="display:none;top:40px;"> <div class="PNB content readwrite grey-bg" style="display:none;top:40px;">
<form name="list-editor-search" method="POST" action="{{ path('prod_push_list_edit', { 'list_id' : list.getId() }) }}"> <form name="list-editor-search" method="POST" action="{{ path('prod_push_list_edit', { 'list_id' : list.getId() }) }}">
<div class="PNB10" style="height:160px;"> <div class="PNB10" style="height:160px;">

View File

@@ -14,7 +14,7 @@
{% set length = '<span class="counter">' ~ list.getEntries().count() ~ '</span>' %} {% set length = '<span class="counter">' ~ list.getEntries().count() ~ '</span>' %}
<li class="list" style="padding:2px;"> <li class="list" style="padding:2px;">
<a href="{{ path('prod_push_list_edit', { 'list_id' : list.getId() }) }}" class="list_link"> <a href="{{ path('prod_push_list_edit', { 'list_id' : list.getId() }) }}" class="list_link">
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<img src="/skins/prod/Push/list-icon.png" /> <img src="/skins/prod/Push/list-icon.png" />
{% else %} {% else %}
<img src="/skins/icons/SHARE16.png" /> <img src="/skins/icons/SHARE16.png" />

View File

@@ -62,7 +62,7 @@
{% for list in lists %} {% for list in lists %}
<li class="list" style="padding:2px;"> <li class="list" style="padding:2px;">
<a class="list_loader" href="{{ path('prod_push_lists_list', { 'list_id' : list.getId() }) }}"> <a class="list_loader" href="{{ path('prod_push_lists_list', { 'list_id' : list.getId() }) }}">
{% if list.getOwner(app['authentication'].getUser(), app).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} {% if list.getOwner(app['authentication'].getUser()).getRole() >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %}
<img src="/skins/prod/Push/list-icon.png" /> <img src="/skins/prod/Push/list-icon.png" />
{% else %} {% else %}
<img src="/skins/icons/SHARE16.png" /> <img src="/skins/icons/SHARE16.png" />

View File

@@ -42,7 +42,7 @@
{% for order in orders %} {% for order in orders %}
{% set deadline = app['date-formatter'].getPrettyString(order.getDeadline()) %} {% set deadline = app['date-formatter'].getPrettyString(order.getDeadline()) %}
<tr id="order_{{ order.getId() }}" class="order_row" {{ current_date > order.getDeadline() ? "style=color:#777": "" }}> <tr id="order_{{ order.getId() }}" class="order_row" {{ current_date > order.getDeadline() ? "style=color:#777": "" }}>
<td>{{ order.getUser(app).getDisplayName() }}</td> <td>{{ order.getUser().getDisplayName() }}</td>
<td>{{ app['date-formatter'].getPrettyString(order.getCreatedOn()) }}</td> <td>{{ app['date-formatter'].getPrettyString(order.getCreatedOn()) }}</td>
<td> <td>
{% if deadline != '' %} {% if deadline != '' %}

View File

@@ -1,5 +1,5 @@
{% import 'common/thumbnail.html.twig' as thumbnail %} {% import 'common/thumbnail.html.twig' as thumbnail %}
{% set displayName = order.getUser(app).getDisplayName() %} {% set displayName = order.getUser().getDisplayName() %}
<div class="page-header"> <div class="page-header">
<h1>{% trans with {'%displayName%' : displayName} %}%displayName% wants to place an order{% endtrans %}</h1> <h1>{% trans with {'%displayName%' : displayName} %}%displayName% wants to place an order{% endtrans %}</h1>
@@ -29,7 +29,7 @@
<table class="table" style="color:#333;"> <table class="table" style="color:#333;">
<tr> <tr>
<td>{{ 'Destinataire' | trans }}</td> <td>{{ 'Destinataire' | trans }}</td>
<td>{{ displayName }}({{ order.getUser(app).getEmail() }})</td> <td>{{ displayName }}({{ order.getUser().getEmail() }})</td>
</tr> </tr>
<tr> <tr>
<td>{{ 'Date de commande' | trans }}</td> <td>{{ 'Date de commande' | trans }}</td>

View File

@@ -266,9 +266,9 @@
<div class="caption"> <div class="caption">
<p>{{ "Filename" | trans }} : <span class="info">{{ file.getOriginalName() }}</span></p> <p>{{ "Filename" | trans }} : <span class="info">{{ file.getOriginalName() }}</span></p>
<p>{{ "Date" | trans }} : <span class="info">{{ app['date-formatter'].getPrettyString(file.getCreated()) }}</span></p> <p>{{ "Date" | trans }} : <span class="info">{{ app['date-formatter'].getPrettyString(file.getCreated()) }}</span></p>
{% if file.getSession().getUser(app) is not none %} {% if file.getSession().getUser() is not none %}
<p> <p>
{% set username = '<a href="#" class="username userTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : file.getSession().getUser(app).getId() }) ~ '/">' ~ file.getSession().getUser(app).getDisplayName() ~ '</a>' %} {% set username = '<a href="#" class="username userTips" tooltipsrc="' ~ path('prod_tooltip_user', { 'usr_id' : file.getSession().getUser(app).getId() }) ~ '/">' ~ file.getSession().getUser().getDisplayName() ~ '</a>' %}
{% trans with {'%username%' : username} %}Uploaded by : %username%{% endtrans %} {% trans with {'%username%' : username} %}Uploaded by : %username%{% endtrans %}
</p> </p>
{% endif %} {% endif %}

View File

@@ -35,7 +35,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app['session'] = $session = $this->getSessionMock(); $app['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session(); $sessionEntity = new Session();
$sessionEntity->setUsrId($user->getId()); $sessionEntity->setUser($user);
$sessionEntity->setUserAgent(''); $sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity); $app['EM']->persist($sessionEntity);
$app['EM']->flush(); $app['EM']->flush();
@@ -133,11 +133,10 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app['session'] = $SFsession = $this->getSessionMock(); $app['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock(); $app['EM'] = $em = $this->getEntityManagerMock();
$usrId = $user->getId();
$sessionId = 4224242; $sessionId = 4224242;
$session = new Session(); $session = new Session();
$session->setUsrId($usrId); $session->setUser($user);
$ref = new \ReflectionObject($session); $ref = new \ReflectionObject($session);
$prop = $ref->getProperty('id'); $prop = $ref->getProperty('id');
@@ -175,11 +174,10 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app['session'] = $SFsession = $this->getSessionMock(); $app['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock(); $app['EM'] = $em = $this->getEntityManagerMock();
$usrId = $user->getId();
$sessionId = 4224242; $sessionId = 4224242;
$session = new Session(); $session = new Session();
$session->setUsrId($usrId); $session->setUser($user);
$ref = new \ReflectionObject($session); $ref = new \ReflectionObject($session);
$prop = $ref->getProperty('id'); $prop = $ref->getProperty('id');
@@ -246,7 +244,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app['session'] = $session = $this->getSessionMock(); $app['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session(); $sessionEntity = new Session();
$sessionEntity->setUsrId($user->getId()); $sessionEntity->setUser($user);
$sessionEntity->setUserAgent(''); $sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity); $app['EM']->persist($sessionEntity);
$app['EM']->flush(); $app['EM']->flush();

View File

@@ -635,7 +635,7 @@ class LazaretTest extends \PhraseanetAuthenticatedWebTestCase
{ {
//The lazaret session //The lazaret session
$lazaretSession = new \Alchemy\Phrasea\Model\Entities\LazaretSession(); $lazaretSession = new \Alchemy\Phrasea\Model\Entities\LazaretSession();
$lazaretSession->setUsrId(self::$DI['user']->getId()); $lazaretSession->setUser(self::$DI['user']);
$lazaretSession->setUpdated(new \DateTime('now')); $lazaretSession->setUpdated(new \DateTime('now'));
$lazaretSession->setCreated(new \DateTime('-1 day')); $lazaretSession->setCreated(new \DateTime('-1 day'));

View File

@@ -238,7 +238,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
$order = new Order(); $order = new Order();
$order->setOrderUsage($usage); $order->setOrderUsage($usage);
$order->setUsrId(self::$DI['user_alt2']->getId()); $order->setUser(self::$DI['user_alt2']);
$order->setDeadline(new \DateTime('+10 minutes')); $order->setDeadline(new \DateTime('+10 minutes'));
$orderElement = new OrderElement(); $orderElement = new OrderElement();

View File

@@ -92,8 +92,8 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
$session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session'); $session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session');
$session->expects($this->once()) $session->expects($this->once())
->method('getUsrId') ->method('getUser')
->will($this->returnValue(self::$DI['app']['authentication']->getUser()->getId())); ->will($this->returnValue(self::$DI['app']['authentication']->getUser()));
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager') $em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@@ -44,22 +44,6 @@ class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription()); $this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription());
} }
public function testGetUsrId()
{
$this->basket->setUsrId(1);
$this->em->persist($this->basket);
$this->em->flush();
$this->assertEquals(1, $this->basket->getUsrId());
}
public function testGetPusherId()
{
$this->basket->setPusherId(1);
$this->em->persist($this->basket);
$this->em->flush();
$this->assertEquals(1, $this->basket->getPusherId());
}
public function testGetArchived() public function testGetArchived()
{ {
$this->basket->setArchived(true); $this->basket->setArchived(true);
@@ -117,10 +101,10 @@ class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGetOwner() public function testGetOwner()
{ {
$this->assertNotNull($this->basket->getOwner(self::$DI['app'])); //no owner $this->assertNotNull($this->basket->getUser()); //no owner
$this->basket->setUsrId(self::$DI['user']->get_id()); $this->basket->setUser(self::$DI['user']);
$this->assertInstanceOf('\User_Adapter', $this->basket->getOwner(self::$DI['app'])); $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $this->basket->getUser());
$this->assertEquals($this->basket->getOwner(self::$DI['app'])->get_id(), self::$DI['user']->get_id()); $this->assertEquals($this->basket->getUser()->getId(), self::$DI['user']->getId());
} }
public function testGetValidation() public function testGetValidation()

View File

@@ -16,7 +16,6 @@ class UsrAuthProviderRepositoryTest extends \PhraseanetTestCase
$repo = self::$DI['app']['EM']->getRepository('Phraseanet:UsrAuthProvider'); $repo = self::$DI['app']['EM']->getRepository('Phraseanet:UsrAuthProvider');
$auth = new UsrAuthProvider(); $auth = new UsrAuthProvider();
$auth->setUsrId(42);
$auth->setProvider('provider-test'); $auth->setProvider('provider-test');
$auth->setDistantId(12345); $auth->setDistantId(12345);

View File

@@ -323,7 +323,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
protected function insertOneBasket(User $user = null) protected function insertOneBasket(User $user = null)
{ {
$basket = new Basket(); $basket = new Basket();
$basket->setOwner($user ?: self::$DI['user']); $basket->setUser($user ?: self::$DI['user']);
$basket->setName('test'); $basket->setName('test');
$basket->setDescription('description test'); $basket->setDescription('description test');
@@ -525,7 +525,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* *
* @return UsrListOwner * @return UsrListOwner
*/ */
protected function insertOneUsrListOwner(\User_Adapter $user = null) protected function insertOneUsrListOwner(User $user = null)
{ {
$user = $user ?: self::$DI['user']; $user = $user ?: self::$DI['user'];
@@ -691,8 +691,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basket = new Basket(); $basket = new Basket();
$basket->setName('test'); $basket->setName('test');
$basket->setDescription('description'); $basket->setDescription('description');
$basket->setOwner(self::$DI['user']); $basket->setUser(self::$DI['user']);
self::$DI['app']['EM']->persist($basket); self::$DI['app']['EM']->persist($basket);
foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) { foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) {
@@ -1157,7 +1156,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$app['session']->clear(); $app['session']->clear();
$app['session']->set('usr_id', self::$DI['user']->get_id()); $app['session']->set('usr_id', self::$DI['user']->get_id());
$session = new Session(); $session = new Session();
$session->setUsrId(self::$DI['user']->get_id()); $session->setUser(self::$DI['user']);
$session->setUserAgent(''); $session->setUserAgent('');
self::$DI['app']['EM']->persist($session); self::$DI['app']['EM']->persist($session);
self::$DI['app']['EM']->flush(); self::$DI['app']['EM']->flush();

View File

@@ -35,7 +35,7 @@ class userTest extends \PhraseanetTestCase
$provider = new Alchemy\Phrasea\Model\Entities\UsrAuthProvider(); $provider = new Alchemy\Phrasea\Model\Entities\UsrAuthProvider();
$provider->setDistantId(12345); $provider->setDistantId(12345);
$provider->setProvider('custom-one'); $provider->setProvider('custom-one');
$provider->setUsrId($user->getId()); $provider->setUser($user);
self::$DI['app']['EM']->persist($provider); self::$DI['app']['EM']->persist($provider);
self::$DI['app']['EM']->flush(); self::$DI['app']['EM']->flush();