From 512e5e5bd195ea4547dc7fa29f34a9d205bd7a54 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Mon, 12 Jan 2015 19:11:45 -0500 Subject: [PATCH] Add ability to delete all articles matching a search --- inc/poche/Poche.class.php | 31 ++++++++++++++++++++++--------- themes/baggy/home.twig | 4 +++- themes/default/home.twig | 4 +++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c7c59878..540aa55e 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -201,18 +201,31 @@ class Poche } break; case 'delete': - $msg = 'delete link #' . $id; - if ($this->store->deleteById($id, $this->user->getId())) { - if (DOWNLOAD_PICTURES) { - Picture::removeDirectory(ABS_PATH . $id); + if (isset($_GET['search'])) { + //when we want to apply a delete to a search + $tags = array($_GET['search']); + $allentry_ids = $this->store->search($tags[0], $this->user->getId()); + $entry_ids = array(); + foreach ($allentry_ids as $eachentry) { + $entry_ids[] = $eachentry[0]; } - $this->messages->add('s', _('the link has been deleted successfully')); + } else { // delete a single article + $entry_ids = array($id); } - else { - $this->messages->add('e', _('the link wasn\'t deleted')); - $msg = 'error : can\'t delete link #' . $id; + foreach($entry_ids as $id) { + $msg = 'delete link #' . $id; + if ($this->store->deleteById($id, $this->user->getId())) { + if (DOWNLOAD_PICTURES) { + Picture::removeDirectory(ABS_PATH . $id); + } + $this->messages->add('s', _('the link has been deleted successfully')); + } + else { + $this->messages->add('e', _('the link wasn\'t deleted')); + $msg = 'error : can\'t delete link #' . $id; + } + Tools::logm($msg); } - Tools::logm($msg); Tools::redirect('?'); break; case 'toggle_fav' : diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index abebe455..9cd66395 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig @@ -59,7 +59,9 @@ {{ block('pager') }} {% if view == 'home' %}{% if nb_results > 1 %}

{% trans "Mark all the entries as read" %}

{% endif %}{% endif %} {% if searchterm is defined %}{% trans "Tag these results as" %} {{ searchterm }}{% endif %}
- + + {% if searchterm is defined %}{% trans "Delete results matching" %} {{ searchterm }}{% endif %}
+ {% if tag %} {% if constant('EPUB') == 1 %}{% trans "Download as ePub3" %}{% endif %} {% if constant('MOBI') == 1 %}{% trans "Download as Mobi" %}{% endif %} diff --git a/themes/default/home.twig b/themes/default/home.twig index c5db5802..88e6a6ea 100755 --- a/themes/default/home.twig +++ b/themes/default/home.twig @@ -59,7 +59,9 @@ {{ block('pager') }} {% if view == 'home' %}{% if nb_results > 1 %}

{% trans "Mark all the entries as read" %}

{% endif %}{% endif %} {% if searchterm is defined %}{% trans "Tag these results as" %} {{ searchterm }}{% endif %}
- + + {% if searchterm is defined %}{% trans "Delete results matching" %} {{ searchterm }}{% endif %}
+ {% if tag %} {% if constant('EPUB') == 1 %}{% trans "Download as ePub3" %}{% endif %} {% if constant('MOBI') == 1 %}{% trans "Download as Mobi" %}{% endif %} -- 2.41.0