-
Notifications
You must be signed in to change notification settings - Fork 7
/
Forward.php
121 lines (105 loc) · 4.02 KB
/
Forward.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @category Horde
* @copyright 2003-2017 Horde LLC
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
/**
* Forward page.
*
* @author Todd Merritt <tmerritt@email.arizona.edu>
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2003-2017 Horde LLC
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
class Ingo_Basic_Forward extends Ingo_Basic_Base
{
/**
*/
protected function _init()
{
global $injector, $notification;
/* Redirect if forward is not available. */
$this->_assertCategory('Ingo_Rule_System_Forward', _("Forward"));
if ($this->vars->submitbutton == _("Return to Rules List")) {
Ingo_Basic_Filters::url()->redirect();
}
/* Get the forward object and rule. */
$ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
$forward = $ingo_storage->getSystemRule('Ingo_Rule_System_Forward');
/* Build form. */
$form = new Ingo_Form_Forward($this->vars);
/* Perform requested actions. Ingo_Form_Forward does token checking
* for us. */
if ($form->validate($this->vars)) {
$forward->addresses = $this->vars->addresses;
$forward->keep = ($this->vars->keep_copy == 'on');
try {
try {
$forward->addressList = $injector->getInstance('Horde_Core_Hooks')
->callHook('verify_forward_addresses', 'ingo', array($forward->addressList));
$this->vars->addresses = implode("\n", $forward->addresses);
} catch (Horde_Exception_HookNotSet $e) {
}
if ($this->vars->submitbutton == _("Save and Enable")) {
$forward->disable = true;
$notify = _("Rule Enabled");
} elseif ($this->vars->submitbutton == _("Save and Disable")) {
$forward->disable = false;
$notify = _("Rule Disabled");
} else {
$notify = _("Changes saved.");
}
$ingo_storage->updateRule($forward);
$notification->push($notify, 'horde.success');
$injector->getInstance('Ingo_Factory_Script')->activateAll();
} catch (Ingo_Exception $e) {
$notification->push($e);
}
}
/* Add buttons depending on the above actions. */
$form->setCustomButtons($forward->disable);
/* Set default values. */
if (!$form->isSubmitted()) {
$this->vars->keep_copy = $forward->keep;
$this->vars->addresses = implode("\n", $forward->addresses);
}
/* Set form title. */
$form_title = _("Forward");
if ($forward->disable) {
$form_title .= ' [<span class="horde-form-error">' . _("Disabled") . '</span>]';
}
$form_title .= ' ' . Horde_Help::link('ingo', 'forward');
$form->setTitle($form_title);
$this->header = _("Forwards Edit");
Horde::startBuffer();
Horde_Util::pformInput();
$form->renderActive(
new Horde_Form_Renderer(array(
'encode_title' => false,
'varrenderer_driver' => array('ingo', 'ingo')
)),
$this->vars,
self::url(array('append_session' => -1)),
'post'
);
$this->output = Horde::endBuffer();
}
/**
*/
public static function url(array $opts = array())
{
if (empty($opts['append_session'])) {
$opts['append_session'] = 0;
}
return Horde::url('basic.php', true, array('append_session' => $opts['append_session']))->add('page', 'forward');
}
}