diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 7ae2a3a5a7..16dde71565 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -159,7 +159,6 @@ return call_user_func(function($environment = 'prod') { * Check wether the current user is Admin or not */ $mustBeAdmin = function (Request $request) use ($app) { - /* @var $user \User_Adapter */ $user = $app['token']->get_account()->get_user(); if (!$user->ACL()->is_admin()) { throw new \API_V1_exception_unauthorized('You are not authorized'); diff --git a/lib/Alchemy/Phrasea/Application/Lightbox.php b/lib/Alchemy/Phrasea/Application/Lightbox.php index bfe88ef773..06fcb46507 100644 --- a/lib/Alchemy/Phrasea/Application/Lightbox.php +++ b/lib/Alchemy/Phrasea/Application/Lightbox.php @@ -344,20 +344,19 @@ class Lightbox implements ControllerProviderInterface 'datas' => _('Erreur lors de la mise a jour des donnes ') ); - $user = $app['phraseanet.user']; $repository = $app['EM']->getRepository('\Entities\BasketElement'); /* @var $repository \Repositories\BasketElementRepository */ $basket_element = $repository->findUserElement( $sselcont_id - , $user + , $app['phraseanet.user'] ); /* @var $basket_element \Entities\BasketElement */ - $validationDatas = $basket_element->getUserValidationDatas($user, $app); + $validationDatas = $basket_element->getUserValidationDatas($app['phraseanet.user'], $app); if (!$basket_element->getBasket() ->getValidation() - ->getParticipant($user, $app)->getCanAgree()) { + ->getParticipant($app['phraseanet.user'], $app)->getCanAgree()) { throw new ControllerException('You can not agree on this'); } @@ -365,7 +364,7 @@ class Lightbox implements ControllerProviderInterface $participant = $basket_element->getBasket() ->getValidation() - ->getParticipant($user, $app); + ->getParticipant($app['phraseanet.user'], $app); $app['EM']->merge($basket_element); @@ -390,8 +389,6 @@ class Lightbox implements ControllerProviderInterface $controllers->post('/ajax/SET_RELEASE/{ssel_id}/', function(SilexApplication $app, $ssel_id) { - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\Basket'); $datas = array('error' => true, 'datas' => ''); @@ -400,7 +397,7 @@ class Lightbox implements ControllerProviderInterface /* @var $repository \Repositories\BasketRepository */ $basket = $repository->findUserBasket( $app, $ssel_id - , $user + , $app['phraseanet.user'] , false ); @@ -408,12 +405,12 @@ class Lightbox implements ControllerProviderInterface throw new ControllerException('There is no validation session attached to this basket'); } - if (!$basket->getValidation()->getParticipant($user, $app)->getCanAgree()) { + if (!$basket->getValidation()->getParticipant($app['phraseanet.user'], $app)->getCanAgree()) { throw new ControllerException('You have not right to agree'); } /* @var $basket \Entities\Basket */ - $participant = $basket->getValidation()->getParticipant($user, $app); + $participant = $basket->getValidation()->getParticipant($app['phraseanet.user'], $app); $evt_mngr = $app['events-manager']; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 29b7589cf5..4e853b81d8 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -223,12 +223,10 @@ class Dashboard implements ControllerProviderInterface */ public function addAdmins(Application $app, Request $request) { - $user = $app['phraseanet.user']; - if (count($admins = $request->request->get('admins', array())) > 0) { - if (!in_array($user->get_id(), $admins)) { - $admins[] = $user->get_id(); + if (!in_array($app['phraseanet.user']->get_id(), $admins)) { + $admins[] = $app['phraseanet.user']->get_id(); } if ($admins > 0) { diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index 587794c54f..26081bb6d7 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -652,11 +652,9 @@ class Databox implements ControllerProviderInterface */ public function mountCollection(Application $app, Request $request, $databox_id, $collection_id) { - $user = $app['phraseanet.user']; - $app['phraseanet.appbox']->get_connection()->beginTransaction(); try { - $baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $user); + $baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $app['phraseanet.user']); if (null == $othCollSel = $request->request->get("othcollsel")) { $app->abort(400); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index b9550b4695..8040d5748d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -121,11 +121,9 @@ class Databoxes implements ControllerProviderInterface $upgradeAvailable = true; } - $user = $app['phraseanet.user']; - $sbasIds = array_merge( - array_keys($user->ACL()->get_granted_sbas(array('bas_manage'))) - , array_keys($user->ACL()->get_granted_sbas(array('bas_modify_struct'))) + array_keys($app['phraseanet.user']->ACL()->get_granted_sbas(array('bas_manage'))) + , array_keys($app['phraseanet.user']->ACL()->get_granted_sbas(array('bas_modify_struct'))) ); $sbas = array(); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index 6ddd867102..766962eb39 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -92,11 +92,9 @@ class Publications implements ControllerProviderInterface $feed = new \Feed_Adapter($app, $id); - $user = $app['phraseanet.user']; - $request = $app["request"]; - if (!$feed->is_owner($user)) { + if (!$feed->is_owner($app['phraseanet.user'])) { $datas['message'] = 'You are not allowed to do that'; return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index b07063cdc7..41cd6aa382 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -38,8 +38,6 @@ class Root implements ControllerProviderInterface }); $controllers->get('/', function(Application $app, Request $request) { - $user = $app['phraseanet.user']; - \User_Adapter::updateClientInfos($app, 3); $section = $request->query->get('section', false); @@ -71,7 +69,7 @@ class Root implements ControllerProviderInterface $databoxes = $off_databoxes = array(); foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { - if (!$user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + if (!$app['phraseanet.user']->ACL()->has_access_to_sbas($databox->get_sbas_id())) { continue; } $databox->get_connection(); @@ -104,8 +102,6 @@ class Root implements ControllerProviderInterface })->bind('admin'); $controllers->get('/tree/', function(Application $app, Request $request) { - $user = $app['phraseanet.user']; - \User_Adapter::updateClientInfos($app, 3); $section = $request->query->get('section', false); @@ -138,7 +134,7 @@ class Root implements ControllerProviderInterface $databoxes = $off_databoxes = array(); foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { - if (!$user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + if (!$app['phraseanet.user']->ACL()->has_access_to_sbas($databox->get_sbas_id())) { continue; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index efde2e7342..b272ea0fc4 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -197,8 +197,6 @@ class Users implements ControllerProviderInterface $user_query = new \User_Query($app); - $user = $app['phraseanet.user']; - $like_value = $request->query->get('term'); $rights = $request->query->get('filter_rights') ? : array(); $have_right = $request->query->get('have_right') ? : array(); @@ -206,7 +204,7 @@ class Users implements ControllerProviderInterface $on_base = $request->query->get('on_base') ? : array(); $elligible_users = $user_query - ->on_sbas_where_i_am($user->ACL(), $rights) + ->on_sbas_where_i_am($app['phraseanet.user']->ACL(), $rights) ->like(\User_Query::LIKE_EMAIL, $like_value) ->like(\User_Query::LIKE_FIRSTNAME, $like_value) ->like(\User_Query::LIKE_LASTNAME, $like_value) @@ -259,13 +257,12 @@ class Users implements ControllerProviderInterface $request = $app['request']; $user_query = new \User_Query($app); - $user = $app['phraseanet.user']; $like_value = $request->request->get('like_value'); $like_field = $request->request->get('like_field'); $on_base = $request->request->get('base_id') ? : null; $on_sbas = $request->request->get('sbas_id') ? : null; - $elligible_users = $user_query->on_bases_where_i_am($user->ACL(), array('canadmin')) + $elligible_users = $user_query->on_bases_where_i_am($app['phraseanet.user']->ACL(), array('canadmin')) ->like($like_field, $like_value) ->on_base_ids($on_base) ->on_sbas_ids($on_sbas); @@ -332,7 +329,6 @@ class Users implements ControllerProviderInterface }); $controllers->get('/demands/', function(Application $app, Request $request) { - $user = $app['phraseanet.user']; $lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60); $sql = "DELETE FROM demand WHERE date_modif < :date"; @@ -340,12 +336,12 @@ class Users implements ControllerProviderInterface $stmt->execute(array(':date' => date('Y-m-d', $lastMonth))); $stmt->closeCursor(); - $baslist = array_keys($user->ACL()->get_granted_base(array('canadmin'))); + $baslist = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('canadmin'))); $sql = 'SELECT usr_id, usr_login FROM usr WHERE model_of = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute(array(':usr_id' => $app['phraseanet.user']->get_id())); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -561,7 +557,6 @@ class Users implements ControllerProviderInterface })->bind('users_display_import_file'); $controllers->post('/import/file/', function(Application $app, Request $request) { - $user = $app['phraseanet.user']; if ((null === $file = $request->files->get('files')) || !$file->isValid()) { @@ -678,12 +673,12 @@ class Users implements ControllerProviderInterface INNER JOIN basusr ON (basusr.usr_id=usr.usr_id) WHERE usr.model_of = :usr_id - AND base_id in(" . implode(', ', array_keys($user->ACL()->get_granted_base(array('manage')))) . ") + AND base_id in(" . implode(', ', array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('manage')))) . ") AND usr_login not like '(#deleted_%)' GROUP BY usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute(array(':usr_id' => $app['phraseanet.user']->get_id())); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -697,7 +692,6 @@ class Users implements ControllerProviderInterface $controllers->post('/import/', function(Application $app, Request $request) { $nbCreation = 0; - $user = $app['phraseanet.user']; if ((null === $serializedArray = $request->request->get('sr')) || ('' === $serializedArray)) { $app->abort(400); @@ -763,7 +757,7 @@ class Users implements ControllerProviderInterface $NewUser = \User_Adapter::create($app, $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false); $NewUser->ACL()->apply_model( - \User_Adapter::getInstance($model, $app), array_keys($user->ACL()->get_granted_base(array('manage'))) + \User_Adapter::getInstance($model, $app), array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('manage'))) ); $nbCreation++; diff --git a/lib/Alchemy/Phrasea/Controller/Datafiles.php b/lib/Alchemy/Phrasea/Controller/Datafiles.php index f4ba7e6217..4799b2690d 100644 --- a/lib/Alchemy/Phrasea/Controller/Datafiles.php +++ b/lib/Alchemy/Phrasea/Controller/Datafiles.php @@ -52,18 +52,16 @@ class Datafiles extends AbstractDelivery } } - $user = $app['phraseanet.user']; - if (!$record->has_subdef($subdef) || !$record->get_subdef($subdef)->is_physically_present()) { throw new NotFoundHttpException; } - if (!$user->ACL()->has_access_to_subdef($record, $subdef)) { + if (!$app['phraseanet.user']->ACL()->has_access_to_subdef($record, $subdef)) { throw new \Exception_UnauthorizedAction(sprintf('User has not access to subdef %s', $subdef)); } $stamp = false; - $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark'); + $watermark = !$app['phraseanet.user']->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark'); if ($watermark && !$all_access) { $subdef_class = $databox @@ -71,9 +69,9 @@ class Datafiles extends AbstractDelivery ->get_subdef($record->get_type(), $subdef) ->get_class(); - if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record)) { + if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['phraseanet.user']->ACL()->has_preview_grant($record)) { $watermark = false; - } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record)) { + } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $app['phraseanet.user']->ACL()->has_hd_grant($record)) { $watermark = false; } } @@ -84,8 +82,8 @@ class Datafiles extends AbstractDelivery /* @var $repository \Repositories\BasketElementRepository */ - $ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $user); - $ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $user); + $ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $app['phraseanet.user']); + $ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $app['phraseanet.user']); if ($ValidationByRecord && count($ValidationByRecord) > 0) { $watermark = false; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php index a59cbbf77e..0c15f42719 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php @@ -422,15 +422,12 @@ class Basket implements ControllerProviderInterface $basket = $app['EM']->getRepository('\Entities\Basket') ->findUserBasket($app, $basket_id, $app['phraseanet.user'], true); - $user = $app['phraseanet.user']; - /* @var $user \User_Adapter */ - $n = 0; foreach ($request->request->get('elements') as $bask_element_id) { try { $basket_element = $app['EM']->getRepository('\Entities\BasketElement') - ->findUserElement($bask_element_id, $user); + ->findUserElement($bask_element_id, $app['phraseanet.user']); } catch (\Exception $e) { continue; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index 1c686dbc77..9d5f624256 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -55,10 +55,9 @@ class Bridge implements ControllerProviderInterface $controllers->post('/manager/', function(Application $app) { $route = new RecordHelper\Bridge($app, $app['request']); - $user = $app['phraseanet.user']; $params = array( - 'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $user) + 'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $app['phraseanet.user']) , 'available_apis' => \Bridge_Api::get_availables($app) , 'route' => $route , 'current_account_id' => '' @@ -76,7 +75,6 @@ class Bridge implements ControllerProviderInterface $controllers->get('/callback/{api_name}/', function(Application $app, $api_name) { $error_message = ''; try { - $user = $app['phraseanet.user']; $api = \Bridge_Api::get_by_api_name($app, $api_name); $connector = $api->get_connector(); @@ -85,9 +83,9 @@ class Bridge implements ControllerProviderInterface $user_id = $connector->get_user_id(); try { - $account = \Bridge_Account::load_account_from_distant_id($app, $api, $user, $user_id); + $account = \Bridge_Account::load_account_from_distant_id($app, $api, $app['phraseanet.user'], $user_id); } catch (\Bridge_Exception_AccountNotFound $e) { - $account = \Bridge_Account::create($app, $api, $user, $user_id, $connector->get_user_name()); + $account = \Bridge_Account::create($app, $api, $app['phraseanet.user'], $user_id, $connector->get_user_name()); } $settings = $account->get_settings(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index 2056671629..b9c4b4137e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -33,8 +33,7 @@ class Feed implements ControllerProviderInterface * I got a selection of docs, which publications are available forthese docs ? */ $controllers->post('/requestavailable/', function(Application $app, Request $request) { - $user = $app['phraseanet.user']; - $feeds = \Feed_Collection::load_all($app, $user); + $feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)); @@ -45,9 +44,8 @@ class Feed implements ControllerProviderInterface */ $controllers->post('/entry/create/', function(Application $app, Request $request) { try { - $user = $app['phraseanet.user']; $feed = new \Feed_Adapter($app, $request->request->get('feed_id')); - $publisher = \Feed_Publisher_Adapter::getPublisher($app['phraseanet.appbox'], $feed, $user); + $publisher = \Feed_Publisher_Adapter::getPublisher($app['phraseanet.appbox'], $feed, $app['phraseanet.user']); $title = $request->request->get('title'); $subtitle = $request->request->get('subtitle'); @@ -70,16 +68,13 @@ class Feed implements ControllerProviderInterface }); $controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) { - - $user = $app['phraseanet.user']; - $entry = \Feed_Entry_Adapter::load_from_id($app, $id); - if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) { + if ($entry->get_publisher()->get_user()->get_id() !== $app['phraseanet.user']->get_id()) { throw new \Exception_UnauthorizedAction(); } - $feeds = \Feed_Collection::load_all($app, $user); + $feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', array('entry' => $entry, 'feeds' => $feeds)); @@ -91,11 +86,9 @@ class Feed implements ControllerProviderInterface try { $app['phraseanet.appbox']->get_connection()->beginTransaction(); - $user = $app['phraseanet.user']; - $entry = \Feed_Entry_Adapter::load_from_id($app, $id); - if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) { + if ($entry->get_publisher()->get_user()->get_id() !== $app['phraseanet.user']->get_id()) { throw new \Exception_UnauthorizedAction(); } @@ -113,12 +106,12 @@ class Feed implements ControllerProviderInterface $new_feed_id = $request->request->get('feed_id', $current_feed_id); if ($current_feed_id != $new_feed_id) { try { - $new_feed = \Feed_Adapter::load_with_user($app, $user, $new_feed_id); + $new_feed = \Feed_Adapter::load_with_user($app, $app['phraseanet.user'], $new_feed_id); } catch (\Exception_NotFound $e) { throw new \Exception_Forbidden('You have no access to this feed'); } - if (!$new_feed->is_publisher($user)) { + if (!$new_feed->is_publisher($app['phraseanet.user'])) { throw new \Exception_Forbidden('You are not publisher of this feed'); } @@ -164,12 +157,10 @@ class Feed implements ControllerProviderInterface try { $app['phraseanet.appbox']->get_connection()->beginTransaction(); - $user = $app['phraseanet.user']; - $entry = \Feed_Entry_Adapter::load_from_id($app, $id); - if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id() - && $entry->get_feed()->is_owner($user) === false) { + if ($entry->get_publisher()->get_user()->get_id() !== $app['phraseanet.user']->get_id() + && $entry->get_feed()->is_owner($app['phraseanet.user']) === false) { throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher')); } @@ -193,9 +184,7 @@ class Feed implements ControllerProviderInterface $page = (int) $request->query->get('page'); $page = $page > 0 ? $page : 1; - $user = $app['phraseanet.user']; - - $feeds = \Feed_Collection::load_all($app, $user); + $feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $datas = $app['twig']->render('prod/feeds/feeds.html.twig' , array( @@ -212,10 +201,8 @@ class Feed implements ControllerProviderInterface $page = (int) $request->query->get('page'); $page = $page > 0 ? $page : 1; - $user = $app['phraseanet.user']; - - $feed = \Feed_Adapter::load_with_user($app, $user, $id); - $feeds = \Feed_Collection::load_all($app, $user); + $feed = \Feed_Adapter::load_with_user($app, $app['phraseanet.user'], $id); + $feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $datas = $app['twig']->render('prod/feeds/feeds.html.twig', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page)); @@ -225,14 +212,12 @@ class Feed implements ControllerProviderInterface $controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) { $renew = ($request->query->get('renew') === 'true'); - $user = $app['phraseanet.user']; - - $feeds = \Feed_Collection::load_all($app, $user); + $feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $output = array( 'texte' => '
' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '
' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '
- ', + ', 'titre' => _('publications::votre rss personnel') ); @@ -241,13 +226,12 @@ class Feed implements ControllerProviderInterface $controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) { $renew = ($request->query->get('renew') === 'true'); - $user = $app['phraseanet.user']; - $feed = \Feed_Adapter::load_with_user($app, $user, $id); + $feed = \Feed_Adapter::load_with_user($app, $app['phraseanet.user'], $id); $output = array( 'texte' => '' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '
' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '
- ', + ', 'titre' => _('publications::votre rss personnel') ); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index 485a13bd75..d4372fd50e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -169,9 +169,7 @@ class Lazaret implements ControllerProviderInterface */ public function listElement(Application $app, Request $request) { - $user = $app['phraseanet.user']; - /* @var $user \User_Adapter */ - $baseIds = array_keys($user->ACL()->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('canaddrecord'))); $lazaretFiles = null; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index 11d33553b1..8784241efb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -64,14 +64,12 @@ class MoveCollection implements ControllerProviderInterface ); try { - $user = $app['phraseanet.user']; - if (null === $request->request->get('base_id')) { $datas['message'] = _('Missing target collection'); return $app->json($datas); } - if (!$user->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) { + if (!$app['phraseanet.user']->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) { $datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination(), $app)); return $app->json($datas); } @@ -88,7 +86,7 @@ class MoveCollection implements ControllerProviderInterface if ($request->request->get("chg_coll_son") == "1") { foreach ($record->get_children() as $child) { - if ($user->ACL()->has_right_on_base($child->get_base_id(), 'candeleterecord')) { + if ($app['phraseanet.user']->ACL()->has_right_on_base($child->get_base_id(), 'candeleterecord')) { $child->move_to_collection($collection, $app['phraseanet.appbox']); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index ae658849b6..8ff6151e5a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -148,12 +148,10 @@ class Push implements ControllerProviderInterface try { $pusher = new RecordHelper\Push($app, $app['request']); - $user = $app['phraseanet.user']; - $push_name = $request->request->get('name'); if (trim($push_name) === '') { - $push_name = sprintf(_('Push from %s'), $user->get_display_name()); + $push_name = sprintf(_('Push from %s'), $app['phraseanet.user']->get_display_name()); } $push_description = $request->request->get('push_description'); @@ -181,7 +179,7 @@ class Push implements ControllerProviderInterface $Basket->setName($push_name); $Basket->setDescription($push_description); $Basket->setOwner($user_receiver); - $Basket->setPusher($user); + $Basket->setPusher($app['phraseanet.user']); $Basket->setIsRead(false); $app['EM']->persist($Basket); @@ -198,13 +196,13 @@ class Push implements ControllerProviderInterface if ($receiver['HD']) { $user_receiver->ACL()->grant_hd_on( $BasketElement->getRecord($app) - , $user + , $app['phraseanet.user'] , \ACL::GRANT_ACTION_PUSH ); } else { $user_receiver->ACL()->grant_preview_on( $BasketElement->getRecord($app) - , $user + , $app['phraseanet.user'] , \ACL::GRANT_ACTION_PUSH ); } @@ -217,8 +215,8 @@ class Push implements ControllerProviderInterface . \random::getUrlToken($app, \random::TYPE_VIEW, $user_receiver->get_id(), null, $Basket->getId()); $params = array( - 'from' => $user->get_id() - , 'from_email' => $user->get_email() + 'from' => $app['phraseanet.user']->get_id() + , 'from_email' => $app['phraseanet.user']->get_email() , 'to' => $user_receiver->get_id() , 'to_email' => $user_receiver->get_email() , 'to_name' => $user_receiver->get_display_name() @@ -265,7 +263,6 @@ class Push implements ControllerProviderInterface try { $pusher = new RecordHelper\Push($app, $app['request']); - $user = $app['phraseanet.user']; $events_manager = $app['events-manager']; @@ -274,7 +271,7 @@ class Push implements ControllerProviderInterface $validation_name = $request->request->get('name'); if (trim($validation_name) === '') { - $validation_name = sprintf(_('Validation from %s'), $user->get_display_name()); + $validation_name = sprintf(_('Validation from %s'), $app['phraseanet.user']->get_display_name()); } $validation_description = $request->request->get('validation_description'); @@ -295,7 +292,7 @@ class Push implements ControllerProviderInterface $Basket = new \Entities\Basket(); $Basket->setName($validation_name); $Basket->setDescription($validation_description); - $Basket->setOwner($user); + $Basket->setOwner($app['phraseanet.user']); $Basket->setIsRead(false); $app['EM']->persist($Basket); @@ -334,16 +331,16 @@ class Push implements ControllerProviderInterface $found = false; foreach ($participants as $key => $participant) { - if ($participant['usr_id'] == $user->get_id()) { + if ($participant['usr_id'] == $app['phraseanet.user']->get_id()) { $found = true; break; } } if (!$found) { - $participants[$user->get_id()] = array( + $participants[$app['phraseanet.user']->get_id()] = array( 'see_others' => 1, - 'usr_id' => $user->get_id(), + 'usr_id' => $app['phraseanet.user']->get_id(), 'agree' => 0, 'HD' => 0 ); @@ -386,13 +383,13 @@ class Push implements ControllerProviderInterface if ($participant['HD']) { $participant_user->ACL()->grant_hd_on( $BasketElement->getRecord($app) - , $user + , $app['phraseanet.user'] , \ACL::GRANT_ACTION_VALIDATE ); } else { $participant_user->ACL()->grant_preview_on( $BasketElement->getRecord($app) - , $user + , $app['phraseanet.user'] , \ACL::GRANT_ACTION_VALIDATE ); } @@ -415,8 +412,8 @@ class Push implements ControllerProviderInterface . \random::getUrlToken($app, \random::TYPE_VIEW, $participant_user->get_id(), null, $Basket->getId()); $params = array( - 'from' => $user->get_id() - , 'from_email' => $user->get_email() + 'from' => $app['phraseanet.user']->get_id() + , 'from_email' => $app['phraseanet.user']->get_email() , 'to' => $participant_user->get_id() , 'to_email' => $participant_user->get_email() , 'to_name' => $participant_user->get_display_name() @@ -458,11 +455,10 @@ class Push implements ControllerProviderInterface $datas = null; $request = $app['request']; - $user = $app['phraseanet.user']; $query = new \User_Query($app); - $query->on_bases_where_i_am($user->ACL(), array('canpush')); + $query->on_bases_where_i_am($app['phraseanet.user']->ACL(), array('canpush')); $query->in(array($usr_id)); @@ -482,11 +478,9 @@ class Push implements ControllerProviderInterface $controllers->get('/list/{list_id}/', function(Application $app, $list_id) use ($listFormatter) { $datas = null; - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); if ($list) { $datas = $listFormatter($list); @@ -498,11 +492,8 @@ class Push implements ControllerProviderInterface $controllers->post('/add-user/', function(Application $app, Request $request) use ($userFormatter) { $result = array('success' => false, 'message' => '', 'user' => null); - $AdminUser = $app['phraseanet.user']; - try { - /* @var $AdminUser \User_Adapter */ - if (!$AdminUser->ACL()->has_right('manageusers')) + if (!$app['phraseanet.user']->ACL()->has_right('manageusers')) throw new ControllerException(_('You are not allowed to add users')); if (!$request->request->get('firstname')) @@ -571,11 +562,10 @@ class Push implements ControllerProviderInterface $controllers->get('/search-user/', function(Application $app) use ($userFormatter, $listFormatter) { $request = $app['request']; - $user = $app['phraseanet.user']; $query = new \User_Query($app); - $query->on_bases_where_i_am($user->ACL(), array('canpush')); + $query->on_bases_where_i_am($app['phraseanet.user']->ACL(), array('canpush')); $query->like(\User_Query::LIKE_FIRSTNAME, $request->query->get('query')) ->like(\User_Query::LIKE_LASTNAME, $request->query->get('query')) @@ -588,7 +578,7 @@ class Push implements ControllerProviderInterface $repository = $app['EM']->getRepository('\Entities\UsrList'); - $lists = $repository->findUserListLike($user, $request->query->get('query')); + $lists = $repository->findUserListLike($app['phraseanet.user'], $request->query->get('query')); $datas = array(); @@ -609,15 +599,13 @@ class Push implements ControllerProviderInterface $controllers->match('/edit-list/{list_id}/', function(Application $app, Request $request, $list_id) { - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); $query = new \User_Query($app); - $query->on_bases_where_i_am($user->ACL(), array('canpush')); + $query->on_bases_where_i_am($app['phraseanet.user']->ACL(), array('canpush')); if ($request->get('query')) { $query->like($request->get('like_field'), $request->get('query')) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 1fb5f63569..1d5af579fd 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -36,12 +36,9 @@ class Query implements ControllerProviderInterface }); $controllers->post('/', function(Application $app, Request $request) { - - $user = $app['phraseanet.user']; - $query = (string) $request->request->get('qry'); - $mod = $user->getPrefs('view'); + $mod = $app['phraseanet.user']->getPrefs('view'); $json = array(); @@ -49,13 +46,12 @@ class Query implements ControllerProviderInterface $bas = is_array($request->request->get('bas')) ? $request->request->get('bas') : array_keys($user->ACL()->get_granted_base()); - /* @var $user \User_Adapter */ - if ($user->ACL()->has_right('modifyrecord')) { + if ($app['phraseanet.user']->ACL()->has_right('modifyrecord')) { $options->set_business_fields(array()); $BF = array(); - foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection) { + foreach ($app['phraseanet.user']->ACL()->get_granted_base(array('canmodifrecord')) as $collection) { if (count($bas) === 0 || in_array($collection->get_base_id(), $bas)) { $BF[] = $collection->get_base_id(); } @@ -70,7 +66,7 @@ class Query implements ControllerProviderInterface $options->set_fields($fields); $options->set_status($status); - $options->set_bases($bas, $user->ACL()); + $options->set_bases($bas, $app['phraseanet.user']->ACL()); $options->set_search_type($request->request->get('search_type')); $options->set_record_type($request->request->get('recordtype')); @@ -82,7 +78,7 @@ class Query implements ControllerProviderInterface $form = serialize($options); - $perPage = (int) $user->getPrefs('images_per_page'); + $perPage = (int) $app['phraseanet.user']->getPrefs('images_per_page'); $search_engine = new \searchEngine_adapter($app); $search_engine->set_options($options); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index cebb907c79..4a854dc1ae 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -42,7 +42,6 @@ class Root implements ControllerProviderInterface \User_Adapter::updateClientInfos($app, 1); - $user = $app['phraseanet.user']; $cssPath = $app['phraseanet.registry']->get('GV_RootPath') . 'www/skins/prod/'; $css = array(); @@ -63,13 +62,13 @@ class Root implements ControllerProviderInterface $css[$baseName] = $baseName; } - $cssfile = $user->getPrefs('css'); + $cssfile = $app['phraseanet.user']->getPrefs('css'); if (!$cssfile && isset($css['000000'])) { $cssfile = '000000'; } - $user_feeds = \Feed_Collection::load_all($app, $user); + $user_feeds = \Feed_Collection::load_all($app, $app['phraseanet.user']); $feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds()); $thjslist = ""; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 60ca2aeb96..20f80b4a54 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -35,11 +35,9 @@ class Story implements ControllerProviderInterface $controllers->post('/', function(Application $app, Request $request) { /* @var $request \Symfony\Component\HttpFoundation\Request */ - $user = $app['phraseanet.user']; - $collection = \collection::get_from_base_id($app, $request->request->get('base_id')); - if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) { + if (!$app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) { throw new \Exception_Forbidden('You can not create a story on this collection'); } @@ -54,9 +52,9 @@ class Story implements ControllerProviderInterface $record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]); - if (!$user->ACL()->has_access_to_base($record->get_base_id()) - && !$user->ACL()->has_hd_grant($record) - && !$user->ACL()->has_preview_grant($record)) { + if (!$app['phraseanet.user']->ACL()->has_access_to_base($record->get_base_id()) + && !$app['phraseanet.user']->ACL()->has_hd_grant($record) + && !$app['phraseanet.user']->ACL()->has_preview_grant($record)) { continue; } @@ -87,7 +85,7 @@ class Story implements ControllerProviderInterface $Story->set_metadatas($metadatas)->rebuild_subdefs(); $StoryWZ = new \Entities\StoryWZ(); - $StoryWZ->setUser($user); + $StoryWZ->setUser($app['phraseanet.user']); $StoryWZ->setRecord($Story); $app['EM']->persist($StoryWZ); @@ -122,13 +120,9 @@ class Story implements ControllerProviderInterface $controllers->post('/{sbas_id}/{record_id}/addElements/', function(Application $app, Request $request, $sbas_id, $record_id) { $Story = new \record_adapter($app, $sbas_id, $record_id); - $user = $app['phraseanet.user']; - - if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) + if (!$app['phraseanet.user']->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) throw new \Exception_Forbidden('You can not add document to this Story'); - /* @var $user \User_Adapter */ - $n = 0; foreach (explode(';', $request->request->get('lst')) as $sbas_rec) { @@ -139,9 +133,9 @@ class Story implements ControllerProviderInterface $record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]); - if (!$user->ACL()->has_access_to_base($record->get_base_id()) - && !$user->ACL()->has_hd_grant($record) - && !$user->ACL()->has_preview_grant($record)) { + if (!$app['phraseanet.user']->ACL()->has_access_to_base($record->get_base_id()) + && !$app['phraseanet.user']->ACL()->has_hd_grant($record) + && !$app['phraseanet.user']->ACL()->has_preview_grant($record)) { continue; } @@ -170,13 +164,9 @@ class Story implements ControllerProviderInterface $record = new \record_adapter($app, $child_sbas_id, $child_record_id); - $user = $app['phraseanet.user']; - - if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) + if (!$app['phraseanet.user']->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) throw new \Exception_Forbidden('You can not add document to this Story'); - /* @var $user \User_Adapter */ - $Story->removeChild($record); $data = array( @@ -218,8 +208,6 @@ class Story implements ControllerProviderInterface $controllers->post('/{sbas_id}/{record_id}/reorder/', function(Application $app, $sbas_id, $record_id) { $ret = array('success' => false, 'message' => _('An error occured')); try { - $user = $app['phraseanet.user']; - /* @var $user \User_Adapter */ $story = new \record_adapter($app, $sbas_id, $record_id); @@ -227,7 +215,7 @@ class Story implements ControllerProviderInterface throw new \Exception('This is not a story'); } - if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) { + if (!$app['phraseanet.user']->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) { throw new ControllerException(_('You can not edit this story')); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index d85b7031bf..b06905a4a1 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -31,14 +31,12 @@ class TOU implements ControllerProviderInterface $ret = array('success' => false, 'message' => ''); try { - $user = $app['phraseanet.user']; - $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - $user->ACL()->revoke_access_from_bases( - $user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) + $app['phraseanet.user']->ACL()->revoke_access_from_bases( + $app['phraseanet.user']->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) ); - $user->ACL()->revoke_unused_sbas_rights(); + $app['phraseanet.user']->ACL()->revoke_unused_sbas_rights(); $app->closeAccount(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php index 445fcc57fc..f500c8576c 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php @@ -45,9 +45,7 @@ class UserPreferences implements ControllerProviderInterface $ret = array('success' => false, 'message' => _('Error while saving preference')); try { - $user = $app['phraseanet.user']; - - $ret = $user->setPrefs($request->request->get('prop'), $request->request->get('value')); + $ret = $app['phraseanet.user']->setPrefs($request->request->get('prop'), $request->request->get('value')); if ($ret == $request->request->get('value')) $output = "1"; else diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 648b9276a8..904d1de2b8 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -216,11 +216,9 @@ class UsrLists implements ControllerProviderInterface public function displayList(Application $app, Request $request, $list_id) { - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); $entries = new ArrayCollection(); $owners = new ArrayCollection(); @@ -276,13 +274,11 @@ class UsrLists implements ControllerProviderInterface throw new ControllerException(_('List name is required')); } - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_EDITOR) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_EDITOR) { throw new ControllerException(_('You are not authorized to do this')); } @@ -311,11 +307,9 @@ class UsrLists implements ControllerProviderInterface try { $repository = $app['EM']->getRepository('\Entities\UsrList'); - $user = $app['phraseanet.user']; + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); - - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_ADMIN) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_ADMIN) { throw new ControllerException(_('You are not authorized to do this')); } @@ -347,12 +341,10 @@ class UsrLists implements ControllerProviderInterface try { $repository = $app['EM']->getRepository('\Entities\UsrList'); - $user = $app['phraseanet.user']; - - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); /* @var $list \Entities\UsrList */ - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_EDITOR) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_EDITOR) { throw new ControllerException(_('You are not authorized to do this')); } @@ -385,8 +377,6 @@ class UsrLists implements ControllerProviderInterface public function addUsers(Application $app, Request $request, $list_id) { - $user = $app['phraseanet.user']; - try { if (!is_array($request->request->get('usr_ids'))) { throw new ControllerException('Invalid or missing parameter usr_ids'); @@ -394,10 +384,10 @@ class UsrLists implements ControllerProviderInterface $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); /* @var $list \Entities\UsrList */ - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_EDITOR) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_EDITOR) { throw new ControllerException(_('You are not authorized to do this')); } @@ -453,17 +443,15 @@ class UsrLists implements ControllerProviderInterface public function displayShares(Application $app, Request $request, $list_id) { - $user = $app['phraseanet.user']; - $list = null; try { $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); /* @var $list \Entities\UsrList */ - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_ADMIN) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_ADMIN) { $list = null; throw new \Exception(_('You are not authorized to do this')); } @@ -476,8 +464,6 @@ class UsrLists implements ControllerProviderInterface public function shareWithUser(Application $app, $list_id, $usr_id) { - $user = $app['phraseanet.user']; - $availableRoles = array( UsrListOwner::ROLE_USER, UsrListOwner::ROLE_EDITOR, @@ -492,17 +478,17 @@ class UsrLists implements ControllerProviderInterface try { $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); /* @var $list \Entities\UsrList */ - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_EDITOR) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_EDITOR) { throw new ControllerException(_('You are not authorized to do this')); } $new_owner = \User_Adapter::getInstance($usr_id, $app); if ($list->hasAccess($new_owner, $app)) { - if ($new_owner->get_id() == $user->get_id()) { + if ($new_owner->get_id() == $app['phraseanet.user']->get_id()) { throw new ControllerException('You can not downgrade your Admin right'); } @@ -545,15 +531,13 @@ class UsrLists implements ControllerProviderInterface public function unshareWithUser(Application $app, $list_id, $usr_id) { - $user = $app['phraseanet.user']; - try { $repository = $app['EM']->getRepository('\Entities\UsrList'); - $list = $repository->findUserListByUserAndId($app, $user, $list_id); + $list = $repository->findUserListByUserAndId($app, $app['phraseanet.user'], $list_id); /* @var $list \Entities\UsrList */ - if ($list->getOwner($user, $app)->getRole() < UsrListOwner::ROLE_ADMIN) { + if ($list->getOwner($app['phraseanet.user'], $app)->getRole() < UsrListOwner::ROLE_ADMIN) { throw new \Exception(_('You are not authorized to do this')); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index 76a60aaf96..cc77a03c69 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -74,8 +74,6 @@ class WorkZone implements ControllerProviderInterface public function browserSearch(Application $app) { - $user = $app['phraseanet.user']; - $request = $app['request']; $BasketRepo = $app['EM']->getRepository('\Entities\Basket'); @@ -86,7 +84,7 @@ class WorkZone implements ControllerProviderInterface $offsetStart = max(($Page - 1) * $PerPage, 0); $Baskets = $BasketRepo->findWorkzoneBasket( - $user + $app['phraseanet.user'] , $request->query->get('Query') , $request->query->get('Year') , $request->query->get('Type') @@ -125,8 +123,6 @@ class WorkZone implements ControllerProviderInterface throw new \Exception_BadRequest(); } - $user = $app['phraseanet.user']; - $StoryWZRepo = $app['EM']->getRepository('\Entities\StoryWZ'); $alreadyFixed = $done = 0; @@ -141,17 +137,17 @@ class WorkZone implements ControllerProviderInterface throw new \Exception('You can only attach stories'); } - if (!$user->ACL()->has_access_to_base($Story->get_base_id())) { + if (!$app['phraseanet.user']->ACL()->has_access_to_base($Story->get_base_id())) { throw new \Exception_Forbidden('You do not have access to this Story'); } - if ($StoryWZRepo->findUserStory($app, $user, $Story)) { + if ($StoryWZRepo->findUserStory($app, $app['phraseanet.user'], $Story)) { $alreadyFixed++; continue; } $StoryWZ = new StoryWZ(); - $StoryWZ->setUser($user); + $StoryWZ->setUser($app['phraseanet.user']); $StoryWZ->setRecord($Story); $app['EM']->persist($StoryWZ); @@ -202,12 +198,10 @@ class WorkZone implements ControllerProviderInterface { $Story = new \record_adapter($app, $sbas_id, $record_id); - $user = $app['phraseanet.user']; - $repository = $app['EM']->getRepository('\Entities\StoryWZ'); /* @var $repository \Repositories\StoryWZRepository */ - $StoryWZ = $repository->findUserStory($app, $user, $Story); + $StoryWZ = $repository->findUserStory($app, $app['phraseanet.user'], $Story); if (!$StoryWZ) { throw new \Exception_NotFound('Story not found'); diff --git a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php index 0f19928bbb..5eac33bebd 100644 --- a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php +++ b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php @@ -233,24 +233,22 @@ class RecordsRequest extends ArrayCollection $to_remove = array(); - $user = $app['phraseanet.user']; - foreach ($elements as $id => $record) { - if (!$user->ACL()->has_access_to_record($record)) { + if (!$app['phraseanet.user']->ACL()->has_access_to_record($record)) { $to_remove[] = $id; continue; } foreach ($rightsColl as $right) { - if (!$user->ACL()->has_right_on_base($record->get_base_id(), $right)) { + if (!$app['phraseanet.user']->ACL()->has_right_on_base($record->get_base_id(), $right)) { $to_remove[] = $id; continue; } } foreach ($rightsDatabox as $right) { - if (!$user->ACL()->has_right_on_sbas($record->get_sbas_id(), $right)) { + if (!$app['phraseanet.user']->ACL()->has_right_on_sbas($record->get_sbas_id(), $right)) { $to_remove[] = $id; continue; } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index ca5a27b19f..92ae185b52 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -283,10 +283,8 @@ class Account implements ControllerProviderInterface $app->abort(400, _('Could not perform request, please contact an administrator.')); } - $user = $app['phraseanet.user']; - try { - $auth = new \Session_Authentication_Native($app, $user->get_login(), $password); + $auth = new \Session_Authentication_Native($app, $app['phraseanet.user']->get_login(), $password); $auth->challenge_password(); } catch (\Exception $e) { return $app->redirect('/account/reset-email/?notice=bad-password'); @@ -299,7 +297,7 @@ class Account implements ControllerProviderInterface return $app->redirect('/account/reset-email/?notice=mail-match'); } - if (!\mail::reset_email($app, $email, $user->get_id()) === true) { + if (!\mail::reset_email($app, $email, $app['phraseanet.user']->get_id()) === true) { return $app->redirect('/account/reset-email/?notice=mail-server'); } @@ -371,12 +369,10 @@ class Account implements ControllerProviderInterface } try { - $user = $app['phraseanet.user']; - - $auth = new \Session_Authentication_Native($app, $user->get_login(), $request->request->get('form_old_password', '')); + $auth = new \Session_Authentication_Native($app, $app['phraseanet.user']->get_login(), $request->request->get('form_old_password', '')); $auth->challenge_password(); - $user->set_password($passwordConfirm); + $app['phraseanet.user']->set_password($passwordConfirm); return $app->redirect('/account/?notice=pass-ok'); } catch (\Exception $e) { @@ -474,7 +470,6 @@ class Account implements ControllerProviderInterface */ public function displayAccount(Application $app, Request $request) { - $user = $app['phraseanet.user']; $evtMngr = $app['events-manager']; switch ($notice = $request->query->get('notice', '')) { @@ -496,10 +491,10 @@ class Account implements ControllerProviderInterface } return $app['twig']->render('account/account.html.twig', array( - 'user' => $user, + 'user' => $app['phraseanet.user'], 'notice' => $notice, 'evt_mngr' => $evtMngr, - 'notifications' => $evtMngr->list_notifications_available($user->get_id()), + 'notifications' => $evtMngr->list_notifications_available($app['phraseanet.user']->get_id()), )); } @@ -512,7 +507,6 @@ class Account implements ControllerProviderInterface */ public function updateAccount(Application $app, Request $request) { - $user = $app['phraseanet.user']; $evtMngr = $app['events-manager']; $notice = 'account-update-bad'; @@ -523,7 +517,7 @@ class Account implements ControllerProviderInterface foreach ($demands as $baseId) { try { - $register->add_request($user, \collection::get_from_base_id($app, $baseId)); + $register->add_request($app['phraseanet.user'], \collection::get_from_base_id($app, $baseId)); $notice = 'demand-ok'; } catch (\Exception $e) { @@ -570,7 +564,7 @@ class Account implements ControllerProviderInterface try { $app['phraseanet.appbox']->get_connection()->beginTransaction(); - $user->set_gender($request->request->get("form_gender")) + $app['phraseanet.user']->set_gender($request->request->get("form_gender")) ->set_firstname($request->request->get("form_firstname")) ->set_lastname($request->request->get("form_lastname")) ->set_address($request->request->get("form_address")) @@ -601,15 +595,15 @@ class Account implements ControllerProviderInterface $requestedNotifications = (array) $request->request->get('notifications', array()); - foreach ($evtMngr->list_notifications_available($user->get_id()) as $notifications) { + foreach ($evtMngr->list_notifications_available($app['phraseanet.user']->get_id()) as $notifications) { foreach ($notifications as $notification) { $notifId = $notification['id']; $notifName = sprintf('notification_%d', $notifId); if (isset($requestedNotifications[$notifId])) { - $user->setPrefs($notifName, '1'); + $app['phraseanet.user']->setPrefs($notifName, '1'); } else { - $user->setPrefs($notifName, '0'); + $app['phraseanet.user']->setPrefs($notifName, '0'); } } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index 08701bc7a7..e95626ab01 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -370,19 +370,17 @@ class Developers implements ControllerProviderInterface */ public function getApp(Application $app, Request $request, $id) { - $user = $app['phraseanet.user']; - try { $client = new \API_OAuth2_Application($app, $id); } catch (\Exception_NotFound $e) { $app->abort(404); } - $token = $client->get_user_account($user)->get_token()->get_value(); + $token = $client->get_user_account($app['phraseanet.user'])->get_token()->get_value(); return $app['twig']->render('developers/application.html.twig', array( "application" => $client, - "user" => $user, + "user" => $app['phraseanet.user'], "token" => $token )); } diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index f55af2ed29..36f6ceda27 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -28,15 +28,14 @@ class Prod extends Helper ); $bases = $fields = $dates = array(); - $user = $this->app['phraseanet.user']; - if ( ! $user instanceof \User_Adapter) { + if ( ! $this->app['phraseanet.user'] instanceof \User_Adapter) { return $search_datas; } - $searchSet = $user->getPrefs('search'); + $searchSet = $this->app['phraseanet.user']->getPrefs('search'); - foreach ($user->ACL()->get_granted_sbas() as $databox) { + foreach ($this->app['phraseanet.user']->ACL()->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); $bases[$sbas_id] = array( @@ -46,7 +45,7 @@ class Prod extends Helper 'sbas_id' => $sbas_id ); - foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { + foreach ($this->app['phraseanet.user']->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { $selected = ($searchSet && isset($searchSet->bases) && isset($searchSet->bases->$sbas_id)) ? (in_array($coll->get_base_id(), $searchSet->bases->$sbas_id)) : true; @@ -85,7 +84,7 @@ class Prod extends Helper if ( ! $bases[$sbas_id]['thesaurus']) { continue; } - if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th')) { + if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th')) { continue; } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 3350e34292..a679234295 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -70,9 +70,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper protected function delete_user(\User_Adapter $user) { - $master = $this->app['phraseanet.user']; - - $list = array_keys($master->ACL()->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['phraseanet.user']->ACL()->get_granted_base(array('canadmin'))); $user->ACL()->revoke_access_from_bases($list); @@ -85,9 +83,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function get_users_rights() { - $user = $this->app['phraseanet.user']; - - $list = array_keys($user->ACL()->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['phraseanet.user']->ACL()->get_granted_base(array('canadmin'))); $sql = "SELECT b.sbas_id, @@ -555,9 +551,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper throw new \Exception_Forbidden('You are not the owner of the template'); } - $current_user = $this->app['phraseanet.user']; - - $base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['phraseanet.user']->ACL()->get_granted_base(array('canadmin'))); foreach ($this->users as $usr_id) { $user = \User_adapter::getInstance($usr_id, $this->app); @@ -625,9 +619,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function resetRights() { - $authUser = $this->app['phraseanet.user']; - $adminACL = $authUser->ACL(); - $base_ids = array_keys($adminACL->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['phraseanet.user']->ACL()->get_granted_base(array('canadmin'))); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, $this->app); @@ -636,7 +628,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper if ($user->is_template()) { $template = $user; - if ($template->get_template_owner()->get_id() !== $authUser->get_id()) { + if ($template->get_template_owner()->get_id() !== $this->app['phraseanet.user']->get_id()) { continue; } } diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index 64eb3b2b75..a093af36d6 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -56,7 +56,6 @@ class Manage extends Helper , 'offset_start' => 0 ); - $user = $this->app['phraseanet.user']; $query = new \User_Query($this->app); if (is_array($this->query_parms['base_id'])) @@ -68,7 +67,7 @@ class Manage extends Helper ->like($this->query_parms['like_field'], $this->query_parms['like_value']) ->get_inactives($this->query_parms['inactives']) ->include_templates(false) - ->on_bases_where_i_am($user->ACL(), array('canadmin')) + ->on_bases_where_i_am($this->app['phraseanet.user']->ACL(), array('canadmin')) ->execute(); return $this->results->get_results(); @@ -95,7 +94,6 @@ class Manage extends Helper , 'offset_start' => $offset_start ); - $user = $this->app['phraseanet.user']; $query = new \User_Query($this->app); if (is_array($this->query_parms['base_id'])) @@ -107,7 +105,7 @@ class Manage extends Helper ->like($this->query_parms['like_field'], $this->query_parms['like_value']) ->get_inactives($this->query_parms['inactives']) ->include_templates(true) - ->on_bases_where_i_am($user->ACL(), array('canadmin')) + ->on_bases_where_i_am($this->app['phraseanet.user']->ACL(), array('canadmin')) ->limit($offset_start, $results_quantity) ->execute(); @@ -196,11 +194,9 @@ class Manage extends Helper throw new \Exception_InvalidArgument(_('Invalid template name')); } - $user = $this->app['phraseanet.user']; - $created_user = \User_Adapter::create($this->app, $name, \random::generatePassword(16), null, false, false); - $created_user->set_template($user); - $this->usr_id = $user->get_id(); + $created_user->set_template($this->app['phraseanet.user']); + $this->usr_id = $this->app['phraseanet.user']->get_id(); return $created_user; } diff --git a/lib/Alchemy/Phrasea/Helper/WorkZone.php b/lib/Alchemy/Phrasea/Helper/WorkZone.php index 9525c76d83..781fef2c34 100644 --- a/lib/Alchemy/Phrasea/Helper/WorkZone.php +++ b/lib/Alchemy/Phrasea/Helper/WorkZone.php @@ -38,8 +38,6 @@ class WorkZone extends Helper */ public function getContent($sort) { - $current_user = $this->app['phraseanet.user']; - /* @var $repo_baskets \Doctrine\Repositories\BasketRepository */ $repo_baskets = $this->app['EM']->getRepository('Entities\Basket'); @@ -47,13 +45,13 @@ class WorkZone extends Helper $ret = new \Doctrine\Common\Collections\ArrayCollection(); - $baskets = $repo_baskets->findActiveByUser($current_user, $sort); - $validations = $repo_baskets->findActiveValidationByUser($current_user, $sort); + $baskets = $repo_baskets->findActiveByUser($this->app['phraseanet.user'], $sort); + $validations = $repo_baskets->findActiveValidationByUser($this->app['phraseanet.user'], $sort); /* @var $repo_stories \Doctrine\Repositories\StoryWZRepository */ $repo_stories = $this->app['EM']->getRepository('Entities\StoryWZ'); - $stories = $repo_stories->findByUser($this->app, $current_user, $sort); + $stories = $repo_stories->findByUser($this->app, $this->app['phraseanet.user'], $sort); $ret->set(self::BASKETS, $baskets); $ret->set(self::VALIDATIONS, $validations); diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index c84e6ab7b7..c7bcfc22e6 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -124,8 +124,6 @@ class PDF protected function print_thumbnailGrid($links = false) { - $user = $this->app['phraseanet.user']; - $NDiapoW = 3; $NDiapoH = 4; @@ -168,7 +166,7 @@ class PDF $fimg = $subdef->get_pathfile(); - if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") + if (!$this->app['phraseanet.user']->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") && $subdef->get_type() == \media_subdef::TYPE_IMAGE) { $fimg = \recordutils_image::watermark($this->app, $subdef); } @@ -310,8 +308,6 @@ class PDF protected function print_preview($withtdm, $write_caption) { - $user = $this->app['phraseanet.user']; - if ($withtdm === true) { $this->print_thumbnailGrid($this->pdf, $this->records, true); } @@ -433,7 +429,7 @@ class PDF $f = $subdef->get_pathfile(); - if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") + if (!$this->app['phraseanet.user']->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") && $subdef->get_type() == \media_subdef::TYPE_IMAGE) $f = \recordutils_image::watermark($this->app, $subdef); diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index 737c35f282..e84acf065c 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -727,9 +727,7 @@ class API_V1_adapter extends API_V1_Abstract $offset_start = max($request->get('offset_start', 0), 0); $per_page = min(max($request->get('per_page', 10), 1), 20); - $user = $app['phraseanet.user']; - /* @var $user \User_Adapter */ - $baseIds = array_keys($user->ACL()->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('canaddrecord'))); $lazaretFiles = array(); @@ -825,7 +823,6 @@ class API_V1_adapter extends API_V1_Abstract */ public function search_records(Request $request) { - $user = $this->app['phraseanet.user']; $result = new API_V1_result($request, $this); $search_type = ($request->get('search_type') @@ -866,15 +863,14 @@ class API_V1_adapter extends API_V1_Abstract $options = new searchEngine_options(); - $params['bases'] = is_array($params['bases']) ? $params['bases'] : array_keys($user->ACL()->get_granted_base()); + $params['bases'] = is_array($params['bases']) ? $params['bases'] : array_keys($this->app['phraseanet.user']->ACL()->get_granted_base()); - /* @var $user \User_Adapter */ - if ($user->ACL()->has_right('modifyrecord')) { + if ($this->app['phraseanet.user']->ACL()->has_right('modifyrecord')) { $options->set_business_fields(array()); $BF = array(); - foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection) { + foreach ($this->app['phraseanet.user']->ACL()->get_granted_base(array('canmodifrecord')) as $collection) { if (count($params['bases']) === 0 || in_array($collection->get_base_id(), $params['bases'])) { $BF[] = $collection->get_base_id(); } @@ -884,7 +880,7 @@ class API_V1_adapter extends API_V1_Abstract $options->set_business_fields(array()); } - $options->set_bases($params['bases'], $user->ACL()); + $options->set_bases($params['bases'], $this->app['phraseanet.user']->ACL()); if ( ! is_array($params['fields'])) { $params['fields'] = array(); @@ -1222,10 +1218,8 @@ class API_V1_adapter extends API_V1_Abstract throw new API_V1_exception_badrequest('Missing basket name parameter'); } - $user = $this->app['phraseanet.user']; - $Basket = new \Entities\Basket(); - $Basket->setOwner($user); + $Basket->setOwner($this->app['phraseanet.user']); $Basket->setName($name); $this->app['EM']->persist($Basket); diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 93b5b7f83f..5bb7eb4661 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -465,8 +465,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public static function saveQuery(Application $app, $query) { try { - $user = $app['phraseanet.user']; - $sql = "INSERT INTO dsel (id, name, usr_id, query) VALUES (null, :name, :usr_id, :query)"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -477,8 +475,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface )); $stmt->closeCursor(); - if ($user->getPrefs('start_page') == 'LAST_QUERY') - $user->setPrefs('start_page_query', $query); + if ($app['phraseanet.user']->getPrefs('start_page') == 'LAST_QUERY') + $app['phraseanet.user']->setPrefs('start_page_query', $query); } catch (Exception $e) { return false; } diff --git a/lib/classes/databox/cgu.class.php b/lib/classes/databox/cgu.class.php index 91e85a59a8..05b1ea7bee 100644 --- a/lib/classes/databox/cgu.class.php +++ b/lib/classes/databox/cgu.class.php @@ -51,10 +51,6 @@ class databox_cgu { $terms = array(); - if ( ! $home) { - $user = $app['phraseanet.user']; - } - foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { $cgus = $databox->get_cgus(); @@ -68,10 +64,10 @@ class databox_cgu $userValidation = true; if ( ! $home) { - if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + if ( ! $app['phraseanet.user']->ACL()->has_access_to_sbas($databox->get_sbas_id())) { continue; } - $userValidation = ($user->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== ''); + $userValidation = ($app['phraseanet.user']->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== ''); } if ($userValidation) diff --git a/lib/classes/databox/status.class.php b/lib/classes/databox/status.class.php index e3fe6da995..35615380dc 100644 --- a/lib/classes/databox/status.class.php +++ b/lib/classes/databox/status.class.php @@ -125,9 +125,7 @@ class databox_status return self::$_statuses; } - $user = $app['phraseanet.user']; - - $sbas_ids = $user->ACL()->get_granted_sbas(); + $sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); $statuses = array(); @@ -146,11 +144,9 @@ class databox_status public static function getSearchStatus(Application $app) { - $user = $app['phraseanet.user']; - $statuses = array(); - $sbas_ids = $user->ACL()->get_granted_sbas(); + $sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); $see_all = array(); @@ -158,7 +154,7 @@ class databox_status $see_all[$databox->get_sbas_id()] = false; foreach ($databox->get_collections() as $collection) { - if ($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) { + if ($app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) { $see_all[$databox->get_sbas_id()] = true; break; } @@ -176,8 +172,9 @@ class databox_status $see_this = isset($see_all[$sbas_id]) ? $see_all[$sbas_id] : false; - if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) + if ($app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) { $see_this = true; + } foreach ($status as $bit => $props) { diff --git a/lib/classes/deprecated/prodUtils.php b/lib/classes/deprecated/prodUtils.php index 97b01e3732..912adef73e 100644 --- a/lib/classes/deprecated/prodUtils.php +++ b/lib/classes/deprecated/prodUtils.php @@ -20,8 +20,7 @@ function deleteRecord(Application $app, $lst, $del_children) { $BE_repository = $app['EM']->getRepository('\Entities\BasketElement'); - $user = $app['phraseanet.user']; - $ACL = $user->ACL(); + $ACL = $app['phraseanet.user']->ACL(); $lst = explode(";", $lst); diff --git a/lib/classes/eventsmanager/notify/autoregister.class.php b/lib/classes/eventsmanager/notify/autoregister.class.php index 40bf4a2baa..c31dc8fc63 100644 --- a/lib/classes/eventsmanager/notify/autoregister.class.php +++ b/lib/classes/eventsmanager/notify/autoregister.class.php @@ -266,13 +266,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract return false; } - try { - $user = $this->app['phraseanet.user']; - } catch (Exception $e) { - return false; - } - - if ($user->ACL()->has_right('manageusers') === true) { + if ($this->app['phraseanet.user']->ACL()->has_right('manageusers') === true) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/order.class.php b/lib/classes/eventsmanager/notify/order.class.php index 35ddb76ce6..b023e4fcf9 100644 --- a/lib/classes/eventsmanager/notify/order.class.php +++ b/lib/classes/eventsmanager/notify/order.class.php @@ -240,13 +240,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract return false; } - try { - $user = $this->app['phraseanet.user']; - } catch (Exception $e) { - return false; - } - - if ($user->ACL()->has_right('order_master')) { + if ($this->app['phraseanet.user']->ACL()->has_right('order_master')) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/register.class.php b/lib/classes/eventsmanager/notify/register.class.php index d4e97ca200..58a1e32141 100644 --- a/lib/classes/eventsmanager/notify/register.class.php +++ b/lib/classes/eventsmanager/notify/register.class.php @@ -270,13 +270,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract return false; } - try { - $user = $this->app['phraseanet.user']; - } catch (Exception $e) { - return false; - } - - if ($user->ACL()->has_right('manageusers')) { + if ($this->app['phraseanet.user']->ACL()->has_right('manageusers')) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/validationdone.class.php b/lib/classes/eventsmanager/notify/validationdone.class.php index 93795b3a59..3cac835a36 100644 --- a/lib/classes/eventsmanager/notify/validationdone.class.php +++ b/lib/classes/eventsmanager/notify/validationdone.class.php @@ -215,13 +215,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract return false; } - try { - $user = $this->app['phraseanet.user']; - } catch (Exception $e) { - return false; - } - - if ($user->ACL()->has_right('push')) { + if ($this->app['phraseanet.user']->ACL()->has_right('push')) { $bool = true; } diff --git a/lib/classes/gatekeeper.class.php b/lib/classes/gatekeeper.class.php index 8b09b8fffa..058a80450e 100644 --- a/lib/classes/gatekeeper.class.php +++ b/lib/classes/gatekeeper.class.php @@ -160,17 +160,15 @@ class gatekeeper return; } - $user = $this->app['phraseanet.user']; - switch ($this->_directory) { case 'admin': case 'taskmanager': - if (!$user->ACL()->has_access_to_module('admin')) { + if (!$this->app['phraseanet.user']->ACL()->has_access_to_module('admin')) { phrasea::headers(403); } break; case 'thesaurus2': - if (!$user->ACL()->has_access_to_module('thesaurus')) { + if (!$this->app['phraseanet.user']->ACL()->has_access_to_module('thesaurus')) { phrasea::headers(403); } break; @@ -180,12 +178,12 @@ class gatekeeper $this->token_access(); break; case 'upload': - if (!$user->ACL()->has_right('addrecord')) { + if (!$this->app['phraseanet.user']->ACL()->has_right('addrecord')) { phrasea::headers(403); } break; case 'report': - if (!$user->ACL()->has_right('report')) { + if (!$this->app['phraseanet.user']->ACL()->has_right('report')) { phrasea::headers(403); } break; diff --git a/lib/classes/liste.class.php b/lib/classes/liste.class.php index 44962838de..fd6c41008b 100644 --- a/lib/classes/liste.class.php +++ b/lib/classes/liste.class.php @@ -12,8 +12,6 @@ class liste $okbrec = array(); - $user = $app['phraseanet.user']; - foreach ($lst as $basrec) { $basrec = explode("_", $basrec); if ( ! $basrec || count($basrec) != 2) { @@ -25,25 +23,23 @@ class liste continue; } - if ($user->ACL()->has_hd_grant($record)) { + if ($app['phraseanet.user']->ACL()->has_hd_grant($record)) { $okbrec[] = implode('_', $basrec); - ; continue; } - if ($user->ACL()->has_preview_grant($record)) { + if ($app['phraseanet.user']->ACL()->has_preview_grant($record)) { $okbrec[] = implode('_', $basrec); - ; continue; } - if ( ! $user->ACL()->has_access_to_base($record->get_base_id())) + if ( ! $app['phraseanet.user']->ACL()->has_access_to_base($record->get_base_id())) continue; try { $connsbas = connection::getPDOConnection($app, $basrec[0]); - $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $user->ACL()->get_mask_xor($record->get_base_id()) . ') - & ' . $user->ACL()->get_mask_and($record->get_base_id()) . ')=0' . + $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $app['phraseanet.user']->ACL()->get_mask_xor($record->get_base_id()) . ') + & ' . $app['phraseanet.user']->ACL()->get_mask_and($record->get_base_id()) . ')=0' . ' AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); diff --git a/lib/classes/phrasea.class.php b/lib/classes/phrasea.class.php index 91b733c35f..befe33ab9a 100644 --- a/lib/classes/phrasea.class.php +++ b/lib/classes/phrasea.class.php @@ -75,7 +75,6 @@ class phrasea public function getHome(Application $app, $type = 'PUBLI', $context = 'prod') { - $user = $app['phraseanet.user']; if ($type == 'HELP') { if (file_exists($app['phraseanet.registry']->get('GV_RootPath') . "config/help_" . $app['locale.I18n'] . ".php")) { require($app['phraseanet.registry']->get('GV_RootPath') . "config/help_" . $app['locale.I18n'] . ".php"); @@ -99,17 +98,16 @@ class phrasea $bas = array(); - $searchSet = json_decode($user->getPrefs('search')); + $searchSet = json_decode($app['phraseanet.user']->getPrefs('search')); if ($searchSet && isset($searchSet->bases)) { foreach ($searchSet->bases as $bases) $bas = array_merge($bas, $bases); } else { - $user = $app['phraseanet.user']; - $bas = array_keys($user->ACL()->get_granted_base()); + $bas = array_keys($app['phraseanet.user']->ACL()->get_granted_base()); } - $start_page_query = $user->getPrefs('start_page_query'); + $start_page_query = $app['phraseanet.user']->getPrefs('start_page_query'); if ($context == "prod") { $parm["bas"] = $bas; @@ -126,7 +124,7 @@ class phrasea $parm["datefield"] = ''; } if ($context == "client") { - $parm["mod"] = $user->getPrefs('client_view'); + $parm["mod"] = $app['phraseanet.user']->getPrefs('client_view'); $parm["bas"] = $bas; $parm["qry"] = $start_page_query; $parm["pag"] = ''; diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index fc0c423598..d6c9377c42 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -394,14 +394,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface { $dstatus = databox_status::getDisplayStatus($this->app); $sbas_id = $this->get_sbas_id(); - $user = $this->app['phraseanet.user']; $status = ''; if (isset($dstatus[$sbas_id])) { foreach ($dstatus[$sbas_id] as $n => $statbit) { if ($statbit['printable'] == '0' && - !$user->ACL()->has_right_on_base($this->base_id, 'chgstatus')) { + !$this->app['phraseanet.user']->ACL()->has_right_on_base($this->base_id, 'chgstatus')) { continue; } diff --git a/lib/classes/record/exportElement.class.php b/lib/classes/record/exportElement.class.php index 42a500f2c5..7a397399fe 100644 --- a/lib/classes/record/exportElement.class.php +++ b/lib/classes/record/exportElement.class.php @@ -82,8 +82,6 @@ class record_exportElement extends record_adapter $sbas_id = phrasea::sbasFromBas($this->app, $this->base_id); - $user = $this->app['phraseanet.user']; - $subdefgroups = $this->app['phraseanet.appbox']->get_databox($sbas_id)->get_subdef_structure(); $subdefs = array(); @@ -101,17 +99,17 @@ class record_exportElement extends record_adapter 'thumbnail' => true ); - if ($user->ACL()->has_right_on_base($this->get_base_id(), 'candwnldhd')) { + if ($this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'candwnldhd')) { $go_dl['document'] = true; } - if ($user->ACL()->has_right_on_base($this->get_base_id(), 'candwnldpreview')) { + if ($this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'candwnldpreview')) { $go_dl['preview'] = true; } - if ($user->ACL()->has_hd_grant($this)) { + if ($this->app['phraseanet.user']->ACL()->has_hd_grant($this)) { $go_dl['document'] = true; $go_dl['preview'] = true; } - if ($user->ACL()->has_preview_grant($this)) { + if ($this->app['phraseanet.user']->ACL()->has_preview_grant($this)) { $go_dl['preview'] = true; } @@ -121,14 +119,14 @@ class record_exportElement extends record_adapter ->who_have_right(array('order_master')) ->execute()->get_results(); - $go_cmd = (count($masters) > 0 && $user->ACL()->has_right_on_base($this->base_id, 'cancmd')); + $go_cmd = (count($masters) > 0 && $this->app['phraseanet.user']->ACL()->has_right_on_base($this->base_id, 'cancmd')); $orderable['document'] = false; $downloadable['document'] = false; if (isset($sd['document']) && is_file($sd['document']->get_pathfile())) { if ($go_dl['document'] === true) { - if ($user->ACL()->is_restricted_download($this->base_id)) { + if ($this->app['phraseanet.user']->ACL()->is_restricted_download($this->base_id)) { $this->remain_hd --; if ($this->remain_hd >= 0) $downloadable['document'] = array( @@ -176,7 +174,7 @@ class record_exportElement extends record_adapter if (isset($sd[$name]) && is_file($sd[$name]->get_pathfile())) { if ($class == 'document') { - if ($user->ACL()->is_restricted_download($this->base_id)) { + if ($this->app['phraseanet.user']->ACL()->is_restricted_download($this->base_id)) { $this->remain_hd --; if ($this->remain_hd >= 0) $downloadable[$name] = array( diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index f2d4fb43fb..277eefb804 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -316,9 +316,7 @@ class record_preview extends record_adapter $tab = array(); - $user = $this->app['phraseanet.user']; - - $report = $user->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); + $report = $this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); $connsbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); @@ -330,7 +328,7 @@ class record_preview extends record_adapter if ( ! $report) { $sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; - $params[':usr_id'] = $user->get_id(); + $params[':usr_id'] = $this->app['phraseanet.user']->get_id(); $params[':site'] = $this->app['phraseanet.registry']->get('GV_sit'); } @@ -401,8 +399,7 @@ class record_preview extends record_adapter return $this->view_popularity; } - $user = $this->app['phraseanet.user']; - $report = $user->ACL()->has_right_on_base( + $report = $this->app['phraseanet.user']->ACL()->has_right_on_base( $this->get_base_id(), 'canreport'); if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { @@ -491,8 +488,7 @@ class record_preview extends record_adapter return $this->refferer_popularity; } - $user = $this->app['phraseanet.user']; - $report = $user->ACL()->has_right_on_base( + $report = $this->app['phraseanet.user']->ACL()->has_right_on_base( $this->get_base_id(), 'canreport'); if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { @@ -566,14 +562,11 @@ class record_preview extends record_adapter */ public function get_download_popularity() { - if ( ! is_null($this->download_popularity)) { return $this->download_popularity; } - $user = $this->app['phraseanet.user']; - $report = $user->ACL()->has_right_on_base( - $this->get_base_id(), 'canreport'); + $report = $this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); $ret = false; if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php index 06efba8a24..835a7381d0 100644 --- a/lib/classes/set/export.class.php +++ b/lib/classes/set/export.class.php @@ -44,8 +44,6 @@ class set_export extends set_abstract { $this->app = $app; - $user = $app['phraseanet.user']; - $download_list = array(); $remain_hd = array(); @@ -53,7 +51,7 @@ class set_export extends set_abstract if ($storyWZid) { $repository = $app['EM']->getRepository('\\Entities\\StoryWZ'); - $storyWZ = $repository->findByUserAndId($this->app, $user, $storyWZid); + $storyWZ = $repository->findByUserAndId($this->app, $app['phraseanet.user'], $storyWZid); $lst = $storyWZ->getRecord($this->app)->get_serialize_key(); } @@ -62,7 +60,7 @@ class set_export extends set_abstract $repository = $app['EM']->getRepository('\Entities\Basket'); /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $sstid, $user, false); + $Basket = $repository->findUserBasket($this->app, $sstid, $app['phraseanet.user'], false); foreach ($Basket->getElements() as $basket_element) { /* @var $basket_element \Entities\BasketElement */ @@ -70,8 +68,8 @@ class set_export extends set_abstract $record_id = $basket_element->getRecord($this->app)->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($user->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = $user->ACL()->remaining_download($base_id); + if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -108,9 +106,8 @@ class set_export extends set_abstract $record_id = $child_basrec->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($user->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = - $user->ACL()->remaining_download($base_id); + if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -132,9 +129,8 @@ class set_export extends set_abstract $record_id = $record->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($user->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = - $user->ACL()->remaining_download($base_id); + if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -168,7 +164,7 @@ class set_export extends set_abstract $this->businessFieldsAccess = false; foreach ($this->elements as $download_element) { - if ($user->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { + if ($app['phraseanet.user']->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { $this->businessFieldsAccess = true; } @@ -220,11 +216,11 @@ class set_export extends set_abstract $display_ftp = array(); - $hasadminright = $user->ACL()->has_right('addrecord') - || $user->ACL()->has_right('deleterecord') - || $user->ACL()->has_right('modifyrecord') - || $user->ACL()->has_right('coll_manage') - || $user->ACL()->has_right('coll_modify_struct'); + $hasadminright = $app['phraseanet.user']->ACL()->has_right('addrecord') + || $app['phraseanet.user']->ACL()->has_right('deleterecord') + || $app['phraseanet.user']->ACL()->has_right('modifyrecord') + || $app['phraseanet.user']->ACL()->has_right('coll_manage') + || $app['phraseanet.user']->ACL()->has_right('coll_modify_struct'); $this->ftp_datas = array(); @@ -232,7 +228,7 @@ class set_export extends set_abstract $display_ftp = $display_download; $this->total_ftp = $this->total_download; - $lst_base_id = array_keys($user->ACL()->get_granted_base()); + $lst_base_id = array_keys($app['phraseanet.user']->ACL()->get_granted_base()); if ($hasadminright) { $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP, @@ -276,7 +272,7 @@ class set_export extends set_abstract 'passifFTP' => false, 'retryFTP' => 5, 'mailFTP' => '', - 'sendermail' => $user->get_email() + 'sendermail' => $app['phraseanet.user']->get_email() ); $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -300,7 +296,7 @@ class set_export extends set_abstract 'passifFTP' => ($row['passifFTP'] > 0), 'retryFTP' => $row['retryFTP'], 'mailFTP' => $row['usr_mail'], - 'sendermail' => $user->get_email() + 'sendermail' => $app['phraseanet.user']->get_email() ); } @@ -847,13 +843,6 @@ class set_export extends set_abstract */ public static function log_download(Array $list, $type, $anonymous = false, $comment = '') { - $user = false; - if ($anonymous) { - - } else { - $user = $this->app['phraseanet.user']; - } - $tmplog = array(); $files = $list['files']; @@ -879,8 +868,9 @@ class set_export extends set_abstract $log["poids"] = $obj["size"]; $log["shortXml"] = $record_object->get_caption()->serialize(caption_record::SERIALIZE_XML); $tmplog[$record_object->get_base_id()][] = $log; - if (!$anonymous && $o == 'document') - $user->ACL()->remove_remaining($record_object->get_base_id()); + if (!$anonymous && $o == 'document') { + $this->app['phraseanet.user']->ACL()->remove_remaining($record_object->get_base_id()); + } } unset($record_object); @@ -903,11 +893,11 @@ class set_export extends set_abstract $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); foreach ($list_base as $base_id) { - if ($user->ACL()->is_restricted_download($base_id)) { + if ($this->app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { $params = array( - ':remain_dl' => $user->ACL()->remaining_download($base_id) + ':remain_dl' => $this->app['phraseanet.user']->ACL()->remaining_download($base_id) , ':base_id' => $base_id - , ':usr_id' => $user->get_id() + , ':usr_id' => $this->app['phraseanet.user']->get_id() ); $stmt->execute($params); diff --git a/lib/classes/set/exportftp.class.php b/lib/classes/set/exportftp.class.php index f16253f02c..2b7b8a2f60 100644 --- a/lib/classes/set/exportftp.class.php +++ b/lib/classes/set/exportftp.class.php @@ -33,7 +33,6 @@ class set_exportftp extends set_export */ public function export_ftp($usr_to, $host, $login, $password, $ssl, $retry, $passif, $destfolder, $makedirectory, $logfile) { - $user_f = $this->app['phraseanet.user']; $conn = $this->app['phraseanet.appbox']->get_connection(); $email_dest = ''; @@ -44,7 +43,7 @@ class set_exportftp extends set_export $text_mail_receiver = "Bonjour,\n" . "L'utilisateur " - . $user_f->get_display_name() . " (login : " . $user_f->get_login() . ") " + . $this->app['phraseanet.user']->get_display_name() . " (login : " . $this->app['phraseanet.user']->get_login() . ") " . "a fait un transfert FTP sur le serveur ayant comme adresse \"" . $host . "\" avec le login \"" . $login . "\" " . "et pour repertoire de destination \"" @@ -102,10 +101,10 @@ class set_exportftp extends set_export , ':pwd' => $password , ':passif' => ($passif == "1" ? "1" : "0") , ':destfolder' => $destfolder - , ':sendermail' => $user_f->get_email() + , ':sendermail' => $this->app['phraseanet.user']->get_email() , ':text_mail_receiver' => $text_mail_receiver , ':text_mail_sender' => $text_mail_sender - , ':usr_id' => $user_f->get_id() + , ':usr_id' => $this->app['phraseanet.user']->get_id() , ':foldertocreate' => $makedirectory , ':logfile' => ( ! ! $logfile ? '1' : '0') ); diff --git a/lib/classes/set/order.class.php b/lib/classes/set/order.class.php index 0924b6194e..c0c1bbc574 100644 --- a/lib/classes/set/order.class.php +++ b/lib/classes/set/order.class.php @@ -230,7 +230,6 @@ class set_order extends set_abstract throw new Exception_NotFound('unknown order ' . $id); $current_user = User_Adapter::getInstance($row['usr_id'], $app); - $user = $app['phraseanet.user']; $this->id = $row['id']; $this->user = $current_user; @@ -241,7 +240,7 @@ class set_order extends set_abstract $this->total = (int) $row['total']; $this->ssel_id = (int) $row['ssel_id']; - $base_ids = array_keys($user->ACL()->get_granted_base(array('order_master'))); + $base_ids = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('order_master'))); $sql = 'SELECT e.base_id, e.record_id, e.order_master_id, e.id, e.deny FROM order_elements e diff --git a/lib/classes/set/selection.class.php b/lib/classes/set/selection.class.php index b5e5fb0cc4..e67bfa03d0 100644 --- a/lib/classes/set/selection.class.php +++ b/lib/classes/set/selection.class.php @@ -53,8 +53,6 @@ class set_selection extends set_abstract */ public function grep_authorized(Array $rights = array(), Array $sbas_rights = array()) { - $user = $this->app['phraseanet.user']; - $to_remove = array(); foreach ($this->elements as $id => $record) { @@ -62,26 +60,26 @@ class set_selection extends set_abstract $sbas_id = $record->get_sbas_id(); $record_id = $record->get_record_id(); if ( ! $rights) { - if ($user->ACL()->has_hd_grant($record)) { + if ($this->app['phraseanet.user']->ACL()->has_hd_grant($record)) { continue; } - if ($user->ACL()->has_preview_grant($record)) { + if ($this->app['phraseanet.user']->ACL()->has_preview_grant($record)) { continue; } - if ( ! $user->ACL()->has_access_to_base($base_id)) { + if ( ! $this->app['phraseanet.user']->ACL()->has_access_to_base($base_id)) { $to_remove[] = $id; continue; } } else { foreach ($rights as $right) { - if ( ! $user->ACL()->has_right_on_base($base_id, $right)) { + if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_base($base_id, $right)) { $to_remove[] = $id; continue; } } foreach ($sbas_rights as $right) { - if ( ! $user->ACL()->has_right_on_sbas($sbas_id, $right)) { + if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, $right)) { $to_remove[] = $id; continue; } @@ -93,8 +91,8 @@ class set_selection extends set_abstract $sql = 'SELECT record_id FROM record - WHERE ((status ^ ' . $user->ACL()->get_mask_xor($base_id) . ') - & ' . $user->ACL()->get_mask_and($base_id) . ')=0 + WHERE ((status ^ ' . $this->app['phraseanet.user']->ACL()->get_mask_xor($base_id) . ') + & ' . $this->app['phraseanet.user']->ACL()->get_mask_and($base_id) . ')=0 AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); diff --git a/lib/classes/task/period/outofdate.class.php b/lib/classes/task/period/outofdate.class.php index c1a34050bb..7a44d1c0f5 100755 --- a/lib/classes/task/period/outofdate.class.php +++ b/lib/classes/task/period/outofdate.class.php @@ -310,10 +310,9 @@ class task_period_outofdate extends task_abstract // ==================================================================== public function getInterfaceHTML() { - $user = $this->dependencyContainer['phraseanet.user']; ob_start(); - $sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage')); + $sbas_list = $this->dependencyContainer['phraseanet.user']->ACL()->get_granted_sbas(array('bas_manage')); ?>