Skip to content

Commit

Permalink
Bug: 14312 Persist tags when moving/copying contact.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Apr 2, 2016
1 parent b06cbcd commit 36d513b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions turba/lib/Driver.php
Expand Up @@ -1035,12 +1035,13 @@ protected function _canAdd()
/**
* Deletes the specified entry from the contact source.
*
* @param string $object_id The ID of the object to delete.
* @param string $object_id The ID of the object to delete.
* @param boolean $remove_tags Remove tags if true.
*
* @throws Turba_Exception
* @throws Horde_Exception_NotFound
*/
public function delete($object_id)
public function delete($object_id, $remove_tags = true)
{
$object = $this->getObject($object_id);

Expand Down Expand Up @@ -1083,12 +1084,14 @@ public function delete($object_id)
}

/* Remove tags */
$GLOBALS['injector']->getInstance('Turba_Tagger')
->replaceTags($object->getValue('__uid'), array(), $this->getContactOwner(), 'contact');
if ($remove_tags) {
$GLOBALS['injector']->getInstance('Turba_Tagger')
->replaceTags($object->getValue('__uid'), array(), $this->getContactOwner(), 'contact');

/* Tell content we removed the object */
$GLOBALS['injector']->getInstance('Content_Objects_Manager')
->delete(array($object->getValue('__uid')), 'contact');
/* Tell content we removed the object */
$GLOBALS['injector']->getInstance('Content_Objects_Manager')
->delete(array($object->getValue('__uid')), 'contact');
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion turba/lib/View/Browse.php
Expand Up @@ -209,6 +209,8 @@ public function run()
if ($actionID == 'copy') {
unset($objAttributes['__uid']);
}
// Try adding tags.
$objAttributes['__tags'] = $object->getValue('__tags');

try {
$targetDriver->add($objAttributes);
Expand All @@ -232,7 +234,7 @@ public function run()
// delete them from the original source now.
if ($actionID == 'move') {
try {
$sourceDriver->delete($objectKey);
$sourceDriver->delete($objectKey, false);
} catch (Turba_Exception $e) {
$notification->push(
sprintf(_("There was an error deleting \"%s\" from the source address book."),
Expand Down

0 comments on commit 36d513b

Please sign in to comment.