steffen: server/kolab-webadmin/kolab-webadmin/www/admin/user forward.php, 1.5, 1.6 vacation.php, 1.5, 1.6

cvs at intevation.de cvs at intevation.de
Fri Nov 5 14:31:11 CET 2004


Author: steffen

Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user
In directory doto:/tmp/cvs-serv19991/kolab-webadmin/kolab-webadmin/www/admin/user

Modified Files:
	forward.php vacation.php 
Log Message:
move mail sieve stuff -- needs improvement!

Index: forward.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user/forward.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- forward.php	1 Sep 2004 22:18:05 -0000	1.5
+++ forward.php	5 Nov 2004 13:31:09 -0000	1.6
@@ -1,6 +1,6 @@
 <?php
 /*
- *  Copyright (c) 2004 Klarälvdalens Datakonsult AB
+ *  Copyright (c) 2004 Klarälvdalens Datakonsult AB
  *
  *    Written by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
  *
@@ -52,6 +52,15 @@
   $obj = $ldap->read( $auth->dn() );
   $sieve =& new Net_Sieve( $auth->uid(), $auth->password(), $obj['kolabHomeServer'][0] );
 
+  // Fetch script data from server
+  $scripts = $sieve->listScripts();
+  if( in_array( "kolab-deliver.siv", $scripts ) ) {
+	$deliverscript = $sieve->getScript( $scriptname );
+	
+	if( ereg('fileinto "INBOX/(.*)";', $deliverscript, $regs ) ) {
+	  $inbox = $regs[1];
+	}
+  }
   
   // Update sieve script on server in case we have submit data
   if( $_REQUEST['submit'] ) {
@@ -63,7 +72,10 @@
 	  $errors[] = _('Please enter an email address');
 	} else {
 	  $script = 
-		"redirect \"".addslashes($address)."\";".($keep?" keep;":"");
+		"require \"fileinto\";\r\nredirect \"".addslashes($address)."\";".($keep?" keep;":"");
+	  if( $inbox ) {
+		$script .= "\r\nif header :contains [\"X-Kolab-Scheduling-Message\"] [\"FALSE\"] {\r\nfileinto \"INBOX/$inbox\";\r\n}\r\n";
+	  }
 	  if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
 		$errors[] = $res->getMessage();
 		$errors[] = _('Script was:');
@@ -80,8 +92,6 @@
 	}
   }
 
-  // Fetch script data from server
-  $scripts = $sieve->listScripts();
   if( in_array( $scriptname, $scripts ) ) {
 	$script = $sieve->getScript( $scriptname );
 	if( ereg('redirect "(.*)";', $script, $regs ) ) {

Index: vacation.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user/vacation.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- vacation.php	1 Sep 2004 22:18:05 -0000	1.5
+++ vacation.php	5 Nov 2004 13:31:09 -0000	1.6
@@ -1,6 +1,6 @@
 <?php
 /*
- (c) 2004 Klarälvdalens Datakonsult AB
+ (c) 2004 Klarälvdalens Datakonsult AB
 
  This program is Free Software under the GNU General Public License (>=v2).
  Read the file COPYING that comes with this packages for details.
@@ -38,16 +38,29 @@
 if( !$errors ) {
   $obj = $ldap->read( $auth->dn() );
   $sieve =& new Net_Sieve( $auth->uid(), $auth->password(), $obj['kolabHomeServer'][0] );
-  
+
+  // Fetch script data from server
+  $scripts = $sieve->listScripts();
+  if( in_array( "kolab-deliver.siv", $scripts ) ) {
+	$deliverscript = $sieve->getScript( $scriptname );
+	
+	if( ereg('fileinto "INBOX/(.*)";', $deliverscript, $regs ) ) {
+	  $inbox = $regs[1];
+	}
+  }
+
   // Update sieve script on server in case we have submit data
   if( $_REQUEST['submit'] ) {
 	$addresses = array_unique( array_filter( array_map( 'trim', preg_split( '/\n/', $_POST['addresses'] ) ), 'strlen') );
-
 	$script = 
 	  "require \"vacation\";\r\n\r\n".
+	  "require \"fileinto\";\r\n\r\n".
 	  "vacation :addresses [ \"".join('", "', $addresses )."\" ] :days ".
 	  $_REQUEST['days']." text:\r\n".
-	  dotstuff($_REQUEST['text'])."\r\n.\r\n;";
+	  dotstuff($_REQUEST['text'])."\r\n.\r\n;\r\n\r\n";
+	if( $inbox ) {
+	  $script .= "if header :contains [\"X-Kolab-Scheduling-Message\"] [\"FALSE\"] {\r\nfileinto \"INBOX/$inbox\";\r\n}\r\n";
+	}
 	$active = isset($_REQUEST['active']);
 
 	if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
@@ -65,12 +78,10 @@
 	}
   }
 
-  // Fetch script data from server
-  $scripts = $sieve->listScripts();
   if( in_array( $scriptname, $scripts ) ) {
 	$script = $sieve->getScript( $scriptname );
 	//debug("<pre>".htmlentities($script)."</pre>");
-	if( ereg(':addresses \[(.*)\]', $script, $regs ) ) {
+	if( ereg(':addresses \[([^\]]*)\]', $script, $regs ) ) {
 	  $tmp = split(',', $regs[1] );
 	  $addresses = array();
 	  foreach( $tmp as $a ) {
@@ -121,6 +132,7 @@
 $smarty->assign( 'text', $text );
 $smarty->assign( 'addresses', $addresses );
 $smarty->assign( 'days', $days );
+$smarty->assign( 'inbox', $inbox );
 $smarty->assign( 'maincontent', 'vacation.tpl' );
 $smarty->display('page.tpl');
 





More information about the commits mailing list