Skip to content

Commit

Permalink
Fix: [ bug #404 ] Impossible d'ajouter un contact lorsque le module LDAP
Browse files Browse the repository at this point in the history
est actif (erreur Array 1)
  • Loading branch information
eldy committed May 12, 2012
1 parent d4ca08d commit be85c5c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions htdocs/contact/class/contact.class.php
Expand Up @@ -131,7 +131,7 @@ function create($user)
$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.",";
Expand Down Expand Up @@ -330,7 +330,7 @@ function _load_ldap_info()

// 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;
Expand Down
12 changes: 6 additions & 6 deletions htdocs/contact/fiche.php
@@ -1,6 +1,6 @@
<?php
/* 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) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
Expand Down Expand Up @@ -159,13 +159,13 @@
$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';
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@
}
else
{
$error=$object->error; $errors[]=$object->errors;
$error=$object->error; $errors=$object->errors;
}
}

Expand Down Expand Up @@ -355,7 +355,7 @@
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)
{
Expand Down Expand Up @@ -689,7 +689,7 @@
}
}

if (! empty($id) && $action != 'edit')
if (! empty($id) && $action != 'edit' && $action != 'create')
{
$objsoc = new Societe($db);

Expand Down
6 changes: 4 additions & 2 deletions htdocs/contact/ldap.php
Expand Up @@ -32,6 +32,8 @@
$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;
Expand All @@ -45,7 +47,7 @@
* Actions
*/

if ($_GET["action"] == 'dolibarr2ldap')
if ($action == 'dolibarr2ldap')
{
$message="";

Expand Down Expand Up @@ -133,7 +135,7 @@
print '</div>';


if ($message) { print $message; }
dol_htmloutput_mesg($message);


/*
Expand Down
7 changes: 4 additions & 3 deletions htdocs/core/class/ldap.class.php
Expand Up @@ -411,7 +411,7 @@ function add($dn, $info, $user)
{
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)
Expand Down Expand Up @@ -439,13 +439,14 @@ function add($dn, $info, $user)

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;
}
}
Expand Down
@@ -1,5 +1,5 @@
<?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
* it under the terms of the GNU General Public License as published by
Expand Down

0 comments on commit be85c5c

Please sign in to comment.