diff --git a/lib/Alchemy/Phrasea/Helper/Record/Printer.php b/lib/Alchemy/Phrasea/Helper/Record/Printer.php index 6568ae87d7..64f554e1e8 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Printer.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Printer.php @@ -137,6 +137,7 @@ class Printer extends RecordHelper $this->userACL->has_right_on_base($element->getBaseId(), \ACL::CANDWNLDHD)) || ($subdefName != 'document' && $element->has_subdef($subdefName) && + $this->userACL->has_right_on_base($element->getBaseId(), \ACL::CANDWNLDPREVIEW) && $this->userACL->has_access_to_subdef($element, $subdefName) && $element->get_subdef($subdefName)->is_physically_present()) ) diff --git a/lib/Alchemy/Phrasea/Out/Module/PDFRecords.php b/lib/Alchemy/Phrasea/Out/Module/PDFRecords.php index 9b7345feaf..58c44bf6ab 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDFRecords.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDFRecords.php @@ -286,7 +286,12 @@ class PDFRecords extends PDF $downloadLink = $rec->get_title(); - if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef)) { + + if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef) + && (($rec->get_subdef($this->downloadSubdef)->get_name() != 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDPREVIEW)) + || + ($rec->get_subdef($this->downloadSubdef)->get_name() == 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDHD))) + ) { $sd = $rec->get_subdef($this->downloadSubdef); if ($sd->is_physically_present()) { $url = $this->getDownloadUrl($sd); @@ -431,7 +436,11 @@ class PDFRecords extends PDF $p0 = $this->pdf->PageNo(); $y0 = $this->pdf->GetY(); - if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef)) { + if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef) + && (($rec->get_subdef($this->downloadSubdef)->get_name() != 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDPREVIEW)) + || + ($rec->get_subdef($this->downloadSubdef)->get_name() == 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDHD))) + ) { $sd = $rec->get_subdef($this->downloadSubdef); if ($sd->is_physically_present()) { $url = $this->getDownloadUrl($sd); @@ -522,7 +531,11 @@ class PDFRecords extends PDF $this->pdf->SetY($y = $y2); $this->pdf->SetY($y + 2); - if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef)) { + if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef) + && ((($rec->get_subdef($this->downloadSubdef)->get_name() != 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDPREVIEW)) + || + ($rec->get_subdef($this->downloadSubdef)->get_name() == 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDHD))) ) + ) { $sd = $rec->get_subdef($this->downloadSubdef); if ($sd->is_physically_present()) { $url = $this->getDownloadUrl($sd); @@ -810,7 +823,11 @@ class PDFRecords extends PDF } $this->pdf->SetXY($lmargin, $y += ( $finalHeight + 5)); - if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef)) { + if ($this->canDownload && !empty($this->downloadSubdef) && $rec->has_subdef($this->downloadSubdef) + && ((($rec->get_subdef($this->downloadSubdef)->get_name() != 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDPREVIEW)) + || + ($rec->get_subdef($this->downloadSubdef)->get_name() == 'document' && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($rec->getBaseId(), \ACL::CANDWNLDHD)))) + ) { $sd = $rec->get_subdef($this->downloadSubdef); if ($sd->is_physically_present()) { $url = $this->getDownloadUrl($sd); diff --git a/templates/web/prod/actions/printer_default.html.twig b/templates/web/prod/actions/printer_default.html.twig index b95d6f96f2..daf7e198d8 100644 --- a/templates/web/prod/actions/printer_default.html.twig +++ b/templates/web/prod/actions/printer_default.html.twig @@ -29,6 +29,7 @@ {% endif %} {% if total_count > 0 %} + {% set subdefCount = printer.getSubdefCount %} {% if printer.get_count_preview() > 0 %}