1: <?php
2: 3: 4: 5: 6: 7:
8: class Turba_View_Contact
9: {
10: 11: 12:
13: public $contact;
14:
15: 16: 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:
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:
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: