Skip to content

Commit

Permalink
feat: Add possibility to disable Organization
Browse files Browse the repository at this point in the history
  • Loading branch information
xgaia authored and wincelau committed Mar 17, 2023
1 parent 7d7e666 commit c9f0d25
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 :
Expand Down
9 changes: 8 additions & 1 deletion app.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
$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');
Expand Down Expand Up @@ -294,6 +299,7 @@ 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')))));
Expand All @@ -319,7 +325,7 @@ function($f3) {
$filenames[] = str_replace('.pdf', '', $fileBaseName);

return basename($tmpfile).uniqid().".pdf";
});
});

if(!count($files)) {
$f3->error(403);
Expand All @@ -341,6 +347,7 @@ function($f3) {
array_map('unlink', glob($tmpfile."*"));
}
);
}

function convertPHPSizeToBytes($sSize)
{
Expand Down
3 changes: 2 additions & 1 deletion config/config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions config/config.ini.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 2 additions & 0 deletions templates/signature.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit c9f0d25

Please sign in to comment.