From 0d63c43ccd239b116b9c0283ddd79ec29f911570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 08:15:01 +0200 Subject: [PATCH 1/2] add doaction to actioncommcard --- htdocs/comm/action/card.php | 49 +++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 003203940a8..31b2f22a194 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -86,6 +86,18 @@ $form = new Form($db); $formfile = new FormFile($db); $formactions = new FormActions($db); +// Load object +if ($id > 0 && $action!='add') { + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } +} + // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); @@ -94,6 +106,9 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('actioncard','globalcard')); +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); /* * Actions @@ -101,7 +116,7 @@ $hookmanager->initHooks(array('actioncard','globalcard')); $listUserAssignedUpdated = false; // Remove user to assigned list -if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') +if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) { $idtoremove=GETPOST('removedassigned'); @@ -122,7 +137,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') } // Add user to assigned list -if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) +if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) { // Add a new user if (GETPOST('assignedtouser') > 0) @@ -143,15 +158,15 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) } // Link to a project -if ($action == 'classin' && ($user->rights->agenda->allactions->create || +if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { - $object->fetch($id); + //$object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') +if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -160,7 +175,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') else { if ($id > 0) { - $object->fetch($id); + //$object->fetch($id); if (!empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); @@ -178,7 +193,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Add event -if ($action == 'add') +if (empty($reshook) && $action == 'add') { $error=0; @@ -403,7 +418,7 @@ if ($action == 'add') /* * Action update event */ -if ($action == 'update') +if (empty($reshook) && $action == 'update') { if (empty($cancel)) { @@ -420,8 +435,8 @@ if ($action == 'update') if ($p2hour == -1) $p2hour='0'; if ($p2min == -1) $p2min='0'; - $object->fetch($id); - $object->fetch_userassigned(); + //$object->fetch($id); + //$object->fetch_userassigned(); $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -546,9 +561,9 @@ if ($action == 'update') /* * delete event */ -if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') +if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { - $object->fetch($id); + //$object->fetch($id); if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) @@ -571,10 +586,10 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') * Action move update, used when user move an event in calendar by drag'n drop * TODO Move this into page comm/action/index that trigger this call by the drag and drop of event. */ -if (GETPOST('actionmove', 'alpha') == 'mupdate') +if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $object->fetch($id); - $object->fetch_userassigned(); + //$object->fetch($id); + //$object->fetch_userassigned(); $shour = dol_print_date($object->datep, "%H"); $smin = dol_print_date($object->datep, "%M"); @@ -614,7 +629,9 @@ if (GETPOST('actionmove', 'alpha') == 'mupdate') // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissioncreate = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); -include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; +if (empty($reshook) { + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; +} /* From 155e8fb50083934adca79862db73d0de76d137b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 08:18:01 +0200 Subject: [PATCH 2/2] fix syntax --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 31b2f22a194..6418869bf1d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -629,7 +629,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissioncreate = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); -if (empty($reshook) { +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; }