phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc/class.accounts_ldap.inc.php, 1.101.2.13.


From: nomail
Subject: [Phpgroupware-cvs] phpgwapi/inc/class.accounts_ldap.inc.php, 1.101.2.13.2.30
Date: Tue, 15 Jun 2004 15:23:09 +0200

Update of /phpgwapi/inc
Modified Files:
        Branch: Version-0_9_16-branch
          class.accounts_ldap.inc.php

date: 2004/06/15 13:23:09;  author: fipsfuchs;  state: Exp;  lines: +71 -19

Log Message:
patch 2916
=====================================================================
Index: phpgwapi/inc/class.accounts_ldap.inc.php
diff -u phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.29 
phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.30
--- phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.29    Sat May  1 
09:50:43 2004
+++ phpgwapi/inc/class.accounts_ldap.inc.php    Tue Jun 15 13:23:09 2004
@@ -103,6 +103,12 @@
                        {
                                $this->data['status'] = 'A';
                        }
+                       
+                       if ( $allValues[0]['phpgwcontactid'][0] )
+                       {
+                               $this->data['person_id']  = 
$allValues[0]['phpgwcontactid'][0];
+                               $this->account_contact_id       = 
$this->data['person_id'];
+                       }
                        return $this->data;
                }
 
@@ -116,9 +122,6 @@
                        }
                        else
                        {
-                               /* this line is not working
-                               $this->data['person_id'] = 
$this->save_contact_for_account($this->data);
-                               */
                                return $this->create_account($this->data, '');  
                
                        }
                }
@@ -560,7 +563,7 @@
                * @param string $dn LDAP distinguised name
                * @return array|boolean Array with 'dn' infos or false
                */
-               function account_exists($id, $dn = '')
+               function account_exists($id, $dn = null)
                {
                        if ($id)
                        {
@@ -570,10 +573,10 @@
                                {
                                        return $allValues[0];
                                }
-                               else
-                               {
-                                       return $this->dn_exists($dn);
-                               }
+                       }
+                       if($dn)
+                       {
+                               return $this->dn_exists($dn);
                        }
                        return false;
                }
@@ -711,7 +714,7 @@
                                
                        // phpgw attributes
                        $entry['objectclass'][]       = 'phpgwAccount';
-                       $entry['phpgwAccountID']      = 
$account_info['account_id'];
+                       $entry['phpgwaccountid']      = 
$account_info['account_id'];
                        $entry['phpgwaccountexpires'] = 
$account_info['account_expires'];
                        if ($account_info['account_status'])
                        {
@@ -734,13 +737,23 @@
                                $entry['phpgwlastpasswordchange'] = 
$account_info['lastpasswd_change'];
                        }
                                
+                       $structural_modification = false;
+                       if((int) $account_info['person_id'])
+                       {
+                               $entry['objectclass'][] = 'phpgwContact'; // 
shouldn't be structural
+                               $entry['phpgwcontactid'] = 
(int)$account_info['person_id'];
+                       }
+                       else
+                       {
+                               $entry['objectclass'][]       = 'account';
+                       }
+
                        // additional attributes from the phpgw for groups
-                       $entry['objectclass'][]       = 'account';
                        $entry['objectclass'][]       = 'posixAccount';
                        $entry['cn']                  = 
utf8_encode($this->get_fullname($account_info['account_firstname'], 
$account_info['account_lastname']));
                        $entry['uidnumber']           = 
$account_info['account_id'];
                        $entry['uid']                 = 
