Clean code

This commit is contained in:
Laurent Destailleur 2018-06-19 08:51:25 +02:00
parent 75dee7538b
commit e402f68593
4 changed files with 39 additions and 7 deletions

View File

@ -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='';
}
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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';
}