Fix: [ bug #404 ] Impossible d'ajouter un contact lorsque le module LDAP

est actif (erreur Array 1)
This commit is contained in:
Laurent Destailleur 2012-05-12 12:32:24 +02:00
parent d4ca08db00
commit be85c5c381
5 changed files with 17 additions and 14 deletions

View File

@ -131,7 +131,7 @@ class Contact extends CommonObject
$sql.= "'".$this->db->idate($now)."',"; $sql.= "'".$this->db->idate($now)."',";
if ($this->socid > 0) $sql.= " ".$this->socid.","; if ($this->socid > 0) $sql.= " ".$this->socid.",";
else $sql.= "null,"; else $sql.= "null,";
$sql.= "'".$this->db->escape($this->name)."',"; $sql.= "'".$this->db->escape($this->lastname)."',";
$sql.= "'".$this->db->escape($this->firstname)."',"; $sql.= "'".$this->db->escape($this->firstname)."',";
$sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= " ".$this->priv.","; $sql.= " ".$this->priv.",";
@ -330,7 +330,7 @@ class Contact extends CommonObject
// Fields // Fields
if ($this->fullname && $conf->global->LDAP_CONTACT_FIELD_FULLNAME) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname; 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->firstname && $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
if ($this->poste) $info["title"] = $this->poste; if ($this->poste) $info["title"] = $this->poste;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
@ -159,13 +159,13 @@ if (empty($reshook))
$error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"));
$action = 'create'; $action = 'create';
} }
if (! $error) if (! $error)
{ {
$id = $object->create($user); $id = $object->create($user);
if ($id <= 0) 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'; $action = 'create';
} }
} }
@ -199,7 +199,7 @@ if (empty($reshook))
} }
else else
{ {
$error=$object->error; $errors[]=$object->errors; $error=$object->error; $errors=$object->errors;
} }
} }
@ -355,7 +355,7 @@ else
print_fiche_titre($title); print_fiche_titre($title);
// Affiche les erreurs // Affiche les erreurs
dol_htmloutput_errors($error,$errors); dol_htmloutput_errors(is_numeric($error)?'':$error,$errors);
if ($conf->use_javascript_ajax) 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); $objsoc = new Societe($db);

View File

@ -32,6 +32,8 @@ $langs->load("companies");
$langs->load("ldap"); $langs->load("ldap");
$langs->load("admin"); $langs->load("admin");
$action=GETPOST('action');
// Security check // Security check
$contactid = isset($_GET["id"])?$_GET["id"]:''; $contactid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -45,7 +47,7 @@ $contact->fetch($_GET["id"], $user);
* Actions * Actions
*/ */
if ($_GET["action"] == 'dolibarr2ldap') if ($action == 'dolibarr2ldap')
{ {
$message=""; $message="";
@ -133,7 +135,7 @@ print '</table>';
print '</div>'; print '</div>';
if ($message) { print $message; } dol_htmloutput_mesg($message);
/* /*

View File

@ -411,7 +411,7 @@ class Ldap
{ {
global $conf; global $conf;
dol_syslog("Ldap::add dn=".$dn." info=".join(',',$info)); dol_syslog(get_class($this)."::add dn=".$dn." info=".join(',',$info));
// Check parameters // Check parameters
if (! $this->connection) if (! $this->connection)
@ -439,13 +439,14 @@ class Ldap
if ($result) if ($result)
{ {
dol_syslog("Ldap::add successfull", LOG_DEBUG); dol_syslog(get_class($this)."::add successfull", LOG_DEBUG);
return 1; return 1;
} }
else else
{ {
$this->error=@ldap_error($this->connection); $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; return -1;
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by