diff --git a/DeleteUsrIdFieldMigration.php b/DeleteUsrIdFieldMigration.php new file mode 100644 index 0000000000..0d2ac9e822 --- /dev/null +++ b/DeleteUsrIdFieldMigration.php @@ -0,0 +1,78 @@ +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"); + } +} diff --git a/lib/Alchemy/Phrasea/ACL/BasketACL.php b/lib/Alchemy/Phrasea/ACL/BasketACL.php index 70af5cd298..cba34291b0 100644 --- a/lib/Alchemy/Phrasea/ACL/BasketACL.php +++ b/lib/Alchemy/Phrasea/ACL/BasketACL.php @@ -24,7 +24,7 @@ class BasketACL if ($basket->getValidation()) { foreach ($basket->getValidation()->getParticipants() as $participant) { - if ($participant->getUsrId() === $user->getId()) { + if ($participant->getUser()->getId() === $user->getId()) { return true; } } @@ -35,6 +35,6 @@ class BasketACL public function isOwner(Basket $basket, User $user) { - return $basket->getUsrId() === $user->getId(); + return $basket->getUser()->getId() === $user->getId(); } } diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php index 7ef715de6a..f5f269be04 100644 --- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php +++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php @@ -70,7 +70,7 @@ class Authenticator ->setBrowserVersion($this->browser->getVersion()) ->setPlatform($this->browser->getPlatform()) ->setUserAgent($this->browser->getUserAgent()) - ->setUsrId($user->getId()); + ->setUser($user); $this->em->persist($session); $this->em->flush(); @@ -105,7 +105,7 @@ class Authenticator 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'); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index 8a30a840d7..eb4907589f 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -52,7 +52,7 @@ class Publications implements ControllerProviderInterface $feed = new Feed(); $publisher->setFeed($feed); - $publisher->setUsrId($app['authentication']->getUser()->getId()); + $publisher->setUser($app['authentication']->getUser()); $publisher->setIsOwner(true); $feed->addPublisher($publisher); @@ -197,7 +197,7 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); $publisher = new FeedPublisher(); - $publisher->setUsrId($user->getId()); + $publisher->setUser($user); $publisher->setFeed($feed); $feed->addPublisher($publisher); @@ -226,7 +226,7 @@ class Publications implements ControllerProviderInterface $app->abort(404, "Feed Publisher not found"); } - $user = $publisher->getUser($app); + $user = $publisher->getUser(); if ($feed->isPublisher($user) && !$feed->isOwner($user)) { $feed->removePublisher($publisher); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index cac6279632..5f88a742d6 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -812,7 +812,7 @@ class Users implements ControllerProviderInterface $NewUser = $app['manipulator.user']->createUser($curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail']); $ftpCredential = new FtpCredential(); - $ftpCredential->setUsrId($NewUser->getId()); + $ftpCredential->setUser($NewUser); if (isset($curUser['activeFTP'])) { $ftpCredential->setActive((int) $curUser['activeFTP']); diff --git a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php index 151c3b8016..94460c33a4 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php @@ -111,7 +111,7 @@ class Baskets implements ControllerProviderInterface try { $basket = new Basket(); $basket->setName($request->request->get('p0')); - $basket->setOwner($app['authentication']->getUser()); + $basket->setuser($app['authentication']->getUser()); $app['EM']->persist($basket); $app['EM']->flush(); diff --git a/lib/Alchemy/Phrasea/Controller/Client/Root.php b/lib/Alchemy/Phrasea/Controller/Client/Root.php index b9399a805d..d3201daecc 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Root.php @@ -91,7 +91,7 @@ class Root implements ControllerProviderInterface $result = $app['phraseanet.SE']->query($query, ($currentPage - 1) * $perPage, $perPage, $options); $userQuery = new UserQuery(); - $userQuery->setUsrId($app['authentication']->getUser()->getId()); + $userQuery->setUser($app['authentication']->getUser()); $userQuery->setQuery($query); $app['EM']->persist($userQuery); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index 9fd56f5a0e..fa8165a603 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -118,7 +118,7 @@ class BasketController implements ControllerProviderInterface $Basket = new BasketEntity(); $Basket->setName($request->request->get('name', '')); - $Basket->setOwner($app['authentication']->getUser()); + $Basket->setUser($app['authentication']->getUser()); $Basket->setDescription($request->request->get('desc')); $app['EM']->persist($Basket); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php index 47b666c4f6..add39c8cae 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php @@ -94,7 +94,7 @@ class Order implements ControllerProviderInterface if (!$records->isEmpty()) { $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->setOrderUsage($request->request->get('use', '')); foreach ($records as $key => $record) { @@ -144,7 +144,7 @@ class Order implements ControllerProviderInterface try { $app['events-manager']->trigger('__NEW_ORDER__', [ 'order_id' => $order->getId(), - 'usr_id' => $order->getUsrId() + 'usr_id' => $order->getUser()->getId() ]); $success = true; @@ -237,19 +237,15 @@ class Order implements ControllerProviderInterface public function sendOrder(Application $app, Request $request, $order_id) { $success = false; - $order = $app['EM']->getRepository('Phraseanet:Order')->find($order_id); - if (null === $order) { + if (null === $order = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->find($order_id)) { throw new NotFoundHttpException('Order not found'); } - - $dest_user = $app['manipulator.user']->getRepository()->find($order->getUsrId()); - $basket = $order->getBasket(); if (null === $basket) { $basket = new Basket(); $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()); $app['EM']->persist($basket); @@ -274,7 +270,7 @@ class Order implements ControllerProviderInterface $basket->addElement($basketElement); $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__', [ 'ssel_id' => $order->getBasket()->getId(), 'from' => $app['authentication']->getUser()->getId(), - 'to' => $dest_user->getId(), + 'to' => $order->getUser()->getId(), 'n' => $n ]); } @@ -347,7 +343,7 @@ class Order implements ControllerProviderInterface $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [ 'from' => $app['authentication']->getUser()->getId(), - 'to' => $order->getUsrId(), + 'to' => $order->getUser()->getId(), 'n' => $n ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index 7eeb047b78..edaab27a84 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -57,7 +57,7 @@ class Push implements ControllerProviderInterface /* @var $entry UsrListEntry */ $entries[] = [ 'Id' => $entry->getId(), - 'User' => $userFormatter($entry->getUser($app)) + 'User' => $userFormatter($entry->getUser()) ]; } @@ -185,7 +185,7 @@ class Push implements ControllerProviderInterface $Basket = new Basket(); $Basket->setName($push_name); $Basket->setDescription($push_description); - $Basket->setOwner($user_receiver); + $Basket->setUser($user_receiver); $Basket->setPusher($app['authentication']->getUser()); $Basket->setIsRead(false); @@ -299,7 +299,7 @@ class Push implements ControllerProviderInterface $Basket = new Basket(); $Basket->setName($validation_name); $Basket->setDescription($validation_description); - $Basket->setOwner($app['authentication']->getUser()); + $Basket->setUser($app['authentication']->getUser()); $Basket->setIsRead(false); $app['EM']->persist($Basket); @@ -495,7 +495,7 @@ class Push implements ControllerProviderInterface $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) { $datas = $listFormatter($list); @@ -617,7 +617,7 @@ class Push implements ControllerProviderInterface $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); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 5a083c4a83..bffb604049 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -73,7 +73,7 @@ class Query implements ControllerProviderInterface $result = $app['phraseanet.SE']->query($query, (($page - 1) * $perPage), $perPage, $options); $userQuery = new UserQuery(); - $userQuery->setUsrId($app['authentication']->getUser()->getId()); + $userQuery->setUser($app['authentication']->getUser()); $userQuery->setQuery($result->getQuery()); $app['EM']->persist($userQuery); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 7e8c15e2ff..5ad126e045 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -158,7 +158,7 @@ class Upload implements ControllerProviderInterface $collection = \collection::get_from_base_id($app, $base_id); $lazaretSession = new LazaretSession(); - $lazaretSession->setUsrId($app['authentication']->getUser()->getId()); + $lazaretSession->setUser($app['authentication']->getUser()); $app['EM']->persist($lazaretSession); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 0b679e9ee2..f5973e9fb0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -195,7 +195,7 @@ class UsrLists implements ControllerProviderInterface { $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(); $owners = new ArrayCollection(); @@ -253,7 +253,7 @@ class UsrLists implements ControllerProviderInterface $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) { throw new ControllerException($app->trans('You are not authorized to do this')); @@ -284,9 +284,9 @@ class UsrLists implements ControllerProviderInterface try { $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')); } @@ -318,10 +318,10 @@ class UsrLists implements ControllerProviderInterface try { $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 */ - 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')); } @@ -360,10 +360,10 @@ class UsrLists implements ControllerProviderInterface $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 */ - 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')); } @@ -424,10 +424,10 @@ class UsrLists implements ControllerProviderInterface try { $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 */ - if ($list->getOwner($app['authentication']->getUser(), $app)->getRole() < UsrListOwner::ROLE_ADMIN) { + if ($list->getOwner($app['authentication']->getUser())->getRole() < UsrListOwner::ROLE_ADMIN) { $list = null; throw new \Exception($app->trans('You are not authorized to do this')); } @@ -454,21 +454,21 @@ class UsrLists implements ControllerProviderInterface try { $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 */ - 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')); } $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()) { throw new ControllerException('You can not downgrade your Admin right'); } - $owner = $list->getOwner($new_owner, $app); + $owner = $list->getOwner($new_owner); } else { $owner = new UsrListOwner(); $owner->setList($list); @@ -510,10 +510,10 @@ class UsrLists implements ControllerProviderInterface try { $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 */ - 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')); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 831e1da45b..12d74201d4 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -309,7 +309,7 @@ class Login implements ControllerProviderInterface ->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); if (null !== $userAuthProvider) { - $this->postAuthProcess($app, $userAuthProvider->getUser($app)); + $this->postAuthProcess($app, $userAuthProvider->getUser()); if (null !== $redirect = $request->query->get('redirect')) { $redirection = '../' . $redirect; @@ -466,7 +466,7 @@ class Login implements ControllerProviderInterface $usrAuthProvider = new UsrAuthProvider(); $usrAuthProvider->setDistantId($provider->getToken()->getId()); $usrAuthProvider->setProvider($provider->getId()); - $usrAuthProvider->setUsrId($user->getId()); + $usrAuthProvider->setUser($user); try { $provider->logout(); @@ -856,7 +856,7 @@ class Login implements ControllerProviderInterface /* @var $participant ValidationParticipant */ $validationSession = $participant->getSession(); - $participantId = $participant->getUsrId(); + $participantId = $participant->getUser()->getId(); $basketId = $validationSession->getBasket()->getId(); try { @@ -927,7 +927,7 @@ class Login implements ControllerProviderInterface ->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); if (null !== $userAuthProvider) { - $this->postAuthProcess($app, $userAuthProvider->getUser($app)); + $this->postAuthProcess($app, $userAuthProvider->getUser()); if (null !== $redirect = $request->query->get('redirect')) { $redirection = '../' . $redirect; @@ -1058,7 +1058,7 @@ class Login implements ControllerProviderInterface $baskets = $repo->findBy(['usr_id' => $inviteUsrId]); foreach ($baskets as $basket) { - $basket->setUsrId($user->getId()); + $basket->setUser($user); $app['EM']->persist($basket); } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index 4cd9fb3ef4..f4dab81e61 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -64,7 +64,7 @@ class RSSFeeds implements ControllerProviderInterface $controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) { $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)); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php index 08e4eaef45..1778dc978e 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Session.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php @@ -138,7 +138,7 @@ class Session implements ControllerProviderInterface $app->abort(404, 'Unknown session'); } - if ($session->getUsrId() !== $app['authentication']->getUser()->getId()) { + if ($session->getUser()->getId() !== $app['authentication']->getUser()->getId()) { $app->abort(403, 'Unauthorized'); } diff --git a/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php b/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php index 29efaf1afa..2c3b6786d6 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php +++ b/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php @@ -27,9 +27,12 @@ class AggregateToken private $id; /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @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 */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usrId = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usrId; + return $this->user; } /** @@ -91,4 +91,5 @@ class AggregateToken { return $this->value; } + } diff --git a/lib/Alchemy/Phrasea/Model/Entities/Basket.php b/lib/Alchemy/Phrasea/Model/Entities/Basket.php index abb8c84b89..41f51891f4 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Basket.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Basket.php @@ -43,9 +43,12 @@ class Basket private $description; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @ORM\Column(type="boolean") @@ -155,38 +158,23 @@ class Basket } /** - * Set usr_id + * @param User $user * - * @param integer $usrId * @return Basket */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usr_id = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - 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); - } + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php index f6df5f4fb8..c9b5b20999 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php +++ b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php @@ -283,7 +283,7 @@ class BasketElement public function getUserValidationDatas(\User_Adapter $user, Application $app) { 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; } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/Feed.php b/lib/Alchemy/Phrasea/Model/Entities/Feed.php index e61b47e139..396b0bfdfc 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Feed.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Feed.php @@ -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 * * @return boolean */ - public function isOwner(\User_Adapter $user) + public function isOwner(User $user) { $owner = $this->getOwner(); - if ($owner !== null && $user->getId() === $owner->getUsrId()) { + if ($owner !== null && $user->getId() === $owner->getUser()->getId()) { 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 * * @return boolean */ - public function isPublisher(\User_Adapter $user) + public function isPublisher(User $user) { foreach ($this->getPublishers() as $publisher) { - if ($publisher->getUsrId() == $user->getId()) { + if ($publisher->getUser()->getId() == $user->getId()) { 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 * * @return FeedPublisher */ - public function getPublisher(\User_Adapter $user) + public function getPublisher(User $user) { foreach ($this->getPublishers() as $publisher) { - if ($publisher->getUsrId() == $user->getId()) { + if ($publisher->gteUser()->getId() == $user->getId()) { 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 Application $app * * @return boolean */ - public function hasAccess(\User_Adapter $user, Application $app) + public function hasAccess(User $user, Application $app) { if ($this->getCollection($app) instanceof collection) { 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 * - * @param \User_Adapter $user + * @param User $user * @param \Alchemy\Phrasea\Application $app * * @return boolean */ - public function isAccessible(\User_Adapter $user, Application $app) + public function isAccessible(User $user, Application $app) { $coll = $this->getCollection($app); if ($this->isPublic() diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php b/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php index 4892456dfa..0ab608482b 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php @@ -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 * * @return boolean */ - public function isPublisher(\User_Adapter $user) + public function isPublisher(User $user) { if ($this->publisher) { - if ($this->publisher->getUsrId() === $user->getId()) { + if ($this->publisher->getUser()->getId() === $user->getId()) { return true; } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php b/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php index 540e19ac47..03efd4da17 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php @@ -29,9 +29,12 @@ class FeedPublisher private $id; /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @ORM\Column(type="boolean") @@ -61,26 +64,23 @@ class FeedPublisher } /** - * Set usr_id + * @param User $user * - * @param integer $usrId * @return FeedPublisher */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usrId = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usrId; + return $this->user; } /** @@ -129,18 +129,6 @@ class FeedPublisher 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 * diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php b/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php index f173c9c7db..1c7dc16cec 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php @@ -27,9 +27,12 @@ class FeedToken private $id; /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @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 */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usrId = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usrId; + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php b/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php index 023fefa03c..2cf0496187 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php @@ -27,11 +27,6 @@ class FtpCredential */ private $id; - /** - * @ORM\Column(type="integer") - */ - private $usrId; - /** * @ORM\OneToOne(targetEntity="User", inversedBy="ftpCredential") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") @@ -97,22 +92,6 @@ class FtpCredential return $this->id; } - /** - * @return integer - */ - public function getUsrId() - { - return $this->usrId; - } - - /** - * @param integer $usrId - */ - public function setUsrId($usrId) - { - $this->usrId = $usrId; - } - /** * @return User */ diff --git a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php index 50489594e5..0a5da5726a 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php @@ -90,9 +90,12 @@ class FtpExport private $textMailReceiver; /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @ORM\Column(type="text", nullable=true) @@ -141,6 +144,26 @@ class FtpExport 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 * @@ -441,54 +464,6 @@ class FtpExport 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 * diff --git a/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php b/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php index 7348129258..efd91ef6e5 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php @@ -28,10 +28,13 @@ class LazaretSession */ private $id; - /** - * @ORM\Column(type="integer", nullable=true) - */ - private $usr_id; + /** + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @Gedmo\Timestampable(on="create") @@ -70,44 +73,23 @@ class LazaretSession } /** - * Set usr_id + * @param User $user * - * @param integer $usrId * @return LazaretSession */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usr_id = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - /** - * 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; + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/Order.php b/lib/Alchemy/Phrasea/Model/Entities/Order.php index 6ea8ee76db..e1ffec6759 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Order.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Order.php @@ -29,9 +29,12 @@ class Order private $id; /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @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 */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usrId = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usrId; + return $this->user; } /** @@ -184,20 +184,6 @@ class Order 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 * diff --git a/lib/Alchemy/Phrasea/Model/Entities/Session.php b/lib/Alchemy/Phrasea/Model/Entities/Session.php index 115c3558f4..80df8b2f09 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Session.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Session.php @@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM; 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") */ class Session @@ -29,9 +29,12 @@ class Session private $id; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @ORM\Column(type="string", length=512) @@ -114,39 +117,24 @@ class Session 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 */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usr_id = $usrId; + $this->user = $user; return $this; } - public function getUser(Application $app) - { - if ($this->getUsrId()) { - return \User_Adapter::getInstance($this->getUsrId(), $app); - } - } - /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php index cedee99432..7ae23162c8 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php +++ b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php @@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping as ORM; 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") */ class StoryWZ @@ -40,9 +40,12 @@ class StoryWZ private $record_id; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @Gedmo\Timestampable(on="create") @@ -116,40 +119,24 @@ class StoryWZ $this->setRecordId($record->get_record_id()); $this->setSbasId($record->get_sbas_id()); } - /** - * Set usr_id + * @param User $user * - * @param integer $usrId * @return StoryWZ */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usr_id = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - 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); - } + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php b/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php index a747270e8c..0777315684 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php @@ -31,11 +31,6 @@ class UserNotificationSetting */ private $id; - /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; - /** * @ORM\ManyToOne(targetEntity="User", inversedBy="notificationSettings") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") @@ -92,26 +87,6 @@ class UserNotificationSetting 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 */ diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php b/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php index fdbfe01ef3..549589828b 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php @@ -27,11 +27,6 @@ class UserQuery */ private $id; - /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; - /** * @ORM\ManyToOne(targetEntity="User", inversedBy="queries") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") @@ -57,22 +52,6 @@ class UserQuery return $this->id; } - /** - * @return integer - */ - public function getUsrId() - { - return $this->usrId; - } - - /** - * @param integer $usrId - */ - public function setUsrId($usrId) - { - $this->usrId = $usrId; - } - /** * @return User */ diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php b/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php index acfd44ddfc..07784b279e 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php @@ -31,11 +31,6 @@ class UserSetting */ private $id; - /** - * @ORM\Column(type="integer", name="usr_id") - */ - private $usrId; - /** * @ORM\ManyToOne(targetEntity="User", inversedBy="settings") * @ORM\JoinColumn(name="user_id", referencedColumnName="id") @@ -92,26 +87,6 @@ class UserSetting 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 */ diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php b/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php index aa07140dca..68b3a8d6cf 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php @@ -17,7 +17,7 @@ use Gedmo\Mapping\Annotation as Gedmo; /** * @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\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\UsrAuthProviderRepository") @@ -32,9 +32,12 @@ class UsrAuthProvider private $id; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @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; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - public function getUser(Application $app) - { - return \User_Adapter::getInstance($this->usr_id, $app); + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php index 6dfb2451d1..62747797a4 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php @@ -209,10 +209,10 @@ class UsrList return $this->entries; } - public function hasAccess(\User_Adapter $user, Application $app) + public function hasAccess(User $user) { foreach ($this->getOwners() as $owner) { - if ($owner->getUser($app)->getId() == $user->getId()) { + if ($owner->getUser()->getId() == $user->getId()) { return true; } } @@ -222,13 +222,13 @@ class UsrList /** * - * @param \User_Adapter $user + * @param User $user * @return UsrListOwner */ - public function getOwner(\User_Adapter $user, Application $app) + public function getOwner(User $user) { foreach ($this->getOwners() as $owner) { - if ($owner->getUser($app)->getId() == $user->getId()) { + if ($owner->getUser()->getId() == $user->getId()) { return $owner; } } @@ -246,7 +246,7 @@ class UsrList { return $this->entries->exists( function ($key, $entry) use ($user, $app) { - return $entry->getUser($app)->getId() === $user->getId(); + return $entry->getUser()->getId() === $user->getId(); } ); } diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php index e2973782f6..5fefc3edf6 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php @@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM; 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") */ class UsrListEntry @@ -29,9 +29,12 @@ class UsrListEntry private $id; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @Gedmo\Timestampable(on="create") @@ -62,36 +65,23 @@ class UsrListEntry } /** - * Set usr_id + * @param User $user * - * @param integer $usrId * @return UsrListEntry */ - public function setUsrId($usrId) + public function setUser(User $user) { - $this->usr_id = $usrId; + $this->user = $user; return $this; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - public function getUser(Application $app) - { - return \User_Adapter::getInstance($this->getUsrId(), $app); - } - - public function setUser(\User_Adapter $user) - { - return $this->setUsrId($user->getId()); + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php index 1f446280a1..d078d771bf 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php @@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping as ORM; 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") */ class UsrListOwner @@ -33,9 +33,12 @@ class UsrListOwner private $id; /** - * @ORM\Column(type="integer") - */ - private $usr_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * + * @return User + **/ + private $user; /** * @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; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - public function setUser(\User_Adapter $user) - { - return $this->setUsrId($user->getId()); - } - - public function getUser(Application $app) - { - return \User_Adapter::getInstance($this->getUsrId(), $app); + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php index f183428432..3819799921 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php @@ -27,11 +27,6 @@ class ValidationParticipant */ private $id; - /** - * @ORM\Column(type="integer") - */ - private $usr_id; - /** * @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 ValidationParticipant + * @return User + **/ + 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; } /** - * Get usr_id - * - * @return integer + * @return User */ - public function getUsrId() + public function getUser() { - return $this->usr_id; - } - - /** - * - * @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); + return $this->user; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php index 677663647a..70cfc020c8 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php @@ -284,7 +284,7 @@ class ValidationSession public function getParticipant(\User_Adapter $user, Application $app) { foreach ($this->getParticipants() as $participant) { - if ($participant->getUser($app)->getId() == $user->getId()) { + if ($participant->getUser()->getId() == $user->getId()) { return $participant; } } diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php index 10c5a3f9b6..4f523f0808 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php @@ -187,7 +187,7 @@ class UserManipulator implements ManipulatorInterface public function addUserSetting(User $user, $name, $value) { $userSetting = new UserSetting(); - $userSetting->setUsrId($user->getId()); + $userSetting->setUser($user); $userSetting->setName($name); $userSetting->setValue($value); $user->addSetting($userSetting); @@ -207,7 +207,7 @@ class UserManipulator implements ManipulatorInterface $notifSetting = new UserNotificationSetting(); $notifSetting->setName($name); $notifSetting->setValue($value); - $notifSetting->setUsrId($user->getId()); + $notifSetting->setUsrId($user); $user->addNotificationSettings($notifSetting); $this->manager->update($user); @@ -224,7 +224,7 @@ class UserManipulator implements ManipulatorInterface $userQuery = new UserQuery(); $userQuery->setUser($user); $userQuery->setQuery($query); - $userQuery->setUsrId($user->getId()); + $userQuery->setUser($user); $user->addQuery($userQuery); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php index 94272957bb..63ac6f46bd 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php @@ -141,7 +141,7 @@ class BasketRepository extends EntityRepository throw new NotFoundHttpException(_('Basket is not found')); } - if ($basket->getOwner($app)->getId() != $user->getId()) { + if ($basket->getUser()->getId() != $user->getId()) { $participant = false; if ($basket->getValidation() && !$requireOwner) { diff --git a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php index 84bb3ba055..3fc0548140 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php @@ -84,7 +84,7 @@ class StoryWZRepository extends EntityRepository 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'); } } else { diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php index 6128ed64cc..afea5aad57 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php @@ -55,7 +55,7 @@ class UsrListRepository extends EntityRepository * @param type $list_id * @return UsrList */ - public function findUserListByUserAndId(Application $app, User $user, $list_id) + public function findUserListByUserAndId(User $user, $list_id) { $list = $this->find($list_id); @@ -64,7 +64,7 @@ class UsrListRepository extends EntityRepository 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.'); } diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php new file mode 100644 index 0000000000..0d2ac9e822 --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php @@ -0,0 +1,78 @@ +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"); + } +} diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php new file mode 100644 index 0000000000..389b6f5e9e --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php @@ -0,0 +1,103 @@ +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"); + } +} diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index 231f4e873c..4e2da476b3 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -659,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract } $session = new Alchemy\Phrasea\Model\Entities\LazaretSession(); - $session->setUsrId($app['authentication']->getUser()->getId()); + $session->setUser($app['authentication']->getUser()); $app['EM']->persist($session); $app['EM']->flush(); @@ -784,8 +784,8 @@ class API_V1_adapter extends API_V1_Abstract } $usr_id = null; - if ($file->getSession()->getUser($this->app)) { - $usr_id = $file->getSession()->getUser($this->app)->getId(); + if ($file->getSession()->getUser()) { + $usr_id = $file->getSession()->getUser()->getId(); } $session = [ @@ -877,7 +877,7 @@ class API_V1_adapter extends API_V1_Abstract $search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage, $options); $userQuery = new UserQuery(); - $userQuery->setUsrId($this->app['authentication']->getUser()->getId()); + $userQuery->setUser($this->app['authentication']->getUser()); $userQuery->setQuery($query); $this->app['EM']->persist($userQuery); @@ -1272,7 +1272,7 @@ class API_V1_adapter extends API_V1_Abstract } $Basket = new Basket(); - $Basket->setOwner($this->app['authentication']->getUser()); + $Basket->setUser($this->app['authentication']->getUser()); $Basket->setName($name); $this->app['EM']->persist($Basket); @@ -1369,7 +1369,7 @@ class API_V1_adapter extends API_V1_Abstract foreach ($basket_element->getValidationDatas() as $validation_datas) { $participant = $validation_datas->getParticipant(); - $user = $participant->getUser($this->app); + $user = $participant->getUser(); /* @var $validation_datas ValidationData */ $choices[] = [ 'validation_user' => [ @@ -1814,7 +1814,7 @@ class API_V1_adapter extends API_V1_Abstract foreach ($basket->getValidation()->getParticipants() as $participant) { /* @var $participant ValidationParticipant */ - $user = $participant->getUser($this->app); + $user = $participant->getUser(); $users[] = [ 'usr_id' => $user->getId(), diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php index e7a788a2c1..1a66e53e5d 100644 --- a/lib/classes/eventsmanager/notify/uploadquarantine.php +++ b/lib/classes/eventsmanager/notify/uploadquarantine.php @@ -72,7 +72,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract $datas = $domXML->saveXml(); //Sender - if (null !== $user = $lazaretFile->getSession()->getUser($this->app)) { + if (null !== $user = $lazaretFile->getSession()->getUser()) { $sender = $domXML->createElement('sender'); $sender->appendChild($domXML->createTextNode($user->getDisplayName())); $root->appendChild($sender); diff --git a/lib/classes/patch/320alpha4b.php b/lib/classes/patch/320alpha4b.php index 96cc718f4a..3794d9b28b 100644 --- a/lib/classes/patch/320alpha4b.php +++ b/lib/classes/patch/320alpha4b.php @@ -201,7 +201,7 @@ class patch_320alpha4b implements patchInterface $feed->addPublisher($publisher); $publisher->setFeed($feed); $publisher->setOwner(true); - $publisher->setUsrId($user->getId()); + $publisher->setUser($user); if ($homelink) { $feed->setPublic(true); diff --git a/lib/classes/patch/370alpha7a.php b/lib/classes/patch/370alpha7a.php index 7536131603..23902ef532 100644 --- a/lib/classes/patch/370alpha7a.php +++ b/lib/classes/patch/370alpha7a.php @@ -111,8 +111,10 @@ class patch_370alpha7a implements patchInterface $borderFile = new \Alchemy\Phrasea\Border\File($app, $media, $collection); + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $lazaretSession = new LazaretSession(); - $lazaretSession->setUsrId($row['usr_id']); + $lazaretSession->setUser($user); $lazaretFile = new LazaretFile(); $lazaretFile->setBaseId($row['base_id']); diff --git a/lib/classes/patch/380alpha11a.php b/lib/classes/patch/380alpha11a.php index af4ae93417..01ea1b2fee 100644 --- a/lib/classes/patch/380alpha11a.php +++ b/lib/classes/patch/380alpha11a.php @@ -80,9 +80,11 @@ class patch_380alpha11a implements patchInterface $updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']); } + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $session = new Session(); $session - ->setUsrId($row['usr_id']) + ->setUser($user) ->setUserAgent($row['user_agent']) ->setUpdated($updated) ->setToken($row['token']) diff --git a/lib/classes/patch/390alpha1a.php b/lib/classes/patch/390alpha1a.php index d18a67da4a..2e762ae8ee 100644 --- a/lib/classes/patch/390alpha1a.php +++ b/lib/classes/patch/390alpha1a.php @@ -70,6 +70,8 @@ class patch_390alpha1a implements patchInterface $em = $app['EM']; foreach ($rs as $row) { + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $credential = new FtpCredential(); $credential->setActive($row['activeFTP']); $credential->setAddress($row['addrFTP']); @@ -79,7 +81,7 @@ class patch_390alpha1a implements patchInterface $credential->setPassword($row['pwdFTP']); $credential->setReceptionFolder($row['destFTP']); $credential->setRepositoryPrefixName($row['prefixFTPfolder']); - $credential->setUsrId($row['usr_id']); + $credential->setUser($user); $em->persist($credential); diff --git a/lib/classes/patch/390alpha1b.php b/lib/classes/patch/390alpha1b.php index 8cfeac42ee..2469772534 100644 --- a/lib/classes/patch/390alpha1b.php +++ b/lib/classes/patch/390alpha1b.php @@ -92,8 +92,10 @@ class patch_390alpha1b implements patchInterface $todo = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $order = new Order(); - $order->setUsrId($row['usr_id']) + $order->setUser($user) ->setTodo($todo['todo']) ->setOrderUsage($row['usage']) ->setDeadline(new \DateTime($row['deadline'])) diff --git a/lib/classes/patch/390alpha3a.php b/lib/classes/patch/390alpha3a.php index 8d6ac8d39f..b6132acd40 100644 --- a/lib/classes/patch/390alpha3a.php +++ b/lib/classes/patch/390alpha3a.php @@ -73,9 +73,11 @@ class patch_390alpha3a implements patchInterface $em = $app['EM']; foreach ($rs as $row) { + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $userQuery = new UserQuery(); $userQuery->setQuery($row['query']); - $userQuery->setUsrId($row['usr_id']); + $userQuery->setUser($user); $em->persist($userQuery); diff --git a/lib/classes/patch/390alpha4a.php b/lib/classes/patch/390alpha4a.php index dd359d5928..9befea01c4 100644 --- a/lib/classes/patch/390alpha4a.php +++ b/lib/classes/patch/390alpha4a.php @@ -77,10 +77,12 @@ class patch_390alpha4a implements patchInterface continue; } + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $userSetting = new UserSetting(); $userSetting->setName($row['prop']); $userSetting->setValue($row['value']); - $userSetting->setUsrId($row['usr_id']); + $userSetting->setUser($user); $em->persist($userSetting); diff --git a/lib/classes/patch/390alpha5a.php b/lib/classes/patch/390alpha5a.php index b94bd15406..8be8997182 100644 --- a/lib/classes/patch/390alpha5a.php +++ b/lib/classes/patch/390alpha5a.php @@ -74,10 +74,12 @@ class patch_390alpha5a implements patchInterface $em = $app['EM']; foreach ($rs as $row) { + $user = $app['manipulator.user']->getRepository()->find($row['usr_id']); + $userSetting = new UserNotificationSetting(); $userSetting->setName($row['prop']); $userSetting->setValue($row['value']); - $userSetting->setUsrId($row['usr_id']); + $userSetting->setUser($user); $em->persist($userSetting); diff --git a/lib/classes/patch/390alpha7a.php b/lib/classes/patch/390alpha7a.php index cbd6a99f0e..d9f8813bd0 100644 --- a/lib/classes/patch/390alpha7a.php +++ b/lib/classes/patch/390alpha7a.php @@ -133,12 +133,14 @@ class patch_390alpha7a implements patchInterface $fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($fpRes as $fpRow) { + $user = $app['manipulator.user']->getRepository()->find($fpRow['usr_id']); + $feedPublisher = new FeedPublisher(); $feedPublisher->setFeed($feed); $feed->addPublisher($feedPublisher); $feedPublisher->setCreatedOn(new \DateTime($fpRow['created_on'])); $feedPublisher->setIsOwner((Boolean) $fpRow['owner']); - $feedPublisher->setUsrId($fpRow['usr_id']); + $feedPublisher->setUser($user); $feStmt->execute([':feed_id' => $row['id'], ':publisher_id' => $fpRow['id']]); $feRes = $feStmt->fetchAll(\PDO::FETCH_ASSOC); @@ -177,10 +179,12 @@ class patch_390alpha7a implements patchInterface $ftRes = $ftStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($ftRes as $ftRow) { + $user = $app['manipulator.user']->getRepository()->find($ftRow['usr_id']); + $token = new FeedToken(); $token->setFeed($feed); $feed->addToken($token); - $token->setUsrId($ftRow['usr_id']); + $token->setUser($user); $token->setValue($ftRow['token']); $em->persist($token); @@ -204,8 +208,10 @@ class patch_390alpha7a implements patchInterface $faRes = $faStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($faRes as $faRow) { + $user = $app['manipulator.user']->getRepository()->find($faRow['usr_id']); + $token = new AggregateToken(); - $token->setUsrId($faRow['usr_id']); + $token->setUser($user); $token->setValue($faRow['token']); $em->persist($token); diff --git a/lib/conf.d/migrations.yml b/lib/conf.d/migrations.yml index 27f488abe2..a66e542caa 100644 --- a/lib/conf.d/migrations.yml +++ b/lib/conf.d/migrations.yml @@ -42,3 +42,9 @@ migrations: migration13: version: ftp-export 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 diff --git a/templates/mobile/lightbox/sc_note.html.twig b/templates/mobile/lightbox/sc_note.html.twig index f6e721e341..0114bd0b9d 100644 --- a/templates/mobile/lightbox/sc_note.html.twig +++ b/templates/mobile/lightbox/sc_note.html.twig @@ -1,5 +1,5 @@ {% 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) %}
  • @@ -7,7 +7,7 @@ {% endif %} - {{ validationDatas.getParticipant().getUser(app).getDisplayName() }} + {{ validationDatas.getParticipant().getUser().getDisplayName() }}

    {% if validationDatas.getNote() != '' %}

    {{ 'validation:: note' | trans }} : {{ validationDatas.getNote()|nl2br }}

    diff --git a/templates/web/admin/connected-users.html.twig b/templates/web/admin/connected-users.html.twig index 5baf22316d..11f53ce058 100644 --- a/templates/web/admin/connected-users.html.twig +++ b/templates/web/admin/connected-users.html.twig @@ -1,6 +1,6 @@ {% macro tooltip_connected_users(row) %} -{% set user = row.getUser(app) %} +{% set user = row.getUser() %} @@ -102,9 +102,9 @@ {% if row.getId() == app['session'].get('session_id') %} - + {% else %} - + {% endif %}
    {{ row.getUser(app).getDisplayName() }}{{ row.getUser().getDisplayName() }}{{ row.getUser(app).getDisplayName() }}{{ row.getUser().getDisplayName() }} diff --git a/templates/web/admin/publications/fiche.html.twig b/templates/web/admin/publications/fiche.html.twig index 9354885110..b3f950d723 100644 --- a/templates/web/admin/publications/fiche.html.twig +++ b/templates/web/admin/publications/fiche.html.twig @@ -140,13 +140,13 @@ {% for publisher in feed.getPublishers() %}
    - {{ publisher.getUsrId() }} + {{ publisher.getUser().getId() }} - {{ publisher.getUser(app).getDisplayName() }} + {{ publisher.getUser().getDisplayName() }} - {{ publisher.getUser(app).getEmail() }} + {{ publisher.getUser().getEmail() }} {% if publisher.isOwner() == true %} diff --git a/templates/web/lightbox/IE6/agreement_box.html.twig b/templates/web/lightbox/IE6/agreement_box.html.twig index ea348767b6..80ff0cdd8c 100644 --- a/templates/web/lightbox/IE6/agreement_box.html.twig +++ b/templates/web/lightbox/IE6/agreement_box.html.twig @@ -18,7 +18,7 @@
      {% 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 %} {% set classuser = 'agree' %} {% elseif validation_data.getAgreement() is null %} @@ -26,7 +26,7 @@ {% else %} {% set classuser = 'disagree' %} {% endif %} - {% set participant = validation_data.getParticipant().getUser(app) %} + {% set participant = validation_data.getParticipant().getUser() %}
    • {{participant.getDisplayName()}}
    • {% endif %} {% endfor %} diff --git a/templates/web/lightbox/agreement_box.html.twig b/templates/web/lightbox/agreement_box.html.twig index 14339f2b28..78539ba5e4 100644 --- a/templates/web/lightbox/agreement_box.html.twig +++ b/templates/web/lightbox/agreement_box.html.twig @@ -16,7 +16,7 @@
      {{ basket.getValidation().getValidationString(app, app['authentication'].getUser()) }}
        {% 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 %} {% set classuser = 'agree' %} {% elseif choice.getAgreement() is null %} @@ -24,7 +24,7 @@ {% else %} {% set classuser = 'disagree' %} {% endif %} - {% set participant = choice.getParticipant().getUser(app) %} + {% set participant = choice.getParticipant().getUser() %}
      • {{participant.getDisplayName()}}
      • {% endif %} {% endfor %} diff --git a/templates/web/lightbox/basket_content_report.html.twig b/templates/web/lightbox/basket_content_report.html.twig index 2e837b4111..8e7a689793 100644 --- a/templates/web/lightbox/basket_content_report.html.twig +++ b/templates/web/lightbox/basket_content_report.html.twig @@ -33,7 +33,7 @@ {% set imguser = '' %} {% set styleuser = '' %} {% endif %} - {{imguser|raw}} {{validationDatas.getParticipant().getUser(app).getDisplayName()}} + {{imguser|raw}} {{validationDatas.getParticipant().getUser().getDisplayName()}} {% if validationDatas.getNote() != '' %} : {{validationDatas.getNote()|nl2br}} {% endif %} diff --git a/templates/web/lightbox/sc_note.html.twig b/templates/web/lightbox/sc_note.html.twig index 883ae5c0ab..a441c90e3f 100644 --- a/templates/web/lightbox/sc_note.html.twig +++ b/templates/web/lightbox/sc_note.html.twig @@ -8,9 +8,9 @@
        {% for validationDatas in basket_element.getValidationDatas() %} {% if validationDatas.getNote() != '' %} -
        +
        - {{validationDatas.getParticipant().getUser(app).getDisplayName()}} + {{validationDatas.getParticipant().getUser().getDisplayName()}} : {{ validationDatas.getNote()|nl2br }}
        {% endif %} diff --git a/templates/web/prod/WorkZone/Browser/Basket.html.twig b/templates/web/prod/WorkZone/Browser/Basket.html.twig index 2869d0683e..3c635f54b2 100644 --- a/templates/web/prod/WorkZone/Browser/Basket.html.twig +++ b/templates/web/prod/WorkZone/Browser/Basket.html.twig @@ -58,9 +58,9 @@ {% set list_participants = list_participants ~ ', ' %} {% endif %} - {% set list_participants = list_participants ~ '' - ~ Participant.getUser(app).getDisplayName + {% set list_participants = list_participants ~ '' + ~ Participant.getUser().getDisplayName ~ '' %} {% endfor %} {% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %} diff --git a/templates/web/prod/WorkZone/Browser/Results.html.twig b/templates/web/prod/WorkZone/Browser/Results.html.twig index 3360571a95..12a65fdced 100644 --- a/templates/web/prod/WorkZone/Browser/Results.html.twig +++ b/templates/web/prod/WorkZone/Browser/Results.html.twig @@ -84,8 +84,8 @@ {% set list_participants = list_participants ~ ', ' %} {% endif %} - {% set list_participants = list_participants ~ '' %} - {% set list_participants = list_participants ~ Participant.getUser(app).getDisplayName %} + {% set list_participants = list_participants ~ '' %} + {% set list_participants = list_participants ~ Participant.getUser().getDisplayName %} {% set list_participants = list_participants ~ '' %} {% endfor %} {% trans with {'%list_participants%' : list_participants} %}Sent for validation to %list_participants%{% endtrans %} diff --git a/templates/web/prod/WorkZone/Macros.html.twig b/templates/web/prod/WorkZone/Macros.html.twig index 315bfa192e..e42be80d43 100644 --- a/templates/web/prod/WorkZone/Macros.html.twig +++ b/templates/web/prod/WorkZone/Macros.html.twig @@ -353,9 +353,9 @@
    {% 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() %} - + diff --git a/templates/web/prod/actions/Feedback/list.html.twig b/templates/web/prod/actions/Feedback/list.html.twig index 56da7b085d..e0abbb4305 100644 --- a/templates/web/prod/actions/Feedback/list.html.twig +++ b/templates/web/prod/actions/Feedback/list.html.twig @@ -5,7 +5,7 @@
    {{ choice.getParticipant().getUser(app).getDisplayName() }} {{ choice.getParticipant().getUser().getDisplayName() }} {% if choice.getParticipant().getCanAgree() %} {% if choice.getAgreement() == true %} diff --git a/templates/web/prod/actions/Feedback/List-Share.html.twig b/templates/web/prod/actions/Feedback/List-Share.html.twig index 6bc00b2082..2b5543251e 100644 --- a/templates/web/prod/actions/Feedback/List-Share.html.twig +++ b/templates/web/prod/actions/Feedback/List-Share.html.twig @@ -29,11 +29,11 @@ - {{ owner.getUser(app).getDisplayName() }} - + {{ owner.getUser().getDisplayName() }} + - {% 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') %} {{ 'You are Admin' | trans }} {% endif %} @@ -53,7 +53,7 @@ {% endif %} - {% if app['authentication'].getUser().getgetId() owner.getUser(app).getId() %} + {% if app['authentication'].getUser().getgetId() owner.getUser().getId() %} diff --git a/templates/web/prod/actions/Feedback/ListsMacros.html.twig b/templates/web/prod/actions/Feedback/ListsMacros.html.twig index 1203b08daa..e290d46559 100644 --- a/templates/web/prod/actions/Feedback/ListsMacros.html.twig +++ b/templates/web/prod/actions/Feedback/ListsMacros.html.twig @@ -176,7 +176,7 @@ {% macro badgeReadonly(entry, role) %}
    - + {% if role >= constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_EDITOR') %} @@ -188,7 +188,7 @@
    - {{ entry.getUser(app).getDisplayName() }} + {{ entry.getUser().getDisplayName() }}
    - {% 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') %} order.getDeadline() ? "style=color:#777": "" }}> - +
    - {% 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') %}
    @@ -16,14 +16,14 @@ {% endif %}
    - {% 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') %} {{ "Set sharing permission" | trans }} {% endif %} {% endif %}

    - {% set role = list.getOwner(app['authentication'].getUser(), app).getRole() %} + {% set role = list.getOwner(app['authentication'].getUser()).getRole() %} {% for entry in list.getEntries() %} {{ ListsMacros.badgeReadonly(entry, role) }} {% endfor %}
    - {% 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') %}
    {{ order.getUser(app).getDisplayName() }}{{ order.getUser().getDisplayName() }} {{ app['date-formatter'].getPrettyString(order.getCreatedOn()) }} {% if deadline != '' %} diff --git a/templates/web/prod/orders/order_item.html.twig b/templates/web/prod/orders/order_item.html.twig index 5b01e76239..ef71e30750 100644 --- a/templates/web/prod/orders/order_item.html.twig +++ b/templates/web/prod/orders/order_item.html.twig @@ -1,5 +1,5 @@ {% import 'common/thumbnail.html.twig' as thumbnail %} -{% set displayName = order.getUser(app).getDisplayName() %} +{% set displayName = order.getUser().getDisplayName() %}