diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index 23c0da35d5..bf6ca99967 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -665,7 +665,7 @@ class API_V1_adapter extends API_V1_Abstract $collection = \collection::get_from_base_id($this->app, $request->get('base_id')); - if (!$app['phraseanet.user']->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord')) { + if (!$app['authentication']->getUser()->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord')) { throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_name())); } @@ -678,7 +678,7 @@ class API_V1_adapter extends API_V1_Abstract } $session = new Entities\LazaretSession(); - $session->setUsrId($app['phraseanet.user']->get_id()); + $session->setUsrId($app['authentication']->getUser()->get_id()); $app['EM']->persist($session); $app['EM']->flush(); @@ -740,7 +740,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); - $baseIds = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['authentication']->getUser()->ACL()->get_granted_base(array('canaddrecord'))); $lazaretFiles = array(); @@ -778,7 +778,7 @@ class API_V1_adapter extends API_V1_Abstract throw new \API_V1_exception_notfound(sprintf('Lazaret file id %d not found', $lazaret_id)); } - if (!$app['phraseanet.user']->ACL()->has_right_on_base($lazaretFile->getBaseId(), 'canaddrecord')) { + if (!$app['authentication']->getUser()->ACL()->has_right_on_base($lazaretFile->getBaseId(), 'canaddrecord')) { throw new \API_V1_exception_forbidden('You do not have access to this quarantine item'); } @@ -943,7 +943,7 @@ class API_V1_adapter extends API_V1_Abstract }, (array) $this->app['phraseanet.appbox'] ->get_databox($databox_id) ->get_record($record_id) - ->get_container_baskets($this->app['EM'], $this->app['phraseanet.user']) + ->get_container_baskets($this->app['EM'], $this->app['authentication']->getUser()) ); $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); @@ -1233,7 +1233,7 @@ class API_V1_adapter extends API_V1_Abstract { $result = new API_V1_result($this->app, $request, $this); - $usr_id = $session = $this->app['phraseanet.user']->get_id(); + $usr_id = $session = $this->app['authentication']->getUser()->get_id(); $result->set_datas(array('baskets' => $this->list_baskets($usr_id))); @@ -1251,7 +1251,7 @@ class API_V1_adapter extends API_V1_Abstract $repo = $this->app['EM']->getRepository('\Entities\Basket'); /* @var $repo \Repositories\BasketRepository */ - $baskets = $repo->findActiveByUser($this->app['phraseanet.user']); + $baskets = $repo->findActiveByUser($this->app['authentication']->getUser()); $ret = array(); foreach ($baskets as $basket) { @@ -1278,7 +1278,7 @@ class API_V1_adapter extends API_V1_Abstract } $Basket = new \Entities\Basket(); - $Basket->setOwner($this->app['phraseanet.user']); + $Basket->setOwner($this->app['authentication']->getUser()); $Basket->setName($name); $this->app['EM']->persist($Basket); @@ -1302,7 +1302,7 @@ class API_V1_adapter extends API_V1_Abstract /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], true); + $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true); $this->app['EM']->remove($Basket); $this->app['EM']->flush(); @@ -1324,7 +1324,7 @@ class API_V1_adapter extends API_V1_Abstract /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], false); + $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), false); $result->set_datas( array( @@ -1384,14 +1384,14 @@ class API_V1_adapter extends API_V1_Abstract 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), - 'readonly' => $user->get_id() != $this->app['phraseanet.user']->get_id(), + 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), ), 'agreement' => $validation_datas->getAgreement(), 'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM), 'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(), ); - if ($user->get_id() == $this->app['phraseanet.user']->get_id()) { + if ($user->get_id() == $this->app['authentication']->getUser()->get_id()) { $agreement = $validation_datas->getAgreement(); $note = null === $validation_datas->getNote() ? '' : $validation_datas->getNote(); } @@ -1423,7 +1423,7 @@ class API_V1_adapter extends API_V1_Abstract /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], true); + $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true); $Basket->setName($name); $this->app['EM']->merge($Basket); @@ -1451,7 +1451,7 @@ class API_V1_adapter extends API_V1_Abstract /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], true); + $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true); $Basket->setDescription($desc); $this->app['EM']->merge($Basket); @@ -1819,7 +1819,7 @@ class API_V1_adapter extends API_V1_Abstract 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), - 'readonly' => $user->get_id() != $this->app['phraseanet.user']->get_id(), + 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), ); } @@ -1833,9 +1833,9 @@ class API_V1_adapter extends API_V1_Abstract array( 'validation_users' => $users, 'expires_on' => $expires_on_atom, - 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['phraseanet.user']), - 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['phraseanet.user'], $this->app)->getIsConfirmed(), - 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['phraseanet.user']), + 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()), + 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(), + 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()), ), $ret ); } diff --git a/lib/classes/Feed/Publisher/Adapter.php b/lib/classes/Feed/Publisher/Adapter.php index 1c2397046f..7ceeef146f 100644 --- a/lib/classes/Feed/Publisher/Adapter.php +++ b/lib/classes/Feed/Publisher/Adapter.php @@ -192,7 +192,7 @@ class Feed_Publisher_Adapter implements Feed_Publisher_Interface, cache_cacheabl ':usr_id' => $user->get_id() , ':feed_id' => $feed->get_id() , ':owner' => $owner ? '1' : null - , ':added_by' => $owner ? $user->get_id() : $app['phraseanet.user']->get_id() + , ':added_by' => $owner ? $user->get_id() : $app['authentication']->getUser()->get_id() ); $stmt->execute($params); $id = $app['phraseanet.appbox']->get_connection()->lastInsertId(); diff --git a/lib/classes/Session/Authentication/Native.php b/lib/classes/Session/Authentication/Native.php index d703694658..cd20d1d1cb 100644 --- a/lib/classes/Session/Authentication/Native.php +++ b/lib/classes/Session/Authentication/Native.php @@ -116,10 +116,38 @@ class Session_Authentication_Native implements Session_Authentication_Interface /** * + * @param Browser $browser * @return Session_Authentication_Native */ - public function postlog() + public function challenge_password(Browser $browser = null) { + $conn = $this->app['phraseanet.appbox']->get_connection(); + + $sql = 'SELECT usr_id + FROM usr + WHERE usr_login = :login + AND usr.usr_password = :password + AND usr_login NOT IN ("invite","autoregister") + AND usr_login NOT LIKE "(#deleted_%" + AND salted_password = 1 + AND model_of="0" AND invite="0"'; + + $salt = $this->app['auth.password-encoder']->encodePassword($this->password, $this->user->get_nonce()); + $stmt = $conn->prepare($sql); + $stmt->execute(array( + ':login' => $this->login, + ':password' => $salt + )); + + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + if (count($rs) == 0) { + if ($browser instanceof Browser) + $this->save_badlog($browser); + throw new Exception_Unauthorized('Bad login/Password'); + } + return $this; } @@ -146,43 +174,6 @@ class Session_Authentication_Native implements Session_Authentication_Interface return $this; } - /** - * - * @param Browser $browser - * @return Session_Authentication_Native - */ - public function challenge_password(Browser $browser = null) - { - $conn = $this->app['phraseanet.appbox']->get_connection(); - - $sql = 'SELECT usr_id - FROM usr - WHERE usr_login = :login - AND usr.usr_password = :password - AND usr_login NOT IN ("invite","autoregister") - AND usr_login NOT LIKE "(#deleted_%" - AND salted_password = 1 - AND model_of="0" AND invite="0"'; - - $salt = User_Adapter::salt_password($this->app, $this->password, $this->user->get_nonce()); - $stmt = $conn->prepare($sql); - $stmt->execute(array( - ':login' => $this->login, - ':password' => $salt - )); - - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (count($rs) == 0) { - if ($browser instanceof Browser) - $this->save_badlog($browser); - throw new Exception_Unauthorized('Bad login/Password'); - } - - return $this; - } - /** * * @param Browser $browser diff --git a/lib/classes/Session/Authentication/PersistentCookie.php b/lib/classes/Session/Authentication/PersistentCookie.php index 0111851e9f..465b17ec33 100644 --- a/lib/classes/Session/Authentication/PersistentCookie.php +++ b/lib/classes/Session/Authentication/PersistentCookie.php @@ -55,7 +55,7 @@ class Session_Authentication_PersistentCookie implements Session_Authentication_ $string = $app['browser']->getBrowser() . '_' . $app['browser']->getPlatform(); - if (\User_Adapter::salt_password($this->app, $string, $session->getNonce()) !== $session->getToken()) { + if ($this->app['auth.password-encoder']->encodePassword($string, $session->getNonce()) !== $session->getToken()) { throw new \Exception_Session_WrongToken('Persistent cookie value is corrupted'); } diff --git a/lib/classes/Session/Logger.php b/lib/classes/Session/Logger.php index b3495cffdf..94842ee0b3 100644 --- a/lib/classes/Session/Logger.php +++ b/lib/classes/Session/Logger.php @@ -104,8 +104,8 @@ class Session_Logger { $colls = array(); - if ($app['phraseanet.user']) { - $bases = $app['phraseanet.user']->ACL()->get_granted_base(array(), array($databox->get_sbas_id())); + if ($app['authentication']->getUser()) { + $bases = $app['authentication']->getUser()->ACL()->get_granted_base(array(), array($databox->get_sbas_id())); foreach ($bases as $collection) { $colls[] = $collection->get_coll_id(); } @@ -124,7 +124,7 @@ class Session_Logger $params = array( ':ses_id' => $app['session']->get('session_id'), - ':usr_login' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_login() : null, + ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null, ':site_id' => $app['phraseanet.registry']->get('GV_sit'), ':usr_id' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_id() : null, ':browser' => $browser->getBrowser(), @@ -134,10 +134,10 @@ class Session_Logger ':ip' => $browser->getIP(), ':user_agent' => $browser->getUserAgent(), ':appli' => serialize(array()), - ':fonction' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_job() : null, - ':company' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_company() : null, - ':activity' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_position() : null, - ':country' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_country() : null + ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_job() : null, + ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_company() : null, + ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_position() : null, + ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_country() : null ); $stmt = $conn->prepare($sql); @@ -163,7 +163,7 @@ class Session_Logger public static function load(Application $app, databox $databox) { - if ( ! $app->isAuthenticated()) { + if ( ! $app['authentication']->isAuthenticated()) { throw new Exception_Session_LoggerNotFound('Not authenticated'); } diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php index 66b294e5c7..4495d0c9be 100644 --- a/lib/classes/User/Adapter.php +++ b/lib/classes/User/Adapter.php @@ -401,7 +401,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_password = :password, salted_password = "1" WHERE usr_id = :usr_id'; - $password = self::salt_password($this->app, $pasword, $this->get_nonce()); + $password = $this->app['auth.password-encoder']->encodePassword($pasword, $this->get_nonce()); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(array(':password' => $password, ':usr_id' => $this->get_id())); @@ -496,13 +496,13 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(array( ':name' => $query, - ':usr_id' => $app['phraseanet.user']->get_id(), + ':usr_id' => $app['authentication']->getUser()->get_id(), ':query' => $query )); $stmt->closeCursor(); - if ($app['phraseanet.user']->getPrefs('start_page') == 'LAST_QUERY') - $app['phraseanet.user']->setPrefs('start_page_query', $query); + if ($app['authentication']->getUser()->getPrefs('start_page') == 'LAST_QUERY') + $app['authentication']->getUser()->setPrefs('start_page_query', $query); } catch (Exception $e) { return false; } @@ -1461,7 +1461,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public static function updateClientInfos(Application $app, $app_id) { - if (!$app->isAuthenticated()) { + if (!$app['authentication']->isAuthenticated()) { return; } @@ -1484,7 +1484,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $app['EM']->flush(); } - $usr_id = $app['phraseanet.user']->get_id(); + $usr_id = $app['authentication']->getUser()->get_id(); $user = User_Adapter::getInstance($usr_id, $app); @@ -1563,7 +1563,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface try { $sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); $stmt->closeCursor(); $sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; @@ -1676,7 +1676,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $stmt->execute(array( ':login' => $login, ':nonce' => $nonce, - ':password' => self::salt_password($app, $password, $nonce), + ':password' => $app['auth.password-encoder']->encodePassword($password, $nonce), ':email' => ($email ? $email : null), ':admin' => ($admin ? '1' : '0'), ':invite' => ($invite ? '1' : '0') @@ -1695,10 +1695,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return self::getInstance($usr_id, $app); } - public static function salt_password(Application $app, $password, $nonce) - { - return hash_hmac('sha512', $password . $nonce, $app['phraseanet.registry']->get('GV_sit')); - } protected $nonce; public function get_nonce() diff --git a/lib/classes/User/Interface.php b/lib/classes/User/Interface.php index 769e72ea3c..3b23447c1d 100644 --- a/lib/classes/User/Interface.php +++ b/lib/classes/User/Interface.php @@ -162,8 +162,6 @@ interface User_Interface public static function create(Application $app, $login, $password, $email, $admin, $invite = false); - public static function salt_password(Application $app, $password, $nonce); - public static function getInstance($id, Application $app); public static function saveQuery(Application $app, $query); diff --git a/lib/classes/User/Query.php b/lib/classes/User/Query.php index cd25fead68..5cb86b0c22 100644 --- a/lib/classes/User/Query.php +++ b/lib/classes/User/Query.php @@ -233,11 +233,11 @@ class User_Query implements User_QueryInterface } if ($this->only_templates === true) { - $sql .= ' AND model_of = ' . $this->app['phraseanet.user']->get_id(); + $sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->get_id(); } elseif ($this->include_templates === false) { $sql .= ' AND model_of=0'; } else { - $sql .= ' AND (model_of=0 OR model_of = ' . $this->app['phraseanet.user']->get_id() . ' ) '; + $sql .= ' AND (model_of=0 OR model_of = ' . $this->app['authentication']->getUser()->get_id() . ' ) '; } if ($this->activities) { diff --git a/lib/classes/base.php b/lib/classes/base.php index 0b20a1bba4..5a16211aeb 100644 --- a/lib/classes/base.php +++ b/lib/classes/base.php @@ -468,7 +468,7 @@ abstract class base implements cache_cacheableInterface foreach ($default->data as $data) { $k = trim($data['key']); if ($k === 'usr_password') - $data = User_Adapter::salt_password($this->app, $data, $nonce); + $data = $this->app['auth.password-encoder']->encodePassword($data, $nonce); if ($k === 'nonce') $data = $nonce; $v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data)); diff --git a/lib/classes/databox/cgu.php b/lib/classes/databox/cgu.php index 921b62ad96..60b3f01cb6 100644 --- a/lib/classes/databox/cgu.php +++ b/lib/classes/databox/cgu.php @@ -64,10 +64,10 @@ class databox_cgu $userValidation = true; if (! $home) { - if ( ! $app['phraseanet.user']->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + if ( ! $app['authentication']->getUser()->ACL()->has_access_to_sbas($databox->get_sbas_id())) { continue; } - $userValidation = ($app['phraseanet.user']->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== ''); + $userValidation = ($app['authentication']->getUser()->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== ''); } if ($userValidation) diff --git a/lib/classes/databox/status.php b/lib/classes/databox/status.php index 6d72f70e10..8e919fbd2a 100644 --- a/lib/classes/databox/status.php +++ b/lib/classes/databox/status.php @@ -125,7 +125,7 @@ class databox_status return self::$_statuses; } - $sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); + $sbas_ids = $app['authentication']->getUser()->ACL()->get_granted_sbas(); $statuses = array(); @@ -146,7 +146,7 @@ class databox_status { $statuses = array(); - $sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); + $sbas_ids = $app['authentication']->getUser()->ACL()->get_granted_sbas(); $see_all = array(); @@ -154,7 +154,7 @@ class databox_status $see_all[$databox->get_sbas_id()] = false; foreach ($databox->get_collections() as $collection) { - if ($app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) { + if ($app['authentication']->getUser()->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) { $see_all[$databox->get_sbas_id()] = true; break; } @@ -172,7 +172,7 @@ class databox_status $see_this = isset($see_all[$sbas_id]) ? $see_all[$sbas_id] : false; - if ($app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) { + if ($app['authentication']->getUser()->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) { $see_this = true; } diff --git a/lib/classes/eventsmanager/broker.php b/lib/classes/eventsmanager/broker.php index 4c41aaeea1..86aa458b42 100644 --- a/lib/classes/eventsmanager/broker.php +++ b/lib/classes/eventsmanager/broker.php @@ -120,7 +120,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -139,7 +139,7 @@ class eventsmanager_broker $data = array('notifications' => array(), 'next' => ''); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -189,7 +189,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id AND unread="1"'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -209,7 +209,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -228,7 +228,7 @@ class eventsmanager_broker $ret = $bloc = array(); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['phraseanet.user']->get_id())); + $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php index 69ab224152..73279d370d 100644 --- a/lib/classes/eventsmanager/notify/autoregister.php +++ b/lib/classes/eventsmanager/notify/autoregister.php @@ -222,11 +222,11 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract $bool = false; $login = new \login(); - if ( ! $this->app->isAuthenticated() || ! $login->register_enabled($this->app)) { + if ( ! $this->app['authentication']->isAuthenticated() || ! $login->register_enabled($this->app)) { return false; } - if ($this->app['phraseanet.user']->ACL()->has_right('manageusers') === true) { + if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers') === true) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php index 817010ed22..2b0715cd28 100644 --- a/lib/classes/eventsmanager/notify/order.php +++ b/lib/classes/eventsmanager/notify/order.php @@ -191,11 +191,11 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract public function is_available() { $bool = false; - if ( !$this->app->isAuthenticated()) { + if ( !$this->app['authentication']->isAuthenticated()) { return false; } - if ($this->app['phraseanet.user']->ACL()->has_right('order_master')) { + if ($this->app['authentication']->getUser()->ACL()->has_right('order_master')) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php index 8c24ec6659..c67bba2ce1 100644 --- a/lib/classes/eventsmanager/notify/orderdeliver.php +++ b/lib/classes/eventsmanager/notify/orderdeliver.php @@ -150,7 +150,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract try { $repository = $this->app['EM']->getRepository('\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['phraseanet.user'], false); + $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); } catch (Exception $e) { return array(); } diff --git a/lib/classes/eventsmanager/notify/register.php b/lib/classes/eventsmanager/notify/register.php index 549a73d944..17f924b93a 100644 --- a/lib/classes/eventsmanager/notify/register.php +++ b/lib/classes/eventsmanager/notify/register.php @@ -201,11 +201,11 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract $bool = false; $login = new \login(); - if ( !$this->app->isAuthenticated() || ! $login->register_enabled($this->app)) { + if ( !$this->app['authentication']->isAuthenticated() || ! $login->register_enabled($this->app)) { return false; } - if ($this->app['phraseanet.user']->ACL()->has_right('manageusers')) { + if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers')) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php index 0699be9bad..ef0d8ba346 100644 --- a/lib/classes/eventsmanager/notify/uploadquarantine.php +++ b/lib/classes/eventsmanager/notify/uploadquarantine.php @@ -185,8 +185,8 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract */ public function is_available() { - if (null !== $this->app['phraseanet.user']) { - return $this->app['phraseanet.user']->ACL()->has_right('addrecord'); + if (null !== $this->app['authentication']->getUser()) { + return $this->app['authentication']->getUser()->ACL()->has_right('addrecord'); } return false; diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php index 6a02f99288..0ea9b9364b 100644 --- a/lib/classes/eventsmanager/notify/validate.php +++ b/lib/classes/eventsmanager/notify/validate.php @@ -146,7 +146,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract try { $repository = $this->app['EM']->getRepository('\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['phraseanet.user'], false); + $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); $basket_name = trim($basket->getName()) ? : _('Une selection'); } catch (Exception $e) { diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php index 5270119301..fa54d95873 100644 --- a/lib/classes/eventsmanager/notify/validationdone.php +++ b/lib/classes/eventsmanager/notify/validationdone.php @@ -141,7 +141,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract try { $repository = $this->app['EM']->getRepository('\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['phraseanet.user'], false); + $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); } catch (Exception $e) { return array(); } @@ -184,11 +184,11 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract { $bool = false; - if ( ! $this->app->isAuthenticated()) { + if ( ! $this->app['authentication']->isAuthenticated()) { return false; } - if ($this->app['phraseanet.user']->ACL()->has_right('push')) { + if ($this->app['authentication']->getUser()->ACL()->has_right('push')) { $bool = true; } diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php index 095241fbf7..f723788cdf 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.php +++ b/lib/classes/eventsmanager/notify/validationreminder.php @@ -146,7 +146,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra try { $repository = $this->app['EM']->getRepository('\Entities\Basket'); - $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['phraseanet.user'], false); + $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false); $basket_name = trim($basket->getName()) ? : _('Une selection'); } catch (Exception $e) { diff --git a/lib/classes/liste.php b/lib/classes/liste.php index fd6c41008b..91a254d64a 100644 --- a/lib/classes/liste.php +++ b/lib/classes/liste.php @@ -23,23 +23,23 @@ class liste continue; } - if ($app['phraseanet.user']->ACL()->has_hd_grant($record)) { + if ($app['authentication']->getUser()->ACL()->has_hd_grant($record)) { $okbrec[] = implode('_', $basrec); continue; } - if ($app['phraseanet.user']->ACL()->has_preview_grant($record)) { + if ($app['authentication']->getUser()->ACL()->has_preview_grant($record)) { $okbrec[] = implode('_', $basrec); continue; } - if ( ! $app['phraseanet.user']->ACL()->has_access_to_base($record->get_base_id())) + if ( ! $app['authentication']->getUser()->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 ^ ' . $app['phraseanet.user']->ACL()->get_mask_xor($record->get_base_id()) . ') - & ' . $app['phraseanet.user']->ACL()->get_mask_and($record->get_base_id()) . ')=0' . + $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $app['authentication']->getUser()->ACL()->get_mask_xor($record->get_base_id()) . ') + & ' . $app['authentication']->getUser()->ACL()->get_mask_and($record->get_base_id()) . ')=0' . ' AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); diff --git a/lib/classes/module/report.php b/lib/classes/module/report.php index de307731c8..d8eeb0163f 100644 --- a/lib/classes/module/report.php +++ b/lib/classes/module/report.php @@ -251,7 +251,7 @@ class module_report $this->dmax = $d2; $this->sbas_id = $sbas_id; $this->list_coll_id = $collist; - $this->user_id = $this->app['phraseanet.user']->get_id(); + $this->user_id = $this->app['authentication']->getUser()->get_id(); $this->periode = sprintf( '%s - %s ', $this->app['date-formatter']->getPrettyString(new \DateTime($d1)), diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index dc407a6c85..975a460d02 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -400,7 +400,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface if (isset($dstatus[$sbas_id])) { foreach ($dstatus[$sbas_id] as $n => $statbit) { if ($statbit['printable'] == '0' && - !$this->app['phraseanet.user']->ACL()->has_right_on_base($this->base_id, 'chgstatus')) { + !$this->app['authentication']->getUser()->ACL()->has_right_on_base($this->base_id, 'chgstatus')) { continue; } @@ -1930,7 +1930,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface throw new Exception('This record is not a grouping'); } - if ($this->app['phraseanet.user']) { + if ($this->app['authentication']->getUser()) { $sql = 'SELECT record_id FROM regroup g INNER JOIN (record r @@ -1946,7 +1946,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $params = array( ':GV_site' => $this->app['phraseanet.registry']->get('GV_sit'), - ':usr_id' => $this->app['phraseanet.user']->get_id(), + ':usr_id' => $this->app['authentication']->getUser()->get_id(), ':record_id' => $this->get_record_id(), ); } else { @@ -1997,7 +1997,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $params = array( ':GV_site' => $this->app['phraseanet.registry']->get('GV_sit') - , ':usr_id' => $this->app['phraseanet.user']->get_id() + , ':usr_id' => $this->app['authentication']->getUser()->get_id() , ':record_id' => $this->get_record_id() ); diff --git a/lib/classes/record/exportElement.php b/lib/classes/record/exportElement.php index 32f9481c22..b399b61393 100644 --- a/lib/classes/record/exportElement.php +++ b/lib/classes/record/exportElement.php @@ -107,17 +107,17 @@ class record_exportElement extends record_adapter 'thumbnail' => true ); - if ($this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'candwnldhd')) { + if ($this->app['authentication']->getUser()->ACL()->has_right_on_base($this->get_base_id(), 'candwnldhd')) { $go_dl['document'] = true; } - if ($this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'candwnldpreview')) { + if ($this->app['authentication']->getUser()->ACL()->has_right_on_base($this->get_base_id(), 'candwnldpreview')) { $go_dl['preview'] = true; } - if ($this->app['phraseanet.user']->ACL()->has_hd_grant($this)) { + if ($this->app['authentication']->getUser()->ACL()->has_hd_grant($this)) { $go_dl['document'] = true; $go_dl['preview'] = true; } - if ($this->app['phraseanet.user']->ACL()->has_preview_grant($this)) { + if ($this->app['authentication']->getUser()->ACL()->has_preview_grant($this)) { $go_dl['preview'] = true; } @@ -127,14 +127,14 @@ class record_exportElement extends record_adapter ->who_have_right(array('order_master')) ->execute()->get_results(); - $go_cmd = (count($masters) > 0 && $this->app['phraseanet.user']->ACL()->has_right_on_base($this->base_id, 'cancmd')); + $go_cmd = (count($masters) > 0 && $this->app['authentication']->getUser()->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 ($this->app['phraseanet.user']->ACL()->is_restricted_download($this->base_id)) { + if ($this->app['authentication']->getUser()->ACL()->is_restricted_download($this->base_id)) { $this->remain_hd --; if ($this->remain_hd >= 0) $downloadable['document'] = array( @@ -182,7 +182,7 @@ class record_exportElement extends record_adapter if (isset($sd[$name]) && is_file($sd[$name]->get_pathfile())) { if ($class == 'document') { - if ($this->app['phraseanet.user']->ACL()->is_restricted_download($this->base_id)) { + if ($this->app['authentication']->getUser()->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.php b/lib/classes/record/preview.php index ebd4589170..99f7121a7b 100644 --- a/lib/classes/record/preview.php +++ b/lib/classes/record/preview.php @@ -141,7 +141,7 @@ class record_preview extends record_adapter $repository = $app['EM']->getRepository('\Entities\Basket'); /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($app, $contId, $app['phraseanet.user'], false); + $Basket = $repository->findUserBasket($app, $contId, $app['authentication']->getUser(), false); /* @var $Basket \Entities\Basket */ $this->container = $Basket; @@ -323,7 +323,7 @@ class record_preview extends record_adapter $tab = array(); - $report = $this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); + $report = $this->app['authentication']->getUser()->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); $connsbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); @@ -335,7 +335,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'] = $this->app['phraseanet.user']->get_id(); + $params[':usr_id'] = $this->app['authentication']->getUser()->get_id(); $params[':site'] = $this->app['phraseanet.registry']->get('GV_sit'); } @@ -406,7 +406,7 @@ class record_preview extends record_adapter return $this->view_popularity; } - $report = $this->app['phraseanet.user']->ACL()->has_right_on_base( + $report = $this->app['authentication']->getUser()->ACL()->has_right_on_base( $this->get_base_id(), 'canreport'); if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { @@ -495,7 +495,7 @@ class record_preview extends record_adapter return $this->refferer_popularity; } - $report = $this->app['phraseanet.user']->ACL()->has_right_on_base( + $report = $this->app['authentication']->getUser()->ACL()->has_right_on_base( $this->get_base_id(), 'canreport'); if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { @@ -567,7 +567,7 @@ class record_preview extends record_adapter return $this->download_popularity; } - $report = $this->app['phraseanet.user']->ACL()->has_right_on_base($this->get_base_id(), 'canreport'); + $report = $this->app['authentication']->getUser()->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.php b/lib/classes/set/export.php index 02cfc8a77d..2cfbfc4eeb 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -54,7 +54,7 @@ class set_export extends set_abstract if ($storyWZid) { $repository = $app['EM']->getRepository('\\Entities\\StoryWZ'); - $storyWZ = $repository->findByUserAndId($this->app, $app['phraseanet.user'], $storyWZid); + $storyWZ = $repository->findByUserAndId($this->app, $app['authentication']->getUser(), $storyWZid); $lst = $storyWZ->getRecord($this->app)->get_serialize_key(); } @@ -63,7 +63,7 @@ class set_export extends set_abstract $repository = $app['EM']->getRepository('\Entities\Basket'); /* @var $repository \Repositories\BasketRepository */ - $Basket = $repository->findUserBasket($this->app, $sstid, $app['phraseanet.user'], false); + $Basket = $repository->findUserBasket($this->app, $sstid, $app['authentication']->getUser(), false); $this->exportName = str_replace(array(' ', '\\', '/'), '_', $Basket->getName()) . "_" . date("Y-n-d"); foreach ($Basket->getElements() as $basket_element) { @@ -72,8 +72,8 @@ class set_export extends set_abstract $record_id = $basket_element->getRecord($this->app)->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); + if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -112,8 +112,8 @@ class set_export extends set_abstract $record_id = $child_basrec->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); + if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -135,8 +135,8 @@ class set_export extends set_abstract $record_id = $record->get_record_id(); if (!isset($remain_hd[$base_id])) { - if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { - $remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); + if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) { + $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id); } else { $remain_hd[$base_id] = false; } @@ -170,7 +170,7 @@ class set_export extends set_abstract $this->businessFieldsAccess = false; foreach ($this->elements as $download_element) { - if ($app['phraseanet.user']->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { + if ($app['authentication']->getUser()->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { $this->businessFieldsAccess = true; } @@ -222,11 +222,11 @@ class set_export extends set_abstract $display_ftp = array(); - $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'); + $hasadminright = $app['authentication']->getUser()->ACL()->has_right('addrecord') + || $app['authentication']->getUser()->ACL()->has_right('deleterecord') + || $app['authentication']->getUser()->ACL()->has_right('modifyrecord') + || $app['authentication']->getUser()->ACL()->has_right('coll_manage') + || $app['authentication']->getUser()->ACL()->has_right('coll_modify_struct'); $this->ftp_datas = array(); @@ -234,7 +234,7 @@ class set_export extends set_abstract $display_ftp = $display_download; $this->total_ftp = $this->total_download; - $lst_base_id = array_keys($app['phraseanet.user']->ACL()->get_granted_base()); + $lst_base_id = array_keys($app['authentication']->getUser()->ACL()->get_granted_base()); if ($hasadminright) { $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP, @@ -263,7 +263,7 @@ class set_export extends set_abstract ) ) GROUP BY usr_id "; - $params = array(':usr_id' => $app['phraseanet.user']->get_id()); + $params = array(':usr_id' => $app['authentication']->getUser()->get_id()); } $datas[] = array( @@ -278,7 +278,7 @@ class set_export extends set_abstract 'passifFTP' => false, 'retryFTP' => 5, 'mailFTP' => '', - 'sendermail' => $app['phraseanet.user']->get_email() + 'sendermail' => $app['authentication']->getUser()->get_email() ); $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -302,7 +302,7 @@ class set_export extends set_abstract 'passifFTP' => ($row['passifFTP'] > 0), 'retryFTP' => $row['retryFTP'], 'mailFTP' => $row['usr_mail'], - 'sendermail' => $app['phraseanet.user']->get_email() + 'sendermail' => $app['authentication']->getUser()->get_email() ); } @@ -641,7 +641,7 @@ class set_export extends set_abstract if (in_array('caption', $subdefs)) { $caption_dir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/desc_tmp/' - . time() . $this->app['phraseanet.user']->get_id() . '/'; + . time() . $this->app['authentication']->getUser()->get_id() . '/'; $filesystem->mkdir($caption_dir, 0750); @@ -663,7 +663,7 @@ class set_export extends set_abstract if (in_array('caption-yaml', $subdefs)) { $caption_dir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/desc_tmp/' - . time() . $this->app['phraseanet.user']->get_id() . '/'; + . time() . $this->app['authentication']->getUser()->get_id() . '/'; $filesystem->mkdir($caption_dir, 0750); @@ -891,7 +891,7 @@ class set_export extends set_abstract $log["shortXml"] = $record_object->get_caption()->serialize(caption_record::SERIALIZE_XML); $tmplog[$record_object->get_base_id()][] = $log; if (!$anonymous && $o == 'document') { - $app['phraseanet.user']->ACL()->remove_remaining($record_object->get_base_id()); + $app['authentication']->getUser()->ACL()->remove_remaining($record_object->get_base_id()); } } @@ -915,11 +915,11 @@ class set_export extends set_abstract $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); foreach ($list_base as $base_id) { - if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { + if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) { $params = array( - ':remain_dl' => $app['phraseanet.user']->ACL()->remaining_download($base_id) + ':remain_dl' => $app['authentication']->getUser()->ACL()->remaining_download($base_id) , ':base_id' => $base_id - , ':usr_id' => $app['phraseanet.user']->get_id() + , ':usr_id' => $app['authentication']->getUser()->get_id() ); $stmt->execute($params); diff --git a/lib/classes/set/exportftp.php b/lib/classes/set/exportftp.php index 7ad8b58cf9..8d0728feaf 100644 --- a/lib/classes/set/exportftp.php +++ b/lib/classes/set/exportftp.php @@ -45,7 +45,7 @@ class set_exportftp extends set_export $text_mail_receiver = "Bonjour,\n" . "L'utilisateur " - . $this->app['phraseanet.user']->get_display_name() . " (login : " . $this->app['phraseanet.user']->get_login() . ") " + . $this->app['authentication']->getUser()->get_display_name() . " (login : " . $this->app['authentication']->getUser()->get_login() . ") " . "a fait un transfert FTP sur le serveur ayant comme adresse \"" . $host . "\" avec le login \"" . $login . "\" " . "et pour repertoire de destination \"" @@ -103,10 +103,10 @@ class set_exportftp extends set_export , ':pwd' => $password , ':passif' => ($passif == "1" ? "1" : "0") , ':destfolder' => $destfolder - , ':sendermail' => $this->app['phraseanet.user']->get_email() + , ':sendermail' => $this->app['authentication']->getUser()->get_email() , ':text_mail_receiver' => $text_mail_receiver , ':text_mail_sender' => $text_mail_sender - , ':usr_id' => $this->app['phraseanet.user']->get_id() + , ':usr_id' => $this->app['authentication']->getUser()->get_id() , ':foldertocreate' => $makedirectory , ':logfile' => ( ! ! $logfile ? '1' : '0') ); diff --git a/lib/classes/set/order.php b/lib/classes/set/order.php index f355448836..5f60cc53af 100644 --- a/lib/classes/set/order.php +++ b/lib/classes/set/order.php @@ -244,7 +244,7 @@ class set_order extends set_abstract $this->total = (int) $row['total']; $this->ssel_id = (int) $row['ssel_id']; - $base_ids = array_keys($app['phraseanet.user']->ACL()->get_granted_base(array('order_master'))); + $base_ids = array_keys($app['authentication']->getUser()->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 @@ -379,7 +379,7 @@ class set_order extends set_abstract $Basket = new \Entities\Basket(); $Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d'))); $Basket->setOwner($this->user); - $Basket->setPusher($app['phraseanet.user']); + $Basket->setPusher($app['authentication']->getUser()); $app['EM']->persist($Basket); $app['EM']->flush(); @@ -419,7 +419,7 @@ class set_order extends set_abstract $app['EM']->persist($BasketElement); $params = array( - ':usr_id' => $app['phraseanet.user']->get_id() + ':usr_id' => $app['authentication']->getUser()->get_id() , ':order_id' => $this->id , ':order_element_id' => $order_element_id ); @@ -427,7 +427,7 @@ class set_order extends set_abstract $stmt->execute($params); $n ++; - $this->user->ACL()->grant_hd_on($record, $app['phraseanet.user'], 'order'); + $this->user->ACL()->grant_hd_on($record, $app['authentication']->getUser(), 'order'); unset($record); } catch (Exception $e) { @@ -441,7 +441,7 @@ class set_order extends set_abstract if ($n > 0) { $params = array( 'ssel_id' => $this->ssel_id, - 'from' => $app['phraseanet.user']->get_id(), + 'from' => $app['authentication']->getUser()->get_id(), 'to' => $this->user->get_id(), 'n' => $n ); @@ -470,7 +470,7 @@ class set_order extends set_abstract AND ISNULL(order_master_id)'; $params = array( - ':order_master_id' => $this->app['phraseanet.user']->get_id() + ':order_master_id' => $this->app['authentication']->getUser()->get_id() , ':order_id' => $this->id , ':order_element_id' => $order_element_id ); @@ -482,7 +482,7 @@ class set_order extends set_abstract if ($n > 0) { $params = array( - 'from' => $this->app['phraseanet.user']->get_id(), + 'from' => $this->app['authentication']->getUser()->get_id(), 'to' => $this->user->get_id(), 'n' => $n ); diff --git a/lib/classes/set/selection.php b/lib/classes/set/selection.php index 92e608fecc..81edf5b9e9 100644 --- a/lib/classes/set/selection.php +++ b/lib/classes/set/selection.php @@ -63,26 +63,26 @@ class set_selection extends set_abstract $sbas_id = $record->get_sbas_id(); $record_id = $record->get_record_id(); if (! $rights) { - if ($this->app['phraseanet.user']->ACL()->has_hd_grant($record)) { + if ($this->app['authentication']->getUser()->ACL()->has_hd_grant($record)) { continue; } - if ($this->app['phraseanet.user']->ACL()->has_preview_grant($record)) { + if ($this->app['authentication']->getUser()->ACL()->has_preview_grant($record)) { continue; } - if ( ! $this->app['phraseanet.user']->ACL()->has_access_to_base($base_id)) { + if ( ! $this->app['authentication']->getUser()->ACL()->has_access_to_base($base_id)) { $to_remove[] = $id; continue; } } else { foreach ($rights as $right) { - if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_base($base_id, $right)) { + if ( ! $this->app['authentication']->getUser()->ACL()->has_right_on_base($base_id, $right)) { $to_remove[] = $id; continue; } } foreach ($sbas_rights as $right) { - if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, $right)) { + if ( ! $this->app['authentication']->getUser()->ACL()->has_right_on_sbas($sbas_id, $right)) { $to_remove[] = $id; continue; } @@ -94,8 +94,8 @@ class set_selection extends set_abstract $sql = 'SELECT record_id FROM record - WHERE ((status ^ ' . $this->app['phraseanet.user']->ACL()->get_mask_xor($base_id) . ') - & ' . $this->app['phraseanet.user']->ACL()->get_mask_and($base_id) . ')=0 + WHERE ((status ^ ' . $this->app['authentication']->getUser()->ACL()->get_mask_xor($base_id) . ') + & ' . $this->app['authentication']->getUser()->ACL()->get_mask_and($base_id) . ')=0 AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); diff --git a/lib/classes/task/period/writemeta.php b/lib/classes/task/period/writemeta.php index 30b8c1941b..32da6b96fc 100644 --- a/lib/classes/task/period/writemeta.php +++ b/lib/classes/task/period/writemeta.php @@ -166,7 +166,7 @@ class task_period_writemeta extends task_databoxAbstract public function getInterfaceHTML() { - $sbas_ids = $this->dependencyContainer['phraseanet.user']->ACL()->get_granted_sbas(array('bas_manage')); + $sbas_ids = $this->dependencyContainer['authentication']->getUser()->ACL()->get_granted_sbas(array('bas_manage')); ob_start(); if (count($sbas_ids) > 0) {