/**
* Returns the value of the specified attribute.
*
* @param string $attribute The attribute to retrieve.
*
* @return mixed The value of $attribute, an array (for photo type)
* or the empty string.
*/
public function getValue($attribute)
{
global $attributes, $injector;
if (isset($this->attributes[$attribute]) && ($hooks = $injector->getInstance('Horde_Core_Hooks')) && $hooks->hookExists('decode_attribute', 'turba')) {
try {
return $hooks->callHook('decode_attribute', 'turba', array($attribute, $this->attributes[$attribute], $this));
} catch (Turba_Exception $e) {
}
} elseif (isset($this->driver->map[$attribute]) && is_array($this->driver->map[$attribute])) {
$args = array();
foreach ($this->driver->map[$attribute]['fields'] as $field) {
$args[] = $this->getValue($field);
}
return Turba::formatCompositeField($this->driver->map[$attribute]['format'], $args);
} elseif (!isset($this->attributes[$attribute])) {
if (isset($attributes[$attribute]) && $attributes[$attribute]['type'] == 'Turba:TurbaTags' && ($uid = $this->getValue('__uid'))) {
$this->synchronizeTags($injector->getInstance('Turba_Tagger')->getTags($uid, 'contact'));
} else {
return null;
}
} elseif (isset($attributes[$attribute]) && $attributes[$attribute]['type'] == 'image') {
return empty($this->attributes[$attribute]) ? null : array('load' => array('data' => $this->attributes[$attribute], 'file' => basename(Horde::getTempFile('horde_form_', false, '', false, true))));
}
return $this->attributes[$attribute];
}