Add AuthenticationServiceProvider

This commit is contained in:
Romain Neutron
2013-02-15 11:12:22 +01:00
parent d2bc4f4a23
commit 6537b96f4c
30 changed files with 158 additions and 173 deletions

View File

@@ -665,7 +665,7 @@ class API_V1_adapter extends API_V1_Abstract
$collection = \collection::get_from_base_id($this->app, $request->get('base_id')); $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())); 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 = new Entities\LazaretSession();
$session->setUsrId($app['phraseanet.user']->get_id()); $session->setUsrId($app['authentication']->getUser()->get_id());
$app['EM']->persist($session); $app['EM']->persist($session);
$app['EM']->flush(); $app['EM']->flush();
@@ -740,7 +740,7 @@ class API_V1_adapter extends API_V1_Abstract
$offset_start = max($request->get('offset_start', 0), 0); $offset_start = max($request->get('offset_start', 0), 0);
$per_page = min(max($request->get('per_page', 10), 1), 20); $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(); $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)); 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'); 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'] }, (array) $this->app['phraseanet.appbox']
->get_databox($databox_id) ->get_databox($databox_id)
->get_record($record_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); $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); $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))); $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'); $repo = $this->app['EM']->getRepository('\Entities\Basket');
/* @var $repo \Repositories\BasketRepository */ /* @var $repo \Repositories\BasketRepository */
$baskets = $repo->findActiveByUser($this->app['phraseanet.user']); $baskets = $repo->findActiveByUser($this->app['authentication']->getUser());
$ret = array(); $ret = array();
foreach ($baskets as $basket) { foreach ($baskets as $basket) {
@@ -1278,7 +1278,7 @@ class API_V1_adapter extends API_V1_Abstract
} }
$Basket = new \Entities\Basket(); $Basket = new \Entities\Basket();
$Basket->setOwner($this->app['phraseanet.user']); $Basket->setOwner($this->app['authentication']->getUser());
$Basket->setName($name); $Basket->setName($name);
$this->app['EM']->persist($Basket); $this->app['EM']->persist($Basket);
@@ -1302,7 +1302,7 @@ class API_V1_adapter extends API_V1_Abstract
/* @var $repository \Repositories\BasketRepository */ /* @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']->remove($Basket);
$this->app['EM']->flush(); $this->app['EM']->flush();
@@ -1324,7 +1324,7 @@ class API_V1_adapter extends API_V1_Abstract
/* @var $repository \Repositories\BasketRepository */ /* @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( $result->set_datas(
array( array(
@@ -1384,14 +1384,14 @@ class API_V1_adapter extends API_V1_Abstract
'confirmed' => $participant->getIsConfirmed(), 'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(), 'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(), '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(), 'agreement' => $validation_datas->getAgreement(),
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM), 'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(), '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(); $agreement = $validation_datas->getAgreement();
$note = null === $validation_datas->getNote() ? '' : $validation_datas->getNote(); $note = null === $validation_datas->getNote() ? '' : $validation_datas->getNote();
} }
@@ -1423,7 +1423,7 @@ class API_V1_adapter extends API_V1_Abstract
/* @var $repository \Repositories\BasketRepository */ /* @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); $Basket->setName($name);
$this->app['EM']->merge($Basket); $this->app['EM']->merge($Basket);
@@ -1451,7 +1451,7 @@ class API_V1_adapter extends API_V1_Abstract
/* @var $repository \Repositories\BasketRepository */ /* @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); $Basket->setDescription($desc);
$this->app['EM']->merge($Basket); $this->app['EM']->merge($Basket);
@@ -1819,7 +1819,7 @@ class API_V1_adapter extends API_V1_Abstract
'confirmed' => $participant->getIsConfirmed(), 'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(), 'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(), '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( array(
'validation_users' => $users, 'validation_users' => $users,
'expires_on' => $expires_on_atom, 'expires_on' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['phraseanet.user']), 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()),
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['phraseanet.user'], $this->app)->getIsConfirmed(), 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(),
'validation_initiator' => $basket->getValidation()->isInitiator($this->app['phraseanet.user']), 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()),
), $ret ), $ret
); );
} }

View File

@@ -192,7 +192,7 @@ class Feed_Publisher_Adapter implements Feed_Publisher_Interface, cache_cacheabl
':usr_id' => $user->get_id() ':usr_id' => $user->get_id()
, ':feed_id' => $feed->get_id() , ':feed_id' => $feed->get_id()
, ':owner' => $owner ? '1' : null , ':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); $stmt->execute($params);
$id = $app['phraseanet.appbox']->get_connection()->lastInsertId(); $id = $app['phraseanet.appbox']->get_connection()->lastInsertId();

View File

@@ -116,10 +116,38 @@ class Session_Authentication_Native implements Session_Authentication_Interface
/** /**
* *
* @param Browser $browser
* @return Session_Authentication_Native * @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; return $this;
} }
@@ -146,43 +174,6 @@ class Session_Authentication_Native implements Session_Authentication_Interface
return $this; 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 * @param Browser $browser

View File

@@ -55,7 +55,7 @@ class Session_Authentication_PersistentCookie implements Session_Authentication_
$string = $app['browser']->getBrowser() . '_' . $app['browser']->getPlatform(); $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'); throw new \Exception_Session_WrongToken('Persistent cookie value is corrupted');
} }

View File

@@ -104,8 +104,8 @@ class Session_Logger
{ {
$colls = array(); $colls = array();
if ($app['phraseanet.user']) { if ($app['authentication']->getUser()) {
$bases = $app['phraseanet.user']->ACL()->get_granted_base(array(), array($databox->get_sbas_id())); $bases = $app['authentication']->getUser()->ACL()->get_granted_base(array(), array($databox->get_sbas_id()));
foreach ($bases as $collection) { foreach ($bases as $collection) {
$colls[] = $collection->get_coll_id(); $colls[] = $collection->get_coll_id();
} }
@@ -124,7 +124,7 @@ class Session_Logger
$params = array( $params = array(
':ses_id' => $app['session']->get('session_id'), ':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'), ':site_id' => $app['phraseanet.registry']->get('GV_sit'),
':usr_id' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_id() : null, ':usr_id' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_id() : null,
':browser' => $browser->getBrowser(), ':browser' => $browser->getBrowser(),
@@ -134,10 +134,10 @@ class Session_Logger
':ip' => $browser->getIP(), ':ip' => $browser->getIP(),
':user_agent' => $browser->getUserAgent(), ':user_agent' => $browser->getUserAgent(),
':appli' => serialize(array()), ':appli' => serialize(array()),
':fonction' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_job() : null, ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_job() : null,
':company' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_company() : null, ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_company() : null,
':activity' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_position() : null, ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_position() : null,
':country' => $app['phraseanet.user'] ? $app['phraseanet.user']->get_country() : null ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_country() : null
); );
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -163,7 +163,7 @@ class Session_Logger
public static function load(Application $app, databox $databox) public static function load(Application $app, databox $databox)
{ {
if ( ! $app->isAuthenticated()) { if ( ! $app['authentication']->isAuthenticated()) {
throw new Exception_Session_LoggerNotFound('Not authenticated'); throw new Exception_Session_LoggerNotFound('Not authenticated');
} }

View File

@@ -401,7 +401,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET usr_password = :password, salted_password = "1" $sql = 'UPDATE usr SET usr_password = :password, salted_password = "1"
WHERE usr_id = :usr_id'; 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 = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':password' => $password, ':usr_id' => $this->get_id())); $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 = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array( $stmt->execute(array(
':name' => $query, ':name' => $query,
':usr_id' => $app['phraseanet.user']->get_id(), ':usr_id' => $app['authentication']->getUser()->get_id(),
':query' => $query ':query' => $query
)); ));
$stmt->closeCursor(); $stmt->closeCursor();
if ($app['phraseanet.user']->getPrefs('start_page') == 'LAST_QUERY') if ($app['authentication']->getUser()->getPrefs('start_page') == 'LAST_QUERY')
$app['phraseanet.user']->setPrefs('start_page_query', $query); $app['authentication']->getUser()->setPrefs('start_page_query', $query);
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
@@ -1461,7 +1461,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function updateClientInfos(Application $app, $app_id) public static function updateClientInfos(Application $app, $app_id)
{ {
if (!$app->isAuthenticated()) { if (!$app['authentication']->isAuthenticated()) {
return; return;
} }
@@ -1484,7 +1484,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$app['EM']->flush(); $app['EM']->flush();
} }
$usr_id = $app['phraseanet.user']->get_id(); $usr_id = $app['authentication']->getUser()->get_id();
$user = User_Adapter::getInstance($usr_id, $app); $user = User_Adapter::getInstance($usr_id, $app);
@@ -1563,7 +1563,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
try { try {
$sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $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 = $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(); $stmt->closeCursor();
$sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; $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( $stmt->execute(array(
':login' => $login, ':login' => $login,
':nonce' => $nonce, ':nonce' => $nonce,
':password' => self::salt_password($app, $password, $nonce), ':password' => $app['auth.password-encoder']->encodePassword($password, $nonce),
':email' => ($email ? $email : null), ':email' => ($email ? $email : null),
':admin' => ($admin ? '1' : '0'), ':admin' => ($admin ? '1' : '0'),
':invite' => ($invite ? '1' : '0') ':invite' => ($invite ? '1' : '0')
@@ -1695,10 +1695,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return self::getInstance($usr_id, $app); 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; protected $nonce;
public function get_nonce() public function get_nonce()

View File

@@ -162,8 +162,6 @@ interface User_Interface
public static function create(Application $app, $login, $password, $email, $admin, $invite = false); 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 getInstance($id, Application $app);
public static function saveQuery(Application $app, $query); public static function saveQuery(Application $app, $query);

View File

@@ -233,11 +233,11 @@ class User_Query implements User_QueryInterface
} }
if ($this->only_templates === true) { 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) { } elseif ($this->include_templates === false) {
$sql .= ' AND model_of=0'; $sql .= ' AND model_of=0';
} else { } 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) { if ($this->activities) {

View File

@@ -468,7 +468,7 @@ abstract class base implements cache_cacheableInterface
foreach ($default->data as $data) { foreach ($default->data as $data) {
$k = trim($data['key']); $k = trim($data['key']);
if ($k === 'usr_password') 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') if ($k === 'nonce')
$data = $nonce; $data = $nonce;
$v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data)); $v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data));

View File

@@ -64,10 +64,10 @@ class databox_cgu
$userValidation = true; $userValidation = true;
if (! $home) { 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; 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) if ($userValidation)

View File

@@ -125,7 +125,7 @@ class databox_status
return self::$_statuses; return self::$_statuses;
} }
$sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); $sbas_ids = $app['authentication']->getUser()->ACL()->get_granted_sbas();
$statuses = array(); $statuses = array();
@@ -146,7 +146,7 @@ class databox_status
{ {
$statuses = array(); $statuses = array();
$sbas_ids = $app['phraseanet.user']->ACL()->get_granted_sbas(); $sbas_ids = $app['authentication']->getUser()->ACL()->get_granted_sbas();
$see_all = array(); $see_all = array();
@@ -154,7 +154,7 @@ class databox_status
$see_all[$databox->get_sbas_id()] = false; $see_all[$databox->get_sbas_id()] = false;
foreach ($databox->get_collections() as $collection) { 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; $see_all[$databox->get_sbas_id()] = true;
break; break;
} }
@@ -172,7 +172,7 @@ class databox_status
$see_this = isset($see_all[$sbas_id]) ? $see_all[$sbas_id] : false; $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; $see_this = true;
} }

View File

@@ -120,7 +120,7 @@ class eventsmanager_broker
FROM notifications WHERE usr_id = :usr_id'; FROM notifications WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $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); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -139,7 +139,7 @@ class eventsmanager_broker
$data = array('notifications' => array(), 'next' => ''); $data = array('notifications' => array(), 'next' => '');
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $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); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -189,7 +189,7 @@ class eventsmanager_broker
FROM notifications FROM notifications
WHERE usr_id = :usr_id AND unread="1"'; WHERE usr_id = :usr_id AND unread="1"';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $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); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -209,7 +209,7 @@ class eventsmanager_broker
FROM notifications WHERE usr_id = :usr_id'; FROM notifications WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $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); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -228,7 +228,7 @@ class eventsmanager_broker
$ret = $bloc = array(); $ret = $bloc = array();
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $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); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -222,11 +222,11 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$bool = false; $bool = false;
$login = new \login(); $login = new \login();
if ( ! $this->app->isAuthenticated() || ! $login->register_enabled($this->app)) { if ( ! $this->app['authentication']->isAuthenticated() || ! $login->register_enabled($this->app)) {
return false; return false;
} }
if ($this->app['phraseanet.user']->ACL()->has_right('manageusers') === true) { if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers') === true) {
$bool = true; $bool = true;
} }

View File

@@ -191,11 +191,11 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
public function is_available() public function is_available()
{ {
$bool = false; $bool = false;
if ( !$this->app->isAuthenticated()) { if ( !$this->app['authentication']->isAuthenticated()) {
return false; return false;
} }
if ($this->app['phraseanet.user']->ACL()->has_right('order_master')) { if ($this->app['authentication']->getUser()->ACL()->has_right('order_master')) {
$bool = true; $bool = true;
} }

View File

@@ -150,7 +150,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
try { try {
$repository = $this->app['EM']->getRepository('\Entities\Basket'); $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) { } catch (Exception $e) {
return array(); return array();
} }

View File

@@ -201,11 +201,11 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$bool = false; $bool = false;
$login = new \login(); $login = new \login();
if ( !$this->app->isAuthenticated() || ! $login->register_enabled($this->app)) { if ( !$this->app['authentication']->isAuthenticated() || ! $login->register_enabled($this->app)) {
return false; return false;
} }
if ($this->app['phraseanet.user']->ACL()->has_right('manageusers')) { if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers')) {
$bool = true; $bool = true;
} }

View File

@@ -185,8 +185,8 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
*/ */
public function is_available() public function is_available()
{ {
if (null !== $this->app['phraseanet.user']) { if (null !== $this->app['authentication']->getUser()) {
return $this->app['phraseanet.user']->ACL()->has_right('addrecord'); return $this->app['authentication']->getUser()->ACL()->has_right('addrecord');
} }
return false; return false;

View File

@@ -146,7 +146,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
try { try {
$repository = $this->app['EM']->getRepository('\Entities\Basket'); $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'); $basket_name = trim($basket->getName()) ? : _('Une selection');
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -141,7 +141,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
try { try {
$repository = $this->app['EM']->getRepository('\Entities\Basket'); $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) { } catch (Exception $e) {
return array(); return array();
} }
@@ -184,11 +184,11 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{ {
$bool = false; $bool = false;
if ( ! $this->app->isAuthenticated()) { if ( ! $this->app['authentication']->isAuthenticated()) {
return false; return false;
} }
if ($this->app['phraseanet.user']->ACL()->has_right('push')) { if ($this->app['authentication']->getUser()->ACL()->has_right('push')) {
$bool = true; $bool = true;
} }

View File

@@ -146,7 +146,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
try { try {
$repository = $this->app['EM']->getRepository('\Entities\Basket'); $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'); $basket_name = trim($basket->getName()) ? : _('Une selection');
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -23,23 +23,23 @@ class liste
continue; continue;
} }
if ($app['phraseanet.user']->ACL()->has_hd_grant($record)) { if ($app['authentication']->getUser()->ACL()->has_hd_grant($record)) {
$okbrec[] = implode('_', $basrec); $okbrec[] = implode('_', $basrec);
continue; continue;
} }
if ($app['phraseanet.user']->ACL()->has_preview_grant($record)) { if ($app['authentication']->getUser()->ACL()->has_preview_grant($record)) {
$okbrec[] = implode('_', $basrec); $okbrec[] = implode('_', $basrec);
continue; 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; continue;
try { try {
$connsbas = connection::getPDOConnection($app, $basrec[0]); $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()) . ') $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $app['authentication']->getUser()->ACL()->get_mask_xor($record->get_base_id()) . ')
& ' . $app['phraseanet.user']->ACL()->get_mask_and($record->get_base_id()) . ')=0' . & ' . $app['authentication']->getUser()->ACL()->get_mask_and($record->get_base_id()) . ')=0' .
' AND record_id = :record_id'; ' AND record_id = :record_id';
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);

View File

@@ -251,7 +251,7 @@ class module_report
$this->dmax = $d2; $this->dmax = $d2;
$this->sbas_id = $sbas_id; $this->sbas_id = $sbas_id;
$this->list_coll_id = $collist; $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( $this->periode = sprintf(
'%s - %s ', '%s - %s ',
$this->app['date-formatter']->getPrettyString(new \DateTime($d1)), $this->app['date-formatter']->getPrettyString(new \DateTime($d1)),

View File

@@ -400,7 +400,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (isset($dstatus[$sbas_id])) { if (isset($dstatus[$sbas_id])) {
foreach ($dstatus[$sbas_id] as $n => $statbit) { foreach ($dstatus[$sbas_id] as $n => $statbit) {
if ($statbit['printable'] == '0' && 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; continue;
} }
@@ -1930,7 +1930,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
throw new Exception('This record is not a grouping'); throw new Exception('This record is not a grouping');
} }
if ($this->app['phraseanet.user']) { if ($this->app['authentication']->getUser()) {
$sql = 'SELECT record_id $sql = 'SELECT record_id
FROM regroup g FROM regroup g
INNER JOIN (record r INNER JOIN (record r
@@ -1946,7 +1946,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$params = array( $params = array(
':GV_site' => $this->app['phraseanet.registry']->get('GV_sit'), ':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(), ':record_id' => $this->get_record_id(),
); );
} else { } else {
@@ -1997,7 +1997,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$params = array( $params = array(
':GV_site' => $this->app['phraseanet.registry']->get('GV_sit') ':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() , ':record_id' => $this->get_record_id()
); );

View File

@@ -107,17 +107,17 @@ class record_exportElement extends record_adapter
'thumbnail' => true '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; $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; $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['document'] = true;
$go_dl['preview'] = 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; $go_dl['preview'] = true;
} }
@@ -127,14 +127,14 @@ class record_exportElement extends record_adapter
->who_have_right(array('order_master')) ->who_have_right(array('order_master'))
->execute()->get_results(); ->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; $orderable['document'] = false;
$downloadable['document'] = false; $downloadable['document'] = false;
if (isset($sd['document']) && is_file($sd['document']->get_pathfile())) { if (isset($sd['document']) && is_file($sd['document']->get_pathfile())) {
if ($go_dl['document'] === true) { 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 --; $this->remain_hd --;
if ($this->remain_hd >= 0) if ($this->remain_hd >= 0)
$downloadable['document'] = array( $downloadable['document'] = array(
@@ -182,7 +182,7 @@ class record_exportElement extends record_adapter
if (isset($sd[$name]) && is_file($sd[$name]->get_pathfile())) { if (isset($sd[$name]) && is_file($sd[$name]->get_pathfile())) {
if ($class == 'document') { 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 --; $this->remain_hd --;
if ($this->remain_hd >= 0) if ($this->remain_hd >= 0)
$downloadable[$name] = array( $downloadable[$name] = array(

View File

@@ -141,7 +141,7 @@ class record_preview extends record_adapter
$repository = $app['EM']->getRepository('\Entities\Basket'); $repository = $app['EM']->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */ /* @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 */ /* @var $Basket \Entities\Basket */
$this->container = $Basket; $this->container = $Basket;
@@ -323,7 +323,7 @@ class record_preview extends record_adapter
$tab = array(); $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()); $connsbas = connection::getPDOConnection($this->app, $this->get_sbas_id());
@@ -335,7 +335,7 @@ class record_preview extends record_adapter
if (! $report) { if (! $report) {
$sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; $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'); $params[':site'] = $this->app['phraseanet.registry']->get('GV_sit');
} }
@@ -406,7 +406,7 @@ class record_preview extends record_adapter
return $this->view_popularity; 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'); $this->get_base_id(), 'canreport');
if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) {
@@ -495,7 +495,7 @@ class record_preview extends record_adapter
return $this->refferer_popularity; 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'); $this->get_base_id(), 'canreport');
if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) {
@@ -567,7 +567,7 @@ class record_preview extends record_adapter
return $this->download_popularity; 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; $ret = false;
if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) { if ( ! $report && ! $this->app['phraseanet.registry']->get('GV_google_api')) {

View File

@@ -54,7 +54,7 @@ class set_export extends set_abstract
if ($storyWZid) { if ($storyWZid) {
$repository = $app['EM']->getRepository('\\Entities\\StoryWZ'); $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(); $lst = $storyWZ->getRecord($this->app)->get_serialize_key();
} }
@@ -63,7 +63,7 @@ class set_export extends set_abstract
$repository = $app['EM']->getRepository('\Entities\Basket'); $repository = $app['EM']->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */ /* @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"); $this->exportName = str_replace(array(' ', '\\', '/'), '_', $Basket->getName()) . "_" . date("Y-n-d");
foreach ($Basket->getElements() as $basket_element) { 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(); $record_id = $basket_element->getRecord($this->app)->get_record_id();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id);
} else { } else {
$remain_hd[$base_id] = false; $remain_hd[$base_id] = false;
} }
@@ -112,8 +112,8 @@ class set_export extends set_abstract
$record_id = $child_basrec->get_record_id(); $record_id = $child_basrec->get_record_id();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id);
} else { } else {
$remain_hd[$base_id] = false; $remain_hd[$base_id] = false;
} }
@@ -135,8 +135,8 @@ class set_export extends set_abstract
$record_id = $record->get_record_id(); $record_id = $record->get_record_id();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app['phraseanet.user']->ACL()->is_restricted_download($base_id)) { if ($app['authentication']->getUser()->ACL()->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['phraseanet.user']->ACL()->remaining_download($base_id); $remain_hd[$base_id] = $app['authentication']->getUser()->ACL()->remaining_download($base_id);
} else { } else {
$remain_hd[$base_id] = false; $remain_hd[$base_id] = false;
} }
@@ -170,7 +170,7 @@ class set_export extends set_abstract
$this->businessFieldsAccess = false; $this->businessFieldsAccess = false;
foreach ($this->elements as $download_element) { 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; $this->businessFieldsAccess = true;
} }
@@ -222,11 +222,11 @@ class set_export extends set_abstract
$display_ftp = array(); $display_ftp = array();
$hasadminright = $app['phraseanet.user']->ACL()->has_right('addrecord') $hasadminright = $app['authentication']->getUser()->ACL()->has_right('addrecord')
|| $app['phraseanet.user']->ACL()->has_right('deleterecord') || $app['authentication']->getUser()->ACL()->has_right('deleterecord')
|| $app['phraseanet.user']->ACL()->has_right('modifyrecord') || $app['authentication']->getUser()->ACL()->has_right('modifyrecord')
|| $app['phraseanet.user']->ACL()->has_right('coll_manage') || $app['authentication']->getUser()->ACL()->has_right('coll_manage')
|| $app['phraseanet.user']->ACL()->has_right('coll_modify_struct'); || $app['authentication']->getUser()->ACL()->has_right('coll_modify_struct');
$this->ftp_datas = array(); $this->ftp_datas = array();
@@ -234,7 +234,7 @@ class set_export extends set_abstract
$display_ftp = $display_download; $display_ftp = $display_download;
$this->total_ftp = $this->total_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) { if ($hasadminright) {
$sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP, $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 "; GROUP BY usr_id ";
$params = array(':usr_id' => $app['phraseanet.user']->get_id()); $params = array(':usr_id' => $app['authentication']->getUser()->get_id());
} }
$datas[] = array( $datas[] = array(
@@ -278,7 +278,7 @@ class set_export extends set_abstract
'passifFTP' => false, 'passifFTP' => false,
'retryFTP' => 5, 'retryFTP' => 5,
'mailFTP' => '', 'mailFTP' => '',
'sendermail' => $app['phraseanet.user']->get_email() 'sendermail' => $app['authentication']->getUser()->get_email()
); );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
@@ -302,7 +302,7 @@ class set_export extends set_abstract
'passifFTP' => ($row['passifFTP'] > 0), 'passifFTP' => ($row['passifFTP'] > 0),
'retryFTP' => $row['retryFTP'], 'retryFTP' => $row['retryFTP'],
'mailFTP' => $row['usr_mail'], '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)) { if (in_array('caption', $subdefs)) {
$caption_dir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/desc_tmp/' $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); $filesystem->mkdir($caption_dir, 0750);
@@ -663,7 +663,7 @@ class set_export extends set_abstract
if (in_array('caption-yaml', $subdefs)) { if (in_array('caption-yaml', $subdefs)) {
$caption_dir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/desc_tmp/' $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); $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); $log["shortXml"] = $record_object->get_caption()->serialize(caption_record::SERIALIZE_XML);
$tmplog[$record_object->get_base_id()][] = $log; $tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document') { 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); $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
foreach ($list_base as $base_id) { 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( $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 , ':base_id' => $base_id
, ':usr_id' => $app['phraseanet.user']->get_id() , ':usr_id' => $app['authentication']->getUser()->get_id()
); );
$stmt->execute($params); $stmt->execute($params);

View File

@@ -45,7 +45,7 @@ class set_exportftp extends set_export
$text_mail_receiver = "Bonjour,\n" $text_mail_receiver = "Bonjour,\n"
. "L'utilisateur " . "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 \"" . "a fait un transfert FTP sur le serveur ayant comme adresse \""
. $host . "\" avec le login \"" . $login . "\" " . $host . "\" avec le login \"" . $login . "\" "
. "et pour repertoire de destination \"" . "et pour repertoire de destination \""
@@ -103,10 +103,10 @@ class set_exportftp extends set_export
, ':pwd' => $password , ':pwd' => $password
, ':passif' => ($passif == "1" ? "1" : "0") , ':passif' => ($passif == "1" ? "1" : "0")
, ':destfolder' => $destfolder , ':destfolder' => $destfolder
, ':sendermail' => $this->app['phraseanet.user']->get_email() , ':sendermail' => $this->app['authentication']->getUser()->get_email()
, ':text_mail_receiver' => $text_mail_receiver , ':text_mail_receiver' => $text_mail_receiver
, ':text_mail_sender' => $text_mail_sender , ':text_mail_sender' => $text_mail_sender
, ':usr_id' => $this->app['phraseanet.user']->get_id() , ':usr_id' => $this->app['authentication']->getUser()->get_id()
, ':foldertocreate' => $makedirectory , ':foldertocreate' => $makedirectory
, ':logfile' => ( ! ! $logfile ? '1' : '0') , ':logfile' => ( ! ! $logfile ? '1' : '0')
); );

View File

@@ -244,7 +244,7 @@ class set_order extends set_abstract
$this->total = (int) $row['total']; $this->total = (int) $row['total'];
$this->ssel_id = (int) $row['ssel_id']; $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 $sql = 'SELECT e.base_id, e.record_id, e.order_master_id, e.id, e.deny
FROM order_elements e FROM order_elements e
@@ -379,7 +379,7 @@ class set_order extends set_abstract
$Basket = new \Entities\Basket(); $Basket = new \Entities\Basket();
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d'))); $Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
$Basket->setOwner($this->user); $Basket->setOwner($this->user);
$Basket->setPusher($app['phraseanet.user']); $Basket->setPusher($app['authentication']->getUser());
$app['EM']->persist($Basket); $app['EM']->persist($Basket);
$app['EM']->flush(); $app['EM']->flush();
@@ -419,7 +419,7 @@ class set_order extends set_abstract
$app['EM']->persist($BasketElement); $app['EM']->persist($BasketElement);
$params = array( $params = array(
':usr_id' => $app['phraseanet.user']->get_id() ':usr_id' => $app['authentication']->getUser()->get_id()
, ':order_id' => $this->id , ':order_id' => $this->id
, ':order_element_id' => $order_element_id , ':order_element_id' => $order_element_id
); );
@@ -427,7 +427,7 @@ class set_order extends set_abstract
$stmt->execute($params); $stmt->execute($params);
$n ++; $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); unset($record);
} catch (Exception $e) { } catch (Exception $e) {
@@ -441,7 +441,7 @@ class set_order extends set_abstract
if ($n > 0) { if ($n > 0) {
$params = array( $params = array(
'ssel_id' => $this->ssel_id, 'ssel_id' => $this->ssel_id,
'from' => $app['phraseanet.user']->get_id(), 'from' => $app['authentication']->getUser()->get_id(),
'to' => $this->user->get_id(), 'to' => $this->user->get_id(),
'n' => $n 'n' => $n
); );
@@ -470,7 +470,7 @@ class set_order extends set_abstract
AND ISNULL(order_master_id)'; AND ISNULL(order_master_id)';
$params = array( $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_id' => $this->id
, ':order_element_id' => $order_element_id , ':order_element_id' => $order_element_id
); );
@@ -482,7 +482,7 @@ class set_order extends set_abstract
if ($n > 0) { if ($n > 0) {
$params = array( $params = array(
'from' => $this->app['phraseanet.user']->get_id(), 'from' => $this->app['authentication']->getUser()->get_id(),
'to' => $this->user->get_id(), 'to' => $this->user->get_id(),
'n' => $n 'n' => $n
); );

View File

@@ -63,26 +63,26 @@ class set_selection extends set_abstract
$sbas_id = $record->get_sbas_id(); $sbas_id = $record->get_sbas_id();
$record_id = $record->get_record_id(); $record_id = $record->get_record_id();
if (! $rights) { if (! $rights) {
if ($this->app['phraseanet.user']->ACL()->has_hd_grant($record)) { if ($this->app['authentication']->getUser()->ACL()->has_hd_grant($record)) {
continue; continue;
} }
if ($this->app['phraseanet.user']->ACL()->has_preview_grant($record)) { if ($this->app['authentication']->getUser()->ACL()->has_preview_grant($record)) {
continue; 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; $to_remove[] = $id;
continue; continue;
} }
} else { } else {
foreach ($rights as $right) { 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; $to_remove[] = $id;
continue; continue;
} }
} }
foreach ($sbas_rights as $right) { 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; $to_remove[] = $id;
continue; continue;
} }
@@ -94,8 +94,8 @@ class set_selection extends set_abstract
$sql = 'SELECT record_id $sql = 'SELECT record_id
FROM record FROM record
WHERE ((status ^ ' . $this->app['phraseanet.user']->ACL()->get_mask_xor($base_id) . ') WHERE ((status ^ ' . $this->app['authentication']->getUser()->ACL()->get_mask_xor($base_id) . ')
& ' . $this->app['phraseanet.user']->ACL()->get_mask_and($base_id) . ')=0 & ' . $this->app['authentication']->getUser()->ACL()->get_mask_and($base_id) . ')=0
AND record_id = :record_id'; AND record_id = :record_id';
$stmt = $connsbas->prepare($sql); $stmt = $connsbas->prepare($sql);

View File

@@ -166,7 +166,7 @@ class task_period_writemeta extends task_databoxAbstract
public function getInterfaceHTML() 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(); ob_start();
if (count($sbas_ids) > 0) { if (count($sbas_ids) > 0) {