diff --git a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php index 6f43ca21ad..0d6d1859a9 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php +++ b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php @@ -61,7 +61,7 @@ class RegenerateSqliteDb extends Command if (is_file($source)) { $renamed = true; - $fs->rename($source, $target); + $fs->rename($source, $target, true); } try { @@ -92,10 +92,11 @@ class RegenerateSqliteDb extends Command $this->insertLazaretFiles($this->container['EM'], $DI); $this->insertAuthFailures($this->container['EM'], $DI); - $fixtures['user']['test_phpunit'] = $DI['user']->get_id(); - $fixtures['user']['test_phpunit_not_admin'] = $DI['user_notAdmin']->get_id(); - $fixtures['user']['test_phpunit_alt1'] = $DI['user_alt1']->get_id(); - $fixtures['user']['test_phpunit_alt2'] = $DI['user_alt2']->get_id(); + $fixtures['user']['test_phpunit'] = $DI['user']->getId(); + $fixtures['user']['test_phpunit_not_admin'] = $DI['user_notAdmin']->getId(); + $fixtures['user']['test_phpunit_alt1'] = $DI['user_alt1']->getId(); + $fixtures['user']['test_phpunit_alt2'] = $DI['user_alt2']->getId(); + $fixtures['user']['user_guest'] = $DI['user_guest']->getId(); $fixtures['oauth']['user'] = $DI['app-user']->get_id(); $fixtures['oauth']['user_notAdmin'] = $DI['app-user_notAdmin']->get_id(); @@ -134,9 +135,7 @@ class RegenerateSqliteDb extends Command } catch (\Exception $e) { $output->writeln("".$e->getMessage().""); if ($renamed) { - if (is_file($source)) { - unlink($source); - } + $fs->remove($source); $fs->rename($target, $source); } throw $e; @@ -145,11 +144,6 @@ class RegenerateSqliteDb extends Command $fs->remove($target); $fs->dumpFile($json, json_encode($fixtures, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); - $this->container['manipulator.user']->createUser('test_phpunit', 'test_phpunit', 'noone@example.com', true); - $this->container['manipulator.user']->createUser('test_phpunit_not_admin', 'test_phpunit_not_admin', 'noone_not_admin@example.com'); - $this->container['manipulator.user']->createUser('test_phpunit_alt1', 'test_phpunit_alt1', 'noonealt1@example.com'); - $this->container['manipulator.user']->createUser('test_phpunit_alt2', 'test_phpunit_alt2', 'noonealt2@example.com'); - return 0; } @@ -210,6 +204,7 @@ class RegenerateSqliteDb extends Command $DI['user_alt1'] = $this->getUserAlt1(); $DI['user_alt2'] = $this->getUserAlt2(); $DI['user_notAdmin'] = $this->getUserNotAdmin(); + $DI['user_guest'] = $this->getUserGuest(); $user1 = $this->insertOneUser('user1'); $user2 = $this->insertOneUser('user2', 'user2@phraseanet.com'); @@ -327,44 +322,53 @@ class RegenerateSqliteDb extends Command private function getUser() { - if (false === $usr_id = \User_Adapter::get_usr_id_from_login($this->container, 'test_phpunit')) { - return \User_Adapter::create($this->container, 'test_phpunit', \random::generatePassword(), 'noone@example.com', false); + if (null === $user = $this->container['manipulator.user']->getRepository()->findByLogin('test_phpunit')) { + $user = $this->container['manipulator.user']->createUser('test_phpunit', \random::generatePassword(), 'noone@example.com', true); } - return \User_Adapter::getInstance($usr_id, $this->container); + return $user; } private function getUserAlt1() { - if (false === $usr_id = \User_Adapter::get_usr_id_from_login($this->container, 'test_phpunit_alt1')) { - return \User_Adapter::create($this->container, 'test_phpunit_alt1', \random::generatePassword(), 'noonealt1@example.com', false); + if (null === $user = $this->container['manipulator.user']->getRepository()->findByLogin('test_phpunit_alt1')) { + $user = $this->container['manipulator.user']->createUser('test_phpunit_alt1', \random::generatePassword(), 'noonealt1@example.com', false); } - return \User_Adapter::getInstance($usr_id, $this->container); + return $user; } private function getUserAlt2() { - if (false === $usr_id = \User_Adapter::get_usr_id_from_login($this->container, 'test_phpunit_alt2')) { - return \User_Adapter::create($this->container, 'test_phpunit_alt2', \random::generatePassword(), 'noonealt2@example.com', false); + if (null === $user = $this->container['manipulator.user']->getRepository()->findByLogin('test_phpunit_alt2')) { + $user = $this->container['manipulator.user']->createUser('test_phpunit_alt2', \random::generatePassword(), 'noonealt2@example.com', false); } - return \User_Adapter::getInstance($usr_id, $this->container); + return $user; } public function getUserNotAdmin() { - if (false === $usr_id = \User_Adapter::get_usr_id_from_login($this->container, 'test_phpunit_not_admin')) { - return \User_Adapter::create($this->container, 'test_phpunit_not_admin', \random::generatePassword(), 'noone_not_admin@example.com', false); + if (null === $user = $this->container['manipulator.user']->getRepository()->findByLogin('test_phpunit_not_admin')) { + $user = $this->container['manipulator.user']->createUser('test_phpunit_not_admin', \random::generatePassword(), 'noone_not_admin@example.com', false); } - return \User_Adapter::getInstance($usr_id, $this->container); + return $user; + } + + public function getUserGuest() + { + if (null === $user = $this->container['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) { + $user = $this->container['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST); + } + + return $user; } private function insertTwoBasket(EntityManager $em, \Pimple $DI) { $basket1 = new Basket(); - $basket1->setOwner($this->getUser()); + $basket1->setUser($this->getUser()); $basket1->setName('test'); $basket1->setDescription('description test'); @@ -374,12 +378,12 @@ class RegenerateSqliteDb extends Command $element->setBasket($basket1); $basket2 = new Basket(); - $basket2->setOwner($this->getUser()); + $basket2->setUser($this->getUser()); $basket2->setName('test'); $basket2->setDescription('description test'); $basket3 = new Basket(); - $basket3->setOwner($this->getUserAlt1()); + $basket3->setUser($this->getUserAlt1()); $basket3->setName('test'); $basket3->setDescription('description test'); @@ -391,7 +395,7 @@ class RegenerateSqliteDb extends Command $basket4 = new Basket(); $basket4->setName('test'); $basket4->setDescription('description'); - $basket4->setOwner($this->getUser()); + $basket4->setUser($this->getUser()); foreach ([$DI['record_1'], $DI['record_2']] as $record) { $basketElement = new BasketElement(); @@ -495,7 +499,7 @@ class RegenerateSqliteDb extends Command $user = $DI['user']; - $publisher->setUsrId($user->get_id()); + $publisher->setUser($user); $publisher->setIsOwner(true); $publisher->setFeed($feed); @@ -518,7 +522,7 @@ class RegenerateSqliteDb extends Command $user = $DI['user']; - $publisher->setUsrId($user->get_id()); + $publisher->setUser($user); $publisher->setIsOwner(true); $publisher->setFeed($feed); @@ -541,7 +545,7 @@ class RegenerateSqliteDb extends Command $user = $DI['user_alt1']; - $publisher->setUsrId($user->get_id()); + $publisher->setUser($user); $publisher->setIsOwner(true); $publisher->setFeed($feed); @@ -585,7 +589,7 @@ class RegenerateSqliteDb extends Command $token = new FeedToken(); $token->setValue($this->container['tokens']->generatePassword(12)); $token->setFeed($feed); - $token->setUsrId($DI['user']->get_id()); + $token->setUser($DI['user']); $feed->addToken($token); @@ -599,7 +603,7 @@ class RegenerateSqliteDb extends Command $token = new AggregateToken(); $token->setValue($this->container['tokens']->generatePassword(12)); - $token->setUsrId($user->get_id()); + $token->setUser($user); $em->persist($token); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index 5f3632c103..2eb6f1dcd3 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -14,8 +14,6 @@ namespace Alchemy\Phrasea\Controller\Admin; use Alchemy\Phrasea\Helper\User as UserHelper; use Alchemy\Phrasea\Model\Entities\FtpCredential; use Alchemy\Phrasea\Model\Entities\User; -use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\ORM\Query\ResultSetMappingBuilder; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; @@ -245,7 +243,7 @@ class Users implements ControllerProviderInterface $datas[] = [ 'email' => $user->getEmail() ? : '' , 'login' => $user->getLogin() ? : '' - , 'name' => $user->getDisplayName() ? : '' + , 'name' => $user->getDisplayName($app['translator']) ? : '' , 'id' => $user->getId() ]; } @@ -364,34 +362,17 @@ class Users implements ControllerProviderInterface $basList = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canadmin'])); $models = $app['manipulator.user']->getRepository()->findModelOf($app['authentication']->getUser()); - $rsm = new ResultSetMappingBuilder($app['EM']); - $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); - $rsm->addScalarResult('date_demand', 'date_demand'); - $rsm->addScalarResult('base_demand', 'base_demand'); - - $selectClause = $rsm->generateSelectClause(); - - $query = $app['EM']->createNativeQuery(" - SELECT d.date_modif AS date_demand, d.base_id AS base_demand, " . $selectClause . " - FROM (demand d INNER JOIN Users u ON d.usr_id=u.id - AND d.en_cours=1 - AND u.deleted=0 - ) - WHERE (base_id='" . implode("' OR base_id='", $basList) . "') - ORDER BY d.usr_id DESC, d.base_id ASC - ", $rsm); - $currentUsr = null; $table = ['users' => [], 'coll' => []]; - foreach ($query->getResult() as $row) { + foreach ($app['phraseanet.native-query']->getUsersRegistrationDemand($basList) as $row) { $user = $row[0]; if ($user->getId() !== $currentUsr) { $currentUsr = $user->getId(); $table['users'][$currentUsr] = [ 'user' => $user, - 'date_demand' => new \DateTime($row['date_demand']), + 'date_demand' => $row['date_demand'], ]; } @@ -547,8 +528,8 @@ class Users implements ControllerProviderInterface foreach ($done as $usr => $bases) { $acceptColl = $denyColl = []; - if (null === $user = $app['manipulator.user']->getRepository()->find($usr)) { - if (\Swift_Validate::email($user.getEmail())) { + if (null !== $user = $app['manipulator.user']->getRepository()->find($usr)) { + if (\Swift_Validate::email($user->getEmail())) { foreach ($bases as $bas => $isok) { if ($isok) { $acceptColl[] = \phrasea::bas_labels($bas, $app); @@ -565,7 +546,7 @@ class Users implements ControllerProviderInterface $message .= "\n" . $app->trans('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . implode(', ', $denyColl) . "\n"; } - $receiver = new Receiver(null, $row['usr_mail']); + $receiver = new Receiver(null, $user->getEmail()); $mail = MailSuccessEmailUpdate::create($app, $receiver, null, $message); $app['notification.deliverer']->deliver($mail); @@ -710,22 +691,8 @@ class Users implements ControllerProviderInterface ]); } - $rsm = new ResultSetMappingBuilder($app['EM']); - $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); - - $selectClause = $rsm->generateSelectClause(); - - $query = $app['EM']->createNativeQuery(" - SELECT " . $selectClause . " - FROM Users u - INNER JOIN basusr b ON (b.usr_id=u.id) - WHERE u.model_of = :user_id - AND b.base_id IN (" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))) . ") - AND u.deleted='0' - GROUP BY u.id" - ); - $query->setParameter(':user_id', $app['authentication']->getUser()->getId()); - $models = $query->getResult(); + $basList = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage'])); + $models = $app['phraseanet.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/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index 36d32fe81b..918699b7b3 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -248,7 +248,7 @@ class Edit implements ControllerProviderInterface $query = $request->query->get('query'); - $results = $VC->find($query, $app['authentication']->getUser(), $databox); + $results = $VC->find($query, $app['authentication']->getUser(), $app['translator'], $databox); $list = []; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index 51d617b63c..91b93f2618 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['authentication']->getUser()->getEmail()); + $emitter = new Emitter($app['authentication']->getUser()->getDisplayName($app['translator']), $app['authentication']->getUser()->getEmail()); foreach ($destMails as $key => $mail) { try { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index a56353c820..49861f4404 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -29,9 +29,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Push implements ControllerProviderInterface { - protected function getUserFormatter() + protected function getUserFormatter(Application $app) { - return function (User $user) { + return function (User $user) use ($app) { $subtitle = array_filter([$user->getJob(), $user->getCompany()]); return [ @@ -40,7 +40,7 @@ class Push implements ControllerProviderInterface , 'firstname' => $user->getFirstName() , 'lastname' => $user->getLastName() , 'email' => $user->getEmail() - , 'display_name' => $user->getDisplayName() + , 'display_name' => $user->getDisplayName($app['translator']) , 'subtitle' => implode(', ', $subtitle) ]; }; @@ -48,7 +48,7 @@ class Push implements ControllerProviderInterface protected function getListFormatter($app) { - $userFormatter = $this->getUserFormatter(); + $userFormatter = $this->getUserFormatter($app); return function (UsrList $List) use ($userFormatter, $app) { $entries = []; @@ -109,7 +109,7 @@ class Push implements ControllerProviderInterface $app['firewall']->requireRight('push'); }); - $userFormatter = $this->getUserFormatter(); + $userFormatter = $this->getUserFormatter($app); $listFormatter = $this->getListFormatter($app); @@ -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()])); + $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName($app['translator'])])); $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() + , 'to_name' => $user_receiver->getDisplayName($app['translator']) , '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()])); + $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName($app['translator'])])); $validation_description = $request->request->get('validation_description'); $participants = $request->request->get('participants'); @@ -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(), + 'to_name' => $participant_user->getDisplayName($app['translator']), '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 f5973e9fb0..88f21659ea 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -91,24 +91,24 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getOwners() as $owner) { $owners[] = [ - 'usr_id' => $owner->getUser($app)->getId(), - 'display_name' => $owner->getUser($app)->getDisplayName(), - 'position' => $owner->getUser($app)->getActivity(), - 'job' => $owner->getUser($app)->getJob(), - 'company' => $owner->getUser($app)->getCompany(), - 'email' => $owner->getUser($app)->getEmail(), + 'usr_id' => $owner->getUser()->getId(), + 'display_name' => $owner->getUser()->getDisplayName($app['translator']), + 'position' => $owner->getUser()->getActivity(), + 'job' => $owner->getUser()->getJob(), + 'company' => $owner->getUser()->getCompany(), + 'email' => $owner->getUser()->getEmail(), 'role' => $owner->getRole() ]; } foreach ($list->getEntries() as $entry) { $entries[] = [ - 'usr_id' => $owner->getUser($app)->getId(), - 'display_name' => $owner->getUser($app)->getDisplayName(), - 'position' => $owner->getUser($app)->getActivity(), - 'job' => $owner->getUser($app)->getJob(), - 'company' => $owner->getUser($app)->getCompany(), - 'email' => $owner->getUser($app)->getEmail(), + 'usr_id' => $entry->getUser()->getId(), + 'display_name' => $entry->getUser()->getDisplayName($app['translator']), + 'position' => $entry->getUser()->getActivity(), + 'job' => $entry->getUser()->getJob(), + 'company' => $entry->getUser()->getCompany(), + 'email' => $entry->getUser()->getEmail(), ]; } @@ -202,24 +202,24 @@ class UsrLists implements ControllerProviderInterface foreach ($list->getOwners() as $owner) { $owners[] = [ - 'usr_id' => $owner->getUser($app)->getId(), - 'display_name' => $owner->getUser($app)->getDisplayName(), - 'position' => $owner->getUser($app)->getActivity(), - 'job' => $owner->getUser($app)->getJob(), - 'company' => $owner->getUser($app)->getCompany(), - 'email' => $owner->getUser($app)->getEmail(), - 'role' => $owner->getRole($app) + 'usr_id' => $owner->getUser()->getId(), + 'display_name' => $owner->getUser()->getDisplayName($app['translator']), + 'position' => $owner->getUser()->getActivity(), + 'job' => $owner->getUser()->getJob(), + 'company' => $owner->getUser()->getCompany(), + 'email' => $owner->getUser()->getEmail(), + 'role' => $owner->getRole() ]; } foreach ($list->getEntries() as $entry) { $entries[] = [ - 'usr_id' => $entry->getUser($app)->getId(), - 'display_name' => $entry->getUser($app)->getDisplayName(), - 'position' => $entry->getUser($app)->getActivity(), - 'job' => $entry->getUser($app)->getJob(), - 'company' => $entry->getUser($app)->getCompany(), - 'email' => $entry->getUser($app)->getEmail(), + 'usr_id' => $entry->getUser()->getId(), + 'display_name' => $entry->getUser()->getDisplayName($app['translator']), + 'position' => $entry->getUser()->getActivity(), + 'job' => $entry->getUser()->getJob(), + 'company' => $entry->getUser()->getCompany(), + 'email' => $entry->getUser()->getEmail(), ]; } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index b5c967119c..78d1ced4f6 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -143,7 +143,7 @@ class Account implements ControllerProviderInterface $url = $app->url('account_reset_email', ['token' => $token]); try { - $receiver = Receiver::fromUser($app['authentication']->getUser()); + $receiver = Receiver::fromUser($app['authentication']->getUser(), $app['translator']); } catch (InvalidArgumentException $e) { $app->addFlash('error', $app->trans('phraseanet::erreur: echec du serveur de mail')); @@ -331,11 +331,9 @@ class Account implements ControllerProviderInterface $demands = (array) $request->request->get('demand', []); if (0 !== count($demands)) { - $register = new \appbox_register($app['phraseanet.appbox']); - foreach ($demands as $baseId) { try { - $register->add_request($app['authentication']->getUser(), \collection::get_from_base_id($app, $baseId)); + $app['phraseanet.appbox-register']->add_request($app['authentication']->getUser(), \collection::get_from_base_id($app, $baseId)); $app->addFlash('success', $app->trans('login::notification: Vos demandes ont ete prises en compte')); } catch (\Exception $e) { @@ -412,11 +410,7 @@ class Account implements ControllerProviderInterface foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->getId()) as $notifications) { foreach ($notifications as $notification) { - if (isset($requestedNotifications[$notification['id']])) { - $app['authentication']->getUser()->set_notification_preference($app, $notification['id'], '1'); - } else { - $app['authentication']->getUser()->set_notification_preference($app, $notification['id'], '0'); - } + $app['manipulator.user']->setNotificationSetting($app['authentication']->getUser(), $notification['id'], isset($requestedNotifications[$notification['id']])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 4303abd86b..5f9d1a73cc 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -410,15 +410,13 @@ class Login implements ControllerProviderInterface $autoReg = $app['acl']->get($user)->get_granted_base(); - $appbox_register = new \appbox_register($app['phraseanet.appbox']); - foreach ($inscOK as $base_id => $autorisation) { if (false === $autorisation || $app['acl']->get($user)->has_access_to_base($base_id)) { continue; } $collection = \collection::get_from_base_id($app, $base_id); - $appbox_register->add_request($user, $collection); + $app['phraseanet.appbox-register']->add_request($user, $collection); $demandOK[$base_id] = true; } @@ -524,7 +522,7 @@ class Login implements ControllerProviderInterface */ private function sendAccountUnlockEmail(PhraseaApplication $app, User $user) { - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $app['translator']); $expire = new \DateTime('+3 days'); $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->getId(), $expire, $user->getEmail()); @@ -559,9 +557,7 @@ class Login implements ControllerProviderInterface return $app->redirectPath('homepage'); } - try { - $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id']); - } catch (\Exception $e) { + if (null === $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id'])) { $app->addFlash('error', _('Invalid unlock link.')); return $app->redirectPath('homepage'); @@ -577,7 +573,7 @@ class Login implements ControllerProviderInterface $user->setMailLocked(false); try { - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $app['translator']); } catch (InvalidArgumentException $e) { $app->addFlash('success', $app->trans('Account has been unlocked, you can now login.')); @@ -662,14 +658,12 @@ class Login implements ControllerProviderInterface if ($form->isValid()) { $data = $form->getData(); - try { - $user = $app['manipulator.user']->getRepository()->findByEmail($data['email']); - } catch (\Exception $e) { + if (null === $user = $app['manipulator.user']->getRepository()->findByEmail($data['email'])) { throw new FormProcessingException(_('phraseanet::erreur: Le compte n\'a pas ete trouve')); } try { - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $app['translator']); } catch (InvalidArgumentException $e) { throw new FormProcessingException($app->trans('Invalid email address')); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index f4dab81e61..c9a04e43f3 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -55,7 +55,7 @@ class RSSFeeds implements ControllerProviderInterface $page = $page < 1 ? 1 : $page; return $app['feed.formatter-strategy']($format) - ->createResponse($app, $token->getFeed(), $page, $app['manipulator.user']->getRepository()->find($token->getUsrId())); + ->createResponse($app, $token->getFeed(), $page, $token->getUser()); }) ->bind('feed_user') ->assert('id', '\d+') diff --git a/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php b/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php index 040e4b1a26..377e55d202 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php @@ -101,14 +101,14 @@ class DisplaySettingService * * @return mixed */ - public function getUserNotificationSetting(User $user, $name, $default = false) + public function getUserNotificationSetting(User $user, $name, $default = true) { if (false === $user->getNotificationSettings()->containsKey($name)) { return $default; } - return $user->getUserNotificationSetting()->get($name)->getValue(); + return $user->getNotificationSettings()->get($name)->getValue(); } /** diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php index 9600537910..7b460b646b 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php @@ -12,6 +12,7 @@ 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; @@ -38,6 +39,14 @@ class PhraseanetServiceProvider implements ServiceProviderInterface $app['acl'] = $app->share(function (SilexApplication $app) { 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']); + }); } public function boot(SilexApplication $app) diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index 7a2e720f51..b81d86b800 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -30,8 +30,8 @@ class Prod extends Helper return $search_datas; } - $searchSet = json_decode($this->app['authentication']->getUser()->getPrefs('search'), true); - $saveSettings = $this->app['authentication']->getUser()->getPrefs('advanced_search_reload'); + $searchSet = json_decode($this->app['settings']->getUserSetting($this->app['authentication']->getUser(), 'search'), true); + $saveSettings = $this->app['settings']->getUserSetting($this->app['authentication']->getUser(), 'advanced_search_reload'); foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index 6efd77aefb..406f98bed0 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -154,7 +154,7 @@ class Manage extends Helper $receiver = null; try { - $receiver = Receiver::fromUser($createdUser); + $receiver = Receiver::fromUser($createdUser, $this->app['translator']); } catch (InvalidArgumentException $e) { } diff --git a/lib/Alchemy/Phrasea/Model/Entities/Basket.php b/lib/Alchemy/Phrasea/Model/Entities/Basket.php index 4e17ada07b..0eebb810ad 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Basket.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Basket.php @@ -234,7 +234,7 @@ class Basket public function getPusher(Application $app) { if ($this->getPusherId()) { - return $this->pusher = $app['EM']->find('Alchemy\Phrasea\Model\Entities\User', $this->getPusherId()); + return $app['manipulator.user']->getRepository()->find($this->getPusherId()); } } diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php index 93d99412e9..2f32c8a6e7 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php @@ -268,9 +268,9 @@ class ValidationSession } } 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(), '%n%' => count($this->getParticipants()) - 1]); + 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]); } else { - return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->getDisplayName()]); + return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->getDisplayName($app['translator'])]); } } } @@ -288,6 +288,6 @@ class ValidationSession } } - throw new NotFoundHttpException('Participant not found' . $user->get_email()); + throw new NotFoundHttpException('Participant not found' . $user->getEmail()); } } diff --git a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php index 61b7fd822a..c352812542 100644 --- a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php +++ b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Model\Manager; use Doctrine\Common\Persistence\ObjectManager; use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\UserSetting; +use Doctrine\ORM\UnitOfWork AS UOW; class UserManager { @@ -159,6 +160,21 @@ class UserManager } } + /** + * Removes user orders. + * + * @param User $user + */ + private function cleanUserSessions(User $user) + { + $sessions = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\Session') + ->findByUser(['user' => $user->getId()]); + + foreach ($sessions as $session) { + $this->objectManager->remove($session); + } + } + /** * Removes user providers. * @@ -196,6 +212,7 @@ class UserManager $this->cleanOrders($user); $this->cleanFtpExports($user); $this->cleanAuthProvider($user); + $this->cleanUserSessions($user); } /** diff --git a/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php b/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php new file mode 100644 index 0000000000..7bed0ee892 --- /dev/null +++ b/lib/Alchemy/Phrasea/Model/NativeQueryProvider.php @@ -0,0 +1,94 @@ +em = $em; + } + + public function getUsersRegistrationDemand(array $basList) + { + $rsm = new ResultSetMappingBuilder($this->em); + $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); + $rsm->addScalarResult('date_demand', 'date_demand'); + $rsm->addScalarResult('base_demand', 'base_demand'); + + $selectClause = $rsm->generateSelectClause(); + + return $this->em->createNativeQuery(" + SELECT d.date_modif AS date_demand, d.base_id AS base_demand, " . $selectClause . " + FROM (demand d INNER JOIN Users u ON d.usr_id=u.id + AND d.en_cours=1 + AND u.deleted=0 + ) + WHERE (base_id='" . implode("' OR base_id='", $basList) . "') + ORDER BY d.usr_id DESC, d.base_id ASC + ", $rsm) + ->getResult(); + } + + public function getModelForUser(User $user, array $basList) + { + debug_print_backtrace(10); + echo __METHOD__; + exit; + $rsm = new ResultSetMappingBuilder($this->em); + $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); + + $selectClause = $rsm->generateSelectClause(); + + $query = $this->em->createNativeQuery(" + SELECT " . $selectClause . " + FROM Users u + INNER JOIN basusr b ON (b.usr_id=u.id) + WHERE u.model_of = :user_id + AND b.base_id IN (" . implode(', ', $basList) . ") + AND u.deleted='0' + GROUP BY u.id", $rsm); + + $query->setParameter(':user_id', $user->getId()); + + return $query->getResult(); + } + + public function getAdminsOfBases(array $basList) + { + debug_print_backtrace(10); + echo __METHOD__; + exit; + $rsm = new ResultSetMappingBuilder($this->em); + $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); + $rsm->addScalarResult('base_id', 'base_id'); + $selectClause = $rsm->generateSelectClause(); + + $query = $this->em->createNativeQuery(' + SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b + WHERE u.id = b.usr_id + AND b.base_id IN (' . implode(', ', $basList) . ') + AND u.model_of IS NULL + AND b.actif="1" + AND b.canadmin="1" + AND u.deleted="0"', $rsm + ); + + return $query->getResults(); + } +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php index daec4ddd7d..4df8e69479 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php @@ -56,7 +56,7 @@ class OrderRepository extends EntityRepository } if ($sort === 'user') { - $qb->orderBy('o.userId', 'ASC'); + $qb->orderBy('o.user', 'ASC'); } elseif ($sort === 'usage') { $qb->orderBy('o.orderUsage', 'ASC'); } else { diff --git a/lib/Alchemy/Phrasea/Model/Repositories/SessionRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/SessionRepository.php index f2f1befa29..16f92356dd 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/SessionRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/SessionRepository.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Model\Repositories; use Doctrine\ORM\EntityRepository; +use Alchemy\Phrasea\Model\Entities\User; /** * SessionRepository @@ -21,15 +22,4 @@ use Doctrine\ORM\EntityRepository; */ class SessionRepository extends EntityRepository { - public function findByUser(\User_Adapter $user) - { - $dql = 'SELECT s - FROM Phraseanet:Session s - WHERE s.usr_id = :usr_id'; - - $query = $this->_em->createQuery($dql); - $query->setParameters(['usr_id' => $user->get_id()]); - - return $query->getResult(); - } } diff --git a/lib/Alchemy/Phrasea/Notification/Emitter.php b/lib/Alchemy/Phrasea/Notification/Emitter.php index 868182a734..dc00a7686a 100644 --- a/lib/Alchemy/Phrasea/Notification/Emitter.php +++ b/lib/Alchemy/Phrasea/Notification/Emitter.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Notification; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Entities\User; +use Symfony\Component\Translation\TranslatorInterface; class Emitter implements EmitterInterface { @@ -54,8 +55,8 @@ class Emitter implements EmitterInterface * * @throws InvalidArgumentException In case no valid email is found for user */ - public static function fromUser(User $user) + public static function fromUser(User $user, TranslatorInterface $translator) { - return new static($user->getDisplayName(), $user->getEmail()); + return new static($user->getDisplayName($translator), $user->getEmail()); } } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php index c56b901d14..823830cf43 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()]); + return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName($this->app['translator'])]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php index a8da22facb..76a35d67af 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(), + '%user%' => $this->deliverer->getDisplayName($this->app['translator']), '%quantity%' => $this->quantity, ]); } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php index a976be10a2..da3bbf2232 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()]); + 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'])]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php index e658c3833d..c978f43124 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->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName($this->app['translator'])]) . "\n" . $this->message; } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php index 057de54c78..e81184ec11 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(), + '%user%' => $this->user->getDisplayName($this->app['translator']), '%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(), + '%user%' => $this->user->getDisplayName($this->app['translator']), ]); } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php index 2aa87739c8..2d9b01365a 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(), '%title%' => $this->title]); + return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName($this->app['translator']), '%title%' => $this->title]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Receiver.php b/lib/Alchemy/Phrasea/Notification/Receiver.php index e3671c882c..44d1836aa9 100644 --- a/lib/Alchemy/Phrasea/Notification/Receiver.php +++ b/lib/Alchemy/Phrasea/Notification/Receiver.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Notification; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Entities\User; +use Symfony\Component\Translation\TranslatorInterface; class Receiver implements ReceiverInterface { @@ -54,8 +55,8 @@ class Receiver implements ReceiverInterface * * @throws InvalidArgumentException In case no valid email is found for user */ - public static function fromUser(User $user) + public static function fromUser(User $user, TranslatorInterface $translator) { - return new static($user->getDisplayName(), $user->getEmail()); + return new static($user->getDisplayName($translator), $user->getEmail()); } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineSubscriber.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineSubscriber.php index 4c5ee6bd00..0f49bb180d 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineSubscriber.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineSubscriber.php @@ -48,7 +48,7 @@ class PhraseaEngineSubscriber implements EventSubscriberInterface $initialized = false; foreach ($rows as $row) { - $user = \User_Adapter::getInstance($row['usr_id'], $this->app); + $user = $this->app['manipulator.user']->getRepository()->find($row['usr_id']); $this->app['acl']->get($user)->inject_rights(); if (null !== $row['session_id']) { if (!$initialized) { diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index be54da7dae..a31c12478e 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -34,6 +34,7 @@ class Installer $this->createAB(); $this->populateRegistryData($serverName, $dataPath, $binaryData); $user = $this->createUser($email, $password); + $this->createDefaultUsers(); if (null !== $dbConn) { $this->createDB($dbConn, $template); } diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php index 3fe9cddf39..5d5bb704c8 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Vocabulary\ControlProvider; use Alchemy\Phrasea\Model\Entities\User; +use Symfony\Component\Translation\TranslatorInterface; interface ControlProviderInterface { @@ -51,9 +52,10 @@ interface ControlProviderInterface * * @param string $query A scalar quaery * @param User $for_user The user doing the query + * @param TranslatorInterface $translator * @param \databox $on_databox The databox where vocabulary should be requested * * @return Doctrine\Common\Collections\ArrayCollection */ - public function find($query, User $for_user, \databox $on_databox); + public function find($query, User $for_user, TranslatorInterface $translator, \databox $on_databox); } diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php index 6758126cf0..7e80ee2375 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php @@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\User; use Doctrine\Common\Collections\ArrayCollection; use Alchemy\Phrasea\Vocabulary\Term; +use Symfony\Component\Translation\TranslatorInterface; class UserProvider implements ControlProviderInterface { @@ -50,7 +51,7 @@ class UserProvider implements ControlProviderInterface * @param \databox $on_databox * @return \Doctrine\Common\Collections\ArrayCollection */ - public function find($query, User $for_user, \databox $on_databox = null) + public function find($query, User $for_user, TranslatorInterface $translator ,\databox $on_databox = null) { $user_query = new \User_Query($this->app); @@ -68,7 +69,7 @@ class UserProvider implements ControlProviderInterface foreach ($users as $user) { $results->add( - new Term($user->getDisplayName(), '', $this, $user->getId()) + new Term($user->getDisplayName($translator), '', $this, $user->getId()) ); } @@ -98,7 +99,7 @@ class UserProvider implements ControlProviderInterface throw new \Exception('User unknown'); } - return $user->getDisplayName(); + return $user->getDisplayName($this->app['translator']); } /** diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php index 9620615bd0..079f0d403e 100644 --- a/lib/classes/ACL.php +++ b/lib/classes/ACL.php @@ -114,11 +114,6 @@ class ACL implements cache_cacheableInterface return $this; } - public function set_app(Application $app) - { - $this->app = $app; - } - /** * Check if a hd grant has been received for a record * @@ -195,7 +190,6 @@ class ACL implements cache_cacheableInterface */ public function has_preview_grant(record_Interface $record) { - $this->load_hd_grant(); $key = $record->get_serialize_key(); @@ -757,7 +751,11 @@ class ACL implements cache_cacheableInterface public function set_admin($boolean) { - $this->app['manipulator.user']->promote($this->user); + if ($boolean) { + $this->app['manipulator.user']->promote($this->user); + } else { + $this->app['manipulator.user']->demote($this->user); + } return $this; } diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index 4e2da476b3..c90ba10584 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -1374,7 +1374,7 @@ class API_V1_adapter extends API_V1_Abstract $choices[] = [ 'validation_user' => [ 'usr_id' => $user->getId(), - 'usr_name' => $user->getDisplayName(), + 'usr_name' => $user->getDisplayName($this->app['translator']), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), @@ -1818,7 +1818,7 @@ class API_V1_adapter extends API_V1_Abstract $users[] = [ 'usr_id' => $user->getId(), - 'usr_name' => $user->getDisplayName(), + 'usr_name' => $user->getDisplayName($this->app['translator']), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php deleted file mode 100644 index 874f11b2b1..0000000000 --- a/lib/classes/User/Adapter.php +++ /dev/null @@ -1,917 +0,0 @@ - 'العربية' - , 'de' => 'Deutsch' - , 'nl' => 'Dutch' - , 'en' => 'English' - , 'es' => 'Español' - , 'fr' => 'Français' - ]; - - /** - * - * @var array - */ - protected static $_instance = []; - - /** - * - * @var array - */ - protected $_prefs = []; - - /** - * - * @var array - */ - protected $_updated_prefs = []; - - /** - * - * @var array - */ - public static $def_values = array( - 'view' => 'thumbs', - 'images_per_page' => 20, - 'images_size' => 120, - 'editing_images_size' => 134, - 'editing_top_box' => '180px', - 'editing_right_box' => '400px', - 'editing_left_box' => '710px', - 'basket_sort_field' => 'name', - 'basket_sort_order' => 'ASC', - 'warning_on_delete_story' => 'true', - 'client_basket_status' => '1', - 'css' => '000000', - 'advanced_search_reload' => '1', - 'start_page_query' => 'last', - 'start_page' => 'QUERY', - 'rollover_thumbnail' => 'caption', - 'technical_display' => '1', - 'doctype_display' => '1', - 'bask_val_order' => 'nat', - 'basket_caption_display' => '0', - 'basket_status_display' => '0', - 'basket_title_display' => '0' - ]; - - /** - * - * @var array - */ - protected static $available_values = [ - 'view' => ['thumbs', 'list'], - 'basket_sort_field' => ['name', 'date'], - 'basket_sort_order' => ['ASC', 'DESC'], - 'start_page' => ['PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'], - 'technical_display' => ['0', '1', 'group'], - 'rollover_thumbnail' => ['caption', 'preview'], - 'bask_val_order' => ['nat', 'asc', 'desc'] - ]; - - /** - * - * @var Application - */ - protected $app; - - /** - * - * @var int - */ - protected $id; - - /** - * - * @var string - */ - protected $email; - - /** - * - * @var string - */ - protected $login; - /** - * - * @var string - */ - protected $locale; - - /** - * - * @var string - */ - protected $firstname; - - /** - * - * @var string - */ - protected $lastname; - - /** - * - * @var string - */ - protected $address; - - /** - * - * @var string - */ - protected $city; - - /** - * - * @var int - */ - protected $geonameid; - - /** - * - * @var string - */ - protected $zip; - - /** - * - * @var int - */ - protected $gender; - - /** - * - * @var string - */ - protected $tel; - - /** - * - * @var int - */ - protected $lastModel; - - /** - * - * @var DateTime - */ - protected $creationdate; - - /** - * - * @var DateTime - */ - protected $modificationdate; - - /** - * - * @var string - */ - protected $fax; - - /** - * - * @var string - */ - protected $job; - - /** - * - * @var string - */ - protected $position; - - /** - * - * @var string - */ - protected $company; - - /** - * - * @var boolean - */ - protected $ldap_created; - - /** - * - * @var boolean - */ - protected $is_guest; - - /** - * - * @var boolean - */ - protected $mail_locked; - - /** - * - * @var FtpCredential - */ - protected $ftpCredential; - /** - * - * @var string - */ - protected $mail_notifications; - - /** - * - * @var string - */ - protected $country; - - /** - * - * @var boolean - */ - protected $is_template; - - /** - * - * @var User_Adapter - */ - protected $template_owner; - - protected $password; - - protected $preferences_loaded = false; - protected $notifications_preferences_loaded = false; - - /** - * - * @param Integer $id - * @param Application $app - * - * @return User_Adapter - */ - public function __construct($id, Application $app) - { - - $this->app = $app; - $this->load($id); - - return $this; - } - - public static function unsetInstances() - { - foreach (self::$_instance as $id => $user) { - self::unsetInstance($id); - } - } - - public static function unsetInstance($id) - { - if (isset(self::$_instance[$id])) { - self::$_instance[$id] = null; - unset(self::$_instance[$id]); - } - } - - /** - * - * @param type $id - * @param Application $app - * @return User_Adapter - */ - public static function getInstance($id, Application $app) - { - if (is_int((int) $id) && (int) $id > 0) { - $id = (int) $id; - } else - throw new Exception('Invalid usr_id'); - - if (!isset(self::$_instance[$id])) { - try { - self::$_instance[$id] = $app['phraseanet.appbox']->get_data_from_cache('_user_' . $id); - self::$_instance[$id]->set_app($app); - } catch (Exception $e) { - self::$_instance[$id] = new self($id, $app); - $app['phraseanet.appbox']->set_data_to_cache(self::$_instance[$id], '_user_' . $id); - } - } else { - self::$_instance[$id]->set_app($app); - } - - return array_key_exists($id, self::$_instance) ? self::$_instance[$id] : false; - } - - /** - * - * @param type $pasword - * @return User_Adapter - */ - public function set_password($pasword) - { - $sql = 'UPDATE usr SET usr_password = :password, salted_password = "1" - WHERE usr_id = :usr_id'; - - $password = $this->app['auth.password-encoder']->encodePassword($pasword, $this->get_nonce()); - - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':password' => $password, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $this->password = $password; - - return $this; - } - - /** - * - * @param string $email - * @return User_Adapter - */ - public function set_email($email) - { - if (trim($email) == '') { - $email = null; - } - - $test_user = User_Adapter::get_usr_id_from_email($this->app, $email); - - if ($test_user && $test_user != $this->get_id()) { - throw new Exception_InvalidArgument($this->app->trans('A user already exists with email addres %email%', ['%email%' => $email])); - } - - $sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':new_email' => $email, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->email = $email; - $this->delete_data_from_cache(); - - return $this; - } - - /** - * - * @param bollean $boolean - * @return User_Adapter - */ - public function set_mail_notifications($boolean) - { - $value = $boolean ? '1' : '0'; - $sql = 'UPDATE usr SET mail_notifications = :mail_notifications WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':mail_notifications' => $value, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->mail_notifications = !!$boolean; - $this->delete_data_from_cache(); - - return $this; - } - - /** - * - * @param boolean $boolean - * @return User_Adapter - */ - public function set_ldap_created($boolean) - { - $value = $boolean ? '1' : '0'; - $sql = 'UPDATE usr SET ldap_created = :ldap_created WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':ldap_created' => $value, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->ldap_created = $boolean; - - return $this; - } - - public function set_firstname($firstname) - { - $sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_prenom' => $firstname, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->firstname = $firstname; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_lastname($lastname) - { - $sql = 'UPDATE usr SET usr_nom = :usr_nom WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_nom' => $lastname, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->lastname = $lastname; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_address($address) - { - $sql = 'UPDATE usr SET adresse = :adresse WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':adresse' => $address, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->address = $address; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_city($city) - { - $sql = 'UPDATE usr SET ville = :city WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':city' => $city, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->city = $city; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_geonameid($geonameid) - { - $country_code = null; - - try { - $country = $this->app['geonames.connector'] - ->geoname($this->geonameid) - ->get('country'); - - if (isset($country['code'])) { - $country_code = $country['code']; - } - } catch (GeonamesExceptionInterface $e) { - - } - - $sql = 'UPDATE usr SET geonameid = :geonameid, pays=:country_code WHERE usr_id = :usr_id'; - - $datas = [ - ':geonameid' => $geonameid, - ':usr_id' => $this->get_id(), - ':country_code' => $country_code - ]; - - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute($datas); - $stmt->closeCursor(); - $this->geonameid = $geonameid; - $this->country = $country_code; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_zip($zip) - { - $sql = 'UPDATE usr SET cpostal = :cpostal WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':cpostal' => $zip, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->zip = $zip; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_gender($gender) - { - $sql = 'UPDATE usr SET usr_sexe = :usr_sexe WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_sexe' => $gender, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->gender = $gender; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_tel($tel) - { - $sql = 'UPDATE usr SET tel = :tel WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':tel' => $tel, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->tel = $tel; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_fax($fax) - { - $sql = 'UPDATE usr SET fax = :fax WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':fax' => $fax, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->fax = $fax; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_job($job) - { - $sql = 'UPDATE usr SET fonction = :fonction WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':fonction' => $job, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->job = $job; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_position($position) - { - $sql = 'UPDATE usr SET activite = :activite WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':activite' => $position, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->position = $position; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_company($company) - { - $sql = 'UPDATE usr SET societe = :company WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':company' => $company, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->company = $company; - $this->delete_data_from_cache(); - - return $this; - } - - public function set_template(User_Adapter $owner) - { - $this->is_template = true; - $this->template_owner = $owner; - - if ($owner->get_id() == $this->get_id()) - throw new Exception_InvalidArgument (); - - $sql = 'UPDATE usr SET model_of = :owner_id WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $this - ->set_city('') - ->set_company('') - ->set_email(null) - ->set_fax('') - ->set_firstname('') - ->set_gender('') - ->set_geonameid('') - ->set_job('') - ->set_lastname('') - ->set_mail_locked(false) - ->set_mail_notifications(true) - ->set_position('') - ->set_zip('') - ->set_tel(''); - - $this->ftpCredential = new FtpCredential(); - $this->ftpCredential->setUsrId($this->get_id()); - $this->app['EM']->persist($this->ftpCredential); - $this->app['EM']->flush(); - - $this->delete_data_from_cache(); - - return $this; - } - /** - * @todo close all open session - * @return type - */ - public function delete() - { - $repo = $this->app['EM']->getRepository('Phraseanet:UsrAuthProvider'); - foreach ($repo->findByUser($this) as $provider) { - $this->app['EM']->remove($provider); - } - - $repo = $this->app['EM']->getRepository('Phraseanet:FtpExport'); - foreach ($repo->findByUser($this) as $export) { - $this->app['EM']->remove($export); - } - - $repo = $this->app['EM']->getRepository('Phraseanet:Order'); - foreach ($repo->findByUser($this) as $order) { - $this->app['EM']->remove($order); - } - - $repo = $this->app['EM']->getRepository('Phraseanet:Session'); - - foreach ($repo->findByUser($this) as $session) { - $this->app['EM']->remove($session); - } - - $this->app['EM']->flush(); - - $sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null - WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM basusr WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM sbasusr WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM dsel WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM edit_presets WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM tokens WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - $sql = 'DELETE FROM usr_settings WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - - unset(self::$_instance[$this->get_id()]); - - return; - } - public function get_mail_notifications() - { - return $this->mail_notifications; - } - - /** - * - * @param $id - * @return user - */ - public function load($id) - { - $sql = 'SELECT usr_id, ldap_created, create_db, usr_login, usr_password, usr_nom, activite, - usr_prenom, usr_sexe as gender, usr_mail, adresse, usr_creationdate, usr_modificationdate, - ville, cpostal, tel, fax, fonction, societe, geonameid, lastModel, invite, - mail_notifications, mail_locked, model_of, locale - FROM usr WHERE usr_id= :id '; - - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':id' => $id]); - - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (!$row) { - throw new \Exception('User unknown'); - } - - $this->id = (int) $row['usr_id']; - $this->email = $row['usr_mail']; - $this->login = $row['usr_login']; - $this->password = $row['usr_password']; - - $this->ldap_created = $row['ldap_created']; - - $this->mail_notifications = $row['mail_notifications']; - - $this->mail_locked = !!$row['mail_locked']; - - $this->firstname = $row['usr_prenom']; - $this->lastname = $row['usr_nom']; - $this->address = $row['adresse']; - $this->city = $row['ville']; - $this->geonameid = $row['geonameid']; - $this->zip = $row['cpostal']; - $this->gender = $row['gender']; - $this->tel = $row['tel']; - $this->locale = $row['locale']; - $this->fax = $row['fax']; - $this->job = $row['fonction']; - $this->position = $row['activite']; - $this->company = $row['societe']; - $this->creationdate = new DateTime($row['usr_creationdate']); - $this->modificationdate = new DateTime($row['usr_modificationdate']); - $this->applied_template = $row['lastModel']; - - $this->country = $this->get_country(); - - $this->is_guest = ($row['invite'] == '1'); - - if ($row['model_of'] > 0) { - $this->is_template = true; - $this->template_owner = self::getInstance($row['model_of'], $this->app); - } - - return $this; - } - - public function set_last_template(User_Interface $template) - { - $sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id'; - - $params = [ - ':usr_id' => $this->get_id() - , ':template_id' => $template->get_login() - ]; - - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - $this->delete_data_from_cache(); - - return $this; - } - - public function set_mail_locked($boolean) - { - $sql = 'UPDATE usr SET mail_locked = :mail_locked WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0')]); - $stmt->closeCursor(); - $this->mail_locked = !!$boolean; - - return $this; - } - - public function get_notifications_preference(Application $app, $notification_id) - { - if (!$this->notifications_preferences_loaded) - $this->load_notifications_preferences($app); - - return isset($this->_prefs['notification_' . $notification_id]) ? $this->_prefs['notification_' . $notification_id] : '0'; - } - - public function set_notification_preference(Application $app, $notification_id, $value) - { - if (!$this->notifications_preferences_loaded) - $this->load_notifications_preferences($app); - - $prop = 'notification_' . $notification_id; - $value = $value ? '1' : '0'; - - $this->setPrefs($prop, $value); - - return ; - } - - public function get_cache_key($option = null) - { - return '_user_' . $this->get_id() . ($option ? '_' . $option : ''); - } - - public function delete_data_from_cache($option = null) - { - $this->app['phraseanet.appbox']->delete_data_from_cache($this->get_cache_key($option)); - - return $this; - } - - public function get_data_from_cache($option = null) - { - $this->app['phraseanet.appbox']->get_data_from_cache($this->get_cache_key($option)); - - return $this; - } - - public function set_data_to_cache($value, $option = null, $duration = 0) - { - $this->app['phraseanet.appbox']->set_data_to_cache($value, $this->get_cache_key($option), $duration); - - return $this; - } - - public function setPrefs($prop, $value) - { - $this->load_preferences(); - if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value) { - return $this->_prefs[$prop]; - } - - $ok = true; - - if (isset(self::$available_values[$prop])) { - $ok = false; - if (in_array($value, self::$available_values[$prop])) - $ok = true; - } - - if ($ok) { - $this->_prefs[$prop] = $value; - $this->update_pref($prop, $value); - } - - return $this->_prefs[$prop]; - } - - public function getPrefs($prop, $default = null) - { - $this->load_preferences(); - - return array_key_exists($prop, $this->_prefs) ? $this->_prefs[$prop] : $default; - } - - public static function set_sys_admins(Application $app, $admins) - { - try { - $sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; - $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':usr_id' => $app['authentication']->getUser()->getId()]); - $stmt->closeCursor(); - - $sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; - $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - - return true; - } catch (Exception $e) { - - } - - return false; - } - - public function get_locale() - { - return $this->locale ?: $this->app['conf']->get(['languages', 'default'], 'en'); - } - - public function set_locale($locale) - { - if (!array_key_exists($locale, $this->app['locales.available'])) { - throw new \InvalidArgumentException(sprintf('Locale %s is not recognized', $locale)); - } - - $sql = 'UPDATE usr SET locale = :locale WHERE usr_id = :usr_id'; - $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute([':locale' => $locale, ':usr_id' => $this->get_id()]); - $stmt->closeCursor(); - $this->delete_data_from_cache(); - - $this->locale = $locale; - - return $this->locale; - } - - public function __sleep() - { - $vars = []; - foreach ($this as $key => $value) { - if (in_array($key, ['ACL', 'app'])) - continue; - $vars[] = $key; - } - - return $vars; - } - - public static function purge() - { - self::$_instance = []; - } -} diff --git a/lib/classes/base.php b/lib/classes/base.php index 6598293ab4..83cda4c901 100644 --- a/lib/classes/base.php +++ b/lib/classes/base.php @@ -144,19 +144,6 @@ abstract class base implements cache_cacheableInterface return $this->connection; } - /** - * Replaces the connection - * - * @param \connection_pdo $connection - * @return \base - */ - public function set_connection(\connection_pdo $connection) - { - $this->connection = $connection; - - return $this; - } - public function get_cache() { return $this->app['cache']; diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php index d162274c47..3843c3e885 100644 --- a/lib/classes/eventsmanager/notify/autoregister.php +++ b/lib/classes/eventsmanager/notify/autoregister.php @@ -12,7 +12,6 @@ use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered; use Alchemy\Phrasea\Model\Entities\User; -use Doctrine\ORM\Query\ResultSetMappingBuilder; class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract { @@ -50,23 +49,8 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract $mailColl = []; - $rsm = new ResultSetMappingBuilder($this->app['EM']); - $rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u'); - $rsm->addScalarResult('base_id', 'base_id'); - $selectClause = $rsm->generateSelectClause(); - - $query = $this->app['EM']->createNativeQuery(' - SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b - WHERE u.id = b.usr_id - AND b.base_id IN (' . implode(', ', array_keys($base_ids)) . ') - AND u.model_of IS NULL - AND b.actif="1" - AND b.canadmin="1" - AND u.deleted="0"', $rsm - ); - try { - $rs = $query->getResult(); + $rs = $this->app['phraseanet.native-query']->getAdminsOfBases(array_keys($base_ids)); foreach ($rs as $row) { $user = $row[0]; @@ -145,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(), '%before_link%' => '', '%after_link%' => '']) + '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%' => '']) , 'class' => '' ]; @@ -179,15 +163,16 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract */ public function mail(User $to, User $registeredUser) { - $body .= sprintf("Login : %s\n", $registeredUser->get_login()); - $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->get_firstname()); - $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->get_lastname()); - $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->get_email()); - $body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->get_company()); + $body = ''; + $body .= sprintf("Login : %s\n", $registeredUser->getLogin()); + $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->getFirstName()); + $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->getLastName()); + $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->getEmail()); + $body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->getCompany()); $readyToSend = false; try { - $receiver = Receiver::fromUser($to); + $receiver = Receiver::fromUser($to, $this->app['translator']); $readyToSend = true; } catch (Exception $e) { diff --git a/lib/classes/eventsmanager/notify/bridgeuploadfail.php b/lib/classes/eventsmanager/notify/bridgeuploadfail.php index 84f5408d2e..5bd9c4f7ed 100644 --- a/lib/classes/eventsmanager/notify/bridgeuploadfail.php +++ b/lib/classes/eventsmanager/notify/bridgeuploadfail.php @@ -81,7 +81,7 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract try { $user = $this->app['manipulator.user']->getRepository()->find($params['usr_id']); $account = Bridge_Account::load_account($this->app, $params['account_id']); - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php index b41888e9cd..85653b7e66 100644 --- a/lib/classes/eventsmanager/notify/feed.php +++ b/lib/classes/eventsmanager/notify/feed.php @@ -97,7 +97,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract $url = $this->app->url('lightbox', ['LOG' => $token]); - $receiver = Receiver::fromUser($user_to_notif); + $receiver = Receiver::fromUser($user_to_notif, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php index 3320e36825..e808e409cf 100644 --- a/lib/classes/eventsmanager/notify/order.php +++ b/lib/classes/eventsmanager/notify/order.php @@ -102,7 +102,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract if ($this->shouldSendNotificationFor($user->getId())) { $readyToSend = false; try { - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { continue; @@ -140,7 +140,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); $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 12e63f4273..47c1baad2d 100644 --- a/lib/classes/eventsmanager/notify/orderdeliver.php +++ b/lib/classes/eventsmanager/notify/orderdeliver.php @@ -95,8 +95,8 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']); $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $repository = $this->app['EM']->getRepository('Phraseanet:Basket'); $basket = $repository->find($params['ssel_id']); @@ -148,7 +148,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); try { $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php index 7e00b75a65..4377045045 100644 --- a/lib/classes/eventsmanager/notify/ordernotdelivered.php +++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php @@ -78,8 +78,8 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']); $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $readyToSend = true; } catch (Exception $e) { @@ -111,7 +111,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); $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 a9faa1ea28..2e1b58e712 100644 --- a/lib/classes/eventsmanager/notify/push.php +++ b/lib/classes/eventsmanager/notify/push.php @@ -86,8 +86,8 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']); $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { @@ -123,7 +123,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); $ret = [ 'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => 'getResult() as $row) { + $rs = $this->app['phraseanet.native-query']->getAdminsOfBases(array_keys($base_ids)); + + foreach ($rs as $row) { $user = $row[0]; if (!isset($mailColl[$user->getId()])) { @@ -117,7 +103,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract $readyToSend = false; try { $admin_user = $this->app['manipulator.user']->getRepository()->find($usr_id); - $receiver = Receiver::fromUser($admin_user); + $receiver = Receiver::fromUser($admin_user, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { continue; @@ -155,7 +141,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); $ret = [ 'text' => $this->app->trans('%user% demande votre approbation sur une ou plusieurs %before_link% collections %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => '']) diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php index 1a66e53e5d..b35b15067f 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())); + $sender->appendChild($domXML->createTextNode($user->getDisplayName($this->app['translator']))); $root->appendChild($sender); $this->notifyUser($user, $datas); @@ -109,7 +109,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract if ($this->shouldSendNotificationFor($user->getId())) { $readyToSend = false; try { - $receiver = Receiver::fromUser($user); + $receiver = Receiver::fromUser($user, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php index a1bb639794..fa5dc7b035 100644 --- a/lib/classes/eventsmanager/notify/validate.php +++ b/lib/classes/eventsmanager/notify/validate.php @@ -101,8 +101,8 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract ->find($params['ssel_id']); $title = $basket->getName(); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { @@ -141,7 +141,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); 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 3862e5c5b0..e16e826d61 100644 --- a/lib/classes/eventsmanager/notify/validationdone.php +++ b/lib/classes/eventsmanager/notify/validationdone.php @@ -96,8 +96,8 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract ->find($params['ssel_id']); $title = $basket->getName(); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { @@ -135,7 +135,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract return []; } - $sender = $registered_user->getDisplayName(); + $sender = $registered_user->getDisplayName($this->app['translator']); try { $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php index 18758168cb..1b41f3f8b8 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.php +++ b/lib/classes/eventsmanager/notify/validationreminder.php @@ -102,8 +102,8 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra ->find($params['ssel_id']); $title = $basket->getName(); - $receiver = Receiver::fromUser($user_to); - $emitter = Emitter::fromUser($user_from); + $receiver = Receiver::fromUser($user_to, $this->app['translator']); + $emitter = Emitter::fromUser($user_from, $this->app['translator']); $readyToSend = true; } catch (\Exception $e) { @@ -140,7 +140,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra return []; } - $sender = $user->getDisplayName(); + $sender = $user->getDisplayName($this->app['translator']); 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 993c8812eb..b9017dc94b 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() + , $TestUser->getDisplayName($this->container['translator']) , $TestUser->getEmail() ) ); diff --git a/lib/classes/module/report/activity.php b/lib/classes/module/report/activity.php index 2fdef6aee9..57afa36d14 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(); + $login = $this->app['manipulator.user']->getRepository()->find($usr)->getDisplayName($this->app['translator']); $this->setChamp($rs); diff --git a/lib/classes/module/report/add.php b/lib/classes/module/report/add.php index 2835f20e91..cea19ffc9d 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(); + $caption = $user->getDisplayName($this->app['translator']); } } 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 97b94320de..e012eda51f 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(); + $caption = $user->getDisplayName($this->app['translator']); } } 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 fdae8ecc96..7a15034f00 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(); + $caption = $user->getDisplayName($this->app['translator']); } } 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 539841519b..7231bbec71 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(); + $caption = $user->getDisplayName($this->app['translator']); } } 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 6063552db4..1bc48a33ed 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(); + $caption = $user->getDisplayName($this->app['translator']); } } 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 57ab178189..f42a600f67 100644 --- a/lib/classes/patch/320alpha4b.php +++ b/lib/classes/patch/320alpha4b.php @@ -100,7 +100,7 @@ class patch_320alpha4b implements patchInterface $entry = new FeedEntry(); $entry->setAuthorEmail($user->getEmail()); - $entry->setAuthorName($user->getDisplayName()); + $entry->setAuthorName($user->getDisplayName($app['translator'])); $entry->setFeed($feed); $entry->setPublisher($publishers->first()); $entry->setTitle($row['name']); @@ -188,11 +188,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() . ' - ' . 'homelink Feed'; + $title = $user->getDisplayName($app['translator']) . ' - ' . 'homelink Feed'; elseif ($pub_restrict == '1') - $title = $user->getDisplayName() . ' - ' . 'private Feed'; + $title = $user->getDisplayName($app['translator']) . ' - ' . 'private Feed'; else - $title = $user->getDisplayName() . ' - ' . 'public Feed'; + $title = $user->getDisplayName($app['translator']) . ' - ' . 'public Feed'; $feed = new Feed(); $publisher = new FeedPublisher(); diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index ff31341d0e..a3112b3443 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -1728,14 +1728,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface ON (g.rid_parent = r.record_id) WHERE rid_child = :record_id'; - $params = array( - ':GV_site' => $this->app['conf']->get(['main', 'key']) - , ':usr_id' => $this->app['authentication']->getUser()->get_id() - , ':record_id' => $this->get_record_id() - ]; - $stmt = $this->get_databox()->get_connection()->prepare($sql); - $stmt->execute($params); + $stmt->execute([ + ':site' => $this->app['conf']->get(['main', 'key']), + ':usr_id' => $this->app['authentication']->getUser()->getId(), + ':record_id' => $this->get_record_id(), + ]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/classes/record/orderElement.php b/lib/classes/record/orderElement.php index 1b372d7dda..90d0260de1 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(); + return $user->getDisplayName($this->app['translator']); } return ''; diff --git a/lib/classes/set/exportftp.php b/lib/classes/set/exportftp.php index a667d4a498..2055746d64 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() . " (login : " . $this->app['authentication']->getUser()->getLogin() . ") " + . $this->app['authentication']->getUser()->getDisplayName($this->app['translator']) . " (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 c4f018345d..8879ccc436 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() ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %}
{% if app['authentication'].getUser() is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %}

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

