add doaction to actioncommcard

This commit is contained in:
Frédéric FRANCE 2019-09-17 08:15:01 +02:00
parent 6c078bdcb0
commit 0d63c43ccd
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -86,6 +86,18 @@ $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formactions = new FormActions($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 // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $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 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('actioncard','globalcard')); $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 * Actions
@ -101,7 +116,7 @@ $hookmanager->initHooks(array('actioncard','globalcard'));
$listUserAssignedUpdated = false; $listUserAssignedUpdated = false;
// Remove user to assigned list // Remove user to assigned list
if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0'))
{ {
$idtoremove=GETPOST('removedassigned'); $idtoremove=GETPOST('removedassigned');
@ -122,7 +137,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
} }
// Add user to assigned list // Add user to assigned list
if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')))
{ {
// Add a new user // Add a new user
if (GETPOST('assignedtouser') > 0) if (GETPOST('assignedtouser') > 0)
@ -143,15 +158,15 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
} }
// Link to a project // 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->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)))
{ {
$object->fetch($id); //$object->fetch($id);
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
} }
// Action clone object // 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')) if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
@ -160,7 +175,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
else else
{ {
if ($id > 0) { if ($id > 0) {
$object->fetch($id); //$object->fetch($id);
if (!empty($object->socpeopleassigned)) { if (!empty($object->socpeopleassigned)) {
reset($object->socpeopleassigned); reset($object->socpeopleassigned);
$object->contactid = key($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned);
@ -178,7 +193,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
} }
// Add event // Add event
if ($action == 'add') if (empty($reshook) && $action == 'add')
{ {
$error=0; $error=0;
@ -403,7 +418,7 @@ if ($action == 'add')
/* /*
* Action update event * Action update event
*/ */
if ($action == 'update') if (empty($reshook) && $action == 'update')
{ {
if (empty($cancel)) if (empty($cancel))
{ {
@ -420,8 +435,8 @@ if ($action == 'update')
if ($p2hour == -1) $p2hour='0'; if ($p2hour == -1) $p2hour='0';
if ($p2min == -1) $p2min='0'; if ($p2min == -1) $p2min='0';
$object->fetch($id); //$object->fetch($id);
$object->fetch_userassigned(); //$object->fetch_userassigned();
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $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"]); $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 * 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 if ($user->rights->agenda->myactions->delete
|| $user->rights->agenda->allactions->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 * 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. * 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($id);
$object->fetch_userassigned(); //$object->fetch_userassigned();
$shour = dol_print_date($object->datep, "%H"); $shour = dol_print_date($object->datep, "%H");
$smin = dol_print_date($object->datep, "%M"); $smin = dol_print_date($object->datep, "%M");
@ -614,7 +629,9 @@ if (GETPOST('actionmove', 'alpha') == 'mupdate')
// Actions to delete doc // Actions to delete doc
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $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)); $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';
}
/* /*