public function html($active = true) { global $browser, $conf, $registry; if (!$this->contact || !$this->contact->hasPermission(Horde_Perms::READ)) { echo '<h3>' . _("The requested contact was not found.") . '</h3>'; 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 '<div id="Contact"' . ($active ? '' : ' style="display:none"') . '>'; $form->renderInactive($form->getRenderer(), $vars); /* Comments. */ if (!empty($conf['comments']['allow']) && $registry->hasMethod('forums/doComments')) { try { $comments = $registry->call('forums/doComments', array('turba', $this->contact->driver->getName() . '.' . $this->contact->getValue('__key'), 'commentCallback')); } catch (Horde_Exception $e) { Horde::log($e, 'DEBUG'); $comments = array(); } } if (!empty($comments['threads'])) { echo '<br />' . $comments['threads']; } if (!empty($comments['comments'])) { echo '<br />' . $comments['comments']; } echo '</div>'; 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); } } }
/** * Renders this view. */ public function display() { $view = new Horde_View(array('templatePath' => TURBA_TEMPLATES . '/search/duplicate')); new Horde_View_Helper_Text($view); $hasDuplicate = $this->_type && $this->_duplicate && isset($this->_duplicates[$this->_type]) && isset($this->_duplicates[$this->_type][$this->_duplicate]); if ($hasDuplicate) { $vars = new Horde_Variables(); $view->type = $GLOBALS['attributes'][$this->_type]['label']; $view->value = $this->_duplicate; echo $view->render('header'); $view->contactUrl = Horde::url('contact.php'); $view->mergeUrl = Horde::url('merge.php'); $view->first = true; $duplicate = $this->_duplicates[$this->_type][$this->_duplicate]; while ($contact = $duplicate->next()) { $contact->lastModification(); } $duplicate->sort(array(array('field' => '__modified', 'ascending' => false))); $view->mergeTarget = $duplicate->reset()->getValue('__key'); while ($contact = $duplicate->next()) { $view->source = $contact->getSource(); $view->id = $contact->getValue('__key'); $history = $contact->getHistory(); if (isset($history['modified'])) { $view->changed = $history['modified']; } elseif (isset($history['created'])) { $view->changed = $history['created']; } else { unset($view->changed); } echo $view->render('contact_header'); $contactView = new Turba_Form_Contact($vars, $contact, false); $contactView->renderInactive($contactView->getRenderer(), $vars); echo $view->render('contact_footer'); $view->first = false; } echo $view->render('footer'); } $view->duplicates = $this->_duplicates; $view->hasDuplicate = (bool) $hasDuplicate; $view->attributes = $GLOBALS['attributes']; $view->link = Horde::url('search.php')->add(array('source' => $this->_driver->getName(), 'search_mode' => 'duplicate')); echo $view->render('list'); }