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 4382ceb commit b2357dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 13 additions & 11 deletions turba/lib/Driver.php
Expand Up @@ -997,12 +997,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 @@ -1045,16 +1046,17 @@ public function delete($object_id)
}

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

/* Might have tags disabled, hence no Content_* objects autoloadable. */
try {
/* Tell content we removed the object */
$GLOBALS['injector']->getInstance('Content_Objects_Manager')
->delete(array($object->getValue('__uid')), 'contact');
} catch (Horde_Exception $e) {}
if ($remove_tags) {
$GLOBALS['injector']->getInstance('Turba_Tagger')
->replaceTags($object->getValue('__uid'), array(), $this->getContactOwner(), 'contact');

/* Might have tags disabled, hence no Content_* objects autoloadable. */
try {
/* Tell content we removed the object */
$GLOBALS['injector']->getInstance('Content_Objects_Manager')
->delete(array($object->getValue('__uid')), 'contact');
} catch (Horde_Exception $e) {}
}
}

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

try {
$targetDriver->add($objAttributes);
Expand All @@ -239,7 +241,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 b2357dc

Please sign in to comment.