From: ArthurHoaro Date: Sun, 11 Oct 2020 11:34:38 +0000 (+0200) Subject: Bulk creation: fix private status based on the first form X-Git-Tag: v0.12.1^2~23^2~3 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=25e90d8d75382721ff7473fa1686090fcfeb46ff Bulk creation: fix private status based on the first form --- diff --git a/application/front/controller/admin/ShaarePublishController.php b/application/front/controller/admin/ShaarePublishController.php index 608f79cf..fd680ea0 100644 --- a/application/front/controller/admin/ShaarePublishController.php +++ b/application/front/controller/admin/ShaarePublishController.php @@ -169,7 +169,11 @@ class ShaarePublishController extends ShaarliAdminController $title = $request->getParam('title'); $description = $request->getParam('description'); $tags = $request->getParam('tags'); - $private = filter_var($request->getParam('private'), FILTER_VALIDATE_BOOLEAN); + if ($request->getParam('private') !== null) { + $private = filter_var($request->getParam('private'), FILTER_VALIDATE_BOOLEAN); + } else { + $private = $this->container->conf->get('privacy.default_private_links', false); + } // If this is an HTTP(S) link, we try go get the page to extract // the title (otherwise we will to straight to the edit form.) diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 9161b4fc..4163577d 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js @@ -654,5 +654,13 @@ function init(description) { e.preventDefault(); toggleBulkCreationVisibility(bulkCreationButton, bulkCreationForm); }); + + // Force to send falsy value if the checkbox is not checked. + const privateButton = bulkCreationForm.querySelector('input[type="checkbox"][name="private"]'); + const privateHiddenButton = bulkCreationForm.querySelector('input[type="hidden"][name="private"]'); + privateButton.addEventListener('click', () => { + privateHiddenButton.disabled = !privateHiddenButton.disabled; + }); + privateHiddenButton.disabled = privateButton.checked; } })(); diff --git a/tpl/default/addlink.html b/tpl/default/addlink.html index 7d4bc9e6..4aac7ff1 100644 --- a/tpl/default/addlink.html +++ b/tpl/default/addlink.html @@ -62,8 +62,8 @@
- + +  
diff --git a/tpl/default/editlink.html b/tpl/default/editlink.html index 980b2b8e..83e541fd 100644 --- a/tpl/default/editlink.html +++ b/tpl/default/editlink.html @@ -65,7 +65,7 @@