Skip to content

Commit

Permalink
Fix setting tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Mar 6, 2014
1 parent fd84f44 commit 464f147
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions turba/lib/Driver/Kolab.php
Expand Up @@ -101,6 +101,16 @@ public function __construct($name = '', $params = array())
*/
public function toDriverKeys(array $hash)
{
if (isset($hash['__tags'])) {
if (!is_array($hash['__tags'])) {
$hash['__tags'] = $GLOBALS['injector']
->getInstance('Turba_Tagger')
->split($hash['__tags']);
}
usort($hash['__tags'], 'strcoll');
$hash['__internaltags'] = serialize($hash['__tags']);
}

$hash = parent::toDriverKeys($hash);

if (isset($hash['name'])) {
Expand Down Expand Up @@ -193,7 +203,7 @@ public function toDriverKeys(array $hash)
}

if (isset($hash['categories'])) {
$hash['categories'] = array($hash['categories']);
$hash['categories'] = unserialize($hash['categories']);
}

if (!empty($hash['birthday'])) {
Expand Down Expand Up @@ -311,6 +321,10 @@ public function connect()
$contact['__type'] = 'Object';
$contact['__key'] = Horde_Url::uriB64Encode($id);

if (isset($contact['categories'])) {
$contact['categories'] = serialize($contact['categories']);
}

if (isset($contact['picture'])) {
$name = $contact['picture'];
$contact['photo'] = new Horde_Stream_Existing(array(
Expand Down Expand Up @@ -384,6 +398,9 @@ public function connect()
$group = $group->getData();
$group['__type'] = 'Group';
$group['__key'] = Horde_Url::uriB64Encode($id);
if (isset($group['categories'])) {
$group['categories'] = serialize($group['categories']);
}
$groups[Horde_Url::uriB64Encode($id)] = $group;
}
}
Expand Down Expand Up @@ -622,10 +639,6 @@ protected function _read($key, $ids, $owner, array $fields,
}
$object = $this->_contacts_cache[$id];

if (isset($object['categories'])) {
$object['categories'] = serialize($object['categories']);
}

if (!isset($object['__type']) || $object['__type'] == 'Object') {
if ($count) {
$result = array();
Expand Down Expand Up @@ -827,15 +840,6 @@ protected function _store($attributes, $object_id = null)
$data = $this->_getData();
}

if (isset($attributes['__tags'])) {
if (!is_array($attributes['__tags'])) {
$attributes['categories'] = $GLOBALS['injector']->getInstance('Nag_Tagger')->split($attributes['__tags']);
} else {
$attributes['categories'] = $attributes['__tags'];
}
usort($attributes['categories'], 'strcoll');
}

if ($object_id === null) {
$object_id = $data->create($attributes);
} else {
Expand Down

0 comments on commit 464f147

Please sign in to comment.