mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-23 17:42:15 -05:00
Simplifed function which does tag cleanup
This commit is contained in:
parent
4910af33ff
commit
24696800e5
@ -512,22 +512,23 @@ class Database {
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanUnusedTags() {
|
public function cleanUnusedTag($tag_id) {
|
||||||
$sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id";
|
$sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?";
|
||||||
$query = $this->executeQuery($sql_action,array());
|
$query = $this->executeQuery($sql_action,array($tag_id));
|
||||||
$tagstokeep = $query->fetchAll();
|
$tagstokeep = $query->fetchAll();
|
||||||
$sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id";
|
$sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?";
|
||||||
$query = $this->executeQuery($sql_action,array());
|
$query = $this->executeQuery($sql_action,array($tag_id));
|
||||||
$alltags = $query->fetchAll();
|
$alltags = $query->fetchAll();
|
||||||
|
|
||||||
foreach ($alltags as $tag) {
|
foreach ($alltags as $tag) {
|
||||||
if ($tag && !in_array($tag,$tagstokeep)) {
|
if ($tag && !in_array($tag,$tagstokeep)) {
|
||||||
//delete tag
|
|
||||||
$sql_action = "DELETE FROM tags WHERE id=?";
|
$sql_action = "DELETE FROM tags WHERE id=?";
|
||||||
$params_action = array($tag[0]);
|
$params_action = array($tag[0]);
|
||||||
$query = $this->executeQuery($sql_action, $params_action);
|
$this->executeQuery($sql_action, $params_action);
|
||||||
return $query;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function retrieveTagByValue($value) {
|
public function retrieveTagByValue($value) {
|
||||||
|
@ -559,6 +559,7 @@ class Poche
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->messages->add('s', _('The tag has been applied successfully'));
|
$this->messages->add('s', _('The tag has been applied successfully'));
|
||||||
|
Tools::logm('The tag has been applied successfully');
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
break;
|
break;
|
||||||
case 'remove_tag' :
|
case 'remove_tag' :
|
||||||
@ -571,8 +572,9 @@ class Poche
|
|||||||
}
|
}
|
||||||
$this->store->removeTagForEntry($id, $tag_id);
|
$this->store->removeTagForEntry($id, $tag_id);
|
||||||
Tools::logm('tag entry deleted');
|
Tools::logm('tag entry deleted');
|
||||||
$this->store->cleanUnusedTags();
|
if ($this->store->cleanUnusedTag($tag_id)) {
|
||||||
Tools::logm('old tags cleaned');
|
Tools::logm('tag deleted');
|
||||||
|
}
|
||||||
$this->messages->add('s', _('The tag has been successfully deleted'));
|
$this->messages->add('s', _('The tag has been successfully deleted'));
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user