Beta version of sub-process (sub-case) management

Partially re-coding to be more compliant to GLPI framework
This commit is contained in:
tomolimo
2018-07-04 11:24:29 +02:00
parent 71c1e00e8a
commit 51a71c4289
35 changed files with 2418 additions and 1593 deletions

View File

@@ -3,7 +3,6 @@ if (strpos($_SERVER['PHP_SELF'],"asynchronousdatas.php")) {
$AJAX_INCLUDE = 1;
define('GLPI_ROOT','../../..');
include (GLPI_ROOT."/inc/includes.php");
//header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}

View File

@@ -13,7 +13,7 @@ if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) {
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
die("Can not access directly to this file");
}
@@ -24,6 +24,7 @@ if (isset($_REQUEST["entity_restrict"])
&& (substr($_REQUEST["entity_restrict"], 0, 1) === '[')
&& (substr($_REQUEST["entity_restrict"], -1) === ']')) {
$_REQUEST["entity_restrict"] = json_decode($_REQUEST["entity_restrict"]);
$_REQUEST["entity_restrict"] = $_REQUEST["entity_restrict"][0];
}
// Security
@@ -62,10 +63,11 @@ if (empty($_REQUEST['searchText'])) {
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
if (in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) )) {
array_push( $processes, array( 'id' => $data["id"],
'text' => $data["name"] ));
while ($data = $DB->fetch_array($result)) {
$process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true);
if (in_array( $_REQUEST["entity_restrict"], $process_entities)) {
array_push( $processes, array( 'id' => $data["id"],
'text' => $data["name"] ));
$count++;
}
}

View File

@@ -13,7 +13,7 @@
//}
//if (!defined('GLPI_ROOT')) {
// die("Can not acces directly to this file");
// die("Can not access directly to this file");
//}

View File

@@ -16,11 +16,9 @@ if (strpos($_SERVER['PHP_SELF'], "dropdownUsers.php")) {
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
die("Can not access directly to this file");
}
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
Session::checkLoginUser();
@@ -58,7 +56,7 @@ if (!isset($_REQUEST['page'])) {
if ($one_item < 0) {
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['pmTaskId'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['taskGuid'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
$_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT);
} else {
$query = "SELECT DISTINCT `glpi_users`.*

View File

@@ -13,7 +13,7 @@ if (strpos($_SERVER['PHP_SELF'], "task_users.php")) {
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
die("Can not access directly to this file");
}
Session::checkLoginUser();
@@ -24,22 +24,23 @@ $rand = rand();
echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQUEST['delIndex']."' id='processmaker_form_task$rand-".$_REQUEST['delIndex']."' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo $LANG['processmaker']['item']['reassigncase']."&nbsp;";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='id' value='".$_REQUEST['itemId']."'>";
echo "<input type='hidden' name='itemtype' value='".$_REQUEST['itemType']."'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$_REQUEST['caseId']."'>";
echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$_REQUEST['delIndex']."'>";
echo "<input type='hidden' name='plugin_processmaker_userId' value='".$_REQUEST['userId']."'>";
echo "<input type='hidden' name='plugin_processmaker_taskId' value='".$_REQUEST['taskId']."'>";
echo "<input type='hidden' name='plugin_processmaker_delThread' value='".$_REQUEST['delThread']."'>";
echo "<input type='hidden' name='items_id' value='".$_REQUEST['items_id']."'>";
echo "<input type='hidden' name='itemtype' value='".$_REQUEST['itemtype']."'>";
echo "<input type='hidden' name='cases_id' value='".$_REQUEST['cases_id']."'>";
echo "<input type='hidden' name='delIndex' value='".$_REQUEST['delIndex']."'>";
echo "<input type='hidden' name='users_id' value='".$_REQUEST['users_id']."'>";
echo "<input type='hidden' name='taskGuid' value='".$_REQUEST['taskGuid']."'>";
echo "<input type='hidden' name='delThread' value='".$_REQUEST['delThread']."'>";
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
'value' => $_REQUEST['users_id'],
'used' => [$_REQUEST['users_id']],
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
'entity_sons' => false, // not used, as any user can be assigned to any tasks
'right' => 'all',
'rand' => $rand,
'width' => '',
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
'specific_tags' => array('taskGuid' => $_REQUEST['taskGuid'])));
echo "&nbsp;&nbsp;";
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
Html::closeForm(true);

69
front/case.form.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
include_once ("../../../inc/includes.php");
$locCase = new PluginProcessmakerCase();
function glpi_processmaker_case_reload_page() {
global $PM_SOAP;
// now redirect to item form page
$config = $PM_SOAP->config;
echo "<html><body><script>";
if (isset($config->fields['domain']) && $config->fields['domain'] != '') {
echo "document.domain='{$config->fields['domain']}';";
}
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>";
}
// check if it is from PM pages
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'route' && isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) {
// then get item id from DB
if ($locCase->getFromGUID($_REQUEST['APP_UID'])) {
if (isset( $_REQUEST['form'] )) {
$PM_SOAP->derivateCase($locCase, $_REQUEST);
}
}
glpi_processmaker_case_reload_page();
} else
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
// delete case from case table, this will also delete the tasks
if ($locCase->getFromDB($_POST['cases_id']) && $locCase->deleteCase()) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
}
// will redirect to item or to list if no item
$locCase->redirectToList();
} else
if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID'])) {
// Claim task management
// here we are in a Claim request
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromGUID( $_REQUEST['form']['APP_UID'] )) {
$pmClaimCase = $PM_SOAP->claimCase($myCase->fields['case_guid'], $_REQUEST['DEL_INDEX'] );
// now manage tasks associated with item
$PM_SOAP->claimTask($myCase->getID(), $_REQUEST['DEL_INDEX']);
}
glpi_processmaker_case_reload_page();
} else
if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) {
Html::header(__('Process cases', 'processmaker'), $_SERVER['PHP_SELF'], "helpdesk", "PluginProcessmakerCase", "cases");
if ($locCase->getFromDB($_REQUEST['id'])) {
$locCase->display($_REQUEST);
Html::footer();
}
}

View File

@@ -1,40 +1,39 @@
<?php
include_once '../../../inc/includes.php';
//include_once '../../../inc/includes.php';
// check if it is from PM pages
if (isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) {
// then get item id from DB
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromDB( $_REQUEST['APP_UID'] )) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login( );
//// check if it is from PM pages
//if (isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) {
// // then get item id from DB
// $myCase = new PluginProcessmakerCase;
// if ($myCase->getFromGUID($_REQUEST['APP_UID'])) {
// //$PM_SOAP = new PluginProcessmakerProcessmaker();
// //$PM_SOAP->login( );
if (isset( $_REQUEST['form'] )) {
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
}
}
// if (isset( $_REQUEST['form'] )) {
// $PM_SOAP->derivateCase($myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
// }
// }
} else if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID'])) {
// Claim task management
// here we are in a Claim request
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromDB( $_REQUEST['form']['APP_UID'] )) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login( );
//} else
// if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID'])) {
// // Claim task management
// // here we are in a Claim request
// $myCase = new PluginProcessmakerCase;
// if ($myCase->getFromGUID( $_REQUEST['form']['APP_UID'] )) {
// //$PM_SOAP = new PluginProcessmakerProcessmaker();
// //$PM_SOAP->login( );
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
// now manage tasks associated with item
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
}
}
// now redirect to item form page
$config = PluginProcessmakerConfig::getInstance();
echo "<html><body><script>";
if (isset($config->fields['domain']) && $config->fields['domain'] != '') {
echo "document.domain='{$config->fields['domain']}';";
}
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>";
// $pmClaimCase = $PM_SOAP->claimCase($myCase->fields['case_guid'], $_REQUEST['DEL_INDEX'] );
// // now manage tasks associated with item
// $PM_SOAP->claimTask($myCase->getID(), $_REQUEST['DEL_INDEX']);
// }
//}
//// now redirect to item form page
//$config = $PM_SOAP->config; // PluginProcessmakerConfig::getInstance();
//echo "<html><body><script>";
//if (isset($config->fields['domain']) && $config->fields['domain'] != '') {
// echo "document.domain='{$config->fields['domain']}';";
//}
//echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>";

23
front/case.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
include_once ("../../../inc/includes.php");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "helpdesk", "PluginProcessmakerCase", "cases");
if (Session::haveRightsOr("plugin_processmaker_config", [READ, UPDATE])) {
//$process=new PluginProcessmakerProcess();
//if (isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config", UPDATE)) {
// $process->refresh();
// Html::back();
//}
//$process->title();
Search::show('PluginProcessmakerCase');
} else {
Html::displayRightError();
}
Html::footer();

View File

@@ -2,7 +2,7 @@
include_once ("../../../inc/includes.php");
Plugin::load('processmaker', true);
Plugin::load('processmaker', true); // ???
if (!isset($_REQUEST["id"])) {
$_REQUEST["id"] = "";

View File

@@ -4,36 +4,14 @@ include_once ("../../../inc/includes.php");
Session::checkCentralAccess();
$profile = new Profile();
$right = new PluginProcessmakerProcess_Profile();
$process = new PluginProcessmakerProcess();
if (isset($_POST["add"])) {
$right->check(-1, UPDATE, $_POST);
if ($right->add($_POST)) {
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
}
Html::back();
} else if (isset($_POST["delete"])) {
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($right->can($key, UPDATE)) {
$right->delete(array('id' => $key));
}
}
}
//if (isset($_POST["processes_id"])) {
// Event::log($_POST["processes_id"], "users", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
// }
}
Html::back();
}
}
Html::displayErrorAndDie("lost");

View File

@@ -3,17 +3,34 @@ include_once ("../../../inc/includes.php");
switch ($_POST["action"]) {
case 'newcase':
if (isset($_POST['id']) && $_POST['id'] > 0) { // then this case will be bound to an item
// we must check if a case is not already existing
if (isset($_POST['items_id']) && $_POST['items_id'] > 0) { // then this case will be bound to an item
// TODO: we must check if a case is not already existing
// to manage the problem of F5 (Refresh)
$hasCase = PluginProcessmakerProcessmaker::getCaseIdFromItem( $_POST['itemtype'], $_POST['id'] );
if ($hasCase === false && $_POST['plugin_processmaker_process_id'] > 0) { //$DB->numrows($res) == 0) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login(); //openSession();
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() );
//$hasCase = PluginProcessmakerCase::getIDFromItem($_POST['itemtype'], $_POST['items_id']);
//if ($hasCase === false && $_POST['plugin_processmaker_processes_id'] > 0) {
if ($_POST['plugin_processmaker_processes_id'] > 0) {
$resultCase = $PM_SOAP->startNewCase($_POST['plugin_processmaker_processes_id'], $_POST['itemtype'], $_POST['items_id'], Session::getLoginUserID());
if ($resultCase->status_code == 0) {
$case = new PluginProcessmakerCase;
if ($case->getFromGUID($resultCase->caseId)) {
$link = $case->getLinkURL();
$task = new PluginProcessmakerTask();
$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task
//$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID();
Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->getID());
$item = new $_POST['itemtype'];
$item->getFromDB($_POST['items_id']);
unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList
Session::initNavigateListItems('PluginProcessmakerCase',
//TRANS : %1$s is the itemtype name,
// %2$s is the name of the item (used for headings of a list)
sprintf(__('%1$s = %2$s'),
$_POST['itemtype']::getTypeName(1), $item->fields["name"]));
Html::redirect($link);
}
Html::back();
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
@@ -22,19 +39,17 @@ switch ($_POST["action"]) {
Html::back();
}
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login();
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
$resultCase = $PM_SOAP->newCase( $_POST['plugin_processmaker_processes_id'],
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_ITEM_TYPE' => 'Ticket',
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) );
'GLPI_URL' => $CFG_GLPI['url_base']) );
if ($resultCase->status_code == 0) {
// case is created
// Must show it...
//
$rand = rand( );
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
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=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
@@ -45,36 +60,28 @@ switch ($_POST["action"]) {
break;
case 'unpausecase_or_reassign_or_delete' :
if (isset( $_POST['unpause'] )) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login(); //openSession();
$pmResultUnpause = $myProcessMaker->unpauseCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] );
if (isset($_POST['unpause'])) {
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_POST['cases_id']);
$pmResultUnpause = $locCase->unpauseCase($_POST['delIndex'], $_POST['users_id']);
if ($pmResultUnpause->status_code == 0) {
Html::back();
} else {
echo "Error unpausing case: ".$pmResultUnpause->message." \n";
}
} else if (isset( $_POST['reassign'] )) {
// here we should re-assign the current task to $_POST['users_id_recipient']
$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] );
if ($_POST['plugin_processmaker_userId'] != $GLPINewPMUserId) {
$locPM = new PluginProcessmakerProcessmaker();
$locPM->login( );
} else if (isset($_POST['reassign'])) {
// here we should re-assign the current task to $_POST['users_id_recipient']
//$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] );
if ($_POST['users_id'] != $_POST['users_id_recipient']) { // normally should be different as of the dropdown prevents already used
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_POST['cases_id']);
$pmResponse = $locPM->reassignCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'], $GLPINewPMUserId );
if ($pmResponse->status_code == 0) {
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
// we need the delindex of the current glpi task, and the delindex of the new one
// search for new delindex
$newCaseInfo = $locPM->getCaseInfo( $_POST['plugin_processmaker_caseId'] );
$newDelIndex = 0;
foreach ($newCaseInfo->currentUsers as $newCaseUser) {
if ($newCaseUser->taskId == $_POST['plugin_processmaker_taskId'] && $newCaseUser->delThread == $_POST['plugin_processmaker_delThread']) {
$newDelIndex = $newCaseUser->delIndex;
break;
}
}
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] );
$pmResponse = $locCase->reassignCase($_POST['delIndex'],
$_POST['taskGuid'],
$_POST['delThread'],
$_POST['users_id'],
$_POST['users_id_recipient']);
if ($pmResponse) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
@@ -82,39 +89,51 @@ switch ($_POST["action"]) {
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['assignedtoyou'], true, ERROR); // Html::back();
}
} else if (isset($_POST['delete'])) {
// delete case from case table, this will also delete the tasks
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
if ($locCase->deleteCase()) {
// request delete from pm itself
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login(true);
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] );
//} else if (isset($_POST['delete'])) {
// // delete case from case table, this will also delete the tasks
// $locCase = new PluginProcessmakerCase;
// if ($locCase->getFromDB($_POST['cases_id']) && $locCase->deleteCase()) {
// // request delete from pm itself
// $PM_SOAP->login(true);
if ($resultPM->status_code == 0) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
}
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
}
// $resultPM = $PM_SOAP->deleteCase($locCase->fields['case_guid']);
// if ($resultPM->status_code == 0) {
// Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
// } else {
// Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
// }
// } else {
// Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
// }
} else if (isset($_POST['cancel'])) {
// cancel case from PM
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login();
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ); //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($_POST['cases_id']);
$resultPM = $PM_SOAP->cancelCase($locCase->fields['case_guid']); //, $_POST['plugin_processmaker_del_index'], $_POST['plugin_processmaker_users_id'] ) ;
if ($resultPM->status_code === 0) {
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
//$locCase = new PluginProcessmakerCase;
//$locCase->getFromDB($_POST['cases_id']);
if ($locCase->cancelCase()) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
}
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
if ($resultPM->status_code == 100 && $locCase->deleteCase()) { // case is draft then delete it
// request delete from pm itself
$PM_SOAP->login(true);
$resultPM = $PM_SOAP->deleteCase($locCase->fields['case_guid']);
if ($resultPM->status_code == 0) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
}
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled']. " " . $resultPM->message, true, ERROR);
}
}
}
@@ -122,6 +141,6 @@ switch ($_POST["action"]) {
}
// to return to ticket
// to return to item
Html::back();

