Overview

Packages

  • Horde
    • Data
  • None
  • Turba

Classes

  • Turba
  • Turba_Api
  • Turba_Driver
  • Turba_Driver_Facebook
  • Turba_Driver_Favourites
  • Turba_Driver_Group
  • Turba_Driver_Imsp
  • Turba_Driver_Kolab
  • Turba_Driver_Ldap
  • Turba_Driver_Prefs
  • Turba_Driver_Share
  • Turba_Driver_Sql
  • Turba_Driver_Vbook
  • Turba_Exception
  • Turba_Factory_Driver
  • Turba_Form_AddContact
  • Turba_Form_Contact
  • Turba_Form_ContactBase
  • Turba_Form_CreateAddressBook
  • Turba_Form_DeleteAddressBook
  • Turba_Form_EditAddressBook
  • Turba_Form_EditContact
  • Turba_Form_EditContactGroup
  • Turba_List
  • Turba_LoginTasks_SystemTask_Upgrade
  • Turba_Object
  • Turba_Object_Group
  • Turba_Test
  • Turba_View_Browse
  • Turba_View_Contact
  • Turba_View_DeleteContact
  • Turba_View_Duplicates
  • Turba_View_EditContact
  • Turba_View_List
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Turba_View_Contact:: class provides an API for viewing events.
 4:  *
 5:  * @author  Chuck Hagenbuch <chuck@horde.org>
 6:  * @package Turba
 7:  */
 8: class Turba_View_Contact
 9: {
10:     /**
11:      * @var Turba_Object
12:      */
13:     public $contact;
14: 
15:     /**
16:      * @param Turba_Object &$contact
17:      */
18:     public function __construct(Turba_Object $contact)
19:     {
20:         $this->contact = $contact;
21:     }
22: 
23:     public function getTitle()
24:     {
25:         if (!$this->contact) {
26:             return _("Not Found");
27:         }
28:         return $this->contact->getValue('name');
29:     }
30: 
31:     public function html($active = true)
32:     {
33:         global $conf, $prefs, $registry;
34: 
35:         if (!$this->contact ||
36:             !$this->contact->hasPermission(Horde_Perms::READ)) {
37:             echo '<h3>' . _("The requested contact was not found.") . '</h3>';
38:             return;
39:         }
40: 
41:         $vars = new Horde_Variables();
42:         $form = new Turba_Form_Contact($vars, $this->contact);
43: 
44:         /* Get the contact's history. */
45:         $history = $this->contact->getHistory();
46:         foreach ($history as $what => $when) {
47:             $v = $form->addVariable(
48:                 $what == 'created' ? _("Created") : _("Last Modified"),
49:                 'object[__' . $what . ']',
50:                 'text',
51:                 false,
52:                 false);
53:             $v->disable();
54:             $vars->set('object[__' . $what . ']', $when);
55:         }
56: 
57:         echo '<div id="Contact"' . ($active ? '' : ' style="display:none"') . '>';
58:         $form->renderInactive(new Horde_Form_Renderer(), $vars);
59: 
60:         /* Comments. */
61:         if (!empty($conf['comments']['allow']) && $registry->hasMethod('forums/doComments')) {
62:             try {
63:                 $comments = $registry->call('forums/doComments', array('turba', $this->contact->driver->getName() . '.' . $this->contact->getValue('__key'), 'commentCallback'));
64:             } catch (Horde_Exception $e) {
65:                 Horde::logMessage($e, 'DEBUG');
66:                 $comments = array();
67:             }
68:         }
69:         if (!empty($comments['threads'])) {
70:             echo '<br />' . $comments['threads'];
71:         }
72:         if (!empty($comments['comments'])) {
73:             echo '<br />' . $comments['comments'];
74:         }
75: 
76:         echo '</div>';
77: 
78:         if ($active && $GLOBALS['browser']->hasFeature('dom')) {
79:             if ($this->contact->hasPermission(Horde_Perms::EDIT)) {
80:                 $edit = new Turba_View_EditContact($this->contact);
81:                 $edit->html(false);
82:             }
83:             if ($this->contact->hasPermission(Horde_Perms::DELETE)) {
84:                 $delete = new Turba_View_DeleteContact($this->contact);
85:                 $delete->html(false);
86:             }
87:         }
88:     }
89: 
90: }
91: 
API documentation generated by ApiGen