diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 394680f4d8e..e0badfb9530 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/actions_addupdatedelete.inc.php - * \brief Code for common actions cancel / add / update / delete + * \brief Code for common actions cancel / add / update / delete / clone */ @@ -183,3 +183,33 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) else setEventMessages($object->error, null, 'errors'); } } + +// Action clone object +if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) +{ + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); + } + else + { + if ($object->id > 0) + { + // Because createFromClone modifies the object, we must clone it so that we can restore it later + $orig = clone $object; + + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $object = $orig; + $action=''; + } + } + } +} diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 9e2e48ce6cf..6648e63bc6d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -123,9 +123,9 @@ if (empty($reshook)) $permissiontodelete = $user->rights->mymodule->delete; if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__'; $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); - $triggermodname = 'MYMODULE_MODIFY'; + $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record - // Actions cancel, add, update or delete + // Actions cancel, add, update, delete or clone include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; // Actions when printing a doc from card diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 1f47ce11247..9207ea02860 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -80,12 +80,15 @@ $result = restrictedArea($user, 'ticket', $object->id); $triggermodname = 'TICKETSUP_MODIFY'; $permissiontoadd = $user->rights->ticket->write; +$actionobject = new ActionsTicket($db); /* * Actions */ +// TODO Replace actions with common includes actions_addupdatedelete.inc.php + if ($cancel) { if (! empty($backtopage)) @@ -96,8 +99,7 @@ if ($cancel) $action=''; } - -$actionobject = new ActionsTicket($db); +// Do action $actionobject->doActions($action, $object); // Action to update one extrafield diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index d62adfb063b..a4cf96c9338 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -106,8 +106,8 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='MYOBJECT_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trigger_name='WEBSITEACCOUNT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO'; $trackid='websiteaccount'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; }