diff --git a/dev/samples/create_order.php b/dev/samples/create_order.php
index 1a16b4251c1..d099fd29ae9 100644
--- a/dev/samples/create_order.php
+++ b/dev/samples/create_order.php
@@ -49,7 +49,7 @@ $langs->load("main"); // To load language file for default language
@set_time_limit(0);
// Load user and its permissions
-$result=$user->fetch('admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
+$result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (! $result > 0) { dol_print_error('',$user->error); exit; }
$user->getrights();
diff --git a/dev/samples/create_product.php b/dev/samples/create_product.php
index ea489d33829..ff3815b8ab6 100644
--- a/dev/samples/create_product.php
+++ b/dev/samples/create_product.php
@@ -49,7 +49,7 @@ $langs->load("main"); // To load language file for default language
@set_time_limit(0);
// Load user and its permissions
-$result=$user->fetch('admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
+$result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (! $result > 0) { dol_print_error('',$user->error); exit; }
$user->getrights();
diff --git a/dev/skeletons/skeleton_script.php b/dev/skeletons/skeleton_script.php
index 5ebfb54639e..4f3a202f76e 100644
--- a/dev/skeletons/skeleton_script.php
+++ b/dev/skeletons/skeleton_script.php
@@ -51,7 +51,7 @@ $langs->load("main"); // To load language file for default language
@set_time_limit(0); // No timeout for this script
// Load user and its permissions
-$result=$user->fetch('admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
+$result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
if (! $result > 0) { dol_print_error('',$user->error); exit; }
$user->getrights();
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 7d106da5999..9a950b60dbf 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -504,8 +504,7 @@ class Adherent extends CommonObject
// This member is linked with a user, so we also update users informations
// if this is an update.
$luser=new User($this->db);
- $luser->id=$this->user_id;
- $result=$luser->fetch();
+ $result=$luser->fetch($this->user_id);
if ($result >= 0)
{
@@ -2051,22 +2050,22 @@ class Adherent extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_mod)
{
- $muser = new User($this->db, $obj->fk_user_mod);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_mod);
$this->user_modification = $muser;
}
diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php
index db29b82b759..dad6e4de252 100644
--- a/htdocs/bookmarks/fiche.php
+++ b/htdocs/bookmarks/fiche.php
@@ -224,8 +224,7 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"]))
if ($bookmark->fk_user)
{
$fuser=new User($db);
- $fuser->id=$bookmark->fk_user;
- $fuser->fetch();
+ $fuser->fetch($bookmark->fk_user);
//$fuser->nom=$fuser->login; $fuser->prenom='';
print $fuser->getNomUrl(1);
}
diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index 261f59e4a33..b8c8a834bcf 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -81,9 +81,9 @@ switch ( $_GET['action'] )
case 'valide_facture':
-
+
$now=dol_now('tzserver');
-
+
// Recuperation de la date et de l'heure
$date = dol_print_date($now,'day');
$heure = dol_print_date($now,'hour');
@@ -131,8 +131,7 @@ switch ( $_GET['action'] )
$db->begin();
- $user->id=$_SESSION['uid'];
- $user->fetch();
+ $user->fetch($_SESSION['uid']);
$user->getrights();
$invoice=new Facture($db,$conf_fksoc);
@@ -216,11 +215,11 @@ switch ( $_GET['action'] )
{
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
}
- else
+ else
{
$error++;
}
-
+
$id = $invoice->id;
}
else
@@ -231,7 +230,7 @@ switch ( $_GET['action'] )
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
$id = $invoice->id;
-
+
// Add the payment
$payment=new Paiement($db);
$payment->datepaye=$now;
@@ -240,7 +239,7 @@ switch ( $_GET['action'] )
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture();
$payment->paiementid=$invoice->mode_reglement_id;
$payment->num_paiement='';
-
+
$paiement_id = $payment->create($user);
if ($paiement_id > 0)
{
@@ -260,13 +259,13 @@ switch ( $_GET['action'] )
{
$bankaccountid=$conf_fkaccount_cb;
}
-
+
if ($bankaccountid > 0)
{
// Insertion dans llx_bank
$label = "(CustomerInvoicePayment)";
$acc = new Account($db, $bankaccountid);
-
+
$bank_line_id = $acc->addline($payment->datepaye,
$payment->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label,
@@ -276,7 +275,7 @@ switch ( $_GET['action'] )
$user,
'',
'');
-
+
// Mise a jour fk_bank dans llx_paiement.
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0)
@@ -308,7 +307,7 @@ switch ( $_GET['action'] )
}
}
}
- else
+ else
{
$error++;
}
diff --git a/htdocs/comm/action/actioncomm.class.php b/htdocs/comm/action/actioncomm.class.php
index bd7a4b2c51a..a33c783761a 100644
--- a/htdocs/comm/action/actioncomm.class.php
+++ b/htdocs/comm/action/actioncomm.class.php
@@ -454,14 +454,14 @@ class ActionComm
$this->id = $obj->id;
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_mod)
{
- $muser = new User($this->db, $obj->fk_user_mod);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_mod);
$this->user_modification = $muser;
}
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 42c8806f517..93cbef993b2 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -615,10 +615,10 @@ if ($_GET["id"])
}
$act->societe = $societe;
- if ($act->author->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->author->id; $res=$tmpuser->fetch(); $act->author=$tmpuser; }
- if ($act->usermod->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->usermod->id; $res=$tmpuser->fetch(); $act->usermod=$tmpuser; }
- if ($act->usertodo->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->usertodo->id; $res=$tmpuser->fetch(); $act->usertodo=$tmpuser; }
- if ($act->userdone->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->userdone->id; $res=$tmpuser->fetch(); $act->userdone=$tmpuser; }
+ if ($act->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($act->author->id); $act->author=$tmpuser; }
+ if ($act->usermod->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($act->usermod->id); $act->usermod=$tmpuser; }
+ if ($act->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($act->usertodo->id); $act->usertodo=$tmpuser; }
+ if ($act->userdone->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($act->userdone->id); $act->userdone=$tmpuser; }
$contact = new Contact($db);
if ($act->contact->id)
diff --git a/htdocs/comm/adresse_livraison.class.php b/htdocs/comm/adresse_livraison.class.php
index fe21fbadce8..a7e0a257200 100644
--- a/htdocs/comm/adresse_livraison.class.php
+++ b/htdocs/comm/adresse_livraison.class.php
@@ -450,14 +450,14 @@ class AdresseLivraison
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
- $cuser = new User($this->db, $obj->fk_user_creat);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
- $muser = new User($this->db, $obj->fk_user_modif);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->ref = $obj->nom;
diff --git a/htdocs/comm/propal/propal.class.php b/htdocs/comm/propal/propal.class.php
index 78c9352bcf0..c0b37407be5 100644
--- a/htdocs/comm/propal/propal.class.php
+++ b/htdocs/comm/propal/propal.class.php
@@ -1744,21 +1744,21 @@ class Propal extends CommonObject
$this->date_validation = $this->db->jdate($obj->datev);
$this->date_cloture = $this->db->jdate($obj->dateo);
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
- $cluser = new User($this->db, $obj->fk_user_cloture);
- $cluser->fetch();
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 28ba7dc16f4..63dd0ac443a 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2190,22 +2190,22 @@ class Commande extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
- $cluser = new User($this->db, $obj->fk_user_cloture);
- $cluser->fetch();
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
}
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index a17e0ec26dd..d9869ab1341 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1107,14 +1107,14 @@ class AccountLine
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_rappro)
{
- $ruser = new User($this->db, $obj->fk_user_rappro);
- $ruser->fetch();
+ $ruser = new User($this->db);
+ $ruser->fetch($obj->fk_user_rappro);
$this->user_rappro = $ruser;
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index fb482158098..fd91bfb33ca 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2290,14 +2290,14 @@ class Facture extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
$this->date_creation = $this->db->jdate($obj->datec);
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 09ff8890bed..1635503dc21 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -356,14 +356,14 @@ class Paiement
$this->id = $obj->rowid;
if ($obj->fk_user_creat)
{
- $cuser = new User($this->db, $obj->fk_user_creat);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif)
{
- $muser = new User($this->db, $obj->fk_user_modif);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
diff --git a/htdocs/compta/prelevement/class/rejet-prelevement.class.php b/htdocs/compta/prelevement/class/rejet-prelevement.class.php
index 97d71f06e80..d8f11b05101 100644
--- a/htdocs/compta/prelevement/class/rejet-prelevement.class.php
+++ b/htdocs/compta/prelevement/class/rejet-prelevement.class.php
@@ -197,8 +197,8 @@ class RejetPrelevement
if ($userid > 0)
{
- $emuser = new User($this->db, $userid);
- $emuser->fetch();
+ $emuser = new User($this->db);
+ $emuser->fetch($userid);
$soc = new Societe($this->db);
$soc->fetch($fac->socid);
diff --git a/htdocs/compta/prelevement/config.php b/htdocs/compta/prelevement/config.php
index bbe1289d8e8..ed526558a92 100644
--- a/htdocs/compta/prelevement/config.php
+++ b/htdocs/compta/prelevement/config.php
@@ -158,8 +158,8 @@ if ($user->rights->prelevement->bons->configurer)
print '
';
if (defined("PRELEVEMENT_USER") && PRELEVEMENT_USER > 0)
{
- $cuser = new User($db, PRELEVEMENT_USER);
- $cuser->fetch();
+ $cuser = new User($db);
+ $cuser->fetch(PRELEVEMENT_USER);
print $cuser->fullname;
}
else
diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php
index 102d92a48fd..3936b070476 100644
--- a/htdocs/compta/prelevement/fiche.php
+++ b/htdocs/compta/prelevement/fiche.php
@@ -173,8 +173,8 @@ if ($_GET["id"])
if($bon->date_trans <> 0)
{
- $muser = new User($db, $bon->user_trans);
- $muser->fetch();
+ $muser = new User($db);
+ $muser->fetch($bon->user_trans);
print ' | | Date Transmission / Par | ';
print dol_print_date($bon->date_trans,'dayhour');
diff --git a/htdocs/contact/contact.class.php b/htdocs/contact/contact.class.php
index 987bcc60654..823a09d5a46 100644
--- a/htdocs/contact/contact.class.php
+++ b/htdocs/contact/contact.class.php
@@ -672,14 +672,14 @@ class Contact extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
- $cuser = new User($this->db, $obj->fk_user_creat);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
- $muser = new User($this->db, $obj->fk_user_modif);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 6a456eb2d4b..da6ecd1220d 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -467,8 +467,7 @@ if ($user->rights->societe->contact->creer)
if ($contact->user_id)
{
$dolibarr_user=new User($db);
- $dolibarr_user->id=$contact->user_id;
- $result=$dolibarr_user->fetch();
+ $result=$dolibarr_user->fetch($contact->user_id);
print $dolibarr_user->getLoginUrl(1);
}
else print $langs->trans("NoDolibarrAccess");
@@ -617,8 +616,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
if ($contact->user_id)
{
$dolibarr_user=new User($db);
- $dolibarr_user->id=$contact->user_id;
- $result=$dolibarr_user->fetch();
+ $result=$dolibarr_user->fetch($contact->user_id);
print $dolibarr_user->getLoginUrl(1);
}
else print $langs->trans("NoDolibarrAccess");
diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
index afebe903a15..c6d7a7f35d9 100644
--- a/htdocs/contrat/contrat.class.php
+++ b/htdocs/contrat/contrat.class.php
@@ -1149,14 +1149,14 @@ class Contrat extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_author) {
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_cloture) {
- $cuser = new User($this->db, $obj->fk_user_cloture);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cuser;
}
$this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref;
diff --git a/htdocs/core/commonobject.class.php b/htdocs/core/commonobject.class.php
index 1f8ecf5bf00..ec25373e7c0 100644
--- a/htdocs/core/commonobject.class.php
+++ b/htdocs/core/commonobject.class.php
@@ -386,8 +386,8 @@ class CommonObject
*/
function fetch_user($userid)
{
- $user = new User($this->db, $userid);
- $result=$user->fetch();
+ $user = new User($this->db);
+ $result=$user->fetch($userid);
$this->user = $user;
return $result;
}
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index 0baaf7b4f22..3b89ff5fcf7 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -491,14 +491,14 @@ class Fichinter extends CommonObject
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_validation = $this->db->jdate($obj->datev);
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
}
diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php
index 08a035f08d6..dbfc4e44530 100644
--- a/htdocs/fourn/facture/paiementfourn.class.php
+++ b/htdocs/fourn/facture/paiementfourn.class.php
@@ -356,14 +356,14 @@ class PaiementFourn
$this->id = $obj->rowid;
if ($obj->fk_user_creat)
{
- $cuser = new User($this->db, $obj->fk_user_creat);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif)
{
- $muser = new User($this->db, $obj->fk_user_modif);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index 9c2976b8173..bfee057abbb 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -878,14 +878,14 @@ class FactureFournisseur extends Facture
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
$this->date_creation = $obj->datec;
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index edc6d2b5490..70348e62dcd 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -1958,8 +1958,7 @@ class Form
//$this->load_cache_contacts();
//print $this->cache_contacts[$selected];
$theuser=new User($this->db);
- $theuser->id=$selected;
- $theuser->fetch();
+ $theuser->fetch($selected);
print $theuser->getNomUrl(1);
} else {
print " ";
diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php
index 042c510f7da..47f69659854 100644
--- a/htdocs/html.formmail.class.php
+++ b/htdocs/html.formmail.class.php
@@ -235,8 +235,7 @@ class FormMail
{
$langs->load("users");
$fuser=new User($this->db);
- $fuser->id=$this->fromid;
- $fuser->fetch();
+ $fuser->fetch($this->fromid);
print $fuser->getNomUrl(1);
}
else
diff --git a/htdocs/includes/login/functions_ldap.php b/htdocs/includes/login/functions_ldap.php
index 7d13802be10..f5fd68e1d80 100644
--- a/htdocs/includes/login/functions_ldap.php
+++ b/htdocs/includes/login/functions_ldap.php
@@ -40,7 +40,7 @@ function check_user_password_ldap($usertotest,$passwordtotest)
global $dolibarr_main_auth_ldap_login_attribute,$dolibarr_main_auth_ldap_dn;
global $dolibarr_main_auth_ldap_admin_login,$dolibarr_main_auth_ldap_admin_pass;
global $dolibarr_main_auth_ldap_debug;
-
+
if (! function_exists("ldap_connect"))
{
dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP. LDAP functions are disabled on this PHP");
@@ -50,11 +50,11 @@ function check_user_password_ldap($usertotest,$passwordtotest)
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorLDAPFunctionsAreDisabledOnThisPHP").' '.$langs->trans("TryAnotherConnectionMode");
return;
}
-
+
$login='';
$resultFetchUser='';
-
- if (! empty($_POST["username"]))
+
+ if (! empty($_POST["username"]))
{
// If test username/password asked, we define $test=false and $login var if ok, set $_SESSION["dol_loginmesg"] if ko
$ldaphost=$dolibarr_main_auth_ldap_host;
@@ -67,7 +67,7 @@ function check_user_password_ldap($usertotest,$passwordtotest)
$ldapadminlogin=$dolibarr_main_auth_ldap_admin_login;
$ldapadminpass=$dolibarr_main_auth_ldap_admin_pass;
$ldapdebug=(empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug=="false" ? false : true);
-
+
if ($ldapdebug) print "DEBUG: Logging LDAP steps \n";
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
@@ -78,16 +78,16 @@ function check_user_password_ldap($usertotest,$passwordtotest)
$ldap->serverType=$ldapservertype;
$ldap->searchUser=$ldapadminlogin;
$ldap->searchPassword=$ldapadminpass;
-
+
dol_syslog("functions_ldap::check_user_password_ldap usertotest=".$usertotest);
- if ($ldapdebug)
+ if ($ldapdebug)
{
dol_syslog("functions_ldap::check_user_password_ldap Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType);
dol_syslog("functions_ldap::check_user_password_ldap uid/samacountname=".$ldapuserattr.", dn=".$ladpdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword);
print "DEBUG: Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."\n";
print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ladpdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."\n";
}
-
+
$resultCheckUserDN=false;
// If admin login provided
@@ -116,7 +116,7 @@ function check_user_password_ldap($usertotest,$passwordtotest)
}
$ldap->close();
}
-
+
// Forge LDAP user and password to test from config setup
$ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn;
$ldap->searchPassword=$passwordtotest;
@@ -124,7 +124,7 @@ function check_user_password_ldap($usertotest,$passwordtotest)
if ($resultCheckUserDN) $ldap->searchUser = $ldap->ldapUserDN;
// Test with this->seachUser and this->searchPassword
- $result=$ldap->connect_bind();
+ $result=$ldap->connect_bind();
if ($result > 0)
{
if ($result == 2)
@@ -138,17 +138,17 @@ function check_user_password_ldap($usertotest,$passwordtotest)
// On charge les attributs du user ldap
if ($ldapdebug) print "DEBUG: login ldap = ".$login." \n";
$ldap->fetch($login);
-
+
if ($ldapdebug) print "DEBUG: UACF = ".join(',',$ldap->uacf)." \n";
if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset,'day')." \n";
if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime,'day')." \n";
-
+
// On recherche le user dolibarr en fonction de son SID ldap
$sid = $ldap->getObjectSid($login);
if ($ldapdebug) print "DEBUG: sid = ".$sid." \n";
$user=new User($db);
- $resultFetchUser=$user->fetch($login,$sid);
+ $resultFetchUser=$user->fetch('',$login,$sid);
if ($resultFetchUser > 0)
{
// On verifie si le login a change et on met a jour les attributs dolibarr
@@ -179,10 +179,10 @@ function check_user_password_ldap($usertotest,$passwordtotest)
$langs->load('other');
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
}
-
+
$ldap->close();
}
-
+
return $login;
}
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 4914ad5a431..3bee4e665fa 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -399,7 +399,7 @@ if (! defined('NOLOGIN'))
exit;
}
- $resultFetchUser=$user->fetch($login);
+ $resultFetchUser=$user->fetch('',$login);
if ($resultFetchUser <= 0)
{
dol_syslog('User not found, connexion refused');
@@ -436,7 +436,7 @@ if (! defined('NOLOGIN'))
{
// It is already in a session
$login=$_SESSION["dol_login"];
- $resultFetchUser=$user->fetch($login);
+ $resultFetchUser=$user->fetch('',$login);
dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login);
if ($resultFetchUser <= 0)
diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php
index 3496621a441..cafd660fab0 100644
--- a/htdocs/product/stock/entrepot.class.php
+++ b/htdocs/product/stock/entrepot.class.php
@@ -292,14 +292,14 @@ class Entrepot extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_author) {
- $cuser = new User($this->db, $obj->fk_user_author);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid) {
- $vuser = new User($this->db, $obj->fk_user_valid);
- $vuser->fetch();
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
diff --git a/htdocs/societe/societe.class.php b/htdocs/societe/societe.class.php
index b7346ba7069..2dfe5bff7f5 100644
--- a/htdocs/societe/societe.class.php
+++ b/htdocs/societe/societe.class.php
@@ -1881,14 +1881,14 @@ class Societe extends CommonObject
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
- $cuser = new User($this->db, $obj->fk_user_creat);
- $cuser->fetch();
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
- $muser = new User($this->db, $obj->fk_user_modif);
- $muser->fetch();
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->ref = $obj->nom;
diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php
index 308ebfa6dd2..8c0c815b5cc 100644
--- a/htdocs/user/clicktodial.php
+++ b/htdocs/user/clicktodial.php
@@ -67,8 +67,8 @@ llxHeader("","ClickToDial");
if ($_GET["id"])
{
- $fuser = new User($db, $_GET["id"]);
- $fuser->fetch();
+ $fuser = new User($db);
+ $fuser->fetch($_GET["id"]);
$fuser->fetch_clicktodial();
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index a825e376de6..b918189bd6a 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -98,8 +98,7 @@ if ($_REQUEST["action"] == 'confirm_disable' && $_REQUEST["confirm"] == "yes")
if ($_GET["id"] <> $user->id)
{
$edituser = new User($db);
- $edituser->id=$_GET["id"];
- $edituser->fetch();
+ $edituser->fetch($_GET["id"]);
$edituser->setstatus(0);
Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]);
exit;
@@ -109,9 +108,8 @@ if ($_REQUEST["action"] == 'confirm_enable' && $_REQUEST["confirm"] == "yes")
{
if ($_GET["id"] <> $user->id)
{
- $edituser = new User($db, $_GET["id"]);
- $edituser->id=$_GET["id"];
- $edituser->fetch();
+ $edituser = new User($db);
+ $edituser->fetch($_GET["id"]);
$edituser->setstatus(1);
Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]);
exit;
@@ -122,7 +120,7 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes")
{
if ($_GET["id"] <> $user->id)
{
- $edituser = new User($db, $_GET["id"]);
+ $edituser = new User($db);
$edituser->id=$_GET["id"];
$result = $edituser->delete();
if ($result < 0)
@@ -242,8 +240,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
if (! $message)
{
$db->begin();
- $edituser = new User($db, $_GET["id"]);
- $edituser->fetch();
+ $edituser = new User($db);
+ $edituser->fetch($_GET["id"]);
$edituser->oldcopy=dol_clone($edituser);
@@ -328,8 +326,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
}
else if ($caneditpassword) // Case we can edit only password
{
- $edituser = new User($db, $_GET["id"]);
- $edituser->fetch();
+ $edituser = new User($db);
+ $edituser->fetch($_GET["id"]);
$ret=$edituser->setPassword($user,$_POST["password"]);
if ($ret < 0)
@@ -343,8 +341,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
if ((($_REQUEST["action"] == 'confirm_password' && $_REQUEST["confirm"] == 'yes')
|| ($_REQUEST["action"] == 'confirm_passwordsend' && $_REQUEST["confirm"] == 'yes')) && $caneditpassword)
{
- $edituser = new User($db, $_GET["id"]);
- $edituser->fetch();
+ $edituser = new User($db);
+ $edituser->fetch($_GET["id"]);
$newpassword=$edituser->setPassword($user,'');
if ($newpassword < 0)
@@ -746,8 +744,8 @@ else
if ($_GET["id"])
{
- $fuser = new User($db, $_GET["id"]);
- $fuser->fetch();
+ $fuser = new User($db);
+ $fuser->fetch($_GET["id"]);
// Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon
diff --git a/htdocs/user/group/usergroup.class.php b/htdocs/user/group/usergroup.class.php
index 37118d7adda..a58fe07e60f 100644
--- a/htdocs/user/group/usergroup.class.php
+++ b/htdocs/user/group/usergroup.class.php
@@ -600,8 +600,7 @@ class UserGroup extends CommonObject
foreach($this->members as $key=>$val)
{
$muser=new User($this->db);
- $muser->id=$val;
- $muser->fetch();
+ $muser->fetch($val);
$ldapuserid=$muser->login;
// TODO ldapuserid should depends on value $conf->global->LDAP_KEY_USERS;
diff --git a/htdocs/user/info.php b/htdocs/user/info.php
index 32f49551692..0cb78224d79 100644
--- a/htdocs/user/info.php
+++ b/htdocs/user/info.php
@@ -33,8 +33,7 @@ $langs->load("users");
// Security check
$id = isset($_GET["id"])?$_GET["id"]:'';
$fuser = new User($db);
-$fuser->id = $id;
-$fuser->fetch();
+$fuser->fetch($id);
// Security check
$socid=0;
diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php
index eaea78bb59c..1740a8e47f5 100644
--- a/htdocs/user/ldap.php
+++ b/htdocs/user/ldap.php
@@ -47,8 +47,8 @@ if ($user->id == $_GET["id"]) // A user can always read its own card
}
$result = restrictedArea($user, 'user', $_GET["id"], '', $feature2);
-$fuser = new User($db, $_GET["id"]);
-$fuser->fetch();
+$fuser = new User($db);
+$fuser->fetch($_GET["id"]);
$fuser->getrights();
diff --git a/htdocs/user/note.php b/htdocs/user/note.php
index 99081a1f9d0..b9d939b954b 100644
--- a/htdocs/user/note.php
+++ b/htdocs/user/note.php
@@ -37,8 +37,7 @@ $langs->load("bills");
$langs->load("users");
$fuser = new User($db);
-$fuser->id = $id;
-$fuser->fetch();
+$fuser->fetch($id);
// If user is not user read and no permission to read other users, we stop
if (($fuser->id != $user->id) && (! $user->rights->user->user->lire))
diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php
index bd5a63b7c7e..997dbcd50fb 100644
--- a/htdocs/user/param_ihm.php
+++ b/htdocs/user/param_ihm.php
@@ -63,8 +63,8 @@ $dirleft = "../includes/menus/barre_left";
$dirtheme = "../theme";
// Charge utilisateur edite
-$fuser = new User($db, $id);
-$fuser->fetch();
+$fuser = new User($db);
+$fuser->fetch($id);
$fuser->getrights();
// Liste des zone de recherche permanentes supportees
diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php
index 0f3b223d8a5..515973eaa1e 100644
--- a/htdocs/user/passwordforgotten.php
+++ b/htdocs/user/passwordforgotten.php
@@ -54,7 +54,7 @@ $conf->entity = isset($_POST["entity"])?$_POST["entity"]:1;
if ($_GET["action"] == 'validatenewpassword' && $_GET["username"] && $_GET["passwordmd5"])
{
$edituser = new User($db);
- $result=$edituser->fetch($_GET["username"]);
+ $result=$edituser->fetch('',$_GET["username"]);
if ($result < 0)
{
$message = ''.$langs->trans("ErrorLoginDoesNotExists",$_GET["username"]).' ';
@@ -93,7 +93,7 @@ if ($_POST["action"] == 'buildnewpassword' && $_POST["username"])
else
{
$edituser = new User($db);
- $result=$edituser->fetch($_POST["username"],'',1);
+ $result=$edituser->fetch('',$_POST["username"],'',1);
if ($result <= 0 && $edituser->error == 'USERNOTFOUND')
{
$message = ''.$langs->trans("ErrorLoginDoesNotExists",$_POST["username"]).' ';
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index b8f10108553..3040509f743 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -96,8 +96,8 @@ llxHeader('',$langs->trans("Permissions"));
$form=new Form($db);
-$fuser = new User($db, $_GET["id"]);
-$fuser->fetch();
+$fuser = new User($db);
+$fuser->fetch($_GET["id"]);
$fuser->getrights();
/*
diff --git a/htdocs/user/user.class.php b/htdocs/user/user.class.php
index 8ce1f2ebb0f..cb309d52021 100644
--- a/htdocs/user/user.class.php
+++ b/htdocs/user/user.class.php
@@ -133,12 +133,13 @@ class User extends CommonObject
/**
* \brief Charge un objet user avec toutes ces caracteristiques depuis un id ou login
- * \param login Si defini, login a utiliser pour recherche
+ * \param id Si defini, id a utiliser pour recherche
+ * \param login Si defini, login a utiliser pour recherche
* \param sid Si defini, sid a utiliser pour recherche
* \param $loadpersonalconf Also load personal conf of user (in $user->conf->xxx)
* \return int <0 if KO, 0 not found, >0 if OK
*/
- function fetch($login='',$sid='',$loadpersonalconf=1)
+ function fetch($id='', $login='',$sid='',$loadpersonalconf=1)
{
global $conf;
diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php
index 9f6964ab3ec..686beac8aaa 100644
--- a/scripts/user/sync_users_dolibarr2ldap.php
+++ b/scripts/user/sync_users_dolibarr2ldap.php
@@ -79,8 +79,7 @@ if ($resql)
$obj = $db->fetch_object($resql);
$fuser = new User($db);
- $fuser->id = $obj->rowid;
- $fuser->fetch();
+ $fuser->fetch($obj->rowid);
print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname;
diff --git a/scripts/withdrawals/prelevement-verif.php b/scripts/withdrawals/prelevement-verif.php
index ae75624fbe4..48294007584 100644
--- a/scripts/withdrawals/prelevement-verif.php
+++ b/scripts/withdrawals/prelevement-verif.php
@@ -43,8 +43,8 @@ require_once(DOL_DOCUMENT_ROOT."/societe/societe.class.php");
$error = 0;
-$puser = new user($db, PRELEVEMENT_USER);
-$puser->fetch();
+$puser = new user($db);
+$puser->fetch(PRELEVEMENT_USER);
dol_syslog("Prelevements effectues par ".$puser->fullname." [".PRELEVEMENT_USER."]");
dol_syslog("Raison sociale : ".PRELEVEMENT_RAISON_SOCIALE);
diff --git a/test/AdherentTest.php b/test/AdherentTest.php
index a59ec7e3d85..bb4a5731726 100644
--- a/test/AdherentTest.php
+++ b/test/AdherentTest.php
@@ -32,8 +32,8 @@ require_once dirname(__FILE__).'/../htdocs/adherents/class/adherent.class.php';
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
diff --git a/test/CommandeTest.php b/test/CommandeTest.php
index a576b82817e..ef0c22f22a3 100644
--- a/test/CommandeTest.php
+++ b/test/CommandeTest.php
@@ -32,8 +32,8 @@ require_once dirname(__FILE__).'/../htdocs/commande/class/commande.class.php';
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
diff --git a/test/ContratTest.php b/test/ContratTest.php
index 4ad4012e2ff..c165ee172c7 100644
--- a/test/ContratTest.php
+++ b/test/ContratTest.php
@@ -32,8 +32,8 @@ require_once dirname(__FILE__).'/../htdocs/contrat/contrat.class.php';
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
diff --git a/test/FactureTest.php b/test/FactureTest.php
index c61f71df21b..531b98e4432 100644
--- a/test/FactureTest.php
+++ b/test/FactureTest.php
@@ -32,8 +32,8 @@ require_once dirname(__FILE__).'/../htdocs/compta/facture/class/facture.class.ph
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
diff --git a/test/MyTestSuite.php b/test/MyTestSuite.php
index b3986a8cb09..8d1cc09c8e7 100644
--- a/test/MyTestSuite.php
+++ b/test/MyTestSuite.php
@@ -33,8 +33,8 @@ require_once dirname(__FILE__).'/../htdocs/master.inc.php';
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
diff --git a/test/PropalTest.php b/test/PropalTest.php
index 16048d878ab..50b4fa0bfb9 100644
--- a/test/PropalTest.php
+++ b/test/PropalTest.php
@@ -32,8 +32,8 @@ require_once dirname(__FILE__).'/../htdocs/comm/propal/propal.class.php';
if (empty($user->id))
{
- print "Load permissions for admin user with login 'admin'\n";
- $user->fetch('admin');
+ print "Load permissions for admin user nb 1\n";
+ $user->fetch(1);
$user->getrights();
}
|