]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Bugfixes on link deletion, and use a GET form
authorArthurHoaro <arthur@hoa.ro>
Sat, 5 Nov 2016 13:13:18 +0000 (14:13 +0100)
committerArthurHoaro <arthur@hoa.ro>
Sat, 5 Nov 2016 13:30:56 +0000 (14:30 +0100)
Use a GET form to delete links: harmonize with edit_link and preparation for #585

Bug fixes:

  * LinkDB element can't be passed as reference, fix error:

    PHP Notice:  Indirect modification of overloaded element of LinkDB has no effect

  * Resource cache folder setting wasn't set correctly

application/Router.php
index.php
tpl/linklist.html

index caed4a281619f56aefd0482575dd2427510208de..c9a519120eecf3274c1b66a7df5f4e2deacbec95 100644 (file)
@@ -31,6 +31,8 @@ class Router
 
     public static $PAGE_EDITLINK = 'edit_link';
 
+    public static $PAGE_DELETELINK = 'delete_link';
+
     public static $PAGE_EXPORT = 'export';
 
     public static $PAGE_IMPORT = 'import';
@@ -120,6 +122,10 @@ class Router
             return self::$PAGE_EDITLINK;
         }
 
+        if (isset($get['delete_link'])) {
+            return self::$PAGE_DELETELINK;
+        }
+
         if (startsWith($query, 'do='. self::$PAGE_EXPORT)) {
             return self::$PAGE_EXPORT;
         }
index 84282b8dc6c6ecc41dd67cae0eae0e9c3fdf883a..c4c0d15ada79b7420dca028f149d50b043c9178b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1314,18 +1314,19 @@ function renderPage($conf, $pluginManager)
     }
 
     // -------- User clicked the "Delete" button when editing a link: Delete link from database.
-    if (isset($_POST['delete_link']))
+    if ($targetPage == Router::$PAGE_DELETELINK)
     {
-        if (!tokenOk($_POST['token'])) die('Wrong token.');
+        if (!tokenOk($_GET['token'])) die('Wrong token.');
         // We do not need to ask for confirmation:
         // - confirmation is handled by JavaScript
         // - we are protected from XSRF by the token.
-        $linkdate=$_POST['lf_linkdate'];
-
-        $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
+        $linkdate = $_GET['delete_link'];
+        $link = $LINKSDB[$linkdate];
+        
+        $pluginManager->executeHooks('delete_link', $link);
 
         unset($LINKSDB[$linkdate]);
-        $LINKSDB->save('resource.page_cache'); // save to disk
+        $LINKSDB->save($conf->get('resource.page_cache')); // save to disk
 
         // If we are called from the bookmarklet, we must close the popup:
         if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
index 9782cff6c0286bda32142cf88095118f5533e227..70c9cf79eecaf9716eb90078f894ec56dfd4e4b6 100644 (file)
                             <input type="hidden" name="edit_link" value="{$value.linkdate}">
                             <input type="image" alt="Edit" src="images/edit_icon.png#" title="Edit" class="button_edit">
                         </form><br>
-                        <form method="POST" class="buttoneditform">
-                            <input type="hidden" name="lf_linkdate" value="{$value.linkdate}">
+                        <form method="GET" class="buttoneditform">
                             <input type="hidden" name="token" value="{$token}">
-                            <input type="hidden" name="delete_link">
+                            <input type="hidden" name="delete_link" value="{$value.linkdate}">
                             <input type="image" alt="Delete" src="images/delete_icon.png#" title="Delete"
                                    class="button_delete" onClick="return confirmDeleteLink();">
                         </form>