feat: Add possibility to disable Organization

This commit is contained in:
xgaia 2023-03-14 17:18:10 +01:00 committed by Vincent LAURENT
parent 7d7e666bc7
commit c9f0d25027
6 changed files with 21 additions and 3 deletions

View File

@ -5,6 +5,7 @@ ENV UPLOAD_MAX_FILESIZE=24M
ENV POST_MAX_SIZE=24M
ENV MAX_FILE_UPLOADS=201
ENV PDF_STORAGE_PATH=
ENV DISABLE_ORGANIZATION=false
RUN apt update && \
apt install -y gettext-base librsvg2-bin pdftk imagemagick potrace && \

View File

@ -96,10 +96,11 @@ Les variables suivantes permettent de configurer le déployement :
|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48M|24M|
|`MAX_FILE_UPLOADS`|Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine|401|201|
|`PDF_STORAGE_PATH`|chemin vers lequel les fichiers pdf uploadés pourront être stockés|/data||
|`DISABLE_ORGANIZATION`|Desactiver la route Organiser|true|false|
```bash
docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 -e PDF_STORAGE_PATH=/data signaturepdf
````
```
### Alpine
@ -237,6 +238,11 @@ Par exemple pour apache :
chown www-data /path/to/folder/to/store/pdf
```
### Desactivation du mode Organiser
Pour desactiver le mode Organiser, ajouter `DISABLE_ORGANIZATION=true` dans le fichier
`config/config.ini`.
## Mise à jour
La dernière version stable est sur la branche `master`, pour la mise à jour il suffit de récupérer les dernières modifications :

View File

@ -16,6 +16,11 @@ if($f3->get('PDF_STORAGE_PATH') && !preg_match('|/$|', $f3->get('PDF_STORAGE_PAT
$f3->set('PDF_STORAGE_PATH', $f3->get('PDF_STORAGE_PATH').'/');
}
$f3->set('disableOrganization', false);
if($f3->get('DISABLE_ORGANIZATION')) {
$f3->set('disableOrganization', $f3->get('DISABLE_ORGANIZATION'));
}
$f3->route('GET /',
function($f3) {
$f3->reroute('/signature');
@ -294,6 +299,7 @@ $f3->route('GET /cron', function($f3) {
}
});
if (!$f3->get('disableOrganization')) {
$f3->route('GET /organization',
function($f3) {
$f3->set('maxSize', min(array(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')))));
@ -319,7 +325,7 @@ $f3->route('POST /organize',
$filenames[] = str_replace('.pdf', '', $fileBaseName);
return basename($tmpfile).uniqid().".pdf";
});
});
if(!count($files)) {
$f3->error(403);
@ -341,6 +347,7 @@ $f3->route('POST /organize',
array_map('unlink', glob($tmpfile."*"));
}
);
}
function convertPHPSizeToBytes($sSize)
{

View File

@ -2,4 +2,5 @@
# Path to which stored pdf to activate the mode of sharing a signature to several.
# To deactivate this mode, simply do not configure it or leave it empty
PDF_STORAGE_PATH=/path/to/folder
PDF_STORAGE_PATH=/path/to/folder
DISABLE_ORGANIZATION=false

View File

@ -3,3 +3,4 @@
# Path to which stored pdf to activate the mode of sharing a signature to several.
# To deactivate this mode, simply do not configure it or leave it empty
PDF_STORAGE_PATH=${PDF_STORAGE_PATH}
DISABLE_ORGANIZATION=${DISABLE_ORGANIZATION}

View File

@ -17,6 +17,7 @@
</div>
</noscript>
<div id="page-upload">
<?php if(!$disableOrganization): ?>
<ul class="nav justify-content-center nav-tabs mt-2">
<li class="nav-item">
<a class="nav-link active" href="/signature"><i class="bi bi-vector-pen"></i> Signer</a>
@ -25,6 +26,7 @@
<a class="nav-link" href="/organization"><i class="bi bi-ui-checks-grid"></i> Organiser</a>
</li>
</ul>
<?php endif; ?>
<div class="px-4 py-4 text-center">
<h1 class="display-5 fw-bold mb-0 mt-3"><i class="bi bi-vector-pen"></i> Signer un PDF</h1>
<p class="fw-light mb-3 subtitle text-dark text-nowrap" style="overflow: hidden; text-overflow: ellipsis;">Signer, parapher, tamponner, compléter un document</p>