GLPI 9.4 compliant
This commit is contained in:
@@ -6,6 +6,8 @@ version 3.4.x is compatible with GLPI 9.2 and needs ProcessMaker either 3.0.1.8-
|
||||
|
||||
version 3.5.x is compatible with GLPI 9.3 and needs ProcessMaker 3.3.0-RE-1.x (https://github.com/tomolimo/processmaker-server/releases/latest)
|
||||
|
||||
version 3.6.x is compatible with GLPI 9.4 and needs ProcessMaker 3.3.0-RE-1.x (https://github.com/tomolimo/processmaker-server/releases/latest)
|
||||
|
||||
This plugin can run classic and bpmn processes
|
||||
|
||||
An IRC channel is available: #processmaker-glpi on https://webchat.freenode.net/
|
||||
|
||||
@@ -45,7 +45,7 @@ if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
|
||||
|
||||
$search="";
|
||||
if (!empty($_REQUEST['searchText'])) {
|
||||
$search = Search::makeTextSearch($_REQUEST['searchText']);
|
||||
$search = ['LIKE', Search::makeTextSearchValue($_REQUEST['searchText'])];
|
||||
}
|
||||
|
||||
$processes = [];
|
||||
@@ -65,8 +65,10 @@ $count_cases_per_item = isset($_REQUEST['specific_tags']['count_cases_per_item']
|
||||
|
||||
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
|
||||
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data = $DB->fetch_array($result)) {
|
||||
//if ($DB->numrows($result)) {
|
||||
// while ($data = $DB->fetch_array($result)) {
|
||||
if ($result->numrows()) {
|
||||
foreach ($result as $data) {
|
||||
$process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true);
|
||||
$can_add = $data['max_cases_per_item'] == 0 || !isset($count_cases_per_item[$data["id"]]) || $count_cases_per_item[$data["id"]] < $data['max_cases_per_item'];
|
||||
if ($processall
|
||||
|
||||
@@ -58,20 +58,29 @@ if ($one_item < 0) {
|
||||
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
|
||||
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
|
||||
$searchText = isset($_REQUEST['searchText']) ? $_REQUEST['searchText'] : "";
|
||||
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['taskGuid'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
/*$result*/$res = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['taskGuid'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
$_REQUEST['value'], $used, $searchText, $LIMIT);
|
||||
} else {
|
||||
$query = "SELECT DISTINCT `glpi_users`.*
|
||||
FROM `glpi_users`
|
||||
WHERE `glpi_users`.`id` = '$one_item';";
|
||||
$result = $DB->query($query);
|
||||
$res = $DB->request([
|
||||
'SELECT' => 'glpi_users.*',
|
||||
'FROM' => 'glpi_users',
|
||||
'WHERE' => [
|
||||
'glpi_users.id' => $one_item
|
||||
]
|
||||
]);
|
||||
//$query = "SELECT DISTINCT `glpi_users`.*
|
||||
// FROM `glpi_users`
|
||||
// WHERE `glpi_users`.`id` = '$one_item';";
|
||||
//$result = $DB->query($query);
|
||||
}
|
||||
$users = [];
|
||||
|
||||
// Count real items returned
|
||||
$count = 0;
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
//if ($DB->numrows($result)) {
|
||||
// while ($data = $DB->fetch_assoc($result)) {
|
||||
if ($res->numrows()) {
|
||||
foreach ($res as $data) {
|
||||
$users[$data["id"]] = $dbu->formatUserName($data["id"], $data["name"], $data["realname"],
|
||||
$data["firstname"]);
|
||||
$logins[$data["id"]] = $data["name"];
|
||||
|
||||
@@ -225,7 +225,7 @@ if (!Session::haveRight('ticket', CREATE)
|
||||
&& !Session::haveRight('reminder_public', READ)
|
||||
&& !Session::haveRight("rssfeed_public", READ)) {
|
||||
|
||||
if (Session::haveRight('followup', TicketFollowup::SEEPUBLIC)
|
||||
if (Session::haveRight('followup', ITILFollowup::SEEPUBLIC) //TicketFollowup::SEEPUBLIC
|
||||
|| Session::haveRight('task', TicketTask::SEEPUBLIC)
|
||||
|| Session::haveRightsOr('ticketvalidation', [TicketValidation::VALIDATEREQUEST,
|
||||
TicketValidation::VALIDATEINCIDENT])) {
|
||||
@@ -245,9 +245,14 @@ Html::helpHeader(__('New ticket'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
|
||||
|
||||
|
||||
if (isset($_REQUEST['case_guid'])) {
|
||||
$res = $DB->request(
|
||||
'glpi_plugin_processmaker_cases', [
|
||||
' case_guid'=>$_REQUEST['case_guid']
|
||||
]);
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE case_guid='".$_REQUEST['case_guid']."'";
|
||||
$res = $DB->query( $query );
|
||||
if ($DB->numrows( $res )) { // a ticket already exists for this case, then show new cases
|
||||
//$res = $DB->query( $query );
|
||||
//if ($DB->numrows( $res )) { // a ticket already exists for this case, then show new cases
|
||||
if ($res->numrows()) { // a ticket already exists for this case, then show new cases
|
||||
processMakerShowProcessList(Session::getLoginUserID(), 1);
|
||||
} else {
|
||||
// before showing the case, we must check the rights for this user to view it, if entity has been changed in the meanwhile
|
||||
|
||||
@@ -265,11 +265,18 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
*/
|
||||
public function reassignTask ($delIndex, $newDelIndex, $delThread, $newDelThread, $newTech) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id={$this->getID()} AND del_index=$delIndex AND del_thread=$delThread; ";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
$row = $DB->fetch_array( $res );
|
||||
$res = $DB->request('glpi_plugin_processmaker_tasks', [
|
||||
'AND' => [
|
||||
'plugin_processmaker_cases_id' => $this->getID(),
|
||||
'del_index' => $delIndex,
|
||||
'del_thead' => $delThread
|
||||
]
|
||||
]);
|
||||
//$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id={$this->getID()} AND del_index=$delIndex AND del_thread=$delThread; ";
|
||||
//$res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
// $row = $DB->fetch_array( $res );
|
||||
if ($row = $res->next()) {
|
||||
$glpi_task = new $row['itemtype'];
|
||||
$glpi_task->getFromDB( $row['items_id'] );
|
||||
|
||||
@@ -281,8 +288,15 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
$glpi_task->update( [ 'id' => $row['items_id'], $foreignkey => $glpi_task->fields[ $foreignkey ], 'users_id_tech' => $newTech ]);
|
||||
|
||||
// then update the delIndex and delThread
|
||||
$query = "UPDATE glpi_plugin_processmaker_tasks SET del_index = $newDelIndex, del_thread = $newDelThread WHERE id={$row['id']}; ";
|
||||
$res = $DB->query($query);
|
||||
//$query = "UPDATE glpi_plugin_processmaker_tasks SET del_index = $newDelIndex, del_thread = $newDelThread WHERE id={$row['id']}; ";
|
||||
//$res = $DB->query($query);
|
||||
$DB->Update( 'glpi_plugin_processmaker_tasks', [
|
||||
'del_index' => $newDelIndex,
|
||||
'del_thread' => $newDelThread
|
||||
], [
|
||||
'id' => $row['id']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,11 +309,20 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
|
||||
// get all tasks that are OPEN for any sub-case of this case
|
||||
$case_tasks = [];
|
||||
$query = "SELECT `glpi_plugin_processmaker_tasks`.* FROM `glpi_plugin_processmaker_tasks`
|
||||
WHERE `glpi_plugin_processmaker_tasks`.`plugin_processmaker_cases_id`={$this->getID()} AND `del_thread_status`='OPEN'";
|
||||
foreach ($DB->request($query) as $task) {
|
||||
$res = $DB->request('glpi_plugin_processmaker_tasks', [
|
||||
'AND' => [
|
||||
'plugin_processmaker_cases_id' => $this->getID(),
|
||||
'del_thread_status' => 'OPEN'
|
||||
]
|
||||
]);
|
||||
foreach ($res as $task) {
|
||||
$case_tasks[$task['del_index']] = $task;
|
||||
}
|
||||
//$query = "SELECT `glpi_plugin_processmaker_tasks`.* FROM `glpi_plugin_processmaker_tasks`
|
||||
// WHERE `glpi_plugin_processmaker_tasks`.`plugin_processmaker_cases_id`={$this->getID()} AND `del_thread_status`='OPEN'";
|
||||
//foreach ($DB->request($query) as $task) {
|
||||
// $case_tasks[$task['del_index']] = $task;
|
||||
//}
|
||||
|
||||
//// get all tasks that are OPEN for any sub-case of this case
|
||||
//$sub_cases = [];
|
||||
@@ -314,11 +337,19 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
if (property_exists($caseInfo, 'currentUsers')) {
|
||||
$caseInfo->currentUsers = $this->sortTasks($caseInfo->currentUsers, PluginProcessmakerUser::getPMUserId(Session::getLoginUserID()));
|
||||
}
|
||||
$query = "SELECT `DEL_INDEX`, `DEL_DELEGATE_DATE` FROM `APP_DELEGATION` WHERE `APP_UID`='{$caseInfo->caseId}'";
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => ['DEL_INDEX', 'DEL_DELEGATE_DATE'],
|
||||
'FROM' => 'APP_DELEGATION',
|
||||
'WHERE' => ['APP_UID' => $caseInfo->caseId]
|
||||
]);
|
||||
//$query = "SELECT `DEL_INDEX`, `DEL_DELEGATE_DATE` FROM `APP_DELEGATION` WHERE `APP_UID`='{$caseInfo->caseId}'";
|
||||
$tasks = [];
|
||||
foreach ($PM_DB->request($query) as $row) {
|
||||
foreach ($res as $row) {
|
||||
$tasks[$row['DEL_INDEX']] = $row['DEL_DELEGATE_DATE'];
|
||||
}
|
||||
//foreach ($PM_DB->request($query) as $row) {
|
||||
// $tasks[$row['DEL_INDEX']] = $row['DEL_DELEGATE_DATE'];
|
||||
//}
|
||||
|
||||
echo "<p></p>";
|
||||
// show the case properties like given by PM server
|
||||
@@ -346,9 +377,21 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
$case_url .= $case_tasks[$currentTask->delIndex]['id'];
|
||||
echo "<td class='tab_bg_2'><a href='$case_url'>".$currentTask->taskName."</a></td>";
|
||||
} else {
|
||||
$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$this->fields['case_guid']}' AND DEL_INDEX_PARENT={$currentTask->delIndex} AND SA_STATUS='ACTIVE'");
|
||||
if ($res && $PM_DB->numrows($res) == 1) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => 'APP_UID',
|
||||
'FROM' => 'SUB_APPLICATION',
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'APP_PARENT' => $this->fields['case_guid'],
|
||||
'DEL_INDEX_PARENT' => $currentTask->delIndex,
|
||||
'SA_STATUS' => 'ACTIVE'
|
||||
]
|
||||
]
|
||||
]);
|
||||
//$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$this->fields['case_guid']}' AND DEL_INDEX_PARENT={$currentTask->delIndex} AND SA_STATUS='ACTIVE'");
|
||||
//if ($res && $PM_DB->numrows($res) == 1) {
|
||||
// $row = $PM_DB->fetch_assoc($res);
|
||||
if ($res->numrows() == 1 && $row = $res->next()) {
|
||||
$sub_case = new PluginProcessmakerCase;
|
||||
$sub_case->getFromGUID($row['APP_UID']);
|
||||
$case_url .= $sub_case->getID()."-".$currentTask->delIndex;
|
||||
@@ -572,20 +615,36 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
$canupdate = $item->can($items_id, UPDATE);
|
||||
|
||||
$rand = mt_rand();
|
||||
|
||||
$query = "SELECT gppc.`id` AS assocID, gppc.`id` as id, gppp.id as pid, gppp.name as pname, gppc.`case_status`, gppc.`plugin_processmaker_cases_id`
|
||||
FROM `glpi_plugin_processmaker_cases` as gppc
|
||||
LEFT JOIN `glpi_plugin_processmaker_processes` AS gppp ON gppp.`id`=gppc.`plugin_processmaker_processes_id`
|
||||
WHERE gppc.`itemtype` = '$itemtype'
|
||||
AND gppc.`items_id` = $items_id
|
||||
";
|
||||
$result = $DB->query($query);
|
||||
$res = $DB->request([
|
||||
'SELECT' => ['gppc.id AS assocID', 'gppc.id AS id', 'gppp.id AS pid', 'gppp.name AS pname', 'gppc.case_status', 'gppc.plugin_processmaker_cases_id'],
|
||||
'FROM' => 'glpi_plugin_processmaker_cases AS gppc',
|
||||
'LEFT JOIN' => [
|
||||
'glpi_plugin_processmaker_processes AS gppp' => [
|
||||
'FKEY' => [
|
||||
'gppp' => 'id',
|
||||
'gppc' => 'plugin_processmaker_processes_id']
|
||||
]
|
||||
],
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'gppc.itemtype' => $itemtype,
|
||||
'gppc.items_id' => $items_id
|
||||
]
|
||||
]
|
||||
]);
|
||||
//$query = "SELECT gppc.`id` AS assocID, gppc.`id` as id, gppp.id as pid, gppp.name as pname, gppc.`case_status`, gppc.`plugin_processmaker_cases_id`
|
||||
// FROM `glpi_plugin_processmaker_cases` as gppc
|
||||
// LEFT JOIN `glpi_plugin_processmaker_processes` AS gppp ON gppp.`id`=gppc.`plugin_processmaker_processes_id`
|
||||
// WHERE gppc.`itemtype` = '$itemtype'
|
||||
// AND gppc.`items_id` = $items_id
|
||||
// ";
|
||||
//$result = $DB->query($query);
|
||||
|
||||
$cases = [];
|
||||
$used = [];
|
||||
$pid = [];
|
||||
if ($numrows = $DB->numrows($result)) {
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
if ($numrows = $res->numrows()) {
|
||||
foreach ($res as $data) {
|
||||
$cases[$data['id']] = $data;
|
||||
$used[$data['id']] = $data['id'];
|
||||
if (isset($pid[$data['pid']])) {
|
||||
@@ -595,6 +654,17 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
}
|
||||
}
|
||||
}
|
||||
//if ($numrows = $DB->numrows($result)) {
|
||||
// while ($data = $DB->fetch_assoc($result)) {
|
||||
// $cases[$data['id']] = $data;
|
||||
// $used[$data['id']] = $data['id'];
|
||||
// if (isset($pid[$data['pid']])) {
|
||||
// $pid[$data['pid']] += 1;
|
||||
// } else {
|
||||
// $pid[$data['pid']] = 1;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
$columns = ['pname' => __('Process', 'processmaker'),
|
||||
'name' => __('Title', 'processmaker'),
|
||||
@@ -621,18 +691,23 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
echo "<tr class='tab_bg_2'><td class='tab_bg_2'>";
|
||||
echo __('Select the process you want to add', 'processmaker');
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
$condition[] = ['is_active' => 1];
|
||||
if ($itemtype == 'Ticket') {
|
||||
$condition[] = ['is_incident' => 1];
|
||||
$is_itemtype = "AND is_incident=1";
|
||||
if ($item->fields['type'] == Ticket::DEMAND_TYPE) {
|
||||
$condition[] = ['is_request' => 1];
|
||||
$is_itemtype = "AND is_request=1";
|
||||
}
|
||||
} else {
|
||||
$condition[] = ['is_'.strtolower($itemtype) => 1];
|
||||
$is_itemtype = "AND is_".strtolower($itemtype)."=1";
|
||||
}
|
||||
PluginProcessmakerProcess::dropdown(['value' => 0,
|
||||
'entity' => $item->fields['entities_id'],
|
||||
'name' => 'plugin_processmaker_processes_id',
|
||||
'condition' => "is_active=1 $is_itemtype",
|
||||
//'condition' => "is_active=1 $is_itemtype",
|
||||
'condition' => $condition,
|
||||
'specific_tags' => ['count_cases_per_item' => $pid]
|
||||
]);
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
@@ -762,14 +837,24 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
private function deleteTasks() {
|
||||
global $DB;
|
||||
$ret = false;
|
||||
$sub = new QuerySubQuery([
|
||||
'SELECT' => 'items_id',
|
||||
'FROM' => 'glpi_plugin_processmaker_tasks',
|
||||
'WHERE' => ['plugin_processmaker_cases_id' => $this->fields['id']]
|
||||
]);
|
||||
|
||||
$query = "DELETE FROM glpi_".strtolower($this->fields['itemtype'])."tasks WHERE id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id='".$this->fields['id']."')";
|
||||
if ($DB->query( $query )) {
|
||||
$query = "DELETE FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id='".$this->fields['id']."'";
|
||||
if ($DB->query( $query )) {
|
||||
if ($DB->delete('glpi_'.strtolower($this->fields['itemtype']).'tasks', ['id' => $sub ])) {
|
||||
if ($DB->delete('glpi_plugin_processmaker_tasks', ['plugin_processmaker_cases_id' => $this->fields['id']])) {
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
//$query = "DELETE FROM glpi_".strtolower($this->fields['itemtype'])."tasks WHERE id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id='".$this->fields['id']."')";
|
||||
//if ($DB->query( $query )) {
|
||||
// $query = "DELETE FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id='".$this->fields['id']."'";
|
||||
// if ($DB->query( $query )) {
|
||||
// $ret = true;
|
||||
// }
|
||||
//}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -795,10 +880,29 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
$ret = false;
|
||||
|
||||
if (isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO") {
|
||||
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where plugin_processmaker_cases_id='".$this->fields['id']."')";
|
||||
if ($DB->query( $query )) {
|
||||
$sub = new QuerySubQuery([
|
||||
'SELECT' => 'items_id',
|
||||
'FROM' => 'glpi_plugin_processmaker_tasks',
|
||||
'WHERE' => ['plugin_processmaker_cases_id' => $this->fields['id']]
|
||||
]);
|
||||
$res = $DB->update('glpi_'.$this->fields['itemtype'].'tasks', [
|
||||
'state' => 0,
|
||||
'users_id_tech' => 0,
|
||||
'begin' => null,
|
||||
'end' => null
|
||||
], [
|
||||
'AND' => [
|
||||
'state' => 1,
|
||||
'id' => $sub
|
||||
]
|
||||
]);
|
||||
if ($res) {
|
||||
$ret = true;
|
||||
}
|
||||
//$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where plugin_processmaker_cases_id='".$this->fields['id']."')";
|
||||
//if ($DB->query( $query )) {
|
||||
// $ret = true;
|
||||
//}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -930,22 +1034,36 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
if (isset($options['searchopt']['processmaker_cases'])) {
|
||||
switch ($options['searchopt']['processmaker_cases']) {
|
||||
case 'creation_date':
|
||||
$res = $PM_DB->query('SELECT * FROM APPLICATION WHERE APP_NUMBER = '.$values['id']);
|
||||
if ($res->num_rows > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$res = $PM_DB->request('APPLICATION', [
|
||||
'APP_NUMBER' => $values['id']
|
||||
]
|
||||
);
|
||||
if ($row = $res->next()) {
|
||||
return Html::convDateTime($row['APP_CREATE_DATE']);
|
||||
}
|
||||
//$res = $PM_DB->query('SELECT * FROM APPLICATION WHERE APP_NUMBER = '.$values['id']);
|
||||
//if ($res->num_rows > 0) {
|
||||
// $row = $PM_DB->fetch_assoc($res);
|
||||
// return Html::convDateTime($row['APP_CREATE_DATE']);
|
||||
//}
|
||||
//$locCase = new self;
|
||||
//$locCase->getFromDB($values['id']);
|
||||
//$caseInfo = $locCase->getCaseInfo();
|
||||
//return Html::convDateTime($caseInfo->createDate);
|
||||
break;
|
||||
case 'update_date':
|
||||
$res = $PM_DB->query('SELECT * FROM APPLICATION WHERE APP_NUMBER = '.$values['id']);
|
||||
if ($res->num_rows > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$res = $PM_DB->request('APPLICATION', [
|
||||
'APP_NUMBER' => $values['id']
|
||||
]
|
||||
);
|
||||
if ($row = $res->next()) {
|
||||
return Html::convDateTime($row['APP_UPDATE_DATE']);
|
||||
}
|
||||
//$res = $PM_DB->query('SELECT * FROM APPLICATION WHERE APP_NUMBER = '.$values['id']);
|
||||
//if ($res->num_rows > 0) {
|
||||
// $row = $PM_DB->fetch_assoc($res);
|
||||
// return Html::convDateTime($row['APP_UPDATE_DATE']);
|
||||
//}
|
||||
//$locCase = new self;
|
||||
//$locCase->getFromDB($values['id']);
|
||||
//$caseInfo = $locCase->getCaseInfo();
|
||||
@@ -1356,9 +1474,12 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
function deleteCronTaskActions() {
|
||||
global $DB;
|
||||
|
||||
$query = "DELETE FROM `glpi_plugin_processmaker_crontaskactions` WHERE `plugin_processmaker_cases_id` = ".$this->getID();
|
||||
|
||||
return $DB->query($query);
|
||||
return $DB->delete('glpi_plugin_processmaker_crontaskactions', [
|
||||
'plugin_processmaker_cases_id' => $this->getID()
|
||||
]
|
||||
);
|
||||
//$query = "DELETE FROM `glpi_plugin_processmaker_crontaskactions` WHERE `plugin_processmaker_cases_id` = ".$this->getID();
|
||||
//return $DB->query($query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -307,11 +307,28 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
echo "<td >".__('Group in ProcessMaker which will contain all GLPI users', 'processmaker')."</td><td >";
|
||||
|
||||
$pmGroups = [ 0 => Dropdown::EMPTY_VALUE ];
|
||||
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE' ORDER BY CON_VALUE;";
|
||||
//$res = $PM_DB->request([
|
||||
// 'SELECT DISTINCT' => 'CON_ID',
|
||||
// 'FIELDS' => 'CON_VALUE',
|
||||
// 'FROM' => 'CONTENT',
|
||||
// 'WHERE' => ['CON_CATEGORY' => 'GRP_TITLE'],
|
||||
// 'ORDER' => 'CON_VALUE'
|
||||
// ]);
|
||||
//$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE' ORDER BY CON_VALUE;";
|
||||
if ($PM_DB->connected) {
|
||||
foreach ($PM_DB->request( $query ) as $row) {
|
||||
$res = $PM_DB->request([
|
||||
'SELECT DISTINCT' => 'CON_ID',
|
||||
'FIELDS' => 'CON_VALUE',
|
||||
'FROM' => 'CONTENT',
|
||||
'WHERE' => ['CON_CATEGORY' => 'GRP_TITLE'],
|
||||
'ORDER' => 'CON_VALUE'
|
||||
]);
|
||||
foreach ($res as $row) {
|
||||
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
|
||||
}
|
||||
//foreach ($PM_DB->request( $query ) as $row) {
|
||||
// $pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
|
||||
//}
|
||||
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, ['value' => $config->fields['pm_group_guid']] );
|
||||
} else {
|
||||
echo "<font color='red'>".__('Not connected');
|
||||
|
||||
@@ -71,7 +71,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
// we need to get the tasks + content from PM db
|
||||
//$config = PluginProcessmakerConfig::getInstance() ;
|
||||
//$database = $config->fields['pm_workspace'] ;
|
||||
$translates = false;
|
||||
//$translates = false;
|
||||
$mapLangs = [];
|
||||
$dbu = new DbUtils;
|
||||
// if (class_exists('DropdownTranslation')) {
|
||||
@@ -79,7 +79,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name';
|
||||
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['completename'] = 'completename';
|
||||
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['comment'] = 'comment';
|
||||
$translates = true;
|
||||
//$translates = true;
|
||||
// create a reversed map for languages
|
||||
foreach ($CFG_GLPI['languages'] as $key => $valArray) {
|
||||
$lg = locale_get_primary_language( $key );
|
||||
@@ -88,9 +88,31 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
}
|
||||
//}
|
||||
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
|
||||
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, TASK.TAS_TYPE, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
||||
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
||||
WHERE (TASK.TAS_TYPE = 'NORMAL' OR TASK.TAS_TYPE = 'SUBPROCESS') AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
||||
$query = [
|
||||
'SELECT' => ['TASK.TAS_UID', 'TASK.TAS_START', 'TASK.TAS_TYPE', 'CONTENT.CON_LANG', 'CONTENT.CON_CATEGORY', 'CONTENT.CON_VALUE'],
|
||||
'FROM' => 'TASK',
|
||||
'INNER JOIN' => [
|
||||
'CONTENT' => [
|
||||
'FKEY' => [
|
||||
'CONTENT' => 'CON_ID',
|
||||
'TASK' => 'TAS_UID'
|
||||
]
|
||||
]
|
||||
],
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'TASK.TAS_TYPE' => ['NORMAL', 'SUBPROCESS'],
|
||||
'TASK.PRO_UID' => $this->fields['process_guid'],
|
||||
'CONTENT.CON_CATEGORY' => ['TAS_TITLE', 'TAS_DESCRIPTION']
|
||||
]
|
||||
]
|
||||
];
|
||||
//if (!$translates) {
|
||||
// $query['WHERE']['AND']['CONTENT.CON_LANG'] = $lang;
|
||||
//}
|
||||
//$query = "SELECT TASK.TAS_UID, TASK.TAS_START, TASK.TAS_TYPE, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
||||
// INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
||||
// WHERE (TASK.TAS_TYPE = 'NORMAL' OR TASK.TAS_TYPE = 'SUBPROCESS') AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
||||
$taskArray = [];
|
||||
$defaultLangTaskArray = [];
|
||||
foreach ($PM_DB->request( $query ) as $task) {
|
||||
@@ -168,7 +190,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
] );
|
||||
}
|
||||
// here we should take into account translations if any
|
||||
if ($translates && isset($taskArray[ $taskGUID ])) {
|
||||
if ( isset($taskArray[ $taskGUID ])) {
|
||||
foreach ($taskArray[ $taskGUID ] as $langTask => $taskL) {
|
||||
// look for 'name' field
|
||||
if ($loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'name', $langTask )) {
|
||||
@@ -289,8 +311,13 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
$proc->getFromDB($key);
|
||||
|
||||
// check if at least one case is existing for this process
|
||||
$query = "SELECT * FROM `".PluginProcessmakerCase::getTable()."` WHERE `plugin_processmaker_processes_id` = ".$key;
|
||||
$res = $DB->query($query);
|
||||
$res = $DB->request(
|
||||
PluginProcessmakerCase::getTable(), [
|
||||
'plugin_processmaker_processes_id' => $key
|
||||
]
|
||||
);
|
||||
//$query = "SELECT * FROM `".PluginProcessmakerCase::getTable()."` WHERE `plugin_processmaker_processes_id` = ".$key;
|
||||
//$res = $DB->query($query);
|
||||
if ($DB->numrows($res) === 0) {
|
||||
// and if no will delete the process
|
||||
$proc->delete(['id' => $key]);
|
||||
@@ -386,15 +413,21 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
public function getFromGUID($process_guid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `process_guid` = '$process_guid'";
|
||||
$res = $DB->request(
|
||||
$this->getTable(), [
|
||||
'process_guid' => $process_guid
|
||||
]
|
||||
);
|
||||
//$query = "SELECT *
|
||||
// FROM `".$this->getTable()."`
|
||||
// WHERE `process_guid` = '$process_guid'";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
//if ($result = $DB->query($query)) {
|
||||
if ($res) {
|
||||
if ($res->numrows() != 1) {//if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
$this->fields = $res->next(); //$DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
@@ -784,31 +817,38 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
*
|
||||
* @return mysql result set.
|
||||
**/
|
||||
static function getSqlSearchResult ($count = true, $search = '') {
|
||||
static function getSqlSearchResult ($count = true, $search = []) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
$query = [];
|
||||
$where = '';
|
||||
$orderby = '';
|
||||
|
||||
if (isset($_REQUEST['condition']) && isset($_SESSION['glpicondition'][$_REQUEST['condition']])) {
|
||||
$where = ' WHERE '.$_SESSION['glpicondition'][$_REQUEST['condition']]; //glpi_plugin_processmaker_processes.is_active=1 ';
|
||||
//$where = ' WHERE '.$_SESSION['glpicondition'][$_REQUEST['condition']]; //glpi_plugin_processmaker_processes.is_active=1 ';
|
||||
$query['WHERE']['AND'] = $_SESSION['glpicondition'][$_REQUEST['condition']];
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$fields = " COUNT(DISTINCT glpi_plugin_processmaker_processes.id) AS cpt ";
|
||||
//$fields = " COUNT(DISTINCT glpi_plugin_processmaker_processes.id) AS cpt ";
|
||||
$query['SELECT'] = ['COUNT' => 'glpi_plugin_processmaker_processes.id AS cpt'];
|
||||
} else {
|
||||
$fields = " DISTINCT glpi_plugin_processmaker_processes.* ";
|
||||
$orderby = " ORDER BY glpi_plugin_processmaker_processes.name ASC";
|
||||
//$fields = " DISTINCT glpi_plugin_processmaker_processes.* ";
|
||||
$query['SELECT'] = ['glpi_plugin_processmaker_processes.*'];
|
||||
$query['ORDER'] ='glpi_plugin_processmaker_processes.name ASC';
|
||||
//$orderby = " ORDER BY glpi_plugin_processmaker_processes.name ASC";
|
||||
}
|
||||
|
||||
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$where .= " AND (glpi_plugin_processmaker_processes.name $search
|
||||
OR glpi_plugin_processmaker_processes.comment $search) ";
|
||||
if (!empty($search) && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$query['WHERE']['AND']['OR']['glpi_plugin_processmaker_processes.name'] = $search;
|
||||
$query['WHERE']['AND']['OR']['glpi_plugin_processmaker_processes.comment'] = $search;
|
||||
//$where .= " AND (glpi_plugin_processmaker_processes.name $search
|
||||
// OR glpi_plugin_processmaker_processes.comment $search) ";
|
||||
}
|
||||
|
||||
$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";";
|
||||
|
||||
return $DB->query($query);
|
||||
$query['FROM'] = 'glpi_plugin_processmaker_processes';
|
||||
//$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";";
|
||||
//return $DB->query($query);
|
||||
$r= $DB->request($query);
|
||||
return $DB->request($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -826,11 +866,13 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
"comment" => ""];
|
||||
}
|
||||
|
||||
$query="SELECT * FROM glpi_plugin_processmaker_processes WHERE id=$pid";
|
||||
$result = $DB->query($query);
|
||||
if ($result && $DB->numrows($result)==1) {
|
||||
$data = $DB->fetch_assoc($result);
|
||||
$processname = $data["name"];
|
||||
$res = $DB->request('glpi_plugin_processmaker_processes', ['id' => $pid]);
|
||||
//$query="SELECT * FROM glpi_plugin_processmaker_processes WHERE id=$pid";
|
||||
//$result = $DB->query($query);
|
||||
//if ($result && $DB->numrows($result)==1) {
|
||||
// $data = $DB->fetch_assoc($result);
|
||||
if ($res && $res->numrows() == 1) {
|
||||
$processname = $res['name'];//$data["name"];
|
||||
if ($link==2) {
|
||||
$process["name"] = $processname;
|
||||
$process["link"] = $CFG_GLPI["root_doc"]."/plugins/processmaker/front/process.form.php?id=".$pid;
|
||||
@@ -856,13 +898,24 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
static function getEntitiesForProfileByProcess($processes_id, $profiles_id, $child = false) {
|
||||
global $DB;
|
||||
$dbu = new DbUtils;
|
||||
$res = $DB->request([
|
||||
'SELECT' => ['entities_id', 'is_recursive'],
|
||||
'FROM' => 'glpi_plugin_processmaker_processes_profiles',
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'plugin_processmaker_processes_id' => $processes_id,
|
||||
'profiles_id' => $profiles_id
|
||||
]
|
||||
]
|
||||
]);
|
||||
$query = "SELECT `entities_id`, `is_recursive`
|
||||
FROM `glpi_plugin_processmaker_processes_profiles`
|
||||
WHERE `plugin_processmaker_processes_id` = '$processes_id'
|
||||
AND `profiles_id` = '$profiles_id'";
|
||||
|
||||
$entities = [];
|
||||
foreach ($DB->request($query) as $data) {
|
||||
//foreach ($DB->request($query) as $data) {
|
||||
foreach ($res as $data) {
|
||||
if ($child && $data['is_recursive']) {
|
||||
foreach ($dbu->getSonsOf('glpi_entities', $data['entities_id']) as $id) {
|
||||
$entities[$id] = $id;
|
||||
|
||||
@@ -59,23 +59,50 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
$query = "SELECT DISTINCT gpp.`id` AS linkID,
|
||||
`glpi_profiles`.`id`,
|
||||
`glpi_profiles`.`name`,
|
||||
`gpp`.`is_recursive`,
|
||||
`glpi_entities`.`completename`,
|
||||
`gpp`.`entities_id`
|
||||
FROM `". self::getTable() ."` as gpp
|
||||
LEFT JOIN `glpi_profiles`
|
||||
ON (`gpp`.`profiles_id` = `glpi_profiles`.`id`)
|
||||
LEFT JOIN `glpi_entities`
|
||||
ON (`gpp`.`entities_id` = `glpi_entities`.`id`)
|
||||
WHERE `gpp`.`plugin_processmaker_processes_id` = '$ID'
|
||||
ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
|
||||
$result = $DB->query($query);
|
||||
$num = $DB->numrows($result);
|
||||
|
||||
$res = $DB->request([
|
||||
'SELECT DISTINCT' => 'gpp.id AS linkID',
|
||||
'FIELDS' => [
|
||||
'gpp.id AS linkID',
|
||||
'glpi_profiles.id',
|
||||
'glpi_profiles.name',
|
||||
'gpp.is_recursive',
|
||||
'glpi_entities.completename',
|
||||
'gpp.entities_id'
|
||||
],
|
||||
'FROM' => self::getTable() .' AS gpp',
|
||||
'LEFT JOIN' => [
|
||||
'glpi_profiles' => [
|
||||
'FKEY' => [
|
||||
'glpi_profiles' => 'id',
|
||||
'gpp' => 'profiles_id'
|
||||
]
|
||||
],
|
||||
'glpi_entities' => [
|
||||
'FKEY' => [
|
||||
'glpi_entities' => 'id',
|
||||
'gpp' => 'entities_id'
|
||||
]
|
||||
]
|
||||
],
|
||||
'WHERE' => [ 'gpp.plugin_processmaker_processes_id' => $ID ],
|
||||
'ORDER' => [ 'glpi_profiles.name', 'glpi_entities.completename' ]
|
||||
]);
|
||||
//$query = "SELECT DISTINCT gpp.`id` AS linkID,
|
||||
// `glpi_profiles`.`id`,
|
||||
// `glpi_profiles`.`name`,
|
||||
// `gpp`.`is_recursive`,
|
||||
// `glpi_entities`.`completename`,
|
||||
// `gpp`.`entities_id`
|
||||
// FROM `". self::getTable() ."` as gpp
|
||||
// LEFT JOIN `glpi_profiles`
|
||||
// ON (`gpp`.`profiles_id` = `glpi_profiles`.`id`)
|
||||
// LEFT JOIN `glpi_entities`
|
||||
// ON (`gpp`.`entities_id` = `glpi_entities`.`id`)
|
||||
// WHERE `gpp`.`plugin_processmaker_processes_id` = '$ID'
|
||||
// ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
|
||||
//$result = $DB->query($query);
|
||||
//$num = $DB->numrows($result);
|
||||
$num = $res->numrows();
|
||||
echo "<div class='spaced'>";
|
||||
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
|
||||
|
||||
@@ -103,7 +130,8 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
$header_end .= "</th></tr>";
|
||||
echo $header_begin.$header_top.$header_end;
|
||||
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
//while ($data = $DB->fetch_assoc($result)) {
|
||||
foreach ($res as $data) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
if ($canedit) {
|
||||
echo "<td width='10'>";
|
||||
|
||||
@@ -135,28 +135,28 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
|
||||
/**
|
||||
* Summary of addTicketFollowup
|
||||
* Summary of addItemFollowup
|
||||
* @param mixed $itemId
|
||||
* @param mixed $txtForFollowup
|
||||
* @param integer $users_id optional, if null will uses logged-in user
|
||||
*/
|
||||
public function addTicketFollowup($itemId, $txtForFollowup, $users_id = null) {
|
||||
public function addItemFollowup($itemtype, $itemId, $txtForFollowup, $users_id = null) {
|
||||
global $DB;
|
||||
$fu = new TicketFollowup();
|
||||
$fu = new ITILFollowup();//new TicketFollowup();
|
||||
$fu->getEmpty(); // to get default values
|
||||
$input = $fu->fields;
|
||||
if (isset( $txtForFollowup['GLPI_TICKET_FOLLOWUP_CONTENT'] )) {
|
||||
$input['content'] = $DB->escape($txtForFollowup['GLPI_TICKET_FOLLOWUP_CONTENT']);
|
||||
if (isset( $txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT'] )) {
|
||||
$input['content'] = $DB->escape($txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT']);
|
||||
}
|
||||
if (isset( $txtForFollowup['GLPI_TICKET_FOLLOWUP_IS_PRIVATE'] )) {
|
||||
$input['is_private'] = $txtForFollowup['GLPI_TICKET_FOLLOWUP_IS_PRIVATE'];
|
||||
if (isset( $txtForFollowup['GLPI_ITEM_FOLLOWUP_IS_PRIVATE'] )) {
|
||||
$input['is_private'] = $txtForFollowup['GLPI_ITEM_FOLLOWUP_IS_PRIVATE'];
|
||||
}
|
||||
if (isset( $txtForFollowup['GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID'] )) {
|
||||
$input['requesttypes_id'] = $txtForFollowup['GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID'];
|
||||
if (isset( $txtForFollowup['GLPI_ITEM_FOLLOWUP_REQUESTTYPES_ID'] )) {
|
||||
$input['requesttypes_id'] = $txtForFollowup['GLPI_ITEM_FOLLOWUP_REQUESTTYPES_ID'];
|
||||
}
|
||||
$input['tickets_id'] = $itemId;
|
||||
$input['items_id'] = $itemId;//$input['tickets_id'] = $itemId;
|
||||
$input['users_id'] = (isset($users_id) ? $users_id : Session::getLoginUserID( true )); // $this->taskWriter;
|
||||
|
||||
$input['itemtype'] = $itemtype;
|
||||
$fu->add( $input );
|
||||
}
|
||||
|
||||
@@ -266,8 +266,10 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$pass = md5(Toolbox::encrypt( $gusr->getID().$gusr->getName().time(), GLPIKEY) );
|
||||
//$pmusr->update( array('id' => $pmusr->getID(), 'password' => $pass) );
|
||||
// and must be updated also in PM db
|
||||
$PM_DB->query("UPDATE RBAC_USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
|
||||
$PM_DB->query("UPDATE USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
|
||||
$PM_DB->update('RBAC_USERS', ['USR_PASSWORD' => $pass], ['USR_UID' => $pmusr->fields['pm_users_id']]);
|
||||
//$PM_DB->query("UPDATE RBAC_USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
|
||||
$PM_DB->update('USERS', ['USR_PASSWORD' => $pass], ['USR_UID' => $pmusr->fields['pm_users_id']]);
|
||||
//$PM_DB->query("UPDATE USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
|
||||
//}
|
||||
//$locSession = $this->pmSoapClient->login( array( 'userid' => $gusr->fields['name'], 'password' => 'md5:'.$pmusr->fields['password']) );
|
||||
$locSession = $this->pmSoapClient->login( ['userid' => $gusr->fields['name'], 'password' => 'md5:'.$pass] );
|
||||
@@ -868,8 +870,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
*/
|
||||
function updateGroup($group_id, $groupStatus) {
|
||||
global $PM_DB;
|
||||
$query = "UPDATE GROUPWF SET GRP_STATUS='$groupStatus' WHERE GRP_UID='$group_id';";
|
||||
$PM_DB->query( $query );
|
||||
$PM_DB->update('GROUPWF', ['GRP_STATUS' => $groupStatus], ['GRP_UID' => $group_id]);
|
||||
//$query = "UPDATE GROUPWF SET GRP_STATUS='$groupStatus' WHERE GRP_UID='$group_id';";
|
||||
//$PM_DB->query( $query );
|
||||
if ($PM_DB->affected_rows != 1) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -1049,7 +1052,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$formerusers_id = 0;
|
||||
// get the list of taskactions to be done
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
foreach ($DB->request( $dbu->getTableForItemType('PluginProcessmakerCrontaskaction'), ' `state` = '.PluginProcessmakerCrontaskaction::DATA_READY ) as $taskaction) {
|
||||
//foreach ($DB->request( $dbu->getTableForItemType('PluginProcessmakerCrontaskaction'), ' `state` = '.PluginProcessmakerCrontaskaction::DATA_READY ) as $taskaction) {
|
||||
foreach ($DB->request( $dbu->getTableForItemType('PluginProcessmakerCrontaskaction'), ['state' => PluginProcessmakerCrontaskaction::DATA_READY] ) as $taskaction) {
|
||||
if ($locCase->getFromDB($taskaction['plugin_processmaker_cases_id'])) {
|
||||
// there is an existing case for this crontaskaction.
|
||||
try {
|
||||
@@ -1188,7 +1192,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
// get list of case assigned to GLPI items
|
||||
$draftCases = [0];
|
||||
$query = "SELECT id FROM glpi_plugin_processmaker_cases WHERE case_status = 'DRAFT';";
|
||||
foreach ($DB->request( $query ) as $row) {
|
||||
//foreach ($DB->request( $query ) as $row) {
|
||||
foreach ($DB->request(['SELECT' => 'id', 'FROM' => 'glpi_plugin_processmaker_cases'], ['case_status' => 'DRAFT']) as $row) {
|
||||
$draftCases[] = $row['id'];
|
||||
}
|
||||
|
||||
@@ -1205,7 +1210,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
AND DATEDIFF( NOW(), APP_UPDATE_DATE) > ".$task->fields['param']."
|
||||
AND APP_NUMBER NOT IN (".implode(',', $draftCases).");
|
||||
";
|
||||
foreach ($PM_DB->request( $query ) as $row) {
|
||||
$res = $PM_DB->request('APPLICATION', ['AND' => [
|
||||
'APP_DATA' => ['LIKE', '%s:24:\"GLPI_SELFSERVICE_CREATED\";s:1:\"1\"%'],
|
||||
'APP_STATUS' => 'DRAFT',
|
||||
'RAW' => ['DATEDIFF(NOW(), APP_UPDATE_DATE)' => ['>', $task->fields['param']]],
|
||||
'NOT' => ['APP_NUMBER' => $draftCases]
|
||||
]]);
|
||||
//foreach ($PM_DB->request( $query ) as $row) {
|
||||
foreach ($res as $row) {
|
||||
$ret = $PM_SOAP->deleteCase( $row['APP_UID'] );
|
||||
$task->addVolume(1);
|
||||
if ($ret !== false) {
|
||||
@@ -1254,8 +1266,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
}
|
||||
|
||||
$pmGroupList = $PM_SOAP->groupList( );
|
||||
foreach ($pmGroupList as $pmGroup) {
|
||||
if ($pmGroup->guid == $PM_SOAP->pm_group_guid) {
|
||||
$pmGroup = null;
|
||||
//if($pmgrp_key = array_search($PM_SOAP->pm_group_guid, array_column($pmGroupList, 'guid'))) {
|
||||
// $pmgroup = $pmGroupList[$pmgrp_key];
|
||||
//}
|
||||
foreach ($pmGroupList as $pmGroupL) {
|
||||
if ($pmGroupL->guid == $PM_SOAP->pm_group_guid) {
|
||||
$pmGroup = $pmGroupL;
|
||||
break; // to get the name :)
|
||||
}
|
||||
}
|
||||
@@ -1267,10 +1284,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
// get the complete user list from GLPI DB
|
||||
$glpiUserList = [];
|
||||
foreach ($DB->request("SELECT glpi_users.id, glpi_users.name, glpi_users.realname, glpi_users.firstname, glpi_users.is_active, glpi_users.is_deleted, glpi_plugin_processmaker_users.pm_users_id as pmUserId
|
||||
FROM glpi_users
|
||||
LEFT JOIN glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.id = glpi_users.id
|
||||
WHERE name not like '*%'") as $dbgroup) {
|
||||
$res = $DB->request(['SELECT' => ['glpi_users.id', 'glpi_users.name', 'glpi_users.realname', 'glpi_users.firstname', 'glpi_users.is_active', 'glpi_users.is_deleted', 'glpi_plugin_processmaker_users.pm_users_id as pmUserId'],
|
||||
'FROM' => 'glpi_users',
|
||||
'LEFT JOIN' => ['glpi_plugin_processmaker_users' => ['FKEY' => ['glpi_plugin_processmaker_users' => 'id', 'glpi_users' => 'id']]],
|
||||
'WHERE' => ['name' => ['NOT LIKE', '*%']]
|
||||
]);
|
||||
//foreach ($DB->request("SELECT glpi_users.id, glpi_users.name, glpi_users.realname, glpi_users.firstname, glpi_users.is_active, glpi_users.is_deleted, glpi_plugin_processmaker_users.pm_users_id as pmUserId
|
||||
// FROM glpi_users
|
||||
// LEFT JOIN glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.id = glpi_users.id
|
||||
// WHERE name not like '*%'") as $dbgroup) {
|
||||
foreach ($res as $dbgroup) {
|
||||
$glpiUserList[ strtolower($dbgroup['name'])] = $dbgroup;
|
||||
}
|
||||
|
||||
@@ -1286,13 +1309,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$task->log( "Added user: '".$user['name']."'" );
|
||||
|
||||
// then assign user to group
|
||||
if($pmGroup) {
|
||||
$pmResult2 = $PM_SOAP->assignUserToGroup( $pmResult->userUID, $pmGroup->guid );
|
||||
if ($pmResult2->status_code == 0) {
|
||||
$task->log( "Added user: '".$user['name']."' to '".$pmGroup->name."' group" );
|
||||
} else {
|
||||
$task->log( "Error PM: '".$pmResult2->message."'" );
|
||||
}
|
||||
|
||||
}
|
||||
// insert into DB the link between glpi users and pm user
|
||||
$pmuser = new PluginProcessmakerUser;
|
||||
if ($pmuser->getFromDB( $user['id'] )) {
|
||||
@@ -1379,7 +1403,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
// so now treat GLPI groups
|
||||
$glpiGroupList = [];
|
||||
foreach ($DB->request("SELECT id, name, is_task, is_usergroup FROM glpi_groups WHERE is_task=1 AND is_usergroup=1") as $dbgroup) {
|
||||
$res = $DB->request(['SELECT' => ['id', 'name', 'is_task', 'is_usergroup'],
|
||||
'FROM' => 'glpi_groups',
|
||||
'WHERE' => ['AND' => ['is_task' => 1, 'is_usergroup' => 1]]
|
||||
]);
|
||||
//foreach ($DB->request("SELECT id, name, is_task, is_usergroup FROM glpi_groups WHERE is_task=1 AND is_usergroup=1") as $dbgroup) {
|
||||
foreach ($res as $dbgroup) {
|
||||
$glpiGroupList[$dbgroup['name']] = $dbgroup;
|
||||
}
|
||||
|
||||
@@ -1408,25 +1437,44 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
// for each group will delete users and re-create them
|
||||
// not really optimized, but this way we are sure that groups are synchronized
|
||||
// must be redesigned
|
||||
$query = "DELETE FROM GROUP_USER WHERE GROUP_USER.GRP_UID='".$pmGroupList[$group['name']]['CON_ID']."';";
|
||||
$PM_DB->query( $query );
|
||||
$PM_DB->delete('GROUP_USER', ['GROUP_USER.GRP_UID' => $pmGroupList[$group['name']]['CON_ID']]);
|
||||
//$query = "DELETE FROM GROUP_USER WHERE GROUP_USER.GRP_UID='".$pmGroupList[$group['name']]['CON_ID']."';";
|
||||
//$PM_DB->query( $query );
|
||||
// and insert all users from real GLPI group
|
||||
foreach ($DB->request("SELECT glpi_groups_users.users_id, glpi_plugin_processmaker_users.pm_users_id
|
||||
FROM glpi_groups
|
||||
JOIN glpi_groups_users ON glpi_groups_users.groups_id=glpi_groups.id
|
||||
JOIN glpi_plugin_processmaker_users ON glpi_plugin_processmaker_users.id=glpi_groups_users.users_id
|
||||
WHERE glpi_groups.name='".$group['name']."'") as $user ) {
|
||||
$query = "INSERT INTO GROUP_USER (`GRP_UID`, `USR_UID`) VALUES ( '".$pmGroupList[$group['name']]['CON_ID']."', '".$user['pm_users_id']."' )";
|
||||
$PM_DB->query( $query );
|
||||
$res = $DB->request(['SELECT' => ['glpi_groups_users.users_id', 'glpi_plugin_processmaker_users.pm_users_id'],
|
||||
'FROM' => 'glpi_groups',
|
||||
'INNER JOIN' => ['glpi_groups_users' => ['FKEY' => ['glpi_groups_users' => 'groups_id', 'glpi_groups' => 'id']],
|
||||
'glpi_plugin_processmaker_users' => ['FKEY' => ['glpi_plugin_processmaker_users' => 'id', 'glpi_groups_users' => 'users_id']]],
|
||||
'WHERE' => ['glpi_groups.name' => $group['name']]]);
|
||||
|
||||
//foreach ($DB->request("SELECT glpi_groups_users.users_id, glpi_plugin_processmaker_users.pm_users_id
|
||||
// FROM glpi_groups
|
||||
// JOIN glpi_groups_users ON glpi_groups_users.groups_id=glpi_groups.id
|
||||
// JOIN glpi_plugin_processmaker_users ON glpi_plugin_processmaker_users.id=glpi_groups_users.users_id
|
||||
// WHERE glpi_groups.name='".$group['name']."'") as $user ) {
|
||||
foreach ($res as $user) {
|
||||
//$query = "INSERT INTO GROUP_USER (`GRP_UID`, `USR_UID`) VALUES ( '".$pmGroupList[$group['name']]['CON_ID']."', '".$user['pm_users_id']."' )";
|
||||
//$PM_DB->query( $query );
|
||||
$PM_DB->insert('GROUP_USER', ['GRP_UID' => $pmGroupList[$group['name']]['CON_ID'],
|
||||
'USR_UID' => $user['pm_users_id']
|
||||
]
|
||||
);
|
||||
}
|
||||
$task->addVolume(1);
|
||||
$task->log( "Updated users into PM group: '".$group['name']."'" );
|
||||
}
|
||||
|
||||
// now should renew the duedate of the users
|
||||
$PM_DB->query("UPDATE USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
|
||||
$PM_DB->query("UPDATE RBAC_USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
|
||||
|
||||
//$PM_DB->query("UPDATE USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
|
||||
//$PM_DB->query("UPDATE RBAC_USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
|
||||
$PM_DB->update('USERS',
|
||||
['USR_DUE_DATE' => '2035-12-31'],
|
||||
['USR_DUE_DATE' => ['!=', '2035-12-31']]
|
||||
);
|
||||
$PM_DB->update('RBAC_USERS',
|
||||
['USR_DUE_DATE' => '2035-12-31'],
|
||||
['USR_DUE_DATE' => ['!=', '2035-12-31']]
|
||||
);
|
||||
if ($error) {
|
||||
return -1;
|
||||
} else {
|
||||
@@ -1684,10 +1732,22 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
if ($techId == 0) { // then we must look-up DB to get the group that will be assigned to the task
|
||||
$groupname='';
|
||||
if ($groupId == 0) {
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => 'CONTENT.CON_VALUE',
|
||||
'FROM' => 'TASK_USER',
|
||||
'INNER JOIN' => ['CONTENT' => ['AND' => ['FKEY' => ['CONTENT' => 'CON_ID', 'TASK_USER' => 'USR_UID'], ['CONTENT' => 'CON_CATEGORY', 'GRP_TITLE'], ['CONTENT' => 'CON_LANG', 'en']]]],
|
||||
'WHERE' => ['AND' => ['TASK_USER.TAS_UID' => $pmTaskId, 'TASK_USER.TU_RELATION' => 2]],
|
||||
'LIMIT' => 1
|
||||
]);
|
||||
$query = "SELECT CONTENT.CON_VALUE FROM TASK_USER
|
||||
JOIN CONTENT ON CONTENT.CON_ID=TASK_USER.USR_UID AND CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG = 'en'
|
||||
WHERE TASK_USER.TAS_UID='$pmTaskId' AND TASK_USER.TU_RELATION=2 LIMIT 1;";
|
||||
} else {
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => 'CON_VALUE',
|
||||
'FROM' => 'CONTENT',
|
||||
'WHERE' => ['AND' => ['CONTENT.CON_ID' => $groupId, 'CONTENT.CON_CATEGORY' => 'GRP_TITLE', 'CONTENT.CON_LANG' => 'en']]
|
||||
]);
|
||||
$query = "SELECT CON_VALUE FROM CONTENT
|
||||
WHERE CONTENT.CON_ID='$groupId' AND CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG='en' ;";
|
||||
}
|
||||
@@ -1695,17 +1755,26 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
// or
|
||||
// as there is only one group per guid
|
||||
// then we should have at maximun 1 record
|
||||
foreach ($PM_DB->request($query) as $onlyrec) {
|
||||
foreach ($res as $onlyrec) {
|
||||
//foreach ($PM_DB->request($query) as $onlyrec) {
|
||||
$groupname = $onlyrec['CON_VALUE'];
|
||||
}
|
||||
|
||||
$groups_id_tech = 0;
|
||||
$query = "SELECT id AS glpi_group_id FROM glpi_groups WHERE name LIKE '$groupname';";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
$row = $DB->fetch_array( $res );
|
||||
$res = $DB->request([
|
||||
'SELECT' => 'id AS glpi_group_id',
|
||||
'FROM' => 'glpi_groups',
|
||||
'WHERE' => ['name' => ['LIKE', $groupname]]
|
||||
]);
|
||||
if ($row = $res->next()) {
|
||||
$groups_id_tech = $row['glpi_group_id'];
|
||||
}
|
||||
//$query = "SELECT id AS glpi_group_id FROM glpi_groups WHERE name LIKE '$groupname';";
|
||||
//$res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
// $row = $DB->fetch_array( $res );
|
||||
// $groups_id_tech = $row['glpi_group_id'];
|
||||
//}
|
||||
|
||||
} else {
|
||||
// adds the user tech to ticket watcher if neccessary
|
||||
@@ -1762,9 +1831,18 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
// 'plugin_processmaker_cases_id' => $cases_id,
|
||||
// 'del_index' => $delIndex
|
||||
// ], [], false);
|
||||
$query = "INSERT INTO glpi_plugin_processmaker_tasks (items_id, itemtype, plugin_processmaker_cases_id, plugin_processmaker_taskcategories_id, del_index, del_thread)
|
||||
VALUES ({$glpi_task->getId()}, '{$glpi_task->getType()}', $cases_id, {$pmtaskcat->fields['id']}, $delIndex, $delThread);";
|
||||
$DB->query( $query );
|
||||
$DB->insert('glpi_plugin_processmaker_tasks',
|
||||
[
|
||||
'items_id' => $glpi_task->getId(),
|
||||
'itemtype' => $glpi_task->getType(),
|
||||
'plugin_processmaker_cases_id' => $cases_id,
|
||||
'plugin_processmaker_taskcategories_id' => $pmtaskcat->fields['id'],
|
||||
'del_index' => $delIndex,
|
||||
'del_thread' =>$delThread
|
||||
]);
|
||||
//$query = "INSERT INTO glpi_plugin_processmaker_tasks (items_id, itemtype, plugin_processmaker_cases_id, plugin_processmaker_taskcategories_id, del_index, del_thread)
|
||||
// VALUES ({$glpi_task->getId()}, '{$glpi_task->getType()}', $cases_id, {$pmtaskcat->fields['id']}, $delIndex, $delThread);";
|
||||
//$DB->query( $query );
|
||||
}
|
||||
|
||||
// send notification if needed for new task as now we have the PluginProcessmakerTask in the DB
|
||||
@@ -1989,10 +2067,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id=$cases_id and del_index=$delIndex; ";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
//$res = $DB->query($query);
|
||||
$res = $DB->request('glpi_plugin_processmaker_tasks', ['AND' => ['plugin_processmaker_cases_id' => $cases_id, 'del_index' => $delIndex]]);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
if ($row = $res->next()) {
|
||||
$dbu = new DbUtils;
|
||||
$row = $DB->fetch_array( $res );
|
||||
//$row = $DB->fetch_array( $res );
|
||||
|
||||
$glpi_task = new $row['itemtype'];
|
||||
$glpi_task->getFromDB( $row['items_id'] );
|
||||
@@ -2040,8 +2120,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
self::restoreNotification($donotif);
|
||||
|
||||
// Close the task
|
||||
$DB->query("UPDATE glpi_plugin_processmaker_tasks SET del_thread_status = '".PluginProcessmakerTask::CLOSED."' WHERE id = {$row['id']}");
|
||||
|
||||
//$DB->query("UPDATE glpi_plugin_processmaker_tasks SET del_thread_status = '".PluginProcessmakerTask::CLOSED."' WHERE id = {$row['id']}");
|
||||
$DB->update('glpi_plugin_processmaker_tasks', ['del_thread_status' => PluginProcessmakerTask::CLOSED], ['id' => $row['id']]);
|
||||
// restore current glpi time
|
||||
$_SESSION["glpi_currenttime"] = $saved_date_time;
|
||||
|
||||
@@ -2059,12 +2139,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
*/
|
||||
public function claimTask($cases_id, $delIndex, $users_id_tech = null) {
|
||||
global $DB;
|
||||
|
||||
$res = $DB->request('glpi_plugin_processmaker_tasks', ['AND' => ['plugin_processmaker_cases_id' => $cases_id, 'del_index' => $delIndex]]);
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id='$cases_id' and del_index=$delIndex; ";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
//$res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
if ($row = $res->next()) {
|
||||
$dbu = new DbUtils;
|
||||
$row = $DB->fetch_array( $res );
|
||||
//$row = $DB->fetch_array( $res );
|
||||
$glpi_task = new $row['itemtype'];
|
||||
$glpi_task->getFromDB( $row['items_id'] );
|
||||
|
||||
@@ -2089,14 +2170,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
*/
|
||||
public static function getCaseIdFromItem ($item_type, $item_id) {
|
||||
global $DB;
|
||||
|
||||
$res = $DB->request('glpi_plugin_processmaker_cases', ['AND' => ['itemtype' => $item_type, 'items_id' => $item_id]]);
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE `itemtype` = '$item_type' AND `items_id` = $item_id ;";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
// case is existing for this item
|
||||
// then get info from db
|
||||
$row = $DB->fetch_array($res);
|
||||
|
||||
// $res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
// // case is existing for this item
|
||||
// // then get info from db
|
||||
// $row = $DB->fetch_array($res);
|
||||
if ($row = $res->next()) {
|
||||
return $row['id'];
|
||||
}
|
||||
|
||||
@@ -2112,14 +2193,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
*/
|
||||
public static function getCaseGuidFromItem ($item_type, $item_id) {
|
||||
global $DB;
|
||||
|
||||
$res = $DB->request('glpi_plugin_processmaker_cases', ['AND' => ['itemtype' => $item_type, 'items_id' => $item_id]]);
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE `itemtype` = '$item_type' AND `items_id` = $item_id ;";
|
||||
$res = $DB->query($query);
|
||||
if ($DB->numrows($res) > 0) {
|
||||
// case is existing for this item
|
||||
// then get info from db
|
||||
$row = $DB->fetch_array($res);
|
||||
|
||||
//$res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
// // case is existing for this item
|
||||
// // then get info from db
|
||||
// $row = $DB->fetch_array($res);
|
||||
if ($row = $res->next()) {
|
||||
return $row['case_guid'];
|
||||
}
|
||||
|
||||
@@ -2363,12 +2444,19 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$item_users = $item->userlinkclass;
|
||||
$item_userstable = $dbu->getTableForItemType( $item_users );
|
||||
$itemlink = getForeignKeyFieldForItemType( $itemtype );
|
||||
|
||||
$res = $DB->request([
|
||||
'SELECT' => ['glpi_plugin_processmaker_users.pm_users_id as pm_users_id', 'glpi_plugin_processmaker_users.id as id'],
|
||||
'FROM' => $item_userstable,
|
||||
'LEFT JOIN' => ['glpi_plugin_processmaker_users' => ['FKEY' => ['glpi_plugin_processmaker_users' => 'id', $item_userstable => 'users_id']]],
|
||||
'WHERE' => ['AND' => ["$item_userstable.$itemlink" => $itemId, "$item_userstable.type" => $userType]],
|
||||
'ORDER' => ['ORDER' => $item_userstable.'.id']
|
||||
]);
|
||||
$query = "select glpi_plugin_processmaker_users.pm_users_id as pm_users_id, glpi_plugin_processmaker_users.id as id from $item_userstable
|
||||
left join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.id = $item_userstable.users_id
|
||||
where $item_userstable.$itemlink = $itemId and $item_userstable.type = $userType
|
||||
order by $item_userstable.id";
|
||||
foreach ($DB->request( $query ) as $dbuser) {
|
||||
//foreach ($DB->request( $query ) as $dbuser) {
|
||||
foreach ($res as $dbuser) {
|
||||
$users[] = [ 'glpi_id' => $dbuser['id'], 'pm_id' => $dbuser['pm_users_id'] ];
|
||||
}
|
||||
|
||||
@@ -2612,18 +2700,53 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
global $DB;
|
||||
$dbu = new DbUtils;
|
||||
$processList = [ ];
|
||||
$entityAncestors = implode( ", ", $dbu->getAncestorsOf( $dbu->getTableForItemType( 'Entity' ), $entity ) );
|
||||
if (strlen( $entityAncestors ) > 0) {
|
||||
$entityAncestors = " OR (entities_id IN ($entityAncestors) AND is_recursive = 1) ";
|
||||
//$entityAncestors = implode( ", ", $dbu->getAncestorsOf( $dbu->getTableForItemType( 'Entity' ), $entity ) );
|
||||
$entityAncestors = $dbu->getAncestorsOf( $dbu->getTableForItemType( 'Entity' ), $entity );
|
||||
//if (strlen( $entityAncestors ) > 0) {
|
||||
if ($category > 0) {
|
||||
$query = [
|
||||
'SELECT DISTINCT' => ['glpi_plugin_processmaker_processes.id' ],
|
||||
'FIELDS' => ['glpi_plugin_processmaker_processes.name'],
|
||||
//'DISTINCT' => true,
|
||||
'FROM' => 'glpi_plugin_processmaker_processes',
|
||||
'INNER JOIN' => [
|
||||
'glpi_plugin_processmaker_processes_profiles' => [
|
||||
'FKEY' => [
|
||||
'glpi_plugin_processmaker_processes_profiles' => 'plugin_processmaker_processes_id',
|
||||
'glpi_plugin_processmaker_processes' => 'id',
|
||||
['AND' => [
|
||||
'glpi_plugin_processmaker_processes.itilcategories_id' => ['!=', 0]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'itilcategories_id' => $category,
|
||||
'type' => $type,
|
||||
'profiles_id' => $profile,
|
||||
'entities_id' => $entity
|
||||
]
|
||||
]
|
||||
];
|
||||
if (count( $entityAncestors ) > 0) {
|
||||
//$entityAncestors = " OR (entities_id IN ($entityAncestors) AND is_recursive = 1) ";
|
||||
$entityAncestors[] = $entity;
|
||||
$query['WHERE']['AND']['entities_id'] = $entityAncestors;
|
||||
$query['WHERE']['AND']['is_recursive'] = 1;
|
||||
}
|
||||
|
||||
$query ="SELECT DISTINCT glpi_plugin_processmaker_processes.id, glpi_plugin_processmaker_processes.name FROM glpi_plugin_processmaker_processes
|
||||
INNER JOIN glpi_plugin_processmaker_processes_profiles ON glpi_plugin_processmaker_processes_profiles.plugin_processmaker_processes_id=glpi_plugin_processmaker_processes.id
|
||||
WHERE is_active = 1 AND itilcategories_id = $category AND `type` = $type AND profiles_id = $profile AND (entities_id = $entity $entityAncestors)";
|
||||
|
||||
foreach ($DB->request( $query ) as $row) {
|
||||
$res = $DB->request($query);
|
||||
foreach ($res as $row) {
|
||||
$processList[] = $row;
|
||||
}
|
||||
$processList = array_map("unserialize", array_unique(array_map("serialize", $processList)));
|
||||
}
|
||||
//$query ="SELECT DISTINCT glpi_plugin_processmaker_processes.id, glpi_plugin_processmaker_processes.name FROM glpi_plugin_processmaker_processes
|
||||
// INNER JOIN glpi_plugin_processmaker_processes_profiles ON glpi_plugin_processmaker_processes_profiles.plugin_processmaker_processes_id=glpi_plugin_processmaker_processes.id
|
||||
// WHERE is_active = 1 AND itilcategories_id = $category AND `type` = $type AND profiles_id = $profile AND (entities_id = $entity $entityAncestors)";
|
||||
|
||||
//foreach ($DB->request( $query ) as $row) {
|
||||
|
||||
return $processList;
|
||||
|
||||
@@ -2757,8 +2880,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
"GLPI_NEXT_GROUP_TO_BE_ASSIGNED",
|
||||
"GLPI_ITEM_TITLE",
|
||||
"GLPI_TICKET_FOLLOWUP_CONTENT",
|
||||
"GLPI_ITEM_FOLLOWUP_CONTENT",
|
||||
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE",
|
||||
"GLPI_ITEM_FOLLOWUP_IS_PRIVATE",
|
||||
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID",
|
||||
"GLPI_ITEM_FOLLOWUP_REQUESTTYPES_ID",
|
||||
"GLPI_ITEM_TASK_ENDDATE",
|
||||
"GLPI_ITEM_TASK_STARTDATE",
|
||||
"GLPI_ITEM_TASK_REMINDER",
|
||||
@@ -2842,7 +2968,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
}
|
||||
|
||||
$createFollowup = false; // by default
|
||||
if (array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $casevariablevalues ) && $casevariablevalues[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') {
|
||||
if (array_key_exists( 'GLPI_ITEM_FOLLOWUP_CONTENT', $casevariablevalues ) && $casevariablevalues[ 'GLPI_ITEM_FOLLOWUP_CONTENT' ] != '') {
|
||||
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_IS_PRIVATE', $infoForTasks )
|
||||
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID', $infoForTasks )
|
||||
$createFollowup = true;
|
||||
@@ -2883,7 +3009,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
// create a followup if requested
|
||||
if ($createFollowup && $itemtype == 'Ticket') {
|
||||
$this->addTicketFollowup( $items_id, $casevariablevalues );
|
||||
$this->addItemFollowup( $itemtype, $items_id, $casevariablevalues );
|
||||
}
|
||||
|
||||
if ($txtItemTitle != '') {
|
||||
@@ -2920,10 +3046,23 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$locTaskCat = new PluginProcessmakerTaskCategory;
|
||||
if ($locTaskCat->getFromGUID($route->taskId) && $locTaskCat->fields['is_subprocess']) {
|
||||
// look for APP_UID
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => [
|
||||
'APPUID'
|
||||
],
|
||||
'FROM' => 'SUB_APPLICATION',
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'APP_PARENT' => $myCase->fields['case_guid'],
|
||||
'DEL_INDEX_PARENT' => $route->delIndex,
|
||||
'SA_STATUS' => 'ACTIVE'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$myCase->fields['case_guid']}' AND DEL_INDEX_PARENT={$route->delIndex} AND SA_STATUS='ACTIVE'"); // AND DEL_THREAD_PARENT={$route->delThread} seems like it is not set to correct threadIndex
|
||||
if ($res && $PM_DB->numrows($res) == 1) {
|
||||
if ($row = $res->next() && $PM_DB->numrows($res) == 1) {
|
||||
// then new task is a sub-process,
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
//$row = $PM_DB->fetch_assoc($res);
|
||||
|
||||
// now need to get the PRO_UID
|
||||
$sub_caseInfo = self::getCaseInfo($row['APP_UID']);
|
||||
@@ -2961,7 +3100,18 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
// if end date was specified, then must change due date of the PM task
|
||||
if ($taskEndDate != '') {
|
||||
$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$sub_caseInfo->caseId."' AND DEL_INDEX=".$sub_route->delIndex);
|
||||
$PM_DB->update(
|
||||
'APP_DELEGATION',
|
||||
[
|
||||
'DEL_TASK_DUE_DATE' => $taskEndDate
|
||||
],
|
||||
['AND' => [
|
||||
'APP_UID' => $sub_caseInfo->caseId,
|
||||
'DEL_INDEX' => $sub_route->delIndex
|
||||
]
|
||||
]
|
||||
);
|
||||
//$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$sub_caseInfo->caseId."' AND DEL_INDEX=".$sub_route->delIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3032,7 +3182,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
);
|
||||
// if end date was specified, then must change due date of the PM task
|
||||
if ($taskEndDate != '') {
|
||||
$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$caseInfo->caseId."' AND DEL_INDEX=".$route->delIndex);
|
||||
$PM_DB->update(
|
||||
'APP_DELEGATION',
|
||||
[
|
||||
'DEL_TASK_DUE_DATE' => $taskEndDate
|
||||
],
|
||||
['AND' => [
|
||||
'APP_UID' => $caseInfo->caseId,
|
||||
'DEL_INDEX' => $route->delIndex
|
||||
]
|
||||
]);
|
||||
//$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$caseInfo->caseId."' AND DEL_INDEX=".$route->delIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3079,7 +3239,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
// if end date was specified, then must change due date of the PM task
|
||||
if ($taskEndDate != '') {
|
||||
$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$sub_caseInfo->caseId."' AND DEL_INDEX=".$open_task->delIndex);
|
||||
$PM_DB->update('APP_DELEGATION', ['DEL_TASK_DUE_DATE' => $taskEndDate], ['AND' => ['APP_UID' => $sub_caseInfo->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3102,7 +3263,15 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
public static function getPMGroups() {
|
||||
global $PM_DB;
|
||||
$pmGroupList = [];
|
||||
foreach ($PM_DB->request("SELECT * FROM CONTENT WHERE CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG='en'") as $dbgroup) {
|
||||
$res = $PM_DB->request(
|
||||
'CONTENT', [
|
||||
'AND' => [
|
||||
'CONTENT.CON_CATEGORY' => 'GRP_TITLE',
|
||||
'CONTENT.CON_LANG' => 'en'
|
||||
]
|
||||
]);
|
||||
//foreach ($PM_DB->request("SELECT * FROM CONTENT WHERE CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG='en'") as $dbgroup) {
|
||||
foreach ($res as $dbgroup) {
|
||||
$pmGroupList[$dbgroup['CON_VALUE']] = $dbgroup;
|
||||
}
|
||||
return $pmGroupList;
|
||||
|
||||
@@ -116,12 +116,10 @@ class PluginProcessmakerProfile extends CommonDBTM {
|
||||
$dbu = new DbUtils;
|
||||
$profileRight = new ProfileRight();
|
||||
foreach ($rights as $right => $value) {
|
||||
if ($dbu->countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
|
||||
if ($dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]]) && $drop_existing) {
|
||||
$profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]);
|
||||
}
|
||||
if (!$dbu->countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
|
||||
if (!$dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]])) {
|
||||
$myright['profiles_id'] = $profiles_id;
|
||||
$myright['name'] = $right;
|
||||
$myright['rights'] = $value;
|
||||
|
||||
@@ -79,13 +79,24 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
$selfTable = $dbu->getTableForItemType( __CLASS__);
|
||||
//$itemTypeTaskTable = getTableForItemType( $itemtype );
|
||||
|
||||
$res = $DB->request([
|
||||
'SELECT' => $selfTable.'.items_id AS taskID',
|
||||
'FROM' => $selfTable,
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
$selfTable.'del_thread_status' => self::OPEN,
|
||||
$selfTable.'plugin_processmaker_cases_id' =>$case_id
|
||||
]
|
||||
]
|
||||
]);
|
||||
$query = "SELECT `$selfTable`.`items_id` as taskID from $selfTable
|
||||
WHERE `$selfTable`.`del_thread_status` = '".self::OPEN."' AND `$selfTable`.`plugin_processmaker_cases_id` = '$case_id';";
|
||||
|
||||
//$query = "SELECT $itemTypeTaskTable.id as taskID from $itemTypeTaskTable
|
||||
// INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
|
||||
// WHERE $itemTypeTaskTable.state=1 and $selfTable.plugin_processmaker_cases_id='$case_id';";
|
||||
foreach ($DB->request($query) as $row) {
|
||||
//foreach ($DB->request($query) as $row) {
|
||||
foreach ($res as $row) {
|
||||
$ret[$row['taskID']]=$row['taskID'];
|
||||
}
|
||||
return $ret;
|
||||
@@ -164,8 +175,17 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
|
||||
// get all tasks that are OPEN for this case
|
||||
$tasks = [];
|
||||
$res = $DB->request(
|
||||
'glpi_plugin_processmaker_tasks', [
|
||||
'AND' => [
|
||||
'plugin_processmaker_cases_id' => $case->fields['id'],
|
||||
'del_thread_status' => 'OPEN'
|
||||
]
|
||||
]
|
||||
);
|
||||
$query = "SELECT * FROM `glpi_plugin_processmaker_tasks` WHERE `plugin_processmaker_cases_id`={$case->fields['id']} AND `del_thread_status`='OPEN'";
|
||||
foreach ($DB->request($query) as $task) {
|
||||
//foreach ($DB->request($query) as $task) {
|
||||
foreach ($res as $task) {
|
||||
$tasks[$task['del_index']] = $task;
|
||||
}
|
||||
|
||||
@@ -200,9 +220,21 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
}
|
||||
|
||||
foreach ($main_tasks as $task) {
|
||||
$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$case->fields['case_guid']}' AND DEL_INDEX_PARENT={$task->delIndex} AND SA_STATUS='ACTIVE'");
|
||||
if ($res && $PM_DB->numrows($res) == 1) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => 'APP_UID',
|
||||
'FROM' => 'SUB_APPLICATION',
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'APP_PARENT' => $case->fields['case_guid'],
|
||||
'DEL_INDEX_PARENT' => $task->delIndex,
|
||||
'SA_STATUS' => 'ACTIVE'
|
||||
]
|
||||
]
|
||||
]);
|
||||
//$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$case->fields['case_guid']}' AND DEL_INDEX_PARENT={$task->delIndex} AND SA_STATUS='ACTIVE'");
|
||||
//if ($res && $PM_DB->numrows($res) == 1) {
|
||||
if ($row = $res->next() && $res->numrows() == 1) {
|
||||
//$row = $PM_DB->fetch_assoc($res);
|
||||
$loc_case = new PluginProcessmakerCase;
|
||||
$loc_case->getFromGUID($row['APP_UID']);
|
||||
$tab[$loc_case->getID()."-".$task->delIndex] = "<i><sub>> ".$task->taskName."</sub></i>";
|
||||
@@ -253,18 +285,34 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
|
||||
// get all tasks that are OPEN for any sub-case of this case
|
||||
$sub_tasks = [];
|
||||
$query = "SELECT `glpi_plugin_processmaker_tasks`.* FROM `glpi_plugin_processmaker_tasks`
|
||||
WHERE `glpi_plugin_processmaker_tasks`.`plugin_processmaker_cases_id`={$matches['cases_id']} AND `del_thread_status`='OPEN'";
|
||||
foreach ($DB->request($query) as $task) {
|
||||
$res = $DB->request(
|
||||
'glpi_plugin_processmaker_tasks AS ppt',
|
||||
['AND' => [
|
||||
'ppt.plugin_processmaker_cases_id' => $matches['cases_id'],
|
||||
'del_thread_status' => 'OPEN']
|
||||
]
|
||||
);
|
||||
//$query = "SELECT `glpi_plugin_processmaker_tasks`.* FROM `glpi_plugin_processmaker_tasks`
|
||||
// WHERE `glpi_plugin_processmaker_tasks`.`plugin_processmaker_cases_id`={$matches['cases_id']} AND `del_thread_status`='OPEN'";
|
||||
//foreach ($DB->request($query) as $task) {
|
||||
foreach ($res as $task) {
|
||||
$sub_tasks[$task['plugin_processmaker_cases_id']][$task['del_index']] = $task;
|
||||
}
|
||||
$sub_case = new PluginProcessmakerCase;
|
||||
$sub_case->getFromDB($matches['cases_id']);
|
||||
$sub_case_url = $sub_case->getLinkURL().'&forcetab=PluginProcessmakerTask$';
|
||||
|
||||
$query = "SELECT `DEL_INDEX`, `DEL_DELEGATE_DATE` FROM `APP_DELEGATION` WHERE `APP_UID`='{$sub_case->fields['case_guid']}'";
|
||||
$res = $PM_DB->request([
|
||||
'SELECT' => ['DEL_INDEX', 'DEL_DELEGATE_DATE'],
|
||||
'FROM' => 'APP_DELEGATION',
|
||||
'WHERE' => [
|
||||
'APP_UID' => $sub_case->fields['case_guid']
|
||||
]
|
||||
]);
|
||||
//$query = "SELECT `DEL_INDEX`, `DEL_DELEGATE_DATE` FROM `APP_DELEGATION` WHERE `APP_UID`='{$sub_case->fields['case_guid']}'";
|
||||
$sub_tasks_pm = [];
|
||||
foreach ($PM_DB->request($query) as $row) {
|
||||
//foreach ($PM_DB->request($query) as $row) {
|
||||
foreach ($res as $row) {
|
||||
$sub_tasks_pm[$row['DEL_INDEX']] = $row['DEL_DELEGATE_DATE'];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,36 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
"<th>".__('Sub-process', 'processmaker')."</th>" .
|
||||
"</tr>";
|
||||
|
||||
$res = $DB->request([
|
||||
'SELECT' => [
|
||||
'pm.pm_task_guid',
|
||||
'pm.taskcategories_id',
|
||||
'pm.is_start',
|
||||
'gl.name',
|
||||
'gl.completename',
|
||||
'gl.comment',
|
||||
'pm.is_active',
|
||||
'pm.is_subprocess'
|
||||
],
|
||||
'FROM' => 'glpi_plugin_processmaker_taskcategories AS pm',
|
||||
'LEFT JOIN' => [
|
||||
'glpi_taskcategories AS gl' => [
|
||||
'FKEY' => [
|
||||
'gl' => 'id',
|
||||
'pm' => 'taskcategories_id'
|
||||
]
|
||||
]
|
||||
],
|
||||
'WHERE' => [
|
||||
'pm.plugin_processmaker_processes_id' => $item->getId()
|
||||
]
|
||||
]);
|
||||
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`is_start`, gl.name, gl.completename, gl.`comment`, pm.is_active, pm.is_subprocess FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||
WHERE pm.plugin_processmaker_processes_id=".$item->getID().";";
|
||||
|
||||
foreach ($DB->request($query) as $taskCat) {
|
||||
//foreach ($DB->request($query) as $taskCat) {
|
||||
foreach ($res as $taskCat) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
|
||||
echo "<td class='b'><a href='".
|
||||
@@ -118,19 +143,35 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
function getFromGUID($task_guid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `pm_task_guid` = '$task_guid'";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
$res = $DB->request(
|
||||
$this->getTable(),
|
||||
[
|
||||
'pm_task_guid' => $task_guid
|
||||
]
|
||||
);
|
||||
if ($res) {
|
||||
if ($res->numrows() != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
$this->fields = $res->next();
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//$query = "SELECT *
|
||||
// FROM `".$this->getTable()."`
|
||||
// WHERE `pm_task_guid` = '$task_guid'";
|
||||
|
||||
//if ($result = $DB->query($query)) {
|
||||
// if ($DB->numrows($result) != 1) {
|
||||
// return false;
|
||||
// }
|
||||
// $this->fields = $DB->fetch_assoc($result);
|
||||
// if (is_array($this->fields) && count($this->fields)) {
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -144,19 +185,33 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
function getFromDBbyCategory($catid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `taskcategories_id` = $catid";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
$res = $DB->request(
|
||||
$this->getTable(),
|
||||
[
|
||||
'taskcategories_id' => $catid
|
||||
]
|
||||
);
|
||||
//$query = "SELECT *
|
||||
// FROM `".$this->getTable()."`
|
||||
// WHERE `taskcategories_id` = $catid";
|
||||
if ($res) {
|
||||
if ($res->numrows() != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
$this->fields = $res->next();
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//if ($result = $DB->query($query)) {
|
||||
// if ($DB->numrows($result) != 1) {
|
||||
// return false;
|
||||
// }
|
||||
// $this->fields = $DB->fetch_assoc($result);
|
||||
// if (is_array($this->fields) && count($this->fields)) {
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,107 +28,207 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
static function getSqlSearchResult ($taskId, $count = true, $right = "all", $entity_restrict = -1, $value = 0,
|
||||
$used = [], $search = '', $limit = '') {
|
||||
global $DB, $PM_DB, $CFG_GLPI;
|
||||
|
||||
$res1 = new QuerySubQuery([
|
||||
'SELECT' => ['GROUP_USER.USR_UID AS pm_user_id'],
|
||||
'FROM' => 'TASK_USER',
|
||||
'INNER JOIN' => [
|
||||
'GROUP_USER' => [
|
||||
'FKEY' => [
|
||||
'GROUP_USER' => 'GRP_UID',
|
||||
'TASK_USER' => 'USR_UID',
|
||||
['AND' => [
|
||||
'TASk_USER.TU_RELATION' => 2,
|
||||
'TASk_USER.TU_TYPE' => 1
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$res2 = new QuerySubQuery([
|
||||
'SELECT' => 'TASK_USER.USR_UID AS pm_user_id',
|
||||
'FROM' => 'TASK_USER',
|
||||
'WHERE' => [
|
||||
'AND' => [
|
||||
'TAS_UID' => $taskId,
|
||||
'TASK_USER.TU_RELATION' => 1,
|
||||
'TASk_USER.TU_TYPE' => 1
|
||||
]
|
||||
]
|
||||
]);
|
||||
$union = new QueryUnion([$res1, $res2]);
|
||||
$res = $PM_DB->request([
|
||||
'FROM' => $union
|
||||
]);
|
||||
// first need to get all users from $taskId
|
||||
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
|
||||
$pmQuery = "SELECT GROUP_USER.USR_UID AS pm_user_id FROM TASK_USER
|
||||
JOIN GROUP_USER ON GROUP_USER.GRP_UID=TASK_USER.USR_UID AND TASK_USER.TU_RELATION = 2 AND TASK_USER.TU_TYPE=1
|
||||
WHERE TAS_UID = '$taskId'
|
||||
UNION
|
||||
SELECT TASK_USER.USR_UID AS pm_user_id FROM TASK_USER
|
||||
WHERE TAS_UID = '$taskId' AND TASK_USER.TU_RELATION = 1 AND TASK_USER.TU_TYPE=1 ; ";
|
||||
//$pmQuery = "SELECT GROUP_USER.USR_UID AS pm_user_id FROM TASK_USER
|
||||
// JOIN GROUP_USER ON GROUP_USER.GRP_UID=TASK_USER.USR_UID AND TASK_USER.TU_RELATION = 2 AND TASK_USER.TU_TYPE=1
|
||||
// WHERE TAS_UID = '$taskId'
|
||||
// UNION
|
||||
// SELECT TASK_USER.USR_UID AS pm_user_id FROM TASK_USER
|
||||
// WHERE TAS_UID = '$taskId' AND TASK_USER.TU_RELATION = 1 AND TASK_USER.TU_TYPE=1 ; ";
|
||||
$pmUsers = [ ];
|
||||
foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
|
||||
//foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
|
||||
foreach ($res as $pmUser) {
|
||||
$pmUsers[ ] = $pmUser[ 'pm_user_id' ];
|
||||
}
|
||||
|
||||
$where = '';
|
||||
//$where = '';
|
||||
$joinprofile = false;
|
||||
|
||||
switch ($right) {
|
||||
case "id" :
|
||||
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
|
||||
$used[] = Session::getLoginUserID();
|
||||
//$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
|
||||
$query2['WHERE']['AND']['glpi_users.id'] = Session::getLoginUserID();
|
||||
break;
|
||||
|
||||
case "all" :
|
||||
$where = " `glpi_users`.`id` > '1' ";
|
||||
//$where = " `glpi_users`.`id` > '1' ";
|
||||
$query2['WHERE']['AND']['glpi_users.id'] = ['>', 1];
|
||||
break;
|
||||
}
|
||||
|
||||
$where .= " AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
|
||||
//$where .= " AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
|
||||
|
||||
$where .= " AND `glpi_users`.`is_deleted` = '0'
|
||||
AND `glpi_users`.`is_active` = '1' ";
|
||||
//$where .= " AND `glpi_users`.`is_deleted` = '0'
|
||||
// AND `glpi_users`.`is_active` = '1' ";
|
||||
|
||||
$query2['WHERE']['AND']['glpi_plugin_processmaker_users.pm_users_id'] = $pmUsers;
|
||||
$query2['WHERE']['AND']['glpi_users.is_deleted'] = 0;
|
||||
$query2['WHERE']['AND']['glpi_users.is_active'] = 1;
|
||||
|
||||
if ((is_numeric($value) && $value)
|
||||
|| count($used)) {
|
||||
|
||||
$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
//$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
if (is_numeric($value)) {
|
||||
$first = false;
|
||||
$where .= $value;
|
||||
//$where .= $value;
|
||||
$used[] = $value;
|
||||
//$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $value;
|
||||
} else {
|
||||
$first = true;
|
||||
}
|
||||
foreach ($used as $val) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$where .= ",";
|
||||
}
|
||||
$where .= $val;
|
||||
}
|
||||
$where .= ")";
|
||||
//$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $used;
|
||||
//foreach ($used as $val) {
|
||||
// if ($first) {
|
||||
// $first = false;
|
||||
// } else {
|
||||
// $where .= ",";
|
||||
// }
|
||||
// $where .= $val;
|
||||
//}
|
||||
//$where .= ")";
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
|
||||
//$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
|
||||
$query2['SELECT'] = ['COUNT DISTINCT' => 'glpi_users.id AS cpt'];
|
||||
|
||||
} else {
|
||||
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
|
||||
//$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
|
||||
$query2['SELECT DISTINCT'] = 'glpi_users.id';
|
||||
$query2['FIELDS'] = ['glpi_users.realname', 'glpi_users.firstname', 'glpi_users.name', 'glpi_useremails.email'];
|
||||
}
|
||||
$query2['FROM'] = 'glpi_plugin_processmaker_users';
|
||||
//$query .= "FROM glpi_plugin_processmaker_users
|
||||
// JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id ";
|
||||
$query2['FROM'] = 'glpi_plugin_processmaker_users';
|
||||
$query2['INNER JOIN'] = [
|
||||
'glpi_users' => [
|
||||
'FKEY' => [
|
||||
'glpi_users' => 'id',
|
||||
'glpi_plugin_processmaker_users' => 'id'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$query .= "FROM glpi_plugin_processmaker_users
|
||||
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id ";
|
||||
|
||||
$query .= " LEFT JOIN `glpi_useremails`
|
||||
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
|
||||
$query .= " LEFT JOIN `glpi_profiles_users`
|
||||
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
|
||||
//$query .= " LEFT JOIN `glpi_useremails`
|
||||
// ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
|
||||
$query2['LEFT JOIN'] = [
|
||||
'glpi_useremails' => [
|
||||
'FKEY' => [
|
||||
'glpi_users' => 'id',
|
||||
'glpi_useremails' => 'users_id', [
|
||||
'AND' => [
|
||||
'glpi_useremails.is_default' => 1
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'glpi_profiles_users' => [
|
||||
'FKEY' => [
|
||||
'glpi_users' => 'id',
|
||||
'glpi_profiles_users' => 'users_id'
|
||||
]
|
||||
]
|
||||
];
|
||||
//$query .= " LEFT JOIN `glpi_profiles_users`
|
||||
// ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
|
||||
|
||||
if ($joinprofile) {
|
||||
$query .= " LEFT JOIN `glpi_profiles`
|
||||
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
|
||||
$query2['LEFT JOIN'] = [
|
||||
'glpi_profiles' => [
|
||||
'FKEY' => [
|
||||
'glpi_profiles' => 'id',
|
||||
'glpi_profiles_user' => 'profiles_id'
|
||||
]
|
||||
]
|
||||
];
|
||||
//$query .= " LEFT JOIN `glpi_profiles`
|
||||
// ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query .= " WHERE $where ";
|
||||
$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $used;
|
||||
//$query .= " WHERE $where ";
|
||||
} else {
|
||||
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
|
||||
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
|
||||
Search::makeTextSearch($search).")";
|
||||
$query2['WHERE']['AND'] = [
|
||||
'glpi_users.name' => ['LIKE',Search::makeTextSearchValue($search)],
|
||||
'OR' => [
|
||||
'glpi_users.realname' => ['LIKE',Search::makeTextSearchValue($search)],
|
||||
'glpi_users.firstname' => ['LIKE',Search::makeTextSearchValue($search)],
|
||||
'glpi_users.phone' => ['LIKE',Search::makeTextSearchValue($search)],
|
||||
'glpi_useremails.email' => ['LIKE',Search::makeTextSearchValue($search)],
|
||||
'RAW' => [
|
||||
"CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`)".Search::makeTextSearch($search)
|
||||
]
|
||||
]
|
||||
];
|
||||
//$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
|
||||
// OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
|
||||
// OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
|
||||
// OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
|
||||
// OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
|
||||
// OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
|
||||
// Search::makeTextSearch($search).")";
|
||||
}
|
||||
$query .= " WHERE $where ";
|
||||
$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $used;
|
||||
//$query .= " WHERE $where ";
|
||||
|
||||
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
|
||||
$query.=" ORDER BY `glpi_users`.`firstname`,
|
||||
`glpi_users`.`realname`,
|
||||
`glpi_users`.`name` ";
|
||||
//$query.=" ORDER BY `glpi_users`.`firstname`,
|
||||
// `glpi_users`.`realname`,
|
||||
// `glpi_users`.`name` ";
|
||||
$query2['ORDER'] = ['glpi_users.firstname', 'glpi_users.realname', 'glpi_users.name'];
|
||||
} else {
|
||||
$query.=" ORDER BY `glpi_users`.`realname`,
|
||||
`glpi_users`.`firstname`,
|
||||
`glpi_users`.`name` ";
|
||||
//$query.=" ORDER BY `glpi_users`.`realname`,
|
||||
// `glpi_users`.`firstname`,
|
||||
// `glpi_users`.`name` ";
|
||||
$query2['ORDER'] = ['glpi_users.realname', 'glpi_users.firstname', 'glpi_users.name'];
|
||||
}
|
||||
|
||||
if ($search != $CFG_GLPI["ajax_wildcard"]) {
|
||||
$query .= " $limit";
|
||||
//$query .= " $limit";
|
||||
$query2['LIMIT'] = 200;
|
||||
}
|
||||
}
|
||||
|
||||
return $DB->query($query);
|
||||
return $DB->request($query2);
|
||||
//return $DB->query($query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
<num>3.5.2</num>
|
||||
<compatibility>9.3</compatibility>
|
||||
</version>
|
||||
<version>
|
||||
<num>3.6.2</num>
|
||||
<compatibility>9.4</compatibility>
|
||||
</version>
|
||||
</versions>
|
||||
<langs>
|
||||
<lang>en_gb</lang>
|
||||
|
||||
10
setup.php
10
setup.php
@@ -2,7 +2,7 @@
|
||||
|
||||
// used for case cancellation
|
||||
define("CANCEL", 256);
|
||||
define('PROCESSMAKER_VERSION', '3.5.2');
|
||||
define('PROCESSMAKER_VERSION', '3.6.2');
|
||||
|
||||
// Init the hooks of the plugins -Needed
|
||||
function plugin_init_processmaker() {
|
||||
@@ -128,8 +128,8 @@ function plugin_version_processmaker() {
|
||||
'homepage' => 'https://github.com/tomolimo/processmaker',
|
||||
'requirements' => [
|
||||
'glpi' => [
|
||||
'min' => '9.3',
|
||||
'max' => '9.4'
|
||||
'min' => '9.4',
|
||||
'max' => '9.5'
|
||||
],
|
||||
]
|
||||
];
|
||||
@@ -137,8 +137,8 @@ function plugin_version_processmaker() {
|
||||
|
||||
// Optional : check prerequisites before install : may print errors or add to message after redirect
|
||||
function plugin_processmaker_check_prerequisites() {
|
||||
if (version_compare(GLPI_VERSION, '9.3', 'lt') || version_compare(GLPI_VERSION, '9.4', 'ge')) {
|
||||
echo "This plugin requires GLPI >= 9.3 and < 9.4";
|
||||
if (version_compare(GLPI_VERSION, '9.4', 'lt') || version_compare(GLPI_VERSION, '9.5', 'ge')) {
|
||||
echo "This plugin requires GLPI >= 9.4 and < 9.5";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user