diff --git a/include/simpleplugin/attributes/class_FileAttribute.inc b/include/simpleplugin/attributes/class_FileAttribute.inc index 388112074afd0c382f494196c1d88946d08c9e3d..8c310ec4404903f66430369c4205da0c24954f87 100644 --- a/include/simpleplugin/attributes/class_FileAttribute.inc +++ b/include/simpleplugin/attributes/class_FileAttribute.inc @@ -130,6 +130,7 @@ class FileDownloadAttribute extends FileAttribute { protected $extension; protected $upload; + protected $download = TRUE; function __construct ($label, $description, $ldapName, $required = FALSE, $extension = '', $upload = FALSE, $defaultValue = "", $acl = "") { @@ -148,13 +149,15 @@ class FileDownloadAttribute extends FileAttribute { if ($this->isVisible()) { $this->postValue = $this->value; - foreach (array_keys($_POST) as $name) { - if (preg_match('/^download'.$this->getHtmlId().'/', $name)) { - session::set('binary', $this->value); - session::set('binarytype', 'octet-stream'); - session::set('binaryfile', $this->computeFilename()); - header('location: getbin.php'); - exit(); + if ($this->download) { + foreach (array_keys($_POST) as $name) { + if (preg_match('/^download'.$this->getHtmlId().'/', $name)) { + session::set('binary', $this->value); + session::set('binarytype', 'octet-stream'); + session::set('binaryfile', $this->computeFilename()); + header('location: getbin.php'); + exit(); + } } } if ($this->upload && isset($_POST['upload'.$this->getHtmlId()])) { @@ -171,22 +174,27 @@ class FileDownloadAttribute extends FileAttribute $display .= $this->renderInputField('file', $id); $display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload'), 'formnovalidate' => 'formnovalidate')); } - $display .= $this->renderInputField( - 'image', 'download'.$id, - array( - 'title' => _('Download'), - 'alt' => _('Download'), - 'class' => 'center', - 'src' => 'geticon.php?context=actions&icon=document-save&size=16', - ) - ); + if ($this->download) { + $display .= $this->renderInputField( + 'image', 'download'.$id, + array( + 'title' => _('Download'), + 'alt' => _('Download'), + 'class' => 'center', + 'src' => 'geticon.php?context=actions&icon=document-save&size=16', + ) + ); + } return $this->renderAcl($display); } public function htmlIds() { $id = $this->getHtmlId(); - $ids = array('download'.$id); + $ids = array(); + if ($this->download) { + $ids[] = 'download'.$id; + } if ($this->upload) { $ids[] = $id; $ids[] = 'upload'.$id; @@ -210,12 +218,13 @@ class FileDownloadAttribute extends FileAttribute class FileTextAreaAttribute extends FileDownloadAttribute { /* Default values are not the same that for FileDownloadAttribute */ - function __construct ($label, $description, $ldapName, $required = FALSE, $extension = '.txt', $upload = TRUE, $defaultValue = '', $acl = '') + function __construct ($label, $description, $ldapName, $required = FALSE, $extension = '.txt', $upload = TRUE, $download = TRUE, $defaultValue = '', $acl = '') { parent::__construct( $label, $description, $ldapName, $required, $extension, $upload, $defaultValue, $acl ); + $this->download = $download; } /*! \brief Update this attributes postValue depending of the $_POST values @@ -224,13 +233,15 @@ class FileTextAreaAttribute extends FileDownloadAttribute { if ($this->isVisible()) { $this->postValue = $this->value; - foreach (array_keys($_POST) as $name) { - if (preg_match('/^download'.$this->getHtmlId().'/', $name)) { - session::set('binary', $this->value); - session::set('binarytype', 'octet-stream'); - session::set('binaryfile', $this->computeFilename()); - header('location: getbin.php'); - exit(); + if ($this->download) { + foreach (array_keys($_POST) as $name) { + if (preg_match('/^download'.$this->getHtmlId().'/', $name)) { + session::set('binary', $this->value); + session::set('binarytype', 'octet-stream'); + session::set('binaryfile', $this->computeFilename()); + header('location: getbin.php'); + exit(); + } } } if ($this->upload) {