$account_info['account_lid'];
-                       $entry['description']         = 
utf8_encode(lang('phpgw-created account'));
+                       $entry['description']         = 
utf8_encode(str_replace('*','',lang('phpgw-created account')));
                        if ( $account_info['account_firstname'] )
                        {
                                $entry['givenname'] = 
utf8_encode($account_info['account_firstname']);
@@ -749,6 +762,10 @@
                        {
                                $entry['sn'] = 
utf8_encode($account_info['account_lastname']);
                        }
+                       else
+                       {
+                               $entry['sn'] = ' ';
+                       }
                        if ($account_info['account_passwd'])
                        {
                                $entry['userpassword'] = 
$GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd']);
@@ -798,7 +815,7 @@
                                                                                
$oldEntry['dn'] = $this->rename_LDAP_entry($oldEntry['dn'], $dn, 
$this->user_context);
                                                                                
if (!$oldEntry)
                                                                                
{
-                                                                               
       die('ldap_rename FAILED: [' . ldap_errno($this->ds) . '] ' . 
ldap_error($this->ds));
+                                                                               
        die('ldap_rename FAILED: [' . ldap_errno($this->ds) . '] ' . 
ldap_error($this->ds));
                                                                                
}                                                                               
        
                                                                        }
                                                                        break;
@@ -820,14 +837,20 @@
                                                                case 
'phpgwlastlogin':
                                                                case 
'phpgwlastloginfrom':
                                                                case 
'phpgwlastpasswordchange':
+                                                               case 
'phpgwcontactid':
+                                                               case 
'phpgwquota':
                                                                        break;
                                                                        
                                                                case 
'objectclass':
-                                                                       if( 
!in_array('phpgwAccount', $oldEntry[$key]) && !in_array('phpgwAccount', 
$oldEntry[$key]) )
+                                                                       if( 
!in_array('phpgwAccount', $oldEntry[$key]) && !in_array('phpgwContact', 
$oldEntry[$key]) )
                                                                        {
                                                                                
$entry[$key] = $oldEntry[$key];
                                                                                
array_push($entry[$key], 'phpgwAccount');
                                                                        }
+                                                                       
elseif((in_array('phpgwContact',$entry[$key]) && ! 
in_array('phpgwContact',$oldEntry[$key])))
+                                                                       {
+                                                                               
$structural_modification = true;
+                                                                       } 
                                                                        else
                                                                        {
                                                                                
$entry[$key] = $oldEntry[$key];
@@ -839,7 +862,34 @@
                                                        }
                                                } 
                                        }
-                                       
$this->modify_LDAP_Entry($oldEntry['dn'], $entry);
+
+                                       //Caeies Bonification
+                                       //When a structural object is modified 
you need to remove it then re add it ...
+                                       //So You need to add to entry all the 
old stuff not modified in $entry .
+                                       if ( $structural_modification )
+                                       {
+                                               for( $i = 0; $i < 
$oldEntry['count']; ++$i)
+                                               {
+                                                       if ( 
!empty($oldEntry[$i]) && !(array_key_exists($oldEntry[$i],$entry)) ) 
+                                                       {
+                                                               if ( 
count($oldEntry[$oldEntry[$i]]) == 1 ) 
+                                                               {
+                                                                       
$entry[$oldEntry[$i]] = $oldEntry[$oldEntry[$i]][0];
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$entry[$oldEntry[$i]] = $oldEntry[$oldEntry[$i]];
+                                                               }
+                                                       }
+                                               }
+                                               ldap_delete($this->ds, 
$oldEntry['dn']);
+                                               
$this->add_LDAP_Entry($oldEntry['dn'], $entry);
+                                       }
+                                       else
+                                       {
+                                               
$this->modify_LDAP_Entry($oldEntry['dn'], $entry);
+                                       }
+                                       $dn = $oldEntry['dn'];
                                }
                        }
                        else // entry not yet in LDAP
@@ -1150,10 +1200,10 @@
                        $this->read_repository();
 
                        $data[$this->data['account_id']]['lid']       = 
$this->data['account_lid'];
-                       $data[$this->data['account_id']]['firstname'] = 
$this->data['firstname'];
-                       $data[$this->data['account_id']]['lastname']  = 
$this->data['lastname'];
+                       $data[$this->data['account_id']]['firstname'] = 
$this->data['account_firstname'];
+                       $data[$this->data['account_id']]['lastname']  = 
$this->data['account_lastname'];
                        $data[$this->data['account_id']]['fullname']  = 
$this->data['fullname'];
-                       $data[$this->data['account_id']]['type']      = 
$this->data['account_type'];
+                       $data[$this->data['account_id']]['type']      = 
$this->data['type'];
                        $data[$this->data['account_id']]['person_id'] = 
$this->data['person_id'];
                        return $data;
                }
@@ -1214,8 +1264,10 @@
                        $allValues = ldap_get_entries($this->ds, $sri);
                        if(is_array($allValues))
                        {
-                               foreach($allValues as $value)
+                               $count = intval($allValues['count']);
+                               for($i=0;$i<$count;$i++)//foreach(allValues as 
$value)
                                {
+                                       $value = &$allValue[$i];
                                        $accounts[] = $value['uidnumber'][0];
                                }
                        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]