summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-04-06 08:57:24 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-04-06 08:57:24 (GMT)
commitb60f4c9b81ed100729c26ec391be3db3b0fe8afe (patch)
treebcf4303cfcf4f1a008b774324b22c49233077dfe
parent9dd0682b030653b6f848f56104e458a50b3050be (diff)
downloadkolab-webadmin-b60f4c9b81ed100729c26ec391be3db3b0fe8afe.tar.gz
PHP5.3 strict, WS
-rw-r--r--lib/KolabAdmin/Sieve/Script.php219
1 files changed, 110 insertions, 109 deletions
diff --git a/lib/KolabAdmin/Sieve/Script.php b/lib/KolabAdmin/Sieve/Script.php
index 98e609b..fc8d4fc 100644
--- a/lib/KolabAdmin/Sieve/Script.php
+++ b/lib/KolabAdmin/Sieve/Script.php
@@ -19,131 +19,132 @@
*/
class KolabAdmin_Sieve_Script {
- // Funny multiline string escaping in Sieve
- /*static*/ function dotstuff( $str ) {
- return str_replace( "\n.", "\n..", $str );
- }
+
+ // Funny multiline string escaping in Sieve
+ static function dotstuff( $str ) {
+ return str_replace( "\n.", "\n..", $str );
+ }
- /*static*/ function undotstuff( $str ) {
- return str_replace( "\n..", "\n.", $str );
- }
+ static function undotstuff( $str ) {
+ return str_replace( "\n..", "\n.", $str );
+ }
- /*static*/ function getDeliverFolder( $script ) {
- $inbox = false;
- if( preg_match("/fileinto \"INBOX\/([^\"]*)\";/", $script, $regs ) ) {
- $inbox = $regs[1];
- }
- return $inbox;
- }
+ static function getDeliverFolder( $script ) {
+ $inbox = false;
+ if( preg_match("/fileinto \"INBOX\/([^\"]*)\";/", $script, $regs ) ) {
+ $inbox = $regs[1];
+ }
+ return $inbox;
+ }
- /*static*/ function getVacationAddresses( $script ) {
- $addresses = false;
- if( preg_match("/:addresses \\[([^\\]]*)\\]/s", $script, $regs ) ) {
- $tmp = split(',', $regs[1] );
- $addresses = array();
- foreach( $tmp as $a ) {
- if( ereg('^ *"(.*)" *$', $a, $regs ) ) $addresses[] = $regs[1];
- else $addresses[] = $a;
- }
+ static function getVacationAddresses( $script ) {
+ $addresses = false;
+ if( preg_match("/:addresses \\[([^\\]]*)\\]/s", $script, $regs ) ) {
+ $tmp = split(',', $regs[1] );
+ $addresses = array();
+ foreach( $tmp as $a ) {
+ if( ereg('^ *"(.*)" *$', $a, $regs ) ) $addresses[] = $regs[1];
+ else $addresses[] = $a;
+ }
+ }
+ return $addresses;
}
- return $addresses;
- }
- /*static*/ function getMailDomain( $script ) {
- $maildomain = false;
- if( preg_match( '/address :domain :contains "From" "(.*)"/i', $script, $regs ) ) {
- $maildomain = $regs[1];
- }
- return $maildomain;
- }
+ static function getMailDomain( $script ) {
+ $maildomain = false;
+ if( preg_match( '/address :domain :contains "From" "(.*)"/i', $script, $regs ) ) {
+ $maildomain = $regs[1];
+ }
+ return $maildomain;
+ }
- /*static*/ function getReactToSpam( $script ) {
- $spam = false;
- if( preg_match('/header :contains "X-Spam-Flag" "YES"/i', $script ) ) {
- $spam = true;
- }
- return $spam;
- }
+ static function getReactToSpam( $script ) {
+ $spam = false;
+ if( preg_match('/header :contains "X-Spam-Flag" "YES"/i', $script ) ) {
+ $spam = true;
+ }
+ return $spam;
+ }
- /*static*/ function getVacationDays( $script ) {
- $days = false;
- if( preg_match("/:days ([0-9]+)/s", $script, $regs ) ) {
- $days = $regs[1];
+ static function getVacationDays( $script ) {
+ $days = false;
+ if( preg_match("/:days ([0-9]+)/s", $script, $regs ) ) {
+ $days = $regs[1];
+ }
+ return $days;
}
- return $days;
- }
- /*static*/ function getVacationText( $script ) {
- $text = false;
- if( preg_match("/text:(.*\r\n)\\.\r\n/s", $script, $regs ) ) {
- $text = $regs[1];
- $text = str_replace( '\n', "\r\n", $text );
- $text = KolabAdmin_Sieve_Script::undotstuff($text);
+ static function getVacationText( $script ) {
+ $text = false;
+ if( preg_match("/text:(.*\r\n)\\.\r\n/s", $script, $regs ) ) {
+ $text = $regs[1];
+ $text = str_replace( '\n', "\r\n", $text );
+ $text = KolabAdmin_Sieve_Script::undotstuff($text);
+ }
+ return $text;
}
- return $text;
- }
- /*static*/ function getForwardAddress( $script ) {
- $address = false;
- if( preg_match("/redirect \"([^\"]*)\"/s", $script, $regs ) ) {
- $address = $regs[1];
+ static function getForwardAddress( $script ) {
+ $address = false;
+ if( preg_match("/redirect \"([^\"]*)\"/s", $script, $regs ) ) {
+ $address = $regs[1];
+ }
+ return $address;
}
- return $address;
- }
- /*static*/ function getKeepOnServer( $script ) {
- return ereg('"; keep;', $script, $regs ) > 0;
- }
+ static function getKeepOnServer( $script ) {
+ return ereg('"; keep;', $script, $regs ) > 0;
+ }
- /*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 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 isDeliveryEnabled($script) {
+ return ereg('## delivery enabled', $script, $regs )>0;
+ }
- /*static*/ function isVacationEnabled($script) {
- return ereg('## vacation 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";
- }
+ 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;
- }
+ 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;
+ }
};