1: <?php
2: /**
3: * The Ingo_Script_Sieve_Action_Redirect class represents a redirect action.
4: *
5: * See the enclosed file LICENSE for license information (ASL). If you
6: * did not receive this file, see http://www.horde.org/licenses/apache.
7: *
8: * @author Mike Cochrane <mike@graftonhall.co.nz>
9: * @package Ingo
10: */
11: class Ingo_Script_Sieve_Action_Redirect extends Ingo_Script_Sieve_Action
12: {
13: /**
14: * Constructor.
15: *
16: * @param array $vars Any required parameters.
17: */
18: public function __construct($vars = array())
19: {
20: $this->_vars['address'] = isset($vars['address'])
21: ? $vars['address']
22: : '';
23: }
24:
25: /**
26: */
27: public function toCode($depth = 0)
28: {
29: return str_repeat(' ', $depth * 4) . 'redirect ' .
30: '"' . Ingo_Script_Sieve::escapeString($this->_vars['address']) . '";';
31: }
32:
33: /**
34: * Checks if the rule parameters are valid.
35: *
36: * @return boolean|string True if this rule is valid, an error message
37: * otherwise.
38: */
39: public function check()
40: {
41: return empty($this->_vars['address'])
42: ? _("Missing address to redirect message to")
43: : true;
44: }
45:
46: }
47: