]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Bulk creation: fix private status based on the first form
authorArthurHoaro <arthur@hoa.ro>
Sun, 11 Oct 2020 11:34:38 +0000 (13:34 +0200)
committerArthurHoaro <arthur@hoa.ro>
Tue, 27 Oct 2020 19:11:30 +0000 (20:11 +0100)
application/front/controller/admin/ShaarePublishController.php
assets/default/js/base.js
tpl/default/addlink.html
tpl/default/editlink.html

index 608f79cfe1e7a29fe1e9b8861a7dde0204c951ce..fd680ea0090ca1e72d3d3c5d3b1ff3add7c66317 100644 (file)
@@ -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.)
index 9161b4fc1f3a153d02bad6367b30015c6bc1eeee..4163577d0da527d3d1d7b91c3c1eb830bfda4cea 100644 (file)
@@ -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;
   }
 })();
index 7d4bc9e6084e220c9b612a08947e3c171e73ff4d..4aac7ff1e69617df47b78f146ed739f030424c1c 100644 (file)
@@ -62,8 +62,8 @@
           </div>
 
           <div>
-            <input type="checkbox" name="private"
-                   {if="$default_private_links"} checked="checked"{/if}>
+            <input type="hidden" name="private" value="0">
+            <input type="checkbox" name="private" {if="$default_private_links"} checked="checked"{/if}>
           &nbsp; <label for="lf_private">{'Private'|t}</label>
           </div>
         </div>
index 980b2b8e04999f982b4d509d1e696174f505d312..83e541fdf6b32aaf45a985a20645ab19c53bbc37 100644 (file)
@@ -65,7 +65,7 @@
 
       <div>
         <input type="checkbox"  name="lf_private" id="lf_private"
-        {if="($link_is_new && $default_private_links || $link.private == true)"}
+        {if="$link.private === true"}
           checked="checked"
         {/if}>
         &nbsp;<label for="lf_private">{'Private'|t}</label>