phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgwapi/inc/class.contacts_sql.inc.php, 1.17.2.2.2.6


From: nomail
Subject: [Phpgroupware-cvs] phpgwapi/inc/class.contacts_sql.inc.php, 1.17.2.2.2.69
Date: Wed, 1 Sep 2004 15:06:08 +0200

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

date: 2004/09/01 13:06:08;  author: fipsfuchs;  state: Exp;  lines: +36 -33

Log Message:
contact to ldap sync improved
better error reporting
missing utf8_encode added
=====================================================================
Index: phpgwapi/inc/class.contacts_sql.inc.php
diff -u phpgwapi/inc/class.contacts_sql.inc.php:1.17.2.2.2.68 
phpgwapi/inc/class.contacts_sql.inc.php:1.17.2.2.2.69
--- phpgwapi/inc/class.contacts_sql.inc.php:1.17.2.2.2.68       Thu Jul 15 
22:36:02 2004
+++ phpgwapi/inc/class.contacts_sql.inc.php     Wed Sep  1 13:06:08 2004
@@ -4009,29 +4009,28 @@
                        $person = $this->get_principal_persons_data($id);
 
                        $time = gettimeofday();
-                       //$uid = 
time().$time['usec'].':'.$person[0]['per_full_name'];
                        $uid = 
$person[0]['contact_id'].':'.$person[0]['per_full_name'];
-                       $dn = 'uid=' . $uid.',' . 
$GLOBALS['phpgw_info']['server']['ldap_contact_context'];
+                       $dn = 'uid=' . utf8_encode($uid).',' . 
$GLOBALS['phpgw_info']['server']['ldap_contact_context'];
 
                        /* Requerid attributes */
-                       $attributes['objectClass'][]            = 'person';
-                       $attributes['objectClass'][]            = 
'organizationalPerson';
-                       $attributes['objectClass'][]            = 
'inetOrgPerson';
-                       $attributes['cn'][]                     = 
utf8_encode($person[0]['per_full_name']);
-                       $attributes['sn'][]                     = 
utf8_encode($person[0]['per_last_name']);
+                       $attributes['objectClass'][] = 'person';
+                       $attributes['objectClass'][] = 'organizationalPerson';
+                       $attributes['objectClass'][] = 'inetOrgPerson';
+                       $attributes['cn'][]          = 
utf8_encode($person[0]['per_full_name']) ? 
utf8_encode($person[0]['per_full_name']) : ' ';
+                       $attributes['sn'][]          = 
utf8_encode($person[0]['per_last_name']) ? 
utf8_encode($person[0]['per_last_name']) : ' ';
                        /* Optional attributes */
-                       $attributes['uid'][]                    = 
utf8_encode($uid);
+                       $attributes['uid'][]         = utf8_encode($uid);
                        if($person[0]['org_name'])
                        {
-                               $attributes['o'][]              = 
utf8_encode($person[0]['org_name']);
+                               $attributes['o'][]         = 
utf8_encode($person[0]['org_name']);
                        }
                        if($person[0]['per_title'])
                        {
-                               $attributes['title'][]          = 
utf8_encode($person[0]['per_title']);
+                               $attributes['title'][]     = 
utf8_encode($person[0]['per_title']);
                        }
                        if($person[0]['per_first_name'])
                        {
-                               $attributes['givenName'][]      = 
utf8_encode($person[0]['per_first_name']);
+                               $attributes['givenName'][] = 
utf8_encode($person[0]['per_first_name']);
                        }
                        /*if($person[0]['per_last_name'])
                        {
@@ -4042,13 +4041,12 @@
                        }
                        if($person[0]['per_department'])
                        {
-                               $attributes['ou'][]             = 
utf8_encode($person[0]['per_department']);
+                               $attributes['ou'][]       = 
utf8_encode($person[0]['per_department']);
                        }
                        if($person[0]['contact_id'])
                        {
                                $attributes['employeeNumber'][] = 
utf8_encode($person[0]['contact_id']);
                        }
-
                        unset($person);
 
                        $address_pref = $this->get_addr_contact_data($id, 
array('addr_pref_val'=>'Y'));
@@ -4065,31 +4063,30 @@
 
                        if($address_pref[0]['addr_state'])
                        {
-                               $attributes['st'][]                             
= utf8_encode($address_pref[0]['addr_state']);
+                               $attributes['st'][]         = 
utf8_encode($address_pref[0]['addr_state']);
                        }
                        if($address_pref[0]['addr_postal_code'])
                        {
-                               $attributes['postalCode'][]                     
= utf8_encode($address_pref[0]['addr_postal_code']);
+                               $attributes['postalCode'][] = 
utf8_encode($address_pref[0]['addr_postal_code']);
                        }
                        if($address_pref[0]['addr_city'])
                        {
-                               $attributes['l'][]                              
= utf8_encode($address_pref[0]['addr_city']);
+                               $attributes['l'][]          = 
utf8_encode($address_pref[0]['addr_city']);
                        }
                        //$attributes['homePostalAddress'][]            = ''; 
//we can use the address with type home
-
                        unset($address_pref);
 
-                       $db2LDAP_map['home email']        = 'mail';
-                       $db2LDAP_map['work email']        = 'mail';
-                       $db2LDAP_map['home phone']        = 'homePhone';
-                       $db2LDAP_map['work phone']        = 'telephoneNumber';
-                       $db2LDAP_map['pager']             = 'pager';
-                       $db2LDAP_map['isdn']              = 
'internationaliSDNNumber';
-                       $db2LDAP_map['home fax']          = 
'facsimileTelephoneNumber';
-                       $db2LDAP_map['work fax']          = 
'facsimileTelephoneNumber';
+                       $db2LDAP_map['home email']          = 'mail';
+                       $db2LDAP_map['work email']          = 'mail';
+                       $db2LDAP_map['home phone']          = 'homePhone';
+                       $db2LDAP_map['work phone']          = 'telephoneNumber';
+                       $db2LDAP_map['pager']               = 'pager';
+                       $db2LDAP_map['isdn']                = 
'internationaliSDNNumber';
+                       $db2LDAP_map['home fax']            = 
'facsimileTelephoneNumber';
+                       $db2LDAP_map['work fax']            = 
'facsimileTelephoneNumber';
                        $db2LDAP_map['mobile (cell) phone'] = 'mobile';
-                       $db2LDAP_map['car phone']         = 'telephoneNumber';
-                       $db2LDAP_map['website']           = 'labeledURI';
+                       $db2LDAP_map['car phone']           = 'telephoneNumber';
+                       $db2LDAP_map['website']             = 'labeledURI';
 
                        $comms = $this->get_comm_contact_data($id, '');
                        $validator = CreateObject('phpgwapi.validator');
@@ -4120,12 +4117,18 @@
                                }
                        }
 
-                       ldap_add($this->LDAPResource, $dn, $attributes);
-                       //echo ldap_error($this->LDAPResource);
-
-                       //ldap_close($this->LDAPResource);
-                       //die('debug');
+                       $success = @ldap_add($this->LDAPResource, $dn, 
$attributes);
+                       if (!$success)
+                       {
+                               echo 'ldap_add FAILED: [' . 
ldap_errno($this->LDAPResource) . '] ' . ldap_error($this->LDAPResource).'<br 
/><br />';
+                               echo "<strong>Adds: ".$dn."</strong><br />";
+                               echo "<pre>";
+                               print_r($attributes);
+                               echo "</pre>";
+                               echo "<br />";
+                       }
                }
+
                /**
                * Method that could be used to import fields from an array with 
the specified form.
                *




reply via email to

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