mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
PHRAS-3724 restrict download option when print (#4112)
This commit is contained in:
@@ -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())
|
||||
)
|
||||
|
@@ -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);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% if total_count > 0 %}
|
||||
{% set subdefCount = printer.getSubdefCount %}
|
||||
{% if printer.get_count_preview() > 0 %}
|
||||
<div style="margin: 20px 5px;">
|
||||
<label class="checkbox" for="show-record-information" style="margin-top: 5px;height: 21px;padding-top: 2px;padding-bottom: 2px;">
|
||||
@@ -97,11 +98,13 @@
|
||||
<fieldset style="padding:10px;">
|
||||
<select id="print-select-download-subdef" name="print-select-download-subdef" style="margin-left: 0px;">
|
||||
{% for subdefName in printer.getAvailableSubdefName %}
|
||||
<option value="{{ subdefName}}" class="download-{{ subdefName }}"
|
||||
data-count=""
|
||||
{% if subdefName == "preview" %} selected {% endif %} >
|
||||
{{ subdefName }}
|
||||
</option>
|
||||
{% if subdefCount[subdefName] > 0 %} }
|
||||
<option value="{{ subdefName}}" class="download-{{ subdefName }}"
|
||||
data-count=""
|
||||
{% if subdefName == "preview" %} selected {% endif %} >
|
||||
{{ subdefName }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="acceptDl-info" style="display:inline-block;padding-top: 4px;width: 400px;text-align: center;margin-bottom: 0px;">
|
||||
@@ -210,11 +213,11 @@
|
||||
// add dynamically the subdef count in the select option
|
||||
var totalCount = {{ total_count }};
|
||||
var subdefImageCount = JSON.parse('{{ printer.getSubdefImageCount|json_encode|raw }}');
|
||||
var subdefCount = JSON.parse('{{ printer.getSubdefCount|json_encode|raw }}');
|
||||
var subdefCount = JSON.parse('{{ subdefCount|json_encode|raw }}');
|
||||
|
||||
for (const [key, value] of Object.entries(subdefCount)) {
|
||||
$(".download-"+ key).attr('data-count', value + " / " + totalCount);
|
||||
if (key == 'preview') {
|
||||
if ($("#print-select-download-subdef").val() == key) {
|
||||
$('.download-count-info').empty().text(value + " / " + totalCount);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user