diff --git a/front/processmaker.form.php b/front/processmaker.form.php index edd9106..5f44cb5 100644 --- a/front/processmaker.form.php +++ b/front/processmaker.form.php @@ -85,7 +85,7 @@ switch ($_POST["action"]) { } else if (isset($_POST['reassign'])) { // here we should re-assign the current task to $_POST['users_id_recipient'] //$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] ); - if ($_POST['users_id'] != $_POST['users_id_recipient']) { // normally should be different as of the dropdown prevents already used + if ($_POST['users_id'] != $_POST['users_id_recipient'] && $_POST['users_id_recipient'] != 0) { // normally should be different as of the dropdown prevents already used $locCase = new PluginProcessmakerCase; $locCase->getFromDB($_POST['cases_id']); @@ -100,7 +100,13 @@ switch ($_POST["action"]) { Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR); } } else { - Session::addMessageAfterRedirect(__('Task already assigned to this person!', 'processmaker'), true, ERROR); + if ($_POST['users_id_recipient'] == 0) { + Session::addMessageAfterRedirect(__('Can\'t un-assign Task!', 'processmaker'), true, ERROR); + } else { + if ($_POST['users_id'] === $_POST['users_id_recipient'] ) { // normally should be different as of the dropdown prevents already used + Session::addMessageAfterRedirect(__('Task already assigned to this person!', 'processmaker'), true, ERROR); + } + } } //} else if (isset($_POST['delete'])) { // // delete case from case table, this will also delete the tasks diff --git a/inc/case.class.php b/inc/case.class.php index 6ba292a..de22142 100644 --- a/inc/case.class.php +++ b/inc/case.class.php @@ -232,10 +232,13 @@ class PluginProcessmakerCase extends CommonDBTM { */ function reassignCase($delIndex, $taskGuid, $delThread, $users_id_source, $users_id_target) { global $PM_SOAP; - $users_guid_source = PluginProcessmakerUser::getPMUserId($users_id_source); + $users_guid_source = ''; // by default + if ($users_id_source !== 0) { // when task is not 'to be claimed' + $users_guid_source = PluginProcessmakerUser::getPMUserId($users_id_source); + } $users_guid_target = PluginProcessmakerUser::getPMUserId($users_id_target); $pmResponse = $PM_SOAP->reassignCase($this->fields['case_guid'], $delIndex, $users_guid_source, $users_guid_target); - // now should managed GLPI Tasks previously assigned to the $users_guid_source + // now should manage GLPI Tasks previously assigned to the $users_guid_source if ($pmResponse->status_code == 0) { // we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks // we need the delindex of the current glpi task, and the delindex of the new one @@ -279,7 +282,11 @@ class PluginProcessmakerCase extends CommonDBTM { PluginProcessmakerProcessmaker::addWatcher( $itilobject_itemtype, $glpi_task->fields[ $foreignkey ], $newTech ); $donotif = PluginProcessmakerNotificationTargetProcessmaker::saveNotificationState(false); // do not send notification yet - $glpi_task->update( ['id' => $glpi_task->getID(), $foreignkey => $glpi_task->fields[$foreignkey], 'users_id_tech' => $newTech, 'update' => true] ); + $glpi_task->update( ['id' => $glpi_task->getID(), + $foreignkey => $glpi_task->fields[$foreignkey], + 'users_id_tech' => $newTech, + 'groups_id_tech' => 0, + 'update' => true] ); PluginProcessmakerNotificationTargetProcessmaker::restoreNotificationState($donotif); // Notification management diff --git a/inc/notificationtargettask.class.php b/inc/notificationtargettask.class.php index 948be21..3932b1c 100644 --- a/inc/notificationtargettask.class.php +++ b/inc/notificationtargettask.class.php @@ -105,6 +105,9 @@ class PluginProcessmakerNotificationTargetTask extends PluginProcessmakerNotific // task information $taskobj = $this->obj; + // del index + $this->data['##task.delindex##'] = $taskobj->fields['del_index']; + // is private? $this->data['##task.isprivate##'] = Dropdown::getYesNo(false); if ($taskobj->maybePrivate()) { @@ -175,7 +178,8 @@ class PluginProcessmakerNotificationTargetTask extends PluginProcessmakerNotific 'task.end' => __('End date'), 'task.status' => __('Status'), 'task.lastupdater' => __('Last updater'), - 'task.update' => __('Last update') + 'task.update' => __('Last update'), + 'task.delindex' => __('Delegation index') ]; foreach ($tags as $tag => $label) { $elt= ['tag' => $tag, diff --git a/inc/processmaker.class.php b/inc/processmaker.class.php index dede130..99e9952 100644 --- a/inc/processmaker.class.php +++ b/inc/processmaker.class.php @@ -2913,6 +2913,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $casevariables = ["GLPI_ITEM_TASK_CONTENT", "GLPI_ITEM_APPEND_TO_TASK", "GLPI_NEXT_GROUP_TO_BE_ASSIGNED", + "GLPI_ITEM_TASK_GROUP", "GLPI_ITEM_TITLE", "GLPI_TICKET_FOLLOWUP_CONTENT", "GLPI_ITEM_FOLLOWUP_CONTENT", @@ -2971,6 +2972,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { if (array_key_exists( 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED', $casevariablevalues )) { $groupId = $casevariablevalues[ 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' ]; } + if (array_key_exists( 'GLPI_ITEM_TASK_GROUP', $casevariablevalues )) { + $groupId = $casevariablevalues[ 'GLPI_ITEM_TASK_GROUP' ]; + } $taskStartDate = ''; $taskEndDate = ''; @@ -3237,16 +3241,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } } - // send email if requested - if (is_array($sendemail)) { - NotificationEvent::raiseEvent('send_email', - $myCase, - ['glpi_send_email' => $sendemail, - 'case' => $myCase - ]); - } - - } + } } else { // must check if current case is a sub-process, and if it has ended, then must reflect parent case into the current item. @@ -3278,7 +3273,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $parentCaseInfo, $open_task->delIndex, PluginProcessmakerUser::getGLPIUserId($open_task->userId), - 0, + $groupId, $open_task->taskId, $open_task->delThread, [ 'txtTaskContent' => $txtTaskContent, @@ -3289,7 +3284,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { // if end date was specified, then must change due date of the PM task if ($taskEndDate != '') { - $PM_DB->update('APP_DELEGATION', ['DEL_TASK_DUE_DATE' => $taskEndDate], ['AND' => ['APP_UID' => $sub_caseInfo->caseId, 'DEL_INDEX' => $open_task->delIndex]]); + $PM_DB->update('APP_DELEGATION', ['DEL_TASK_DUE_DATE' => $taskEndDate], ['AND' => ['APP_UID' => $parentCaseInfo->caseId, 'DEL_INDEX' => $open_task->delIndex]]); //$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$sub_caseInfo->caseId."' AND DEL_INDEX=".$open_task->delIndex); } } diff --git a/inc/profile.class.php b/inc/profile.class.php index b1c2fe0..a53a16c 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -20,7 +20,7 @@ class PluginProcessmakerProfile extends CommonDBTM { ['itemtype' => 'PluginProcessmakerConfig', 'label' => __('Cases', 'processmaker'), 'field' => 'plugin_processmaker_case', - 'rights' => [READ => __('Read'), CANCEL => __('Cancel', 'processmaker'), DELETE => __('Delete')]] + 'rights' => [READ => __('Read'), CANCEL => __('Cancel', 'processmaker'), DELETE => __('Delete'), ADHOC_REASSIGN => __('Ad Hoc user re-assign', 'processmaker')]] ]; return $rights; @@ -69,7 +69,7 @@ class PluginProcessmakerProfile extends CommonDBTM { * @param mixed $ID */ static function createAdminAccess($ID) { - self::addDefaultProfileInfos($ID, ['plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_case' => READ + DELETE + CANCEL], true); + self::addDefaultProfileInfos($ID, ['plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_case' => READ + DELETE + CANCEL + ADHOC_REASSIGN], true); } /** diff --git a/inc/task.class.php b/inc/task.class.php index e7c43cc..9c2f214 100644 --- a/inc/task.class.php +++ b/inc/task.class.php @@ -377,8 +377,8 @@ class PluginProcessmakerTask extends CommonITILTask } if (isset($currentUser)) { - if ($currentUser->userId && $task[$tabnum]['del_index']) { - // to load users for task re-assign only when task is not to be 'claimed' and if task is not a sub-case + if (/*$currentUser->userId &&*/ $task[$tabnum]['del_index']) { + // to load users for task re-assign only when task is not a sub-case echo "