summaryrefslogtreecommitdiff
path: root/lib/KolabAdmin
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-03-31 20:21:37 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-03-31 20:21:37 (GMT)
commit8cd08ffc789dd67d940fab2d9e422776877cc985 (patch)
tree3fbc769cbf2c89122230e6dfec6f0f790d5cb3bf /lib/KolabAdmin
parent3d422c58f3a48c2b0e01b193ada93abf0d00cd5e (diff)
downloadkolab-webadmin-8cd08ffc789dd67d940fab2d9e422776877cc985.tar.gz
Import the sieve utility segment from the patch in kolab/issue1446 (Webinterface for setting vacation, email-delivery and forwarding (rt#5033)). Writing/reparsing does not yet work and the script generation may produce broken sieve scripts. We do not yet use this in the front end though and this way we don't throw away information from the patch.
Diffstat (limited to 'lib/KolabAdmin')
-rw-r--r--lib/KolabAdmin/Sieve/Script.php54
1 files changed, 51 insertions, 3 deletions
diff --git a/lib/KolabAdmin/Sieve/Script.php b/lib/KolabAdmin/Sieve/Script.php
index b1d06d9..03e177c 100644
--- a/lib/KolabAdmin/Sieve/Script.php
+++ b/lib/KolabAdmin/Sieve/Script.php
@@ -92,10 +92,58 @@ class KolabAdmin_Sieve_Script {
}
/*static*/ function getKeepOnServer( $script ) {
- return ereg('"; keep;', $script, $regs );
+ return ereg('"; keep;', $script, $regs ) > 0;
}
- function createScript( $scriptname ) {
- // TODO
+ /*static*/ function getScriptInfo($script) {
+ return array('maildomain' => KolabAdmin_Sieve_Script::getMailDomain($script),
+ 'vacationaddresses' => KolabAdmin_Sieve_Script::getVacationAddresses($script),
+ 'days' => KolabAdmin_Sieve_Script::getVacationDays($script),
+ 'reacttospam' => KolabAdmin_Sieve_Script::getReactToSpam($script),
+ 'vacationtext' => KolabAdmin_Sieve_Script::getVacationText($script),
+ 'vacationenabled' => KolabAdmin_Sieve_Script::isVacationEnabled($script),
+ 'deliveryfolder' => KolabAdmin_Sieve_Script::getDeliverFolder($script),
+ 'deliveryenabled' => KolabAdmin_Sieve_Script::isDeliveryEnabled($script));
+ }
+
+ /*static*/ function isDeliveryEnabled($script) {
+ return ereg('## delivery enabled', $script, $regs )>0;
+ }
+
+ /*static*/ function isVacationEnabled($script) {
+ return ereg('## vacation enabled', $script, $regs )>0;
+ }
+
+ /*static*/ function createScript($scriptinfo) {
+ $tests = array();
+ if( $scriptinfo['vacationenabled'] ) {
+ $tests[] = "## vacation enabled\r\ntrue";
+ } else {
+ $tests[] = "## vacation disabled\r\nnot true";
+ }
+
+ if(!empty($scriptinfo['maildomain'])) {
+ $tests[] = "address :domain :contains \"From\" \"".$scriptinfo['maildomain']."\"";
+ }
+ if($scriptinfo['reacttospam']) {
+ $tests[] = "not header :contains \"X-Spam-Flag\" \"YES\"";
+ }
+ $script =
+ "require \"vacation\";\r\n\r\n".
+ "require \"fileinto\";\r\n\r\n".
+ "if allof (".join(",\r\n",$tests).") {\r\n".
+ " vacation :addresses [ \"".join('", "', $scriptinfo['vacationaddresses'] )."\" ] :days ".
+ $scriptinfo['days']." text:\r\n".
+ KolabAdmin_Sieve_Script::dotstuff(trim($scriptinfo['vacationtext']))."\r\n.\r\n;\r\n}\r\n";
+ if($scriptinfo['deliveryfolder']) {
+ if($scriptinfo['deliveryenabled']) {
+ $script .= "if allof (true, ## delivery enabled\r\n";
+ } else {
+ $script .= "if allof (not true, ## delivery disabled\r\n";
+ }
+ $script .= "header :contains [\"X-Kolab-Scheduling-Message\"] [\"FALSE\"]) {\r\nfileinto \"INBOX/".
+ $scriptinfo['deliveryfolder']."\";\r\n}\r\n";
+ }
+ return $script;
}
};