1: <?php
2: 3: 4: 5: 6: 7:
8: class Turba_View_EditContact
9: {
10: 11: 12: 13:
14: public $contact;
15:
16: 17: 18:
19: public function __construct(Turba_Object $contact)
20: {
21: $this->contact = $contact;
22: }
23:
24: public function getTitle()
25: {
26: return $this->contact
27: ? sprintf($this->contact->isGroup() ? _("Edit Group \"%s\"") : _("Edit \"%s\""), $this->contact->getValue('name'))
28: : _("Not Found");
29: }
30:
31: public function html($active = true)
32: {
33: global $conf, $prefs, $vars;
34:
35: if (!$this->contact) {
36: echo '<h3>' . _("The requested contact was not found.") . '</h3>';
37: return;
38: }
39:
40: if (!$this->contact->hasPermission(Horde_Perms::EDIT)) {
41: if (!$this->contact->hasPermission(Horde_Perms::READ)) {
42: echo '<h3>' . _("You do not have permission to view this contact.") . '</h3>';
43: return;
44: } else {
45: echo '<h3>' . _("You only have permission to view this contact.") . '</h3>';
46: return;
47: }
48: }
49:
50: echo '<div id="EditContact"' . ($active ? '' : ' style="display:none"') . '>';
51: $form = new Turba_Form_EditContact($vars, $this->contact);
52: $form->renderActive(new Horde_Form_Renderer, $vars, Horde::url('edit.php'), 'post');
53: echo '</div>';
54:
55: if ($active && $GLOBALS['browser']->hasFeature('dom')) {
56: if ($this->contact->hasPermission(Horde_Perms::READ)) {
57: $view = new Turba_View_Contact($this->contact);
58: $view->html(false);
59: }
60: if ($this->contact->hasPermission(Horde_Perms::DELETE)) {
61: $delete = new Turba_View_DeleteContact($this->contact);
62: $delete->html(false);
63: }
64: }
65: }
66:
67: }
68: