steffen: server/kolab-webadmin/kolab-webadmin/www/admin/service index.php, 1.9, 1.10

cvs at intevation.de cvs at intevation.de
Sat Sep 11 04:46:02 CEST 2004


Author: steffen

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

Modified Files:
	index.php 
Log Message:
GUI for adding system administrative aliases (dist. lists)

Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/service/index.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- index.php	6 Sep 2004 21:50:05 -0000	1.9
+++ index.php	11 Sep 2004 02:45:59 -0000	1.10
@@ -80,6 +80,25 @@
 extract_ldap_values();
 
 // Write back to LDAP
+if( $_REQUEST['submitsystemalias'] ) {
+  $mail = trim($_REQUEST['systemaliasmail']);
+  $dn = $ldap->dnForMail( $mail );
+  if( !$dn ) {
+	$errors[] = _("No account has primary email address $mail");
+  } else {
+	foreach( array( 'postmaster', 'hostmaster', 'abuse' ) as $group ) {
+	  $attrs = array( 'objectClass' => array( 'top', 'kolabGroupOfNames' ),
+					  'cn' => $group,
+					  'member' => $dn );
+	  if( !ldap_add( $ldap->connection, "cn=$group,".$_SESSION['base_dn'], $attrs ) ) {
+		$errors[] = _("LDAP Error: Failed to add distribution list $group: ").$ldap->error();
+	  } else {
+		$messages[] = "Successfully created distribution list $group";
+	  }
+	}
+  }
+}
+
 if( $_REQUEST['submitservices'] ) {
   $attrs = array();
   if( postvalue( 'pop3' ) != $pop3 )   $attrs['cyrus-pop3'] = postvalue( 'pop3' );
@@ -176,6 +195,14 @@
 				  array( 'service' => 'http', 'name'  => _('HTTP FreeBusy Service'), 'enabled' => toboolstr( $http ) ),
 				  array( 'service' => 'amavis', 'name' => _('Amavis Virus Scanning'), 'enabled' => toboolstr( $amavis ) ) );
 
+/**** Check for system aliases ****/
+function exists_group( $group ) {
+  global $ldap;
+  $filter = '(&(objectClass=kolabGroupOfNames)(cn='.$ldap->escape($group).'))';
+  $res = $ldap->search( $_SESSION['base_dn'], $filter, array( 'dn' ) );
+  return ( $ldap->count($res) > 0 );
+}
+
 /**** Insert into template and output ***/
 $smarty = new MySmarty();
 $smarty->assign( 'errors', $errors );
@@ -194,6 +221,17 @@
 				 array_key_exists('submenu', 
 								  $menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
 $smarty->assign( 'maincontent', 'service.tpl' );
+
+$smarty->assign( 'systemaliasconf', false );
+if( $auth->group() == 'admin' ) {
+  if( !exists_group( "hostmaster" ) ||
+	  !exists_group( "postmaster" ) ||
+	  !exists_group( "abuse" ) ) {
+	// Ok, user did not set up system aliases
+	$smarty->assign( 'systemaliasconf', true );
+  }
+}
+
 $smarty->display('page.tpl');
 
 /*





More information about the commits mailing list