steffen: server/kolab-webadmin/kolab-webadmin/www/admin/service index.php.in, 1.1, 1.2

cvs at intevation.de cvs at intevation.de
Wed Feb 22 01:36:29 CET 2006


Author: steffen

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

Modified Files:
	index.php.in 
Log Message:
Fix for issue1100 (multidomain admin aliases)

Index: index.php.in
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/service/index.php.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- index.php.in	5 Feb 2006 20:13:55 -0000	1.1
+++ index.php.in	22 Feb 2006 00:36:27 -0000	1.2
@@ -89,25 +89,31 @@
 
 extract_ldap_values();
 
-// Write back to LDAP
-if( $_REQUEST['submitsystemalias'] ) {
-  $mail = trim($_REQUEST['systemaliasmail']);
-  $dn = $ldap->dnForMailOrAlias( $mail );
-  if( !$dn ) {
-	$errors[] = sprintf(_("No account found for email address %s"), $mail);
-  } else {
-	foreach( array( 'postmaster', 'hostmaster', 'abuse', 'virusalert', 'MAILER-DAEMON' ) as $group ) {
-	  $attrs = array( 'objectClass' => array( 'top', 'kolabGroupOfNames' ),
-					  'cn' => $group,
-					  'mail' => $group.'@'.$postfixmydomain,
-					  'member' => $dn );
-	  if( !ldap_add( $ldap->connection, "cn=$group,".$_SESSION['base_dn'], $attrs ) ) {
-		$errors[] = sprintf(_("LDAP Error: Failed to add distribution list %s: %s"), $group, $ldap->error());
-	  } else {
-		$messages[] = sprintf( _("Successfully created distribution list %s"), $group);
+$domains = $ldap->domains();
+$domain_count = 0;
+foreach( $domains as $domain ) {
+  // Write back to LDAP
+  if( $_REQUEST['submitsystemalias_'.$domain_count] ) {
+	$mail = trim($_REQUEST['systemaliasmail_'.$domain_count]);
+	$dn = $ldap->dnForMailOrAlias( $mail );
+	if( !$dn ) {
+	  $errors[] = sprintf(_("No account found for email address %s"), $mail);
+	} else {
+	  foreach( array( 'postmaster', 'hostmaster', 'abuse', 'virusalert', 'MAILER-DAEMON' ) as $group ) {
+		$gadr = $group.'@'.$domain;
+		$attrs = array( 'objectClass' => array( 'top', 'kolabGroupOfNames' ),
+						'cn' => $gadr,
+						'mail' => $gadr,
+						'member' => $dn );
+		if( !ldap_add( $ldap->connection, "cn=$gadr,".$_SESSION['base_dn'], $attrs ) ) {
+		  $errors[] = sprintf(_("LDAP Error: Failed to add distribution list %s: %s"), $gadr, $ldap->error());
+		} else {
+		  $messages[] = sprintf( _("Successfully created distribution list %s"), $gadr);
+		}
 	  }
 	}
   }
+  $domain_count++;
 }
 
 if( $_REQUEST['submitservices'] ) {
@@ -282,7 +288,7 @@
 /**** Check for system aliases ****/
 function exists_group( $group ) {
   global $ldap;
-  $filter = '(&(objectClass=kolabGroupOfNames)(cn='.$ldap->escape($group).'))';
+  $filter = '(&(objectClass=kolabGroupOfNames)(mail='.$ldap->escape($group).'))';
   $res = $ldap->search( $_SESSION['base_dn'], $filter, array( 'dn' ) );
   return ( $ldap->count($res) > 0 );
 }
@@ -312,18 +318,24 @@
 								  $menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
 $smarty->assign( 'maincontent', 'service.tpl' );
 
-$smarty->assign( 'systemaliasconf', false );
+$systemaliasconf = array();
+
 if( $auth->group() == 'admin' ) {
-  if( !exists_group( 'hostmaster' ) ||
-	  !exists_group( 'postmaster' ) ||
-	  !exists_group( 'abuse' ) ||
-	  !exists_group( 'virusalert' ) ||
-	  !exists_group( 'MAILER-DAEMON' ) ) {
-	// Ok, user did not set up system aliases
-	$smarty->assign( 'systemaliasconf', true );
+  $domain_count = 0;
+  foreach( $ldap->domains() as $domain ) {
+	if( !exists_group( 'hostmaster@'.$domain ) ||
+		!exists_group( 'postmaster@'.$domain ) ||
+		!exists_group( 'abuse@'.$domain ) ||
+		!exists_group( 'virusalert@'.$domain ) ||
+		!exists_group( 'MAILER-DAEMON@'.$domain ) ) {
+	  // Ok, user did not set up system aliases
+	  $systemaliasconf[] = array( 'n'=>$domain_count, 'domain'=>$domain );
+	}
+	$domain_count++;
   }
 }
 
+$smarty->assign( 'systemaliasconf', $systemaliasconf );
 $smarty->display('page.tpl');
 
 /*





More information about the commits mailing list