diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-03-12 19:03:50 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-05-08 14:27:20 +0200 |
commit | 29a837f347f53f751b723d466a2cd05fd92fd34e (patch) | |
tree | 5f477d220b7b8c1987b2b337dd69ceb26edc3f0b /index.php | |
parent | bf67ac345f588130e98e784b4ee4740b0dad83fc (diff) | |
download | Shaarli-29a837f347f53f751b723d466a2cd05fd92fd34e.tar.gz Shaarli-29a837f347f53f751b723d466a2cd05fd92fd34e.tar.zst Shaarli-29a837f347f53f751b723d466a2cd05fd92fd34e.zip |
Bulk deletion
* Add a checkboxes in linklist which display a sub-header containing action buttons
* Strongly rely on JS
* Requires a modern browser (ES6 syntax support)
* Checkboxes are hidden if the browser is old or JS disabled
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -1329,18 +1329,21 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
1329 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. | 1329 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. |
1330 | if ($targetPage == Router::$PAGE_DELETELINK) | 1330 | if ($targetPage == Router::$PAGE_DELETELINK) |
1331 | { | 1331 | { |
1332 | // We do not need to ask for confirmation: | ||
1333 | // - confirmation is handled by JavaScript | ||
1334 | // - we are protected from XSRF by the token. | ||
1335 | |||
1336 | if (! tokenOk($_GET['token'])) { | 1332 | if (! tokenOk($_GET['token'])) { |
1337 | die('Wrong token.'); | 1333 | die('Wrong token.'); |
1338 | } | 1334 | } |
1339 | 1335 | ||
1340 | $id = intval(escape($_GET['lf_linkdate'])); | 1336 | if (strpos($_GET['lf_linkdate'], ' ') !== false) { |
1341 | $link = $LINKSDB[$id]; | 1337 | $ids = array_values(array_filter(preg_split('/\s+/', escape($_GET['lf_linkdate'])))); |
1342 | $pluginManager->executeHooks('delete_link', $link); | 1338 | } else { |
1343 | unset($LINKSDB[$id]); | 1339 | $ids = [$_GET['lf_linkdate']]; |
1340 | } | ||
1341 | foreach ($ids as $id) { | ||
1342 | $id = (int) escape($id); | ||
1343 | $link = $LINKSDB[$id]; | ||
1344 | $pluginManager->executeHooks('delete_link', $link); | ||
1345 | unset($LINKSDB[$id]); | ||
1346 | } | ||
1344 | $LINKSDB->save($conf->get('resource.page_cache')); // save to disk | 1347 | $LINKSDB->save($conf->get('resource.page_cache')); // save to disk |
1345 | $history->deleteLink($link); | 1348 | $history->deleteLink($link); |
1346 | 1349 | ||