diff --git a/templates/web/account/authorized_apps.html.twig b/templates/web/account/authorized_apps.html.twig index 5d902759db..e7b785f7a0 100644 --- a/templates/web/account/authorized_apps.html.twig +++ b/templates/web/account/authorized_apps.html.twig @@ -25,7 +25,7 @@ {% if application.get_creator() is not none %} - {% set user_name = application.get_creator().getDisplayName() %} + {% set user_name = application.get_creator().getDisplayName(app['translator']) %} {% trans with {'%user_name%' : user_name} %}par %user_name%{% endtrans %} {% endif%} diff --git a/templates/web/admin/collection/collection.html.twig b/templates/web/admin/collection/collection.html.twig index 694365e328..6d9bb0ba35 100644 --- a/templates/web/admin/collection/collection.html.twig +++ b/templates/web/admin/collection/collection.html.twig @@ -44,7 +44,7 @@
  • {% endfor %} diff --git a/templates/web/admin/connected-users.html.twig b/templates/web/admin/connected-users.html.twig index 11f53ce058..a59381f208 100644 --- a/templates/web/admin/connected-users.html.twig +++ b/templates/web/admin/connected-users.html.twig @@ -10,7 +10,7 @@ - {{ 'admin::compte-utilisateur nom' | trans }} : {{ user.getDisplayName() }} + {{ 'admin::compte-utilisateur nom' | trans }} : {{ user.getDisplayName(app['translator']) }} {{ 'admin::compte-utilisateur societe' | trans }} : {{ user.getCompany() }} @@ -102,9 +102,9 @@ {% if row.getId() == app['session'].get('session_id') %} - {{ row.getUser().getDisplayName() }} + {{ row.getUser().getDisplayName(app['translator']) }} {% else %} - {{ row.getUser().getDisplayName() }} + {{ row.getUser().getDisplayName(app['translator']) }} {% endif %} diff --git a/templates/web/admin/dashboard.html.twig b/templates/web/admin/dashboard.html.twig index 46d09fe0b9..b29a26fd59 100644 --- a/templates/web/admin/dashboard.html.twig +++ b/templates/web/admin/dashboard.html.twig @@ -98,11 +98,11 @@
    {{ 'setup:: administrateurs de l\'application' | trans }}
      - {% for usr_id, usr_login in admins %} + {% for user in admins %}
    • -
    • {% endfor %} diff --git a/templates/web/admin/editusers.html.twig b/templates/web/admin/editusers.html.twig index a408215c82..2b3d19c07e 100644 --- a/templates/web/admin/editusers.html.twig +++ b/templates/web/admin/editusers.html.twig @@ -118,7 +118,7 @@ {{ 'Reglages:: reglages d inscitpition automatisee' | trans }} {% endif %} {% else %} - {% set display_name = main_user.getDisplayName() %} + {% set display_name = main_user.getDisplayName(app['translator']) %} {% trans with {'%display_name%' : display_name} %}Edition des droits de %display_name%{% endtrans %} {% endif %} {% else %} @@ -131,7 +131,7 @@ diff --git a/templates/web/admin/publications/fiche.html.twig b/templates/web/admin/publications/fiche.html.twig index b3f950d723..28c0904838 100644 --- a/templates/web/admin/publications/fiche.html.twig +++ b/templates/web/admin/publications/fiche.html.twig @@ -143,7 +143,7 @@ {{ publisher.getUser().getId() }} - {{ publisher.getUser().getDisplayName() }} + {{ publisher.getUser().getDisplayName(app['translator']) }} {{ publisher.getUser().getEmail() }} diff --git a/templates/web/admin/users.html.twig b/templates/web/admin/users.html.twig index fc90e269ef..2043abe3ed 100644 --- a/templates/web/admin/users.html.twig +++ b/templates/web/admin/users.html.twig @@ -60,7 +60,7 @@ @@ -149,7 +149,7 @@ {% if usr.getLastModel() is not none %} - {{ usr.getLastModel().getDisplayName()}} + {{ usr.getLastModel().getDisplayName(app['translator'])}} {% endif %} diff --git a/templates/web/api/auth/end_user_authorization.html.twig b/templates/web/api/auth/end_user_authorization.html.twig index 6bbabd0d4f..69dc0ca404 100644 --- a/templates/web/api/auth/end_user_authorization.html.twig +++ b/templates/web/api/auth/end_user_authorization.html.twig @@ -55,7 +55,7 @@
    {% else %} {% if user is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %}
    {% if user is not none %} - {% set username = '' ~ app['authentication'].getUser().getDisplayName() ~ '' %} + {% set username = '' ~ app['authentication'].getUser().getDisplayName(app['translator']) ~ '' %}
    {% if selected_basket is not none and selected_basket.getPusher(app) is not none %} - {% set pusher_name = selected_basket.getPusher(app).getDisplayName() %} + {% set pusher_name = selected_basket.getPusher(app).getDisplayName(app['translator']) %}
    {% trans with {'%pusher_name%' : pusher_name} %}paniers:: panier emis par %pusher_name%{% endtrans %}
    diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index e8d4b7112e..51f47430bf 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -145,7 +145,7 @@ {% endif %} {{ _self.choose_title('download', choose_export_title, default_export_title) }} - {% if app['phraseanet.registry'].get('GV_requireTOUValidationForExport') == true %} + {% if app['conf'].get(['registry', 'actions', 'tou-validation-required-for-export']) == true %}
    - {% if app['phraseanet.registry'].get('GV_requireTOUValidationForExport') == true %} + {% if app['conf'].get(['registry', 'actions', 'tou-validation-required-for-export']) == true %}
    {% endif %} - {% if app['phraseanet.registry'].get('GV_requireTOUValidationForExport') == true %} + {% if app['conf'].get(['registry', 'actions', 'tou-validation-required-for-export']) == true %}