aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
authortcit <tcit@tcit.fr>2014-05-14 18:51:02 +0200
committertcit <tcit@tcit.fr>2014-05-14 18:51:02 +0200
commit24696800e5caac6e37ebd2ac166578a9b18aba9d (patch)
treedd8ecc533ee0fb4aec41f8dc179ec7e2abab6387 /inc
parent4910af33ff79cdce6325a07bb0dc74fe4821e680 (diff)
downloadwallabag-24696800e5caac6e37ebd2ac166578a9b18aba9d.tar.gz
wallabag-24696800e5caac6e37ebd2ac166578a9b18aba9d.tar.zst
wallabag-24696800e5caac6e37ebd2ac166578a9b18aba9d.zip
Simplifed function which does tag cleanup
Diffstat (limited to 'inc')
-rwxr-xr-xinc/poche/Database.class.php17
-rwxr-xr-xinc/poche/Poche.class.php6
2 files changed, 13 insertions, 10 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 02e8be8b..9e901974 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -512,22 +512,23 @@ class Database {
512 return $query; 512 return $query;
513 } 513 }
514 514
515 public function cleanUnusedTags() { 515 public function cleanUnusedTag($tag_id) {
516 $sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id"; 516 $sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?";
517 $query = $this->executeQuery($sql_action,array()); 517 $query = $this->executeQuery($sql_action,array($tag_id));
518 $tagstokeep = $query->fetchAll(); 518 $tagstokeep = $query->fetchAll();
519 $sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id"; 519 $sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?";
520 $query = $this->executeQuery($sql_action,array()); 520 $query = $this->executeQuery($sql_action,array($tag_id));
521 $alltags = $query->fetchAll(); 521 $alltags = $query->fetchAll();
522
522 foreach ($alltags as $tag) { 523 foreach ($alltags as $tag) {
523 if ($tag && !in_array($tag,$tagstokeep)) { 524 if ($tag && !in_array($tag,$tagstokeep)) {
524 //delete tag
525 $sql_action = "DELETE FROM tags WHERE id=?"; 525 $sql_action = "DELETE FROM tags WHERE id=?";
526 $params_action = array($tag[0]); 526 $params_action = array($tag[0]);
527 $query = $this->executeQuery($sql_action, $params_action); 527 $this->executeQuery($sql_action, $params_action);
528 return $query; 528 return true;
529 } 529 }
530 } 530 }
531
531 } 532 }
532 533
533 public function retrieveTagByValue($value) { 534 public function retrieveTagByValue($value) {
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 8ea5e7a2..515d4cac 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -559,6 +559,7 @@ class Poche
559 } 559 }
560 } 560 }
561 $this->messages->add('s', _('The tag has been applied successfully')); 561 $this->messages->add('s', _('The tag has been applied successfully'));
562 Tools::logm('The tag has been applied successfully');
562 Tools::redirect(); 563 Tools::redirect();
563 break; 564 break;
564 case 'remove_tag' : 565 case 'remove_tag' :
@@ -571,8 +572,9 @@ class Poche
571 } 572 }
572 $this->store->removeTagForEntry($id, $tag_id); 573 $this->store->removeTagForEntry($id, $tag_id);
573 Tools::logm('tag entry deleted'); 574 Tools::logm('tag entry deleted');
574 $this->store->cleanUnusedTags(); 575 if ($this->store->cleanUnusedTag($tag_id)) {
575 Tools::logm('old tags cleaned'); 576 Tools::logm('tag deleted');
577 }
576 $this->messages->add('s', _('The tag has been successfully deleted')); 578 $this->messages->add('s', _('The tag has been successfully deleted'));
577 Tools::redirect(); 579 Tools::redirect();
578 break; 580 break;