Skip to content

Commit 2d29fa5

Browse files
committed
Fixed issue with criteria in getProcessesWithCategoryAndProfile that 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
1 parent 6ac90bf commit 2d29fa5

7 files changed

+226
-223
lines changed

ajax/task_users.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$grp = false;
4343
$query = "SELECT TAS_GROUP_VARIABLE FROM TASK WHERE TAS_UID='".$_REQUEST['taskGuid']."' AND TAS_ASSIGN_TYPE='SELF_SERVICE';";
4444
$res = $PM_DB->query($query);
45-
if ($PM_DB->numrows($res) > 0 && $row = $PM_DB->fetch_assoc($res)) {
45+
if ($PM_DB->numrows($res) > 0 && $row = $PM_DB->fetchAssoc($res)) {
4646
$can_unclaim = true;
4747
if ($row['TAS_GROUP_VARIABLE'] != '') {
4848
//self-service value based assignment

front/processmaker.form.php

+126-126
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,126 @@
1-
<?php
2-
include_once ("../../../inc/includes.php");
3-
4-
switch ($_POST["action"]) {
5-
case 'newcase':
6-
if (isset($_POST['items_id']) && $_POST['items_id'] > 0) {
7-
8-
// then this case will be bound to an item
9-
if ($_POST['plugin_processmaker_processes_id'] > 0) {
10-
11-
$resultCase = $PM_SOAP->startNewCase($_POST['plugin_processmaker_processes_id'], $_POST['itemtype'], $_POST['items_id'], Session::getLoginUserID());
12-
13-
if ($resultCase->status_code == 0) {
14-
$case = new PluginProcessmakerCase;
15-
if ($case->getFromGUID($resultCase->caseId)) {
16-
$link = $case->getLinkURL();
17-
$task = new PluginProcessmakerTask($_POST['itemtype'].'Task');
18-
19-
$task->getFromDBByRequest([
20-
'WHERE' => [
21-
'plugin_processmaker_cases_id' => $case->getID()
22-
],
23-
]);
24-
25-
26-
//$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task
27-
//$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID();
28-
29-
Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']);
30-
$item = new $_POST['itemtype'];
31-
$item->getFromDB($_POST['items_id']);
32-
unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList
33-
Session::initNavigateListItems('PluginProcessmakerCase',
34-
//TRANS : %1$s is the itemtype name,
35-
// %2$s is the name of the item (used for headings of a list)
36-
sprintf('%1$s = %2$s',
37-
$_POST['itemtype']::getTypeName(1), $item->fields["name"]));
38-
Html::redirect($link);
39-
}
40-
Html::back();
41-
} else {
42-
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
43-
}
44-
} else {
45-
Html::back();
46-
}
47-
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
48-
$pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
49-
$resultCase = $PM_SOAP->newCase( $_POST['plugin_processmaker_processes_id'],
50-
['GLPI_ITEM_CAN_BE_SOLVED' => 0,
51-
'GLPI_SELFSERVICE_CREATED' => '1',
52-
'GLPI_ITEM_TYPE' => 'Ticket',
53-
'GLPI_URL' => $CFG_GLPI['url_base'],
54-
// Specific to Tickets
55-
// GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request)
56-
'GLPI_TICKET_TYPE' => $_POST['type'],
57-
'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(),
58-
'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid
59-
] );
60-
if ($resultCase->status_code == 0) {
61-
// case is created
62-
// Must show it...
63-
//
64-
$rand = rand( );
65-
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']);
66-
67-
} else {
68-
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR);
69-
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
70-
}
71-
72-
}
73-
break;
74-
75-
case 'reassign_reminder' :
76-
if (isset($_POST['reassign'])) {
77-
// here we should re-assign the current task to $_POST['users_id_recipient']
78-
$locCase = new PluginProcessmakerCase;
79-
$locCase->getFromDB($_POST['cases_id']);
80-
if ($_POST['users_id_recipient'] != 0) {
81-
// we are assigning a new tech to a task
82-
$pmResponse = $locCase->reassignCase($_POST['delIndex'],
83-
$_POST['taskGuid'],
84-
$_POST['delThread'],
85-
$_POST['users_id'],
86-
$_POST['users_id_recipient'],
87-
['comment' => $_POST['comment']]);
88-
if ($pmResponse) {
89-
Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO);
90-
} else {
91-
Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR);
92-
}
93-
} elseif ($_POST['users_id_recipient'] == 0) {
94-
// we are unassigning a task, i.e.: task un-claim
95-
$pmResponse = $locCase->unassignCase($_POST['delIndex'],
96-
$_POST['taskGuid'],
97-
$_POST['tasktype'],
98-
$_POST['tasks_id'],
99-
$_POST['itemtype'],
100-
['comment' => $_POST['comment']]);
101-
if ($pmResponse) {
102-
Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO);
103-
} else {
104-
Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR);
105-
}
106-
}
107-
} elseif (isset($_POST['reminder'])) {
108-
// send notification remider as requested for this task
109-
110-
$locCase = new PluginProcessmakerCase;
111-
$locCase->getFromDB($_POST['cases_id']);
112-
$glpi_item = new $_POST['itemtype'];
113-
$glpi_item->getFromDB($_POST['items_id']);
114-
$pm_task = new PluginProcessmakerTask($_POST['tasktype']);
115-
$pm_task->getFromDB($_POST['tasks_id']);
116-
$glpi_task = new $_POST['tasktype'];
117-
$glpi_task->getFromDB($_POST['tasks_id']);
118-
119-
// send notification now!
120-
$pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase);
121-
}
122-
}
123-
124-
// to return to item
125-
Html::back();
126-
1+
<?php
2+
include_once ("../../../inc/includes.php");
3+
4+
switch ($_REQUEST["action"]) {
5+
case 'newcase':
6+
if (isset($_REQUEST['items_id']) && $_REQUEST['items_id'] > 0) {
7+
8+
// then this case will be bound to an item
9+
if ($_REQUEST['plugin_processmaker_processes_id'] > 0) {
10+
11+
$resultCase = $PM_SOAP->startNewCase($_REQUEST['plugin_processmaker_processes_id'], $_REQUEST['itemtype'], $_REQUEST['items_id'], Session::getLoginUserID());
12+
13+
if ($resultCase->status_code == 0) {
14+
$case = new PluginProcessmakerCase;
15+
if ($case->getFromGUID($resultCase->caseId)) {
16+
$link = $case->getLinkURL();
17+
$task = new PluginProcessmakerTask($_REQUEST['itemtype'].'Task');
18+
19+
$task->getFromDBByRequest([
20+
'WHERE' => [
21+
'plugin_processmaker_cases_id' => $case->getID()
22+
],
23+
]);
24+
25+
26+
//$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task
27+
//$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID();
28+
29+
Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']);
30+
$item = new $_REQUEST['itemtype'];
31+
$item->getFromDB($_REQUEST['items_id']);
32+
unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList
33+
Session::initNavigateListItems('PluginProcessmakerCase',
34+
//TRANS : %1$s is the itemtype name,
35+
// %2$s is the name of the item (used for headings of a list)
36+
sprintf('%1$s = %2$s',
37+
$_REQUEST['itemtype']::getTypeName(1), $item->fields["name"]));
38+
Html::redirect($link);
39+
}
40+
Html::back();
41+
} else {
42+
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
43+
}
44+
} else {
45+
Html::back();
46+
}
47+
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
48+
$pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
49+
$resultCase = $PM_SOAP->newCase( $_REQUEST['plugin_processmaker_processes_id'],
50+
['GLPI_ITEM_CAN_BE_SOLVED' => 0,
51+
'GLPI_SELFSERVICE_CREATED' => '1',
52+
'GLPI_ITEM_TYPE' => 'Ticket',
53+
'GLPI_URL' => $CFG_GLPI['url_base'],
54+
// Specific to Tickets
55+
// GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request)
56+
'GLPI_TICKET_TYPE' => $_REQUEST['type'],
57+
'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(),
58+
'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid
59+
] );
60+
if ($resultCase->status_code == 0) {
61+
// case is created
62+
// Must show it...
63+
//
64+
$rand = rand( );
65+
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']);
66+
67+
} else {
68+
Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR);
69+
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
70+
}
71+
72+
}
73+
break;
74+
75+
case 'reassign_reminder' :
76+
if (isset($_REQUEST['reassign'])) {
77+
// here we should re-assign the current task to $_REQUEST['users_id_recipient']
78+
$locCase = new PluginProcessmakerCase;
79+
$locCase->getFromDB($_REQUEST['cases_id']);
80+
if ($_REQUEST['users_id_recipient'] != 0) {
81+
// we are assigning a new tech to a task
82+
$pmResponse = $locCase->reassignCase($_REQUEST['delIndex'],
83+
$_REQUEST['taskGuid'],
84+
$_REQUEST['delThread'],
85+
$_REQUEST['users_id'],
86+
$_REQUEST['users_id_recipient'],
87+
['comment' => $_REQUEST['comment']]);
88+
if ($pmResponse) {
89+
Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO);
90+
} else {
91+
Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR);
92+
}
93+
} elseif ($_REQUEST['users_id_recipient'] == 0) {
94+
// we are unassigning a task, i.e.: task un-claim
95+
$pmResponse = $locCase->unassignCase($_REQUEST['delIndex'],
96+
$_REQUEST['taskGuid'],
97+
$_REQUEST['tasktype'],
98+
$_REQUEST['tasks_id'],
99+
$_REQUEST['itemtype'],
100+
['comment' => $_REQUEST['comment']]);
101+
if ($pmResponse) {
102+
Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO);
103+
} else {
104+
Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR);
105+
}
106+
}
107+
} elseif (isset($_REQUEST['reminder'])) {
108+
// send notification remider as requested for this task
109+
110+
$locCase = new PluginProcessmakerCase;
111+
$locCase->getFromDB($_REQUEST['cases_id']);
112+
$glpi_item = new $_REQUEST['itemtype'];
113+
$glpi_item->getFromDB($_REQUEST['items_id']);
114+
$pm_task = new PluginProcessmakerTask($_REQUEST['tasktype']);
115+
$pm_task->getFromDB($_REQUEST['tasks_id']);
116+
$glpi_task = new $_REQUEST['tasktype'];
117+
$glpi_task->getFromDB($_REQUEST['tasks_id']);
118+
119+
// send notification now!
120+
$pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase);
121+
}
122+
}
123+
124+
// to return to item
125+
Html::back();
126+

