Merge pull request #11913 from frederic34/actioncommcarddoaction
add doaction to actioncommcard
This commit is contained in:
commit
f90bfb54d4
@ -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"]);
|
||||
@ -605,9 +620,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)
|
||||
@ -630,10 +645,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");
|
||||
@ -673,7 +688,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';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user