Fix: La config LDAP accepte la liste des objectClass

This commit is contained in:
Laurent Destailleur 2007-04-13 00:35:13 +00:00
parent 79b28739ce
commit 6a365194bb
6 changed files with 149 additions and 186 deletions

View File

@ -1891,7 +1891,7 @@ class Adherent
/*
* \brief Retourne chaine dn dans l'annuaire LDAP
* \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@ -1900,26 +1900,15 @@ class Adherent
$info=array();
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Object classes
$info["objectclass"]=split(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS);
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
if ($this->login && $conf->global->LDAP_FIELD_LOGIN) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login;
if ($this->pass && $conf->global->LDAP_FIELD_PASSWORD) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypté
if ($this->poste && $conf->global->LDAP_FIELD_TITLE) $info[$conf->global->LDAP_FIELD_TITLE] = $this->poste;
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;

View File

@ -99,128 +99,128 @@ llxHeader();
if ($facid > 0)
{
$facture = new Facture($db);
if ($facture->fetch($facid))
{
$facref = sanitize_string($facture->ref);
$upload_dir = $conf->facture->dir_output.'/'.$facref;
$societe = new Societe($db);
$societe->fetch($facture->socid);
$facture = new Facture($db);
$head = facture_prepare_head($facture);
dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
print '<table class="border"width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$facture->ref.'</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n";
print "</div>\n";
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?facid='.$facture->id);
if ($facture->fetch($facid))
{
$facref = sanitize_string($facture->ref);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
$upload_dir = $conf->facture->dir_output.'/'.$facref;
$societe = new Societe($db);
$societe->fetch($facture->socid);
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Document").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "<td>&nbsp;</td></tr>\n";
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
$head = facture_prepare_head($facture);
dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
// Construit liste des fichiers
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=facture&file='.$facref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").'</td>';
print '<td align="center">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>';
print '<td align="center">';
if ($file == $facref . '.pdf')
$i=0;
while (($file = readdir($handle))!==false)
{
echo '-';
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$filearray[$i]=$file;
$totalsize+=filesize($upload_dir."/".$file);
$i++;
}
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
closedir($handle);
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
}
else
{
dolibarr_print_error($db);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
print '<table class="border"width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$facture->ref.'</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n";
print "</div>\n";
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$html=new Form($db);
$html->form_attach_new_file('document.php?facid='.$facture->id);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Document").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "<td>&nbsp;</td></tr>\n";
if (is_dir($upload_dir))
{
$handle=opendir($upload_dir);
if ($handle)
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (! is_dir($dir.$file)
&& ! eregi('^\.',$file)
&& ! eregi('^CVS',$file)
&& ! eregi('\.meta$',$file))
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=facture&file='.$facref.'/'.urlencode($file).'">'.$file.'</a>';
print "</td>\n";
print '<td align="right">'.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").'</td>';
print '<td align="center">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>';
print '<td align="center">';
if ($file == $facref . '.pdf')
{
echo '-';
}
else
{
echo '<a href="'.DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
}
print "</td></tr>\n";
}
}
closedir($handle);
}
else
{
print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>';
}
}
print '</table>';
}
else
{
dolibarr_print_error($db);
}
}
else
{

View File

@ -220,28 +220,16 @@ class Contact
/*
* \brief Retourne chaine dn dand l'annuaire LDAP
* \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
{
global $conf,$langs;
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Object classes
$info["objectclass"]=split(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS);
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
@ -262,7 +250,7 @@ class Contact
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
if ($this->phone_perso && $conf->global->LDAP_FIELD_PHONE_PERSO) $info[$conf->global->LDAP_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note;

View File

@ -39,7 +39,7 @@ class Ldap
/**
* Tableau des serveurs (IP addresses ou nom d'hôtes)
*/
var $server;
var $server=array();
/**
* Base DN (e.g. "dc=foo,dc=com")
*/
@ -53,7 +53,7 @@ class Ldap
*/
var $domain;
/**
* Administrateur Ldap
* User administrateur Ldap
* Active Directory ne supporte pas les connexions anonymes
*/
var $searchUser;
@ -112,7 +112,8 @@ class Ldap
global $conf;
//Server
$this->server = array($conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_HOST_SLAVE);
if ($conf->global->LDAP_SERVER_HOST) $this->server[] = $conf->global->LDAP_SERVER_HOST;
if ($conf->global->LDAP_SERVER_HOST_SLAVE) $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE;
$this->serverPort = $conf->global->LDAP_SERVER_PORT;
$this->ldapProtocolVersion = $conf->global->LDAP_SERVER_PROTOCOLVERSION;
$this->dn = $conf->global->LDAP_SERVER_DN;
@ -666,9 +667,17 @@ class Ldap
$fp=fopen($file,"w");
if ($fp)
{
fputs($fp,"# ldapadd -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
fputs($fp,"# ldapmodify -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
fputs($fp,"# ldapdelete -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
if (ereg('^ldap',$this->server[0]))
{
$target="-H ".join(',',$this->server);
}
else
{
$target="-h ".join(',',$this->server)." -p ".$this->serverPort;
}
fputs($fp,"# ldapadd $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
fputs($fp,"# ldapmodify $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
fputs($fp,"# ldapdelete $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
fputs($fp, "dn: ".$dn."\n");
foreach($info as $key => $value)
{

View File

@ -1283,7 +1283,7 @@ class User
/*
* \brief Retourne chaine dn dand l'annuaire LDAP
* \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@ -1292,27 +1292,16 @@ class User
$info=array();
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Object classes
$info["objectclass"]=split(',',$conf->global->LDAP_USER_OBJECT_CLASS);
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
if ($this->login && $conf->global->LDAP_FIELD_LOGIN) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login;
if ($this->login && $conf->global->LDAP_FIELD_LOGIN_SAMBA) $info[$conf->global->LDAP_FIELD_LOGIN_SAMBA] = $this->login;
if ($this->pass && $conf->global->LDAP_FIELD_PASSWORD) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypté
if ($this->poste) $info["title"] = $this->poste;
if ($this->societe_id > 0)
{

View File

@ -479,7 +479,7 @@ class UserGroup
/*
* \brief Retourne chaine dn dand l'annuaire LDAP
* \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@ -487,21 +487,9 @@ class UserGroup
global $conf,$langs;
$info=array();
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Object classes
$info["objectclass"]=split(',',$conf->global->LDAP_GROUP_OBJECT_CLASS);
// Champs
if ($this->nom && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->nom;
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;