front/processmaker.helpdesk.form.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function processMakerShowCase($users_id, $from_helpdesk) {
5959

6060
$tkt = new Ticket;
6161

62-
// as showFormHelpdesk uses $_POST, we must set it
63-
$_POST = $_REQUEST;
62+
// as showFormHelpdesk uses $_REQUEST, we must set it
63+
$_REQUEST = $_REQUEST;
6464

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

190190

191191
// Change profile system
192-
if (isset($_POST['newprofile'])) {
193-
if (isset($_SESSION["glpiprofiles"][$_POST['newprofile']])) {
194-
Session::changeProfile($_POST['newprofile']);
192+
if (isset($_REQUEST['newprofile'])) {
193+
if (isset($_SESSION["glpiprofiles"][$_REQUEST['newprofile']])) {
194+
Session::changeProfile($_REQUEST['newprofile']);
195195

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

207207
// Manage entity change
208-
if (isset($_GET["active_entity"])) {
209-
if (!isset($_GET["is_recursive"])) {
210-
$_GET["is_recursive"] = 0;
208+
if (isset($_REQUEST["active_entity"])) {
209+
if (!isset($_REQUEST["is_recursive"])) {
210+
$_REQUEST["is_recursive"] = 0;
211211
}
212-
if (Session::changeActiveEntities($_GET["active_entity"], $_GET["is_recursive"])) {
213-
if ($_GET["active_entity"] == $_SESSION["glpiactive_entity"]) {
212+
if (Session::changeActiveEntities($_REQUEST["active_entity"], $_REQUEST["is_recursive"])) {
213+
if ($_REQUEST["active_entity"] == $_SESSION["glpiactive_entity"]) {
214214
Html::redirect(preg_replace("/entities_id.*/", "", $_SERVER['HTTP_REFERER']));
215215
}
216216
}
217217
}
218218

219219
// Redirect management
220-
if (isset($_GET["redirect"])) {
221-
Toolbox::manageRedirect($_GET["redirect"]);
220+
if (isset($_REQUEST["redirect"])) {
221+
Toolbox::manageRedirect($_REQUEST["redirect"]);
222222
}
223223

224224
// redirect if no create ticket right

0 commit comments

Comments
 (0)