steffen: server/kolab-webadmin/kolab-webadmin/www/admin/user user.php, 1.50, 1.51

cvs at intevation.de cvs at intevation.de
Wed Feb 23 23:18:01 CET 2005


Author: steffen

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

Modified Files:
	user.php 
Log Message:
configurable access to attributes in account object

Index: user.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/user/user.php,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- user.php	3 Feb 2005 14:25:57 -0000	1.50
+++ user.php	23 Feb 2005 22:17:59 -0000	1.51
@@ -11,6 +11,8 @@
 require_once('admin/include/authenticate.php');
 require_once('admin/include/form.class.php');
 
+require_once('admin/include/attributeaccess.php');
+
 /**** Functions ***/
 function comment( $s ) {
   return $s;
@@ -150,6 +152,24 @@
   }
 }
 
+function apply_attributeaccess( &$entries ) {
+  global $attributeaccess;
+  foreach( $entries as $key=>$value ) {
+	if( ereg( '(.*)_[0-9]', $key, $regs ) ) {
+	  $akey = $regs[1];
+	} else {
+	  $akey = $key;
+	}
+	if( isset($attributeaccess[$akey] ) ) {
+	  if( $attributeaccess[$akey] == 'ro' ) {
+		$entries[$key]['attrs'] = 'readonly';
+	  } else if( $attributeaccess[$akey] == 'hidden' ) {
+		unset($entries[$key]);
+	  }
+	}
+  }
+}
+
 function fill_form_for_modify( &$form, $dn, &$ldap_object ) {
   global $auth;
   if (is_array($ldap_object['sn'])) $lastname = $ldap_object['sn'][0];
@@ -163,16 +183,16 @@
       $firstname = substr($cn, 0, $b - $a);
     }
   }
-  if (is_array($ldap_object['mail'])) $mail_0 = $ldap_object['mail'][0];
-  else $mail_0 = $ldap_object['mail'];
+  if (is_array($ldap_object['mail'])) $mail = $ldap_object['mail'][0];
+  else $mail = $ldap_object['mail'];
   if (is_array($ldap_object['uid'])) $uid = $ldap_object['uid'][0];
   else $uid = $ldap_object['uid'];
   $form->entries['firstname']['value'] = $firstname;
   $form->entries['lastname']['value'] = $lastname;
   $form->entries['password_0']['value'] = '';
   $form->entries['password_1']['value'] = '';
-  $form->entries['mail_0']['value'] = $mail_0;
-  $form->entries['mail_0']['attrs'] = 'readonly';
+  $form->entries['mail']['value'] = $mail;
+  $form->entries['mail']['attrs'] = 'readonly';
   $form->entries['uid']['value'] = $uid;
 
   // accttype
@@ -302,11 +322,11 @@
 
 // Fill in data
 if ($action == "create") {
-  $comment_mail_0 = _('Required, non volatile');
+  $comment_mail = _('Required, non volatile');
   $comment_password = _('Required');
   $comment_kolabhomeserver = _('Required, non volatile');
 } else {
-  $comment_mail_0 = _('Non volatile');
+  $comment_mail = _('Non volatile');
   $comment_password = _('Leave blank to keep password unchanged');
   $comment_kolabhomeserver = _('Non volatile');
 }
@@ -325,9 +345,9 @@
 					 'type' => 'password',
 					 'validation' => 'checkpw',
 					 'comment' => $comment_password ),
-		  'mail_0' => array( 'name' => _('Primary Email Address'),
+		  'mail' => array( 'name' => _('Primary Email Address'),
 				     'validation' => 'notempty',
-				     'comment' => $comment_mail_0 ),
+				     'comment' => $comment_mail ),
 		  'uid'    => array( 'name' => _('Unique Identity (UID)'),
                                      'validation' => 'checkuid',
                                      'comment' => _('Optional - Defaults to Primary Email Address') ),
@@ -390,12 +410,15 @@
   }
 }
 
+if( $auth->group() == 'user' ) {
+  apply_attributeaccess( $entries );
+}
 $form =& new KolabForm( 'user', 'createuser.tpl', $entries );
 /***************** Main action swicth **********************/
 switch( $action ) {
  case 'firstsave':
    debug("adding checkuniquemail to validation");
-   $form->entries['mail_0']['validation'] = 'checkuniquemail';   
+   $form->entries['mail']['validation'] = 'checkuniquemail';   
  case 'save':
    if( $form->isSubmitted() ) {
      if( !$form->validate() ) {
@@ -436,7 +459,7 @@
 		   }
 		 }
        }
-       $ldap_object['mail'] = trim( strtolower( $_POST['mail_0'] ) );
+       $ldap_object['mail'] = trim( strtolower( $_POST['mail'] ) );
        $ldap_object['uid'] = trim( strtolower( $_POST['uid'] ) );
        if( $action == 'firstsave' ) {
 		 if ($ldap_object['uid'] == "") $ldap_object['uid'] = $ldap_object['mail'];
@@ -555,6 +578,7 @@
 			   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));
@@ -577,7 +601,7 @@
 		 $heading = _('Modify User');
 		 if( !$errors ) $messages[] = _("User '$dn' successfully modified");
 		 $form->setValues();
-		 $form->entries['mail_0']['attrs'] = 'readonly';
+		 $form->entries['mail']['attrs'] = 'readonly';
 		 $form->entries['kolabhomeserver']['attrs'] = 'readonly';
 		 $form->entries['action']['value'] = 'save';
 		 $form->entries['dn'] = array( 'name' => 'dn',





More information about the commits mailing list