* @package Turba */ class Turba_View_Contact { /** * @var Turba_Object */ public $contact; /** * @param Turba_Object &$contact */ public function __construct(Turba_Object $contact) { $this->contact = $contact; } public function getTitle() { if (!$this->contact) { return _("Not Found"); } return $this->contact->getValue('name'); } public function html($active = true) { global $browser, $conf, $registry; if (!$this->contact || !$this->contact->hasPermission(Horde_Perms::READ)) { echo '

' . _("The requested contact was not found.") . '

'; return; } $vars = new Horde_Variables(); $form = new Turba_Form_Contact($vars, $this->contact); $form->setOpenSection(Horde_Util::getFormData('section', 0)); /* Get the contact's history. */ $history = $this->contact->getHistory(); foreach ($history as $what => $when) { $v = $form->addVariable( $what == 'created' ? _("Created") : _("Last Modified"), 'object[__' . $what . ']', 'text', false, false); $v->disable(); $vars->set('object[__' . $what . ']', $when); } echo ''; if ($active && $browser->hasFeature('dom')) { if ($this->contact->hasPermission(Horde_Perms::EDIT)) { $edit = new Turba_View_EditContact($this->contact); $edit->html(false); } if ($this->contact->hasPermission(Horde_Perms::DELETE)) { $delete = new Turba_View_DeleteContact($this->contact); $delete->html(false); } } } }