Skip to content

Commit

Permalink
Fixed issue with criteria in getProcessesWithCategoryAndProfile that …
Browse files Browse the repository at this point in the history
…prevents correct list of processes

Fixed issue with too much processes in getProcessesWithCategoryAndProfile
Fixed deprecated use of fetch_assoc
Replaced $_POST and $_GET by $_REQUEST
  • Loading branch information
tomolimo committed Jun 23, 2021
1 parent 6ac90bf commit 2d29fa5
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 223 deletions.
2 changes: 1 addition & 1 deletion ajax/task_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$grp = false;
$query = "SELECT TAS_GROUP_VARIABLE FROM TASK WHERE TAS_UID='".$_REQUEST['taskGuid']."' AND TAS_ASSIGN_TYPE='SELF_SERVICE';";
$res = $PM_DB->query($query);
if ($PM_DB->numrows($res) > 0 && $row = $PM_DB->fetch_assoc($res)) {
if ($PM_DB->numrows($res) > 0 && $row = $PM_DB->fetchAssoc($res)) {
$can_unclaim = true;
if ($row['TAS_GROUP_VARIABLE'] != '') {
//self-service value based assignment
Expand Down
252 changes: 126 additions & 126 deletions front/processmaker.form.php
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
<?php
include_once ("../../../inc/includes.php");

switch ($_POST["action"]) {
case 'newcase':
if (isset($_POST['items_id']) && $_POST['items_id'] > 0) {

// then this case will be bound to an item
if ($_POST['plugin_processmaker_processes_id'] > 0) {

$resultCase = $PM_SOAP->startNewCase($_POST['plugin_processmaker_processes_id'], $_POST['itemtype'], $_POST['items_id'], Session::getLoginUserID());

if ($resultCase->status_code == 0) {
$case = new PluginProcessmakerCase;
if ($case->getFromGUID($resultCase->caseId)) {
$link = $case->getLinkURL();
$task = new PluginProcessmakerTask($_POST['itemtype'].'Task');

$task->getFromDBByRequest([
'WHERE' => [
'plugin_processmaker_cases_id' => $case->getID()
],
]);


//$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task
//$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID();

Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']);
$item = new $_POST['itemtype'];
$item->getFromDB($_POST['items_id']);
unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList
Session::initNavigateListItems('PluginProcessmakerCase',
//TRANS : %1$s is the itemtype name,
// %2$s is the name of the item (used for headings of a list)
sprintf('%1$s = %2$s',
$_POST['itemtype']::getTypeName(1), $item->fields["name"]));
Html::redirect($link);
}
Html::back();
} else {
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
}
} else {
Html::back();
}
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
$resultCase = $PM_SOAP->newCase( $_POST['plugin_processmaker_processes_id'],
['GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_ITEM_TYPE' => 'Ticket',
'GLPI_URL' => $CFG_GLPI['url_base'],
// Specific to Tickets
// GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request)
'GLPI_TICKET_TYPE' => $_POST['type'],
'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(),
'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid
] );
if ($resultCase->status_code == 0) {
// case is created
// Must show it...
//
$rand = rand( );
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?processes_id=".$_POST['plugin_processmaker_processes_id']."&case_guid=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_POST["type"]."&entities_id=".$_POST['entities_id']);

} else {
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR);
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
}

}
break;

case 'reassign_reminder' :
if (isset($_POST['reassign'])) {
// here we should re-assign the current task to $_POST['users_id_recipient']
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_POST['cases_id']);
if ($_POST['users_id_recipient'] != 0) {
// we are assigning a new tech to a task
$pmResponse = $locCase->reassignCase($_POST['delIndex'],
$_POST['taskGuid'],
$_POST['delThread'],
$_POST['users_id'],
$_POST['users_id_recipient'],
['comment' => $_POST['comment']]);
if ($pmResponse) {
Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO);
} else {
Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR);
}
} elseif ($_POST['users_id_recipient'] == 0) {
// we are unassigning a task, i.e.: task un-claim
$pmResponse = $locCase->unassignCase($_POST['delIndex'],
$_POST['taskGuid'],
$_POST['tasktype'],
$_POST['tasks_id'],
$_POST['itemtype'],
['comment' => $_POST['comment']]);
if ($pmResponse) {
Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO);
} else {
Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR);
}
}
} elseif (isset($_POST['reminder'])) {
// send notification remider as requested for this task

$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_POST['cases_id']);
$glpi_item = new $_POST['itemtype'];
$glpi_item->getFromDB($_POST['items_id']);
$pm_task = new PluginProcessmakerTask($_POST['tasktype']);
$pm_task->getFromDB($_POST['tasks_id']);
$glpi_task = new $_POST['tasktype'];
$glpi_task->getFromDB($_POST['tasks_id']);

// send notification now!
$pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase);
}
}

// to return to item
Html::back();

<?php
include_once ("../../../inc/includes.php");

switch ($_REQUEST["action"]) {
case 'newcase':
if (isset($_REQUEST['items_id']) && $_REQUEST['items_id'] > 0) {

// then this case will be bound to an item
if ($_REQUEST['plugin_processmaker_processes_id'] > 0) {

$resultCase = $PM_SOAP->startNewCase($_REQUEST['plugin_processmaker_processes_id'], $_REQUEST['itemtype'], $_REQUEST['items_id'], Session::getLoginUserID());

if ($resultCase->status_code == 0) {
$case = new PluginProcessmakerCase;
if ($case->getFromGUID($resultCase->caseId)) {
$link = $case->getLinkURL();
$task = new PluginProcessmakerTask($_REQUEST['itemtype'].'Task');

$task->getFromDBByRequest([
'WHERE' => [
'plugin_processmaker_cases_id' => $case->getID()
],
]);


//$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task
//$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID();

Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']);
$item = new $_REQUEST['itemtype'];
$item->getFromDB($_REQUEST['items_id']);
unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList
Session::initNavigateListItems('PluginProcessmakerCase',
//TRANS : %1$s is the itemtype name,
// %2$s is the name of the item (used for headings of a list)
sprintf('%1$s = %2$s',
$_REQUEST['itemtype']::getTypeName(1), $item->fields["name"]));
Html::redirect($link);
}
Html::back();
} else {
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
}
} else {
Html::back();
}
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
$resultCase = $PM_SOAP->newCase( $_REQUEST['plugin_processmaker_processes_id'],
['GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_ITEM_TYPE' => 'Ticket',
'GLPI_URL' => $CFG_GLPI['url_base'],
// Specific to Tickets
// GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request)
'GLPI_TICKET_TYPE' => $_REQUEST['type'],
'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(),
'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid
] );
if ($resultCase->status_code == 0) {
// case is created
// Must show it...
//
$rand = rand( );
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?processes_id=".$_REQUEST['plugin_processmaker_processes_id']."&case_guid=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_REQUEST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);

} else {
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR);
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
}

}
break;

case 'reassign_reminder' :
if (isset($_REQUEST['reassign'])) {
// here we should re-assign the current task to $_REQUEST['users_id_recipient']
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_REQUEST['cases_id']);
if ($_REQUEST['users_id_recipient'] != 0) {
// we are assigning a new tech to a task
$pmResponse = $locCase->reassignCase($_REQUEST['delIndex'],
$_REQUEST['taskGuid'],
$_REQUEST['delThread'],
$_REQUEST['users_id'],
$_REQUEST['users_id_recipient'],
['comment' => $_REQUEST['comment']]);
if ($pmResponse) {
Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO);
} else {
Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR);
}
} elseif ($_REQUEST['users_id_recipient'] == 0) {
// we are unassigning a task, i.e.: task un-claim
$pmResponse = $locCase->unassignCase($_REQUEST['delIndex'],
$_REQUEST['taskGuid'],
$_REQUEST['tasktype'],
$_REQUEST['tasks_id'],
$_REQUEST['itemtype'],
['comment' => $_REQUEST['comment']]);
if ($pmResponse) {
Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO);
} else {
Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR);
}
}
} elseif (isset($_REQUEST['reminder'])) {
// send notification remider as requested for this task

$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_REQUEST['cases_id']);
$glpi_item = new $_REQUEST['itemtype'];
$glpi_item->getFromDB($_REQUEST['items_id']);
$pm_task = new PluginProcessmakerTask($_REQUEST['tasktype']);
$pm_task->getFromDB($_REQUEST['tasks_id']);
$glpi_task = new $_REQUEST['tasktype'];
$glpi_task->getFromDB($_REQUEST['tasks_id']);

// send notification now!
$pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase);
}
}

// to return to item
Html::back();
24 changes: 12 additions & 12 deletions front/processmaker.helpdesk.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function processMakerShowCase($users_id, $from_helpdesk) {

$tkt = new Ticket;

// as showFormHelpdesk uses $_POST, we must set it
$_POST = $_REQUEST;
// as showFormHelpdesk uses $_REQUEST, we must set it
$_REQUEST = $_REQUEST;

//// must be using bare text
//$save_rich_text = $CFG_GLPI["use_rich_text"];
Expand Down Expand Up @@ -189,9 +189,9 @@ function in_array_recursive($needle, $haystack) {


// Change profile system
if (isset($_POST['newprofile'])) {
if (isset($_SESSION["glpiprofiles"][$_POST['newprofile']])) {
Session::changeProfile($_POST['newprofile']);
if (isset($_REQUEST['newprofile'])) {
if (isset($_SESSION["glpiprofiles"][$_REQUEST['newprofile']])) {
Session::changeProfile($_REQUEST['newprofile']);

if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
Html::redirect($CFG_GLPI['root_doc']."/front/central.php");
Expand All @@ -205,20 +205,20 @@ function in_array_recursive($needle, $haystack) {
}

// Manage entity change
if (isset($_GET["active_entity"])) {
if (!isset($_GET["is_recursive"])) {
$_GET["is_recursive"] = 0;
if (isset($_REQUEST["active_entity"])) {
if (!isset($_REQUEST["is_recursive"])) {
$_REQUEST["is_recursive"] = 0;
}
if (Session::changeActiveEntities($_GET["active_entity"], $_GET["is_recursive"])) {
if ($_GET["active_entity"] == $_SESSION["glpiactive_entity"]) {
if (Session::changeActiveEntities($_REQUEST["active_entity"], $_REQUEST["is_recursive"])) {
if ($_REQUEST["active_entity"] == $_SESSION["glpiactive_entity"]) {
Html::redirect(preg_replace("/entities_id.*/", "", $_SERVER['HTTP_REFERER']));
}
}
}

// Redirect management
if (isset($_GET["redirect"])) {
Toolbox::manageRedirect($_GET["redirect"]);
if (isset($_REQUEST["redirect"])) {
Toolbox::manageRedirect($_REQUEST["redirect"]);
}

// redirect if no create ticket right
Expand Down
Loading

0 comments on commit 2d29fa5

Please sign in to comment.