From 1b3e4edde4397772bfc1ca0f6db63c0de48ee109 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Wed, 16 Sep 2015 11:21:31 -0400 Subject: [PATCH] Bug: 14112 Remove tags when deleting objects. --- mnemo/lib/Driver.php | 7 +++++++ nag/lib/Driver.php | 9 ++++++++- turba/lib/Driver.php | 10 +++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mnemo/lib/Driver.php b/mnemo/lib/Driver.php index 38dce3b57f2..e798f1b3f8f 100644 --- a/mnemo/lib/Driver.php +++ b/mnemo/lib/Driver.php @@ -261,7 +261,12 @@ public function delete($noteId) array('action' => 'delete'), true); } catch (Horde_Exception $e) { } + + // Remove tags + $GLOBALS['injector']->getInstance('Mnemo_Tagger') + ->replaceTags($uid, array(), $GLOBALS['registry']->getAuth(), 'note') } + } /** @@ -291,6 +296,8 @@ public function deleteAll() 'mnemo:' . $this->_notepad . ':' . $uid, array('action' => 'delete'), true); + $injector->getInstance('Mnemo_Tagger') + ->replaceTags($uid, array(), $GLOBALS['registry']->getAuth(), 'note'); } } catch (Horde_Exception $e) { } diff --git a/nag/lib/Driver.php b/nag/lib/Driver.php index 78d3317f657..7a5500e0d35 100644 --- a/nag/lib/Driver.php +++ b/nag/lib/Driver.php @@ -400,6 +400,10 @@ public function delete($taskId) $task = $this->get($taskId); $delete = $this->_delete($taskId); + /* Remove tags */ + $task->tags = array(); + $this->_updateTags($task); + /* Log the deletion of this item in the history log. */ if (!empty($task->uid)) { try { @@ -444,7 +448,7 @@ public function deleteAll() { $ids = $this->_deleteAll(); - // Update History. + // Update History and Tagger $history = $GLOBALS['injector']->getInstance('Horde_History'); try { foreach ($ids as $id) { @@ -452,6 +456,9 @@ public function deleteAll() 'nag:' . $this->_tasklist . ':' . $id, array('action' => 'delete'), true); + + $GLOBALS['injector']->getInstance('Nag_Tagger') + ->replaceTags($id, array(), $GLOBALS['registry']->getAuth(), 'task'); } } catch (Exception $e) { Horde::log($e, 'ERR'); diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index ee0700b137b..320c170930a 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -1065,6 +1065,10 @@ public function delete($object_id) } } catch (Horde_Exception $e) { } + + /* Remove tags */ + $GLOBALS['injector']->getInstance('Turba_Tagger') + ->replaceTags($object->getValue('__uid'), array(), $this->getContactOwner(), 'contact'); } /** @@ -1085,7 +1089,7 @@ public function deleteAll($sourceName = null) $ids = $this->_deleteAll($sourceName); - // Update Horde_History + // Update Horde_History and Tagger $history = $GLOBALS['injector']->getInstance('Horde_History'); try { foreach ($ids as $id) { @@ -1095,6 +1099,10 @@ public function deleteAll($sourceName = null) // Turba_Object#getGuid $guid = 'turba:' . $this->getName() . ':' . $id; $history->log($guid, array('action' => 'delete'), true); + + // Remove tags. + $GLOBALS['injector']->getInstance('Turba_Tagger') + ->replaceTags($id, array(), $this->getContactOwner(), 'contact'); } } catch (Exception $e) { Horde::log($e, 'ERR');