From 091132de2fedcee1d8bf9f58f50fcdb6344bc8e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Apr 2019 12:11:32 +0200 Subject: [PATCH] Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter. --- ChangeLog | 1 + .../accountancy/class/bookkeeping.class.php | 10 +++---- htdocs/admin/emailcollector_card.php | 9 ++++-- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 28 +++++-------------- htdocs/comm/mailing/card.php | 2 +- htdocs/comm/mailing/class/mailing.class.php | 5 ++-- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 13 +++++---- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 7 +++-- htdocs/compta/bank/class/bankcateg.class.php | 9 +++--- .../facture/class/paymentterm.class.php | 5 ++-- .../sociales/class/cchargesociales.class.php | 9 +++--- .../class/paymentsocialcontribution.class.php | 5 ++-- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 11 ++++---- htdocs/core/actions_addupdatedelete.inc.php | 17 ----------- htdocs/core/class/ctyperesource.class.php | 9 +++--- .../core/modules/modEmailCollector.class.php | 2 +- htdocs/cron/class/cronjob.class.php | 5 ++-- htdocs/don/class/paymentdonation.class.php | 5 ++-- htdocs/ecm/class/ecmfiles.class.php | 9 +++--- htdocs/expensereport/card.php | 2 +- .../class/expensereport.class.php | 9 +++--- .../class/paymentexpensereport.class.php | 5 ++-- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 9 +++--- .../class/fournisseur.commande.class.php | 7 +++-- .../fournisseur.commande.dispatch.class.php | 7 ++--- htdocs/fourn/commande/card.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/product/class/productbatch.class.php | 5 ++-- .../class/productcustomerprice.class.php | 10 +++---- .../class/propalmergepdfproduct.class.php | 5 ++-- .../product/stock/class/productlot.class.php | 9 +++--- .../class/productstockentrepot.class.php | 9 +++--- htdocs/projet/card.php | 2 +- htdocs/projet/class/project.class.php | 27 +++++++++--------- htdocs/projet/class/task.class.php | 5 ++-- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 13 +++++---- htdocs/ticket/class/ticket.class.php | 9 +++--- htdocs/website/class/website.class.php | 2 +- 44 files changed, 138 insertions(+), 173 deletions(-) diff --git a/ChangeLog b/ChangeLog index b870df3e802..bbd12d6325c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ Following changes may create regressions for some external modules, but were nec * Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming convention of extension .inc.php for files to be included. * All methods set_draft() were renamed into setDraft(). +* Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter. * Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject. * Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated. * Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION. diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 03552557f86..3c985d325bc 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1409,16 +1409,14 @@ class BookKeeping extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; - $error = 0; $object = new BookKeeping($this->db); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index f05bf937169..3d14d8fee2f 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -604,11 +604,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { - print '' . $langs->trans("Edit") . '' . "\n"; + print '
' . $langs->trans("Edit") . '
'; - print '' . $langs->trans("CollectNow") . '' . "\n"; + // Clone + print '
' . $langs->trans("ToClone") . '
'; - print '' . $langs->trans('Delete') . '' . "\n"; + print '
' . $langs->trans("CollectNow") . '
'; + + print '
' . $langs->trans('Delete') . '
'; } print '' . "\n"; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5654b3cb37f..61608b29f09 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -164,7 +164,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); } - $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); + $result = $object->createFromClone($user, GETPOST('fk_userowner'), GETPOST('socid')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 96aaa17fdd2..b543d6790c6 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -87,14 +87,14 @@ class ActionComm extends CommonObject * @var string Agenda event label */ public $label; - + /** * Date creation record (datec) * * @var integer */ public $datec; - + /** * Date modification record (tms) * @@ -129,14 +129,14 @@ class ActionComm extends CommonObject * @var int */ public $usermodid; - + /** * Date action start (datep) * * @var integer */ public $datep; - + /** * Date action end (datep2) * @@ -504,13 +504,13 @@ class ActionComm extends CommonObject /** * Load an object from its id and create a new one in database * - * @param user $fuser Object user making action + * @param User $fuser Object user making action * @param int $socid Id of thirdparty * @return int New id of clone */ - public function createFromClone($fuser, $socid) + public function createFromClone(User $fuser, $socid) { - global $db, $user, $langs, $conf, $hookmanager; + global $db, $conf, $hookmanager; $error=0; $now=dol_now(); @@ -529,20 +529,6 @@ class ActionComm extends CommonObject $this->id=0; - if (!is_object($fuser)) - { - if ($fuser > 0) - { - $u = new User($db); - $u->fetch($fuser); - $fuser = $u; - } - else - { - $fuser = $user; - } - } - // Create clone $this->context['createfromclone']='createfromclone'; $result=$this->create($fuser); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b710ba4656b..34ed7708e9e 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -97,7 +97,7 @@ if (empty($reshook)) } else { - $result=$object->createFromClone($object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); + $result=$object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 0fd41c9dc02..d82ec07612d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -266,14 +266,15 @@ class Mailing extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @param int $option1 1=Copy content, 0=Forget content * @param int $option2 Not used * @return int New id of clone */ - public function createFromClone($fromid, $option1, $option2) + public function createFromClone(User $user, $fromid, $option1, $option2) { - global $user,$langs; + global $langs; $error=0; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 419c8cf05dd..abed072bc2c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -192,7 +192,7 @@ if (empty($reshook)) } } - $result = $object->createFromClone($socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 388433222e0..0b9863f287b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -473,7 +473,7 @@ class Propal extends CommonObject // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -690,7 +690,7 @@ class Propal extends CommonObject if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag if (empty($type)) $type=0; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -1226,12 +1226,13 @@ class Propal extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { - global $user,$conf,$hookmanager; + global $conf,$hookmanager; dol_include_once('/projet/class/project.class.php'); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9e48fd2303a..05d02c487c0 100755 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -142,7 +142,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($socid); + $result=$object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5506d8a4770..35cb8335232 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1070,10 +1070,11 @@ class Commande extends CommonOrder /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { global $conf, $user,$hookmanager; diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index dc9c1d242e8..cb74bf54ca8 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -269,13 +269,12 @@ class BankCateg // extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user; - $error = 0; $object = new BankCateg($this->db); diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 707b6586b83..d3b4bd83743 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -393,13 +393,12 @@ class PaymentTerm // extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentTerm($this->db); diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 1cb304fe519..3c2efbd6141 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -346,15 +346,14 @@ class Cchargesociales /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Cchargesociales($this->db); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index a2a6009cd6a..86dda559061 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -448,13 +448,12 @@ class PaymentSocialContribution extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentSocialContribution($this->db); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 443cf984f79..687dc2c7f2f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1072,7 +1072,7 @@ if (empty($reshook)) else { if ($object->id > 0) { - $result = $object->createFromClone($socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2cd4f472f95..87830593714 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2388,13 +2388,14 @@ class Contrat extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int New id of clone */ - public function createFromClone($socid = 0, $notrigger = 0) + public function createFromClone(User $user, $socid = 0, $notrigger = 0) { - global $db, $user, $langs, $conf, $hookmanager, $extrafields; + global $db, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 5c5e7752b49..3bd33c94c15 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -195,23 +195,6 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } } -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) -{ - $objectutil = dol_clone($object); // To avoid to denaturate loaded object when setting some properties for clone - //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - - $result = $objectutil->createFromClone($id); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); - exit(); - } else { - $langs->load("errors"); - setEventMessages($objectutil->error, $objectutil->errors, 'errors'); - $action = ''; - } -} - // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index a4eed8f8b66..0571af1d5fa 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -404,15 +404,14 @@ class Ctyperesource /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Ctyperesource($this->db); diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 2ca7ac73f08..b3daf4ade09 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -64,7 +64,7 @@ class modEmailCollector extends DolibarrModules $this->descriptionlong = "EmailCollectorDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 2caba932e40..4345385f16d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -736,13 +736,12 @@ class Cronjob extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Cronjob($this->db); diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 4ec7c4aa874..b96719e01aa 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -408,13 +408,12 @@ class PaymentDonation extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentDonation($this->db); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 4f4c8dfea61..57a18f5c339 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -707,15 +707,14 @@ class EcmFiles extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Ecmfiles($this->db); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 48535ba8f48..e6354c01105 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -171,7 +171,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - $result=$object->createFromClone(GETPOST('fk_user_author', 'int')); + $result=$object->createFromClone($user, GETPOST('fk_user_author', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 55a411cf1c7..c09d2897980 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -314,12 +314,13 @@ class ExpenseReport extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fk_user_author Id of new user - * @return int New id of clone + * @param User $user User making the clone + * @param int $fk_user_author Id of new user + * @return int New id of clone */ - public function createFromClone($fk_user_author) + public function createFromClone(User $user, $fk_user_author) { - global $user,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index f731638ea1d..deec87887d7 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -414,13 +414,12 @@ class PaymentExpenseReport extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentExpenseReport($this->db); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 47e7dd48589..20d9d786354 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -134,7 +134,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($socid); + $result=$object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index db0ae47f7d2..807b547a4bc 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1144,12 +1144,13 @@ class Fichinter extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { - global $user,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f29fab91e45..f1910c5ab38 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1409,11 +1409,12 @@ class CommandeFournisseur extends CommonOrder /** * Load an object from its id and create a new one in database * - * @return int New id of clone + * @param User $user User making the clone + * @return int New id of clone */ - public function createFromClone() + public function createFromClone(User $user) { - global $conf,$user,$langs,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 6db4607573c..14c114efdbf 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -472,13 +472,12 @@ class CommandeFournisseurDispatch extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Commandefournisseurdispatch($this->db); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7ce9a57f92b..876265d8dcb 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -955,7 +955,7 @@ $result = $object->updateline( { if ($object->id > 0) { - $result=$object->createFromClone(); + $result=$object->createFromClone($user); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d884278028f..24453159a23 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1829,6 +1829,7 @@ MailboxSourceDirectory=Mailbox source directory MailboxTargetDirectory=Mailbox target directory EmailcollectorOperations=Operations to do by collector CollectNow=Collect now +ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ? DateLastCollectResult=Date latest collect tried DateLastcollectResultOk=Date latest collect successfull LastResult=Latest result diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index aac30bce813..4b1e5232abb 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -327,13 +327,12 @@ class Productbatch extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Productbatch($this->db); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 424cb8ce39b..8405120ddef 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -895,14 +895,12 @@ class Productcustomerprice extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid of object to clone - * @return int id of clone + * @param User $user User making the clone + * @param int $fromid ID of object to clone + * @return int id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - - global $user, $langs; - $error = 0; $object = new Productcustomerprice($this->db); diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index 0882490446d..2d350eb0c77 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -560,13 +560,12 @@ class Propalmergepdfproduct extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Propalmergepdfproduct($this->db); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9dc1856c64e..f3cec8f9a98 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -426,15 +426,14 @@ class Productlot extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Productlot($this->db); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 36e302bf661..0cbedb6d347 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -420,15 +420,14 @@ class ProductStockEntrepot extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new ProductStockEntrepot($this->db); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7023f2d871e..c1e40b9ffec 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -429,7 +429,7 @@ if (empty($reshook)) $move_date=GETPOST('move_date')?1:0; $clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0; - $result=$object->createFromClone($object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); + $result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 59d24e5eb3d..09eadbbc8ea 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1274,20 +1274,21 @@ class Project extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @param bool $clone_contact Clone contact of project - * @param bool $clone_task Clone task of project - * @param bool $clone_project_file Clone file of project - * @param bool $clone_task_file Clone file of task (if task are copied) - * @param bool $clone_note Clone note of project - * @param bool $move_date Move task date on clone - * @param integer $notrigger No trigger flag - * @param int $newthirdpartyid New thirdparty id - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @param bool $clone_contact Clone contact of project + * @param bool $clone_task Clone task of project + * @param bool $clone_project_file Clone file of project + * @param bool $clone_task_file Clone file of task (if task are copied) + * @param bool $clone_note Clone note of project + * @param bool $move_date Move task date on clone + * @param integer $notrigger No trigger flag + * @param int $newthirdpartyid New thirdparty id + * @return int New id of clone */ - public function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) + public function createFromClone(User $user, $fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) { - global $user,$langs,$conf; + global $langs,$conf; $error=0; @@ -1477,7 +1478,7 @@ class Project extends CommonObject // Loop on each task, to clone it foreach ($tasksarray as $tasktoclone) { - $result_clone = $taskstatic->createFromClone($tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); + $result_clone = $taskstatic->createFromClone($user, $tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); if ($result_clone <= 0) { $this->error.=$result_clone->error; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 8c12131ce50..a5f63e32826 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1587,6 +1587,7 @@ class Task extends CommonObject /** Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @param int $project_id Id of project to attach clone task * @param int $parent_task_id Id of task to attach clone task @@ -1598,9 +1599,9 @@ class Task extends CommonObject * @param bool $clone_prog clone progress of project * @return int New id of clone */ - public function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) + public function createFromClone(User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { - global $user,$langs,$conf; + global $langs,$conf; $error=0; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1701a95af73..59df170c9ef 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -136,7 +136,7 @@ if (empty($reshook)) else { if ($object->id > 0) { - $result = $object->createFromClone($socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 0b72b7daf2c..ca16348dcd6 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1117,12 +1117,13 @@ class SupplierProposal extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $fromid = 0) { - global $user,$langs,$conf,$hookmanager; + global $conf,$hookmanager; $error=0; $now=dol_now(); @@ -1139,9 +1140,9 @@ class SupplierProposal extends CommonObject $objsoc=new Societe($this->db); // Change socid if needed - if (! empty($socid) && $socid != $this->socid) + if (! empty($fromid) && $fromid != $this->socid) { - if ($objsoc->fetch($socid) > 0) + if ($objsoc->fetch($fromid) > 0) { $this->socid = $objsoc->id; $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 0c2cc91dea4..cab2eab92ed 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -950,13 +950,12 @@ class Ticket extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param User $user User that clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user, $langs; - $error = 0; $object = new Ticket($this->db); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 6bbfb6ac472..a12bb2ebf11 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -519,7 +519,7 @@ class Website extends CommonObject */ public function createFromClone($user, $fromid, $newref, $newlang = '') { - global $conf, $hookmanager, $langs; + global $conf, $hookmanager; global $dolibarr_main_data_root; $now = dol_now();