gunnar: server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve Script.php, 1.3, 1.4
cvs at kolab.org
cvs at kolab.org
Tue Apr 6 10:57:26 CEST 2010
Author: gunnar
Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve
In directory doto:/tmp/cvs-serv24461/kolab-webadmin/lib/KolabAdmin/Sieve
Modified Files:
Script.php
Log Message:
PHP5.3 strict, WS
Index: Script.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve/Script.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Script.php 31 Mar 2010 21:05:43 -0000 1.3
+++ Script.php 6 Apr 2010 08:57:24 -0000 1.4
@@ -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;
+ }
};
More information about the commits
mailing list