Add getAuthenticator usage

Replace $app['authentication']->getUser() by $app->getAuthenticatedUser()
replace twig app['authentication'].getUser() with corresponding method
This commit is contained in:
Benoît Burnichon
2015-06-30 19:51:02 +02:00
parent 3804eb5408
commit 4880f2bf5a
113 changed files with 437 additions and 428 deletions

View File

@@ -49,7 +49,7 @@ class set_export extends set_abstract
if ($storyWZid) {
$repository = $app['repo.story-wz'];
$storyWZ = $repository->findByUserAndId($this->app, $app['authentication']->getUser(), $storyWZid);
$storyWZ = $repository->findByUserAndId($this->app, $app->getAuthenticatedUser(), $storyWZid);
$lst = $storyWZ->getRecord($this->app)->get_serialize_key();
}
@@ -58,7 +58,7 @@ class set_export extends set_abstract
$repository = $app['repo.baskets'];
/* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
$Basket = $repository->findUserBasket($sstid, $app['authentication']->getUser(), false);
$Basket = $repository->findUserBasket($sstid, $app->getAuthenticatedUser(), false);
$this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
foreach ($Basket->getElements() as $basket_element) {
@@ -66,8 +66,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['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->remaining_download($base_id);
if ($app['acl']->get($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
@@ -106,8 +106,8 @@ class set_export extends set_abstract
$record_id = $child_basrec->get_record_id();
if (!isset($remain_hd[$base_id])) {
if ($app['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->remaining_download($base_id);
if ($app['acl']->get($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
@@ -129,8 +129,8 @@ class set_export extends set_abstract
$record_id = $record->get_record_id();
if (!isset($remain_hd[$base_id])) {
if ($app['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app['authentication']->getUser())->remaining_download($base_id);
if ($app['acl']->get($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$remain_hd[$base_id] = $app['acl']->get($app->getAuthenticatedUser())->remaining_download($base_id);
} else {
$remain_hd[$base_id] = false;
}
@@ -164,7 +164,7 @@ class set_export extends set_abstract
$this->businessFieldsAccess = false;
foreach ($this->elements as $download_element) {
if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
if ($app['acl']->get($app->getAuthenticatedUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
$this->businessFieldsAccess = true;
}
@@ -216,11 +216,11 @@ class set_export extends set_abstract
$display_ftp = [];
$hasadminright = $app['acl']->get($app['authentication']->getUser())->has_right('addrecord')
|| $app['acl']->get($app['authentication']->getUser())->has_right('deleterecord')
|| $app['acl']->get($app['authentication']->getUser())->has_right('modifyrecord')
|| $app['acl']->get($app['authentication']->getUser())->has_right('coll_manage')
|| $app['acl']->get($app['authentication']->getUser())->has_right('coll_modify_struct');
$hasadminright = $app['acl']->get($app->getAuthenticatedUser())->has_right('addrecord')
|| $app['acl']->get($app->getAuthenticatedUser())->has_right('deleterecord')
|| $app['acl']->get($app->getAuthenticatedUser())->has_right('modifyrecord')
|| $app['acl']->get($app->getAuthenticatedUser())->has_right('coll_manage')
|| $app['acl']->get($app->getAuthenticatedUser())->has_right('coll_modify_struct');
$this->ftp_datas = [];
@@ -228,7 +228,7 @@ class set_export extends set_abstract
$display_ftp = $display_download;
$this->total_ftp = $this->total_download;
$lst_base_id = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base());
$lst_base_id = array_keys($app['acl']->get($app->getAuthenticatedUser())->get_granted_base());
if ($hasadminright) {
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
@@ -258,7 +258,7 @@ class set_export extends set_abstract
)
)
GROUP BY Users.id ";
$params = [':usr_id' => $app['authentication']->getUser()->getId()];
$params = [':usr_id' => $app->getAuthenticatedUser()->getId()];
}
$datas[] = [
@@ -272,7 +272,7 @@ class set_export extends set_abstract
'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"),
'passive' => false,
'max_retry' => 5,
'sendermail' => $app['authentication']->getUser()->getEmail()
'sendermail' => $app->getAuthenticatedUser()->getEmail()
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
@@ -296,7 +296,7 @@ class set_export extends set_abstract
'passive' => !! $row['passive'],
'max_retry' => $row['max_retry'],
'usr_mail' => $row['usr_mail'],
'sender_mail' => $app['authentication']->getUser()->getEmail()
'sender_mail' => $app->getAuthenticatedUser()->getEmail()
];
}
@@ -631,7 +631,7 @@ class set_export extends set_abstract
$files[$id]["export_name"] = $tmp_name;
if (in_array('caption', $subdefs)) {
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/';
$filesystem->mkdir($caption_dir, 0750);
@@ -652,7 +652,7 @@ class set_export extends set_abstract
}
if (in_array('caption-yaml', $subdefs)) {
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/';
$filesystem->mkdir($caption_dir, 0750);
@@ -775,8 +775,8 @@ class set_export extends set_abstract
$log["poids"] = $obj["size"];
$log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML);
$tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document' && null !== $app['authentication']->getUser()) {
$app['acl']->get($app['authentication']->getUser())->remove_remaining($record_object->get_base_id());
if (!$anonymous && $o == 'document' && null !== $app->getAuthenticatedUser()) {
$app['acl']->get($app->getAuthenticatedUser())->remove_remaining($record_object->get_base_id());
}
}
@@ -786,7 +786,7 @@ class set_export extends set_abstract
$list_base = array_unique(array_keys($tmplog));
if (!$anonymous && null !== $app['authentication']->getUser()) {
if (!$anonymous && null !== $app->getAuthenticatedUser()) {
$sql = "UPDATE basusr
SET remain_dwnld = :remain_dl
WHERE base_id = :base_id AND usr_id = :usr_id";
@@ -794,11 +794,11 @@ class set_export extends set_abstract
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
foreach ($list_base as $base_id) {
if ($app['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) {
if ($app['acl']->get($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$params = [
':remain_dl' => $app['acl']->get($app['authentication']->getUser())->remaining_download($base_id)
':remain_dl' => $app['acl']->get($app->getAuthenticatedUser())->remaining_download($base_id)
, ':base_id' => $base_id
, ':usr_id' => $app['acl']->get($app['authentication']->getUser())->getId()
, ':usr_id' => $app['acl']->get($app->getAuthenticatedUser())->getId()
];
$stmt->execute($params);