public function add(array $attributes)
{
/* Only set __type and __owner if they are not already set. */
if (!isset($attributes['__type'])) {
$attributes['__type'] = 'Object';
}
if (isset($this->map['__owner']) && !isset($attributes['__owner'])) {
$attributes['__owner'] = $this->getContactOwner();
}
if (!isset($attributes['__uid'])) {
$attributes['__uid'] = $this->_makeUid();
}
$key = $attributes['__key'] = $this->_makeKey($this->toDriverKeys($attributes));
$uid = $attributes['__uid'];
/* Remember any tags, since toDriverKeys will remove them.
(They are not stored in the Turba backend so have no mapping). */
$tags = isset($attributes['__tags']) ? $attributes['__tags'] : false;
$attributes = $this->toDriverKeys($attributes);
$this->_add($attributes, $this->toDriverKeys($this->getBlobs()), $this->toDriverKeys($this->getDateFields()));
/* Add tags. */
if ($tags !== false) {
$GLOBALS['injector']->getInstance('Turba_Tagger')->tag($uid, $tags, $GLOBALS['registry']->getAuth(), 'contact');
}
/* Log the creation of this item in the history log. */
try {
$GLOBALS['injector']->getInstance('Horde_History')->log('turba:' . $this->getName() . ':' . $uid, array('action' => 'add'), true);
} catch (Exception $e) {
Horde::log($e, 'ERR');
}
return $key;
}