1: <?php
2: 3: 4:
5: class Turba_Form_EditContactGroup extends Turba_Form_EditContact
6: {
7: public function __construct($vars, $contact)
8: {
9: $this->addHidden('', 'objectkeys', 'text', false);
10: $this->addHidden('', 'original_source', 'text', false);
11: $action = $this->addHidden('', 'actionID', 'text', false);
12: $action->setDefault('groupedit');
13: parent::__construct($vars, $contact);
14: $vars->set('actionID', 'groupedit');
15:
16: $objectkeys = $vars->get('objectkeys');
17: $source = $vars->get('source');
18: $key = $vars->get('key');
19:
20: if (count($objectkeys) == 1) {
21:
22: $this->setButtons(_("Finish"));
23: } elseif ($source . ':' . $key == $objectkeys[0]) {
24:
25: $this->setButtons(_("Next"));
26: $this->appendButtons(_("Finish"));
27: } elseif ($source . ':' . $key == $objectkeys[count($objectkeys) - 1]) {
28:
29: $this->setButtons(_("Previous"));
30: $this->appendButtons(_("Finish"));
31: } else {
32:
33: $this->setButtons(_("Previous"));
34: $this->appendButtons(_("Next"));
35: $this->appendButtons(_("Finish"));
36: }
37: }
38:
39: public function renderActive($renderer, $vars, $action, $method)
40: {
41: parent::renderActive($renderer, $vars, $action, $method);
42:
43: $results = new Turba_List($vars->get('objectkeys'));
44:
45:
46: if (count($results) > 1) {
47:
48: $source = $vars->get('source');
49: $sources = Turba::getColumns();
50:
51: $listView = new Turba_View_List(
52: $results,
53: array(
54: 'Group' => true
55: ),
56: isset($sources[$source]) ? $sources[$source] : array()
57: );
58: echo '<br />' . $listView->getPage($numDisplayed);
59: }
60: }
61:
62: public function execute()
63: {
64: $result = parent::execute();
65:
66: $this->getInfo($this->_vars, $info);
67:
68: $next_page = Horde::url('edit.php', true)->add(array(
69: 'source' => $info['source'],
70: 'original_source' => $info['original_source'],
71: 'objectkeys' => $info['objectkeys'],
72: 'url' => $info['url'],
73: 'actionID' => 'groupedit'
74: ));
75:
76: $objectkey = array_search($info['source'] . ':' . $info['key'], $info['objectkeys']);
77:
78: $submitbutton = $this->_vars->get('submitbutton');
79: if ($submitbutton == _("Finish")) {
80: $next_page = Horde::url('browse.php', true);
81: if ($info['original_source'] == '**search') {
82: $next_page->add('key', $info['original_source']);
83: } else {
84: $next_page->add('source', $info['original_source']);
85: }
86: } elseif ($submitbutton == _("Previous") && $info['source'] . ':' . $info['key'] != $info['objectkeys'][0]) {
87:
88: list(, $previous_key) = explode(':', $info['objectkeys'][$objectkey - 1]);
89: $next_page->add('key', $previous_key);
90: if ($this->getOpenSection()) {
91: $next_page->add('__formOpenSection', $this->getOpenSection());
92: }
93: } elseif ($submitbutton == _("Next") &&
94: $info['source'] . ':' . $info['key'] != $info['objectkeys'][count($info['objectkeys']) - 1]) {
95:
96: list(, $next_key) = explode(':', $info['objectkeys'][$objectkey + 1]);
97: $next_page->add('key', $next_key);
98: if ($this->getOpenSection()) {
99: $next_page->add('__formOpenSection', $this->getOpenSection());
100: }
101: }
102:
103: $next_page->redirect();
104: }
105:
106: }
107: