diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-09-01 18:25:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-01 18:25:44 +0200 |
commit | 87d019986e6948bd3f88eea94cc5b09e34d938aa (patch) | |
tree | c0efb8d0cf07f1632d0f85128bed90ae725959c2 | |
parent | c5f5365ae6d57f6ca49b9ed6b6be05c52a05c3bb (diff) | |
parent | a74f52a8d206a6d5c3fe27667f1633bf2fc1374d (diff) | |
download | Shaarli-87d019986e6948bd3f88eea94cc5b09e34d938aa.tar.gz Shaarli-87d019986e6948bd3f88eea94cc5b09e34d938aa.tar.zst Shaarli-87d019986e6948bd3f88eea94cc5b09e34d938aa.zip |
Merge pull request #950 from thewilli/delete-fix
fixed link deletion
-rw-r--r-- | index.php | 13 | ||||
-rw-r--r-- | tpl/default/js/shaarli.js | 6 |
2 files changed, 13 insertions, 6 deletions
@@ -1330,10 +1330,17 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
1330 | die('Wrong token.'); | 1330 | die('Wrong token.'); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | if (strpos($_GET['lf_linkdate'], ' ') !== false) { | 1333 | $ids = trim($_GET['lf_linkdate']); |
1334 | $ids = array_values(array_filter(preg_split('/\s+/', escape($_GET['lf_linkdate'])))); | 1334 | if (strpos($ids, ' ') !== false) { |
1335 | // multiple, space-separated ids provided | ||
1336 | $ids = array_values(array_filter(preg_split('/\s+/', escape($ids)))); | ||
1335 | } else { | 1337 | } else { |
1336 | $ids = [$_GET['lf_linkdate']]; | 1338 | // only a single id provided |
1339 | $ids = [$ids]; | ||
1340 | } | ||
1341 | // assert at least one id is given | ||
1342 | if(!count($ids)){ | ||
1343 | die('no id provided'); | ||
1337 | } | 1344 | } |
1338 | foreach ($ids as $id) { | 1345 | foreach ($ids as $id) { |
1339 | $id = (int) escape($id); | 1346 | $id = (int) escape($id); |
diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index 4f49affa..f38ba62f 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js | |||
@@ -401,14 +401,14 @@ window.onload = function () { | |||
401 | 401 | ||
402 | var message = 'Are you sure you want to delete '+ links.length +' links?\n'; | 402 | var message = 'Are you sure you want to delete '+ links.length +' links?\n'; |
403 | message += 'This action is IRREVERSIBLE!\n\nTitles:\n'; | 403 | message += 'This action is IRREVERSIBLE!\n\nTitles:\n'; |
404 | var ids = ''; | 404 | var ids = []; |
405 | links.forEach(function(item) { | 405 | links.forEach(function(item) { |
406 | message += ' - '+ item['title'] +'\n'; | 406 | message += ' - '+ item['title'] +'\n'; |
407 | ids += item['id'] +'+'; | 407 | ids.push(item['id']); |
408 | }); | 408 | }); |
409 | 409 | ||
410 | if (window.confirm(message)) { | 410 | if (window.confirm(message)) { |
411 | window.location = '?delete_link&lf_linkdate='+ ids +'&token='+ token.value; | 411 | window.location = '?delete_link&lf_linkdate='+ ids.join('+') +'&token='+ token.value; |
412 | } | 412 | } |
413 | }); | 413 | }); |
414 | } | 414 | } |