From eaa1feb7654dcd9f2a156104f7eee9d9a2d6c1ee Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 17 Feb 2014 14:46:08 +0100 Subject: [PATCH] Address PR comments --- .../Phrasea/Command/Developer/JsFixtures.php | 12 ++-- .../Command/Developer/RegenerateSqliteDb.php | 1 + .../Phrasea/Controller/Admin/Collection.php | 67 ++++++++++--------- .../Phrasea/Controller/Admin/Dashboard.php | 27 +++++--- .../Phrasea/Controller/Admin/Users.php | 6 +- .../Phrasea/Controller/Client/Baskets.php | 2 +- lib/Alchemy/Phrasea/Controller/Lightbox.php | 22 +++--- .../Controller/Prod/BasketController.php | 4 +- .../Phrasea/Controller/Prod/Export.php | 2 +- lib/Alchemy/Phrasea/Controller/Prod/Order.php | 4 +- lib/Alchemy/Phrasea/Controller/Prod/Push.php | 12 ++-- .../Phrasea/Controller/Prod/UsrLists.php | 10 +-- lib/Alchemy/Phrasea/Controller/Root/Login.php | 11 ++- .../Core/Provider/ORMServiceProvider.php | 5 ++ .../Provider/PhraseanetServiceProvider.php | 5 -- .../Phrasea/Model/Entities/AggregateToken.php | 5 +- lib/Alchemy/Phrasea/Model/Entities/Basket.php | 45 +++++-------- .../Phrasea/Model/Entities/BasketElement.php | 4 +- .../Phrasea/Model/Entities/FeedPublisher.php | 4 +- .../Phrasea/Model/Entities/FeedToken.php | 4 +- .../Phrasea/Model/Entities/FtpCredential.php | 4 +- .../Phrasea/Model/Entities/FtpExport.php | 4 +- .../Phrasea/Model/Entities/LazaretSession.php | 4 +- lib/Alchemy/Phrasea/Model/Entities/Order.php | 4 +- .../Phrasea/Model/Entities/OrderElement.php | 44 ++++-------- .../Phrasea/Model/Entities/Session.php | 6 +- .../Phrasea/Model/Entities/StoryWZ.php | 4 +- lib/Alchemy/Phrasea/Model/Entities/User.php | 7 +- .../Entities/UserNotificationSetting.php | 4 +- .../Phrasea/Model/Entities/UserQuery.php | 4 +- .../Phrasea/Model/Entities/UserSetting.php | 4 +- .../Model/Entities/UsrAuthProvider.php | 4 +- .../Phrasea/Model/Entities/UsrList.php | 4 +- .../Phrasea/Model/Entities/UsrListEntry.php | 4 +- .../Phrasea/Model/Entities/UsrListOwner.php | 4 +- .../Model/Entities/ValidationParticipant.php | 4 +- .../Model/Entities/ValidationSession.php | 49 ++++++-------- .../Phrasea/Model/NativeQueryProvider.php | 2 +- .../Model/Repositories/BasketRepository.php | 4 +- .../Notification/Mail/MailInfoNewOrder.php | 2 +- .../Mail/MailInfoOrderCancelled.php | 2 +- .../Mail/MailInfoOrderDelivered.php | 2 +- .../Mail/MailInfoPushReceived.php | 2 +- .../Mail/MailInfoValidationDone.php | 4 +- .../Mail/MailInfoValidationRequest.php | 2 +- .../DeleteUsrIdFieldMigration.php | 9 +++ .../UserAuthProviderMigration.php | 9 +++ .../DoctrineMigrations/UserFieldMigration.php | 9 +++ .../DoctrineMigrations/UserListMigration.php | 9 +++ .../PreSchemaUpgradeCollection.php | 2 +- .../PreSchemaUpgradeInterface.php | 2 +- .../Version/PreSchemaUpgrade/Upgrade39.php | 2 +- .../ControlProvider/UserProvider.php | 4 +- lib/classes/API/V1/adapter.php | 8 +-- .../eventsmanager/notify/autoregister.php | 4 +- lib/classes/eventsmanager/notify/order.php | 2 +- .../eventsmanager/notify/orderdeliver.php | 4 +- .../notify/ordernotdelivered.php | 2 +- lib/classes/eventsmanager/notify/push.php | 2 +- lib/classes/eventsmanager/notify/register.php | 4 +- .../eventsmanager/notify/uploadquarantine.php | 2 +- lib/classes/eventsmanager/notify/validate.php | 2 +- .../eventsmanager/notify/validationdone.php | 4 +- .../notify/validationreminder.php | 2 +- lib/classes/module/console/checkExtension.php | 2 +- lib/classes/module/report/activity.php | 2 +- lib/classes/module/report/add.php | 2 +- lib/classes/module/report/edit.php | 2 +- lib/classes/module/report/push.php | 2 +- lib/classes/module/report/sent.php | 2 +- lib/classes/module/report/validate.php | 2 +- lib/classes/patch/320alpha4b.php | 8 +-- lib/classes/record/orderElement.php | 2 +- lib/classes/set/export.php | 2 +- lib/classes/set/exportftp.php | 2 +- .../api/auth/end_user_authorization.html.twig | 2 +- .../auth/native_app_access_token.html.twig | 2 +- .../mobile/lightbox/basket_element.html.twig | 6 +- templates/mobile/lightbox/note_form.html.twig | 2 +- templates/mobile/lightbox/sc_note.html.twig | 2 +- templates/mobile/lightbox/validate.html.twig | 8 +-- .../web/account/authorized_apps.html.twig | 2 +- .../web/admin/collection/collection.html.twig | 2 +- templates/web/admin/connected-users.html.twig | 6 +- templates/web/admin/editusers.html.twig | 2 +- .../web/admin/publications/fiche.html.twig | 2 +- .../api/auth/end_user_authorization.html.twig | 2 +- .../auth/native_app_access_token.html.twig | 2 +- templates/web/client/baskets.html.twig | 4 +- .../web/lightbox/IE6/agreement_box.html.twig | 8 +-- .../web/lightbox/IE6/basket_options.html.twig | 2 +- templates/web/lightbox/IE6/index.html.twig | 2 +- .../web/lightbox/IE6/sc_container.html.twig | 4 +- .../web/lightbox/agreement_box.html.twig | 8 +-- .../lightbox/basket_content_report.html.twig | 2 +- .../web/lightbox/basket_options.html.twig | 2 +- templates/web/lightbox/index.html.twig | 2 +- templates/web/lightbox/sc_container.html.twig | 4 +- templates/web/lightbox/sc_note.html.twig | 4 +- templates/web/lightbox/selector_box.html.twig | 4 +- templates/web/lightbox/validate.html.twig | 2 +- templates/web/login/common/macros.html.twig | 4 +- templates/web/prod/Tooltip/User.html.twig | 4 +- .../prod/WorkZone/Browser/Basket.html.twig | 6 +- .../prod/WorkZone/Browser/Results.html.twig | 6 +- templates/web/prod/WorkZone/Macros.html.twig | 8 +-- .../actions/Feedback/List-Share.html.twig | 2 +- .../actions/Feedback/ListsMacros.html.twig | 4 +- templates/web/prod/actions/Push.html.twig | 4 +- .../prod/actions/publish/publish.html.twig | 2 +- templates/web/prod/orders/order_box.html.twig | 2 +- .../web/prod/orders/order_item.html.twig | 8 +-- .../web/prod/preview/short_history.html.twig | 2 +- templates/web/prod/upload/lazaret.html.twig | 2 +- .../Phrasea/Application/LightboxTest.php | 2 +- .../Phrasea/Controller/Admin/UsersTest.php | 2 +- .../Phrasea/Controller/Root/LoginTest.php | 4 +- .../Tests/Phrasea/Model/Entities/UserTest.php | 13 ++-- .../ControlProvider/UserProviderTest.php | 2 +- 119 files changed, 358 insertions(+), 347 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php index 8c0b6ea65e..29b4a9fa11 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php +++ b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php @@ -37,14 +37,10 @@ class JsFixtures extends Command copy($dbRefPath, '/tmp/db.sqlite'); - try { - $sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id(); - $this->writeResponse($output, 'GET', '/login/', '/home/login/index.html'); - $this->writeResponse($output, 'GET', '/admin/fields/'.$sbasId , '/admin/fields/index.html', true); - $this->writeResponse($output, 'GET', '/admin/task-manager/tasks', '/admin/task-manager/index.html', true); - } catch (\Exception $e) { - throw $e; - } + $sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id(); + $this->writeResponse($output, 'GET', '/login/', '/home/login/index.html'); + $this->writeResponse($output, 'GET', '/admin/fields/'.$sbasId , '/admin/fields/index.html', true); + $this->writeResponse($output, 'GET', '/admin/task-manager/tasks', '/admin/task-manager/index.html', true); $this->copy($output, [ ['source' => 'login/common/templates.html.twig', 'target' => 'home/login/templates.html'], diff --git a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php index 0d6d1859a9..9b2e74bfcb 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php +++ b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php @@ -186,6 +186,7 @@ class RegenerateSqliteDb extends Command private function insertLazaretFiles(EntityManager $em, \Pimple $DI) { $session = new LazaretSession(); + $session->setUser($DI['user']); $em->persist($session); $em->flush(); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 64ea4d20dc..f6a3dc3792 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Controller\Admin; +use Alchemy\Phrasea\Exception\RuntimeException; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -176,41 +177,45 @@ class Collection implements ControllerProviderInterface public function setOrderAdmins(Application $app, Request $request, $bas_id) { $success = false; + $admins = array_values($request->request->get('admins', [])); - if (count($admins = $request->request->get('admins', [])) > 0) { - $newAdmins = []; + if (count($admins) === 0) { + $app->abort(400, 'No admins provided.'); + } + if (!is_array($admins)) { + $app->abort(400, 'Admins must be an array.'); + } + + $admins = array_map(function ($usrId) use ($app) { + if (null === $user = $app['manipulator.user']->getRepository()->find($usrId)) { + throw new RuntimeException(sprintf('Invalid usrId %s provided.', $usrId)); + } + + return $user; + }, $admins); + + $conn = $app['phraseanet.appbox']->get_connection(); + $conn->beginTransaction(); + + try { + $userQuery = new \User_Query($app); + + $result = $userQuery->on_base_ids([$bas_id]) + ->who_have_right(['order_master']) + ->execute()->get_results(); + + foreach ($result as $user) { + $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => false]); + } foreach ($admins as $admin) { - $newAdmins[] = $admin; - } - - if (count($newAdmins) > 0) { - $conn = $app['phraseanet.appbox']->get_connection(); - $conn->beginTransaction(); - - try { - $userQuery = new \User_Query($app); - - $result = $userQuery->on_base_ids([$bas_id]) - ->who_have_right(['order_master']) - ->execute()->get_results(); - - foreach ($result as $user) { - $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => false]); - } - - foreach (array_filter($newAdmins) as $admin) { - if (null !== $user = $app['manipulator.user']->getRepository()->find($admin)) { - $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => true]); - } - } - $conn->commit(); - - $success = true; - } catch (\Exception $e) { - $conn->rollBack(); - } + $app['acl']->get($admin)->update_rights_to_base($bas_id, ['order_master' => true]); } + $conn->commit(); + $success = true; + } catch (\Exception $e) { + $conn->rollBack(); + throw $e; } return $app->redirectPath('admin_display_collection', [ diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 66c027cb9b..b3d4c5060b 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Controller\Admin; use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Mail\MailTest; use Alchemy\Phrasea\Exception\InvalidArgumentException; +use Alchemy\Phrasea\Exception\RuntimeException; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; @@ -146,18 +147,24 @@ class Dashboard implements ControllerProviderInterface */ public function addAdmins(Application $app, Request $request) { - if (count($admins = $request->request->get('admins', [])) > 0) { - if (!in_array($app['authentication']->getUser()->getId(), $admins)) { - $admins[] = $app['authentication']->getUser()->getId(); + $admins = $request->request->get('admins', []); + if (count($admins) === 0 || !is_array($admins)) { + $app->abort(400, '"admins" parameter must contains at least one value.'); + } + if (!in_array($app['authentication']->getUser()->getId(), $admins)) { + $admins[] = $app['authentication']->getUser()->getId(); + } + + $admins = array_map(function ($usrId) use ($app) { + if (null === $user = $app['manipulator.user']->getRepository()->find($usrId)) { + throw new RuntimeException(sprintf('Invalid usrId %s provided.', $usrId)); } - if ($admins > 0) { - $app['manipulator.user']->promote(array_filter(array_map(function ($id) use ($app) { - return $app['manipulator.user']->getRepository()->find($id); - }, $admins))); - $app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins()); - } - } + return $user; + }, $admins); + + $app['manipulator.user']->promote($admins); + $app['manipulator.acl']->resetAdminRights($admins); return $app->redirectPath('admin_dashbord'); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index fe18a25c5e..51f6359efa 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -243,7 +243,7 @@ class Users implements ControllerProviderInterface $datas[] = [ 'email' => $user->getEmail() ? : '', 'login' => $user->getLogin() ? : '', - 'name' => $user->getDisplayName($app['translator']) ? : '', + 'name' => $user->getDisplayName(), 'id' => $user->getId(), ]; } @@ -366,7 +366,7 @@ class Users implements ControllerProviderInterface $currentUsr = null; $table = ['users' => [], 'coll' => []]; - foreach ($app['phraseanet.native-query']->getUsersRegistrationDemand($basList) as $row) { + foreach ($app['EM.native-query']->getUsersRegistrationDemand($basList) as $row) { $user = $row[0]; if ($user->getId() !== $currentUsr) { @@ -693,7 +693,7 @@ class Users implements ControllerProviderInterface } $basList = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage'])); - $models = $app['phraseanet.native-query']->getModelForUser($app['authentication']->getUser(), $basList); + $models = $app['EM.native-query']->getModelForUser($app['authentication']->getUser(), $basList); return $app['twig']->render('/admin/user/import/view.html.twig', [ 'nb_user_to_add' => $nbUsrToAdd, diff --git a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php index 908efcb89d..9e80571d1d 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php @@ -180,7 +180,7 @@ class Baskets implements ControllerProviderInterface } $basketCollections = $baskets->partition(function ($key, $basket) { - return (Boolean) $basket->getPusherId(); + return null !== $basket->getPusher(); }); return $app['twig']->render('client/baskets.html.twig', [ diff --git a/lib/Alchemy/Phrasea/Controller/Lightbox.php b/lib/Alchemy/Phrasea/Controller/Lightbox.php index d7c89695b8..e198cda1ce 100644 --- a/lib/Alchemy/Phrasea/Controller/Lightbox.php +++ b/lib/Alchemy/Phrasea/Controller/Lightbox.php @@ -221,9 +221,9 @@ class Lightbox implements ControllerProviderInterface $app['EM']->flush(); } - if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getIsAware() === false) { + if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) { $basket = $app['EM']->merge($basket); - $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->setIsAware(true); + $basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true); $app['EM']->flush(); } @@ -268,9 +268,9 @@ class Lightbox implements ControllerProviderInterface $app['EM']->flush(); } - if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getIsAware() === false) { + if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) { $basket = $app['EM']->merge($basket); - $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->setIsAware(true); + $basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true); $app['EM']->flush(); } @@ -350,7 +350,7 @@ class Lightbox implements ControllerProviderInterface $basket_element = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); - $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser(), $app); + $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser()); $validationDatas->setNote($note); @@ -400,11 +400,11 @@ class Lightbox implements ControllerProviderInterface , $app['authentication']->getUser() ); /* @var $basket_element BasketElement */ - $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser(), $app); + $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser()); if (!$basket_element->getBasket() ->getValidation() - ->getParticipant($app['authentication']->getUser(), $app)->getCanAgree()) { + ->getParticipant($app['authentication']->getUser())->getCanAgree()) { throw new ControllerException('You can not agree on this'); } @@ -412,7 +412,7 @@ class Lightbox implements ControllerProviderInterface $participant = $basket_element->getBasket() ->getValidation() - ->getParticipant($app['authentication']->getUser(), $app); + ->getParticipant($app['authentication']->getUser()); $app['EM']->merge($basket_element); @@ -446,14 +446,14 @@ class Lightbox implements ControllerProviderInterface throw new ControllerException('There is no validation session attached to this basket'); } - if (!$basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getCanAgree()) { + if (!$basket->getValidation()->getParticipant($app['authentication']->getUser())->getCanAgree()) { throw new ControllerException('You have not right to agree'); } $agreed = false; /* @var $basket Basket */ foreach ($basket->getElements() as $element) { - if (null !== $element->getUserValidationDatas($app['authentication']->getUser(), $app)->getAgreement()) { + if (null !== $element->getUserValidationDatas($app['authentication']->getUser())->getAgreement()) { $agreed = true; } } @@ -463,7 +463,7 @@ class Lightbox implements ControllerProviderInterface } /* @var $basket Basket */ - $participant = $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app); + $participant = $basket->getValidation()->getParticipant($app['authentication']->getUser()); $expires = new \DateTime('+10 days'); $url = $app->url('lightbox', ['LOG' => $app['tokens']->getUrlToken( diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index fa8165a603..b85ce05f0a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -99,8 +99,8 @@ class BasketController implements ControllerProviderInterface } if ($basket->getValidation()) { - if ($basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getIsAware() === false) { - $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->setIsAware(true); + if ($basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) { + $basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true); $app['EM']->flush(); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index 91b93f2618..51d617b63c 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -232,7 +232,7 @@ class Export implements ControllerProviderInterface $url = $app->url('prepare_download', ['token' => $token, 'anonymous']); - $emitter = new Emitter($app['authentication']->getUser()->getDisplayName($app['translator']), $app['authentication']->getUser()->getEmail()); + $emitter = new Emitter($app['authentication']->getUser()->getDisplayName(), $app['authentication']->getUser()->getEmail()); foreach ($destMails as $key => $mail) { try { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php index add39c8cae..f7c53fe43c 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php @@ -263,7 +263,7 @@ class Order implements ControllerProviderInterface $basketElement->setRecord($record); $basketElement->setBasket($basket); - $orderElement->setOrderMasterId($app['authentication']->getUser()->getId()); + $orderElement->setOrderMaster($app['authentication']->getUser()); $orderElement->setDeny(false); $orderElement->getOrder()->setBasket($basket); @@ -329,7 +329,7 @@ class Order implements ControllerProviderInterface $elements = $request->request->get('elements', []); foreach ($order->getElements() as $orderElement) { if (in_array($orderElement->getId(),$elements)) { - $orderElement->setOrderMasterId($app['authentication']->getUser()->getId()); + $orderElement->setOrderMaster($app['authentication']->getUser()); $orderElement->setDeny(true); $app['EM']->persist($orderElement); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index e26b51ddc6..c249d73bef 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -40,7 +40,7 @@ class Push implements ControllerProviderInterface 'firstname' => $user->getFirstName(), 'lastname' => $user->getLastName(), 'email' => $user->getEmail(), - 'display_name' => $user->getDisplayName($app['translator']), + 'display_name' => $user->getDisplayName(), 'subtitle' => implode(', ', $subtitle), ]; }; @@ -162,7 +162,7 @@ class Push implements ControllerProviderInterface try { $pusher = new RecordHelper\Push($app, $app['request']); - $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName($app['translator'])])); + $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()])); $push_description = $request->request->get('push_description'); $receivers = $request->request->get('participants'); @@ -234,7 +234,7 @@ class Push implements ControllerProviderInterface 'from_email' => $app['authentication']->getUser()->getEmail(), 'to' => $user_receiver->getId(), 'to_email' => $user_receiver->getEmail(), - 'to_name' => $user_receiver->getDisplayName($app['translator']), + 'to_name' => $user_receiver->getDisplayName(), 'url' => $url, 'accuse' => $receipt, 'message' => $request->request->get('message'), @@ -278,7 +278,7 @@ class Push implements ControllerProviderInterface try { $pusher = new RecordHelper\Push($app, $app['request']); - $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName($app['translator'])])); + $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()])); $validation_description = $request->request->get('validation_description'); $participants = $request->request->get('participants'); @@ -364,7 +364,7 @@ class Push implements ControllerProviderInterface } try { - $Participant = $Validation->getParticipant($participant_user, $app); + $Participant = $Validation->getParticipant($participant_user); continue; } catch (NotFoundHttpException $e) { @@ -429,7 +429,7 @@ class Push implements ControllerProviderInterface 'from_email' => $app['authentication']->getUser()->getEmail(), 'to' => $participant_user->getId(), 'to_email' => $participant_user->getEmail(), - 'to_name' => $participant_user->getDisplayName($app['translator']), + 'to_name' => $participant_user->getDisplayName(), 'url' => $url, 'accuse' => $receipt, 'message' => $request->request->get('message'), diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 88f21659ea..78e32df93a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -92,7 +92,7 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getOwners() as $owner) { $owners[] = [ 'usr_id' => $owner->getUser()->getId(), - 'display_name' => $owner->getUser()->getDisplayName($app['translator']), + 'display_name' => $owner->getUser()->getDisplayName(), 'position' => $owner->getUser()->getActivity(), 'job' => $owner->getUser()->getJob(), 'company' => $owner->getUser()->getCompany(), @@ -104,7 +104,7 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getEntries() as $entry) { $entries[] = [ 'usr_id' => $entry->getUser()->getId(), - 'display_name' => $entry->getUser()->getDisplayName($app['translator']), + 'display_name' => $entry->getUser()->getDisplayName(), 'position' => $entry->getUser()->getActivity(), 'job' => $entry->getUser()->getJob(), 'company' => $entry->getUser()->getCompany(), @@ -203,7 +203,7 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getOwners() as $owner) { $owners[] = [ 'usr_id' => $owner->getUser()->getId(), - 'display_name' => $owner->getUser()->getDisplayName($app['translator']), + 'display_name' => $owner->getUser()->getDisplayName(), 'position' => $owner->getUser()->getActivity(), 'job' => $owner->getUser()->getJob(), 'company' => $owner->getUser()->getCompany(), @@ -215,7 +215,7 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getEntries() as $entry) { $entries[] = [ 'usr_id' => $entry->getUser()->getId(), - 'display_name' => $entry->getUser()->getDisplayName($app['translator']), + 'display_name' => $entry->getUser()->getDisplayName(), 'position' => $entry->getUser()->getActivity(), 'job' => $entry->getUser()->getJob(), 'company' => $entry->getUser()->getCompany(), @@ -372,7 +372,7 @@ class UsrLists implements ControllerProviderInterface foreach ($request->request->get('usr_ids') as $usr_id) { $user_entry = $app['manipulator.user']->getRepository()->find($usr_id); - if ($list->has($user_entry, $app)) + if ($list->has($user_entry)) continue; $entry = new UsrListEntry(); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 687ec13898..5313885f83 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -364,6 +364,10 @@ class Login implements ControllerProviderInterface $user = $app['manipulator.user']->createUser($data['login'], $data['password'], $data['email'], false); + if (isset($data['geonameid'])) { + $app['manipulator.user']->setGeonameId($user, $data['geonameid']); + } + foreach ([ 'gender' => 'setGender', 'firstname' => 'setFirstName', @@ -375,13 +379,8 @@ class Login implements ControllerProviderInterface 'job' => 'setJob', 'company' => 'setCompany', 'position' => 'setActivity', - 'geonameid' => 'setGeonameId', ] as $property => $method) { if (isset($data[$property])) { - if ($property === 'geonameid') { - $app['manipulator.user']->setGeonameId($user, $data[$property]); - continue; - } call_user_func([$user, $method], $data[$property]); } } @@ -866,7 +865,7 @@ class Login implements ControllerProviderInterface $app['events-manager']->trigger('__VALIDATION_REMINDER__', [ 'to' => $participantId, 'ssel_id' => $basketId, - 'from' => $validationSession->getInitiatorId(), + 'from' => $validationSession->getInitiator()->getId(), 'validate_id' => $validationSession->getId(), 'url' => $app->url('lightbox_validation', ['basket' => $basketId, 'LOG' => $token]), ]); diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index b0eead5f2c..135c30f81d 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Model\MonologSQLLogger; +use Alchemy\Phrasea\Model\NativeQueryProvider; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\FileCacheReader; @@ -155,6 +156,10 @@ class ORMServiceProvider implements ServiceProviderInterface return $em; }); + + $app['EM.native-query'] = $app->share(function ($app) { + return new NativeQueryProvider($app['EM']); + }); } public function boot(Application $app) diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php index 7b460b646b..0a655cb4c2 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php @@ -12,7 +12,6 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Authentication\ACLProvider; -use Alchemy\Phrasea\Model\NativeQueryProvider; use Alchemy\Phrasea\Security\Firewall; use Silex\Application as SilexApplication; use Silex\ServiceProviderInterface; @@ -40,10 +39,6 @@ class PhraseanetServiceProvider implements ServiceProviderInterface return new ACLProvider($app); }); - $app['phraseanet.native-query'] = $app->share(function ($app) { - return new NativeQueryProvider($app['EM']); - }); - $app['phraseanet.appbox-register'] = $app->share(function ($app) { return new \appbox_register($app['phraseanet.appbox']); }); diff --git a/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php b/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php index ef8314c8d2..afb1e361e5 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php +++ b/lib/Alchemy/Phrasea/Model/Entities/AggregateToken.php @@ -28,7 +28,7 @@ class AggregateToken /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -54,7 +54,7 @@ class AggregateToken * * @return AggregateToken */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; @@ -91,5 +91,4 @@ class AggregateToken { return $this->value; } - } diff --git a/lib/Alchemy/Phrasea/Model/Entities/Basket.php b/lib/Alchemy/Phrasea/Model/Entities/Basket.php index 0eebb810ad..7fa1a5c84c 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Basket.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Basket.php @@ -44,7 +44,7 @@ class Basket /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -56,9 +56,12 @@ class Basket private $is_read = false; /** - * @ORM\Column(type="integer", nullable=true) - */ - private $pusher_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="pusher_id", referencedColumnName="id") + * + * @return User + **/ + private $pusher; /** * @ORM\Column(type="boolean") @@ -93,8 +96,6 @@ class Basket */ private $order; - private $pusher; - /** * Constructor */ @@ -164,7 +165,7 @@ class Basket * * @return Basket */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; @@ -203,39 +204,23 @@ class Basket } /** - * Set pusher_id + * @param User $user * - * @param integer $pusherId - * @return Basket + * @return $this */ - public function setPusherId($pusherId) + public function setPusher(User $user = null) { - $this->pusher_id = $pusherId; + $this->pusher = $user; return $this; } /** - * Get pusher_id - * - * @return integer + * @return mixed */ - public function getPusherId() + public function getPusher() { - return $this->pusher_id; - } - - public function setPusher(User $user) - { - $this->setPusherId($user->getId()); - $this->pusher = $user; - } - - public function getPusher(Application $app) - { - if ($this->getPusherId()) { - return $app['manipulator.user']->getRepository()->find($this->getPusherId()); - } + return $this->pusher; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php index 1c1430dd6d..71e6e3c9b6 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php +++ b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php @@ -279,10 +279,10 @@ class BasketElement * * @return ValidationData */ - public function getUserValidationDatas(User $user, Application $app) + public function getUserValidationDatas(User $user) { foreach ($this->validation_datas as $validationData) { - if ($validationData->getParticipant($app)->getUser()->getId() == $user->getId()) { + if ($validationData->getParticipant()->getUser()->getId() == $user->getId()) { return $validationData; } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php b/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php index 12a4abcac7..ba7d30b1c4 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedPublisher.php @@ -29,7 +29,7 @@ class FeedPublisher /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -67,7 +67,7 @@ class FeedPublisher * * @return FeedPublisher */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php b/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php index 2e05099ef5..09e43ebe88 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FeedToken.php @@ -28,7 +28,7 @@ class FeedToken /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -60,7 +60,7 @@ class FeedToken * * @return FeedToken */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php b/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php index 41f63409c2..536c276af6 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FtpCredential.php @@ -29,7 +29,7 @@ class FtpCredential /** * @ORM\OneToOne(targetEntity="User", inversedBy="ftpCredential") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) **/ private $user; @@ -105,7 +105,7 @@ class FtpCredential * * @return FtpCredential */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php index a58431db06..335dd7a0df 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php +++ b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php @@ -90,7 +90,7 @@ class FtpExport /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -148,7 +148,7 @@ class FtpExport * * @return FtpExport */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php b/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php index 9644fbac79..f3c83c9ba3 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/LazaretSession.php @@ -29,7 +29,7 @@ class LazaretSession /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -76,7 +76,7 @@ class LazaretSession * * @return LazaretSession */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/Order.php b/lib/Alchemy/Phrasea/Model/Entities/Order.php index 9198694e09..28acc582ff 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Order.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Order.php @@ -29,7 +29,7 @@ class Order /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -89,7 +89,7 @@ class Order * * @return Order */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php b/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php index 516d548573..d5277abf55 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php +++ b/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php @@ -38,9 +38,12 @@ class OrderElement private $recordId; /** - * @ORM\Column(type="integer", nullable=true, name="order_master_id") - */ - private $orderMasterId; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="order_master", referencedColumnName="id") + * + * @return User + **/ + private $orderMaster; /** * @ORM\Column(type="boolean", nullable=true) @@ -64,44 +67,23 @@ class OrderElement } /** - * Set order_master_id + * @param User $user * - * @param integer $orderMasterId - * @return OrderElement + * @return $this */ - public function setOrderMasterId($orderMasterId) + public function setOrderMaster(User $user = null) { - $this->orderMasterId = $orderMasterId; + $this->orderMaster = $user; return $this; } /** - * Get order_master_id - * - * @return integer + * @return mixed */ - public function getOrderMasterId() + public function getOrderMaster() { - return $this->orderMasterId; - } - - /** - * - * Returns the username matching to the order_master_id - * - * @param Application $app - * @return string - */ - public function getOrderMasterName(Application $app) - { - if (isset($this->orderMasterId) && null !== $this->orderMasterId) { - $user = $app['manipulator.user']->getRepository()->find($this->orderMasterId); - - return $user->getFirstName(); - } - - return null; + return $this->orderMaster; } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/Session.php b/lib/Alchemy/Phrasea/Model/Entities/Session.php index ce87bfc732..cf7b58b036 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Session.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Session.php @@ -15,7 +15,7 @@ use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; /** - * @ORM\Table(name="Sessions") + * @ORM\Table(name="Sessions", indexes={@ORM\index(name="user_id", columns={"user_id"})}) * @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\SessionRepository") */ class Session @@ -29,7 +29,7 @@ class Session /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -121,7 +121,7 @@ class Session * * @return Session */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php index c60a75bd9b..c7fdd93a3a 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php +++ b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php @@ -41,7 +41,7 @@ class StoryWZ /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -124,7 +124,7 @@ class StoryWZ * * @return StoryWZ */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 3e5018f4e8..94b3745d27 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -27,6 +27,7 @@ use Symfony\Component\Translation\TranslatorInterface; * indexes={ * @ORM\index(name="login", columns={"login"}), * @ORM\index(name="mail", columns={"email"}), + * @ORM\index(name="model_of", columns={"model_of"}), * @ORM\index(name="salted_password", columns={"salted_password"}), * @ORM\index(name="admin", columns={"admin"}), * @ORM\index(name="guest", columns={"guest"}) @@ -1030,7 +1031,7 @@ class User /** * @return string */ - public function getDisplayName(TranslatorInterface $translator = null) + public function getDisplayName() { if ($this->isTemplate()) { return $this->getLogin(); @@ -1044,6 +1045,10 @@ class User return $this->email; } + if ('' !== trim($this->getLogin())) { + return $this->getLogin(); + } + return 'Unnamed user'; } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php b/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php index 0777315684..17c3af0955 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserNotificationSetting.php @@ -33,7 +33,7 @@ class UserNotificationSetting /** * @ORM\ManyToOne(targetEntity="User", inversedBy="notificationSettings") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) **/ private $user; @@ -80,7 +80,7 @@ class UserNotificationSetting * * @return UserNotificationSetting */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php b/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php index 549589828b..3013271e71 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserQuery.php @@ -29,7 +29,7 @@ class UserQuery /** * @ORM\ManyToOne(targetEntity="User", inversedBy="queries") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) **/ private $user; @@ -65,7 +65,7 @@ class UserQuery * * @return UserQuery */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php b/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php index 07784b279e..5d1a9d2534 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UserSetting.php @@ -33,7 +33,7 @@ class UserSetting /** * @ORM\ManyToOne(targetEntity="User", inversedBy="settings") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) **/ private $user; @@ -80,7 +80,7 @@ class UserSetting * * @return UserSetting */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php b/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php index 600b6e3294..0b46296e27 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrAuthProvider.php @@ -32,7 +32,7 @@ class UsrAuthProvider /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -75,7 +75,7 @@ class UsrAuthProvider * * @return usrAuthprovider */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php index e4ace3a2fd..a68547e0eb 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php @@ -242,10 +242,10 @@ class UsrList * @param User $user * @return boolean */ - public function has(User $user, Application $app) + public function has(User $user) { return $this->entries->exists( - function ($key, $entry) use ($user, $app) { + function ($key, $entry) use ($user) { 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 9d3e19ed79..b3391b1f83 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php @@ -29,7 +29,7 @@ class UsrListEntry /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -68,7 +68,7 @@ class UsrListEntry * * @return UsrListEntry */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php index 036993ec68..d607b95535 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php @@ -33,7 +33,7 @@ class UsrListOwner /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -77,7 +77,7 @@ class UsrListOwner * * @return UsrListowner */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php index efcbc1f302..564c9f6b88 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php @@ -82,7 +82,7 @@ class ValidationParticipant /** * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="user_id", referencedColumnName="id") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * * @return User **/ @@ -93,7 +93,7 @@ class ValidationParticipant * * @return AggregateToken */ - public function setUser(User $user = null) + public function setUser(User $user) { $this->user = $user; diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php index 2f32c8a6e7..2e3cd5590c 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php @@ -30,9 +30,12 @@ class ValidationSession private $id; /** - * @ORM\Column(type="integer") - */ - private $initiator_id; + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="initiator_id", referencedColumnName="id", nullable=false) + * + * @return User + **/ + private $initiator; /** * @Gedmo\Timestampable(on="create") @@ -81,14 +84,13 @@ class ValidationSession } /** - * Set initiator_id + * @param User $user * - * @param integer $initiatorId - * @return ValidationSession + * @return $this */ - public function setInitiatorId($initiatorId) + public function setInitiator(User $user) { - $this->initiator_id = $initiatorId; + $this->initiator = $user; return $this; } @@ -98,28 +100,19 @@ class ValidationSession * * @return integer */ - public function getInitiatorId() + public function getInitiator() { return $this->initiator_id; } + /** + * @param User $user + * + * @return boolean + */ public function isInitiator(User $user) { - return $this->getInitiatorId() == $user->getId(); - } - - public function setInitiator(User $user) - { - $this->initiator_id = $user->getId(); - - return; - } - - public function getInitiator(Application $app) - { - if ($this->initiator_id) { - return $app['manipulator.user']->getRepository()->find($this->initiator_id); - } + return $this->getInitiator()->getId() == $user->getId(); } /** @@ -267,10 +260,10 @@ class ValidationSession return $app->trans('Vous avez envoye cette demande a %n% utilisateurs', ['%n%' => count($this->getParticipants()) - 1]); } } else { - if ($this->getParticipant($user, $app)->getCanSeeOthers()) { - return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', ['%user%' => $this->getInitiator($app)->getDisplayName($app['translator']), '%n%' => count($this->getParticipants()) - 1]); + if ($this->getParticipant($user)->getCanSeeOthers()) { + return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', ['%user%' => $this->getInitiator($app)->getDisplayName(), '%n%' => count($this->getParticipants()) - 1]); } else { - return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->getDisplayName($app['translator'])]); + return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->getDisplayName()]); } } } @@ -280,7 +273,7 @@ class ValidationSession * * @return ValidationParticipant */ - public function getParticipant(User $user, Application $app) + public function getParticipant(User $user) { foreach ($this->getParticipants() as $participant) { if ($participant->getUser()->getId() == $user->getId()) { diff --git a/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php b/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php index 9bf8e5dc62..8ea422c27d 100644 --- a/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php +++ b/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php @@ -2,7 +2,7 @@ /* * This file is part of Phraseanet * - * (c) 2005-2013 Alchemy + * (c) 2005-2014 Alchemy * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php index dbf7d3823d..493c3b7e35 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php @@ -124,7 +124,7 @@ class BasketRepository extends EntityRepository * @param User $user * @return Basket */ - public function findUserBasket(Application $app, $basket_id, User $user, $requireOwner) + public function findUserBasket($basket_id, User $user, $requireOwner) { $dql = 'SELECT b FROM Alchemy\Phrasea\Model\Entities\Basket b @@ -146,7 +146,7 @@ class BasketRepository extends EntityRepository if ($basket->getValidation() && !$requireOwner) { try { - $basket->getValidation()->getParticipant($user, $app); + $basket->getValidation()->getParticipant($user); $participant = true; } catch (\Exception $e) { diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php index 823830cf43..c56b901d14 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php @@ -46,7 +46,7 @@ class MailInfoNewOrder extends AbstractMail throw new LogicException('You must set a user before calling getMessage()'); } - return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName($this->app['translator'])]); + return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName()]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php index 76a35d67af..a8da22facb 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php @@ -62,7 +62,7 @@ class MailInfoOrderCancelled extends AbstractMail } return $this->app->trans('%user% a refuse %quantity% elements de votre commande', [ - '%user%' => $this->deliverer->getDisplayName($this->app['translator']), + '%user%' => $this->deliverer->getDisplayName(), '%quantity%' => $this->quantity, ]); } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php index da3bbf2232..a976be10a2 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php @@ -63,7 +63,7 @@ class MailInfoOrderDelivered extends AbstractMail throw new LogicException('You must set a deliverer before calling getMessage'); } - return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName($this->app['translator'])]); + return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php index c978f43124..e658c3833d 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php @@ -62,7 +62,7 @@ class MailInfoPushReceived extends AbstractMailWithLink } return - $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName($this->app['translator'])]) + $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()]) . "\n" . $this->message; } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php index e81184ec11..057de54c78 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php @@ -54,7 +54,7 @@ class MailInfoValidationDone extends AbstractMailWithLink } return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', [ - '%user%' => $this->user->getDisplayName($this->app['translator']), + '%user%' => $this->user->getDisplayName(), '%title%' => $this->title, ]); } @@ -69,7 +69,7 @@ class MailInfoValidationDone extends AbstractMailWithLink } return $this->app->trans('%user% has just sent its validation report, you can now see it', [ - '%user%' => $this->user->getDisplayName($this->app['translator']), + '%user%' => $this->user->getDisplayName(), ]); } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php index 2d9b01365a..2aa87739c8 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php @@ -60,7 +60,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink throw new LogicException('You must set a title before calling getSubject'); } - return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName($this->app['translator']), '%title%' => $this->title]); + return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName(), '%title%' => $this->title]); } /** diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php index 1af2248243..740e5897df 100644 --- a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php @@ -1,5 +1,14 @@ add( - new Term($user->getDisplayName($this->app['translator']), '', $this, $user->getId()) + new Term($user->getDisplayName(), '', $this, $user->getId()) ); } @@ -98,7 +98,7 @@ class UserProvider implements ControlProviderInterface throw new \Exception('User unknown'); } - return $user->getDisplayName($this->app['translator']); + return $user->getDisplayName(); } /** diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index 7f84e28826..d306481223 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -1363,7 +1363,7 @@ class API_V1_adapter extends API_V1_Abstract $choices[] = [ 'validation_user' => [ 'usr_id' => $user->getId(), - 'usr_name' => $user->getDisplayName($this->app['translator']), + 'usr_name' => $user->getDisplayName(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), @@ -1778,7 +1778,7 @@ class API_V1_adapter extends API_V1_Abstract 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), 'name' => $basket->getName(), - 'pusher_usr_id' => $basket->getPusherId(), + 'pusher_usr_id' => $basket->getPusher()->getId(), 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation() @@ -1793,7 +1793,7 @@ class API_V1_adapter extends API_V1_Abstract $users[] = [ 'usr_id' => $user->getId(), - 'usr_name' => $user->getDisplayName($this->app['translator']), + 'usr_name' => $user->getDisplayName(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), @@ -1812,7 +1812,7 @@ class API_V1_adapter extends API_V1_Abstract 'validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()), - 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(), + 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser())->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()), ], $ret ); diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php index 312c340a64..241aa2cd6e 100644 --- a/lib/classes/eventsmanager/notify/autoregister.php +++ b/lib/classes/eventsmanager/notify/autoregister.php @@ -50,7 +50,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract $mailColl = []; try { - $rs = $this->app['phraseanet.native-query']->getAdminsOfBases(array_keys($base_ids)); + $rs = $this->app['EM.native-query']->getAdminsOfBases(array_keys($base_ids)); foreach ($rs as $row) { $user = $row[0]; @@ -129,7 +129,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract } $ret = [ - 'text' => $this->app->trans('%user% s\'est enregistre sur une ou plusieurs %before_link% scollections %after_link%', ['%user%' => $user->getDisplayName($this->app['translator']), '%before_link%' => '', '%after_link%' => '']) + 'text' => $this->app->trans('%user% s\'est enregistre sur une ou plusieurs %before_link% scollections %after_link%', ['%user%' => $user->getDisplayName(), '%before_link%' => '', '%after_link%' => '']) , 'class' => '' ]; diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php index 78710d8e98..3320e36825 100644 --- a/lib/classes/eventsmanager/notify/order.php +++ b/lib/classes/eventsmanager/notify/order.php @@ -140,7 +140,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); $ret = [ 'text' => $this->app->trans('%user% a passe une %opening_link% commande %end_link%', [ diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php index 11b189dbfe..1770a74a48 100644 --- a/lib/classes/eventsmanager/notify/orderdeliver.php +++ b/lib/classes/eventsmanager/notify/orderdeliver.php @@ -148,12 +148,12 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); try { $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); + $basket = $repository->findUserBasket($ssel_id, $this->app['authentication']->getUser(), false); } catch (Exception $e) { return []; } diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php index e7e6530907..7e00b75a65 100644 --- a/lib/classes/eventsmanager/notify/ordernotdelivered.php +++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php @@ -111,7 +111,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); $ret = [ 'text' => $this->app->trans('%user% a refuse la livraison de %quantity% document(s) pour votre commande', ['%user%' => $sender, '%quantity%' => $n]) diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php index 93752575db..a9faa1ea28 100644 --- a/lib/classes/eventsmanager/notify/push.php +++ b/lib/classes/eventsmanager/notify/push.php @@ -123,7 +123,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); $ret = [ 'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => 'app->url('admin', ['section' => 'registrations']) . '" target="_blank">', '%after_link%' => '']) diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php index 95d1d1861a..a5d2ea32bd 100644 --- a/lib/classes/eventsmanager/notify/uploadquarantine.php +++ b/lib/classes/eventsmanager/notify/uploadquarantine.php @@ -74,7 +74,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract //Sender if (null !== $user = $lazaretFile->getSession()->getUser()) { $sender = $domXML->createElement('sender'); - $sender->appendChild($domXML->createTextNode($user->getDisplayName($this->app['translator']))); + $sender->appendChild($domXML->createTextNode($user->getDisplayName())); $root->appendChild($sender); $this->notifyUser($user, $datas); diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php index 01fd1e2e00..a1bb639794 100644 --- a/lib/classes/eventsmanager/notify/validate.php +++ b/lib/classes/eventsmanager/notify/validate.php @@ -141,7 +141,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); try { $basket = $this->app['converter.basket']->convert($ssel_id); diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php index b9da40a410..2281791891 100644 --- a/lib/classes/eventsmanager/notify/validationdone.php +++ b/lib/classes/eventsmanager/notify/validationdone.php @@ -135,12 +135,12 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract return []; } - $sender = $registered_user->getDisplayName($this->app['translator']); + $sender = $registered_user->getDisplayName(); try { $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); + $basket = $repository->findUserBasket($ssel_id, $this->app['authentication']->getUser(), false); } catch (Exception $e) { return []; } diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php index 9688998995..18758168cb 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.php +++ b/lib/classes/eventsmanager/notify/validationreminder.php @@ -140,7 +140,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra return []; } - $sender = $user->getDisplayName($this->app['translator']); + $sender = $user->getDisplayName(); try { $basket = $this->app['converter.basket']->convert($ssel_id); diff --git a/lib/classes/module/console/checkExtension.php b/lib/classes/module/console/checkExtension.php index b9017dc94b..993c8812eb 100644 --- a/lib/classes/module/console/checkExtension.php +++ b/lib/classes/module/console/checkExtension.php @@ -50,7 +50,7 @@ class module_console_checkExtension extends Command $output->writeln( sprintf( "\nWill do the check with user %s (%s)\n" - , $TestUser->getDisplayName($this->container['translator']) + , $TestUser->getDisplayName() , $TestUser->getEmail() ) ); diff --git a/lib/classes/module/report/activity.php b/lib/classes/module/report/activity.php index 57afa36d14..2fdef6aee9 100644 --- a/lib/classes/module/report/activity.php +++ b/lib/classes/module/report/activity.php @@ -295,7 +295,7 @@ class module_report_activity extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $login = $this->app['manipulator.user']->getRepository()->find($usr)->getDisplayName($this->app['translator']); + $login = $this->app['manipulator.user']->getRepository()->find($usr)->getDisplayName(); $this->setChamp($rs); diff --git a/lib/classes/module/report/add.php b/lib/classes/module/report/add.php index cea19ffc9d..2835f20e91 100644 --- a/lib/classes/module/report/add.php +++ b/lib/classes/module/report/add.php @@ -78,7 +78,7 @@ class module_report_add extends module_report $caption = $value; if ($field == "getter") { if (null !== $user = $this->app['manipulator.user']->getRepository()->find($value)) { - $caption = $user->getDisplayName($this->app['translator']); + $caption = $user->getDisplayName(); } } elseif ($field == 'date') $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); diff --git a/lib/classes/module/report/edit.php b/lib/classes/module/report/edit.php index e012eda51f..97b94320de 100644 --- a/lib/classes/module/report/edit.php +++ b/lib/classes/module/report/edit.php @@ -78,7 +78,7 @@ class module_report_edit extends module_report $caption = $value; if ($field == "getter") { if (null !== $user = $this->app['manipulator.user']->getRepository()->find($value)) { - $caption = $user->getDisplayName($this->app['translator']); + $caption = $user->getDisplayName(); } } elseif ($field == 'date') { $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); diff --git a/lib/classes/module/report/push.php b/lib/classes/module/report/push.php index 7a15034f00..fdae8ecc96 100644 --- a/lib/classes/module/report/push.php +++ b/lib/classes/module/report/push.php @@ -79,7 +79,7 @@ class module_report_push extends module_report $caption = $value; if ($field == "getter") { if (null !== $user = $this->app['manipulator.user']->getRepository()->find($value)) { - $caption = $user->getDisplayName($this->app['translator']); + $caption = $user->getDisplayName(); } } elseif ($field == 'date') { $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); diff --git a/lib/classes/module/report/sent.php b/lib/classes/module/report/sent.php index 7231bbec71..539841519b 100644 --- a/lib/classes/module/report/sent.php +++ b/lib/classes/module/report/sent.php @@ -79,7 +79,7 @@ class module_report_sent extends module_report $caption = $value; if ($field == "getter") { if (null !== $user = $this->app['manipulator.user']->getRepository()->find($value)) { - $caption = $user->getDisplayName($this->app['translator']); + $caption = $user->getDisplayName(); } } elseif ($field == 'date') { $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); diff --git a/lib/classes/module/report/validate.php b/lib/classes/module/report/validate.php index 1bc48a33ed..6063552db4 100644 --- a/lib/classes/module/report/validate.php +++ b/lib/classes/module/report/validate.php @@ -79,7 +79,7 @@ class module_report_validate extends module_report $caption = $value; if ($field == "getter") { if (null !== $user = $this->app['manipulator.user']->getRepository()->find($value)) { - $caption = $user->getDisplayName($this->app['translator']); + $caption = $user->getDisplayName(); } } elseif ($field == 'date') { $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); diff --git a/lib/classes/patch/320alpha4b.php b/lib/classes/patch/320alpha4b.php index 9d3b8076a6..109635ab42 100644 --- a/lib/classes/patch/320alpha4b.php +++ b/lib/classes/patch/320alpha4b.php @@ -99,7 +99,7 @@ class patch_320alpha4b implements patchInterface $entry = new FeedEntry(); $entry->setAuthorEmail($user->getEmail()); - $entry->setAuthorName($user->getDisplayName($app['translator'])); + $entry->setAuthorName($user->getDisplayName()); $entry->setFeed($feed); $entry->setPublisher($publishers->first()); $entry->setTitle($row['name']); @@ -187,11 +187,11 @@ class patch_320alpha4b implements patchInterface if ( ! array_key_exists($user_key, self::$feeds) || ! isset(self::$feeds[$user_key][$feed_key])) { if ($homelink == '1') - $title = $user->getDisplayName($app['translator']) . ' - ' . 'homelink Feed'; + $title = $user->getDisplayName() . ' - ' . 'homelink Feed'; elseif ($pub_restrict == '1') - $title = $user->getDisplayName($app['translator']) . ' - ' . 'private Feed'; + $title = $user->getDisplayName() . ' - ' . 'private Feed'; else - $title = $user->getDisplayName($app['translator']) . ' - ' . 'public Feed'; + $title = $user->getDisplayName() . ' - ' . 'public Feed'; $feed = new Feed(); $publisher = new FeedPublisher(); diff --git a/lib/classes/record/orderElement.php b/lib/classes/record/orderElement.php index 90d0260de1..1b372d7dda 100644 --- a/lib/classes/record/orderElement.php +++ b/lib/classes/record/orderElement.php @@ -54,7 +54,7 @@ class record_orderElement extends record_adapter if ($this->order_master_id) { $user = $this->app['manipulator.user']->getRepository()->find($this->order_master_id); - return $user->getDisplayName($this->app['translator']); + return $user->getDisplayName(); } return ''; diff --git a/lib/classes/set/export.php b/lib/classes/set/export.php index 3360f253c8..72cf34f837 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -57,7 +57,7 @@ class set_export extends set_abstract $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $sstid, $app['authentication']->getUser(), false); + $Basket = $repository->findUserBasket($sstid, $app['authentication']->getUser(), false); $this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d"); foreach ($Basket->getElements() as $basket_element) { diff --git a/lib/classes/set/exportftp.php b/lib/classes/set/exportftp.php index 2055746d64..a667d4a498 100644 --- a/lib/classes/set/exportftp.php +++ b/lib/classes/set/exportftp.php @@ -39,7 +39,7 @@ class set_exportftp extends set_export $text_mail_receiver = "Bonjour,\n" . "L'utilisateur " - . $this->app['authentication']->getUser()->getDisplayName($this->app['translator']) . " (login : " . $this->app['authentication']->getUser()->getLogin() . ") " + . $this->app['authentication']->getUser()->getDisplayName() . " (login : " . $this->app['authentication']->getUser()->getLogin() . ") " . "a fait un transfert FTP sur le serveur ayant comme adresse \"" . $host . "\" avec le login \"" . $login . "\" " . "et pour repertoire de destination \"" diff --git a/templates/mobile/api/auth/end_user_authorization.html.twig b/templates/mobile/api/auth/end_user_authorization.html.twig index 8879ccc436..c4f018345d 100644 --- a/templates/mobile/api/auth/end_user_authorization.html.twig +++ b/templates/mobile/api/auth/end_user_authorization.html.twig @@ -55,7 +55,7 @@ {% else %} {% if app['authentication'].getUser() is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %}
{% if app['authentication'].getUser() is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %}
{{ thumbnail.format100percent(record.get_preview()) }} {% if basket_element.getBasket().getValidation() %} - {% if basket_element.getBasket().getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} + {% if basket_element.getBasket().getValidation().getParticipant(app['authentication'].getUser()).getCanAgree() %}
- + - +
{% endif %} diff --git a/templates/mobile/lightbox/note_form.html.twig b/templates/mobile/lightbox/note_form.html.twig index 2305266399..0cedce20d1 100644 --- a/templates/mobile/lightbox/note_form.html.twig +++ b/templates/mobile/lightbox/note_form.html.twig @@ -19,7 +19,7 @@
+ {% if basket_element.getUserValidationDatas(app['authentication'].getUser()).getNote() == '' %}placeholder="Note"{% endif %}>{{basket_element.getUserValidationDatas(app['authentication'].getUser()).getNote()}}
diff --git a/templates/mobile/lightbox/sc_note.html.twig b/templates/mobile/lightbox/sc_note.html.twig index 7d1a0ba2c6..0114bd0b9d 100644 --- a/templates/mobile/lightbox/sc_note.html.twig +++ b/templates/mobile/lightbox/sc_note.html.twig @@ -7,7 +7,7 @@ {% endif %} - {{ validationDatas.getParticipant().getUser().getDisplayName(app['translator']) }} + {{ validationDatas.getParticipant().getUser().getDisplayName() }} {% if validationDatas.getNote() != '' %}

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

diff --git a/templates/mobile/lightbox/validate.html.twig b/templates/mobile/lightbox/validate.html.twig index 0caa81edec..5a6dc9463a 100644 --- a/templates/mobile/lightbox/validate.html.twig +++ b/templates/mobile/lightbox/validate.html.twig @@ -4,7 +4,7 @@ {% block javascript %} @@ -30,8 +30,8 @@
    {% for basket_element in basket.getElements() %}
  • - {% if basket_element.getBasket().getValidation() and basket_element.getBasket().getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} -
    + {% if basket_element.getBasket().getValidation() and basket_element.getBasket().getValidation().getParticipant(app['authentication'].getUser()).getCanAgree() %} +
    {% endif %} @@ -43,7 +43,7 @@
- {% if basket.getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} + {% if basket.getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser()).getCanAgree() %}
{% else %} {% if user is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %}
{% if user is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %}
- {% if selected_basket is not none and selected_basket.getPusher(app) is not none %} - {% set pusher_name = selected_basket.getPusher(app).getDisplayName(app['translator']) %} + {% if selected_basket is not none and selected_basket.getPusher() is not none %} + {% set pusher_name = selected_basket.getPusher().getDisplayName() %}
{% trans with {'%pusher_name%' : pusher_name} %}paniers:: panier emis par %pusher_name%{% endtrans %}
diff --git a/templates/web/lightbox/IE6/agreement_box.html.twig b/templates/web/lightbox/IE6/agreement_box.html.twig index 82c15c910d..0916bcb1e9 100644 --- a/templates/web/lightbox/IE6/agreement_box.html.twig +++ b/templates/web/lightbox/IE6/agreement_box.html.twig @@ -18,7 +18,7 @@
{% endif %} - {% if basket_element and basket_element.getBasket().getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} + {% if basket_element and basket_element.getBasket().getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser()).getCanAgree() %}
{% endif %} - {% if basket.getPusher(app) %} + {% if basket.getPusher() %}
- {% set agreement = basket_element.getUserValidationDatas(app['authentication'].getUser(), app).getAgreement() %} + {% set agreement = basket_element.getUserValidationDatas(app['authentication'].getUser()).getAgreement() %}
{{ 'validation:: OUI' | trans }}
diff --git a/templates/web/lightbox/IE6/basket_options.html.twig b/templates/web/lightbox/IE6/basket_options.html.twig index 236b4d1f82..69a23f9c66 100644 --- a/templates/web/lightbox/IE6/basket_options.html.twig +++ b/templates/web/lightbox/IE6/basket_options.html.twig @@ -1,4 +1,4 @@ -{% if basket.getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} +{% if basket.getValidation() and basket.getValidation().getParticipant(app['authentication'].getUser()).getCanAgree() %}
  • - {{ token.getIdentity().getDisplayName(app['translator']) | default(token.getIdentity().getUserName()) }} + {{ token.getIdentity().getDisplayName() | default(token.getIdentity().getUserName()) }}
- {% set pusher = basket.getPusher(app).getDisplayName(app['translator']) %} + {% set pusher = basket.getPusher().getDisplayName() %} {% for choice in basket_element.getValidationDatas() %} - {% if basket.getValidation().getParticipant(app['authentication'].getUser(), app).getCanSeeOthers() or choice.getParticipant().getUser() == app['authentication'].getUser() %} + {% if basket.getValidation().getParticipant(app['authentication'].getUser()).getCanSeeOthers() or choice.getParticipant().getUser() == app['authentication'].getUser() %} - + {% for user in results %} - + diff --git a/templates/web/prod/actions/Push.html.twig b/templates/web/prod/actions/Push.html.twig index 9c7ad1e766..f5b31e4a7b 100644 --- a/templates/web/prod/actions/Push.html.twig +++ b/templates/web/prod/actions/Push.html.twig @@ -106,7 +106,7 @@ {% set recommendation = recommendation ~ ' ' ~ '' - ~ user.getDisplayName(app['translator']) + ~ user.getDisplayName() ~ '' %} {% endif %} {% endfor %} @@ -139,7 +139,7 @@ order.getDeadline() ? "style=color:#777": "" }}> - +
{{ choice.getParticipant().getUser().getDisplayName(app['translator']) }} {{ 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 7c81b03e4d..879be1a96d 100644 --- a/templates/web/prod/actions/Feedback/List-Share.html.twig +++ b/templates/web/prod/actions/Feedback/List-Share.html.twig @@ -29,7 +29,7 @@ - {{ owner.getUser().getDisplayName(app['translator']) }} + {{ owner.getUser().getDisplayName() }} diff --git a/templates/web/prod/actions/Feedback/ListsMacros.html.twig b/templates/web/prod/actions/Feedback/ListsMacros.html.twig index 5991687da5..f9cb7df138 100644 --- a/templates/web/prod/actions/Feedback/ListsMacros.html.twig +++ b/templates/web/prod/actions/Feedback/ListsMacros.html.twig @@ -57,7 +57,7 @@
{{ user.getLogin() }} @@ -188,7 +188,7 @@ - {{ entry.getUser().getDisplayName(app['translator']) }} + {{ entry.getUser().getDisplayName() }}
- {{ user.getDisplayName(app['translator']) }} + {{ user.getDisplayName() }} diff --git a/templates/web/prod/actions/publish/publish.html.twig b/templates/web/prod/actions/publish/publish.html.twig index 4a8bafd174..df6e92f4c3 100644 --- a/templates/web/prod/actions/publish/publish.html.twig +++ b/templates/web/prod/actions/publish/publish.html.twig @@ -46,7 +46,7 @@ - + diff --git a/templates/web/prod/orders/order_box.html.twig b/templates/web/prod/orders/order_box.html.twig index 8a8d4b883d..23b69a1548 100644 --- a/templates/web/prod/orders/order_box.html.twig +++ b/templates/web/prod/orders/order_box.html.twig @@ -42,7 +42,7 @@ {% for order in orders %} {% set deadline = app['date-formatter'].getPrettyString(order.getDeadline()) %}
{{ order.getUser().getDisplayName(app['translator']) }}{{ 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 a0df51ba78..e685badf0a 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().getDisplayName(app['translator']) %} +{% set displayName = order.getUser().getDisplayName() %}