View File

@@ -1,6 +1,13 @@
<?php
include_once ("../../../inc/includes.php");
/**
* Summary of processMakerShowProcessList
* @param mixed $ID
* @param mixed $from_helpdesk
* @return boolean
*/
function processMakerShowProcessList ($ID, $from_helpdesk) {
global $DB, $CFG_GLPI, $LANG, $_SESSION;
@@ -8,544 +15,39 @@ function processMakerShowProcessList ($ID, $from_helpdesk) {
return false;
}
$rand = rand();
echo "<form name= 'processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo "<div class='center'><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='2'>".$LANG['processmaker']['item']['tab']."</th></tr>";
$rand = rand();
echo "<form name= 'processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo "<div class='center'><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='2'>".$LANG['processmaker']['item']['tab']."</th></tr>";
echo "<tr class='tab_bg_2'><td class='right' colspan='1'>";
echo $LANG['processmaker']['item']['selectprocess']."&nbsp;";
echo "<input type='hidden' name='action' value='newcase'>";
echo "<input type='hidden' name='id' value='-1'>";
echo "<input type='hidden' name='itemtype' value='Ticket'>";
echo "<input type='hidden' name='itilcategories_id' value='".$_REQUEST['itilcategories_id']."'>";
echo "<input type='hidden' name='type' value='".$_REQUEST['type']."'>";
PluginProcessmakerProcess::dropdown( array( 'value' => 0, 'entity' => $_SESSION['glpiactive_entity'], 'name' => 'plugin_processmaker_process_id' ));
echo "</td><td class='center'>";
echo "<input type='submit' name='additem' value='Start' class='submit'>";
echo "</td></tr>";
echo "<tr class='tab_bg_2'><td class='right' colspan='1'>";
echo $LANG['processmaker']['item']['selectprocess']."&nbsp;";
echo "<input type='hidden' name='action' value='newcase'>";
echo "<input type='hidden' name='id' value='-1'>";
echo "<input type='hidden' name='itemtype' value='Ticket'>";
echo "<input type='hidden' name='itilcategories_id' value='".$_REQUEST['itilcategories_id']."'>";
echo "<input type='hidden' name='type' value='".$_REQUEST['type']."'>";
PluginProcessmakerProcess::dropdown( array( 'value' => 0, 'entity' => $_SESSION['glpiactive_entity'], 'name' => 'plugin_processmaker_processes_id' ));
echo "</td><td class='center'>";
echo "<input type='submit' name='additem' value='Start' class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</table>";
Html::closeForm();
return true;
}
//function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
// global $DB, $CFG_GLPI;
// if (!Ticket::canCreate()) {
// return false;
// }
// if (!$ticket_template
// && Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
// $opt = array();
// $opt['reset'] = 'reset';
// $opt['criteria'][0]['field'] = 55; // validation status
// $opt['criteria'][0]['searchtype'] = 'equals';
// $opt['criteria'][0]['value'] = CommonITILValidation::WAITING;
// $opt['criteria'][0]['link'] = 'AND';
// $opt['criteria'][1]['field'] = 59; // validation aprobator
// $opt['criteria'][1]['searchtype'] = 'equals';
// $opt['criteria'][1]['value'] = Session::getLoginUserID();
// $opt['criteria'][1]['link'] = 'AND';
// $url_validate = $CFG_GLPI["root_doc"]."/front/ticket.php?".Toolbox::append_params($opt,
// '&amp;');
// if (TicketValidation::getNumberToValidate(Session::getLoginUserID()) > 0) {
// echo "<a href='$url_validate' title=\"".__s('Ticket waiting for your approval')."\"
// alt=\"".__s('Ticket waiting for your approval')."\">".
// __('Tickets awaiting approval')."</a><br><br>";
// }
// }
// $email = UserEmail::getDefaultForUser($ID);
// $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_REQUEST['entities_id'], '', 1);
// // Set default values...
// $default_values = array('_users_id_requester_notif'
// => array('use_notification'
// => (($email == "")?0:$default_use_notif)),
// 'nodelegate' => 1,
// '_users_id_requester' => 0,
// '_users_id_observer' => array(0),
// '_users_id_observer_notif'
// => array('use_notification' => $default_use_notif),
// 'name' => '',
// 'content' => '',
// 'itilcategories_id' => 0,
// 'locations_id' => 0,
// 'urgency' => 3,
// 'items_id' => 0,
// 'entities_id' => $_REQUEST['entities_id'],
// 'plan' => array(),
// 'global_validation' => CommonITILValidation::NONE,
// '_add_validation' => 0,
// 'type' => Entity::getUsedConfig('tickettype',
// $_REQUEST['entities_id'],
// '', Ticket::INCIDENT_TYPE),
// '_right' => "id",
// '_filename' => array(),
// '_tag_filename' => array());
// // Get default values from posted values on reload form
// if (!$ticket_template) {
// if (isset($_POST)) {
// $values = Html::cleanPostForTextArea($_POST);
// }
// }
// $ticket = new Ticket();
// // Restore saved value or override with page parameter
// if (!function_exists('restoreInput')) {
// function restoreInput(Array $default=array()) {
// if (isset($_SESSION['saveInput']['Ticket'])) {
// $saved = Html::cleanPostForTextArea($_SESSION['saveInput']['Ticket']);
// // clear saved data when restored (only need once)
// unset($_SESSION['saveInput']['Ticket']);
// return $saved;
// }
// return $default;
// }
// }
// $saved = restoreInput();
// foreach ($default_values as $name => $value) {
// if (!isset($values[$name])) {
// if (isset($saved[$name])) {
// $values[$name] = $saved[$name];
// } else {
// $values[$name] = $value;
// }
// }
// }
// // Check category / type validity
// if ($values['itilcategories_id']) {
// $cat = new ITILCategory();
// if ($cat->getFromDB($values['itilcategories_id'])) {
// switch ($values['type']) {
// case Ticket::INCIDENT_TYPE :
// if (!$cat->getField('is_incident')) {
// $values['itilcategories_id'] = 0;
// }
// break;
// case Ticket::DEMAND_TYPE :
// if (!$cat->getField('is_request')) {
// $values['itilcategories_id'] = 0;
// }
// break;
// default :
// break;
// }
// }
// }
// if (!$ticket_template) {
// echo "<form method='post' name='helpdeskform' action='".
// $CFG_GLPI["root_doc"]."/front/tracking.injector.php' enctype='multipart/form-data'>";
// }
// $delegating = User::getDelegateGroupsForUser($values['entities_id']);
// if (count($delegating)) {
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th colspan='2'>".__('This ticket concerns me')." ";
// $rand = Dropdown::showYesNo("nodelegate", $values['nodelegate']);
// $params = array('nodelegate' => '__VALUE__',
// 'rand' => $rand,
// 'right' => "delegate",
// '_users_id_requester'
// => $values['_users_id_requester'],
// '_users_id_requester_notif'
// => $values['_users_id_requester_notif'],
// 'use_notification'
// => $values['_users_id_requester_notif']['use_notification'],
// 'entity_restrict'
// => $_REQUEST['entities_id']);
// Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand,
// $CFG_GLPI["root_doc"]."/ajax/dropdownDelegationUsers.php",
// $params);
// $class = 'right';
// if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
// echo "</th><th>".__('Check your personnal information');
// $class = 'center';
// }
// echo "</th></tr>";
// echo "<tr class='tab_bg_1'><td colspan='2' class='".$class."'>";
// echo "<div id='show_result$rand'>";
// $self = $ticket; // new self();
// if ($values["_users_id_requester"] == 0) {
// $values['_users_id_requester'] = Session::getLoginUserID();
// } else {
// $values['_right'] = "delegate";
// }
// $self->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $values);
// echo "</div>";
// if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
// echo "</td><td class='center'>";
// User::showPersonalInformation(Session::getLoginUserID());
// }
// echo "</td></tr>";
// echo "</table></div>";
// echo "<input type='hidden' name='_users_id_recipient' value='".Session::getLoginUserID()."'>";
// } else {
// // User as requester
// $values['_users_id_requester'] = Session::getLoginUserID();
// if ($CFG_GLPI['use_check_pref']) {
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th>".__('Check your personnal information')."</th></tr>";
// echo "<tr class='tab_bg_1'><td class='center'>";
// User::showPersonalInformation(Session::getLoginUserID());
// echo "</td></tr>";
// echo "</table></div>";
// }
// }
// echo "<input type='hidden' name='_from_helpdesk' value='1'>";
// echo "<input type='hidden' name='requesttypes_id' value='".RequestType::getDefault('helpdesk').
// "'>";
// // Load ticket template if available :
// $tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'],
// $values['itilcategories_id'],
// $_REQUEST['entities_id']);
// // Predefined fields from template : reset them
// if (isset($values['_predefined_fields'])) {
// $values['_predefined_fields']
// = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
// } else {
// $values['_predefined_fields'] = array();
// }
// // Store predefined fields to be able not to take into account on change template
// $predefined_fields = array();
// if (isset($tt->predefined) && count($tt->predefined)) {
// foreach ($tt->predefined as $predeffield => $predefvalue) {
// if (isset($values[$predeffield]) && isset($default_values[$predeffield])) {
// // Is always default value : not set
// // Set if already predefined field
// // Set if ticket template change
// if (((count($values['_predefined_fields']) == 0)
// && ($values[$predeffield] == $default_values[$predeffield]))
// || (isset($values['_predefined_fields'][$predeffield])
// && ($values[$predeffield] == $values['_predefined_fields'][$predeffield]))
// || (isset($values['_tickettemplates_id'])
// && ($values['_tickettemplates_id'] != $tt->getID()))) {
// $values[$predeffield] = $predefvalue;
// $predefined_fields[$predeffield] = $predefvalue;
// }
// } else { // Not defined options set as hidden field
// echo "<input type='hidden' name='$predeffield' value='$predefvalue'>";
// }
// }
// // All predefined override : add option to say predifined exists
// if (count($predefined_fields) == 0) {
// $predefined_fields['_all_predefined_override'] = 1;
// }
// } else { // No template load : reset predefined values
// if (count($values['_predefined_fields'])) {
// foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
// if ($values[$predeffield] == $predefvalue) {
// $values[$predeffield] = $default_values[$predeffield];
// }
// }
// }
// }
// if (($CFG_GLPI['urgency_mask'] == (1<<3))
// || $tt->isHiddenField('urgency')) {
// // Dont show dropdown if only 1 value enabled or field is hidden
// echo "<input type='hidden' name='urgency' value='".$values['urgency']."'>";
// }
// // Display predefined fields if hidden
// if ($tt->isHiddenField('items_id')) {
// if (!empty($values['items_id'])) {
// foreach ($values['items_id'] as $itemtype => $items) {
// foreach ($items as $items_id) {
// echo "<input type='hidden' name='items_id[$itemtype][$items_id]' value='$items_id'>";
// }
// }
// }
// }
// if ($tt->isHiddenField('locations_id')) {
// echo "<input type='hidden' name='locations_id' value='".$values['locations_id']."'>";
// }
// echo "<input type='hidden' name='entities_id' value='".$_REQUEST['entities_id']."'>";
// echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th width='30%'>".$caseInfo->processName."</th><th>";
// if (Session::isMultiEntitiesMode()) {
// echo "(".Dropdown::getDropdownName("glpi_entities", $_REQUEST['entities_id']).")";
// }
// echo "</th></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type'))."</td>";
// echo "<td>";
// Ticket::dropdownType('type', array('value' => $values['type'],
// 'on_change' => 'this.form.submit()'));
// echo "</td></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Category'),
// $tt->getMandatoryMark('itilcategories_id'))."</td>";
// echo "<td>";
// $condition = "`is_helpdeskvisible`='1'";
// switch ($values['type']) {
// case Ticket::DEMAND_TYPE :
// $condition .= " AND `is_request`='1'";
// break;
// default: // Ticket::INCIDENT_TYPE :
// $condition .= " AND `is_incident`='1'";
// }
// $opt = array('value' => $values['itilcategories_id'],
// 'condition' => $condition,
// 'entity' => $_REQUEST['entities_id'],
// 'on_change' => 'this.form.submit()');
// if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
// $opt['display_emptychoice'] = false;
// }
// ITILCategory::dropdown($opt);
// echo "</td></tr>";
// if ($CFG_GLPI['urgency_mask'] != (1<<3)) {
// if (!$tt->isHiddenField('urgency')) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')).
// "</td>";
// echo "<td>";
// Ticket::dropdownUrgency(array('value' => $values["urgency"]));
// echo "</td></tr>";
// }
// }
// if (empty($delegating)
// && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".__('Inform me about the actions taken')."</td>";
// echo "<td>";
// if ($values["_users_id_requester"] == 0) {
// $values['_users_id_requester'] = Session::getLoginUserID();
// }
// $_POST['value'] = $values['_users_id_requester'];
// $_POST['field'] = '_users_id_requester_notif';
// $_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification'];
// include (GLPI_ROOT."/ajax/uemailUpdate.php");
// echo "</td></tr>";
// }
// if (($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0)
// && (count($_SESSION["glpiactiveprofile"]["helpdesk_item_type"]))) {
// if (!$tt->isHiddenField('itemtype')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Hardware type'),
// $tt->getMandatoryMark('items_id'))."</td>";
// echo "<td>";
// $values['_canupdate'] = Session::haveRight('ticket', CREATE);
// Item_Ticket::itemAddForm($ticket, $values);
// echo "</td></tr>";
// }
// }
// if (!$tt->isHiddenField('locations_id')) {
// echo "<tr class='tab_bg_1' style='display:none;'><td>";
// printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
// echo "</td><td>";
// Location::dropdown(array('value' => $values["locations_id"]));
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('_users_id_observer')
// || $tt->isPredefinedField('_users_id_observer')) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".sprintf(__('%1$s%2$s'), _n('Watcher', 'Watchers', 2),
// $tt->getMandatoryMark('_users_id_observer'))."</td>";
// echo "<td>";
// $values['_right'] = "groups";
// if (!$tt->isHiddenField('_users_id_observer')) {
// // Observer
// if ($tt->isPredefinedField('_users_id_observer')
// && !is_array($values['_users_id_observer'])) {
// //convert predefined value to array
// $values['_users_id_observer'] = array($values['_users_id_observer']);
// $values['_users_id_observer_notif']['use_notification'] =
// array($values['_users_id_observer_notif']['use_notification']);
// // add new line to permit adding more observers
// $values['_users_id_observer'][1] = 0;
// $values['_users_id_observer_notif']['use_notification'][1] = 1;
// }
// echo "<div class='actor_single first-actor'>";
// if (isset($values['_users_id_observer'])) {
// $observers = $values['_users_id_observer'];
// foreach ($observers as $index_observer => $observer) {
// $options = array_merge($values, array('_user_index' => $index_observer));
// Ticket::showFormHelpdeskObserver($options);
// }
// }
// echo "</div>";
// } else { // predefined value
// if (isset($values["_users_id_observer"]) && $values["_users_id_observer"]) {
// echo Ticket::getActorIcon('user', CommonITILActor::OBSERVER)."&nbsp;";
// echo Dropdown::getDropdownName("glpi_users", $values["_users_id_observer"]);
// echo "<input type='hidden' name='_users_id_observer' value=\"".
// $values["_users_id_observer"]."\">";
// }
// }
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('name')
// || $tt->isPredefinedField('name')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'))."<td>";
// if (!$tt->isHiddenField('name')) {
// echo "<input type='text' maxlength='250' size='80' name='name'
// value=\"".$values['name']."\">";
// } else {
// echo $values['name'];
// echo "<input type='hidden' name='name' value=\"".$values['name']."\">";
// }
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('content')
// || $tt->isPredefinedField('content')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')).
// "</td><td>";
// $rand = mt_rand();
// $rand_text = mt_rand();
// $cols = 90;
// $rows = 6;
// $content_id = "content$rand";
// //if (method_exists('Html', 'setSimpleTextContent')) {
// // // in GLPI 9.2
// // $values["content"] = Html::setSimpleTextContent($values["content"]);
// //} else {
// $values["content"] = $ticket->setSimpleTextContent($values["content"]);
// //}
// echo "<div id='content$rand_text'>";
// echo "<textarea id='$content_id' name='content' cols='$cols' rows='$rows'>".
// $values['content']."</textarea></div>";
// echo "</td></tr>";
// }
// echo "<tr class='tab_bg_1'>";
// echo "<td class='center' colspan='2'>";
// $rand = rand();
// $pmCaseUser = $caseInfo->currentUsers[0]; // by default
// $paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus;
// echo "<iframe onload='onLoadFrame( event, \"".$caseInfo->caseId."\", ".$pmCaseUser->delIndex.", ".$caseInfo->caseNumber.", \"".$caseInfo->processName."\") ;' id='caseiframe' width=100% style='border:none;' src='".$pmItem->serverURL."/cases/cases_Open?sid=". $_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand&glpi_domain={$pmItem->config->fields['domain']}' ></iframe>";
// echo "</td></tr>";
// // File upload system
// $width = '100%';
// if ($CFG_GLPI['use_rich_text']) {
// $width = '50%';
// }
// echo "<tr class='tab_bg_1'>";
// echo "<td class='top'>".sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
// DocumentType::showAvailableTypesLink();
// echo "</td>";
// echo "<td class='top'>";
// echo "<div id='fileupload_info'></div>";
// echo "</td>";
// echo "</tr>";
// echo "<tr class='tab_bg_1'>";
// echo "<td colspan='2'>";
// echo "<table width='100%'><tr>";
// echo "<td width='$width '>";
// echo Html::file(array('multiple' => true,
// 'values' => array('filename' => $values['_filename'],
// 'tag' => $values['_tag_filename'])
// ));
// // "<div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
// echo "</td>";
// if ($CFG_GLPI['use_rich_text']) {
// echo "<td width='$width '>";
// if (!isset($rand)) {
// $rand = mt_rand();
// }
// echo Html::initImagePasteSystem($content_id, $rand);
// echo "</td>";
// }
// echo "</tr></table>";
// echo "</td>";
// echo "</tr>";
// if (!$ticket_template) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td colspan='2' class='center'>";
// if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
// echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
// echo "<input type='hidden' name='_predefined_fields'
// value=\"".Toolbox::prepareArrayForInput($predefined_fields)."\">";
// }
// echo "<input type='submit' name='add' value=\"".__s('Submit message')."\" class='submit'>";
// echo "</td></tr>";
// }
// echo "</table></div>";
// if (!$ticket_template) {
// Html::closeForm();
// }
//}
/**
* Summary of processMakerShowCase
* @param mixed $ID
* @param mixed $from_helpdesk
*/
function processMakerShowCase( $ID, $from_helpdesk ) {
global $CFG_GLPI;
global $CFG_GLPI, $PM_SOAP;
$pmItem = new PluginProcessmakerProcessmaker( );
$pmItem->login( );
$caseInfo = $pmItem->getCaseInfo( $_REQUEST['case_id'] );
$caseInfo = $PM_SOAP->getCaseInfo( $_REQUEST['case_guid'] );
if ($caseInfo->status_code == 0) {
// case is created
// Must show it...
@@ -606,14 +108,19 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
$elt->setAttribute( 'style', 'display:none;');
}
// add an input for processId in the form
// echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
// add an input for processguid in the form
$res = $xpath->query('//form[@name="helpdeskform"]');
$input = $res->item(0)->appendChild(new DOMElement('input'));
$input->setAttribute('name', 'processId');
$input->setAttribute('name', 'processmaker_process_guid');
$input->setAttribute('type', 'hidden');
$input->setAttribute('value', $caseInfo->processId);
// add an input for processid in the form
$input = $res->item(0)->appendChild(new DOMElement('input'));
$input->setAttribute('name', 'processmaker_processes_id');
$input->setAttribute('type', 'hidden');
$input->setAttribute('value', $_REQUEST['processes_id']);
// special case for content textarea which is in the same tr than the file upload
$res = $xpath->query('//*[@name="content"]/ancestor::div[1] | //*[@name="content"]/ancestor::tr[1]/td[1]');
foreach($res as $elt) {
@@ -645,7 +152,7 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
$iframe->setAttribute('onload', "onLoadFrame( event, '{$caseInfo->caseId}', {$pmCaseUser->delIndex}, {$caseInfo->caseNumber}, '{$caseInfo->processName}') ;" ) ;
$iframe->setAttribute('width', '100%' ) ;
$iframe->setAttribute('style', 'border:none;' ) ;
$iframe->setAttribute('src', "{$pmItem->serverURL}/cases/cases_Open?sid={$_SESSION["pluginprocessmaker"]["session"]["id"]}&APP_UID={$caseInfo->caseId}&{$paramsURL}&rand=$rand&glpi_domain={$pmItem->config->fields['domain']}" ) ;
$iframe->setAttribute('src', "{$PM_SOAP->serverURL}/cases/cases_Open?sid={$PM_SOAP->getPMSessionID()}&APP_UID={$caseInfo->caseId}&{$paramsURL}&rand=$rand&glpi_domain={$PM_SOAP->config->fields['domain']}" ) ;
// set the width and the title of the first table th
$th = $xpath->query('//*[@name="add"]/ancestor::table[1]/*/th[1]');
@@ -679,22 +186,6 @@ function in_array_recursive($needle, $haystack) {
}
//// redirect if no create ticket right
//if (!Session::haveRight('ticket', CREATE )) {
// if (Session::haveRight('observe_ticket', 1) || Session::haveRight('validate_ticket', 1)) {
// Html::redirect($CFG_GLPI['root_doc']."/front/ticket.php");
// } else if (Session::haveRight('reservation_helpdesk', 1)) {
// Html::redirect($CFG_GLPI['root_doc']."/front/reservationitem.php");
// } else if (Session::haveRight('faq', READ)) {
// Html::redirect($CFG_GLPI['root_doc']."/front/helpdesk.faq.php");
// }
//}
//Session::checkHelpdeskAccess();
//Html::helpHeader($LANG['job'][13], $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
// Change profile system
if (isset($_POST['newprofile'])) {
if (isset($_SESSION["glpiprofiles"][$_POST['newprofile']])) {
@@ -752,8 +243,8 @@ Session::checkHelpdeskAccess();
Html::helpHeader(__('New ticket'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
if (isset($_REQUEST['case_id'])) {
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE id='".$_REQUEST['case_id']."'";
if (isset($_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
processMakerShowProcessList(Session::getLoginUserID(), 1);
@@ -761,7 +252,7 @@ if (isset($_REQUEST['case_id'])) {
// before showing the case, we must check the rights for this user to view it, if entity has been changed in the meanwhile
// and must check if entity of the ticket is in the tree of authorized entities for current profile
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_REQUEST["itilcategories_id"], $_REQUEST["type"], $_SESSION['glpiactiveprofile']['id'], $_REQUEST['entities_id'] );
if (in_array( $_REQUEST['entities_id'], $_SESSION['glpiactiveentities']) && in_array_recursive( $_REQUEST['process_id'], $processList )) {
if (in_array( $_REQUEST['entities_id'], $_SESSION['glpiactiveentities']) && in_array_recursive( $_REQUEST['processes_id'], $processList )) {
processMakerShowCase(Session::getLoginUserID(), 1);
} else {
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");

View File

@@ -39,7 +39,7 @@ if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
$processQt = count( $processList ) ;
if( $processQt == 1 ) {
$_POST['action']='newcase';
$_POST['plugin_processmaker_process_id'] = $processList[0]['id'];
$_POST['plugin_processmaker_processes_id'] = $processList[0]['id'];
include (GLPI_ROOT . "/plugins/processmaker/front/processmaker.form.php");
die() ;
} elseif( $processQt > 1 ) {

234
hook.php
View File

@@ -29,15 +29,20 @@ function plugin_processmaker_MassiveActions($type) {
switch ($type) {
case 'PluginProcessmakerProcess' :
if (plugin_processmaker_haveRight('config', UPDATE )) {
if (plugin_processmaker_haveRight('config', UPDATE)) {
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
}
break;
case 'PluginProcessmakerProcess_Profile' :
if (plugin_processmaker_haveRight('config', UPDATE )) {
if (plugin_processmaker_haveRight('config', UPDATE)) {
return array('purge' => $LANG['processmaker']['process']['profile']);
}
break;
//case 'PluginProcessmakerCase' :
// if (plugin_processmaker_haveRight("case", DELETE)) {
// return array('purge' => __('Delete permanently'));
// }
//break;
}
return array();
}
@@ -48,16 +53,16 @@ function plugin_processmaker_MassiveActionsDisplay($options) {
switch ($options['itemtype']) {
case 'PluginProcessmakerProcess' :
//case 'PluginProcessmakerCase' :
switch ($options['action']) {
// No case for add_document : use GLPI core one
case "plugin_processmaker_taskrefresh" :
//case "plugin_processmaker_purgecase" :
echo "<input type='submit' name='massiveaction' class='submit' ".
"value='".$LANG['buttons'][2]."'>";
break;
}
break;
}
return "";
}
@@ -77,18 +82,29 @@ function plugin_processmaker_MassiveActionsProcess($data) {
}
}
}
break;
case 'plugin_processmaker_process_profile_delete' :
if ($data['itemtype'] == 'PluginProcessmakerProcess_Profile') {
foreach ($data["item"] as $key => $val) {
if ($val == 1) {
$process_profile = new PluginProcessmakerProcess_Profile;
$process_profile->delete( array( 'id' => $key ), true );
break;
//case "plugin_processmaker_purgecase":
// if ($data['itemtype'] == 'PluginProcessmakerCase') {
// foreach ($data["item"] as $key => $val) {
// if ($val == 1) {
// $locCase= new PluginProcessmakerCase;
// //$locCase->( array( 'id' => $key ) );
}
}
}
break;
// }
// }
// }
// break;
//case 'plugin_processmaker_process_profile_delete' :
// if ($data['itemtype'] == 'PluginProcessmakerProcess_Profile') {
// foreach ($data["item"] as $key => $val) {
// if ($val == 1) {
// $process_profile = new PluginProcessmakerProcess_Profile;
// $process_profile->delete( array( 'id' => $key ), true );
// }
// }
// }
// break;
}
}
@@ -127,7 +143,7 @@ function plugin_processmaker_install() {
}
function plugin_processmaker_uninstall() {
global $DB;
//global $DB;
CronTask::Unregister('PluginProcessmakerProcessmaker');
@@ -136,9 +152,10 @@ function plugin_processmaker_uninstall() {
function plugin_processmaker_getAddSearchOptions($itemtype) {
global $LANG;
global $LANG;
$sopt = array();
$sopt = array();
// TODO add Change and Problem + other fields to the search
if ($itemtype == 'Ticket') {
$sopt[10001]['table'] = 'glpi_plugin_processmaker_cases';
$sopt[10001]['field'] = 'case_status';
@@ -195,50 +212,51 @@ function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,
* @return void
*/
function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
global $DB;
global $DB;//, $PM_SOAP;
if (isset($_SESSION['glpiname']) && $parm->getType() == 'Ticket') {
$locCase = new PluginProcessmakerCase;
if (isset($_SESSION['glpiname'])) { // && $parm->getType() == 'Ticket') {
$locVar = array( );
foreach ($parm->input as $key => $val) {
switch ($key) {
case 'global_validation' :
$locVar[ 'GLPI_TICKET_GLOBAL_VALIDATION' ] = $val;
break;
case 'itilcategories_id' :
$locVar[ 'GLPI_ITEM_ITIL_CATEGORY_ID' ] = $val;
break;
case 'due_date' :
$locVar[ 'GLPI_TICKET_DUE_DATE' ] = $val;
$locVar[ 'GLPI_ITEM_DUE_DATE' ] = $val;
break;
case 'urgency' :
$locVar[ 'GLPI_TICKET_URGENCY' ] = $val;
$locVar[ 'GLPI_ITEM_URGENCY' ] = $val;
break;
case 'impact' :
$locVar[ 'GLPI_ITEM_IMPACT' ] = $val;
break;
case 'priority' :
$locVar[ 'GLPI_ITEM_PRIORITY' ] = $val;
break;
}
}
$itemId = $parm->getID();
$itemType = $parm->getType();
if ($locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId )) {
$locPM = new PluginProcessmakerProcessmaker;
$locPM->login();
$locCase = new PluginProcessmakerCase;
foreach(PluginProcessmakerCase::getIDsFromItem($itemType, $itemId ) as $cases_id){
$locCase->getFromDB($cases_id);
$locCase->sendVariables($locVar);
// case is existing for this item
// beware to empty injection when not modified!!!
$locVar = array( );
foreach ($parm->input as $key => $val) {
switch ($key) {
case 'global_validation' :
$locVar[ 'GLPI_TICKET_GLOBAL_VALIDATION' ] = $val;
break;
case 'itilcategories_id' :
$locVar[ 'GLPI_ITEM_ITIL_CATEGORY_ID' ] = $val;
break;
case 'due_date' :
$locVar[ 'GLPI_TICKET_DUE_DATE' ] = $val;
$locVar[ 'GLPI_ITEM_DUE_DATE' ] = $val;
break;
case 'urgency' :
$locVar[ 'GLPI_TICKET_URGENCY' ] = $val;
$locVar[ 'GLPI_ITEM_URGENCY' ] = $val;
break;
case 'impact' :
$locVar[ 'GLPI_ITEM_IMPACT' ] = $val;
break;
case 'priority' :
$locVar[ 'GLPI_ITEM_PRIORITY' ] = $val;
break;
}
// if entities_id of item has been changed, then must update case
if (isset($parm->input['entities_id']) && $parm->input['entities_id'] != $parm->fields['entities_id']) {
$locCase->update(['id' => $cases_id, 'entities_id' => $parm->input['entities_id']]);
}
$pmResponse = $locPM->sendVariables( $locCase->getID(), $locVar);
}
}
}
/**
@@ -250,7 +268,7 @@ function plugin_item_update_processmaker_satisfaction($parm) {
global $DB, $GLOBALS;
$locCase = new PluginProcessmakerCase;
if ($locCase->getCaseFromItemTypeAndItemId( 'Ticket', $parm->fields['tickets_id'] )) {
if ($locCase->getFromItem( 'Ticket', $parm->fields['tickets_id'] )) {
// case is existing for this item
$locPM = new PluginProcessmakerProcessmaker;
@@ -273,7 +291,7 @@ function plugin_pre_item_purge_processmaker ( $parm ) {
$itemType = 'Ticket';
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ); // 2 for technicians
if (PluginProcessmakerCase::getCaseIdFromItemTypeAndItemId( $itemType, $itemId ) && count($technicians) == 1) {
if (PluginProcessmakerCase::getIDFromItem($itemType, $itemId) && count($technicians) == 1) {
$parm->input = null; // to cancel deletion of the last tech in the ticket
}
}
@@ -284,7 +302,7 @@ function plugin_pre_item_purge_processmaker ( $parm ) {
* @param mixed $parm is the object
*/
function plugin_item_purge_processmaker($parm) {
global $DB;
global $DB, $PM_SOAP;
//$objects = ['Ticket', 'Change', 'Problem'];
$object_users = ['Ticket_User', 'Change_User', 'Problem_User'];
@@ -299,11 +317,11 @@ function plugin_item_purge_processmaker($parm) {
$itemId = $parm->fields['tickets_id'];
$itemType = explode('_', $parm->getType())[0]; // 'Ticket';
if ($locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId )) {
if ($locCase->getFromItem( $itemType, $itemId )) {
// case is existing for this item
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ); // 2 for technicians
$locPM = new PluginProcessmakerProcessmaker;
$locPM->login();
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, CommonITILActor::ASSIGN ); // 2 for technicians
//$locPM = new PluginProcessmakerProcessmaker;
//$locPM->login();
$locVars = array( 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'],
'GLPI_ITEM_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'],
'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id'],
@@ -311,34 +329,38 @@ function plugin_item_purge_processmaker($parm) {
);
// and we must find all tasks assigned to this former user and re-assigned them to new user (if any :))!
$caseInfo = $locPM->getCaseInfo( $locCase->getID() );
//$caseInfo = $locPM->getCaseInfo( $locCase->getID() );
$caseInfo = $locCase->getCaseInfo( $locCase->getID() );
if ($caseInfo !== false) {
$locPM->sendVariables( $locCase->getID( ), $locVars );
//$locPM->sendVariables( $locCase->getID( ), $locVars );
$locCase->sendVariables( $locCase->getID( ), $locVars);
// need to get info on the thread of the GLPI current user
// we must retreive currentGLPI user from this array
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( $parm->fields['users_id'] );
if (isset( $caseInfo->currentUsers ) && is_array( $caseInfo->currentUsers )) {
foreach ($caseInfo->currentUsers as $caseUser) {
if ($caseUser->userId == $GLPICurrentPMUserId && in_array( $caseUser->delThreadStatus, array('DRAFT', 'OPEN', 'PAUSE' ) )) {
$pmResponse = $locPM->reassignCase( $locCase->getID(), $caseUser->delIndex, $GLPICurrentPMUserId, $technicians[0]['pm_id'] );
// now should managed GLPI Tasks previously assigned to the $GLPICurrentPMUserId
if ($pmResponse->status_code == 0) {
// ATTENTION: should be aware of: ticket tech == task tech
// In this particular flow due to 'Change Management'
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
// we need the delindex of the current glpi task, and the delindex of the new one
// search for new delindex
$newCaseInfo = $locPM->getCaseInfo( $locCase->getID() );
$newDelIndex = 0;
foreach ($newCaseInfo->currentUsers as $newCaseUser) {
if ($newCaseUser->taskId == $caseUser->taskId && $newCaseUser->delThread == $caseUser->delThread) {
$newDelIndex = $newCaseUser->delIndex;
break;
}
}
$locPM->reassignTask( $locCase->getID(), $caseUser->delIndex, $newDelIndex, $technicians[0]['glpi_id'] );
}
//$pmResponse = $locPM->reassignCase( $locCase->getID(), $caseUser->delIndex, $GLPICurrentPMUserId, $technicians[0]['pm_id'] );
$locCase->reassignCase($caseUser->delIndex, $caseUser->taskId, $caseUser->delThread, $parm->fields['users_id'], $technicians[0]['pm_id'] );
//// now should managed GLPI Tasks previously assigned to the $GLPICurrentPMUserId
//if ($pmResponse->status_code == 0) {
// // ATTENTION: should be aware of: ticket tech == task tech
// // In this particular flow due to 'Change Management'
// // we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
// // we need the delindex of the current glpi task, and the delindex of the new one
// // search for new delindex
// $newCaseInfo = $locPM->getCaseInfo( $locCase->getID() );
// $newDelIndex = 0;
// foreach ($newCaseInfo->currentUsers as $newCaseUser) {
// if ($newCaseUser->taskId == $caseUser->taskId && $newCaseUser->delThread == $caseUser->delThread) {
// $newDelIndex = $newCaseUser->delIndex;
// break;
// }
// }
// $locPM->reassignTask( $locCase->getID(), $caseUser->delIndex, $newDelIndex, $technicians[0]['glpi_id'] );
//}
}
}
}
@@ -349,8 +371,17 @@ function plugin_item_purge_processmaker($parm) {
}
function plugin_processmaker_post_init() {
global $PM_DB;
$PM_DB = new PluginProcessmakerDB;
global $PM_DB, $PM_SOAP;
if (!isset($PM_DB)) {
$PM_DB = new PluginProcessmakerDB;
}
if (!isset($PM_SOAP)) {
$PM_SOAP = new PluginProcessmakerProcessmaker;
// and default login is current running user if any
if (Session::getLoginUserID() ) {
$PM_SOAP->login();
}
}
}
@@ -359,13 +390,19 @@ function plugin_processmaker_giveItem($itemtype,$ID,$data,$num) {
return;
}
function plugin_processmaker_change_profile($parm) {
if ($_SESSION['glpiactiveprofile']['interface'] == "helpdesk") {
// must add the rights for simplified interface
$_SESSION['glpiactiveprofile']['plugin_processmaker_case'] = READ;
}
}
/**
* Summary of plugin_item_add_update_processmaker_tasks
* @param mixed $parm
*/
function plugin_item_update_processmaker_tasks($parm) {
global $DB, $CFG_GLPI;
global $DB, $CFG_GLPI, $PM_SOAP;
// we need to test if a specific case is completed, and if so
// we should complete the linked cases (via linked tickets)
@@ -376,9 +413,14 @@ function plugin_item_update_processmaker_tasks($parm) {
$itemtype = str_replace( 'Task', '', $parm->getType() );
foreach ($DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask) {
$pmTask = new PluginProcessmakerTask($parm->getType());
$pmTask->getFromDB($parm->fields['id']);
$srcCaseId = PluginProcessmakerProcessmaker::getCaseIdFromItem( $itemtype, $parm->fields['tickets_id']);
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']); //Item($itemtype, $parm->fields['tickets_id']);
$srccase_guid = $locCase->fields['case_guid'];
foreach ($DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask) {
// Must check the condition
$casevariables = array();
@@ -412,10 +454,10 @@ function plugin_item_update_processmaker_tasks($parm) {
}
// ask for those case variables
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login( );
//$PM_SOAP = new PluginProcessmakerProcessmaker();
//$PM_SOAP->login( );
// now tries to get the variables to check condition
$infoForTasks = $myProcessMaker->getVariables( $srcCaseId, $casevariables );
$infoForTasks = $locCase->getVariables($casevariables);
foreach ($infoForTasks as $casevar => $varval) {
$infoForTasks[ "@@$casevar" ] = "'$varval'";
unset( $infoForTasks[ $casevar ] );
@@ -442,7 +484,7 @@ function plugin_item_update_processmaker_tasks($parm) {
foreach ($externalapplication['params'] as $paramname => $variable) {
$externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" );
}
$externalapplicationparams['callback']="http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI['root_doc']."/plugins/processmaker/ajax/asynchronousdatas.php";
$externalapplicationparams['callback'] = $CFG_GLPI["url_base"]."/plugins/processmaker/ajax/asynchronousdatas.php";
$ch = curl_init();
$externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ); // '???
curl_setopt($ch, CURLOPT_URL, $externalapplication['url'] );
@@ -460,7 +502,7 @@ function plugin_item_update_processmaker_tasks($parm) {
//$res = $DB->query($query) ;
//if( $res && $DB->numrows($res) > 0 && $case=$DB->fetch_assoc($res) && isset($case['id']) && isset($case['del_index']) ) {
//foreach( $DB->request($query) as $case ) {
$taskCase = $myProcessMaker->taskCase( $srcCaseId );
$taskCase = $PM_SOAP->taskCase( $srccase_guid );
foreach ($taskCase as $task) {
// search for target task guid
if ($task->guid == $targetTask['targettask_guid']) {
@@ -468,16 +510,17 @@ function plugin_item_update_processmaker_tasks($parm) {
}
}
$postdata['APP_UID'] = $srcCaseId;
$postdata['APP_UID'] = $srccase_guid;
$postdata['DEL_INDEX'] = $task->delegate;
//need to get the 'ProcessMaker' user
$pmconfig = PluginProcessmakerConfig::getInstance();
$pmconfig = $PM_SOAP->config; //PluginProcessmakerConfig::getInstance();
$cronaction = new PluginProcessmakerCrontaskaction;
$cronaction->add( array( 'plugin_processmaker_caselinks_id' => $targetTask['id'],
'itemtype' => $itemtype,
'items_id' => $parm->fields['tickets_id'],
'plugin_processmaker_cases_id' => $locCase->getID(),
//'itemtype' => $itemtype,
//'items_id' => $parm->fields['tickets_id'],
'users_id' => $pmconfig->fields['users_id'],
'is_targettoclaim' => $targetTask['is_targettoclaim'],
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATA : PluginProcessmakerCrontaskaction::DATA_READY),
@@ -528,8 +571,9 @@ function plugin_item_update_processmaker_tasks($parm) {
$cronaction = new PluginProcessmakerCrontaskaction;
$cronaction->add( array( 'plugin_processmaker_caselinks_id' => $targetTask['id'],
'itemtype' => $itemtype,
'items_id' => $parm->fields['tickets_id'],
'plugin_processmaker_cases_id' => $locCase->getID(),
//'itemtype' => $itemtype,
//'items_id' => $parm->fields['tickets_id'],
'users_id' => Session::getLoginUserID(),
'is_targettoclaim' => $targetTask['is_targettoclaim'],
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATA : PluginProcessmakerCrontaskaction::DATA_READY),

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
<?php
/**
* casechangelog short summary.
*
* casechangelog description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCasechangelog extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP;
$config = $PM_SOAP->config;
$rand = rand();
////$caseInfo = $case->getCaseInfo();
//$proj = new PluginProcessmakerProcess;
//// $proj->getFromGUID( $caseInfo->processId );
//$proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
//$project_type = $proj->fields['project_type'];
$caseHistoryURL = $PM_SOAP->serverURL."/cases/ajaxListener?action=changeLogHistory&rand=$rand&glpi_domain={$config->fields['domain']}&GLPI_APP_UID={$case->fields['case_guid']}";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
echo "<iframe id='caseiframe-caseChangeLogHistory' style='border: none;' width='100%' src='$caseHistoryURL'
onload=\"onOtherFrameLoad( 'caseChangeLogHistory', 'caseiframe-caseChangeLogHistory', 'body', 0 );\"></iframe>";
}
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){
global $LANG;
return $LANG['processmaker']['item']['case']['changelog'];
}
}

34
inc/casehistory.class.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
/**
* casehistory short summary.
*
* casehistory description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCasehistory extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP;
$config = $PM_SOAP->config;
$rand = rand();
$proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
$caseHistoryURL = $PM_SOAP->serverURL
."/cases/ajaxListener?action=caseHistory&rand=$rand&glpi_domain={$config->fields['domain']}&GLPI_APP_UID={$case->fields['case_guid']}&GLPI_PRO_UID={$proj->fields['process_guid']}";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>";
echo "<iframe id='caseiframe-caseHistory' style='border: none;' width='100%' src='$caseHistoryURL'
onload=\"onOtherFrameLoad( 'caseHistory', 'caseiframe-caseHistory', 'body', 0 );\"></iframe>";
}
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){
global $LANG;
return $LANG['processmaker']['item']['case']['viewcasehistory'];
}
}

41
inc/casemap.class.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
/**
* PluginProcessmakerCasemap short summary.
*
* casemap description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCasemap extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP;
$config = $PM_SOAP->config;
$rand = rand();
$proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
$project_type = $proj->fields['project_type'];
$caseMapUrl = $PM_SOAP->serverURL.(
$project_type=='bpmn' ?
"/designer?sid=".$PM_SOAP->getPMSessionID()."&prj_uid=".$proj->fields['process_guid']."&prj_readonly=true&app_uid=".$case->fields['case_guid']
:
"/cases/ajaxListener?sid=".$PM_SOAP->getPMSessionID()."&action=processMap" //&GLPI_PRO_UID={$proj->fields['process_guid']}"
)."&glpi_domain={$config->fields['domain']}&rand=$rand&GLPI_APP_UID={$case->fields['case_guid']}&GLPI_PRO_UID={$proj->fields['process_guid']}";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
echo "<iframe id='caseiframe-caseMap' style='border: none;' width='100%' src='$caseMapUrl'
onload=\"onOtherFrameLoad( 'caseMap', 'caseiframe-caseMap', 'body', ".($project_type=='bpmn' ? "true" : "false" )." );\"></iframe>";
}
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){
global $LANG;
return $LANG['processmaker']['item']['case']['viewcasemap'];
}
}

View File

@@ -4,6 +4,8 @@
class PluginProcessmakerConfig extends CommonDBTM {
static $rightname = '';
static private $_instance = NULL;
/**
@@ -141,7 +143,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
* @return boolean
*/
static function showConfigForm($item) {
global $LANG, $PM_DB, $CFG_GLPI;
global $LANG, $PM_DB, $CFG_GLPI, $PM_SOAP;
$setup_ok = false;
@@ -183,7 +185,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
cglpi = glpi.pop() ;
cpm = pm.pop() ;
}
if( domain != '' ) {
if (domain != '' && domain.split('.').length > 1) { // common domain must be at least 'domain.com' and not 'com', otherwise some browser will not accept the CORS javascript
$('div[name=domain]').text(domain) ;
$('div[name=domain]').parent().attr('color', 'green');
return;
@@ -215,16 +217,18 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
$pm = new PluginProcessmakerProcessmaker;
//$pm = new PluginProcessmakerProcessmaker;
if ($config->fields['pm_server_URL'] != ''
&& $config->fields['pm_workspace'] != ''
&& $config->fields["pm_admin_user"] != ''
&& ($pm->login(true))) {
// && ($pm->login(true))) {
&& ($PM_SOAP->login(true))) {
echo "<font color='green'>".__('Test successful');
$setup_ok = true;
} else {
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror, true);
// echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror, true);
echo "<font color='red'>".__('Test failed')."<br>".print_r($PM_SOAP->lasterror, true);
}
echo "</font></span></td></tr>\n";
@@ -237,7 +241,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >" . __('Database name') . "</td>";
echo "<td ><input type='text' size=50 name='pm_dbname' value='".$config->fields["pm_dbname"]."'>";
echo "<td ><input type='text' size=50 name='pm_dbname' value='".$config->fields['pm_dbname']."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
@@ -253,7 +257,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
if ($PM_DB->connected) {
if ($PM_DB->connected && isset($PM_DB->dbdefault) && $PM_DB->dbdefault != '') {
echo "<font color='green'>".__('Test successful');
} else {
echo "<font color='red'>".__('Test failed');
@@ -322,7 +326,8 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr><th colspan='4'>".__('Processmaker system information')."</th></tr>";
if ($setup_ok) {
$info = $pm->systemInformation( );
// $info = $pm->systemInformation( );
$info = $PM_SOAP->systemInformation( );
echo '<tr><td>'._('Version').'</td><td>'.$info->version.'</td></tr>';
echo '<tr><td>'._('Web server').'</td><td>'.$info->webServer.'</td></tr>';
echo '<tr><td>'._('Server name').'</td><td>'.$info->serverName.'</td></tr>';

View File

@@ -18,7 +18,7 @@ class PluginProcessmakerDB extends DBmysql {
$this->dbhost = $config->fields['pm_dbserver_name'];
$this->dbuser = $config->fields['pm_dbserver_user'];
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
$this->dbdefault = $config->fields['pm_dbname'];
$this->dbdefault = isset($config->fields['pm_dbname']) ? $config->fields['pm_dbname'] : '';
parent::__construct();
}
}

View File

@@ -14,6 +14,9 @@ if (!defined('GLPI_ROOT')) {
*/
class PluginProcessmakerProcess extends CommonDBTM {
static $rightname = 'plugin_processmaker_config';
static function canCreate() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
@@ -62,18 +65,20 @@ class PluginProcessmakerProcess extends CommonDBTM {
foreach ($CFG_GLPI['languages'] as $key => $valArray) {
$lg = locale_get_primary_language( $key );
$mapLangs[$lg][] = $key;
$mapLangs[$key][] = $key; // also add complete lang
}
//}
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
$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) {
if ($task['CON_LANG'] == $lang) {
$defaultLangTaskArray[ $task['TAS_UID'] ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
$defaultLangTaskArray[ $task['TAS_UID'] ]['start']=($task['TAS_START']=='TRUE'?true:false);
$defaultLangTaskArray[$task['TAS_UID']][$task['CON_CATEGORY']] = $task['CON_VALUE'];
$defaultLangTaskArray[$task['TAS_UID']]['is_start'] = ($task['TAS_START'] == 'TRUE' ? 1 : 0);
$defaultLangTaskArray[$task['TAS_UID']]['is_subprocess'] = ($task['TAS_TYPE'] == 'SUBPROCESS' ? 1 : 0);
} else {
foreach ($mapLangs[ $task['CON_LANG'] ] as $valL) {
$taskArray[ $task['TAS_UID'] ][ $valL ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
@@ -82,7 +87,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
$pmtask = new PluginProcessmakerTaskCategory;
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), 'is_active = 1 AND processes_id = '.$this->getID());
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), '`is_active` = 1 AND `plugin_processmaker_processes_id` = '.$this->getID());
$tasks=[];
foreach($currentasksinprocess as $task){
$tasks[$task['pm_task_guid']] = $task;
@@ -96,7 +101,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
$countElt += countElementsInTable( getTableForItemType($obj), "taskcategories_id = ".$task['taskcategories_id'] );
if ($countElt != 0) {
// just set 'is_active' to 0
$pmtask->Update( array( 'id' => $task['id'], 'start' => 0, 'is_active' => 0 ) );
$pmtask->Update( array( 'id' => $task['id'], 'is_start' => 0, 'is_active' => 0 ) );
break;
}
}
@@ -112,28 +117,34 @@ class PluginProcessmakerProcess extends CommonDBTM {
foreach ($defaultLangTaskArray as $taskGUID => $task) {
$pmTaskCat = new PluginProcessmakerTaskCategory;
$taskCat = new TaskCategory;
if ($pmTaskCat->getFromDBbyExternalID( $taskGUID )) {
if ($pmTaskCat->getFromGUID( $taskGUID )) {
// got it then check names, and if != update
if ($taskCat->getFromDB( $pmTaskCat->fields['taskcategories_id'] )) {
// found it must test if should be updated
if ($taskCat->fields['name'] != $task['TAS_TITLE'] || $taskCat->fields['comment'] != $task['TAS_DESCRIPTION']) {
$taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
}
if ($pmTaskCat->fields['start'] != $task['start']) {
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'start' => $task['start'] ) );
if ($pmTaskCat->fields['is_start'] != $task['is_start']) {
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'is_start' => $task['is_start'] ) );
}
} else {
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// update pmTaskCat
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'is_start' => $task['is_start'] ) );
}
} else {
// should create a new one
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// pmTaskCat must be created too
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'], 'is_active' => 1 ) );
$pmTaskCat->add( ['plugin_processmaker_processes_id' => $this->getID(),
'pm_task_guid' => $taskGUID,
'taskcategories_id' => $taskCat->getID(),
'is_start' => $task['is_start'],
'is_active' => 1,
'is_subprocess' => $task['is_subprocess']
] );
}
// here we should take into account translations if any
if ($translates && isset($taskArray[ $taskGUID ])) {
@@ -205,10 +216,13 @@ class PluginProcessmakerProcess extends CommonDBTM {
* @return void
*/
function refresh( ) {
global $DB, $PM_SOAP;
$pmCurrentProcesses = [];
// then refresh list of available process from PM to inner table
$pm = new PluginProcessmakerProcessmaker;
$pm->login( true );
$pmProcessList = $pm->processList();
$PM_SOAP->login( true );
$pmProcessList = $PM_SOAP->processList();
$config = PluginProcessmakerConfig::getInstance();
$pmMainTaskCat = $config->fields['taskcategories_id'];
@@ -217,7 +231,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
if ($pmProcessList) {
foreach ($pmProcessList as $process) {
$glpiprocess = new PluginProcessmakerProcess;
if ($glpiprocess->getFromDBbyExternalID($process->guid)) {
if ($glpiprocess->getFromGUID($process->guid)) {
// then update it only if name has changed
if ($glpiprocess->fields['name'] != $process->name) {
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name) );
@@ -242,10 +256,51 @@ class PluginProcessmakerProcess extends CommonDBTM {
$glpiprocess->addTaskCategory( $pmMainTaskCat );
}
}
$pmCurrentProcesses[$glpiprocess->getID()] = $glpiprocess->getID();
}
}
// should de-activate other
$glpiCurrentProcesses = getAllDatasFromTable(self::getTable());
// get difference between PM and GLPI
foreach( array_diff_key($glpiCurrentProcesses, $pmCurrentProcesses) as $key => $process){
$proc = new PluginProcessmakerProcess;
$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);
if ($DB->numrows($res) === 0) {
// and if no will delete the process
$proc->delete(['id' => $key]);
// delete main taskcat
$tmp = new TaskCategory;
$tmp->delete(['id' => $proc->fields['taskcategories_id']]);
// must delete processes_profiles if any
$tmp = new PluginProcessmakerProcess_Profile;
$tmp->deleteByCriteria(['plugin_processmaker_processes_id' => $key]);
// must delete any taskcategory and translations
$pmtaskcategories = getAllDatasFromTable( PluginProcessmakerTaskCategory::getTable(), "plugin_processmaker_processes_id = $key");
foreach($pmtaskcategories as $pmcat){
// delete taskcat
$tmp = new TaskCategory;
$tmp->delete(['id' => $pmcat['taskcategories_id']]);
// delete pmtaskcat
$tmp = new PluginProcessmakerTaskCategory;
$tmp->delete(['id' => $pmcat['id']]);
// delete any translations
$tmp = new DropdownTranslation;
$tmp->deleteByCriteria(['itemtype' => 'TaskCategory', 'items_id' => $pmcat['taskcategories_id']]);
}
} else {
// set it as inactive
$proc->update(['id' => $key, 'is_active' => 0]);
}
}
}
@@ -302,15 +357,15 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* Retrieve a Process from the database using its external id (unique index): process_guid
* @param string $extid guid of the process
* @param string $process_guid guid of the process
* @return bool true if succeed else false
**/
public function getFromDBbyExternalID($extid) {
public function getFromGUID($process_guid) {
global $DB;
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `process_guid` = '$extid'";
WHERE `process_guid` = '$process_guid'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) != 1) {
@@ -467,7 +522,6 @@ class PluginProcessmakerProcess extends CommonDBTM {
//$options['canedit'] = $canedit ;
$this->initForm($ID, $options);
//$this->showTabs($options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
@@ -489,11 +543,6 @@ class PluginProcessmakerProcess extends CommonDBTM {
Dropdown::showYesNo("is_active", $this->fields["is_active"]);
echo "</td></tr>";
//echo "<tr class='tab_bg_1'>";
//echo "<td >".$LANG['tracking'][39]."&nbsp;:</td><td>";
//Dropdown::showYesNo("is_helpdeskvisible",$this->fields["is_helpdeskvisible"]);
//echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['hide_case_num_title']."&nbsp;:</td><td>";
Dropdown::showYesNo("hide_case_num_title", $this->fields["hide_case_num_title"]);
@@ -508,7 +557,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "<td >".$LANG['processmaker']['process']['type']."&nbsp;:</td><td>";
if (true) { // $canupdate || !$ID
$idticketcategorysearch = mt_rand(); $opt = array('value' => $this->fields["type"]);
$rand = $idtype = Ticket::dropdownType('type', $opt, array(), array('toupdate' => "search_".$idticketcategorysearch ));
$rand = Ticket::dropdownType('type', $opt, array(), array('toupdate' => "search_".$idticketcategorysearch ));
$opt = array('value' => $this->fields["type"]);
$params = array('type' => '__VALUE__',
//'entity_restrict' => -1, //$this->fields['entities_id'],
@@ -561,9 +610,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo Html::convDateTime($this->fields["date_mod"]);
echo "</td></tr>";
$this->showFormButtons($options );
//$this->addDivForTabs();
$this->showFormButtons($options);
}
@@ -649,7 +696,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
$query = "SELECT `entities_id`, `is_recursive`
FROM `glpi_plugin_processmaker_processes_profiles`
WHERE `processes_id` = '$processes_id'
WHERE `plugin_processmaker_processes_id` = '$processes_id'
AND `profiles_id` = '$profiles_id'";
$entities = array();

View File

@@ -10,6 +10,9 @@
*/
class PluginProcessmakerProcess_Profile extends CommonDBTM
{
static $rightname = '';
function can($ID, $right, array &$input = NULL) {
switch ($right) {
case DELETE :
@@ -43,7 +46,7 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
echo "<input type='hidden' name='processes_id' value='$ID'>";
echo "<input type='hidden' name='plugin_processmaker_processes_id' value='$ID'>";
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
@@ -58,18 +61,18 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
echo "</div>";
}
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
$query = "SELECT DISTINCT gpp.`id` AS linkID,
`glpi_profiles`.`id`,
`glpi_profiles`.`name`,
`glpi_plugin_processmaker_processes_profiles`.`is_recursive`,
`gpp`.`is_recursive`,
`glpi_entities`.`completename`,
`glpi_plugin_processmaker_processes_profiles`.`entities_id`
FROM `glpi_plugin_processmaker_processes_profiles`
`gpp`.`entities_id`
FROM `". self::getTable() ."` as gpp
LEFT JOIN `glpi_profiles`
ON (`glpi_plugin_processmaker_processes_profiles`.`profiles_id` = `glpi_profiles`.`id`)
ON (`gpp`.`profiles_id` = `glpi_profiles`.`id`)
LEFT JOIN `glpi_entities`
ON (`glpi_plugin_processmaker_processes_profiles`.`entities_id` = `glpi_entities`.`id`)
WHERE `glpi_plugin_processmaker_processes_profiles`.`processes_id` = '$ID'
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);
@@ -133,16 +136,8 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
$entname = $data["name"];
}
// if ($data["is_dynamic"] || $data["is_recursive"]) {
if ($data["is_recursive"]) {
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
//if ($data["is_dynamic"]) {
// //TRANS: letter 'D' for Dynamic
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
//}
//if ($data["is_dynamic"] && $data["is_recursive"]) {
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
//}
if ($data["is_recursive"]) {
//TRANS: letter 'R' for Recursive
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
@@ -168,28 +163,25 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
echo "</div>";
}
//static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) {
// global $CFG_GLPI;
// $action = $ma->getAction();
/**
* Summary of prepareInputForAdd
* @param mixed $input
* @return mixed
*/
function prepareInputForAdd($input) {
$tmp = new self;
if ($tmp->getFromDBByQuery(" WHERE `plugin_processmaker_processes_id` = ".$input['plugin_processmaker_processes_id']."
AND `entities_id` = ".$input['entities_id']."
AND `profiles_id` = ".$input['profiles_id'])) {
//// then update existing
//$tmp->update(['id' => $tmp->getID(),
// 'is_recursive' => $input['is_recursive']]);
Session::addMessageAfterRedirect(__('Authorization not added: already existing!', 'processmaker'), true, WARNING);
// switch ($action) {
// case 'profile_delete' :
// foreach ($ids as $id) {
// if ($item->can($id, DELETE)) {
// if ($item->delete(array("id" => $id))) {
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
// } else {
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
// $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
// }
// } else {
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
// $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
// }
// }
// break ;
// }
//}
return []; // to cancel add
}
return $input;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -21,9 +21,9 @@ class PluginProcessmakerProfile extends CommonDBTM {
'field' => 'plugin_processmaker_config',
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['case_delete'],
'field' => 'plugin_processmaker_deletecase',
'rights' => array(DELETE => __('Delete')))
'label' => $LANG['processmaker']['profile']['case'],
'field' => 'plugin_processmaker_case',
'rights' => array(READ => __('Read'), DELETE => __('Delete')))
);
return $rights;

View File

@@ -11,11 +11,24 @@
class PluginProcessmakerTask extends CommonITILTask
{
private $itemtype;
function __construct($itemtype) {
function __construct($itemtype='TicketTask') {
parent::__construct();
$this->itemtype=$itemtype;
}
/**
* Name of the type
*
* @param $nb : number of item in the type (default 0)
**/
static function getTypeName($nb=0) {
return _n('Process case task', 'Process case tasks', $nb);
}
function getItilObjectItemType() {
return str_replace('Task', '', $this->itemtype);
}
/**
* Summary of getFromDB
* @param mixed $items_id
@@ -42,24 +55,6 @@ class PluginProcessmakerTask extends CommonITILTask
}
}
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
//$ret = $DB->query( $query ) ;
//if( $ret && $DB->numrows( $ret ) == 1 ) {
// $row = $DB->fetch_assoc( $ret ) ;
// $task = new $this->itemtype;
// if( $task->getFromDB( $row['items_id'] ) ) {
// // then we should add our own fields
// unset( $row['id'] ) ;
// unset( $row['items_id'] ) ;
// unset( $row['itemtype'] ) ;
// foreach( $row as $field => $val) {
// $task->fields[ $field ] = $val ;
// }
// $this->fields = $task->fields ;
// return true ;
// }
//}
return false;
}
@@ -107,7 +102,10 @@ class PluginProcessmakerTask extends CommonITILTask
$pmTask = new self('TicketTask');
if ($pmTask->getFromDB( $event['tickettasks_id'] )) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
$event['editable'] = false;
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases';
//$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases';
$tmpCase = new PluginProcessmakerCase;
$tmpCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']);
$event['url'] = $tmpCase->getLinkURL().'&forcetab=PluginProcessmakerTask$'.$pmTask->fields['items_id'];
$taskCat = new TaskCategory;
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] );
@@ -131,4 +129,118 @@ class PluginProcessmakerTask extends CommonITILTask
}
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){
global $DB, $LANG;
$caseInfo = $case->getCaseInfo();
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId(Session::getLoginUserID());
$tasks = [];
$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) {
$tasks[$task['del_index']] = $task;
}
$tab = [];
if (property_exists($caseInfo, 'currentUsers')) {
foreach ($caseInfo->currentUsers as $caseUser) {
$title = $caseUser->taskName;
if (isset($tasks[$caseUser->delIndex])) {
$hide_claim_button = false;
if ($caseUser->userId == '') { // task to be claimed
$itemtask = getItemForItemtype($tasks[$caseUser->delIndex]['itemtype']);
$itemtask->getFromDB($tasks[$caseUser->delIndex]['items_id']);
// check if this group can be found in the current user's groups
if (!isset($_SESSION['glpigroups']) || !in_array( $itemtask->fields['groups_id_tech'], $_SESSION['glpigroups'] )) {
$hide_claim_button = true;
}
}
$tab[$tasks[$caseUser->delIndex]['id']] = ($caseUser->userId != '' && $caseUser->userId != $GLPICurrentPMUserId) || $hide_claim_button ? "<i><sub>$title</sub></i>" : $title;
//} else {
// // it's a sub case
// // then add a tab that will point to the sub-case
// $tab['sb-'.$caseUser->delIndex] = $title; // "<i><sub>$title</sub></i>";
}
}
}
return $tab;
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $case the PluginProcessmakerCase
* @param integer $tabnum contains the id the PluginProcessmakerTask
* @param mixed $withtemplate
*/
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP;
$hide_claim_button = false;
$config = $PM_SOAP->config;
$rand = rand();
// get infos for the current task
$task = getAllDatasFromTable('glpi_plugin_processmaker_tasks', "id = $tabnum");
// shows the re-assign form
$caseInfo = $case->getCaseInfo();
$currentUser = null;
foreach ($caseInfo->currentUsers as $locTask) {
if ($locTask->delIndex == $task[$tabnum]['del_index']) {
$currentUser = $locTask;
break;
}
}
if (isset($currentUser)) {
if ($currentUser->userId && $task[$tabnum]['del_index']) {
// to load users for task re-assign only when task is not to be 'claimed' and if task is not a sub-case
echo "<div class='tab_bg_2' id='divUsers-".$currentUser->delIndex."'><div class='loadingindicator'>".__('Loading...')."</div></div>";
echo "<script>$('#divUsers-{$task[$tabnum]['del_index']}').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?cases_id="
.$case->getID()
."&items_id="
.$case->fields['items_id']
."&itemtype="
.$case->fields['itemtype']
."&users_id="
.PluginProcessmakerUser::getGLPIUserId($currentUser->userId)
."&taskGuid="
.$currentUser->taskId
."&delIndex={$task[$tabnum]['del_index']}&delThread={$currentUser->delThread}&rand=$rand' ); </script>";
} else {
// manages the claim
// current task is to be claimed
// get the assigned group to the item task
$itemtask = getItemForItemtype( $task[$tabnum]['itemtype'] );
$itemtask->getFromDB( $task[$tabnum]['items_id'] );
// check if this group can be found in the current user's groups
if (!isset($_SESSION['glpigroups']) || !in_array( $itemtask->fields['groups_id_tech'], $_SESSION['glpigroups'] )) {
$hide_claim_button=true;
}
}
}
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>";
$csrf = Session::getNewCSRFToken();
echo "<iframe id='caseiframe-task-{$task[$tabnum]['del_index']}' onload=\"onTaskFrameLoad( event, {$task[$tabnum]['del_index']}, "
.($hide_claim_button?"true":"false")
.", '$csrf' );\" style='border:none;' class='tab_bg_2' width='100%' src='";
echo $PM_SOAP->serverURL
."/cases/cases_Open?sid="
.$PM_SOAP->getPMSessionID()
."&APP_UID="
.$case->fields['case_guid']
."&DEL_INDEX="
.$task[$tabnum]['del_index']
."&action=TO_DO";
echo "&rand=$rand&glpi_domain={$config->fields['domain']}'></iframe></div>";
}
}

View File

@@ -30,36 +30,36 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
self::title($item);
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='6'>".$LANG['processmaker']['title'][3]."</th></tr>";
echo "<tr><th colspan='7'>".$LANG['processmaker']['title'][3]."</th></tr>";
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['is_start']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['is_active']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['is_subprocess']."</th>" .
"</tr>";
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment`, pm.is_active FROM glpi_plugin_processmaker_taskcategories AS pm
$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.processes_id=".$item->getID().";";
WHERE pm.plugin_processmaker_processes_id=".$item->getID().";";
foreach ($DB->request($query) as $taskCat) {
echo "<tr class='tab_bg_1'>";
echo "<td class='b'><a href='".
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
$taskCat['taskcategories_id']."'>".$taskCat['name']; //str_replace(" ", "&nbsp;", $taskCat['name']);
Toolbox::getItemTypeFormURL('TaskCategory') . "?id=" . $taskCat['taskcategories_id'] . "'>" . $taskCat['name'];
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$taskCat['taskcategories_id'].")";
echo " (" . $taskCat['taskcategories_id'] . ")";
}
echo "</a></td>";
echo "<td >".$taskCat['completename']."</td>"; //str_replace(" ", "&nbsp;", $taskCat['completename'])."</td>";
echo "<td>" . $taskCat['completename'] . "</td>";
echo "<td class='center'>";
if ($taskCat['start']) {
if ($taskCat['is_start']) {
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
$LANG['processmaker']['process']['taskcategories']['start']."\">";
$LANG['processmaker']['process']['taskcategories']['is_start']."\">";
}
echo "</td>";
@@ -72,7 +72,16 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
$LANG['processmaker']['process']['taskcategories']['is_active']."\">";
}
echo "</td></tr>";
echo "</td>";
echo "<td class='center'>";
if ($taskCat['is_subprocess']) {
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
$LANG['processmaker']['process']['taskcategories']['is_subprocess']."\">";
}
echo "</td>";
echo "</tr>";
}
echo "</table></div>";
@@ -109,16 +118,16 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
/**
* Retrieve a TaskCat from the database using its external id (unique index): pm_task_guid
*
* @param $extid string externalid
* @param $task_guid string externalid
*
* @return true if succeed else false
**/
function getFromDBbyExternalID($extid) {
function getFromGUID($task_guid) {
global $DB;
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `pm_task_guid` = '$extid'";
WHERE `pm_task_guid` = '$task_guid'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) != 1) {

View File

@@ -20,7 +20,7 @@ class PluginProcessmakerUser extends CommonDBTM {
* @param $right limit user who have specific right
* @param $entity_restrict Restrict to a defined entity
* @param $value default value
* @param $used Already used items ID: not to display in dropdown
* @param $used array: Already used items ID: not to display in dropdown
* @param $search pattern
*
* @return mysql result set.
@@ -33,12 +33,16 @@ class PluginProcessmakerUser extends CommonDBTM {
//$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'; ";
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 = array( );
foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
$pmUsers[ ] = $pmUser[ 'pm_user_id' ];
}
$where = '';
$joinprofile = false;
switch ($right) {
case "id" :

View File

@@ -39,20 +39,21 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinks` (
-- Dumping structure for table glpi.glpi_plugin_processmaker_cases
CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_cases` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`id` INT(11) NOT NULL,
`itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket',
`items_id` INT(11) NOT NULL,
`case_guid` VARCHAR(32) NOT NULL,
`case_num` INT(11) NOT NULL,
`entities_id` INT(11) NOT NULL DEFAULT '0',
`name` MEDIUMTEXT NOT NULL DEFAULT '',
`case_guid` VARCHAR(32) NOT NULL,
`case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT',
`plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL,
`is_subprocess` TINYINT(1) NOT NULL DEFAULT '0',
`plugin_processmaker_cases_id` INT(11) NULL DEFAULT NULL,
INDEX `items` (`itemtype`, `items_id`),
INDEX `case_status` (`case_status`),
PRIMARY KEY (`id`),
UNIQUE INDEX `case_guid` (`case_guid`),
UNIQUE INDEX `case_num` (`case_num`),
INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`)
INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`),
INDEX `plugin_processmaker_cases_id` (`plugin_processmaker_cases_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -85,8 +86,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` (
CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_crontaskactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_processmaker_caselinks_id` int(11) DEFAULT NULL,
`itemtype` varchar(100) NOT NULL,
`items_id` int(11) NOT NULL DEFAULT '0',
`plugin_processmaker_cases_id` int(11) DEFAULT '0',
`users_id` int(11) NOT NULL DEFAULT '0',
`is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0',
`postdata` mediumtext,
@@ -117,16 +117,17 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_processes` (
-- Dumping structure for table glpi.glpi_plugin_processmaker_processes_profiles
CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_profiles` (
CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`processes_id` int(11) NOT NULL DEFAULT '0',
`plugin_processmaker_processes_id` int(11) NOT NULL DEFAULT '0',
`entities_id` int(11) NOT NULL DEFAULT '0',
`is_recursive` tinyint(1) NOT NULL DEFAULT '1',
`plugin_processmaker_processes_id` int(11) NOT NULL,
`profiles_id` int(11) NOT NULL,
`entities_id` int(11) NOT NULL,
`is_recursive` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `plugin_processmaker_processes_id_profiles_id_entities_id` (`plugin_processmaker_processes_id`, `profiles_id`, `entities_id`),
KEY `entities_id` (`entities_id`),
KEY `profiles_id` (`profiles_id`),
KEY `processes_id` (`processes_id`),
KEY `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
@@ -152,12 +153,15 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_tasks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`items_id` int(11) NOT NULL,
`itemtype` varchar(32) NOT NULL,
`case_id` varchar(32) NOT NULL,
`plugin_processmaker_cases_id` int(11) NOT NULL,
`plugin_processmaker_taskcategories_id` int(11) NOT NULL,
`del_index` int(11) NOT NULL,
`thread_index` INT(11) NOT NULL,
`del_thread` INT(11) NOT NULL,
`del_thread_status` varchar(32) NOT NULL DEFAULT 'OPEN',
PRIMARY KEY (`id`),
UNIQUE KEY `case_id` (`case_id`,`del_index`),
UNIQUE KEY `items` (`itemtype`,`items_id`)
UNIQUE KEY `tasks` (`plugin_processmaker_cases_id`,`del_index`),
UNIQUE KEY `items` (`itemtype`,`items_id`),
KEY `del_thread_status` (`del_thread_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -165,7 +169,6 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_tasks` (
CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pm_users_id` varchar(32) NOT NULL,
`password` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `pm_users_id` (`pm_users_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -1,9 +1,12 @@
<?php
function update_3_2_9_to_3_3_0(){
global $DB;
global $DB, $PM_DB; //, $PM_SOAP;
// to be sure
$PM_DB = new PluginProcessmakerDB;
// Alter table plugin_processmaker_cases
if (!arFieldExists("glpi_plugin_processmaker_cases", "plugin_processmaker_processes_id" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
@@ -15,41 +18,83 @@ function update_3_2_9_to_3_3_0(){
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_cases table step 2" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
ADD COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT FIRST,
CHANGE COLUMN `case_num` `id` INT(11) NOT NULL FIRST,
CHANGE COLUMN `itemtype` `itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket' AFTER `id`,
CHANGE COLUMN `processes_id` `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`,
ADD COLUMN `is_subprocess` TINYINT(1) NOT NULL DEFAULT '0' AFTER `plugin_processmaker_processes_id`,
ADD COLUMN `entities_id` INT(11) NOT NULL DEFAULT '0' AFTER `items_id`,
ADD COLUMN `name` MEDIUMTEXT NOT NULL DEFAULT '' AFTER `entities_id`,
CHANGE COLUMN `processes_id` `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`,
ADD COLUMN `plugin_processmaker_cases_id` INT(11) NOT NULL DEFAULT '0' AFTER `plugin_processmaker_processes_id`,
DROP INDEX `items`,
ADD INDEX `items` (`itemtype`, `items_id`),
ADD PRIMARY KEY (`id`),
ADD UNIQUE INDEX `case_guid` (`case_guid`),
ADD UNIQUE INDEX `case_num` (`case_num`),
ADD INDEX `plugin_processmaker_cases_id` (`plugin_processmaker_cases_id`),
ADD INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`);";
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_cases table step 3" . $DB->error());
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_cases table step 3 " . $DB->error());
// needs to set entities_id and name fields
// for this needs to browse all cases and do a getCaseInfo for each and to get entities_id from itemtype(items_id)
foreach($DB->request(PluginProcessmakerCase::getTable()) as $row) {
$tmp = new $row['itemtype'];
$entities_id = 0;
if ($tmp->getFromDB($row['items_id'])) {
$entities_id = $tmp->fields['entities_id'];
}
foreach($PM_DB->request("SELECT CON_VALUE FROM CONTENT WHERE CON_CATEGORY='APP_TITLE' AND CON_LANG='en' AND CON_ID='{$row['case_guid']}'") as $name) {
// there is only one record :)
$name = $PM_DB->escape($name['CON_VALUE']);
$query = "UPDATE ".PluginProcessmakerCase::getTable()." SET `name` = '{$name}', `entities_id` = $entities_id WHERE `id` = {$row['id']};";
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_cases table step 4 " . $DB->error());
}
}
}
if (!arTableExists("glpi_plugin_processmaker_profiles")) {
$query = "RENAME TABLE `glpi_plugin_processmaker_processes_profiles` TO `glpi_plugin_processmaker_profiles`;";
$DB->query($query) or die("error renaming glpi_plugin_processmaker_processes_profiles to glpi_plugin_processmaker_profiles" . $DB->error());
}
if (!arFieldExists("glpi_plugin_processmaker_processes_profiles", "plugin_processmaker_processes_id")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes_profiles`
CHANGE COLUMN `processes_id` `plugin_processmaker_processes_id` INT(11) NOT NULL DEFAULT '0' AFTER `id`,
DROP INDEX `processes_id`,
ADD INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`);";
$DB->query($query) or die("error on glpi_plugin_processmaker_processes_profiles table when renaming processes_id into plugin_processmaker_processes_id " . $DB->error());
if (!arFieldExists("glpi_plugin_processmaker_profiles", "plugin_processmaker_processes_id")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_profiles`
CHANGE COLUMN `processes_id` `plugin_processmaker_processes_id` INT(11) NOT NULL DEFAULT '0' AFTER `id`;";
$DB->query($query) or die("error renaming processes_id into plugin_processmaker_processes_id" . $DB->error());
// must clean the table in case there would be duplicate entries for a process
$query = "SELECT gpp.id, gpp.plugin_processmaker_processes_id, gpp.profiles_id, gpp.entities_id, MAX(gpp.is_recursive) AS is_recursive
FROM glpi_plugin_processmaker_processes_profiles AS gpp
GROUP BY gpp.plugin_processmaker_processes_id, gpp.profiles_id, gpp.entities_id
HAVING COUNT(id) > 1;";
foreach($DB->request($query) as $rec){
// there we have one rec per duplicates
// so we may delete all records in the table, and a new one
$del_query = "DELETE FROM glpi_plugin_processmaker_processes_profiles WHERE plugin_processmaker_processes_id=".$rec['plugin_processmaker_processes_id']."
AND profiles_id = ".$rec['profiles_id']."
AND entities_id = ".$rec['entities_id'].";";
$DB->query($del_query) or die("error when deleting duplicated process_profiles in glpi_plugin_processmaker_processes_profiles table ". $DB->error());
$add_query = "INSERT INTO `glpi_plugin_processmaker_processes_profiles` (`id`, `plugin_processmaker_processes_id`, `profiles_id`, `entities_id`, `is_recursive`)
VALUES (".$rec['id'].", ".$rec['plugin_processmaker_processes_id'].", ".$rec['profiles_id'].", ".$rec['entities_id'].", ".$rec['is_recursive'].");";
$DB->query($add_query) or die("error when inserting singletons of duplicated process_profiles in glpi_plugin_processmaker_processes_profiles table ". $DB->error());
}
$query = "ALTER TABLE `glpi_plugin_processmaker_processes_profiles`
ADD UNIQUE INDEX `plugin_processmaker_processes_id_profiles_id_entities_id` (`plugin_processmaker_processes_id`, `profiles_id`, `entities_id`);";
$DB->query($query) or die("error when adding new index on glpi_plugin_processmaker_processes_profiles table " . $DB->error());
}
if (!arFieldExists("glpi_plugin_processmaker_tasks", "plugin_processmaker_cases_id" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_tasks`
ALTER `itemtype` DROP DEFAULT;";
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_tasks table step 1" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_tasks`
CHANGE COLUMN `itemtype` `itemtype` VARCHAR(32) NOT NULL AFTER `id`,
ADD COLUMN `plugin_processmaker_cases_id` INT(11) NULL AFTER `case_id`,
ADD COLUMN `thread_index` INT(11) NOT NULL AFTER `del_index`,
ADD COLUMN `plugin_processmaker_taskcategories_id` INT(11) NULL AFTER `plugin_processmaker_cases_id`,
ADD COLUMN `del_thread` INT(11) NOT NULL AFTER `del_index`,
ADD COLUMN `del_thread_status` VARCHAR(32) NOT NULL DEFAULT 'OPEN' AFTER `del_thread`,
DROP INDEX `case_id`,
ADD INDEX `plugin_processmaker_cases_id` (`plugin_processmaker_cases_id`, `del_index`);";
ADD UNIQUE INDEX `tasks` (`plugin_processmaker_cases_id`, `del_index`),
ADD INDEX `del_thread_status` (`del_thread_status`);";
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_tasks table step 2" . $DB->error());
// transform case_id (=GUID) into plugin_processmaker_cases_id
@@ -61,6 +106,48 @@ function update_3_2_9_to_3_3_0(){
$query = "ALTER TABLE `glpi_plugin_processmaker_tasks`
DROP COLUMN `case_id`;";
$DB->query($query) or die("error deleting case_id column in glpi_plugin_processmaker_tasks table" . $DB->error());
// set real thread status get it from APP_DELEGATION
$query = "SELECT APP_UID, DEL_INDEX, DEL_THREAD, DEL_THREAD_STATUS FROM APP_DELEGATION WHERE DEL_THREAD_STATUS = 'CLOSED';";
$locThreads = [];
foreach($PM_DB->request($query) as $thread){
$locThreads[$thread['APP_UID']][] = $thread;
}
$locCase = new PluginProcessmakerCase;
foreach($locThreads as $key => $threads){
// get GLPI case id
$locCase->getFromGUID($key);
$del_indexes = [];
foreach($threads as $thread){
$del_indexes[] = $thread['DEL_INDEX'];
}
$del_indexes = implode(", ", $del_indexes);
$query = "UPDATE glpi_plugin_processmaker_tasks SET del_thread_status = 'CLOSED' WHERE plugin_processmaker_cases_id = {$locCase->getID()} AND del_index IN ($del_indexes)";
$DB->query($query) or die("error updating del_thread_status in glpi_plugin_processmaker_tasks table" . $DB->error());
}
// set the plugin_processmaker_taskcategories_id
$app_delegation = [];
$query = "SELECT CONCAT(APPLICATION.APP_NUMBER, '-', APP_DELEGATION.DEL_INDEX) AS 'key', APP_DELEGATION.TAS_UID FROM APP_DELEGATION
LEFT JOIN APPLICATION ON APPLICATION.APP_UID=APP_DELEGATION.APP_UID";
foreach($PM_DB->request($query) as $row) {
$app_delegation[$row['key']]=$row['TAS_UID'];
}
$taskcats = [];
$query = "SELECT * FROM glpi_plugin_processmaker_taskcategories";
foreach($DB->request($query) as $row) {
$taskcats[$row['pm_task_guid']] = $row['id'];
}
$query = "SELECT * FROM glpi_plugin_processmaker_tasks";
foreach($DB->request($query) as $row) {
$key = $row['plugin_processmaker_cases_id']."-".$row['del_index'];
if (isset($app_delegation[$key]) && isset($taskcats[$app_delegation[$key]])) {
$DB->query("UPDATE glpi_plugin_processmaker_tasks SET plugin_processmaker_taskcategories_id={$taskcats[$app_delegation[$key]]} WHERE id={$row['id']}") or
die("error updating plugin_processmaker_taskcategories_id in glpi_plugin_processmaker_tasks table" . $DB->error());
}
}
}
if (!arFieldExists("glpi_plugin_processmaker_taskcategories", "is_subprocess" )) {
@@ -77,5 +164,33 @@ function update_3_2_9_to_3_3_0(){
$DB->query($query) or die("error normalizing glpi_plugin_processmaker_taskcategories step 2" . $DB->error());
}
if (arFieldExists("glpi_plugin_processmaker_users", "password" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
DROP COLUMN `password`;
";
$DB->query($query) or die("error deleting password col from glpi_plugin_processmaker_users" . $DB->error());
}
if (!arFieldExists("glpi_plugin_processmaker_crontaskactions", "plugin_processmaker_cases_id" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
ADD COLUMN `plugin_processmaker_cases_id` INT(11) DEFAULT '0' AFTER `plugin_processmaker_caselinks_id`;" ;
$DB->query($query) or die("error adding plugin_processmaker_cases_id col into glpi_plugin_processmaker_crontaskactions" . $DB->error());
// data migration
// before the 3.3.0 release there was one and only one case per item
$query ="UPDATE `glpi_plugin_processmaker_crontaskactions`
LEFT JOIN `glpi_plugin_processmaker_cases` ON `glpi_plugin_processmaker_cases`.`itemtype` = `glpi_plugin_processmaker_crontaskactions`.`itemtype`
AND `glpi_plugin_processmaker_cases`.`items_id` = `glpi_plugin_processmaker_crontaskactions`.`items_id`
SET `glpi_plugin_processmaker_crontaskactions`.`plugin_processmaker_cases_id` = `glpi_plugin_processmaker_cases`.`id`;";
$DB->query($query) or die("error migrating itemtype and items_id into a plugin_processmaker_cases_id col in glpi_plugin_processmaker_crontaskactions" . $DB->error());
// end of migration
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
DROP COLUMN `itemtype`,
DROP COLUMN `items_id`;";
$DB->query($query) or die("error deleting adding itemtype and items_id cols from glpi_plugin_processmaker_crontaskactions" . $DB->error());
}
return '3.3.0';
}

View File

@@ -38,6 +38,8 @@ function update_to_3_2_8(){
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
;";
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
$DB->query("UPDATE glpi_plugin_processmaker_configs SET `pm_dbname` = CONCAT('wf_', `pm_workspace`) WHERE `id` = 1");
}
if (arTableExists("glpi_plugin_processmaker_profiles")) {
@@ -59,7 +61,7 @@ function update_to_3_2_8(){
$proc = new PluginProcessmakerProcess;
$case = new PluginProcessmakerCase;
foreach ($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
$proc->getFromDBbyExternalID( $row['processes_id'] );
$proc->getFromGUID( $row['processes_id'] );
$case->update(array( 'id' => $row['id'], 'processes_id' => $proc->getID() ) );
}
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`

View File

@@ -72,7 +72,7 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
submitButton = $("input[name='add'][type=submit]")[0];
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_action' value='routecase'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseid' value='" + caseId + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseguid' value='" + caseId + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");

View File

@@ -1,7 +1,6 @@
//debugger;
// To manage submits to case.front.php
var loc_split = window.location.href.split('/');
var GLPI_HTTP_CASE_FORM = window.location.href.split('/', loc_split.length-2 ).join('/') + '/plugins/processmaker/front/case.front.php'; // http://hostname/glpi/...
var GLPI_HTTP_CASE_FORM = window.location.href.replace(window.location.search, ''); //window.location.href.split('/', loc_split.length - 2).join('/') + '/plugins/processmaker/front/case.front.php'; // http://hostname/glpi/...
// to manage reloads
var GLPI_RELOAD_PARENT = window; //.location;
var GLPI_DURING_RELOAD = false;
@@ -85,7 +84,7 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
node.setAttribute('actionBackup', node.action);
var action = node.action.split('?');
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex + '&action=route';
// add an element that will be the csrf data code for the POST
//debugger;

View File

@@ -10,13 +10,13 @@ $LANG['processmaker']['title'][7]="Case-links";
$LANG['processmaker']['profile']['rightmgt']="Rights Management";
$LANG['processmaker']['profile']['process_config']="Process configuration";
$LANG['processmaker']['profile']['case_delete']="Delete cases";
$LANG['processmaker']['profile']['case']="Cases";
$LANG['processmaker']['process']['process_guid']="Process GUID";
$LANG['processmaker']['process']['project_type_short']="Project type" ;
$LANG['processmaker']['process']['project_type']="Project type (to be changed if not up-to-date)" ;
$LANG['processmaker']['process']['project_type_bpmn']='bpmn';
$LANG['processmaker']['process']['project_type_classic']='classic' ;
$LANG['processmaker']['process']['project_type_bpmn']='BPMN';
$LANG['processmaker']['process']['project_type_classic']='Classic' ;
$LANG['processmaker']['process']['hide_case_num_title_short']="Hide case number and title";
$LANG['processmaker']['process']['hide_case_num_title']="Hide case number and title in task descriptions";
$LANG['processmaker']['process']['insert_task_comment_short']="Insert Task Category";
@@ -26,9 +26,10 @@ $LANG['processmaker']['process']['itilcategory']="ITIL Category (self-service)";
$LANG['processmaker']['process']['taskcategories']['guid']="Task GUID";
$LANG['processmaker']['process']['taskcategories']['name']="Task name";
$LANG['processmaker']['process']['taskcategories']['completename']="Complete name";
$LANG['processmaker']['process']['taskcategories']['start']="Start";
$LANG['processmaker']['process']['taskcategories']['is_start']="Start";
$LANG['processmaker']['process']['taskcategories']['comment']="Comment";
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
$LANG['processmaker']['process']['taskcategories']['is_subprocess']="Sub-process";
$LANG['processmaker']['process']['profile']="Delete permanently";
$LANG['processmaker']['config']['name']="Name";
@@ -44,7 +45,7 @@ $LANG['processmaker']['config']['refreshprocesslist']="Synchronize Process List"
$LANG['processmaker']['config']['refreshtasklist']="Synchronize Task List";
$LANG['processmaker']['config']['main_task_category']="Main Task Category (edit to change name)";
$LANG['processmaker']['config']['taskwriter']="Task Writer (edit to change name)";
$LANG['processmaker']['config']['pm_group_name']="Group in ProcessMaker which will contain all GLPi users";
$LANG['processmaker']['config']['pm_group_name']="Group in ProcessMaker which will contain all GLPI users";
$LANG['processmaker']['config']['maintenance']="Maintenance mode" ;
$LANG['processmaker']['config']['undermaintenance']="Under maintenance, please try again later." ;
$LANG['processmaker']['config']['empty_pm_group_name']="To select group, input ProcessMaker config first!";
@@ -59,7 +60,7 @@ $LANG['processmaker']['item']['pausedtask']="Status: Task is paused - unpause it
$LANG['processmaker']['item']['completedcase']="Status: Completed";
$LANG['processmaker']['item']['nocase']="No case for this item!";
$LANG['processmaker']['item']['startone']="Start one?";
$LANG['processmaker']['item']['selectprocess']="Select the process you want to start:";
$LANG['processmaker']['item']['selectprocess']="Select the process you want to add:";
$LANG['processmaker']['item']['start']="Start";
$LANG['processmaker']['item']['unpause']="Unpause";
$LANG['processmaker']['item']['deletecase']="Delete case?" ;
@@ -82,11 +83,11 @@ $LANG['processmaker']['item']['case']['casemap']="Case map";
$LANG['processmaker']['item']['case']['casehistory']='Case history' ;
$LANG['processmaker']['item']['case']['dynaforms']='Dynaforms';
$LANG['processmaker']['item']['case']['changelog']='Change log';
$LANG['processmaker']['item']['case']['caseinfo']='Case info';
$LANG['processmaker']['item']['case']['viewcasemap']='View: case map';
$LANG['processmaker']['item']['case']['viewcasehistory']='View: case history';
$LANG['processmaker']['item']['case']['viewdynaforms']='View: dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='View: change log' ;
$LANG['processmaker']['item']['case']['caseinfo']='Case';
$LANG['processmaker']['item']['case']['viewcasemap']='Map';
$LANG['processmaker']['item']['case']['viewcasehistory']='History';
$LANG['processmaker']['item']['case']['viewdynaforms']='Dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='Change log' ;
$LANG['processmaker']['item']['case']['casechangeloghistory']='Change log history' ;
$LANG['processmaker']['item']['error'][11]="Error creating case!";
@@ -103,10 +104,10 @@ $LANG['processmaker']['item']['task']['comment']="##processmaker.taskcomment##"
$LANG['processmaker']['item']['task']['manage']="##ticket.url##_PluginProcessmakerCase\$processmakercases" ;
$LANG['processmaker']['item']['task']['manage_text']= "" ; //"Process - Case tab";
$LANG['processmaker']['case']['statuses']['TO_DO'] = "Processing";
$LANG['processmaker']['case']['statuses']['TO_DO'] = "To do";
$LANG['processmaker']['case']['statuses']['CANCELLED'] = "Cancelled";
$LANG['processmaker']['case']['statuses']['DRAFT'] = "New";
$LANG['processmaker']['case']['statuses']['COMPLETED'] = "Closed";
$LANG['processmaker']['case']['statuses']['DRAFT'] = "Draft";
$LANG['processmaker']['case']['statuses']['COMPLETED'] = "Completed";
$LANG['processmaker']['search']['case']="Case";
$LANG['processmaker']['search']['status']="Status";

View File

@@ -26,9 +26,10 @@ $LANG['processmaker']['process']['type']="Type de ticket (self-service)";
$LANG['processmaker']['process']['itilcategory']="Catégorie ITIL (self-service)";
$LANG['processmaker']['process']['taskcategories']['name']="Nom de la Tâche";
$LANG['processmaker']['process']['taskcategories']['completename']="Nom complet";
$LANG['processmaker']['process']['taskcategories']['start']="Début";
$LANG['processmaker']['process']['taskcategories']['is_start']="Début";
$LANG['processmaker']['process']['taskcategories']['comment']="Commentaire";
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
$LANG['processmaker']['process']['taskcategories']['is_subprocess']="Sous-process";
$LANG['processmaker']['process']['profile']="Effacer définitivement";
$LANG['processmaker']['config']['name']="Nom";
@@ -44,7 +45,7 @@ $LANG['processmaker']['config']['refreshprocesslist']="Synchroniser la liste des
$LANG['processmaker']['config']['refreshtasklist']="Synchroniser la liste des Tâches";
$LANG['processmaker']['config']['main_task_category']="Categorie principale des tâches (editer pour changer le nom)";
$LANG['processmaker']['config']['taskwriter']="Auteur des tâches (editer pour changer le nom)";
$LANG['processmaker']['config']['pm_group_name']="Groupe dans ProcessMaker qui contiendra les utilisateurs de GLPi";
$LANG['processmaker']['config']['pm_group_name']="Groupe dans ProcessMaker qui contiendra les utilisateurs de GLPI";
$LANG['processmaker']['config']['maintenance']="Mode maintenance" ;
$LANG['processmaker']['config']['undermaintenance']="En maintenance, veuillez réessayer plus tard." ;
$LANG['processmaker']['config']['empty_pm_group_name']="Pour sélectionner un groupe, renseigner d'abord la config de ProcessMaker !";
@@ -103,9 +104,9 @@ $LANG['processmaker']['item']['task']['comment']="##processmaker.taskcomment##"
$LANG['processmaker']['item']['task']['manage']="##ticket.url##_PluginProcessmakerCase\$processmakercases" ;
$LANG['processmaker']['item']['task']['manage_text']=""; //"l'onglet Processus - Cas";
$LANG['processmaker']['case']['statuses']['TO_DO'] = "En cours";
$LANG['processmaker']['case']['statuses']['TO_DO'] = "A faire";
$LANG['processmaker']['case']['statuses']['CANCELLED'] = "Annulé";
$LANG['processmaker']['case']['statuses']['DRAFT'] = "Nouveau";
$LANG['processmaker']['case']['statuses']['DRAFT'] = "Brouillon";
$LANG['processmaker']['case']['statuses']['COMPLETED'] = "Achevé";
$LANG['processmaker']['search']['case']="Cas";

View File

@@ -12,7 +12,7 @@ function plugin_init_processmaker() {
Plugin::registerClass('PluginProcessmakerProcessmaker');
Plugin::registerClass('PluginProcessmakerCase', array('addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerCase', array('addtabon' => $objects));
Plugin::registerClass('PluginProcessmakerTaskCategory');
@@ -30,7 +30,7 @@ function plugin_init_processmaker() {
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
$PLUGIN_HOOKS['pre_show_item']['processmaker']
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmaker');
//$PLUGIN_HOOKS['pre_item_form']['processmaker']
// = array('PluginProcessmakerProcessmaker', 'pre_item_form_processmakerticket');
@@ -44,7 +44,8 @@ function plugin_init_processmaker() {
// Display a menu entry ?
if (Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE])) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = ['tools' => 'PluginProcessmakerMenu'];
// tools and helpdesk
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = ['tools' => 'PluginProcessmakerMenu', 'helpdesk' => 'PluginProcessmakerCase'];
}
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) );
@@ -111,13 +112,18 @@ function plugin_init_processmaker() {
$CFG_GLPI['planning_types'][] = 'PluginProcessmakerTask';
$PLUGIN_HOOKS['post_init']['processmaker'] = 'plugin_processmaker_post_init';
// in order to set rights when in helpdesk interface
// otherwise post-only users can't see cases and then can't act on a case task.
$PLUGIN_HOOKS['change_profile']['processmaker'] = 'plugin_processmaker_change_profile';
}
// Get the name and the version of the plugin - Needed
function plugin_version_processmaker() {
global $LANG;
return array ('name' => 'Process Maker',
return array ('name' => 'Process Maker',
'version' => '3.3.0',
'author' => 'Olivier Moron',
'homepage' => 'https://github.com/tomolimo/processmaker',