gunnar: server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve/Segment Forward.php, NONE, 1.1
cvs at kolab.org
cvs at kolab.org
Thu Apr 1 17:10:36 CEST 2010
Author: gunnar
Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve/Segment
In directory doto:/tmp/cvs-serv19058/kolab-webadmin/lib/KolabAdmin/Sieve/Segment
Added Files:
Forward.php
Log Message:
Add the handler for the forward sieve segment.
--- NEW FILE: Forward.php ---
<?php
/**
* A sieve script that handles mail forwarding to a specific address.
*
* PHP version 5
*
* @category Kolab
* @package KolabAdmin
* @author Gunnar Wrobel <wrobel at pardus.de>
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://www.kolab.org
*/
/**
* A sieve script that handles mail forwarding to a specific address.
*
* Copyright 2010 Klarälvdalens Datakonsult AB
*
* See the enclosed file COPYING for license information (LGPL). If you did not
* receive this file, see
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
*
* @category Kolab
* @package KolabAdmin
* @author Gunnar Wrobel <wrobel at pardus.de>
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://www.kolab.org
*/
class KolabAdmin_Sieve_Segment_Forward
extends KolabAdmin_Sieve_Segment
{
/**
* The segment type.
*
* @var string
*/
protected $type = 'forward';
/**
* The forwarding address.
*
* @var string
*/
private $_forward_address = '';
/**
* Should mails be kept on the server after forwarding?
*
* @var string
*/
private $_keep_on_server = true;
/**
* Constructor.
*
* @param string $script The current script segment
*/
public function __construct($script = '')
{
$this->template = 'if allof (%s)' . "\r\n" .
'redirect "%s";%s' . "\r\n";
parent::__construct($script);
}
/**
* Retrieve the forwarding address this script will deliver to.
*
* @return string The forwarding address.
*/
public function getForwardAddress()
{
return $this->_forward_address;
}
/**
* Set the forwarding address this script will deliver to.
*
* @param string $folder The forward address.
*
* @return NULL
*/
public function setForwardAddress($address)
{
$this->_forward_address = $address;
}
/**
* Should the messages be kept on the server after forwarding?
*
* @return bool True if the messages should be kept.
*/
public function getKeepOnServer()
{
return $this->_keep_on_server;
}
/**
* Set if the messages should be kept on the server after forwarding.
*
* @param boolean $keep True if the messages should be kept.
*
* @return NULL
*/
public function setKeepOnServer($keep)
{
$this->_keep_on_server = $keep;
}
public function getArguments()
{
$address = $this->getForwardAddress();
if (empty($address)) {
throw new Exception('Please enter a valid e-mail address!');
}
return array(
($this->isActive()) ? 'true, ## forward enabled' : 'false, ## forward disabled',
$address,
($this->getKeepOnServer()) ? ' keep;' : ''
);
}
public function parseArguments($script)
{
$this->parseForwardAddress($script);
$this->parseKeepOnServer($script);
}
public function parseForwardAddress($script)
{
if (preg_match("/redirect \"([^\"]*)\"/s", $script, $regs)) {
$this->_forward_address = $regs[1];
}
}
public function parseKeepOnServer($script)
{
if (preg_match('/redirect "[^\"]*"; keep;/s', $script, $regs)) {
$this->_keep_on_server = true;
} else {
$this->_keep_on_server = false;
}
}
}
More information about the commits
mailing list