diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index a1c9418ef8a..d35526b1f13 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -131,7 +131,7 @@ class Contact extends CommonObject $sql.= "'".$this->db->idate($now)."',"; if ($this->socid > 0) $sql.= " ".$this->socid.","; else $sql.= "null,"; - $sql.= "'".$this->db->escape($this->name)."',"; + $sql.= "'".$this->db->escape($this->lastname)."',"; $sql.= "'".$this->db->escape($this->firstname)."',"; $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; $sql.= " ".$this->priv.","; @@ -330,7 +330,7 @@ class Contact extends CommonObject // Fields if ($this->fullname && $conf->global->LDAP_CONTACT_FIELD_FULLNAME) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; - if ($this->name && $conf->global->LDAP_CONTACT_FIELD_NAME) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->name; + if ($this->lastname && $conf->global->LDAP_CONTACT_FIELD_NAME) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname; if ($this->firstname && $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname; if ($this->poste) $info["title"] = $this->poste; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index c3f307f6b34..0f8f82b6507 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -159,13 +159,13 @@ if (empty($reshook)) $error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - + if (! $error) { $id = $object->create($user); if ($id <= 0) { - $error++; $errors[]=($object->error?array($object->error):$object->errors); + $error++; $errors=array_merge($errors,($object->error?array($object->error):$object->errors)); $action = 'create'; } } @@ -199,7 +199,7 @@ if (empty($reshook)) } else { - $error=$object->error; $errors[]=$object->errors; + $error=$object->error; $errors=$object->errors; } } @@ -355,7 +355,7 @@ else print_fiche_titre($title); // Affiche les erreurs - dol_htmloutput_errors($error,$errors); + dol_htmloutput_errors(is_numeric($error)?'':$error,$errors); if ($conf->use_javascript_ajax) { @@ -689,7 +689,7 @@ else } } - if (! empty($id) && $action != 'edit') + if (! empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 15b359c8ff5..e8ed38b57cb 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -32,6 +32,8 @@ $langs->load("companies"); $langs->load("ldap"); $langs->load("admin"); +$action=GETPOST('action'); + // Security check $contactid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; @@ -45,7 +47,7 @@ $contact->fetch($_GET["id"], $user); * Actions */ -if ($_GET["action"] == 'dolibarr2ldap') +if ($action == 'dolibarr2ldap') { $message=""; @@ -133,7 +135,7 @@ print ''; print ''; -if ($message) { print $message; } +dol_htmloutput_mesg($message); /* diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index dbb26219f2f..9ca0b596792 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -411,7 +411,7 @@ class Ldap { global $conf; - dol_syslog("Ldap::add dn=".$dn." info=".join(',',$info)); + dol_syslog(get_class($this)."::add dn=".$dn." info=".join(',',$info)); // Check parameters if (! $this->connection) @@ -439,13 +439,14 @@ class Ldap if ($result) { - dol_syslog("Ldap::add successfull", LOG_DEBUG); + dol_syslog(get_class($this)."::add successfull", LOG_DEBUG); return 1; } else { $this->error=@ldap_error($this->connection); - dol_syslog("Ldap::add failed: ".$this->error, LOG_ERR); + $this->errno=@ldap_errno($this->connection); + dol_syslog(get_class($this)."::add failed: ".$this->errno." ".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index ccc7d65af6d..3d6c7b01333 100755 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2012 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by