diff --git a/dev/samples/create_order.php b/dev/samples/create_order.php index 1a16b4251c101d806479c92b1badf5f6987bd316..d099fd29ae9cf9e5a67e94aef33a3e51e6342b7c 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 ea489d33829548e5ce146ea329e2ba7744ccc64f..ff3815b8ab6efb9553639b4b4662d4bc89b922c1 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 5ebfb54639e9ac4efd57df364bf28d039d927178..4f3a202f76e31d34425808c638c667d68eb117d0 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 7d106da5999d9bdf4211ff21fd13c4df97e55893..9a950b60dbf2bbf0d4c46fb0da64ff596d50e841 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 db29b82b75979c752ab1b0c726b2bb729cb55214..dad6e4de2523280009a47a20f4942089ba1205b8 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 261f59e4a33fab0f29c11e7be13de5a0af32f47e..b8c8a834bcf3d19899bd44fdafe32aeb634598dc 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 bd7a4b2c51a8224016a0016cec1e3c0f20839ffd..a33c783761a54a35e25dd62d68c56e26031c50a6 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 42c8806f517a5d15cd92821b9218b4b6a16468f9..93cbef993b28d0008ad7930ad8c3780ddac01363 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 fe21fbadce88d7442a5a5bff004339a7105b8b8d..a7e0a257200139b7676b53757a1fa70415f9b484 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 78c9352bcf018bc0fb36f7ec19cfb464f721438a..c0b37407be5204beebdcd8b0ef13e70d5e0b8785 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 28ba7dc16f49e158916fb89f6b72f829404a67d8..63dd0ac443ae8b2cd0b7c2fe6e26dfa3ba00fded 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 a17e0ec26ddad15911bd67ae6a91e5c6e9311950..d9869ab1341ac60d0369e76be63caea61dc89289 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 fb482158098718c411dc49751e44838878d2ab00..fd91bfb33ca0b60c091d4d7dd3d7934cb108bc85 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 09ff8890bede937656f44e170842623604392923..1635503dc2112fd8b76a4c46a962ca7e3b86659a 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 97d71f06e80996416b2cccc56cbdf8991762654e..d8f11b05101fe616a8e587b86670dff123f49fe0 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 bbe1289d8e886734a214ee06ed5dde1ad021d98c..ed526558a92aa9524626068dc45bd5ded7df5df3 100644 --- a/htdocs/compta/prelevement/config.php +++ b/htdocs/compta/prelevement/config.php @@ -158,8 +158,8 @@ if ($user->rights->prelevement->bons->configurer) print '<td>'; 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 102d92a48fd1ea11b8818b9ea68368342965b055..3936b070476a9c03f11e74955bf822121bfd6c3e 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 '<tr><td width="20%">Date Transmission / Par</td><td>'; print dol_print_date($bon->date_trans,'dayhour'); diff --git a/htdocs/contact/contact.class.php b/htdocs/contact/contact.class.php index 987bcc6065448a222c767f9d9dd131c74f4444e0..823a09d5a46d8b6c38b60295e24539f5a3f9cc8b 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 6a456eb2d4b63e7a8897a56f2151ca016c643ed5..da6ecd1220d560bf069ba8937b981520049059ec 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 afebe903a152e3c373ffbe99a598396958e30ac4..c6d7a7f35d947656034b03bcb6c866e2d9796cb5 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 1f8ecf5bf00ec2e781de69fe1e6991ce387124b7..ec25373e7c0271a00da5589e5526de858df170a7 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 0baaf7b4f22de5bf5af21f0faa81a2cd229e5ba8..3b89ff5fcf7282347ea5834260c997c89940bffa 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 08a035f08d68a602d1a2f367210568fd2b9526a7..dbfc4e4453021ecbd341b589d28796fb2a40838f 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 9c2976b8173ad9ca2c4fc8bd23396b04f8b8bfdc..bfee057abbb22933c0464cf857cb5cefc1f0e4a0 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 edc6d2b54900d3be29241928e9ab421d88baf72a..70348e62dcdcf92ad8df4ec4da341ce47bb492b7 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 042c510f7dab83922bb7cfa0e24b0092490f09c8..47f69659854e9107579192ca76956c0572a58799 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 7d13802be104dea18a67d2b2e48c76611c96553e..f5fd68e1d80f724d775449edbb75fab1534ce893 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<br>\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."<br>\n"; $ldap->fetch($login); - + if ($ldapdebug) print "DEBUG: UACF = ".join(',',$ldap->uacf)."<br>\n"; if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset,'day')."<br>\n"; if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime,'day')."<br>\n"; - + // On recherche le user dolibarr en fonction de son SID ldap $sid = $ldap->getObjectSid($login); if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\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 4914ad5a4311c0b1b740b7a30e450f655ac75294..3bee4e665fae1d6aea38a5c1745c3de5beafb533 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 3496621a441082b1e3d491ff332dcd700460434a..cafd660fab066e2b009c187f0a8141daff257c81 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 b7346ba7069fbeac2b62388fd108051d6bd573fa..2dfe5bff7f5ed899f4d6caf9eb46431be7eacf6c 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 308ebfa6dd2825fcbe15a34059f9b45da14e8688..8c0c815b5cc80f843ee3bfc810606f8b8759de5e 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 a825e376de6d6d7a7afd23f3e6f536d0d6173136..b918189bd6a0b2c6d40256816d622cd610837578 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 37118d7adda8149d3374cf47f613f396c410f22e..a58fe07e60f14d81496c194ede0f26b19cebbeb6 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 32f49551692a0f4047b2d3014b8d7f309cee887a..0cb78224d79a2d5d70d6114365ac20b1a6f02774 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 eaea78bb59cdeb6d4783a5eb0dd5d265e3fcab1c..1740a8e47f58536b079679155cda9d205469fd91 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 99081a1f9d0a24a9c1258228c37a5bf904fc1fc8..b9d939b954b43d811cc124a9672f26c4c169412c 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 bd5a63b7c7e155ec07cc7d2427c212a20df02f46..997dbcd50fb61b9e9963058fa16ae0a29286c3a8 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 0f3b223d8a54537edce178cfb299d8059ed9104d..515973eaa1e9608868d8d4c02f9ad7919abb7464 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 = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists",$_GET["username"]).'</div>'; @@ -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 = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists",$_POST["username"]).'</div>'; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index b8f10108553386fdde33d9ee1f304075731a2a3b..3040509f743f7f8aa53ca8671d01bad212592468 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 8ce1f2ebb0f6c804123881c2619ac64b861f57c9..cb309d52021c1f85c5328afa94eb2e75117b4473 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 9f6964ab3ec73763afa45006f32fd85bda0e55b4..686beac8aaae073a5b567a9e695285638d7ffbd3 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 ae75624fbe4291e7f17dc3f223393a4b41908f16..482940075849f941518e98fe833c7f6951b8672b 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 a59ec7e3d857c68adf650da9676a1bf82134806d..bb4a57317260faa4b47a3d66e28a7ab5abb81b29 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 a576b82817efd6aef2167c5c076d0da7628c74a7..ef0c22f22a3e7436b2bb74c219e488bd31ea7fd8 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 4ad4012e2ff720ed7458acbbb97e9e4909fdca66..c165ee172c755b5ed2e2ad1fa847d4f674ef1081 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 c61f71df21b7cdee54a721e9b0d45dc8e84bfaec..531b98e4432c2f48b6820356f85b141604ca0f68 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 b3986a8cb09bf2d9a43eca53c99571cf3abdbabe..8d1cc09c8e759efd4964cdd7ba0358e261b99fec 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 16048d878aba0878edd3c1f98a20e6f0fc9f52ab..50b4fa0bfb943027de15b3e6cb61d017eecbbdad 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(); }