steffen: server/kolab-webadmin/kolab-webadmin/www/admin/user index.php, 1.12, 1.13 user.php, 1.62, 1.63

cvs at intevation.de cvs at intevation.de
Tue Jul 5 12:31:53 CEST 2005


Author: steffen

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

Modified Files:
	index.php user.php 
Log Message:
multi-domain config (working) + per-domain maintainer config (not working yet)

Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user/index.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- index.php	22 Apr 2005 01:34:52 -0000	1.12
+++ index.php	5 Jul 2005 10:31:51 -0000	1.13
@@ -29,8 +29,9 @@
 /**** Authentication etc. ***/
 $sidx = 'user';
 
-if( $auth->group() != 'maintainer' && $auth->group() != 'admin') {
-   array_push($errors, _("Error: You don't have Permissions to access this Menu"));
+if( $auth->group() != 'maintainer' && $auth->group() != 'admin' && $auth->group() != 'domain-maintainer' ) {
+  debug("auth->group=".$auth->group());
+  array_push($errors, _("Error: You don't have Permissions to access this Menu"));
 }
 
 require_once('admin/include/menu.php');
@@ -87,7 +88,18 @@
 	default: $alphalimit = '';
 	}
   }
-  $filter = "(&($userfilter)$alphalimit(objectclass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))";
+  $domains = $ldap->domainsForMaintainerDn($auth->dn());
+  #debug_var_dump($domains);
+  if( is_array($domains) ) {
+	$domainfilter='';
+	foreach( $domains as $dom ) {
+	  $domainfilter .= '(mail=*@'.$ldap->escape($dom).')';
+	}
+	if( $domainfilter ) $domainfilter = "(|$domainfilter)";
+  } else {
+	$domainfilter= "";
+  }
+  $filter = "(&($userfilter)$domainfilter$alphalimit(objectclass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))";
   $result = ldap_search($ldap->connection, $base_dn, $filter, array( 'uid', 'mail', 'sn', 'cn', 'kolabDeleteflag' ));
 
   if( $result ) {

Index: user.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user/user.php,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- user.php	30 May 2005 11:53:35 -0000	1.62
+++ user.php	5 Jul 2005 10:31:51 -0000	1.63
@@ -54,16 +54,26 @@
 function checkuniquemail( $form, $key, $value ) {
   debug("checkuniquemail( $form, $key, $value )");
   global $ldap;
+  global $auth;
   $value = trim($value);
   if( $value == '' ) return _('Please enter an email address');
 
   // Check that we are in the domain
   $kolab = $ldap->read( 'k=kolab,'.$_SESSION['base_dn'] );
-  $domain = trim($kolab['postfix-mydomain'][0]);
-  debug("value=$value, domain=$domain");
-  if( !endsWith( $value, '@'.$domain ) ) {	
-	return _("Email address $value not in domain $domain");
+  if( $auth->group() == 'domain-maintainer' ) {
+	$domains = $ldap->domainsForMaintainerDn($auth->dn());
+  } else {
+	$domains = $kolab['postfix-mydestination'];
+	unset($domains['count']);
+  }
+  debug("value=$value, domain=$domains");
+  $ok = false;
+  foreach( $domains as $domain ) {
+	if( endsWith( $value, '@'.$domain ) ) {	
+	  $ok = true;
+	}
   }
+  if(!$ok) return _("Email address $value not in domains ".join(", ", $domain));
 
   if( $ldap->countMail( $_SESSION['base_dn'], $value ) > 0 ) {	
 	return _('User, vCard or distribution list with this email address already exists');
@@ -336,9 +346,13 @@
 
 // Check auth
 if (!$errors && $auth->group() != 'maintainer' && $auth->group() != 'admin' &&
+	$auth->group() != 'domain-maintainer' &&
     !($auth->group() == 'user' && $dn == $auth->dn() )) {
   array_push($errors, _("Error: You don't have the required Permissions") );
-}   
+} else if( $auth->group() == 'domain-maintainer' ) {
+  // TODO(steffen): Check that user is in correct domain(s)
+}
+
 
 if( !$errors && $auth->group() == 'user' && ($action == 'firstsave' || $action == 'kill' ) ) {
   $errors[] = _("Error: You don't have the required Permissions");
@@ -370,8 +384,10 @@
 					 'validation' => 'checkpw',
 					 'comment' => $comment_password ),
 		  'mail' => array( 'name' => _('Primary Email Address'),
+					 'type'       => 'email',
+					 'domains'    => $ldap->domains(),
 				     'validation' => 'notempty',
-				     'comment' => $comment_mail ),
+				     'comment'    => $comment_mail ),
 		  'uid'    => array( 'name' => _('Unique Identity (UID)'),
                                      'validation' => 'checkuid',
                                      'comment' => _('Optional - Defaults to Primary Email Address') ),
@@ -483,7 +499,7 @@
 		   }
 		 }
        }
-       $ldap_object['mail'] = trim( strtolower( $_POST['mail'] ) );
+       $ldap_object['mail'] = trim( strtolower( $_POST['user_mail'] ) ).'@'.trim( strtolower( $_POST['domain_mail'] ) );
        $ldap_object['uid'] = trim( strtolower( $_POST['uid'] ) );
        if( $action == 'firstsave' ) {
 		 if ($ldap_object['uid'] == "") $ldap_object['uid'] = $ldap_object['mail'];
@@ -624,10 +640,10 @@
 			   unset($ldap_object['uid']);
 			   unset($ldap_object['kolabHomeServer']);
 			 }
-			 debug_var_dump($ldap_object);
 			 if (!ldap_modify($ldap->connection, $dn, $ldap_object)) {			   
 			   array_push($errors, _("LDAP Error: Could not modify object $dn: ")
 						  .ldap_error($ldap->connection));
+			   debug_var_dump( $ldap_object );
 			 }
 		   }
 		   // Check for collisions on alias





More information about the commits mailing list