Version 3.0.0 first version compatible with GLPi 9.1.1

This commit is contained in:
tomolimo
2016-10-25 11:37:01 +02:00
parent 82317dce44
commit 094b281fb4
44 changed files with 4812 additions and 3926 deletions

View File

@@ -1,4 +1,4 @@
# processmaker
GLPI plugin that provides an interface with ProcessMaker (http://www.processmaker.com/).
Is currently compatible to GLPI 0.83.8 and ProcessMaker 2.5, 2.8 and 3.0 (see note below)
Note: for ProcessMaker 3.0, this plugin can run old (2.x) and new (3.x) processes, but the process map view (for new BMPN process) has a bug.
Is currently compatible to GLPI 9.1 and ProcessMaker 3.0 (see note below)
Note: for ProcessMaker 3.0, this plugin can run old (2.x) and new (3.x) processes

View File

@@ -2,14 +2,12 @@
// ----------------------------------------------------------------------
// Original Author of file: Olivier Moron
// Purpose of file:
// Purpose of file: to return list of processes which can be started by end-user
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
$AJAX_INCLUDE = 1;
define('GLPI_ROOT','../../..');
include (GLPI_ROOT."/inc/includes.php");
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
@@ -18,98 +16,57 @@ if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
include_once dirname(__FILE__)."/../inc/process.class.php" ;
//include_once dirname(__FILE__)."/../inc/process.class.php" ;
Session::checkLoginUser();
if (!isset($_POST['right'])) {
$_POST['right'] = "all";
if (isset($_REQUEST["entity_restrict"])
&& !is_array($_REQUEST["entity_restrict"])
&& (substr($_REQUEST["entity_restrict"], 0, 1) === '[')
&& (substr($_REQUEST["entity_restrict"], -1) === ']')) {
$_REQUEST["entity_restrict"] = json_decode($_REQUEST["entity_restrict"]);
}
// Default view : Nobody
if (!isset($_POST['all'])) {
$_POST['all'] = 0;
// Security
if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
exit();
}
$used = array();
// Count real items returned
$count = 0;
if (isset($_POST['used'])) {
if (is_array($_POST['used'])) {
$used = $_POST['used'];
} else {
$used = unserialize(stripslashes($_POST['used']));
}
if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
}
if (isset($_POST["entity_restrict"])
&& !is_numeric($_POST["entity_restrict"])
&& !is_array($_POST["entity_restrict"])) {
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
if (!empty($_REQUEST['searchText'])) {
$search = Search::makeTextSearch($_REQUEST['searchText']);
}
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $_POST['right'], $_POST["entity_restrict"],
$_POST['value'], $used, $_POST['searchText']);
$processes = array();
// Empty search text : display first
//if (empty($_REQUEST['searchText'])) {
if ($_REQUEST['display_emptychoice']) {
if (($one_item < 0) || ($one_item == 0)) {
array_push($processes, array('id' => 0,
'text' => $_REQUEST['emptylabel']));
}
}
//}
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
if( in_array( $_POST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
$processes[$data["id"]] = $data["name"];
if( in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
array_push( $processes, array( 'id' => $data["id"],
'text' => $data["name"] ));
$count++;
}
}
}
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name='".$_POST['myname']."'";
if (isset($_POST["on_change"]) && !empty($_POST["on_change"])) {
echo " onChange='".$_POST["on_change"]."'";
}
echo ">";
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]
&& $DB->numrows($result)==$CFG_GLPI["dropdown_max"]) {
echo "<option value='0'>--".$LANG['common'][11]."--</option>";
}
if ($_POST['all']==0) {
echo "<option value='0'>".Dropdown::EMPTY_VALUE."</option>";
} else if ($_POST['all']==1) {
echo "<option value='0'>[".$LANG['common'][66]."]</option>";
}
if (isset($_POST['value'])) {
$output = PluginProcessmakerProcess::getProcessName($_POST['value']);
if (!empty($output) && $output!="&nbsp;") {
echo "<option selected value='".$_POST['value']."'>".$output."</option>";
}
}
if (count($processes)) {
foreach ($processes as $ID => $output) {
echo "<option value='$ID' title=\"".Html::cleanInputText($output)."\">".
Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"])."</option>";
}
}
echo "</select>";
if (isset($_POST["comment"]) && $_POST["comment"]) {
$paramscomment = array('value' => '__VALUE__',
'table' => "glpi_plugin_processmaker_processes");
if (isset($_POST['update_link'])) {
$paramscomment['withlink'] = "comment_link_".$_POST["myname"].$_POST["rand"];
}
Ajax::updateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],
"comment_".$_POST["myname"].$_POST["rand"],
$CFG_GLPI["root_doc"]."/ajax/comments.php", $paramscomment);
}
Ajax::commonDropdownUpdateItem($_POST);
?>
$ret['results'] = $processes;
$ret['count'] = $count;
echo json_encode($ret);

View File

@@ -10,9 +10,7 @@
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"dropdownUsers.php")) {
$AJAX_INCLUDE = 1;
define('GLPI_ROOT','../../..');
include (GLPI_ROOT."/inc/includes.php");
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
@@ -21,114 +19,117 @@ if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
include_once dirname(__FILE__)."/../inc/users.class.php" ;
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
Session::checkLoginUser();
if (!isset($_POST['right'])) {
$_POST['right'] = "all";
$PM_DB = new PluginProcessmakerDB ;
if (!isset($_REQUEST['right'])) {
$_REQUEST['right'] = "all";
}
// Default view : Nobody
if (!isset($_POST['all'])) {
$_POST['all'] = 0;
if (!isset($_REQUEST['all'])) {
$_REQUEST['all'] = 0;
}
$used = array();
if (isset($_POST['used'])) {
if (is_array($_POST['used'])) {
$used = $_POST['used'];
} else {
$used = unserialize(stripslashes($_POST['used']));
}
if (isset($_REQUEST['used'])) {
$used = $_REQUEST['used'];
}
if (isset($_POST["entity_restrict"])
&& !is_numeric($_POST["entity_restrict"])
&& !is_array($_POST["entity_restrict"])) {
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
if (!isset($_REQUEST['value'])) {
$_REQUEST['value'] = 0;
}
$result = PluginProcessmakerUsers::getSqlSearchResult( $_POST['pmTaskId'], false, $_POST['right'], $_POST["entity_restrict"],
$_POST['value'], $used, $_POST['searchText']);
$one_item = -1;
if (isset($_REQUEST['_one_id'])) {
$one_item = $_REQUEST['_one_id'];
}
if (!isset($_REQUEST['page'])) {
$_REQUEST['page'] = 1;
$_REQUEST['page_limit'] = $CFG_GLPI['dropdown_max'];
}
if ($one_item < 0) {
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
//$result = User::getSqlSearchResult(false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
// $_REQUEST['value'], $used, $_REQUEST['searchText'], $start,
// $_REQUEST['page_limit']);
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['pmTaskId'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
$_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT);
} else {
$query = "SELECT DISTINCT `glpi_users`.*
FROM `glpi_users`
WHERE `glpi_users`.`id` = '$one_item';";
$result = $DB->query($query);
}
$users = array();
// check if $_POST["myname"] matches _itil_\w+\[users_id\]
if( preg_match( "/^_itil_\\w+\\[users_id\\]/", $_POST["myname"] ) || preg_match( "/^_users_id_\\w+/", $_POST["myname"] )) {
// prevent use of pseudo-groups like *Raynet-Development_Intranet (TASK USE ONLY!)
$raynetPseudoGroupNoUse = true ;
} else $raynetPseudoGroupNoUse = false ;
// Count real items returned
$count = 0;
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
if( !$raynetPseudoGroupNoUse || mb_strpos( $data["name"], "*" ) === false ) {
$users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"],
$data["firstname"]);
$logins[$data["id"]] = $data["name"];
}
}
while ($data = $DB->fetch_assoc($result)) {
$users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"],
$data["firstname"]);
$logins[$data["id"]] = $data["name"];
}
}
if (!function_exists('dpuser_cmp')) {
function dpuser_cmp($a, $b) {
return strcasecmp($a, $b);
}
function dpuser_cmp($a, $b) {
return strcasecmp($a, $b);
}
}
// Sort non case sensitive
uasort($users, 'dpuser_cmp');
//uasort($users, 'dpuser_cmp');
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name='".$_POST['myname']."'";
$datas = array();
if (isset($_POST["on_change"]) && !empty($_POST["on_change"])) {
echo " onChange='".$_POST["on_change"]."'";
}
echo ">";
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]
&& $DB->numrows($result)==$CFG_GLPI["dropdown_max"]) {
echo "<option value='0'>--".$LANG['common'][11]."--</option>";
}
if ($_POST['all']==0) {
echo "<option value='0'>".Dropdown::EMPTY_VALUE."</option>";
} else if ($_POST['all']==1) {
echo "<option value='0'>[".$LANG['common'][66]."]</option>";
}
if (isset($_POST['value'])) {
$output = getUserName($_POST['value']);
if (!empty($output) && $output!="&nbsp;") {
echo "<option selected value='".$_POST['value']."'>".$output."</option>";
}
// Display first if empty search
if ($_REQUEST['page'] == 1 && empty($_REQUEST['searchText'])) {
if (($one_item < 0) || ($one_item == 0)) {
if ($_REQUEST['all'] == 0) {
array_push($datas, array('id' => 0,
'text' => Dropdown::EMPTY_VALUE));
} else if ($_REQUEST['all'] == 1) {
array_push($datas, array('id' => 0,
'text' => __('All')));
}
}
}
if (count($users)) {
foreach ($users as $ID => $output) {
echo "<option value='$ID' title=\"".Html::cleanInputText($output." - ".$logins[$ID])."\">".
Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"])."</option>";
}
}
echo "</select>";
foreach ($users as $ID => $output) {
$title = sprintf(__('%1$s - %2$s'), $output, $logins[$ID]);
if (isset($_POST["comment"]) && $_POST["comment"]) {
$paramscomment = array('value' => '__VALUE__',
'table' => "glpi_users");
if (isset($_POST['update_link'])) {
$paramscomment['withlink'] = "comment_link_".$_POST["myname"].$_POST["rand"];
}
Ajax::updateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],
"comment_".$_POST["myname"].$_POST["rand"],
$CFG_GLPI["root_doc"]."/ajax/comments.php", $paramscomment);
array_push($datas, array('id' => $ID,
'text' => $output,
'title' => $title));
$count++;
}
}
if (($one_item >= 0)
&& isset($datas[0])) {
echo json_encode($datas[0]);
} else {
$ret['results'] = $datas;
$ret['count'] = $count;
echo json_encode($ret);
}
Ajax::commonDropdownUpdateItem($_POST);
?>

View File

@@ -1,81 +0,0 @@
<?php
function HandleHeaderLine( $curl, $header_line ) {
$temp = explode( ": ", $header_line ) ;
if( is_array( $temp ) && $temp[0] == 'Set-Cookie' ) {
header("Set-Cookie: ".$temp[1], false) ;
}
return strlen($header_line);
}
$ch = curl_init();
$pmURL = urldecode($_REQUEST['url']) ;
curl_setopt($ch, CURLOPT_URL, $pmURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine");
$body = curl_exec($ch);
curl_close ($ch);
$pmBaseURL = explode( "/", $pmURL, 4 ) ;
array_pop( $pmBaseURL ) ;
echo "
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='utf-8' />
<title></title>
<link href='".implode("/", $pmBaseURL)."/css/classic-blank.css' rel='stylesheet' type='text/css'/>
</head>
<body aLink='#999999' leftMargin='0' rightMargin='0' topMargin='0' bgColor='#ffffff' text='#000000' vLink='#000000' link='#000000' marginwidth='0' marginheight='0'>
<table cellSpacing='0' cellPadding='0' width='100%' height='100%'>
<tbody><tr>
<td vAlign='top' width='100%'>
<table style='padding-top: 3px;' border='0' cellSpacing='0' cellPadding='0' width='100%'>
<tbody><tr>
<td align='center'>
<div style='margin: 0px;' id='publisherContent[0]' align='center'> <form style='margin: 0px;' id='bHNTajBhT2lsNUhqMmFUTXg1cXM1NTdTWWR1ZDJB' class='formDefault' onsubmit='return validateForm(\"[]\");' encType='multipart/form-data' method='post' name='cases_Resume' action=''> <div style='border-width: 1px; width: 550px; padding-right: 0px; padding-left: 0px;' class='borderForm'>
<div class='boxTop'><div class='a'>&nbsp;</div><div class='b'>&nbsp;</div><div class='c'>&nbsp;</div></div>
<div style='height: 100%;' class='content'>
<table width='99%'>
<tbody><tr>
<td vAlign='top'>
<table border='0' cellSpacing='0' cellPadding='0' width='100%'>
<tbody><tr>
<td class='FormTitle' colSpan='2' align=''><span >Task Properties</span></td>
</tr>
<tr>
<td class='FormLabel' width='150'><label >Ongoing Task</label></td>
<td class='FormFieldContent' width='400'>".urldecode($_REQUEST['taskname'])."</td>
<tr>
<td class='FormLabel' width='150'><label >By</label></td>
<td class='FormFieldContent' width='400'>".urldecode($_REQUEST['username'])."</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</div>
<div class='boxBottom'><div class='a'>&nbsp;</div><div class='b'>&nbsp;</div><div class='c'>&nbsp;</div></div>
</div>
</form>
</div></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</body>
</html>
" ;

View File

@@ -7,9 +7,7 @@
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
$AJAX_INCLUDE = 1;
define('GLPI_ROOT','../../..');
include (GLPI_ROOT."/inc/includes.php");
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
@@ -18,11 +16,12 @@ if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
include_once dirname(__FILE__)."/../inc/users.class.php" ;
//include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
Session::checkLoginUser();
$PM_DB = new PluginProcessmakerDB ;
$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")."'>";
@@ -36,15 +35,16 @@ echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQ
echo "<input type='hidden' name='plugin_processmaker_taskId' value='".$_REQUEST['taskId']."'>";
echo "<input type='hidden' name='plugin_processmaker_delThread' value='".$_REQUEST['delThread']."'>";
PluginProcessmakerUsers::dropdown( array('name' => 'users_id_recipient',
'value' => PluginProcessmakerProcessmaker::getGLPIUserId( $_REQUEST['userId'] ),
'entity' => 0, //$item->fields["entities_id"],
'entity_sons' => true,
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
'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,
'pmTaskId' => $_REQUEST['taskId']));
'width' => '',
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
echo "&nbsp;&nbsp;";
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
echo "</form>";
Html::closeForm(true);
//echo "</form>";
?>

View File

@@ -1,14 +1,13 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
include_once '../inc/processmaker.class.php' ;
include_once '../inc/cases.class.php' ;
define('DO_NOT_CHECK_HTTP_REFERER', 1);
include_once '../../../inc/includes.php';
//include_once '../inc/processmaker.class.php' ;
//include_once '../inc/case.class.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 PluginProcessmakerCases ;
$myCase = new PluginProcessmakerCase ;
if( $myCase->getFromDB( $_REQUEST['APP_UID'] ) ) {
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login( ) ;
@@ -23,22 +22,73 @@ if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUE
$pmRouteCaseResponse = $myProcessMaker->routeCase( $myCase->getID(), $_REQUEST['DEL_INDEX']) ;
// now tries to get some variables to setup content for new task and to append text to solved task
$txtForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_TASK_CONTENT", "GLPI_ITEM_APPEND_TO_TASK", "GLPI_NEXT_GROUP_TO_BE_ASSIGNED" ) );
if( array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $txtForTasks ) )
$txtToAppendToTask = $txtForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ] ;
else
$txtToAppendToTask = '' ;
if( array_key_exists( 'GLPI_ITEM_TASK_CONTENT', $txtForTasks ) )
$txtTaskContent = $txtForTasks[ 'GLPI_ITEM_TASK_CONTENT' ] ;
else
$txtTaskContent = '' ;
if( array_key_exists( 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED', $txtForTasks ) )
$groupId = $txtForTasks[ 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' ] ;
else
$groupId = 0 ;
$infoForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_TASK_CONTENT",
"GLPI_ITEM_APPEND_TO_TASK",
"GLPI_NEXT_GROUP_TO_BE_ASSIGNED",
"GLPI_ITEM_TITLE",
"GLPI_TICKET_FOLLOWUP_CONTENT",
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE",
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID",
"GLPI_ITEM_TASK_ENDDATE",
"GLPI_ITEM_TASK_STARTDATE",
"GLPI_ITEM_SET_STATUS"
) );
$itemSetStatus = '';
if( array_key_exists( 'GLPI_ITEM_SET_STATUS', $infoForTasks ) ) {
$itemSetStatus = $infoForTasks[ 'GLPI_ITEM_SET_STATUS' ] ;
}
$txtItemTitle = '' ;
if( array_key_exists( 'GLPI_ITEM_TITLE', $infoForTasks ) ) {
$txtItemTitle = $infoForTasks[ 'GLPI_ITEM_TITLE' ] ;
}
$txtToAppendToTask = '' ;
if( array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $infoForTasks ) ) {
$txtToAppendToTask = $infoForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ] ;
}
$txtTaskContent = '' ;
if( array_key_exists( 'GLPI_ITEM_TASK_CONTENT', $infoForTasks ) ) {
$txtTaskContent = $infoForTasks[ 'GLPI_ITEM_TASK_CONTENT' ] ;
}
$groupId = 0 ;
if( array_key_exists( 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED', $infoForTasks ) ) {
$groupId = $infoForTasks[ 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' ] ;
}
$taskStartDate = '' ;
$taskEndDate = '' ;
if( array_key_exists( 'GLPI_ITEM_TASK_ENDDATE', $infoForTasks ) ) {
$taskEndDate = $infoForTasks[ 'GLPI_ITEM_TASK_ENDDATE' ] ;
}
if( array_key_exists( 'GLPI_ITEM_TASK_STARTDATE', $infoForTasks ) ) {
$taskStartDate = $infoForTasks[ 'GLPI_ITEM_TASK_STARTDATE' ] ;
if( $taskEndDate == '' ) {
// at least
$taskEndDate = $taskStartDate ;
}
}
$createFollowup = false ; // by default
if( array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $infoForTasks ) && $infoForTasks[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') {
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_IS_PRIVATE', $infoForTasks )
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID', $infoForTasks )
$createFollowup = true ;
}
// reset those variables
$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , array( "GLPI_ITEM_APPEND_TO_TASK" => '', 'GLPI_ITEM_TASK_CONTENT' => '', 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' => '' ) ) ;
$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , array( "GLPI_ITEM_APPEND_TO_TASK" => '',
"GLPI_ITEM_TASK_CONTENT" => '',
"GLPI_NEXT_GROUP_TO_BE_ASSIGNED" => '',
"GLPI_TICKET_FOLLOWUP_CONTENT" => '',
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE" => '',
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" => '',
"GLPI_ITEM_TASK_ENDDATE" => '',
"GLPI_ITEM_TASK_STARTDATE" => '',
'GLPI_ITEM_TITLE' => '',
"GLPI_ITEM_SET_STATUS" => ''
) ) ;
// print_r( $pmRouteCaseResponse ) ;
// die() ;
@@ -49,13 +99,31 @@ if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUE
// switch own task to 'done' and create a new one
$myProcessMaker->solveTask( $myCase->getID(), $_REQUEST['DEL_INDEX'], $txtToAppendToTask ) ;
// create a followup if requested
if( $createFollowup && $itemType == 'Ticket' ) {
$myProcessMaker->addTicketFollowup( $itemId, $infoForTasks ) ;
}
$caseInfo = $myProcessMaker->getCaseInfo( $myCase->getID(), $_REQUEST['DEL_INDEX']) ;
if( property_exists( $pmRouteCaseResponse, 'routing' ) ) {
foreach( $pmRouteCaseResponse->routing as $route ) {
$myProcessMaker->addTask( $itemType, $itemId, $caseInfo, $route->delIndex, PluginProcessmakerProcessmaker::getGLPIUserId( $route->userId ), $groupId, $route->taskId, $txtTaskContent ) ;
$myProcessMaker->addTask( $itemType, $itemId, $caseInfo, $route->delIndex, PluginProcessmakerUser::getGLPIUserId( $route->userId ), $groupId, $route->taskId, $txtTaskContent, $taskStartDate, $taskEndDate ) ;
// if end date was specicied, then must change due date of the PM task
if( $taskEndDate != '' ) {
$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$caseInfo->caseId."' AND DEL_INDEX=".$route->delIndex);
}
}
}
if( $txtItemTitle != '') {
// we are going to change the title of current GLPI Item
$item = new $itemType ;
$item->getFromDB( $itemId ) ;
$item->update( array('id' => $itemId, 'name' => $txtItemTitle) ) ;
}
if( $itemSetStatus != '' ) {
$myProcessMaker->setItemStatus($itemType, $itemId, $itemSetStatus ) ;
}
// evolution of case status: DRAFT, TO_DO, COMPLETED, CANCELLED
$myCase->update( array( 'id' => $myCase->getID(), 'case_status' => $caseInfo->caseStatus ) ) ;
@@ -65,7 +133,7 @@ if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUE
// Claim task management
elseif( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ){
// here we are in a Claim request
$myCase = new PluginProcessmakerCases ;
$myCase = new PluginProcessmakerCase ;
if( $myCase->getFromDB( $_REQUEST['form']['APP_UID'] ) ) {
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login( ) ;
@@ -80,7 +148,6 @@ elseif( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) &&
// now redirect to item form page
//Html::redirect( Toolbox::getItemTypeFormURL($myCase->getField('itemtype')));
echo "<html><body><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
echo "<html><body><script></script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
?>

View File

@@ -2,22 +2,25 @@
/**
*/
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT . "/inc/includes.php");
include ( "../../../inc/includes.php");
// No autoload when plugin is not activated
require_once('../inc/config.class.php');
//require_once('../inc/config.class.php');
$config = new PluginProcessmakerConfig();
if (isset($_POST["update"])) {
$config->check($_POST['id'],'w');
$config->check($_POST['id'], UPDATE);
// save
$config->update($_POST);
Html::back();
} elseif (isset($_POST["refresh"])) {
$config->refresh($_POST); // used to refresh process list, task category list
Html::back();
}
Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=".
urlencode('PluginProcessmakerConfig$1'));

View File

@@ -12,21 +12,22 @@ if (!isset($_REQUEST["id"])) {
$PluginProcess = new PluginProcessmakerProcess();
if (isset($_REQUEST["update"])) {
$PluginProcess->check($_REQUEST['id'], 'w');
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->update($_REQUEST);
Html::back();
} elseif (isset($_REQUEST["refreshtask"])) {
$PluginProcess->check($_REQUEST['id'], 'w');
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->refreshTasks($_REQUEST);
Html::back();
} else {
$PluginProcess->checkGlobal('r');
// $PluginProcess->checkGlobal(READ);
Html::header($LANG['processmaker']['title'][1],$_SERVER["PHP_SELF"],"plugins","processmaker");
$PluginProcess->showForm($_REQUEST["id"]);
$PluginProcess->display($_REQUEST) ;
// $PluginProcess->showForm($_REQUEST["id"]);
Html::footer();
}

View File

@@ -5,10 +5,10 @@ include (GLPI_ROOT."/inc/includes.php");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "plugins", "processmaker");
if (plugin_processmaker_haveRight("process_config","r") || Session::haveRight("config","w")) {
if (Session::haveRight("plugin_processmaker_config",READ) || Session::haveRight("config", UPDATE)) {
$process=new PluginProcessmakerProcess();
if( isset( $_REQUEST['refresh'] ) && plugin_processmaker_haveRight("process_config","w") ) {
if( isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config",UPDATE) ) {
$process->refresh();
Html::back();
}

View File

@@ -1,7 +1,7 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
//define('GLPI_ROOT', '../../..');
include_once ("../../../inc/includes.php");
Session::checkCentralAccess();
@@ -11,7 +11,7 @@ $process = new PluginProcessmakerProcess();
if (isset($_POST["add"])) {
$right->check(-1,'w',$_POST);
$right->check(-1,UPDATE,$_POST);
if ($right->add($_POST)) {
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
@@ -23,7 +23,7 @@ if (isset($_POST["add"])) {
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($right->can($key,'w')) {
if ($right->can($key,UPDATE)) {
$right->delete(array('id' => $key));
}
}

View File

@@ -1,9 +1,7 @@
<?php
if( !defined ('GLPI_ROOT' ) )
define('GLPI_ROOT', '../../..');
include_once (GLPI_ROOT."/inc/includes.php");
include_once '../inc/processmaker.class.php' ;
include_once '../inc/cases.class.php' ;
include_once ("../../../inc/includes.php");
//include_once '../inc/processmaker.class.php' ;
//include_once '../inc/cases.class.php' ;
switch( $_POST["action"] ) {
case 'newcase':
@@ -15,89 +13,21 @@ switch( $_POST["action"] ) {
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login() ; //openSession();
$requesters = PluginProcessmakerProcessmaker::getItemUsers( $_POST['itemtype'], $_POST['id'], 1 ) ; // 1 for requesters
if( !key_exists( 0, $requesters ) ) {
$requesters[0]['glpi_id'] = 0 ;
$requesters[0]['pm_id'] = 0 ;
}
//$technicians = PluginProcessmakerProcessmaker::getItemUsers( $_POST['itemtype'], $_POST['id'], 2 ) ; // 2 for technicians
//if( !key_exists( 0, $technicians ) ) {
// $technicians[0]['glpi_id'] = Session::getLoginUserID() ;
// $technicians[0]['pm_id'] = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) ;
//}
// get item info to retreive title, description and duedate
$locTicket = new $_POST['itemtype'] ; //Ticket();
$locTicket->getFromDB( $_POST['id'] ) ;
if($locTicket->countUsers($locTicket::ASSIGN) == 0
|| !$locTicket->isUser($locTicket::ASSIGN, Session::getLoginUserID()) ){
$locTicket->update( array( 'id' => $_POST['id'], '_itil_assign' => array( '_type' => 'user', 'users_id' => Session::getLoginUserID() ) ) ) ;
}
//$writer = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() );
if( !isset($locTicket->fields['due_date']) || $locTicket->fields['due_date'] == null ) {
$locTicket->fields['due_date'] = "";
}
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_TICKET_ID' => $_POST['id'],
'GLPI_ITEM_TYPE' => $_POST['itemtype'],
'GLPI_TICKET_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'],
'GLPI_TICKET_REQUESTER_PM_ID' => $requesters[0]['pm_id'],
'GLPI_TICKET_TITLE' => $locTicket->fields['name'],
'GLPI_TICKET_DESCRIPTION' => $locTicket->fields['content'],
'GLPI_TICKET_DUE_DATE' => $locTicket->fields['due_date'],
'GLPI_TICKET_URGENCY' => $locTicket->fields['urgency'],
'GLPI_ITEM_IMPACT' => $locTicket->fields['impact'],
'GLPI_ITEM_PRIORITY' => $locTicket->fields['priority'],
'GLPI_TICKET_GLOBAL_VALIDATION' => $locTicket->fields['global_validation'] ,
'GLPI_TICKET_TECHNICIAN_GLPI_ID' => Session::getLoginUserID(), //$technicians[0]['glpi_id'],
'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) //$technicians[0]['pm_id']
) ) ;
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() ) ;
if ($resultCase->status_code == 0){
$caseInfo = $myProcessMaker->getCaseInfo( $resultCase->caseId );
//$query = "UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='".$resultCase->caseId."' AND APP_STATUS='DRAFT'" ;
//$res = $DB->query($query) ;
// save info to DB
$query = "INSERT INTO glpi_plugin_processmaker_cases (items_id, itemtype, id, case_num, case_status, processes_id) VALUES (".$_POST['id'].", '".$_POST['itemtype']."', '".$resultCase->caseId."', ".$resultCase->caseNumber.", '".$caseInfo->caseStatus."', '".$caseInfo->processId."');" ;
$res = $DB->query($query) ;
$myProcessMaker->add1stTask($_POST['itemtype'], $_POST['id'], $caseInfo ) ;
//echo "New case ID: $result->caseId, Case No: $result->caseNumber \n";
Html::back();
}
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";
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
} else
Html::back();
}
else { // the case is created before the ticket (used for user management before ticket creation)
// list of requesters is needed
// so read ticket
//$requesters = array( ) ;
//foreach( $DB->request( $query ) as $dbuser ) {
// $requesters[] = $dbuser['pm_users_id'] ;
//}
//$writer = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() );
//$userGLPI = new User();
//$userGLPI->getFromDB( Session::getLoginUserID() ) ;
//if( $userGLPI->fields['language'] != null )
// $lang = substr( $userGLPI->fields['language'], 0, 2) ;
//else
// $lang = "en" ;
else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login() ; //openSession( $userGLPI->fields['name'], "md5:37d442efb43ebb80ec6f9649b375ab72", $lang) ;
$myProcessMaker->login() ;
//$resultCase = $myProcessMaker->newCaseImpersonate( $_POST['plugin_processmaker_process_id'], $writer) ;
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0 ) ) ;
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, 'GLPI_SELFSERVICE_CREATED' => '1') ) ;
if ($resultCase->status_code == 0){
// case is created
// Must show it...
@@ -106,11 +36,6 @@ switch( $_POST["action"] ) {
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"]);
} else {
//Html::helpHeader($LANG['job'][13], $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
//// case is not created show error message
//echo "Error : ".$resultCase->status_code."</br>" ;
//echo $resultCase->message."</br>" ;
//Html::helpFooter();
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
}
@@ -131,7 +56,7 @@ switch( $_POST["action"] ) {
}
else if( isset( $_POST['reassign'] ) ) {
// here we should re-assign the current task to $_POST['users_id_recipient']
$GLPINewPMUserId = PluginProcessmakerProcessmaker::getPMUserId( $_POST['users_id_recipient'] ) ;
$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] ) ;
if( $_POST['plugin_processmaker_userId'] != $GLPINewPMUserId ) {
$locPM = new PluginProcessmakerProcessmaker() ;
$locPM->login( ) ;
@@ -160,12 +85,12 @@ switch( $_POST["action"] ) {
}
else if( isset($_POST['delete']) ) {
// delete case from case table, this will also delete the tasks
$locCase = new PluginProcessmakerCases ;
$locCase = new PluginProcessmakerCase ;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
if( $locCase->deleteCase() ) {
// request delete from pm itself
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login() ;
$myProcessMaker->login(true) ;
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
if( $resultPM->status_code == 0 ) {
@@ -181,7 +106,7 @@ switch( $_POST["action"] ) {
$myProcessMaker->login() ;
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ) ; //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
if( $resultPM->status_code === 0 ) {
$locCase = new PluginProcessmakerCases ;
$locCase = new PluginProcessmakerCase ;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
if( $locCase->cancelCase() )
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
@@ -198,4 +123,3 @@ switch( $_POST["action"] ) {
// to return to ticket
Html::back();
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +0,0 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
Session::checkRight("profile", "r");
$prof = new PluginProcessmakerProfile();
//Save profile
if (isset ($_POST['update_user_profile'])) {
$prof->update($_POST);
Html::back();
}
?>

View File

@@ -5,15 +5,12 @@
// Purpose of file:
// ----------------------------------------------------------------------
if( !defined('GLPI_ROOT' ) ) {
define('GLPI_ROOT', '../../..');
}
include_once (GLPI_ROOT . "/inc/includes.php");
include( "../../../inc/includes.php");
if (empty($_POST["_type"])
|| ($_POST["_type"] != "Helpdesk")
|| !$CFG_GLPI["use_anonymous_helpdesk"]) {
Session::checkRight("create_ticket", "1");
Session::checkRight("ticket", CREATE);
}
// Security check
@@ -23,7 +20,7 @@ if (empty($_POST) || count($_POST) == 0) {
// here we are going to test if we must start a process
if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
&& isset($_POST["type"]) && $_POST["type"] == Ticket::DEMAND_TYPE
&& isset($_POST["type"]) //&& $_POST["type"] == Ticket::DEMAND_TYPE
&& isset($_POST["itilcategories_id"])
&& isset($_POST["entities_id"])) {
// here we have to check if there is an existing process in the entity and with the category
@@ -83,22 +80,70 @@ if( !function_exists('http_formdata_flat_hierarchy') ) {
}
}
if( !function_exists('tmpdir') ) {
/**
* Summary of tmpdir
* Will attempts $attempts to create a random temp dir in $path
* see: http://php.net/manual/en/function.mkdir.php
* @param string $path: dir into the temp subdir will be created
* @param string $prefix: used to prefix the random number for dir name
* @param int $attempts: is the quantity of attempts trying to create tempdir
* @return bool|string: false if $attempts has been reached, otherwise the path to the newly created dir
*/
function tmpdir($path, $prefix='', $attempts=3){
$count = 1 ;
do {
$rand=$prefix.rand() ;
} while( !mkdir($path.'/'.$rand) && $count++ < $attempts ) ;
return ($count < $attempts ? $path.'/'.$rand : false ) ;
}
}
// by default loads standard page from GLPI
//include (GLPI_ROOT . "/front/tracking.injector.php");
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']);
curl_setopt($ch, CURLOPT_REFERER, "http://localhost".$CFG_GLPI["root_doc"]."/front/tracking.injector.php" ) ;
// why not [HTTP_REFERER] "http://fry07689-glpi090.fr.ray.group/front/helpdesk.public.php?create_ticket=1" string
curl_setopt($ch, CURLOPT_REFERER, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php" ) ;
curl_setopt($ch, CURLOPT_POST, 1);
$data = http_formdata_flat_hierarchy( $_REQUEST ) ;
// CSRF management
if( GLPI_USE_CSRF_CHECK ) {
// must set a csrf token
$data['_glpi_csrf_token'] = Session::getNewCSRFToken() ;
}
// need to add files if some are uploaded
$files = array() ;
$paths = array() ;
if( isset( $_FILES['filename']['name'] ) && is_array($_FILES['filename']['name']) && count($_FILES['filename']['name']) > 0) {
foreach( $_FILES['filename']['name'] as $num => $file ){
if( $file <> '' ){
$path = str_replace( '\\', '/', $_FILES['filename']['tmp_name'][$num] ) ;
$path = explode('/', $path);
array_pop( $path ) ;
$path = tmpdir(implode( '/', $path ), 'php_tmp') ;
if( $path !== false ) {
$paths[$num] = $path;
$files[$num] = $paths[$num].'/'.$file;
copy( $_FILES['filename']['tmp_name'][$num], $files[$num] ) ;
$data['filename['.$num.']']='@'.$files[$num] ;
}
}
}
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
//curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
curl_setopt($ch, CURLOPT_URL, "http://localhost".$CFG_GLPI["root_doc"]."/front/tracking.injector.php");
curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php");
// as sessions in PHP are not re-entrant, we MUST close current one before curl_exec
@session_write_close() ;
@@ -107,3 +152,11 @@ curl_exec ($ch);
curl_close ($ch);
// need to delete temp files
foreach( $files as $file ) {
unlink( $file ) ;
}
foreach( $paths as $path ) {
rmdir( $path ) ;
}

577
hook.php
View File

@@ -3,35 +3,20 @@
include_once 'inc/processmaker.class.php' ;
//function plugin_planning_populate_processmaker($param) {
// if ( !isset($param['begin']) || !isset($param['who']) ) {
// return $param;
// }
// if( isset($param['items'] ) ) {
// foreach( $param['items'] as $key => &$val) {
// $item=false;
// if( isset( $val['tickettasks_id'] ) )
// $item = new TicketTask ;
// if( $item ) {
// $item->getFromDB( $val['id'] ) ;
// PluginProcessmakerProcessmaker::canedit_item_processmakertickettask( $item ) ;
// $val['content']=$item->fields['content'];
// }
// }
// }
// return $param;
//}
function plugin_processmaker_MassiveActions($type) {
global $LANG;
switch ($type) {
case 'PluginProcessmakerProcess' :
if( plugin_processmaker_haveRight('process_config', 'w' ) )
return array('plugin_processmaker_taskrefresh' => 'Synchronize Task List');
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 ) )
return array('purge' => $LANG['processmaker']['process']['profile']);
break ;
}
return array();
}
@@ -58,7 +43,7 @@ function plugin_processmaker_MassiveActionsDisplay($options) {
function plugin_processmaker_MassiveActionsProcess($data) {
global $LANG,$DB;
//global $LANG,$DB;
switch ($data['action']) {
@@ -67,13 +52,24 @@ function plugin_processmaker_MassiveActionsProcess($data) {
foreach ($data["item"] as $key => $val) {
if ($val == 1) {
$process = new PluginProcessmakerProcess;
//$process->getFromDB($key);
$process->refreshTasks( array( 'id' => $key ) ) ;
}
}
}
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;
}
}
@@ -94,46 +90,80 @@ function plugin_processmaker_install() {
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
}
else
if (!TableExists("glpi_plugin_processmaker_configs")) {
$query = " CREATE TABLE `glpi_plugin_processmaker_configs` (
if (!TableExists("glpi_plugin_processmaker_configs")) {
$query = " CREATE TABLE `glpi_plugin_processmaker_configs` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`pm_server_URL` VARCHAR(250) NOT NULL DEFAULT 'http://localhost/',
`pm_workspace` VARCHAR(50) NOT NULL DEFAULT 'workflow',
`pm_theme` VARCHAR(50) NOT NULL DEFAULT 'classic',
`pm_admin_user` VARCHAR(255) NULL DEFAULT NULL,
`pm_admin_passwd` VARCHAR(255) NULL DEFAULT NULL,
`pm_theme` VARCHAR(50) NOT NULL DEFAULT 'glpi_classic',
`date_mod` DATETIME NULL DEFAULT NULL,
`taskcategories_id` INT(11) NULL ,
`users_id` INT(11) NULL DEFAULT NULL,
`pm_group_guid` VARCHAR(32) NULL DEFAULT NULL,
`comment` TEXT NULL,
PRIMARY KEY (`id`)
`pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL,
`pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL,
`pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL,
`maintenance` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
";
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
// ProcessMaker user creation
$user = new User;
$user->add( array( 'name' => 'ProcessMaker', 'realname' => 'Process', 'firstname' => 'Maker') ) ;
// ProcessMaker user creation
//$user = new User;
//$user->add( array( 'name' => 'ProcessMaker', 'realname' => 'Process', 'firstname' => 'Maker') ) ;
// ProcessMaker plugin configuration
$DB->query("INSERT INTO glpi_plugin_processmaker_configs ( id, name, users_id) VALUES ( 1, 'Process Maker 1', ".$user->getID()." );" ) or die("error when inserting default config" . $DB->error());
}
//// ProcessMaker plugin configuration
//$DB->query("INSERT INTO glpi_plugin_processmaker_configs ( id, name, users_id) VALUES ( 1, 'Process Maker 1', ".$user->getID()." );" ) or die("error when inserting default config" . $DB->error());
}
if (!TableExists("glpi_plugin_processmaker_profiles")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_profiles` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`profiles_id` INT(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_profiles (id)',
`process_config` CHAR(1) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
PRIMARY KEY (`id`),
INDEX `profiles_id` (`profiles_id`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB;" ;
$DB->query($query) or die("error creating glpi_plugin_processmaker_profiles" . $DB->error());
}
if( !FieldExists("glpi_plugin_processmaker_configs","pm_dbserver_name" ) ) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_group_guid`,
ADD COLUMN `pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_name`,
ADD COLUMN `pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_user`;";
$DB->query($query) or die("error adding fields pm_dbserver_name, pm_dbserver_user, pm_dbserver_passwd to glpi_plugin_processmaker_configs" . $DB->error());
}
if( !FieldExists("glpi_plugin_processmaker_configs","maintenance" ) ) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `pm_dbserver_passwd`;
;";
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
}
if( !FieldExists("glpi_plugin_processmaker_configs","pm_admin_user" ) ) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_admin_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_workspace`,
ADD COLUMN `pm_admin_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_admin_user`;
";
$DB->query($query) or die("error adding fields pm_admin_user and pm_admin_passwd to glpi_plugin_processmaker_configs" . $DB->error());
}
//if (!TableExists("glpi_plugin_processmaker_profiles")) {
// $query = "CREATE TABLE `glpi_plugin_processmaker_profiles` (
// `id` INT(11) NOT NULL AUTO_INCREMENT,
// `profiles_id` INT(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_profiles (id)',
// `process_config` CHAR(1) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
// PRIMARY KEY (`id`),
// INDEX `profiles_id` (`profiles_id`)
// )
// COLLATE='utf8_unicode_ci'
// ENGINE=InnoDB;" ;
// $DB->query($query) or die("error creating glpi_plugin_processmaker_profiles" . $DB->error());
//}
if (TableExists("glpi_plugin_processmaker_profiles")) {
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;" ;
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
}
if (!TableExists("glpi_plugin_processmaker_cases")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_cases` (
@@ -142,6 +172,7 @@ function plugin_processmaker_install() {
`itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket',
`case_num` INT(11) NOT NULL,
`case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT',
`processes_id` INT(11) NULL DEFAULT NULL
UNIQUE INDEX `items` (`itemtype`, `items_id`),
INDEX `case_status` (`case_status`)
)
@@ -152,6 +183,29 @@ function plugin_processmaker_install() {
$DB->query($query) or die("error creating glpi_plugin_processmaker_cases" . $DB->error());
}
if(!FieldExists("glpi_plugin_processmaker_cases", "processes_id")){
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
ADD COLUMN `processes_id` INT(11) NULL DEFAULT NULL;
";
$DB->query($query) or die("error adding column processes_id into glpi_plugin_processmaker_cases" . $DB->error());
} else {
$flds = $DB::list_fields('glpi_plugin_processmaker_cases') ;
if( strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0 ) {
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/process.class.php");
include_once(GLPI_ROOT."/plugins/processmaker/inc/case.class.php");
$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'] ) ;
$case->update(array( 'id' => $row['id'], 'processes_id' => $proc->getID() ) ) ;
}
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
CHANGE COLUMN `processes_id` `processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`;
" ;
$DB->query($query) or die("error converting column processes_id into INT(11) in glpi_plugin_processmaker_cases" . $DB->error());
}
}
if (!TableExists("glpi_plugin_processmaker_tasks")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_tasks` (
@@ -174,9 +228,10 @@ function plugin_processmaker_install() {
if (!TableExists("glpi_plugin_processmaker_users")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_users` (
`glpi_users_id` INT(11) NOT NULL ,
`id` INT(11) NOT NULL AUTO_INCREMENT,
`pm_users_id` VARCHAR(32) NOT NULL ,
UNIQUE INDEX `glpi_users_id` (`glpi_users_id`),
`password` VARCHAR(32) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `pm_users_id` (`pm_users_id`)
)
COLLATE='utf8_general_ci'
@@ -186,6 +241,36 @@ function plugin_processmaker_install() {
$DB->query($query) or die("error creating glpi_plugin_processmaker_users" . $DB->error());
}
if( !FieldExists('glpi_plugin_processmaker_users', 'password') ) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
ADD COLUMN `password` VARCHAR(32) NULL DEFAULT NULL AFTER `pm_users_id`,
ADD PRIMARY KEY (`id`);
" ;
$DB->query($query) or die("error adding column 'password' to glpi_plugin_processmaker_users" . $DB->error());
// also need to change text of tasks for tasks linked to cases
$query = "UPDATE glpi_tickettasks SET content=REPLACE(content,'##_PluginProcessmakerCases\$processmakercases','##_PluginProcessmakerCase\$processmakercases')
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'" ;
$DB->query($query) or die("error updating TicketTask" . $DB->error());
}
if( FieldExists('glpi_plugin_processmaker_users', 'glpi_users_id') ) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ALTER `glpi_users_id` DROP DEFAULT,
DROP PRIMARY KEY,
DROP COLUMN `id`,
DROP INDEX `glpi_users_id`;
";
$DB->query($query) or die("error droping 'defaults' from 'glpi_users_id' to glpi_plugin_processmaker_users" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
CHANGE COLUMN `glpi_users_id` `id` INT(11) NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error renaming 'glpi_users_id' into 'id' to glpi_plugin_processmaker_users" . $DB->error());
}
if (!TableExists("glpi_plugin_processmaker_processes")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_processes` (
@@ -200,6 +285,7 @@ function plugin_processmaker_install() {
`itilcategories_id` INT(11) NOT NULL DEFAULT '0',
`type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets',
`date_mod` DATETIME NULL DEFAULT NULL,
`project_type` VARCHAR(50) NOT NULL DEFAULT 'classic',
PRIMARY KEY (`id`),
UNIQUE INDEX `process_guid` (`process_guid`)
)
@@ -224,6 +310,12 @@ function plugin_processmaker_install() {
$DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if( !FieldExists( 'glpi_plugin_processmaker_processes', 'project_type') ) { // since version 3.0
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';" ;
$DB->query($query) or die("error adding columns 'project_type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!TableExists("glpi_plugin_processmaker_processes_profiles")) { // since version 2.2
$query = "CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
@@ -268,335 +360,71 @@ function plugin_processmaker_install() {
}
// create default TaskCategory if needed
// verify if taskcategory_id is set in config
// required cause autoload don't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/config.class.php");
$config = new PluginProcessmakerConfig ;
$config->getFromDB( 1 ) ;
$pmCategory = $config->fields['taskcategories_id'] ;
if( !$pmCategory ) {
// add main category into config and glpi_taskcategories
$taskCat = new TaskCategory;
$pmCategory = $taskCat->add( array( 'is_recursive' => 1, 'name' => 'Process Maker', 'comment' => 'Is top category for Process Maker tasks. Name can be changed if desired.' ) ) ;
if( $pmCategory )
$config->update( array( 'id' => $config->getID(), 'taskcategories_id' => $pmCategory ) ) ;
}
//// create default TaskCategory if needed
//// verify if taskcategory_id is set in config
//// required cause autoload don't work for unactive plugin'
//include_once(GLPI_ROOT."/plugins/processmaker/inc/config.class.php");
//$config = new PluginProcessmakerConfig ;
//$config->getFromDB( 1 ) ;
//$pmCategory = $config->fields['taskcategories_id'] ;
//if( !$pmCategory ) {
// // add main category into config and glpi_taskcategories
// $taskCat = new TaskCategory;
// $pmCategory = $taskCat->add( array( 'is_recursive' => 1, 'name' => 'Process Maker', 'comment' => 'Is top category for Process Maker tasks. Name can be changed if desired.' ) ) ;
// if( $pmCategory )
// $config->update( array( 'id' => $config->getID(), 'taskcategories_id' => $pmCategory ) ) ;
//}
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login(true) ; // to force admin login
// no longer used since 2.6
//$myProcessMaker = new PluginProcessmakerProcessmaker() ;
//$myProcessMaker->login(true) ; // to force admin login
// verify if group 'GLPI Requesters' exists in config, if not will create it in PM and add GUID in config
$pmGroup = $config->fields['pm_group_guid'] ;
if( !$pmGroup ) {
$pmres = $myProcessMaker->createGroup( "GLPI Requesters" ) ;
if( $pmres->status_code == 0 )
$config->update( array( 'id' => $config->getID(), 'pm_group_guid' => $pmres->groupUID ) ) ;
}
//// verify if group 'GLPI Requesters' exists in config, if not will create it in PM and add GUID in config
//$pmGroup = $config->fields['pm_group_guid'] ;
//if( !$pmGroup ) {
// $pmres = $myProcessMaker->createGroup( "GLPI Users" ) ;
// if( $pmres->status_code == 0 )
// $config->update( array( 'id' => $config->getID(), 'pm_group_guid' => $pmres->groupUID ) ) ;
//}
// To be called for each task managed by the plugin
// task in class
CronTask::Register('PluginProcessmakerProcessmaker', 'pmusers', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
//CronTask::Register('PluginProcessmakerProcessmaker', 'pmnotifications', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
CronTask::Register('PluginProcessmakerProcessmaker', 'pmorphancases', DAY_TIMESTAMP, array('param' => 10, 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
// required cause autoload doesn't work for unactive plugin'
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php");
PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
// since version 3.0
// needs to update rights values
// 'r' -> READ
// 'w' -> UPDATE
////////////////////////////////////////////////////////////////////////////////////////////////////
// to migrate rights!!!!
// TODO
//$query = "UPDATE glpi_plugin_processmaker_profiles SET process_config=".READ." WHERE process_config='r';" ;
//$DB->query($query) or die("error updating profiles" . $DB->error());
//$query = "UPDATE glpi_plugin_processmaker_profiles SET process_config=".UPDATE." WHERE process_config='w';" ;
//$DB->query($query) or die("error updating profiles" . $DB->error());
return true;
}
function plugin_processmaker_uninstall() {
global $DB;
// Current version tables
//if (TableExists("glpi_plugin_processmaker_ticketcase")) {
// $query = "DROP TABLE `glpi_plugin_processmaker_ticketcase`";
// $DB->query($query) or die("error deleting glpi_plugin_processmaker_ticketcase");
//}
CronTask::Unregister('PluginProcessmakerProcessmaker');
//if (TableExists("glpi_plugin_processmaker_processes")) {
// $query = "DROP TABLE `glpi_plugin_processmaker_processes`";
// $DB->query($query) or die("error deleting glpi_plugin_processmaker_processes");
//}
// now uninstall triggers from PM tables
//$DB->close();
//$DB->dbdefault='wf_workflow';
//$DB->connect( ) ;
//$DB->runFile(GLPI_ROOT.'/plugins/processmaker/config/pm_db_uninstall.sql') or die("error creating triggers on wf_workflow database!" . $DB->error());
//$DB->close();
//$DB->dbdefault='glpi';
//$DB->connect( ) ;
//
return true;
}
//// Define headings added by the plugin
//function plugin_get_headings_processmaker($item, $withtemplate) {
// global $LANG ;
// switch (get_class($item)) {
// case 'Ticket' :
// return array(1 => $LANG['processmaker']['ticket']['tab']);
// //case 'Profile' :
// // $prof = new Profile();
// // if ($item->fields['interface'] == 'central') {
// // return array(1 => "Test PLugin");
// // }
// // return array();
// //case 'Computer' :
// // // new object / template case
// // if ($withtemplate) {
// // return array();
// // // Non template case / editing an existing object
// // }
// // return array(1 => "Test PLugin");
// //case 'ComputerDisk' :
// //case 'Supplier' :
// // if ($item->getField('id')) { // Not in create mode
// // return array(1 => "Test PLugin",
// // 2 => "Test PLugin 2");
// // }
// // break;
// //case 'Central' :
// //case 'Preference':
// //case 'Notification':
// // return array(1 => "Test PLugin");
// }
// return false;
//}
//// Define headings actions added by the plugin
//function plugin_headings_actions_processmaker($item) {
// switch (get_class($item)) {
// //case 'Profile' :
// //case 'Computer' :
// // return array(1 => "plugin_headings_processmaker");
// //case 'ComputerDisk' :
// //case 'Supplier' :
// // return array(1 => "plugin_headings_processmaker",
// // 2 => "plugin_headings_processmaker");
// //case 'Central' :
// //case 'Preference' :
// //case 'Notification' :
// case 'Ticket' :
// return array(1 => "plugin_headings_processmaker");
// }
// return false;
//}
//// Example of an action heading
//function plugin_headings_processmaker($item, $withtemplate=0) {
// global $LANG, $DB, $GLOBALS ;
// if (!$withtemplate) {
// echo "<div class='center'>";
// switch (get_class($item)) {
// //case 'Central' :
// // echo "Plugin central action ".$LANG['plugin_processmaker']["test"];
// // break;
// //case 'Preference' :
// // // Complete form display
// // $data = plugin_version_processmaker();
// // echo "<form action='Where to post form'>";
// // echo "<table class='tab_cadre_fixe'>";
// // echo "<tr><th colspan='3'>".$data['name']." - ".$data['version'];
// // echo "</th></tr>";
// // echo "<tr class='tab_bg_1'><td>Name of the pref</td>";
// // echo "<td>Input to set the pref</td>";
// // echo "<td><input class='submit' type='submit' name='submit' value='submit'></td>";
// // echo "</tr>";
// // echo "</table>";
// // echo "</form>";
// // break;
// //case 'Notification' :
// // echo "Plugin mailing action ".$LANG['plugin_processmaker']["test"];
// // break;
// case 'Ticket' :
// //echo "Show the iframe";
// $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']['ticket']['tab']."</th></tr>";
// //$userGLPI = new User();
// //$userGLPI->getFromDB( Session::getLoginUserID() ) ;
// //if( $userGLPI->fields['language'] != null )
// // $lang = substr( $userGLPI->fields['language'], 0, 2) ;
// //else
// // $lang = "en" ;
// $myProcessMaker = new PluginProcessmakerProcessmaker( ) ;
// $myProcessMaker->login(); //openSession( $userGLPI->fields['name'], "md5:37d442efb43ebb80ec6f9649b375ab72", $lang ) ;
// // first search for the case
// $ticket_id = $item->getField('id') ;
// $caseInfo = $myProcessMaker->getCaseFromItem( "Ticket", $ticket_id ) ;
// if( $caseInfo !== false ){
// // need to get info on the thread of the GLPI current user
// // we must retreive currentGLPI user from this array
// $GLPICurrentPMUserId = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) ; //$userGLPI->fields['id'] ) ;
// $pmCaseUser = $caseInfo->currentUsers[0] ; // by default
// foreach( $caseInfo->currentUsers as $caseUser) {
// if( $caseUser->userId == $GLPICurrentPMUserId ){
// $pmCaseUser = $caseUser ;
// break ;
// }
// }
// if( $pmCaseUser->delThreadStatus == 'PAUSE' ) {
// // means the case itself may not be PAUSED, but task assigned to current GLPI user is paused...
// // then forced PAUSE view for this thread
// // and give possibility to unpause it
// $caseInfo->caseStatus = 'PAUSED' ;
// }
// switch ( $caseInfo->caseStatus ) {
// case "CANCELLED" :
// echo "<tr><th colspan='2'>".$LANG['processmaker']['ticket']['cancelledcase']."</th></tr>";
// $paramsURL = "DEL_INDEX=1" ;
// break;
// case 'PAUSED' :
// // we need to add a button to unpause the case
// echo "<input type='hidden' name='action' value='unpausecase'>";
// echo "<input type='hidden' name='id' value='".$ticket_id."'>";
// echo "<input type='hidden' name='itemtype' value='".$item->gettype()."'>";
// echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
// echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
// echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
// echo "<tr><th>".$LANG['processmaker']['ticket']['pausedtask']."</th><th>";
// echo "<input type='submit' name='unpausecase' value='".$LANG['processmaker']['ticket']['unpause']."' class='submit'>";
// echo "</th></tr>";
// case "DRAFT" :
// case "TO_DO" :
// $paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
// break ;
// case "COMPLETED" :
// echo "<tr><th colspan='2'>".$LANG['processmaker']['ticket']['completedcase']."</th></tr>";
// $paramsURL = "DEL_INDEX=1" ;
// break ;
// }
// echo "<tr class='tab_bg_2' ><td colspan=2>" ;
// echo "<script>
// //var bLoads = 0 ;
// function reloadParent( locParent ) {
// if( locParent.location == locParent.parent.location )
// locParent.location.reload( ) ;
// else
// reloadParent( locParent.parent ) ;
// }
// var oldHandler ;
// var oldParent ;
// var submitButton ;
// function onClickContinue( obj ) {
// // call old handler
// if( obj != undefined )
// oldHandler(obj.target);
// reloadParent( oldParent ) ;
// }
// function onLoadFrame() {
// //debug();
// var caseTimerCounter = 0 ;
// var caseTimer = window.setInterval(function() {
// //debug() ;
// var contentDocument = document.getElementById('caseiframe').contentDocument.getElementById('openCaseFrame').contentDocument ;
// var cancelButton = contentDocument.getElementById('form[BTN_CANCEL]') ;
// var formDerivation = contentDocument.getElementById('frmDerivation') ;
// var buttonContinue = contentDocument.getElementById('btnContinue') ;
// if(cancelButton != undefined) {
// window.clearInterval(caseTimer) ;
// cancelButton.style.visibility='hidden';
// // TODO manage 'Claim' button
// } elseif( formDerivation != undefined && buttonContinue != undefined ) {
// window.clearInterval(caseTimer) ;
// buttonContinue.form.action = '' ;
// oldHandler = buttonContinue.onclick ;
// buttonContinue.onclick = onClickContinue ;
// oldParent = document ;
// } else
// caseTimerCounter = caseTimerCounter + 1 ;
// if( caseTimerCounter > 3000 ) {
// window.clearInterval(caseTimer) ;
// }
// }, 10) ;
// //alert( bLoads ) ;
// //if( bLoads >= 1 )
// // means something has been done in the iFrame of ProcessMaker, then we may reload the complete page in order to
// // 1) prevent view of the casesListExtJs
// // 2) refresh the view of the case with the open form
// // reloadParent( parent ) ;
// //else bLoads = bLoads + 1 ;
// }
// </script>";
// echo "<iframe onload='onLoadFrame();' id='caseiframe' height=1080 width=100% src='".$myProcessMaker->serverURL."/cases/open?sid=".$_SESSION["pluginprocessmaker"]["Session"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."' >" ;
// echo "</iframe>";
// echo "</td></tr>";
// } else {
// // no running case for this ticket
// // propose to start one
// echo "<tr><th colspan='2'>".$LANG['processmaker']['ticket']['nocase'] ;
// // check if ticket is not solved nor closed
// if( $item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' ) {
// // propose case start
// echo "&nbsp;-&nbsp;".$LANG['processmaker']['ticket']['startone'];
// echo "</th></tr>";
// echo "<tr class='tab_bg_2'><td class='right' colspan='1'>";
// echo $LANG['processmaker']['ticket']['selectprocess']."&nbsp;";
// echo "<input type='hidden' name='action' value='newcase'>";
// echo "<input type='hidden' name='id' value='".$item->getField('id')."'>";
// echo "<input type='hidden' name='itemtype' value='".$item->gettype()."'>";
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'name' => 'plugin_processmaker_process_id', 'condition' => "trigger_guid != ''")); // condition is used to prevent start of cases without trigger
// echo "</td><td class='center'>";
// echo "<input type='submit' name='additem' value='".$LANG['processmaker']['ticket']['start']."' class='submit'>";
// echo "</td></tr>";
// }
// else echo "</th></tr>";
// }
// echo "</table>";
// echo "</form>";
// break;
// default :
// echo "Plugin function with headings CLASS=".get_class($item)." id=".$item->getField('id');
// break;
// }
// echo "</div>";
// }
//}
function plugin_processmaker_getAddSearchOptions($itemtype) {
global $LANG;
@@ -662,7 +490,7 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
global $DB ;
if( isset($_SESSION['glpiname']) && $parm->getType() == 'Ticket' ) {
$locCase = new PluginProcessmakerCases ;
$locCase = new PluginProcessmakerCase ;
$itemId = $parm->getID() ;
$itemType = $parm->getType() ;
@@ -672,7 +500,7 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
$locPM->login() ;
// case is existing for this item
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
// $technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
// beware to empty injection when not modified!!!
$locVar = array( ) ;
@@ -681,6 +509,9 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
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 ;
break;
@@ -709,23 +540,11 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
function plugin_item_update_processmaker_satisfaction($parm) {
global $DB, $GLOBALS ;
$locCase = new PluginProcessmakerCases ;
$locCase = new PluginProcessmakerCase ;
if( $locCase->getCaseFromItemTypeAndItemId( 'Ticket', $parm->fields['tickets_id'] ) ) {
// case is existing for this item
//$query = "select * from wf_workflow.application where APP_UID='".$locCase->getID()."';" ;
//$res = $DB->query($query) ;
//$app_data = array() ;
//if( $DB->numrows($res) > 0) {
// $row = $DB->fetch_assoc($res);
// $app_data = unserialize($row['APP_DATA'] ) ;
//}
//$locVars = array( 'GLPI_SATISFACTION_QUALITY' => $parm->fields['satisfaction'],
// 'GLPI_SATISFACTION_RESPONSETIME' => $parm->fields['responsetime'],
// 'GLPI_SATISFACTION_FRIENDLINESS' => $parm->fields['friendliness'] ) ;
$locPM = new PluginProcessmakerProcessmaker ;
$locPM->login() ;
@@ -735,7 +554,6 @@ function plugin_item_update_processmaker_satisfaction($parm) {
'GLPI_SATISFACTION_RESPONSETIME' => $parm->fields['responsetime'],
'GLPI_SATISFACTION_FRIENDLINESS' => $parm->fields['friendliness']
)) ;
//$locCase->sendVariables( $locVars ) ;
}
}
@@ -749,9 +567,8 @@ function plugin_pre_item_purge_processmaker ( $parm ) {
$itemId = $parm->fields['tickets_id'] ;
$itemType = 'Ticket' ;
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
//$locCase = new PluginProcessmakerCases ;
if( PluginProcessmakerCases::getCaseIdFromItemTypeAndItemId( $itemType, $itemId ) && count($technicians) == 1 ) {
if( PluginProcessmakerCase::getCaseIdFromItemTypeAndItemId( $itemType, $itemId ) && count($technicians) == 1 ) {
$parm->input = null ; // to cancel deletion of the last tech in the ticket
}
}
@@ -765,7 +582,7 @@ function plugin_item_purge_processmaker($parm) {
// We just deleted a tech from this ticket then we must if needed "de-assign" the tasks assigned to this tech
// and re-assign them to the first tech in the list !!!!
$locCase = new PluginProcessmakerCases ;
$locCase = new PluginProcessmakerCase ;
$itemId = $parm->fields['tickets_id'] ;
$itemType = 'Ticket' ;
@@ -775,13 +592,8 @@ function plugin_item_purge_processmaker($parm) {
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
$locPM = new PluginProcessmakerProcessmaker ;
$locPM->login() ;
//$pmResponse = $locPM->sendVariables( $locCase->getID(), array(
// 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'],
// 'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id']
// ) ) ;
$locVars = array( 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'],
'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id'] ) ;
//$locCase->sendVariables( $locVars ) ;
// 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() ) ;
@@ -789,7 +601,7 @@ function plugin_item_purge_processmaker($parm) {
$locPM->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 = PluginProcessmakerProcessmaker::getPMUserId( $parm->fields['users_id'] ) ;
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( $parm->fields['users_id'] ) ;
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'] ) ;
@@ -819,4 +631,13 @@ function plugin_item_purge_processmaker($parm) {
}
}
?>
function plugin_processmaker_post_init(){
global $PM_DB ;
$PM_DB = new PluginProcessmakerDB ;
}
function plugin_processmaker_giveItem($itemtype,$ID,$data,$num){
return ;
}

View File

@@ -1,14 +1,674 @@
<?php
/**
* case short summary.
* ticketcase short summary.
*
* case description.
* ticketcase description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCase extends CommonDBTM {
}
?>
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
$item_id = $item->getID() ;
$item_type = $item->getType() ;
if( self::getCaseFromItemTypeAndItemId($item_type, $item_id ) ){
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
} else
return array( 'processmakercases' => $LANG['processmaker']['item']['tab'] );
}
/**
* Summary of getCaseIdFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @return mixed
*/
static function getCaseIdFromItemTypeAndItemId( $itemType, $itemId) {
global $DB;
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';" ;
if( ($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
$row = $DB->fetch_array($res);
return $row['id'] ;
}
return false ;
}
/**
* Summary of getCaseFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @return mixed: returns false when there is no case associated with the item, else fills in the item fields from DB, and returns true
*/
function getCaseFromItemTypeAndItemId($itemType, $itemId) {
if( $caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId) )
return $this->getFromDB( $caseId ) ;
return false ;
}
/**
* Summary of getFromDB
* @param mixed $ID
* @return mixed
*/
function getFromDB($ID) {
global $DB;
// Search for object in database and fills 'fields'
// != 0 because 0 is consider as empty
if (strlen($ID)==0) {
return false;
}
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `".$this->getIndexName()."` = '".$ID."'";
if ( ($result = $DB->query($query)) && $DB->numrows($result)==1) {
$this->fields = $DB->fetch_assoc($result);
$this->post_getFromDB();
return true;
}
return false;
}
/**
* Summary of getVariables
* Gets variables from a case.
* @param array $vars an array of variable name that will be read from the case as case variables
* @return an associative array (variable_name => value). The returned array can be empty if requested variables are not found.
*/
function getVariables( $vars = array() ) {
global $PM_DB ;
$locVars = array( ) ;
$app_data = array() ; // by default
$caseId = $this->getID() ;
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
$row = $PM_DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
$locVars = array_intersect_key( $app_data, array_flip($vars) ) ;
}
return $locVars ;
}
/**
* Summary of sendVariables
* Sends variables to a case.
* BEWARE that this will not work correctly for values containning special chars like \
* instead use the web service function from PluginProcessmakerProcessmaker class
* @param array $vars an array of associative variables (name => value) that will be injected into the case as case variables
* @return true if variables have been saved to the case, false otherwise
*/
function sendVariables( $vars = array() ) {
global $PM_DB ;
$variablesSent = false ; // be default
$app_data = array() ; // by default
$caseId = $this->getID() ;
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
$row = $PM_DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
}
$app_data = array_replace( $app_data, $vars ) ;
$serialized = serialize( $app_data ) ;
$query = "UPDATE application SET APP_DATA='$serialized' WHERE APP_UID='$caseId';" ;
$res = $PM_DB->query( $query ) ;
if( $PM_DB->affected_rows() == 1 ) {
$variablesSent = true ;
}
return $variablesSent ;
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $item
* @param mixed $tabnum
* @param mixed $withtemplate
* @return mixed
*/
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG, $DB, $CFG_GLPI ;
$config = PluginProcessmakerConfig::getInstance() ;
if( $config->fields['maintenance'] == 0 ) {
$item_id = $item->getID() ;
$item_type = $item->getType() ;
////retrieve container for current tab
//$container = new self;
//$found_c = $container->find("`itemtype` = '$item_type' AND `items_id` = $item_id ");
//echo "Show the frame";
$rand = rand();
echo "<form style='margin-bottom: 0px' name='processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo "<div class='center'> <table id='processmakercasemenu' style='margin-bottom: 0px' class='tab_cadre_fixe'>";
echo Html::scriptBlock("$('#processmakercasemenu').css('max-width', 'none');") ;
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['tab']."</th></tr>";
$pmCaseUser = false ; // initial value: no user
// first search for the case
if( self::getCaseIdFromItemTypeAndItemId($item_type, $item_id ) ){
$myProcessMaker = new PluginProcessmakerProcessmaker( ) ;
$myProcessMaker->login();
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id ) ;
if( $caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED' ) {
// need to get info on the thread of the GLPI current user
// we must retreive currentGLPI user from this array
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ) ;
$pmCaseUser = $caseInfo->currentUsers[0] ; // by default currently manage only one task at a time, must define tab management for several tasks
foreach( $caseInfo->currentUsers as $caseUser) {
if( $caseUser->userId == $GLPICurrentPMUserId ){
$pmCaseUser = $caseUser ;
break ;
}
}
//if( $pmCaseUser->delThreadStatus == 'PAUSE' ) {
// // means the case itself may not be PAUSED, but task assigned to current GLPI user is paused...
// // then forced PAUSE view for this thread
// // and give possibility to unpause it
// $caseInfo->caseStatus = 'PAUSED' ;
//}
}
$locDelIndex = 1 ; // by default
switch ( $caseInfo->caseStatus ) {
case "CANCELLED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['cancelledcase']."</th></tr>";
$paramsURL = "DEL_INDEX=1" ;
// echo "<tr class='tab_bg_1' ><td id='GLPI-PM-DEL_INDEX' ><script>var GLPI_DEL_INDEX = 1; </script></td></tr>" ;
break;
//case 'PAUSED' :
// // we need to add a button to unpause the case
// //echo "<input type='hidden' name='id' value='$item_id'>";
// //echo "<input type='hidden' name='itemtype' value='$item_type'>";
// //echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
// //echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
// //echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
// echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['pausedtask']."</th><th>";
// echo "<input type='submit' name='unpausecase' value='".$LANG['processmaker']['item']['unpause']."' class='submit'>";
// echo "</th></tr>";
case "DRAFT" :
case "TO_DO" :
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
$locDelIndex = $pmCaseUser->delIndex ;
if( $pmCaseUser->userId != '' ) {
echo "<tr class='tab_bg_1'>" ;
if( $GLPICurrentPMUserId == $pmCaseUser->userId) {
// then propose a button to cancel case only when assigned user is == to glpi current user
echo "<td class='tab_bg_2' >";
echo $LANG['processmaker']['item']['cancelcase'] ;
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
//echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
//echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttoncancelcaseconfirmation']."\") ; cancelMyMask = !ret ; return ret;' type='submit' name='cancel' value='".$LANG['processmaker']['item']['buttoncancelcase']."' class='submit'>";
echo "</td>";
}
if( $caseInfo->caseStatus == "DRAFT" || (plugin_processmaker_haveRight("deletecase", DELETE) && $_SESSION['glpiactiveprofile']['interface'] == 'central') ) {
// then propose a button to delete case
echo "<td class='tab_bg_2'>";
echo $LANG['processmaker']['item']['deletecase'] ;
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttondeletecaseconfirmation']."\"); cancelMyMask = !ret ; return ret;' type='submit' name='delete' value='".$LANG['processmaker']['item']['buttondeletecase']."' class='submit' >";
echo "</td>";
}
//echo "<td class='tab_bg_2' colspan='1'>";
echo "</form>";
echo "</td></tr>";
}
break ;
case "COMPLETED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
$paramsURL = "DEL_INDEX=" ; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
break ;
}
$proj = new PluginProcessmakerProcess ;
$proj->getFromDBbyExternalID( $caseInfo->processId ) ;
$project_type = $proj->fields['project_type'] ;
// then propose a button to view case history
echo "<tr class='tab_bg_1' >" ;
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseChangeLogHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasechangeloghistory']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>" ; //?rand=$rand'
// processmakertabpaneltable is used to align the tabs
echo "<table id=processmakertabpaneltable style='margin-bottom: 0px; width:100%;' class='tab_cadre_fixe'>";
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');") ;
echo "<tr><td>" ;
//
// Processmaker tab panels
// need to have a global variable which contains tab id
// used only one time for activated panel
$arrayProcessmakerTabPanel = array() ;
echo "<div id=processmakertabpanel >";
// first define tabs
echo " <ul>";
//echo " <li><a href='#tabs-1'>Nunc tincidunt</a></li>";
$arrayProcessmakerTabPanel[] = "tabs-1";
if( $pmCaseUser ) {
foreach($caseInfo->currentUsers as $caseUser) {
echo "<li><a href='#task-".$caseUser->delIndex."'>".($caseUser->userId != $GLPICurrentPMUserId?"<i><sub>".$LANG['processmaker']['item']['task']['task'].$caseUser->taskName."</sub></i>":$LANG['processmaker']['item']['task']['task'].$caseUser->taskName)."</a></li>";
$arrayProcessmakerTabPanel[] = "task-".$caseUser->delIndex;
}
} else {
// no user means CANCELLED or COMPLETED
// then create artificial panel to host case infos
echo "<li><a href='#caseInfo'>".$LANG['processmaker']['item']['case']['caseinfo']."</a></li>";
$arrayProcessmakerTabPanel[] = "caseInfo";
}
echo "</ul>";
// second define panels
//echo "<div id='tabs-1'>
// <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
// </div>";
if( $pmCaseUser ) {
$csrf = Session::getNewCSRFToken() ;
foreach($caseInfo->currentUsers as $caseUser) {
// for each task, if task is to be claimed, we need to verify that current user can claim it by checking if he/she is in the group assigned to the task
$hide_claim_button=false; // by default
if( !$caseUser->userId ) {
// current task is to claimed
// get task user list
$query = "SELECT items_id, itemtype FROM glpi_plugin_processmaker_tasks WHERE case_id = '".$caseInfo->caseId."' AND del_index =".$caseUser->delIndex;
foreach( $DB->request($query) as $row ) {
// normally there is only one task
$task = getItemForItemtype( $row['itemtype'] ) ;
$task->getFromDB( $row['items_id'] ) ;
$user = new User; // pseudo-group
$user->getFromDB( $task->fields['users_id_tech'] ) ;
// check if this pseudo-group can be found in the current user's groups
foreach($DB->request("SELECT id FROM ".getTableForItemType( 'Group' )." WHERE name = '".$user->fields['name']."'") as $grp ){
// normally there is only one record
if( isset($_SESSION['glpigroups']) && !in_array( $grp['id'], $_SESSION['glpigroups'] ) ) {
$hide_claim_button=true;
}
}
}
}
echo "<div id='task-".$caseUser->delIndex."'>";
// to load users for task re-assign only when task is not to be 'claimed'
if( $caseUser->userId ) {
echo "<div class='tab_bg_2' id='divUsers-".$caseUser->delIndex."' >Loading...</div>";
echo "<script>$('#divUsers-".$caseUser->delIndex."').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand' ); </script>" ;
}
echo "<iframe id='caseiframe-task-".$caseUser->delIndex."' onload='onTaskFrameLoad( event, ".$caseUser->delIndex.", ".($hide_claim_button?"true":"false").", \"$csrf\" );' style='border:none;' class='tab_bg_2' width='100%' src='";
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO" ;
//if( $caseUser->userId == $GLPICurrentPMUserId || $caseUser->userId == '' ) {
echo $url ;
//} else {
// echo $CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_resume.php?username=".urlencode( $caseUser->userName )."&taskname=".urlencode( $caseUser->taskName )."&url=".urlencode( $url ) ;
//}
echo "&rand=$rand'></iframe></div>";
}
} else {
// no user means CANCELLED or COMPLETED
// then create artificial panel to host case infos
echo "<div id='caseInfo'>";
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO" ;
echo "<iframe id=\"caseiframe-caseInfo\" onload=\"onOtherFrameLoad( 'caseInfo', 'caseiframe-caseInfo', 'body' );\" style=\"border:none;\" class=\"tab_bg_2\" width=\"100%\" src=\"$url&rand=$rand\"></iframe></div>";
}
echo "</div>" ;
// end of tabs/panels
echo "</td></tr>";
echo "<tr class='tab_bg_1' ><td colspan=4 >" ;
if( $pmCaseUser ) {
$activePanel = 'task-'.$pmCaseUser->delIndex ;
} else {
$activePanel = 'caseInfo' ;
}
$caseMapUrl = $myProcessMaker->serverURL.($project_type=='bpmn' ? "/designer?prj_uid=".$caseInfo->processId."&prj_readonly=true&app_uid=".$caseInfo->caseId : "/cases/ajaxListener?action=processMap&rand=$rand") ;
echo "<script>
function addTabPanel( name, title, html ){
//debugger ;
if( !$('#processmakertabpanel')[0].children[name] ) { // panel is not yet existing, create one
//var num_tabs = $('#processmakertabpanel ul li').length ;
$('#processmakertabpanel ul').append( '<li><a href=\'#' + name + '\'>' + title + '</a></li>' );
//debugger ;
$('#processmakertabpanel').append( '<div id=\'' + name + '\'>' + html + '</div>');
$('#processmakertabpanel').tabs('refresh'); // to show the panel
}
var tabIndex = $('#processmakertabpanel a[href=\"#'+name+'\"]').parent().index();
$('#processmakertabpanel').tabs( 'option', 'active', tabIndex) ; // to activate it
//$('#processmakertabpanel').tabs( 'option', 'collapsible', true );
}
var historyGridListChangeLogGlobal = { viewIdHistory: '', viewIdDin: '', viewDynaformName: '', idHistory: '' } ;
var ActionTabFrameGlobal = { tabData: '', tabName: '', tabTitle: '' } ;
var Actions = { tabFrame: function( actionToDo ) {
// debugger ;
if( actionToDo == 'caseMap' ) {
addTabPanel( actionToDo,
'".$LANG['processmaker']['item']['case']['casemap']."',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", ".($project_type=='bpmn' ? 1 : 0 )." );\' width=\'100%\' src=\'$caseMapUrl\' ></iframe>'
);
} else
if( actionToDo == 'caseHistory' ) {
addTabPanel( actionToDo,
'".$LANG['processmaker']['item']['case']['casehistory']."',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' height=\'600px\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/ajaxListener?action=caseHistory&rand=$rand\' ></iframe>'
);
} else
if( actionToDo == 'caseChangeLogHistory' ) {
addTabPanel( actionToDo,
'".$LANG['processmaker']['item']['case']['casechangeloghistory']."',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' height=\'600px\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/ajaxListener?action=changeLogHistory&rand=$rand\' ></iframe>'
);
} else
if( actionToDo == 'dynaformViewFromHistory' ) {
actionToDo = 'dynaformChangeLogViewHistory_' + historyGridListChangeLogGlobal.viewIdDin + historyGridListChangeLogGlobal.dynDate.replace(/ /g, '_').replace(/:/g, '-') ;
ajaxResponse = $.parseJSON(historyGridListChangeLogGlobal.viewDynaformName);
addTabPanel( actionToDo,
ajaxResponse.dynTitle + ' <sup>(' + historyGridListChangeLogGlobal.dynDate + ')</sup>',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/ajaxListener?action=dynaformViewFromHistory&DYN_UID=' + historyGridListChangeLogGlobal.viewIdDin + \"&HISTORY_ID=\" + historyGridListChangeLogGlobal.viewIdHistory + '&rand=$rand\' ></iframe>'
);
} else
if( actionToDo == 'historyDynaformPage' ) {
addTabPanel( actionToDo,
'".$LANG['processmaker']['item']['case']['dynaforms']."',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand\' ></iframe>'
);
} else
if( actionToDo.search( '^changeLog' ) == 0 ) {
actionToDo = 'changeLog' ;
addTabPanel( actionToDo,
'".$LANG['processmaker']['item']['case']['changelog']."',
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' height=\'600px\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/ajaxListener?action=changeLogTab&idHistory=' + historyGridListChangeLogGlobal.idHistory + '&rand=$rand\' ></iframe>'
);
} else
if( actionToDo.search( '^historyDynaformGridPreview' ) == 0 ) {
actionToDo = actionToDo.replace('_', '$') ;
var act = actionToDo.replace( '$', '&DYN_UID=') ;
addTabPanel( actionToDo,
ActionTabFrameGlobal.tabTitle,
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"form\", 0 );\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand\' ></iframe>'
);
} else
if( actionToDo.search( '^historyDynaformGridHistory' ) == 0) {
var ajaxResponse = $.parseJSON(ActionTabFrameGlobal.tabData);
var act = 'showDynaformListHistory&PRO_UID=' + ajaxResponse.PRO_UID + '&APP_UID=' + ajaxResponse.APP_UID + '&TAS_UID=-1&DYN_UID=' + ajaxResponse.DYN_UID;
addTabPanel( actionToDo,
ActionTabFrameGlobal.tabTitle,
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"body\", 0 );\' height=\'600px\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand\' ></iframe>'
);
} else
if( actionToDo.search( '^dynaformChangeLogViewHistory' ) == 0) {
var ajaxResponse = $.parseJSON(ActionTabFrameGlobal.tabData);
actionToDo='dynaformChangeLogViewHistory' + ajaxResponse.dynUID + ajaxResponse.dynDate ;
//actionToDo = actionToDo.replace(' ', '_').replace(':', '-');
var act = 'dynaformChangeLogViewHistory&DYN_UID=' + ajaxResponse.dynUID + '&HISTORY_ID=' + ajaxResponse.tablename;
addTabPanel( actionToDo,
ActionTabFrameGlobal.tabTitle,
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"form\", 0 );\' width=\'100%\' src=\'".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand\' ></iframe>'
);
}
}
} ;
$(function() {
//debugger;
$('#processmakertabpanel').tabs( {active: ".array_search( $activePanel, $arrayProcessmakerTabPanel )."});
//$('#processmakertabpanel').scrollabletabs();
//$('#processmakertabpanel').position({
// my: 'left top',
// at: 'left top',
// of: '#processmakertabpaneltable'
//});
$('#processmakertabpanel').removeClass( 'ui-tabs' ) ;
//debugger ;
$('#processmakertabpanel').tabs({activate: function (event, ui) {
try {
//debugger;
if( typeof onOtherFrameLoad == 'function' )
var newPanel = ui.newPanel.selector.replace('#', '') ;
var panelType = newPanel.split( '-' )[ 0 ].split( '$' )[ 0 ].split( '_' ) ;
var searchTag = '' ;
switch( panelType[0] ) {
case 'task' :
searchTag = 'table' ;
break ;
case 'historyDynaformGridPreview' :
case 'dynaformChangeLogViewHistory' :
searchTag = 'form' ;
break ;
case 'caseInfo' :
case 'caseMap' :
case 'caseHistory' :
case 'changeLog' :
case 'historyDynaformPage' :
case 'dynaformChangeLogViewHistory' :
case 'historyDynaformGridHistory' :
default :
searchTag = 'body' ;
break ;
}
onOtherFrameLoad( newPanel, 'caseiframe-' + newPanel, searchTag ) ;
} catch( evt ) {
//debugger;
}
}
});
" ;
echo "});
";
echo "</script>";
//////echo "<iframe id='caseiframe' onload='onGLPILoadFrame( event ) ;' height='1080px' style='border:none;' width='100%' src='".$myProcessMaker->serverURL."/cases/open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand' >" ;
//////echo "</iframe>";
echo "</td></tr>";
} else {
//********************************
// no running case for this ticket
// propose to start one
//********************************
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'] ;
// check if item is not solved nor closed
if( $item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk' ) {
// propose case start
echo "&nbsp;-&nbsp;".$LANG['processmaker']['item']['startone'];
echo "</th></tr>";
echo "<tr class='tab_bg_2'><td class='tab_bg_2' colspan='1'>";
echo $LANG['processmaker']['item']['selectprocess']."&nbsp;";
echo "<input type='hidden' name='action' value='newcase'>";
echo "<input type='hidden' name='id' value='$item_id'>";
echo "<input type='hidden' name='itemtype' value='$item_type'>";
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1")); // condition is used to prevent start of none-active cases
PluginProcessmakerProcess::dropdown(array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1"));
echo "</td><td class='tab_bg_2'>";
echo "<input type='submit' name='additem' value='".$LANG['processmaker']['item']['start']."' class='submit'>";
echo "</td></tr>";
}
else echo "</th></tr>";
}
echo "</table>";
Html::closeForm(true ) ;
//echo "</form>";
} else {
// under maintenance
echo $LANG['processmaker']['config']['undermaintenance'];
}
return true ;
}
/**
* Summary of deleteTasks
* will delete all tasks associated with this case from the item
* @return true if tasks have been deleted from associated item and from case table
*/
private function deleteTasks( ) {
global $DB ;
$ret = false ;
$query = "DELETE from glpi_".$this->fields['itemtype']."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
if( $DB->query( $query ) )
$ret = true ;
}
return $ret ;
}
/**
* Summary of deleteCase
* will delete case and all tasks associated with this case from the item
* @return true if case and tasks have been deleted from associated item and from case table
*/
function deleteCase( ) {
global $DB ;
$ret = false ;
if( $this->deleteTasks() )
if( $this->deleteFromDB( ) )
$ret = true ;
return $ret ;
}
/**
* Summary of cancelTasks
* will mark as information all to_do tasks
* BEWARE that this will only be done when case is in TO_DO status
* @return true if tasks have been deleted from associated item and from case table
*/
private function cancelTasks( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" ) {
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
$ret = true ;
}
}
return $ret ;
}
/**
* Summary of cancelCase
* will cancel case and mark 'to_do' tasks associated with this case from the item as information
* BEWARE that this will only be done when case is in TO_DO status
* @return true if case and tasks have been cancelled or marked from associated item and from case table
*/
function cancelCase( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" )
if( $this->cancelTasks() )
if( $this->update( array( 'id' => $this->getID(), 'case_status' => 'CANCELLED' ) ) )
$ret=true;
return $ret ;
}
/**
* Summary of canSolve
* To know if a Ticket (Problem or Change) can be solved
* i.e. the case permits solving of item
* @param mixed $parm
* @return bool
*/
public static function canSolve ($parm) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) ) ;
if( $myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1) ) {
// then item can't be solved
return false ;
}
}
return true ;
}
/**
* Summary of getToDoTasks
* @param mixed $parm is a Ticket, a Problem or a Change
* @return array list of tasks with status 'to do' for case associated with item
*/
public static function getToDoTasks($parm) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
return PluginProcessmakerTask::getToDoTasks( $myCase->getID(), $parm->getType()."Task" ) ;
}
return array();
}
}

View File

@@ -1,713 +0,0 @@
<?php
/**
* ticketcase short summary.
*
* ticketcase description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCases extends CommonDBTM {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
$item_id = $item->getID() ;
$item_type = $item->getType() ;
if( self::getCaseFromItemTypeAndItemId($item_type, $item_id ) ){
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
} else
return array( 'processmakercases' => $LANG['processmaker']['item']['tab'] );
}
/**
* Summary of getCaseIdFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @return mixed
*/
static function getCaseIdFromItemTypeAndItemId( $itemType, $itemId) {
global $DB;
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';" ;
if( ($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
$row = $DB->fetch_array($res);
return $row['id'] ;
}
return false ;
}
/**
* Summary of getCaseFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @return mixed: returns false when there is no case associated with the item, else fills in the item fields from DB, and returns true
*/
function getCaseFromItemTypeAndItemId($itemType, $itemId) {
if( $caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId) )
return $this->getFromDB( $caseId ) ;
return false ;
}
/**
* Summary of getFromDB
* @param mixed $ID
* @return mixed
*/
function getFromDB($ID) {
global $DB;
// Search for object in database and fills 'fields'
// != 0 because 0 is consider as empty
if (strlen($ID)==0) {
return false;
}
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `".$this->getIndexName()."` = '".$ID."'";
if ( ($result = $DB->query($query)) && $DB->numrows($result)==1) {
$this->fields = $DB->fetch_assoc($result);
$this->post_getFromDB();
return true;
}
return false;
}
/**
* Summary of getVariables
* Gets variables from a case.
* @param array $vars an array of variable name that will be read from the case as case variables
* @return an associative array (variable_name => value). The returned array can be empty if requested variables are not found.
*/
function getVariables( $vars = array() ) {
global $DB ;
$locVars = array( ) ;
$app_data = array() ; // by default
$caseId = $this->getID() ;
$query = "select APP_DATA from wf_workflow.application where APP_UID='$caseId';" ;
if( ($res = $DB->query($query)) && $DB->numrows($res) > 0) {
$row = $DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
$locVars = array_intersect_key( $app_data, array_flip($vars) ) ;
}
return $locVars ;
}
/**
* Summary of sendVariables
* Sends variables to a case.
* BEWARE that this will not work correctly for values containning special chars like \
* instead use the web service function from PluginProcessmakerProcessmaker class
* @param array $vars an array of associative variables (name => value) that will be injected into the case as case variables
* @return true if variables have been saved to the case, false otherwise
*/
function sendVariables( $vars = array() ) {
global $DB ;
$variablesSent = false ; // be default
$app_data = array() ; // by default
$caseId = $this->getID() ;
$query = "select APP_DATA from wf_workflow.application where APP_UID='$caseId';" ;
if( ($res = $DB->query($query)) && $DB->numrows($res) > 0) {
$row = $DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
}
$app_data = array_replace( $app_data, $vars ) ;
$serialized = serialize( $app_data ) ;
$query = "update wf_workflow.application set APP_DATA='$serialized' where APP_UID='$caseId';" ;
$res = $DB->query( $query ) ;
if( $DB->affected_rows() == 1 ) {
$variablesSent = true ;
}
return $variablesSent ;
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $item
* @param mixed $tabnum
* @param mixed $withtemplate
* @return mixed
*/
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG, $DB;
$item_id = $item->getID() ;
$item_type = $item->getType() ;
////retrieve container for current tab
//$container = new self;
//$found_c = $container->find("`itemtype` = '$item_type' AND `items_id` = $item_id ");
//echo "Show the frame";
$rand = rand();
echo "<form style='margin-bottom: 0px' name='processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo "<div class='center'><table style='margin-bottom: 0px' class='tab_cadre_fixehov'>";
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['tab']."</th></tr>";
$pmCaseUser = false ; // initial value: no user
// first search for the case
if( self::getCaseIdFromItemTypeAndItemId($item_type, $item_id ) ){
$myProcessMaker = new PluginProcessmakerProcessmaker( ) ;
$myProcessMaker->login();
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id ) ;
if( $caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED' ) {
// need to get info on the thread of the GLPI current user
// we must retreive currentGLPI user from this array
$GLPICurrentPMUserId = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) ;
$pmCaseUser = $caseInfo->currentUsers[0] ; // by default currently manage only one task at a time, must define tab management for several tasks
foreach( $caseInfo->currentUsers as $caseUser) {
if( $caseUser->userId == $GLPICurrentPMUserId ){
$pmCaseUser = $caseUser ;
break ;
}
}
//if( $pmCaseUser->delThreadStatus == 'PAUSE' ) {
// // means the case itself may not be PAUSED, but task assigned to current GLPI user is paused...
// // then forced PAUSE view for this thread
// // and give possibility to unpause it
// $caseInfo->caseStatus = 'PAUSED' ;
//}
}
$locDelIndex = 1 ; // by default
switch ( $caseInfo->caseStatus ) {
case "CANCELLED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['cancelledcase']."</th></tr>";
$paramsURL = "DEL_INDEX=1" ;
// echo "<tr class='tab_bg_1' ><td id='GLPI-PM-DEL_INDEX' ><script>var GLPI_DEL_INDEX = 1; </script></td></tr>" ;
break;
//case 'PAUSED' :
// // we need to add a button to unpause the case
// //echo "<input type='hidden' name='id' value='$item_id'>";
// //echo "<input type='hidden' name='itemtype' value='$item_type'>";
// //echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
// //echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
// //echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
// echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['pausedtask']."</th><th>";
// echo "<input type='submit' name='unpausecase' value='".$LANG['processmaker']['item']['unpause']."' class='submit'>";
// echo "</th></tr>";
case "DRAFT" :
case "TO_DO" :
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
$locDelIndex = $pmCaseUser->delIndex ;
if( $pmCaseUser->userId != '' ) {
echo "<tr class='tab_bg_1'>" ;
if( $caseInfo->caseStatus == "DRAFT" ) {
// then propose a button to delete case
echo "<td class='tab_bg_2'>";
echo $LANG['processmaker']['item']['deletecase'] ;
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttondeletecaseconfirmation']."\"); cancelMyMask = !ret ; return ret;' type='submit' name='delete' value='".$LANG['processmaker']['item']['buttondeletecase']."' class='submit' >";
echo "</td>";
} elseif( $GLPICurrentPMUserId == $pmCaseUser->userId) {
// then propose a button to cancel case only when assigned user is == to glpi current user
echo "<td class='tab_bg_2' >";
echo $LANG['processmaker']['item']['cancelcase'] ;
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
//echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
//echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttoncancelcaseconfirmation']."\") ; cancelMyMask = !ret ; return ret;' type='submit' name='cancel' value='".$LANG['processmaker']['item']['buttoncancelcase']."' class='submit'>";
echo "</td>";
}
echo "<td class='tab_bg_2' colspan='1'>";
echo "</form>";
echo "</td></tr>";
}
break ;
case "COMPLETED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
$paramsURL = "DEL_INDEX=" ; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
break ;
}
// then propose a button to view case history
echo "<tr class='tab_bg_1' >" ;
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='button' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='button' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='button' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1' ><td class='tab_bg_2' colspan=4>" ;
echo "<div id=processmakertabpanel></div>" ;
echo "</td></tr>";
echo "<tr class='tab_bg_1' ><td class='tab_bg_2' colspan=4 >" ;
echo "<script type='text/javascript' src='".GLPI_ROOT."/plugins/processmaker/js/cases.js'></script>" ; //?rand=$rand'
echo "<script>
var historyGridListChangeLogGlobal = { viewIdHistory: '', viewIdDin: '', viewDynaformName: '', idHistory: '' } ;
var ActionTabFrameGlobal = { tabData: '', tabName: '', tabTitle: '' } ;
var Actions = { tabFrame: function( actionToDo ) {
if( actionToDo == 'caseMap' ) {
if( !tabs.items.containsKey( 'caseMap' ) ) {
tabs.add( {
title: '".$LANG['processmaker']['item']['case']['casemap']."',
id: 'caseMap',
closable: true,
listeners: { activate: function () {
// debugger ;
onOtherFrameLoad( 'caseMap', 'caseMapFrame', 'body' ) ;
}
},
html: \"<iframe id='caseMapFrame' \" +
\"style='border:none;' \" +
\"onload='onOtherFrameLoad( \\\"caseMap\\\", \\\"caseMapFrame\\\", \\\"body\\\" );' \" +
\"width='100%' \" +
\"src='".$myProcessMaker->serverURL."/cases/ajaxListener?action=processMap&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( 'caseMap' ) ;
}
else
if( actionToDo == 'caseHistory' ) {
if( !tabs.items.containsKey( 'caseHistory' ) ) {
tabs.add( {
title: '".$LANG['processmaker']['item']['case']['casehistory']."',
id: 'caseHistory',
closable: true,
listeners: { activate: function () {
//debugger ;
onOtherFrameLoad( 'caseHistory', 'caseHistoryFrame', 'body' ) ;
}
},
html: \"<iframe id='caseHistoryFrame' \" +
\"height='500px' \" +
\"style='border:none;' \" +
\"onload='onOtherFrameLoad( \\\"caseHistory\\\", \\\"caseHistoryFrame\\\", \\\"body\\\" );' \" +
\"width='100%' \" +
\"src='".$myProcessMaker->serverURL."/cases/ajaxListener?action=caseHistory&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( 'caseHistory' ) ;
}
else
if( actionToDo == 'dynaformViewFromHistory' ) {
//debugger;
actionToDo = 'dynaformChangeLogViewHistory' + historyGridListChangeLogGlobal.viewIdDin + historyGridListChangeLogGlobal.dynDate ;
if( !tabs.items.containsKey( actionToDo ) ) {
ajaxResponse = Ext.util.JSON.decode(historyGridListChangeLogGlobal.viewDynaformName);
tabs.add( {
title: ajaxResponse.dynTitle + ' <sup>(' + historyGridListChangeLogGlobal.dynDate + ')</sup>',
id: actionToDo,
closable: true,
listeners: { activate: function () {
// debugger ;
onOtherFrameLoad( actionToDo, actionToDo+'Frame', 'body' ) ;
}
},
html: \"<iframe id='\"+actionToDo+\"Frame' \" +
\"style='border:none;' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"\"+actionToDo+\"\\\", \\\"\"+actionToDo+\"Frame\\\", \\\"body\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/ajaxListener?action=dynaformViewFromHistory&DYN_UID=\" + historyGridListChangeLogGlobal.viewIdDin + \"&HISTORY_ID=\" + historyGridListChangeLogGlobal.viewIdHistory + \"&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( actionToDo ) ;
}
else
if( actionToDo == 'historyDynaformPage' ) {
if( !tabs.items.containsKey( 'historyDynaformPage' ) ) {
tabs.add( {
title: '".$LANG['processmaker']['item']['case']['dynaforms']."',
id: 'historyDynaformPage',
closable: true,
listeners: { activate: function () {
//debugger ;
onOtherFrameLoad( 'historyDynaformPage', 'historyDynaformPageFrame', 'body' ) ;
}
},
html: \"<iframe id='historyDynaformPageFrame' \" +
\"onload='onOtherFrameLoad( \\\"\"+actionToDo+\"\\\", \\\"\"+actionToDo+\"Frame\\\", \\\"body\\\" );' \" +
\"style='border:none;' \" +
\"width='100%' \" +
\"src='".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( 'historyDynaformPage' ) ;
}
else
if( actionToDo.search( '^changeLog' ) == 0 ) {
if( !tabs.items.containsKey( 'changeLog' ) ) {
tabs.add( {
title: '".$LANG['processmaker']['item']['case']['changelog']."',
id: 'changeLog',
closable: true,
listeners: { activate: function () {
//debugger ;
onOtherFrameLoad( 'changeLog', 'changeLogFrame', 'body' ) ;
}
}, html: \"<iframe id='changeLogFrame' \" +
\"style='border:none;' \" +
\"height='500px' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"changeLog\\\", \\\"changeLogFrame\\\", \\\"body\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/ajaxListener?action=changeLogTab&idHistory=\" + historyGridListChangeLogGlobal.idHistory + \"&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( 'changeLog' ) ;
}
else
if( actionToDo.search( '^historyDynaformGridPreview' ) == 0 ) {
actionToDo = actionToDo.replace('_', '$') ;
if( !tabs.items.containsKey( actionToDo ) ) {
var act = actionToDo.replace( '$', '&DYN_UID=') ;
tabs.add( {
title: ActionTabFrameGlobal.tabTitle,
id: actionToDo,
closable: true,
listeners: { activate: function () {
// debugger ;
onOtherFrameLoad( actionToDo, actionToDo+'Frame', 'form' ) ;
}
},
html: \"<iframe id='\"+actionToDo+\"Frame' \" +
\"style='border:none;' \" +
\"height='500px' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"\"+actionToDo+\"\\\", \\\"\"+actionToDo+\"Frame\\\", \\\"form\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=\" + act + \"&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( actionToDo ) ;
}
else
if( actionToDo.search( '^historyDynaformGridHistory' ) == 0) {
if( !tabs.items.containsKey( actionToDo ) ) {
var ajaxResponse = Ext.util.JSON.decode(ActionTabFrameGlobal.tabData);
var act = 'showDynaformListHistory&PRO_UID=' + ajaxResponse.PRO_UID + '&APP_UID=' + ajaxResponse.APP_UID + '&TAS_UID=-1&DYN_UID=' + ajaxResponse.DYN_UID;
tabs.add( {
title: ActionTabFrameGlobal.tabTitle,
id: actionToDo,
closable: true,
listeners: { activate: function () {
// debugger ;
onOtherFrameLoad( actionToDo, actionToDo+'Frame', 'body' ) ;
}
},
html: \"<iframe id='\"+actionToDo+\"Frame' \" +
\"style='border:none;' \" +
\"height='500px' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"\"+actionToDo+\"\\\", \\\"\"+actionToDo+\"Frame\\\", \\\"body\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=\" + act + \"&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( actionToDo ) ;
}
else
if( actionToDo.search( '^dynaformChangeLogViewHistory' ) == 0) {
var ajaxResponse = Ext.util.JSON.decode(ActionTabFrameGlobal.tabData);
actionToDo='dynaformChangeLogViewHistory' + ajaxResponse.dynUID + ajaxResponse.dynDate ;
if( !tabs.items.containsKey( actionToDo ) ) {
var act = 'dynaformChangeLogViewHistory&DYN_UID=' + ajaxResponse.dynUID + '&HISTORY_ID=' + ajaxResponse.tablename;
tabs.add( {
title: ajaxResponse.dynTitle + ' <sup>(' + ajaxResponse.dynDate + ')</sup>',
id: actionToDo,
closable: true,
listeners: { activate: function () {
// debugger ;
onOtherFrameLoad( actionToDo, actionToDo+'Frame', 'form' ) ;
}
},
html: \"<iframe id='\"+actionToDo+\"Frame' \" +
\"style='border:none;' \" +
\"height='500px' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"\"+actionToDo+\"\\\", \\\"\"+actionToDo+\"Frame\\\", \\\"form\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=\" + act + \"&rand=$rand' >\" +
\"</iframe>\"
} ) ;
tabs.doLayout( ) ;
}
tabs.setActiveTab( actionToDo ) ;
}
}
} ;
//debugger;
var tabs = new Ext.TabPanel({
renderTo: 'processmakertabpanel',
width: 930,
deferredRender: false,
enableTabScroll: true,
items: [";
if( $pmCaseUser ) {
$first = true ;
foreach($caseInfo->currentUsers as $caseUser) {
if( !$first ) echo "," ;
echo "{
title: ".($caseUser->userId != $GLPICurrentPMUserId?"'<i><sub>Task: ".$caseUser->taskName."</sub></i>'":"'Task: ".$caseUser->taskName."'").",
id: 'task-".$caseUser->delIndex."',
listeners: { activate: function () {
try {
//debugger;
if( typeof onOtherFrameLoad == 'function' )
onOtherFrameLoad( 'task-".$caseUser->delIndex."', 'caseiframe-".$caseUser->delIndex."', 'table' ) ;
// to load users for re-assign only when task is not to be 'claimed'
if( ".($caseUser->userId?"true":"false")." && Ext.get('divUsers-".$caseUser->delIndex."').dom.innerHTML == '' ) {
Ext.get('divUsers-".$caseUser->delIndex."').load({
url : '".GLPI_ROOT."/plugins/processmaker/ajax/task_users.php',
scripts: true,
params: 'caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand',
});
}
} catch( evt ) {
//debugger;
}
}
} ,
html: \"<div class='tab_bg_2' id='divUsers-".$caseUser->delIndex."' >\" +
\"</div>\" +
\"<iframe id='caseiframe-".$caseUser->delIndex."' \" +
\"onload='onTaskFrameLoad( ".$caseUser->delIndex." );' \" +
\"style='border:none;' \" +
\"class='tab_bg_2' \" +
\"width='100%' \" +
\"src='".($caseUser->userId == $GLPICurrentPMUserId || $caseUser->userId == ''?
$myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO"
:
GLPI_ROOT."/plugins/processmaker/ajax/task_resume.php?username=".urlencode( $caseUser->userName )."&taskname=".urlencode( $caseUser->taskName )."&url=".urlencode( $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO" )
)."&rand=$rand'>\" +
\"</iframe>\"
}";
$first = false ;
}
} else {
// no user means CANCELLED or COMPLETED
// then create artificial panel to host case infos
echo "{
title: '".$LANG['processmaker']['item']['case']['caseinfo']."',
id: 'caseInfo',
listeners: { activate: function () {
// debugger ;
if( typeof onOtherFrameLoad == 'function' )
onOtherFrameLoad( 'caseInfo', 'caseInfoFrame', 'body' ) ;
}
},
html: \"<iframe \" +
\"id='caseInfoFrame' \" +
\"style='border:none;' \" +
\"width='100%' \" +
\"onload='onOtherFrameLoad( \\\"caseInfo\\\", \\\"caseInfoFrame\\\", \\\"body\\\" );' \" +
\"src='".$myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO&rand=$rand'>\" +
\"</iframe>\"
}";
}
echo " ]
});";
if( $pmCaseUser )
echo " tabs.setActiveTab( 'task-".$pmCaseUser->delIndex."') ;" ;
else
echo " tabs.setActiveTab( 'caseInfo') ;" ;
echo "</script>";
//////echo "<iframe id='caseiframe' onload='onGLPILoadFrame( event ) ;' height='1080px' style='border:none;' width='100%' src='".$myProcessMaker->serverURL."/cases/open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand' >" ;
//////echo "</iframe>";
echo "</td></tr>";
} else {
// no running case for this ticket
// propose to start one
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'] ;
// check if item is not solved nor closed
if( $item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk' ) {
// propose case start
echo "&nbsp;-&nbsp;".$LANG['processmaker']['item']['startone'];
echo "</th></tr>";
echo "<tr class='tab_bg_2'><td class='tab_bg_2' colspan='1'>";
echo $LANG['processmaker']['item']['selectprocess']."&nbsp;";
echo "<input type='hidden' name='action' value='newcase'>";
echo "<input type='hidden' name='id' value='$item_id'>";
echo "<input type='hidden' name='itemtype' value='$item_type'>";
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1")); // condition is used to prevent start of none-active cases
PluginProcessmakerProcess::dropdown(array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id'));
echo "</td><td class='tab_bg_2'>";
echo "<input type='submit' name='additem' value='".$LANG['processmaker']['item']['start']."' class='submit'>";
echo "</td></tr>";
}
else echo "</th></tr>";
}
echo "</table>";
echo "</form>";
return true ;
}
/**
* Summary of deleteTasks
* will delete all tasks associated with this case from the item
* BEWARE that this will only be done when case is in DRAFT status
* @return true if tasks have been deleted from associated item and from case table
*/
private function deleteTasks( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "DRAFT" ) {
$query = "DELETE from glpi_".$this->fields['itemtype']."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
if( $DB->query( $query ) )
$ret = true ;
}
}
return $ret ;
}
/**
* Summary of deleteCase
* will delete case and all tasks associated with this case from the item
* BEWARE that this will only be done when case is in DRAFT status
* @return true if case and tasks have been deleted from associated item and from case table
*/
function deleteCase( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "DRAFT" ) {
if( $this->deleteTasks() )
if( $this->deleteFromDB( ) )
$ret = true ;
}
return $ret ;
}
/**
* Summary of cancelTasks
* will mark as information all to_do tasks
* BEWARE that this will only be done when case is in TO_DO status
* @return true if tasks have been deleted from associated item and from case table
*/
private function cancelTasks( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" ) {
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
$ret = true ;
}
}
return $ret ;
}
/**
* Summary of cancelCase
* will cancel case and mark 'to_do' tasks associated with this case from the item as information
* BEWARE that this will only be done when case is in TO_DO status
* @return true if case and tasks have been cancelled or marked from associated item and from case table
*/
function cancelCase( ) {
global $DB ;
$ret = false ;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" )
if( $this->cancelTasks() )
if( $this->update( array( 'id' => $this->getID(), 'case_status' => 'CANCELLED' ) ) )
$ret=true;
return $ret ;
}
/**
* Summary of canSolve
* To know if a Ticket (Problem or Change) can be solved
* i.e. the case permits solving of item
* @param mixed $parm
* @return bool
*/
public static function canSolve ($parm) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) ) ;
if( $myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1) ) {
// then item can't be solved
return false ;
}
}
return true ;
}
/**
* Summary of getToDoTasks
* @param mixed $parm is a Ticket, a Problem or a Change
* @return array list of tasks with status 'to do' for case associated with item
*/
public static function getToDoTasks($parm) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
return PluginProcessmakerTasks::getToDoTasks( $myCase->getID(), $parm->getType()."Task" ) ;
}
return array();
}
}

View File

@@ -5,19 +5,24 @@
class PluginProcessmakerConfig extends CommonDBTM {
static private $_instance = NULL;
//static private $db = NULL ;
function canCreate() {
return Session::haveRight('config', 'w');
static function canCreate() {
return Session::haveRight('config', UPDATE);
}
function canView() {
return Session::haveRight('config', 'r');
static function canView() {
return Session::haveRight('config', READ);
}
static function getTypeName() {
static function canUpdate() {
return Session::haveRight('config', UPDATE);
}
static function getTypeName($nb=0) {
global $LANG;
return $LANG['common'][12];
return $LANG['processmaker']['config']['setup'];
}
function getName($with_comment=0) {
@@ -40,82 +45,51 @@ class PluginProcessmakerConfig extends CommonDBTM {
return self::$_instance;
}
//static function install(Migration $mig) {
// global $DB, $LANG;
/**
* Prepare input datas for updating the item
*
* @param $input array used to update the item
*
* @return array the modified $input array
**/
function prepareInputForUpdate($input) {
// $table = 'glpi_plugin_behaviors_configs';
// if (!TableExists($table)) { //not installed
if( !isset($input["maintenance"]) ) {
$input["maintenance"] = 0 ;
}
// $query = "CREATE TABLE `$table` (
// `id` int(11) NOT NULL,
// `use_requester_item_group` tinyint(1) NOT NULL default '0',
// `use_requester_user_group` tinyint(1) NOT NULL default '0',
// `is_ticketsolutiontype_mandatory` tinyint(1) NOT NULL default '0',
// `is_ticketrealtime_mandatory` tinyint(1) NOT NULL default '0',
// `is_requester_mandatory` tinyint(1) NOT NULL default '0',
// `is_ticketdate_locked` tinyint(1) NOT NULL default '0',
// `use_assign_user_group` tinyint(1) NOT NULL default '0',
// `tickets_id_format` VARCHAR(15) NULL,
// `remove_from_ocs` tinyint(1) NOT NULL default '0',
// `add_notif` tinyint(1) NOT NULL default '0',
// `use_lock` tinyint(1) NOT NULL default '0',
// `date_mod` datetime default NULL,
// `comment` text,
// PRIMARY KEY (`id`)
// ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
// $DB->query($query) or die($LANG['update'][90] . "&nbsp;:<br>" . $DB->error());
if (isset($input["pm_dbserver_passwd"])) {
if (empty($input["pm_dbserver_passwd"])) {
unset($input["pm_dbserver_passwd"]);
} else {
$input["pm_dbserver_passwd"] = Toolbox::encrypt(stripslashes($input["pm_dbserver_passwd"]), GLPIKEY);
}
}
// $query = "INSERT INTO `$table` (id, date_mod) VALUES (1, NOW())";
// $DB->query($query) or die($LANG['update'][90] . "&nbsp;:<br>" . $DB->error());
if (isset($input["_blank_pm_dbserver_passwd"]) && $input["_blank_pm_dbserver_passwd"]) {
$input['pm_dbserver_passwd'] = '';
}
// } else {
// // Upgrade
if (isset($input["pm_admin_passwd"])) {
if (empty($input["pm_admin_passwd"])) {
unset($input["pm_admin_passwd"]);
} else {
$input["pm_admin_passwd"] = Toolbox::encrypt(stripslashes($input["pm_admin_passwd"]), GLPIKEY);
}
}
// $mig->addField($table, 'tickets_id_format', 'string');
// $mig->addField($table, 'remove_from_ocs', 'bool');
// $mig->addField($table, 'is_requester_mandatory', 'bool');
// // version 0.78.0 - feature #2801 Forbid change of ticket's creation date
// $mig->addField($table, 'is_ticketdate_locked', 'bool');
// // Version 0.80.0 - set_use_date_on_state now handle in GLPI
// $mig->dropField($table, 'set_use_date_on_state');
// // Version 0.80.4 - feature #3171 additional notifications
// $mig->addField($table, 'add_notif', 'bool');
// // Version 0.83.0 - groups now have is_requester and is_assign attribute
// $mig->dropField($table, 'sql_user_group_filter');
// $mig->dropField($table, 'sql_tech_group_filter');
// // Version 0.83.1 - prevent update on ticket updated by another user
// $mig->addField($table, 'use_lock', 'bool');
// }
// return true;
//}
//static function uninstall() {
// global $DB;
// if (TableExists('glpi_plugin_behaviors_configs')) { //not installed
// $query = "DROP TABLE `glpi_plugin_behaviors_configs`";
// $DB->query($query) or die($DB->error());
// }
// return true;
//}
if (isset($input["_blank_pm_admin_passwd"]) && $input["_blank_pm_admin_passwd"]) {
$input['pm_admin_passwd'] = '';
}
return $input;
}
static function showConfigForm($item) {
global $LANG, $DB;
global $LANG, $PM_DB;
$ui_theme = array(
'classic' => 'classic',
'neoclassic' => 'neoclassic',
'uxmodern' => 'uxmodern' ,
'uxs' => 'uxs'
'glpi_classic' => 'glpi_classic',
'glpi_neoclassic' => 'glpi_neoclassic'
);
$config = self::getInstance();
@@ -123,27 +97,68 @@ class PluginProcessmakerConfig extends CommonDBTM {
$config->showFormHeader();
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['name']."&nbsp;:</td><td>";
echo $config->fields['name'];
echo "</td><td colspan='2' class='center'>".$LANG['processmaker']['config']['comments']."&nbsp;:";
echo "<td >".$LANG['processmaker']['config']['URL']."</td><td >";
echo "<input size='50' type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>" ;
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['URL']."&nbsp;:</td><td>";
echo "<input type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>" ;
echo "</td><td rowspan='5' colspan='2' class='center'>";
echo "<textarea cols='60' rows='8' name='comment' >".$config->fields['comment']."</textarea>";
echo "<br>".$LANG['common'][26]."&nbsp;: ";
echo Html::convDateTime($config->fields["date_mod"]);
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['workspace']."&nbsp;:</td><td>";
echo "<td >".$LANG['processmaker']['config']['workspace']."</td><td >";
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>" ;
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['theme']."&nbsp;:</td><td>";
echo "<td >" . $LANG['processmaker']['config']['admin']['user'] . "</td>";
echo "<td ><input type='text' name='pm_admin_user' value='".$config->fields["pm_admin_user"]."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >" . $LANG['processmaker']['config']['admin']['password'] . "</td>";
echo "<td ><input type='password' name='pm_admin_passwd' value='' autocomplete='off'>";
echo "&nbsp;<input type='checkbox' name='_blank_pm_admin_passwd'>&nbsp;".__('Clear');
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
$pm = new PluginProcessmakerProcessmaker ;
$ret = $pm->login(true);
if( $ret ) {
echo "<font color='green'>".__('Test successful');
} else {
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror,true);
}
echo "</font></span></td></tr>\n";
echo "<tr><td colspan='4' class='center b'>".$LANG['processmaker']['config']['mysql']."</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >" . __('SQL server (MariaDB or MySQL)') . "</td>";
echo "<td ><input type='text' size=50 name='pm_dbserver_name' value='".$config->fields["pm_dbserver_name"]."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >" . __('SQL user') . "</td>";
echo "<td ><input type='text' name='pm_dbserver_user' value='".$config->fields["pm_dbserver_user"]."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >" . __('SQL password') . "</td>";
echo "<td ><input type='password' name='pm_dbserver_passwd' value='' autocomplete='off'>";
echo "&nbsp;<input type='checkbox' name='_blank_pm_dbserver_passwd'>&nbsp;".__('Clear');
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
if( $PM_DB->connected ) {
echo "<font color='green'>".__('Test successful');
} else {
echo "<font color='red'>".__('Test failed');
}
echo "</font></span></td></tr>\n";
echo "<tr><td colspan='4' class='center b'>".__('Settings')."</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['theme']."</td><td >";
Dropdown::showFromArray('pm_theme', $ui_theme,
array('value' => $config->fields['pm_theme']));
echo "</td></tr>";
@@ -151,7 +166,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
$taskCatogrie = new TaskCategory;
$taskCatogrie->getFromDB( $config->fields['taskcategories_id'] ) ;
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['main_task_category']."&nbsp;:</td><td>";
echo "<td >".$LANG['processmaker']['config']['main_task_category']."</td><td >";
echo "<a href='".Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=". $config->fields['taskcategories_id']."'>".str_replace(" ", "&nbsp;", $taskCatogrie->fields['name']);
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$config->fields['taskcategories_id'].")";
@@ -162,7 +177,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
$taskUser = new User;
$taskUser->getFromDB( $config->fields['users_id'] ) ;
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['taskwriter']."&nbsp;:</td><td>";
echo "<td >".$LANG['processmaker']['config']['taskwriter']."</td><td >";
echo "<a href='".Toolbox::getItemTypeFormURL( 'User' )."?id=". $config->fields['users_id']."'>".str_replace(" ", "&nbsp;", $taskUser->getName());
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$config->fields['users_id'].")";
@@ -171,15 +186,38 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['processmaker']['config']['pm_group_name']."&nbsp;:</td><td>";
$query = "SELECT * FROM wf_".$config->fields['pm_workspace'].".content WHERE CON_CATEGORY='GRP_TITLE' and CON_ID='".$config->fields['pm_group_guid']."' ;" ;
echo "<table>";
foreach( $DB->request( $query ) as $row ) {
echo "<tr><td>".$row['CON_LANG']."</td><td>".$row['CON_VALUE']."</td>";
echo "<td >".$LANG['processmaker']['config']['pm_group_name']."</td><td >";
$pmGroups = array( 0 => Dropdown::EMPTY_VALUE ) ;
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM content WHERE CON_CATEGORY='GRP_TITLE' AND CON_LANG='".$pm->lang."' ORDER BY CON_VALUE;" ;
if( $PM_DB->connected ) {
foreach( $PM_DB->request( $query ) as $row ) {
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'] ;
}
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, array('value' => $config->fields['pm_group_guid']) ) ;
} else {
echo "<font color='red'>".__('Not connected');
}
echo "</table>" ;
echo "</td></tr>\n";
//echo "<tr class='tab_bg_1'>";
//echo "<td >".$LANG['processmaker']['config']['comments']."";
//echo "</td><td rowspan='5' >";
//echo "<textarea cols='60' rows='5' name='comment' >".$config->fields['comment']."</textarea>";
//echo "</td></tr>\n";
//echo "<tr></tr>";
//echo "<tr></tr>";
//echo "<tr></tr>";
//echo "<tr></tr>";
echo "<tr><td colspan='4' class='center b'>".__('Maintenance')."</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['maintenance']."</td><td >";
Dropdown::showYesNo("maintenance", $config->fields['maintenance']);
echo "</td></tr>";
$config->showFormButtons(array('candel'=>false));
@@ -205,4 +243,5 @@ class PluginProcessmakerConfig extends CommonDBTM {
return true;
}
}

22
inc/db.class.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
class PluginProcessmakerDB extends DBmysql {
var $dbhost ;
var $dbuser ;
var $dbpassword ;
var $dbdefault ;
function __construct() {
$config = PluginProcessmakerConfig::getInstance() ;
$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 = "wf_".$config->fields['pm_workspace'] ;
parent::__construct();
}
}

View File

@@ -14,13 +14,25 @@ if (!defined('GLPI_ROOT')) {
*/
class PluginProcessmakerProcess extends CommonDBTM {
function canCreate() {
return plugin_processmaker_haveRight('process_config', 'w');
static function getMenuName() {
return 'ProcessMaker';
}
static function canCreate() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function canView() {
return plugin_processmaker_haveRight('process_config', 'r');
static function canView() {
return Session::haveRight('plugin_processmaker_config', READ);
}
static function canUpdate( ) {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function canUpdateItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
@@ -33,14 +45,15 @@ class PluginProcessmakerProcess extends CommonDBTM {
* will refresh (re-synch) all process task list
*/
function refreshTasks( $post ) {
global $DB, $CFG_GLPI ;
global $PM_DB, $CFG_GLPI ;
if( $this->getFromDB( $post['id'] ) ) {
// here we are in the right process
// we need to get the tasks + content from PM db
$config = new PluginProcessmakerConfig ;
$config->getFromDB( 1 ) ;
$database = $config->fields['pm_workspace'] ;
//$config = PluginProcessmakerConfig::getInstance() ;
//$database = $config->fields['pm_workspace'] ;
$translates = false ;
$mapLangs = array( ) ;
if( TableExists( 'glpi_dropdowntranslations' ) && class_exists('DropdownTranslation') ){
// to force rigths to add translations
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name' ;
@@ -51,17 +64,14 @@ class PluginProcessmakerProcess extends CommonDBTM {
foreach( $CFG_GLPI['languages'] as $key => $valArray){
$mapLangs[ locale_get_primary_language( $key ) ][] = $key ;
}
} else {
$translates = false ;
$mapLangs = array( ) ;
}
$lang = $CFG_GLPI['languages'][ $CFG_GLPI['language'] ][ 2 ] ;
$query = "select task.TAS_UID, task.TAS_START, content.CON_LANG, content.CON_CATEGORY, content.CON_VALUE from wf_$database.task
inner join wf_$database.content on content.CON_ID=task.TAS_UID
$lang = locale_get_primary_language( $CFG_GLPI['language'] ) ; // $CFG_GLPI['languages'][ $CFG_GLPI['language'] ][ 3 ] ;
$query = "select task.TAS_UID, task.TAS_START, content.CON_LANG, content.CON_CATEGORY, content.CON_VALUE from task
inner join content on content.CON_ID=task.TAS_UID
where task.PRO_UID = '".$this->fields['process_guid']."' and content.CON_CATEGORY in ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates?"":"and content.CON_LANG='$lang'")." ;" ;
$taskArray = array() ;
$defaultLangTaskArray=array();
foreach( $DB->request( $query ) as $task ) {
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);
@@ -106,14 +116,14 @@ class PluginProcessmakerProcess extends CommonDBTM {
if( DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'name', $langTask ) != $taskL[ 'TAS_TITLE' ] ) {
// must be updated
$trans = new DropdownTranslation ;
$trans->update( array( 'id' => $loc_id, 'field' => 'name', 'value' => $taskL[ 'TAS_TITLE' ], 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) ) ;
$trans->update( array( 'id' => $loc_id, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]), 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) ) ;
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) ) ;
}
} else {
// must be added
// must be updated
$trans = new DropdownTranslation ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'name', 'value' => $taskL[ 'TAS_TITLE' ] ) ) ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]) ) ) ;
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(),'language' => $langTask ) ) ;
}
@@ -122,21 +132,18 @@ class PluginProcessmakerProcess extends CommonDBTM {
if( DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $langTask ) != $taskL[ 'TAS_DESCRIPTION' ] ) {
// must be updated
$trans = new DropdownTranslation ;
$trans->update( array( 'id' => $loc_id, 'field' => 'comment', 'value' => $taskL[ 'TAS_DESCRIPTION' ] , 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask) ) ;
$trans->update( array( 'id' => $loc_id, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) , 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask) ) ;
}
} else {
// must be added
$trans = new DropdownTranslation ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'comment', 'value' => $taskL[ 'TAS_DESCRIPTION' ] ) ) ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) ) ) ;
}
}
}
}
//if( $translates ) {
// unset( $_SESSION['glpi_dropdowntranslations']['TaskCategory'] ) ;
//}
}
}
@@ -151,34 +158,42 @@ class PluginProcessmakerProcess extends CommonDBTM {
$pm->login( true ) ;
$pmProcessList = $pm->processList() ;
$config = new PluginProcessmakerConfig ;
$config->getFromDB( 1 ) ;
$config = PluginProcessmakerConfig::getInstance() ;
$pmMainTaskCat = $config->fields['taskcategories_id'] ;
// and get processlist from GLPI
foreach( $pmProcessList as $process ) {
$glpiprocess = new PluginProcessmakerProcess ;
if( $glpiprocess->getFromDBbyExternalID($process->guid) ) {
// then update it only if name has changed
if( $glpiprocess->fields['name'] != $process->name ) {
if( $pmProcessList ) {
foreach( $pmProcessList as $process ) {
$glpiprocess = new PluginProcessmakerProcess ;
if( $glpiprocess->getFromDBbyExternalID($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 ) ) ;
}
// and check if main task category needs update
if( !$glpiprocess->fields['taskcategories_id'] ) {
}
// and check if main task category needs update
if( !$glpiprocess->fields['taskcategories_id'] ) {
// then needs to be added
$glpiprocess->addTaskCategory( $pmMainTaskCat ) ;
} else {
$glpiprocess->updateTaskCategory( ) ;
}
} else {
// create it
if( $glpiprocess->add( array( 'process_guid' => $process->guid, 'name' => $process->name )) ){
} else {
$glpiprocess->updateTaskCategory( $pmMainTaskCat ) ;
}
} else {
// create it
if( isset( $process->project_type ) )
$project_type = $process->project_type;
else
$project_type = 'classic' ;
if( $glpiprocess->add( array( 'process_guid' => $process->guid, 'name' => $process->name, 'project_type' => $project_type )) ){
// and add main task category for this process
$glpiprocess->addTaskCategory( $pmMainTaskCat ) ;
}
}
}
}
}
}
// should de-activate other
}
/**
@@ -186,10 +201,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
* Updates TaskCategory for current process, only if needed (i.e. name has changed)
* returns true if update is done, false otherwise
*/
function updateTaskCategory( ) {
function updateTaskCategory( $pmMainTaskCat ) {
$taskCat = new TaskCategory ;
if( $taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name'] ) {
return $taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $this->fields['name'] ) ) ;
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name'] ) ) ;
}
return false ;
}
@@ -236,7 +251,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
*
* @return true if succeed else false
**/
function getFromDBbyExternalID($extid) {
public function getFromDBbyExternalID($extid) {
global $DB;
$query = "SELECT *
@@ -269,7 +284,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
$tab[1]['table'] = 'glpi_plugin_processmaker_processes';
$tab[1]['field'] = 'name';
$tab[1]['name'] = $LANG['common'][16];
$tab[1]['name'] = __('Name');
$tab[1]['datatype'] = 'itemlink';
$tab[1]['itemlink_type'] = $this->getType();
@@ -281,19 +296,19 @@ class PluginProcessmakerProcess extends CommonDBTM {
$tab[8]['table'] = 'glpi_plugin_processmaker_processes';
$tab[8]['field'] = 'is_active';
$tab[8]['name'] = $LANG['common'][60];
$tab[8]['name'] = __('Active');
$tab[8]['massiveaction'] = true;
$tab[8]['datatype'] = 'bool';
$tab[4]['table'] = 'glpi_plugin_processmaker_processes';
$tab[4]['field'] = 'comment';
$tab[4]['name'] = $LANG['common'][25];
$tab[4]['name'] = __('Comments');
$tab[4]['massiveaction'] = true;
$tab[4]['datatype'] = 'text';
$tab[9]['table'] = 'glpi_plugin_processmaker_processes';
$tab[9]['field'] = 'date_mod';
$tab[9]['name'] = $LANG['common'][26];
$tab[9]['name'] = __('Last update');
$tab[9]['massiveaction'] = false;
$tab[9]['datatype'] = 'datetime';
@@ -303,10 +318,67 @@ class PluginProcessmakerProcess extends CommonDBTM {
$tab[10]['massiveaction'] = false;
$tab[10]['datatype'] = 'text';
$tab[11]['table'] = 'glpi_plugin_processmaker_processes';
$tab[11]['field'] = 'project_type';
$tab[11]['name'] = $LANG['processmaker']['process']['project_type_short'];
$tab[11]['massiveaction'] = false;
$tab[11]['datatype'] = 'specific';
$tab[12]['table'] = 'glpi_plugin_processmaker_processes';
$tab[12]['field'] = 'hide_case_num_title';
$tab[12]['name'] = $LANG['processmaker']['process']['hide_case_num_title_short'];
$tab[12]['massiveaction'] = true;
$tab[12]['datatype'] = 'bool';
$tab[13]['table'] = 'glpi_plugin_processmaker_processes';
$tab[13]['field'] = 'insert_task_comment';
$tab[13]['name'] = $LANG['processmaker']['process']['insert_task_comment_short'];
$tab[13]['massiveaction'] = true;
$tab[13]['datatype'] = 'bool';
$tab[14]['table'] = 'glpi_itilcategories';
$tab[14]['field'] = 'completename';
$tab[14]['name'] = __('Category');
$tab[14]['datatype'] = 'dropdown';
$tab[14]['massiveaction'] = false;
$tab[15]['table'] = 'glpi_plugin_processmaker_processes';
$tab[15]['field'] = 'type';
$tab[15]['name'] = $LANG['processmaker']['process']['type'];
$tab[15]['searchtype'] = 'equals';
$tab[15]['datatype'] = 'specific';
$tab[15]['massiveaction'] = false;
return $tab;
}
/**
* @since version 0.84
*
* @param $field
* @param $values
* @param $options array
**/
static function getSpecificValueToDisplay($field, $values, array $options=array()) {
global $LANG;
if (!is_array($values)) {
$values = array($field => $values);
}
switch ($field) {
case 'project_type':
return $LANG['processmaker']['process']['project_type_'.$values[$field]] ;
case 'type':
return Ticket::getTicketTypeName($values[$field]);
}
return parent::getSpecificValueToDisplay($field, $values, $options);
}
static function getTypeName($nb=0) {
global $LANG;
@@ -318,7 +390,11 @@ class PluginProcessmakerProcess extends CommonDBTM {
function defineTabs($options=array()) {
$ong = array('empty' => $this->getTypeName(1));
// $ong = array('empty' => $this->getTypeName(1));
$ong = array();
$this->addDefaultFormTab($ong);
$this->addStandardTab(__CLASS__, $ong, $options);
$this->addStandardTab('PluginProcessmakerTaskCategory', $ong, $options);
$this->addStandardTab('PluginProcessmakerProcess_Profile', $ong, $options);
//$this->addStandardTab('Ticket', $ong, $options);
@@ -330,21 +406,23 @@ class PluginProcessmakerProcess extends CommonDBTM {
function showForm ($ID, $options=array('candel'=>false)) {
global $DB, $CFG_GLPI, $LANG;
if ($ID > 0) {
$this->check($ID,'r');
}
//if ($ID > 0) {
// $this->check($ID,READ);
//}
$canedit = $this->can($ID,'w');
//$canedit = $this->can($ID,UPDATE);
//$options['canedit'] = $canedit ;
$this->showTabs($options);
$this->initForm($ID, $options);
//$this->showTabs($options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG["common"][16]."&nbsp;:</td><td>";
echo "<td>".__("Name")."&nbsp;:</td><td>";
//Html::autocompletionTextField($this, "name");
echo $this->fields["name"];
echo "</td>";
echo "<td rowspan='5' class='middle right'>".$LANG["common"][25]."&nbsp;:</td>";
echo "<td rowspan='5' class='middle right'>".__("Comments")."&nbsp;:</td>";
echo "<td class='center middle' rowspan='5'><textarea cols='45' rows='6' name='comment' >".
$this->fields["comment"]."</textarea></td></tr>";
@@ -354,7 +432,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['common'][60]."&nbsp;:</td><td>";
echo "<td >".__("Active")."&nbsp;:</td><td>";
Dropdown::showYesNo("is_active",$this->fields["is_active"]);
echo "</td></tr>";
@@ -380,7 +458,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
$rand = $idtype = Ticket::dropdownType('type', $opt, array(),array('toupdate' => "search_".$idticketcategorysearch ));
$opt = array('value' => $this->fields["type"]);
$params = array('type' => '__VALUE__',
'entity_restrict' => $this->fields['entities_id'],
//'entity_restrict' => -1, //$this->fields['entities_id'],
'value' => $this->fields['itilcategories_id'],
'currenttype' => $this->fields['type']);
@@ -398,11 +476,11 @@ class PluginProcessmakerProcess extends CommonDBTM {
switch ($this->fields['type']) {
case Ticket::INCIDENT_TYPE :
$opt['condition'] .= "`is_incident`='1'";
$opt['condition'] = "`is_incident`='1'";
break;
case Ticket::DEMAND_TYPE :
$opt['condition'] .= "`is_request`='1'";
$opt['condition'] = "`is_request`='1'";
break;
default :
@@ -418,14 +496,19 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['project_type']."&nbsp;:</td><td>";
Dropdown::showFromArray( 'project_type', array( 'classic' => $LANG['processmaker']['process']['project_type_classic'], 'bpmn' => $LANG['processmaker']['process']['project_type_bpmn'] ), array( 'value' => $this->fields["project_type"] ) ) ;
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['common'][26]."&nbsp;:</td><td>";
echo "<td >".__("Last update")."&nbsp;:</td><td>";
echo Html::convDateTime($this->fields["date_mod"]);
echo "</td></tr>";
$this->showFormButtons($options );
$this->addDivForTabs();
//$this->addDivForTabs();
}
@@ -437,16 +520,11 @@ class PluginProcessmakerProcess extends CommonDBTM {
* Internaly used by showGroup_Users, dropdownUsers and ajax/dropdownUsers.php
*
* @param $count true if execute an count(*),
* @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 $search pattern
*
* @return mysql result set.
**/
static function getSqlSearchResult ($count=true, $right="all", $entity_restrict=-1, $value=0,
$used=array(), $search='') {
static function getSqlSearchResult ($count=true, $search='') {
global $DB, $CFG_GLPI;
$orderby = '' ;
@@ -462,155 +540,25 @@ class PluginProcessmakerProcess extends CommonDBTM {
if( strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"] )
{
$where .= " AND (glpi_plugin_processmaker_processes.name LIKE '%$search%'
OR glpi_plugin_processmaker_processes.comment LIKE '%$search%') " ;
$where .= " AND (glpi_plugin_processmaker_processes.name $search
OR glpi_plugin_processmaker_processes.comment $search) " ;
}
// LEFT JOIN glpi_plugin_processmaker_processes_profiles ON glpi_plugin_processmaker_processes_profiles.processes_id=glpi_plugin_processmaker_processes.id
$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";" ;
//// No entity define : use active ones
//if ($entity_restrict < 0) {
// $entity_restrict = $_SESSION["glpiactiveentities"];
//}
//$joinprofile = false;
//switch ($right) {
// case "interface" :
// $where = " `glpi_profiles`.`interface` = 'central' ";
// $joinprofile = true;
// $where .= getEntitiesRestrictRequest("AND","glpi_profiles_users",'',$entity_restrict,1);
// break;
// case "id" :
// $where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
// break;
// case "delegate" :
// $groups = self::getDelegateGroupsForUser($entity_restrict);
// $users = array();
// if (count($groups)) {
// $query = "SELECT `glpi_users`.`id`
// FROM `glpi_groups_users`
// LEFT JOIN `glpi_users`
// ON (`glpi_users`.`id` = `glpi_groups_users`.`users_id`)
// WHERE `glpi_groups_users`.`groups_id` IN ('".implode("','",$groups)."')
// AND `glpi_groups_users`.`users_id` <> '".Session::getLoginUserID()."'";
// $result = $DB->query($query);
// if ($DB->numrows($result)) {
// while ($data=$DB->fetch_array($result)) {
// $users[$data["id"]] = $data["id"];
// }
// }
// }
// // Add me to users list for central
// if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
// $users[Session::getLoginUserID()] = Session::getLoginUserID();
// }
// if (count($users)) {
// $where = " `glpi_users`.`id` IN ('".implode("','",$users)."')";
// } else {
// $where = '0';
// }
// break;
// case "all" :
// $where = " `glpi_users`.`id` > '1' ".
// getEntitiesRestrictRequest("AND","glpi_profiles_users",'',$entity_restrict,1);
// break;
// default :
// $joinprofile = true;
// // Check read or active for rights
// $where = " (`glpi_profiles`.`".$right."` IN ('1', 'r', 'w') ".
// getEntitiesRestrictRequest("AND", "glpi_profiles_users", '',
// $entity_restrict, 1)." ";
// if (!in_array($right,Profile::$helpdesk_rights)) {
// $where .= " AND `glpi_profiles`.`interface` = 'central' ";
// }
// $where .= ')';
//}
//$where .= " AND `glpi_users`.`is_deleted` = '0'
// AND `glpi_users`.`is_active` = '1' ";
//if ((is_numeric($value) && $value)
// || count($used)) {
// $where .= " AND `glpi_users`.`id` NOT IN (";
// if (is_numeric($value)) {
// $first = false;
// $where .= $value;
// } else {
// $first = true;
// }
// foreach ($used as $val) {
// if ($first) {
// $first = false;
// } else {
// $where .= ",";
// }
// $where .= $val;
// }
// $where .= ")";
//}
//if ($count) {
// $query = "SELECT COUNT(DISTINCT `glpi_users`.`id` ) AS cpt
// FROM `glpi_users` ";
//} else {
// $query = "SELECT DISTINCT `glpi_users`.*
// FROM `glpi_users` ";
//}
//$query .= " LEFT JOIN `glpi_useremails`
// ON (`glpi_users`.`id` = `glpi_useremails`.`users_id`)";
//$query .= " LEFT JOIN `glpi_profiles_users`
// ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
//if ($joinprofile) {
// $query .= " LEFT JOIN `glpi_profiles`
// ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
//}
//if ($count) {
// $query .= " WHERE $where ";
//} else {
// if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
// $where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
// OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
// OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
// Search::makeTextSearch($search).")";
// }
// $query .= " WHERE $where ";
// if ($_SESSION["glpinames_format"] == FIRSTNAME_BEFORE) {
// $query.=" ORDER BY `glpi_users`.`firstname`,
// `glpi_users`.`realname`,
// `glpi_users`.`name` ";
// } else {
// $query.=" ORDER BY `glpi_users`.`realname`,
// `glpi_users`.`firstname`,
// `glpi_users`.`name` ";
// }
// if ($search != $CFG_GLPI["ajax_wildcard"]) {
// $query .= " LIMIT 0,".$CFG_GLPI["dropdown_max"];
// }
//}
return $DB->query($query);
}
/**
* Summary of getProcessName
* @param mixed $pid
* @param mixed $link
* @return mixed
*/
static function getProcessName( $pid, $link=0 ) {
global $DB, $LANG;
global $DB;
$process='';
if ($link==2) {
$process = array("name" => "",
@@ -626,7 +574,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
if ($link==2) {
$process["name"] = $processname ;
$process["link"] = $CFG_GLPI["root_doc"]."/plugins/processmaker/front/process.form.php?id=".$pid;
$process["comment"] = $LANG['common'][16]."&nbsp;: ".$processname."<br>".$LANG["common"][25].
$process["comment"] = __('Name')."&nbsp;: ".$processname."<br>".__('Comments').
"&nbsp;: ".$data["comment"]."<br>";
} else {
$process = $processname ;
@@ -672,95 +620,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
* @return mixed
*/
static function dropdown($options=array()) {
global $DB, $CFG_GLPI, $LANG;
global $CFG_GLPI;
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownProcesses.php' ;
return Dropdown::show( __CLASS__, $options ) ;
// Default values
$p['name'] = 'processes_id';
$p['value'] = '';
$p['right'] = 'id';
$p['all'] = 0;
$p['on_change'] = '';
$p['comments'] = 1;
$p['entity'] = -1;
$p['entity_sons'] = false;
$p['used'] = array();
$p['ldap_import'] = false;
$p['toupdate'] = '';
$p['rand'] = mt_rand();
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$p[$key] = $val;
}
}
// Make a select box with all glpi users
$use_ajax = false;
if ($CFG_GLPI["use_ajax"]) {
$res = self::getSqlSearchResult (true, $p['right'], $p['entity'], $p['value'], $p['used']);
$nb = ($res ? $DB->result($res,0,"cpt") : 0);
if ($nb > $CFG_GLPI["ajax_limit_count"]) {
$use_ajax = true;
}
}
$process = self::getProcessName($p['value'],2);
$default_display = "<select id='dropdown_".$p['name'].$p['rand']."' name='".$p['name']."'>";
$default_display .= "<option value='".$p['value']."'>";
$default_display .= Toolbox::substr($process["name"], 0, $_SESSION["glpidropdown_chars_limit"]);
$default_display .= "</option></select>";
//$view_users = (Session::haveRight("user", "r"));
//TODO: management of rights
$view_processes = true ;
$params = array('searchText' => '__VALUE__',
'value' => $p['value'],
'myname' => $p['name'],
'all' => $p['all'],
'right' => $p['right'],
'comment' => $p['comments'],
'rand' => $p['rand'],
'on_change' => $p['on_change'],
'entity_restrict' => $p['entity'],
'used' => $p['used'],
'update_item' => $p['toupdate'],);
if ($view_processes) {
$params['update_link'] = $view_processes;
}
$default = "";
if (!empty($p['value']) && $p['value']>0) {
$default = $default_display;
} else {
$default = "<select name='".$p['name']."' id='dropdown_".$p['name'].$p['rand']."'>";
if ($p['all']) {
$default.= "<option value='0'>[ ".$LANG['common'][66]." ]</option></select>";
} else {
$default.= "<option value='0'>".Dropdown::EMPTY_VALUE."</option></select>\n";
}
}
Ajax::dropdown($use_ajax, "/plugins/processmaker/ajax/dropdownProcesses.php", $params, $default, $p['rand']);
// Display comment
if ($p['comments']) {
if (!$view_processes) {
$process["link"] = '';
} else if (empty($process["link"])) {
$process["link"] = $CFG_GLPI['root_doc']."/plugins/processmaker/front/process.php";
}
Html::showToolTip($process["comment"],
array('contentid' => "comment_".$p['name'].$p['rand'],
'link' => $process["link"],
'linkid' => "comment_link_".$p["name"].$p['rand']));
}
return $p['rand'];
}
}

View File

@@ -10,8 +10,8 @@
*/
class PluginProcessmakerProcess_Profile extends CommonDBTM
{
function can($ID, $right, &$input = NULL) {
return plugin_processmaker_haveRight('process_config', $right) ;
function can($ID, $right, array &$input = NULL) {
return Session::haveRight('plugin_processmaker_config', $right) ;
}
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
@@ -25,37 +25,34 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
$ID = $item->getField('id');
$canshowentity = Session::haveRight("entity","r");
$canedit = plugin_processmaker_haveRight('process_config', 'w') ;
$canshowentity = Session::haveRight("entity", READ);
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE) ;
$rand=mt_rand();
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['processmaker']['title'][4]."</tr>";
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'>";
Dropdown::show('Entity', array('entity' => $_SESSION['glpiactiveentities']));
echo "</td><td class='center'>".$LANG['profiles'][22]."&nbsp;: ";
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
echo "</td><td class='center'>".$LANG['profiles'][28]."&nbsp;: ";
echo "</td><td class='center'>".__('Recursive')."</td><td>";
Dropdown::showYesNo("is_recursive",0);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"".$LANG['buttons'][8]."\" class='submit'>";
echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
echo "</td></tr>";
echo "</table></div>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='2'>".$LANG['Menu'][37]."</th>";
echo "<th>".$LANG['profiles'][22]." (D=".$LANG['profiles'][29].", R=".$LANG['profiles'][28].")";
echo "</th></tr>";
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
`glpi_profiles`.`id`,
`glpi_profiles`.`name`,
@@ -70,55 +67,125 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
WHERE `glpi_plugin_processmaker_processes_profiles`.`processes_id` = '$ID'
ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
$result = $DB->query($query);
$num = $DB->numrows($result);
if ($DB->numrows($result) >0) {
while ($data = $DB->fetch_array($result)) {
echo "<div class='spaced'>";
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
if ($canedit && $num) {
$massiveactionparams = array('num_displayed' => $num,
'container' => 'mass'.__CLASS__.$rand);
Html::showMassiveActions($massiveactionparams);
}
if ($num > 0) {
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_begin .= "<th>";
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_end .= "</th>";
}
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
__('D=Dynamic, R=Recursive'));
$header_end .= "</th></tr>";
echo $header_begin.$header_top.$header_end;
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_1'>";
echo "<td width='10'>";
if ($canedit && in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
echo "<input type='checkbox' name='item[".$data["linkID"]."]' value='1'>";
} else {
echo "&nbsp;";
}
echo "</td>";
if ($data["entities_id"] == 0) {
$data["completename"] = $LANG['entity'][2];
if ($canedit) {
echo "<td width='10'>";
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
} else {
echo "&nbsp;";
}
echo "</td>";
}
echo "<td>";
if ($canshowentity) {
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".$data["entities_id"]."'>";
$link = $data["completename"];
if ($_SESSION["glpiis_ids_visible"]) {
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
}
echo $data["completename"].
($_SESSION["glpiis_ids_visible"]?" (".$data["entities_id"].")":"");
if ($canshowentity) {
echo "</a>";
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
$data["entities_id"]."'>";
}
echo $link.($canshowentity ? "</a>" : '');
echo "</td>";
echo "<td>".$data["name"];
if (Profile::canView()) {
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
$data["name"]."</a>";
} else {
$entname = $data["name"];
}
// if ($data["is_dynamic"] || $data["is_recursive"]) {
if ($data["is_recursive"]) {
echo "<span class='b'>&nbsp;(";
echo "R";
echo ")</span>";
$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'));
}
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
}
echo "</td>";
echo "<td>".$entname."</td>";
echo "</tr>";
}
echo "</tr>";
echo $header_begin.$header_bottom.$header_end;
echo "</table>";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>".__('No item found')."</th></tr>";
echo "</table>\n";
}
echo "</table>";
if ($canedit) {
Html::openArrowMassives("entityprocess_form$rand",true);
Html::closeArrowMassives(array('delete' => $LANG['buttons'][6]));
if ($canedit && $num) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
}
Html::closeForm();
echo "</div>";
}
//static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) {
// global $CFG_GLPI;
// $action = $ma->getAction();
// 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 ;
// }
//}
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ class ProcessmakerConfig extends CommonDBTM {
var $table = 'glpi_plugins_processmaker_config';
static function getTypeName() {
static function getTypeName($nb=0) {
global $LANG;
return 'Process Maker Plugin Configuration';
@@ -68,7 +68,7 @@ class ProcessmakerConfig extends CommonDBTM {
function showForm($ID, $options=array()) {
global $LANG, $CFG_GLPI;
if (!Session::haveRight("config", "w")) {
if (!Session::haveRight("config", UPDATE)) {
return false;
}
if (!$CFG_GLPI['use_mailing']) {
@@ -82,107 +82,16 @@ class ProcessmakerConfig extends CommonDBTM {
}
function canCreate() {
return Session::haveRight('config', 'w');
static function canCreate() {
return Session::haveRight('config', UPDATE);
}
function canView() {
return Session::haveRight('config', 'r');
static function canView() {
return Session::haveRight('config', READ);
}
//function showFormMailServerConfig() {
// global $LANG, $CFG_GLPI;
// echo "<form action='".Toolbox::getItemTypeFormURL(__CLASS__)."' method='post'>";
// echo "<div>";
// echo "<table class='tab_cadre_fixe'>";
// echo "<input type='hidden' name='id' value='1'>";
// echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['setup'][704]."</th></tr>";
// echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][202] . "&nbsp;:</td><td>";
// Dropdown::showYesNo("use_mailing", $CFG_GLPI["use_mailing"]);
// echo "</td>";
// if ($CFG_GLPI['use_mailing']) {
// echo "<td >" . $LANG['setup'][227] . "&nbsp;:</td>";
// echo "<td><input type='text' name='url_base' size='40' value='".$CFG_GLPI["url_base"]."'>";
// echo "</td></tr>";
// echo "<tr class='tab_bg_2'>";
// echo "<td>" . $LANG['setup'][203] . "&nbsp;:</td>";
// echo "<td><input type='text' name='admin_email' size='40' value='".
// $CFG_GLPI["admin_email"]."'>";
// if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_email"])) {
// echo "<span class='red'>&nbsp;".$LANG['mailing'][110]."</span>";
// }
// echo "</td>";
// echo "<td >" . $LANG['setup'][208] . "&nbsp;:</td>";
// echo "<td><input type='text' name='admin_email_name' size='40' value='" .
// $CFG_GLPI["admin_email_name"] . "'>";
// echo " </td></tr>";
// echo "<tr class='tab_bg_2'>";
// echo "<td >" . $LANG['setup'][207] . "&nbsp;:</td>";
// echo "<td><input type='text' name='admin_reply' size='40' value='" .
// $CFG_GLPI["admin_reply"] . "'>";
// if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_reply"])) {
// echo "<span class='red'>&nbsp;".$LANG['mailing'][110]."</span>";
// }
// echo " </td>";
// echo "<td >" . $LANG['setup'][209] . "&nbsp;:</td>";
// echo "<td><input type='text' name='admin_reply_name' size='40' value='" .
// $CFG_GLPI["admin_reply_name"] . "'>";
// echo " </td></tr>";
// if (!function_exists('mail')) {
// echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
// echo "<span class='red'>" . $LANG['setup'][217] . "&nbsp;:</span>".
// $LANG['setup'][218] . "</td></tr>";
// }
// echo "<tr class='tab_bg_2'>";
// echo "<td>" . $LANG['setup'][204] . "&nbsp;:</td>";
// echo "<td colspan='3'><textarea cols='60' rows='3' name='mailing_signature'>".
// $CFG_GLPI["mailing_signature"]."</textarea></td></tr>";
// echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['setup'][660]."</th></tr>";
// echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][231] . "&nbsp;:</td><td>";
// $mail_methods = array(MAIL_MAIL => $LANG['setup'][650],
// MAIL_SMTP => $LANG['setup'][651],
// MAIL_SMTPSSL => $LANG['setup'][652],
// MAIL_SMTPTLS => $LANG['setup'][653]);
// Dropdown::showFromArray("smtp_mode", $mail_methods,
// array('value' => $CFG_GLPI["smtp_mode"]));
// echo "</td><td colspan='2' class='center'>&nbsp;";
// echo "</td></tr>";
// echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][232] . "&nbsp;:</td>";
// echo "<td><input type='text' name='smtp_host' size='40' value='".$CFG_GLPI["smtp_host"]."'>";
// echo "</td>";
// echo "<td >" . $LANG['setup'][234] . "&nbsp;:</td>";
// echo "<td><input type='text' name='smtp_username' size='40' value='" .
// $CFG_GLPI["smtp_username"] . "'></td></tr>";
// echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][175] . "&nbsp;:</td>";
// echo "<td><input type='text' name='smtp_port' size='5' value='".$CFG_GLPI["smtp_port"]."'>";
// echo "</td>";
// echo "<td >" . $LANG['setup'][235] . "&nbsp;:</td>";
// echo "<td><input type='password' name='smtp_passwd' size='40' value='' autocomplete='off'>";
// echo "<br><input type='checkbox' name='_blank_smtp_passwd'>&nbsp;".$LANG['setup'][284];
// echo "</td></tr>";
// } else {
// echo "<td colspan='2'></td></tr>";
// }
// $options['candel'] = false;
// $options['addbuttons'] = array('test_smtp_send' => $LANG['setup'][229]);
// $this->showFormButtons($options);
//}
}

View File

@@ -8,114 +8,82 @@ if (!defined('GLPI_ROOT')) {
class PluginProcessmakerProfile extends CommonDBTM {
//if profile deleted
static function cleanProfiles(Profile $prof) {
$plugprof = new self();
$plugprof->delete(array('id' => $prof->getID()));
}
static function select() {
$prof = new self();
if ($prof->getFromDBByProfile($_SESSION['glpiactiveprofile']['id'])) {
$_SESSION["glpi_plugin_processmaker_profile"] = $prof->fields;
} else {
unset($_SESSION["glpi_plugin_processmaker_profile"]);
}
}
//profiles modification
function showForm($ID, $options=array()) {
/**
* Summary of getAllRights
* @return array[]
*/
static function getAllRights() {
global $LANG;
$target = $this->getFormURL();
if (isset($options['target'])) {
$target = $options['target'];
}
if (!Session::haveRight("profile","r")) {
$rights = array(
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['process_config'],
'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')))
);
return $rights;
}
/**
* Summary of showForm
* @param mixed $ID
* @param mixed $openform
* @param mixed $closeform
* @return bool
*/
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
global $LANG;
if (!Session::haveRight("profile",READ)) {
return false;
}
$canedit = Session::haveRight("profile", "w");
$canedit = Session::haveRight("profile", UPDATE);
$prof = new Profile();
if ($ID) {
$this->getFromDBByProfile($ID);
$prof->getFromDB($ID);
}
echo "<form action='".$target."' method='post'>";
echo "<table class='tab_cadre_fixe'>";
echo "<form action='".$prof->getFormURL()."' method='post'>";
$rights = $this->getAllRights();
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
'default_class' => 'tab_bg_2',
'title' => $LANG['processmaker']['title'][1]));
echo "<tr><th colspan='2'>".$LANG['processmaker']['profile']['rightmgt']." : ".$prof->fields["name"].
"</th></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td>".$LANG['processmaker']['profile']['process_config']." :</td><td>";
if ($prof->fields['interface']!='helpdesk') {
Profile::dropdownNoneReadWrite("process_config", $this->fields["process_config"], 1, 1, 1);
} else {
echo $LANG['profiles'][12]; // No access;
if ($canedit && $closeform) {
echo "<div class='center'>";
echo Html::hidden('id', array('value' => $ID));
echo Html::submit(_sx('button', 'Save'),
array('name' => 'update'));
echo "</div>\n";
}
echo "</td></tr>";
Html::closeForm();
if ($canedit) {
echo "<tr class='tab_bg_1'>";
echo "<td class='center' colspan='2'>";
echo "<input type='hidden' name='id' value=".$this->getID().">";
echo "<input type='submit' name='update_user_profile' value=\"".$LANG['buttons'][7]."\"
class='submit'>";
echo "</td></tr>";
}
echo "</table>";
Html::closeForm();
}
function getFromDBByProfile($profiles_id) {
global $DB;
$query = "SELECT * FROM `".$this->getTable()."`
WHERE `profiles_id` = '" . $profiles_id . "' ";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) != 1) {
return false;
}
$this->fields = $DB->fetch_assoc($result);
if (is_array($this->fields) && count($this->fields)) {
return true;
} else {
return false;
}
}
return false;
}
/**
* Summary of createAdminAccess
* @param mixed $ID
*/
static function createAdminAccess($ID) {
$myProf = new self();
if (!$myProf->getFromDBByProfile($ID)) {
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
$myProf->add(array(
'profiles_id' => $ID,
'process_config' => 'w'
));
}
}
function createUserAccess($Profile) {
return $this->add(array('profiles_id' => $Profile->getID()
));
}
/**
* Summary of getTabNameForItem
* @param CommonGLPI $item
* @param mixed $withtemplate
* @return string|string[]
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
@@ -125,19 +93,51 @@ class PluginProcessmakerProfile extends CommonDBTM {
return '';
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $item
* @param mixed $tabnum
* @param mixed $withtemplate
* @return bool
*/
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI;
if ($item->getType()=='Profile') {
$ID = $item->getID();
$prof = new self();
if ($prof->getFromDBByProfile($ID) || $prof->createUserAccess($item)) {
self::addDefaultProfileInfos($ID,
array('plugin_processmaker_config' => 0,
'plugin_processmaker_deletecase' => 0
));
$prof->showForm($ID);
}
}
return true;
}
}
?>
/**
* @param $profile
**/
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
global $DB;
$profileRight = new ProfileRight();
foreach ($rights as $right => $value) {
if (countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
}
if (!countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
$myright['profiles_id'] = $profiles_id;
$myright['name'] = $right;
$myright['rights'] = $value;
$profileRight->add($myright);
//Add right to the current session
$_SESSION['glpiactiveprofile'][$right] = $value;
}
}
}
}

127
inc/task.class.php Normal file
View File

@@ -0,0 +1,127 @@
<?php
/**
* tasks short summary.
*
* tasks description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerTask extends CommonITILTask
{
private $itemtype ;
function __construct($itemtype) {
parent::__construct();
$this->itemtype=$itemtype;
}
/**
* Summary of getFromDB
* @param mixed $items_id
* @param mixed $itemtype
* @return bool
*/
function getFromDB($items_id) {
global $DB ;
if( $this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ) ) {
$task = new $this->itemtype;
if( $task->getFromDB( $items_id ) ) {
// then we should add our own fields
$task->fields['items_id'] = $this->fields['id'] ;
$task->fields['itemtype'] = $this->fields['itemtype'] ;
unset( $this->fields['id'] ) ;
unset( $this->fields['items_id'] ) ;
unset( $this->fields['itemtype'] ) ;
foreach( $this->fields as $field => $val) {
$task->fields[ $field ] = $val ;
}
$this->fields = $task->fields ;
return true ;
}
}
//$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 ;
}
/**
* Summary of getToDoTasks
* returns all 'to do' tasks associated with this case
* @param mixed $case_id
*/
public static function getToDoTasks( $case_id, $itemtype ) {
global $DB ;
$ret = array();
$selfTable = getTableForItemType( __CLASS__) ;
$itemTypeTaskTable = getTableForItemType( $itemtype );
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
foreach($DB->request($query) as $row){
$ret[$row['taskID']]=$row['taskID'];
}
return $ret ;
}
static function canView( ) {
return true ;
}
static function populatePlanning($params) {
global $CFG_GLPI;
//echo 'Test' ;
$ret = array();
$events = array() ;
$params['begin'] = '2000-01-01 00:00:00';
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
foreach( $ret as $key => $event ) {
if( $event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
// check if task is one within a case
$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' ;
$taskCat = new TaskCategory ;
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] ) ;
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '' ;
if( Session::haveTranslations('TaskCategory', 'comment') ) {
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment ) ;
}
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] ) ;
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ) ; //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
if( $event['state'] == 1 && $event['end'] < $params['start'] ) { // if todo and late
$event['name'] = $event['end'].' '.$event['name'] ; //$event['begin'].' to '.$event['end'].' '.$event['name'] ;
$event['end'] = $params['start'].' 24:00:00'; //.$CFG_GLPI['planning_end'];
}
$events[$key] = $event ;
}
}
}
return $events ;
}
}

View File

@@ -70,7 +70,7 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
$buttons = array();
$title = $LANG['processmaker']['config']['refreshtasklist'];
if (plugin_processmaker_haveRight('process_config', 'w')) {
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
$title = "";
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
@@ -78,12 +78,12 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
}
}
function getLinkItemFromExternalID($extId) {
if( $this->getFromDBbyExternalID( $extId ) ) {
$taskcat = new TaskCategory ;
return $taskcat->getFromDB( $this->fields['items_id'] ) ;
}
}
//function getLinkItemFromExternalID($extId) {
// if( $this->getFromDBbyExternalID( $extId ) ) {
// $taskcat = new TaskCategory ;
// return $taskcat->getFromDB( $this->fields['items_id'] ) ;
// }
//}
/**
@@ -112,5 +112,30 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
return false;
}
/**
* Retrieve a TaskCat from the database using its category id (unique index): taskcategories_id
*
* @param $catid string task category id
*
* @return true if succeed else false
**/
function getFromDBbyCategory($catid) {
global $DB;
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `taskcategories_id` = $catid";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) != 1) {
return false;
}
$this->fields = $DB->fetch_assoc($result);
if (is_array($this->fields) && count($this->fields)) {
return true;
}
}
return false;
}
}

View File

@@ -1,68 +0,0 @@
<?php
/**
* tasks short summary.
*
* tasks description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerTasks extends CommonITILTask
{
private $itemtype ;
function __construct($itemtype) {
parent::__construct();
$this->itemtype=$itemtype;
}
/**
* Summary of getFromDB
* @param mixed $items_id
* @param mixed $itemtype
* @return bool
*/
function getFromDB($items_id) {
global $DB ;
$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 ;
}
/**
* Summary of getToDoTasks
* returns all 'to do' tasks associated with this case
* @param mixed $case_id
*/
public static function getToDoTasks( $case_id, $itemtype ) {
global $DB ;
$ret = array();
$selfTable = getTableForItemType( __CLASS__) ;
$itemTypeTaskTable = getTableForItemType( $itemtype );
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
foreach($DB->request($query) as $row){
$ret[$row['taskID']]=$row['taskID'];
}
return $ret ;
}
}

219
inc/user.class.php Normal file
View File

@@ -0,0 +1,219 @@
<?php
/**
* user short summary.
*
* user description.
*
* @version 2.0
* @author MoronO
*/
class PluginProcessmakerUser extends CommonDBTM {
/**
* Execute the query to select box with all glpi users where select key = name
*
* Internaly used by showGroup_Users, dropdownUsers and ajax/dropdownUsers.php
*
* @param $count true if execute an count(*),
* @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 $search pattern
*
* @return mysql result set.
**/
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
$used=array(), $search='', $limit='') {
global $DB, $PM_DB, $CFG_GLPI;
// first need to get all users from $taskId
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
$pmQuery = "SELECT group_user.USR_UID as pm_user_id FROM task_user
JOIN group_user on group_user.GRP_UID=task_user.USR_UID AND task_user.TU_RELATION = 2 AND task_user.TU_TYPE=1
WHERE TAS_UID = '$taskId'; " ;
$pmUsers = array( ) ;
foreach( $PM_DB->request( $pmQuery ) as $pmUser ) {
$pmUsers[ ] = $pmUser[ 'pm_user_id' ] ;
}
$joinprofile = false;
switch ($right) {
case "id" :
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
break;
case "all" :
$where = " `glpi_users`.`id` > '1' " ;
break;
}
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') " ;
// $where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND TAS_UID = '$taskId' " ;
$where .= " AND `glpi_users`.`is_deleted` = '0'
AND `glpi_users`.`is_active` = '1' ";
if ((is_numeric($value) && $value)
|| count($used)) {
$where .= " AND `glpi_users`.`id` NOT IN (";
if (is_numeric($value)) {
$first = false;
$where .= $value;
} else {
$first = true;
}
foreach ($used as $val) {
if ($first) {
$first = false;
} else {
$where .= ",";
}
$where .= $val;
}
$where .= ")";
}
if ($count) {
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
} else {
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
}
$query .= "FROM glpi_plugin_processmaker_users
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id " ;
//$query .= "from wf_workflow.task_user
// join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
// join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
// join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
$query .= " LEFT JOIN `glpi_useremails`
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
$query .= " LEFT JOIN `glpi_profiles_users`
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
if ($joinprofile) {
$query .= " LEFT JOIN `glpi_profiles`
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
}
if ($count) {
$query .= " WHERE $where ";
} else {
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
Search::makeTextSearch($search).")";
}
$query .= " WHERE $where ";
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
$query.=" ORDER BY `glpi_users`.`firstname`,
`glpi_users`.`realname`,
`glpi_users`.`name` ";
} else {
$query.=" ORDER BY `glpi_users`.`realname`,
`glpi_users`.`firstname`,
`glpi_users`.`name` ";
}
if ($search != $CFG_GLPI["ajax_wildcard"]) {
$query .= " $limit";
}
}
return $DB->query($query);
}
/**
* Make a select box with all glpi users where select key = name
*
* Parameters which could be used in options array :
* - name : string / name of the select (default is users_id)
* - right : string / limit user who have specific right :
* id -> only current user (default case);
* interface -> central ;
* all -> all users ;
* specific right like show_all_ticket, create_ticket....
* - comments : boolean / is the comments displayed near the dropdown (default true)
* - entity : integer or array / restrict to a defined entity or array of entities
* (default -1 : no restriction)
* - entity_sons : boolean / if entity restrict specified auto select its sons
* only available if entity is a single value not an array(default false)
* - all : Nobody or All display for none selected
* all=0 (default) -> Nobody
* all=1 -> All
* all=-1-> nothing
* - rand : integer / already computed rand value
* - toupdate : array / Update a specific item on select change on dropdown
* (need value_fieldname, to_update, url (see Ajax::updateItemOnSelectEvent for informations)
* and may have moreparams)
* - used : array / Already used items ID: not to display in dropdown (default empty)
* - on_change : string / value to transmit to "onChange"
*
* @param $options possible options
*
* @return int (print out an HTML select box)
**/
static function dropdown($options=array()) {
global $CFG_GLPI ;
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php' ;
return User::dropdown( $options ) ;
}
/**
* Summary of getGLPIUserId
* returns GLPI user ID from a Processmaker user ID
* @param string $pmUserId
* @return int, GLPI user id, or 0 if not found
*/
public static function getGLPIUserId( $pmUserId ){
$obj = new self ;
if( $obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'") ) {
return $obj->fields['id'] ;
}
return 0 ;
}
/**
* Summary of getPMUserId
* returns processmaker user id for given GLPI user id
* @param int $glpi_userId id of user from GLPI database
* @return string which is the uid of user in Processmaker database, or false if not found
*/
public static function getPMUserId( $glpiUserId ) {
$obj = new self;
if( $obj->getFromDB( Toolbox::cleanInteger($glpiUserId) ) ) {
return $obj->fields['pm_users_id'] ;
}
return false ;
}
///**
// * Summary of getNewPassword
// * @param mixed $username
// * @return string a new password computed
// * from uppercasing first letter of $username
// * and encoding
// * and adding a ramdon number (4 digits)
// * and truncating it to a length of 20 chars
// */
//public static function getNewPassword( $username ) {
// $newPass = Toolbox::encrypt( ucfirst( stripslashes( $username ) ), GLPIKEY) ;
// return substr( rand(1000,9999).$newPass, 0, 19) ;
//}
}

View File

@@ -1,409 +0,0 @@
<?php
/**
* user short summary.
*
* user description.
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerUsers extends CommonDBTM {
///**
// * Execute the query to select box with all PM users where select key = name
// *
// * Internaly used by showGroup_Users, dropdownUsers and ajax/dropdownUsers.php
// *
// * @param $taskId id of the PM task
// * @param $count true if execute an count(*),
// * @param $value default value
// * @param $used Already used items ID: not to display in dropdown
// * @param $search pattern
// *
// * @return mysql result set.
// **/
//static function getSqlSearchResult ($taskId, $count=true, $value=0,
// $used=array(), $search='') {
// global $DB, $CFG_GLPI;
// $where = " TAS_UID = '$taskId' " ;
// $where .= " AND `glpi_users`.`is_deleted` = '0'
// AND `glpi_users`.`is_active` = '1' ";
// if ((is_numeric($value) && $value)
// || count($used)) {
// $where .= " AND `glpi_users`.`id` NOT IN (";
// if (is_numeric($value)) {
// $first = false;
// $where .= $value;
// } else {
// $first = true;
// }
// foreach ($used as $val) {
// if ($first) {
// $first = false;
// } else {
// $where .= ",";
// }
// $where .= $val;
// }
// $where .= ")";
// }
// if ($count) {
// $query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
// } else {
// $query = "SELECT DISTINCT glpi_users.* ";
// }
// $query .= "from wf_workflow.task_user
// join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
// join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
// join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
// $query .= " LEFT JOIN `glpi_useremails`
// ON (`glpi_users`.`id` = `glpi_useremails`.`users_id`)";
// if ($count) {
// $query .= " WHERE $where ";
// } else {
// if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
// $where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
// OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
// OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
// OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
// Search::makeTextSearch($search).")";
// }
// $query .= " WHERE $where ";
// if ($_SESSION["glpinames_format"] == FIRSTNAME_BEFORE) {
// $query.=" ORDER BY `glpi_users`.`firstname`,
// `glpi_users`.`realname`,
// `glpi_users`.`name` ";
// } else {
// $query.=" ORDER BY `glpi_users`.`realname`,
// `glpi_users`.`firstname`,
// `glpi_users`.`name` ";
// }
// if ($search != $CFG_GLPI["ajax_wildcard"]) {
// $query .= " LIMIT 0,".$CFG_GLPI["dropdown_max"];
// }
// }
// return $DB->query($query);
//}
/**
* Execute the query to select box with all glpi users where select key = name
*
* Internaly used by showGroup_Users, dropdownUsers and ajax/dropdownUsers.php
*
* @param $count true if execute an count(*),
* @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 $search pattern
*
* @return mysql result set.
**/
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
$used=array(), $search='') {
global $DB, $CFG_GLPI;
// No entity define : use active ones
if ($entity_restrict < 0) {
$entity_restrict = $_SESSION["glpiactiveentities"];
}
$joinprofile = false;
switch ($right) {
case "interface" :
$where = " `glpi_profiles`.`interface` = 'central' ";
$joinprofile = true;
$where .= getEntitiesRestrictRequest("AND","glpi_profiles_users",'',$entity_restrict,1);
break;
case "id" :
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
break;
case "delegate" :
$groups = self::getDelegateGroupsForUser($entity_restrict);
$users = array();
if (count($groups)) {
$query = "SELECT `glpi_users`.`id`
FROM `glpi_groups_users`
LEFT JOIN `glpi_users`
ON (`glpi_users`.`id` = `glpi_groups_users`.`users_id`)
WHERE `glpi_groups_users`.`groups_id` IN ('".implode("','",$groups)."')
AND `glpi_groups_users`.`users_id` <> '".Session::getLoginUserID()."'";
$result = $DB->query($query);
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
$users[$data["id"]] = $data["id"];
}
}
}
// Add me to users list for central
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
$users[Session::getLoginUserID()] = Session::getLoginUserID();
}
if (count($users)) {
$where = " `glpi_users`.`id` IN ('".implode("','",$users)."')";
} else {
$where = '0';
}
break;
case "all" :
$where = " `glpi_users`.`id` > '1' ".
getEntitiesRestrictRequest("AND","glpi_profiles_users",'',$entity_restrict,1);
break;
default :
$joinprofile = true;
// Check read or active for rights
$where = " (`glpi_profiles`.`".$right."` IN ('1', 'r', 'w') ".
getEntitiesRestrictRequest("AND", "glpi_profiles_users", '',
$entity_restrict, 1)." ";
if (!in_array($right,Profile::$helpdesk_rights)) {
$where .= " AND `glpi_profiles`.`interface` = 'central' ";
}
$where .= ')';
}
$where .= " AND TAS_UID = '$taskId' " ;
$where .= " AND `glpi_users`.`is_deleted` = '0'
AND `glpi_users`.`is_active` = '1' ";
if ((is_numeric($value) && $value)
|| count($used)) {
$where .= " AND `glpi_users`.`id` NOT IN (";
if (is_numeric($value)) {
$first = false;
$where .= $value;
} else {
$first = true;
}
foreach ($used as $val) {
if ($first) {
$first = false;
} else {
$where .= ",";
}
$where .= $val;
}
$where .= ")";
}
if ($count) {
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
} else {
$query = "SELECT DISTINCT glpi_users.* ";
}
$query .= "from wf_workflow.task_user
join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
$query .= " LEFT JOIN `glpi_useremails`
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id`)";
$query .= " LEFT JOIN `glpi_profiles_users`
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
if ($joinprofile) {
$query .= " LEFT JOIN `glpi_profiles`
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
}
if ($count) {
$query .= " WHERE $where ";
} else {
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
Search::makeTextSearch($search).")";
}
$query .= " WHERE $where ";
if ($_SESSION["glpinames_format"] == FIRSTNAME_BEFORE) {
$query.=" ORDER BY `glpi_users`.`firstname`,
`glpi_users`.`realname`,
`glpi_users`.`name` ";
} else {
$query.=" ORDER BY `glpi_users`.`realname`,
`glpi_users`.`firstname`,
`glpi_users`.`name` ";
}
if ($search != $CFG_GLPI["ajax_wildcard"]) {
$query .= " LIMIT 0,".$CFG_GLPI["dropdown_max"];
}
}
return $DB->query($query);
}
/**
* Make a select box with all glpi users where select key = name
*
* Parameters which could be used in options array :
* - name : string / name of the select (default is users_id)
* - right : string / limit user who have specific right :
* id -> only current user (default case);
* interface -> central ;
* all -> all users ;
* specific right like show_all_ticket, create_ticket....
* - comments : boolean / is the comments displayed near the dropdown (default true)
* - entity : integer or array / restrict to a defined entity or array of entities
* (default -1 : no restriction)
* - entity_sons : boolean / if entity restrict specified auto select its sons
* only available if entity is a single value not an array(default false)
* - all : Nobody or All display for none selected
* all=0 (default) -> Nobody
* all=1 -> All
* all=-1-> nothing
* - rand : integer / already computed rand value
* - toupdate : array / Update a specific item on select change on dropdown
* (need value_fieldname, to_update, url (see Ajax::updateItemOnSelectEvent for informations)
* and may have moreparams)
* - used : array / Already used items ID: not to display in dropdown (default empty)
* - on_change : string / value to transmit to "onChange"
*
* @param $options possible options
*
* @return nothing (print out an HTML select box)
**/
static function dropdown($options=array()) {
global $DB, $CFG_GLPI, $LANG;
// Default values
$p['name'] = 'users_id';
$p['value'] = '';
$p['right'] = 'id';
$p['all'] = 0;
$p['on_change'] = '';
$p['comments'] = 1;
$p['entity'] = -1;
$p['entity_sons'] = false;
$p['used'] = array();
$p['ldap_import'] = false;
$p['toupdate'] = '';
$p['rand'] = mt_rand();
$p['pmTaskId'] = 0 ;
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$p[$key] = $val;
}
}
if (!($p['entity']<0) && $p['entity_sons']) {
if (is_array($p['entity'])) {
echo "entity_sons options is not available with array of entity";
} else {
$p['entity'] = getSonsOf('glpi_entities',$p['entity']);
}
}
// Make a select box with all glpi users
$use_ajax = false;
if ($CFG_GLPI["use_ajax"]) {
$res = self::getSqlSearchResult ($p['pmTaskId'], true, $p['right'], $p['entity'], $p['value'], $p['used']);
//$res = self::getSqlSearchResult ($taskId, true, $p['value'], $p['used']);
$nb = ($res ? $DB->result($res,0,"cpt") : 0);
if ($nb > $CFG_GLPI["ajax_limit_count"]) {
$use_ajax = true;
}
}
$user = getUserName($p['value'],2);
$default_display = "<select id='dropdown_".$p['name'].$p['rand']."' name='".$p['name']."'>";
$default_display .= "<option value='".$p['value']."'>";
$default_display .= Toolbox::substr($user["name"], 0, $_SESSION["glpidropdown_chars_limit"]);
$default_display .= "</option></select>";
$view_users = (Session::haveRight("user", "r"));
$params = array('searchText' => '__VALUE__',
'value' => $p['value'],
'myname' => $p['name'],
'all' => $p['all'],
'right' => $p['right'],
'comment' => $p['comments'],
'rand' => $p['rand'],
'on_change' => $p['on_change'],
'entity_restrict' => $p['entity'],
'used' => $p['used'],
'update_item' => $p['toupdate'],
'pmTaskId' => $p['pmTaskId']);
if ($view_users) {
$params['update_link'] = $view_users;
}
$default = "";
if (!empty($p['value']) && $p['value']>0) {
$default = $default_display;
} else {
$default = "<select name='".$p['name']."' id='dropdown_".$p['name'].$p['rand']."'>";
if ($p['all']) {
$default.= "<option value='0'>[ ".$LANG['common'][66]." ]</option></select>";
} else {
$default.= "<option value='0'>".Dropdown::EMPTY_VALUE."</option></select>\n";
}
}
Ajax::dropdown($use_ajax, "/plugins/processmaker/ajax/dropdownUsers.php", $params, $default, $p['rand']);
// Display comment
if ($p['comments']) {
if (!$view_users) {
$user["link"] = '';
} else if (empty($user["link"])) {
$user["link"] = $CFG_GLPI['root_doc']."/front/user.php";
}
Html::showToolTip($user["comment"],
array('contentid' => "comment_".$p['name'].$p['rand'],
'link' => $user["link"],
'linkid' => "comment_link_".$p["name"].$p['rand']));
}
if (Session::haveRight('import_externalauth_users','w')
&& $p['ldap_import']
&& EntityData::isEntityDirectoryConfigured($_SESSION['glpiactive_entity'])) {
echo "<img alt='' title=\"".$LANG['ldap'][35]."\" src='".$CFG_GLPI["root_doc"].
"/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'
onClick=\"var w = window.open('".$CFG_GLPI['root_doc'].
"/front/popup.php?popup=add_ldapuser&amp;rand=".$p['rand']."&amp;entity=".
$_SESSION['glpiactive_entity']."' ,'glpipopup', 'height=400, ".
"width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
}
return $p['rand'];
}
}

View File

@@ -1,11 +1,18 @@

var oldHandler ;
var submitButton ;
function onClickContinue( obj ) {
var submitButton;
var caseIFrame;
function onClickContinue(obj) {
//debugger;
// call old handler
if (obj != undefined && oldHandler)
oldHandler(obj.target);
submitButton.click() ;
// hide the iFrame
caseIFrame.style.visibility = 'hidden';
// call new handler
submitButton.click();
}
@@ -39,11 +46,11 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
var linkList = contentDocument.getElementsByTagName('a');
if (txtAreaUseRequestSumUp != undefined) { // !bAreaUseRequestSumUp &&
//bAreaUseRequestSumUp = true; // to prevent multiple adds
Ext.select("textarea[name='content']").elements[0].value = txtAreaUseRequestSumUp.value;
if (txtAreaUseRequestSumUp != undefined) {
//debugger;
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
} else
Ext.select("textarea[name='content']").elements[0].value = '_';
$("textarea[name='content']")[0].value = '_';
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) {
bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
@@ -61,13 +68,13 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
buttonContinue.onclick = onClickContinue;
submitButton = Ext.select("input[name='add'][type=submit]").elements[0];
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_delindex' value='" + delIndex + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
Ext.select("input[name='name'][type=text]").elements[0].value = processName;
$("input[name='name'][type=text]")[0].value = processName;
}
@@ -75,7 +82,7 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
// try to redim caseIFrame
if (!redimIFrame) {
var locElt = contentDocument.getElementsByTagName("form")[0];
var newHeight = (locElt.clientHeight < 100 ? 100 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
caseIFrame.height = newHeight;
redimIFrame = true;
}

View File

@@ -29,14 +29,14 @@ function showMask(elt) {
};
function onTaskFrameLoad(delIndex) {
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
//alert("Loaded frame " + delIndex);
var taskFrameId = "caseiframe-" + delIndex;
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
var bShowHideNextStep = false ; // not done yet!
var bHideClaimCancelButton = false; // To manage 'Claim' button
var taskFrameTimerCounter = 0;
var redimIFrame = false;
//debugger;
var taskFrameTimer = window.setInterval(function () {
try {
var locContentDocument;
@@ -63,9 +63,17 @@ function onTaskFrameLoad(delIndex) {
var action = node.action.split('?');
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
// add an element that will be the csrf data code for the POST
//debugger;
var csrfElt = document.createElement("input");
csrfElt.setAttribute("type", "hidden");
csrfElt.setAttribute("name", "_glpi_csrf_token") ;
csrfElt.setAttribute("value", csrf) ;
node.appendChild(csrfElt);
// try to add showMask function to submit event
//locElt.addEventListener( 'click', showMask ); // it is not good if a validation error occurs
node.addEventListener('submit', showMask, true);
// TODO
//node.addEventListener('submit', showMask, true);
} else {
// then hide the button itself
locElt.style.display = 'none';
@@ -78,16 +86,22 @@ function onTaskFrameLoad(delIndex) {
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
if (cancelButton != undefined && !bHideClaimCancelButton) {
cancelButton.style.display = 'none';
// hides claim button if asked for
if (hideClaimButton) {
claimButton = locContentDocument.getElementById('form[BTN_CATCH]');
claimButton.style.display = 'none';
}
// to manage Claim
var formList = locContentDocument.getElementsByTagName('form');
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
var action = node.action.split('?');
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
bHideClaimCancelButton = true;
node.addEventListener('submit', showMask);
// TODO
//node.addEventListener('submit', showMask);
}
// to force immediat reload of GLPI item form
// to force immediate reload of GLPI item form
var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD');
if (forcedReload != undefined && !GLPI_DURING_RELOAD) {
//showMask();
@@ -98,10 +112,17 @@ function onTaskFrameLoad(delIndex) {
// try to redim caseIFrame
if (!redimIFrame) {
var newHeight;
var locElt = locContentDocument.getElementsByTagName("table")[0];
var newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
if (locElt && locElt.offsetParent)
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
else {
locElt = locContentDocument.getElementsByTagName("form")[0];
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetTop ;
}
//locElt.clientHeight = newHeight; // don't know if this is neccessary!!! --> bugs on IE8
tabs.getItem('task-' + delIndex).setHeight(newHeight);
//NOT NEEDED WITH jQuery: var elts = $('#processmakertabpanel').tabs();//.getItem('task-' + delIndex).setHeight(newHeight);
//debugger;
taskFrame.height = newHeight ;
redimIFrame = true;
}
@@ -141,11 +162,14 @@ function clearClass(lociFrame) {
}, 10);
}
function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
var otherFrameId = frameName; //tabPanelName ; //+ 'Frame';
function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
var otherFrameId = frameName;
var otherFrameTimerCounter = 0;
var redimIFrame = false;
//debugger;
if (isMap3 == undefined)
isMap3 = false;
var otherFrameTimer = window.setInterval(function () {
try {
@@ -161,17 +185,38 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
// try to redim otherFrame
// and tabPanel
if (!redimIFrame) {
var locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
var locElt;
// isMap3 == true
// map is bpmn
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div
if (!isMap3) {
if (tabPanelName == 'caseMap') {
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
locElt2 = locContentDocument.getElementById('pm_target');
locElt2.style.height = locElt.clientHeight + 'px';
} else {
locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
}
} else {
locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0];
}
if (locElt != undefined) {
var newHeight ;
var newHeight;
if (isMap3) {
locElt.offsetParent.style.top = 0;
locElt.offsetParent.style.width = locElt.offsetWidth + locElt.offsetLeft + 'px';
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
}
if (locElt.offsetParent)
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
newHeight = (locElt.offsetHeight < 400 ? 400 : locElt.offsetHeight) + locElt.offsetParent.offsetTop ;
else
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) ;
if (locElt.scrollHeight && locElt.scrollHeight > newHeight )
newHeight = locElt.scrollHeight ;
tabs.getItem(tabPanelName).setHeight(newHeight);
otherFrame.height = newHeight;
newHeight = (locElt.offsetHeight < 400 ? 400 : locElt.offsetHeight) ;
if (locElt.scrollHeight && locElt.scrollHeight > newHeight)
newHeight = locElt.scrollHeight;
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
otherFrame.height = newHeight ;
redimIFrame = true;
}
}
@@ -190,3 +235,5 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
}

View File

@@ -12,52 +12,29 @@ if (!defined('GLPI_ROOT')) {
die("Can not access directly to this file");
}
echo "Ext.onReady(function () {
echo "$(function () {
function showMask(){Ext.getBody().moveTo( 0, 0); var myMask = new Ext.LoadMask(Ext.getBody(), {removeMask:false}); myMask.show();};
/*function showMask(){Ext.getBody().moveTo( 0, 0); var myMask = new Ext.LoadMask(Ext.getBody(), {removeMask:false}); myMask.show();};*/
// look if name='helpdeskform' is present. If yes replace the form.location
var ahrefTI = '".$CFG_GLPI["root_doc"]."/plugins/processmaker/front/tracking.injector.php';
var formLink = Ext.select(\"form[name='helpdeskform']\").elements[0];
var formLink = $(\"form[name='helpdeskform']\")[0];
if (formLink != undefined) {
formLink.action = ahrefTI;
}
var ticketType = Ext.select(\"select[name='type']\").elements[0];
/*
var ticketType = $(\"select[name='type']\")$[0];
if (ticketType != undefined) {
ticketType.addEventListener( 'change', showMask );
}
var ticketCat = Ext.select(\"select[name='itilcategories_id']\").elements[0];
var ticketCat = $(\"select[name='itilcategories_id']\")[0];
if (ticketCat!= undefined) {
ticketCat.addEventListener( 'change', showMask );
}
*/
});
"; // end of echo
//Ext.onReady(function () {
// var ahref = "../plugins/processmaker/front/processmaker.helpdesk.form.php";
// var markup = '';
// // look for menu id = menu2 to insert a new menu
// var createTicketMenu = Ext.get('menu2');
// if (createTicketMenu != undefined) {
// markup = '<li id="menu2"><a href="' + ahref + '" class="itemP" title="Create User ticket">Create User ticket</a></li>';
// Ext.DomHelper.insertAfter(createTicketMenu, markup)
// }
// // look for 'Create a ticket' in order to insert a link <a>
// var ticketLink = Ext.select('table.tab_cadrehov tbody tr th a').elements[0];
// if (ticketLink != undefined) {
// var img = Ext.select('table.tab_cadrehov tbody tr th a img').elements[0];
// // add a link to the user management screen
// markup = '&nbsp;<a href="' + ahref + '">User Management Ticket<img src="' + img.attributes["src"].value + '"></a>';
// Ext.DomHelper.insertAfter(ticketLink, markup)
// //window.clearInterval(ticketTimer)
// }
//});
?>

View File

@@ -1,34 +1,56 @@
<?php
$LANG['processmaker']['title'][1]="Process Maker";
$LANG['processmaker']['title'][1]="ProcessMaker";
$LANG['processmaker']['title'][2]="Process";
$LANG['processmaker']['title'][3]="Task List";
$LANG['processmaker']['title'][4]="Authorizations";
$LANG['processmaker']['profile']['rightmgt']="Rights Management";
$LANG['processmaker']['profile']['process_config']="Process configuration";
$LANG['processmaker']['profile']['case_delete']="Delete 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']['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";
$LANG['processmaker']['process']['insert_task_comment']="Insert Task Category comments in Task Description";
$LANG['processmaker']['process']['type']="Type (helpdesk)";
$LANG['processmaker']['process']['itilcategory']="ITIL Category (helpdesk)";
$LANG['processmaker']['process']['type']="Ticket type (self-service)";
$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']['comment']="Comment";
$LANG['processmaker']['process']['profile']="Delete permanently";
$LANG['processmaker']['config']['name']="Name";
$LANG['processmaker']['config']['URL']="Process Maker Server URL";
$LANG['processmaker']['config']['setup']="ProcessMaker setup";
$LANG['processmaker']['config']['mysql']="SQL server setup";
$LANG['processmaker']['config']['URL']="Server URL";
//$LANG['processmaker']['config']['db_server']="mySQL server";
//$LANG['processmaker']['config']['db_user']="mySQL user";
//$LANG['processmaker']['config']['db_password']="mySQL password (leave blank if unchanged)";
//$LANG['processmaker']['config']['admin_user']="PM administrator user";
//$LANG['processmaker']['config']['admin_password']="PM administrator password (leave blank if unchanged)";
$LANG['processmaker']['config']['workspace']="Workspace Name";
$LANG['processmaker']['config']['admin']['user']="Server administrator name";
$LANG['processmaker']['config']['admin']['password']="Server administrator password";
$LANG['processmaker']['config']['theme']="Theme Name";
$LANG['processmaker']['config']['comments']="Comments";
$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 Process Maker which contains all GLPI users (lang : name)";
$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!";
$LANG['processmaker']['config']['test']="Test";
$LANG['processmaker']['config']['connectionstatus']="Connection status";
$LANG['processmaker']['item']['tab']="Process - Case";
$LANG['processmaker']['item']['cancelledcase']="Status: Cancelled";
@@ -56,13 +78,15 @@ $LANG['processmaker']['item']['case']['notreassigned']="Error re-assigning task:
$LANG['processmaker']['item']['case']['assignedtoyou']="Task already assigned to this person!";
$LANG['processmaker']['item']['case']['reassigned']="Task re-assigned!";
$LANG['processmaker']['item']['case']['casemap']="Case map";
$LANG['processmaker']['item']['case']['casehistory']='Case History' ;
$LANG['processmaker']['item']['case']['casehistory']='Case history' ;
$LANG['processmaker']['item']['case']['dynaforms']='Dynaforms';
$LANG['processmaker']['item']['case']['changelog']='Change Log';
$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']['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']['casechangeloghistory']='Change log history' ;
$LANG['processmaker']['item']['error'][11]="Error creating case!";
$LANG['processmaker']['item']['error'][14]="Can't create case: no rights for it!";
@@ -74,7 +98,7 @@ $LANG['processmaker']['item']['task']['process']="Bound to process: ";
$LANG['processmaker']['item']['task']['case']="Case title: ";
$LANG['processmaker']['item']['task']['task']="Task: ";
$LANG['processmaker']['item']['task']['comment']="##processmaker.taskcomment##" ;
$LANG['processmaker']['item']['task']['manage']="##ticket.url##_PluginProcessmakerCases\$processmakercases" ; //"Go to: ##ticket.url##_PluginProcessmakerCases\$processmakercases" ;
$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";
@@ -90,3 +114,6 @@ $LANG['processmaker']['search']['hascase']="Running Case?";
$LANG['processmaker']['cron']['pmusers']="Syncs GLPI users and pseudo-groups into ProcessMaker." ;
$LANG['processmaker']['cron']['pmnotifications']="Notifications for GLPI Tasks bound to ProcessMaker Tasks." ;
$LANG['processmaker']['cron']['pmorphancases']['description']="Cleaning of orphan cases." ;
$LANG['processmaker']['cron']['pmorphancases']['parameter']="Number of days to keep orphan cases";

View File

@@ -1,34 +1,56 @@
<?php
$LANG['processmaker']['title'][1]="Process Maker";
$LANG['processmaker']['title'][1]="ProcessMaker";
$LANG['processmaker']['title'][2]="Processus";
$LANG['processmaker']['title'][3]="Liste des tâches";
$LANG['processmaker']['title'][4]="Autorisations";
$LANG['processmaker']['profile']['rightmgt']="Gestion des droits";
$LANG['processmaker']['profile']['process_config']="Configuration des Processus";
$LANG['processmaker']['profile']['case_delete']="Supprimer cas";
$LANG['processmaker']['process']['process_guid']="GUID du Processus";
$LANG['processmaker']['process']['project_type_short']="Type de projet" ;
$LANG['processmaker']['process']['project_type']="Type de projet (à modifier si pas à jour)" ;
$LANG['processmaker']['process']['project_type_bpmn']='BPMN' ;
$LANG['processmaker']['process']['project_type_classic']='Classique' ;
$LANG['processmaker']['process']['taskcategories']['guid']="GUID de la Tâche";
$LANG['processmaker']['process']['hide_case_num_title_short']="Masquer numéro et titre des Cas";
$LANG['processmaker']['process']['hide_case_num_title']="Masquer numéro et titre des Cas dans les descriptions des tâches";
$LANG['processmaker']['process']['insert_task_comment_short']="Insérer Catégories de Tâches";
$LANG['processmaker']['process']['insert_task_comment']="Insérer les commentaires des Catégories de Tâches dans les descriptions des Tâches";
$LANG['processmaker']['process']['type']="Type (helpdesk)";
$LANG['processmaker']['process']['itilcategory']="Catégorie ITIL (helpdesk)";
$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']['comment']="Commentaire";
$LANG['processmaker']['process']['profile']="Effacer définitivement";
$LANG['processmaker']['config']['name']="Nom";
$LANG['processmaker']['config']['URL']="URL du serveur Process Maker";
$LANG['processmaker']['config']['setup']="Configuration du serveur ProcessMaker";
$LANG['processmaker']['config']['mysql']="Configuration du serveur SQL";
$LANG['processmaker']['config']['URL']="URL du serveur";
//$LANG['processmaker']['config']['db_server']="Serveur mySQL";
//$LANG['processmaker']['config']['db_user']="Utilisateur mySQL";
//$LANG['processmaker']['config']['db_password']="Mot de passe mySQL (vide si inchangé)";
//$LANG['processmaker']['config']['admin_user']="Administrateur de PM";
//$LANG['processmaker']['config']['admin_password']="Mot de passed de l'administrateur de PM (vide si inchangé)";
$LANG['processmaker']['config']['workspace']="Nom du Workspace";
$LANG['processmaker']['config']['admin']['user']="Non de l'administreur du server ProcessMaker";
$LANG['processmaker']['config']['admin']['password']="Mot de passe de l'administrateur du serveur ProcessMaker";
$LANG['processmaker']['config']['theme']="Nom du Theme";
$LANG['processmaker']['config']['comments']="Commentaires";
$LANG['processmaker']['config']['refreshprocesslist']="Synchroniser la liste des Processus";
$LANG['processmaker']['config']['refreshprocesslist']="Synchroniser la liste des processus";
$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 Process Maker des utilisateurs de GLPI (les contient tous)";
$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']['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 !";
$LANG['processmaker']['config']['test']="Test";
$LANG['processmaker']['config']['connectionstatus']="Status de la connexion";
$LANG['processmaker']['item']['tab']="Processus - Cas";
$LANG['processmaker']['item']['cancelledcase']="Statut : Annulé";
@@ -63,6 +85,8 @@ $LANG['processmaker']['item']['case']['caseinfo']='Infos du cas';
$LANG['processmaker']['item']['case']['viewcasemap']='Voir carte du cas';
$LANG['processmaker']['item']['case']['viewcasehistory']='Voir historique du cas';
$LANG['processmaker']['item']['case']['viewdynaforms']='Voir dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='Voir historique évolutions' ;
$LANG['processmaker']['item']['case']['casechangeloghistory']='Historique évolutions' ;
$LANG['processmaker']['item']['error'][11]="Erreur à la création du cas !";
$LANG['processmaker']['item']['error'][14]="Impossible de créer le cas : pas de droits pour cela !";
@@ -74,7 +98,7 @@ $LANG['processmaker']['item']['task']['process']="Lié au processus : ";
$LANG['processmaker']['item']['task']['case']="Titre du cas : ";
$LANG['processmaker']['item']['task']['task']="Tâche : ";
$LANG['processmaker']['item']['task']['comment']="##processmaker.taskcomment##" ;
$LANG['processmaker']['item']['task']['manage']="##ticket.url##_PluginProcessmakerCases\$processmakercases" ;; //"Allez à : ##ticket.url##_PluginProcessmakerCases\$processmakercases" ;
$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";
@@ -90,3 +114,5 @@ $LANG['processmaker']['search']['hascase']="Cas en cours ?";
$LANG['processmaker']['cron']['pmusers']="Synchro des utilisateurs GLPI et des pseudo-groups avec ProcessMaker." ;
$LANG['processmaker']['cron']['pmnotifications']="Notifications des tâches GLPI liées à des tâches de ProcessMaker." ;
$LANG['processmaker']['cron']['pmorphancases']['description']="Nettoyage des cas orphelins." ;
$LANG['processmaker']['cron']['pmorphancases']['parameter']="Nombre de jours avant nettoyage des cas orphelins.";

View File

@@ -23,8 +23,8 @@
</authors>
<versions>
<version>
<num>2.4.1</num>
<compatibility>0.83</compatibility>
<num>3.0.0</num>
<compatibility>9.1</compatibility>
</version>
</versions>
<langs>

208
setup.php
View File

@@ -3,114 +3,111 @@
// Init the hooks of the plugins -Needed
function plugin_init_processmaker() {
global $PLUGIN_HOOKS, $CFG_GLPI;
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
Plugin::registerClass('PluginProcessmakerProcessmaker');//, array(
// 'notificationtemplates_types' => true,
// 'addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerCases', array(
'notificationtemplates_types' => true,
'addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerTaskCategory');
if (Session::haveRight('config','w')) {
Plugin::registerClass('PluginProcessmakerConfig', array('addtabon' => 'Config'));
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
}
Plugin::registerClass('PluginProcessmakerProfile',
array('addtabon' => 'Profile'));
$PLUGIN_HOOKS['change_profile']['processmaker'] = array('PluginProcessmakerProfile','select');
Plugin::registerClass('PluginProcessmakerProcess_Profile');
$plugin = new Plugin();
if ($plugin->isInstalled('processmaker')
&& $plugin->isActivated('processmaker')
&& Session::getLoginUserID() ) {
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
Plugin::registerClass('PluginProcessmakerProcessmaker');//, array(
// 'notificationtemplates_types' => true,
// 'addtabon' => array('Ticket')));
// tabs management
//$PLUGIN_HOOKS['headings']['processmaker'] = 'plugin_get_headings_processmaker';
//$PLUGIN_HOOKS['headings_action']['processmaker'] = 'plugin_headings_actions_processmaker';
Plugin::registerClass('PluginProcessmakerCase', array(
'notificationtemplates_types' => true,
'addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerTaskCategory');
$PLUGIN_HOOKS['canedit']['processmaker']
= array('TicketTask' => array('PluginProcessmakerProcessmaker',
'canedit_item_processmakertickettask'));
if (Session::haveRight('config', UPDATE)) {
Plugin::registerClass('PluginProcessmakerConfig', array('addtabon' => 'Config'));
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
}
Plugin::registerClass('PluginProcessmakerProfile',
array('addtabon' => 'Profile'));
$PLUGIN_HOOKS['change_profile']['processmaker'] = array('PluginProcessmakerProfile','select');
Plugin::registerClass('PluginProcessmakerProcess_Profile');
$PLUGIN_HOOKS['pre_show_item']['processmaker']
= array('Ticket' => array('PluginProcessmakerProcessmaker',
'pre_show_item_processmakerticket'));
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
$PLUGIN_HOOKS['post_show_item']['processmaker']
= array('Ticket' => array('PluginProcessmakerProcessmaker',
'post_show_item_processmakerticket'));
// tabs management
//$PLUGIN_HOOKS['headings']['processmaker'] = 'plugin_get_headings_processmaker';
//$PLUGIN_HOOKS['headings_action']['processmaker'] = 'plugin_headings_actions_processmaker';
// $PLUGIN_HOOKS["helpdesk_menu_entry"]['processmaker'] = '/front/processmaker.helpdesk.form.php';
//$PLUGIN_HOOKS['canedit']['processmaker']
//= array('TicketTask' => array('PluginProcessmakerProcessmaker',
// 'canedit_item_processmakertickettask'));
// Display a menu entry ?
if (plugin_processmaker_haveRight("process_config","r")) {
$PLUGIN_HOOKS['menu_entry']['processmaker'] = 'front/process.php';
$PLUGIN_HOOKS['submenu_entry']['processmaker']['search'] = 'front/process.php';
}
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) ) ;
//$CFG_GLPI["massiveaction_nodelete_types"][] = 'PluginProcessmakerProcess' ;
$PLUGIN_HOOKS['pre_show_item']['processmaker']
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
// Config page
//if (Session::haveRight('config','w')) {
// $PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
//}
/*,
'TicketFollowup' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker_followup') */
$PLUGIN_HOOKS['post_show_item']['processmaker']
= array('Ticket' => array('PluginProcessmakerProcessmaker',
'post_show_item_processmakerticket'));
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
// Display a menu entry ?
if (Session::haveRight('config', READ) ) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
}
);
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) ) ;
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
'Ticket' => 'plugin_pre_item_update_processmaker'
);
// , 'TicketFollowup' => 'plugin_pre_item_update_processmaker_followup'
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction'
);
);
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker')
);
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
'Ticket' => 'plugin_pre_item_update_processmaker'
);
// , 'TicketFollowup' => 'plugin_pre_item_update_processmaker_followup'
$PLUGIN_HOOKS['item_get_datas']['processmaker'] = array(
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
);
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction'
);
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker')
);
$PLUGIN_HOOKS['item_get_datas']['processmaker'] = array(
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
);
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
) ;
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_item_purge_processmaker'
) ;
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
) ;
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_item_purge_processmaker'
) ;
$url = explode("/", $_SERVER['PHP_SELF']);
$pageName = explode("?", array_pop($url));
switch($pageName[0]) {
case "tracking.injector.php":
case "helpdesk.public.php":
//$plug = new Plugin;
//if( !$plug->isActivated('rayusermanagementticket') )
$url = explode("/", $_SERVER['PHP_SELF']);
$pageName = explode("?", array_pop($url));
switch($pageName[0]) {
case "tracking.injector.php":
case "helpdesk.public.php":
//$plug = new Plugin;
//if( !$plug->isActivated('rayusermanagementticket') )
$PLUGIN_HOOKS['add_javascript']['processmaker'] = "js/helpdesk.public.js.php";
break;
break;
}
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
//$PLUGIN_HOOKS['planning_populate']['processmaker'] = "plugin_planning_populate_processmaker"; // used for task descriptions
$CFG_GLPI['planning_types'][] = 'PluginProcessmakerTask';
$PLUGIN_HOOKS['post_init']['processmaker'] = 'plugin_processmaker_post_init';
}
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
//$PLUGIN_HOOKS['planning_populate']['processmaker'] = "plugin_planning_populate_processmaker"; // used for task descriptions
}
// Get the name and the version of the plugin - Needed
@@ -118,53 +115,44 @@ function plugin_version_processmaker(){
global $LANG;
return array ('name' => 'Process Maker',
'version' => '2.4.1',
'version' => '3.0.0',
'author' => 'Olivier Moron',
'homepage' => '',
'minGlpiVersion' => '0.83.8');
'minGlpiVersion' => '0.85.0');
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_processmaker_check_prerequisites(){
if (version_compare(GLPI_VERSION,'0.83.8','lt') || version_compare(GLPI_VERSION,'0.84','ge')) {
echo "This plugin requires GLPI 0.83.8 or higher";
if (version_compare(GLPI_VERSION,'0.85','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
echo "This plugin requires GLPI 0.85.0 or higher";
return false;
}
$plug = new Plugin ;
if (!$plug->isActivated('mhooks') || version_compare( $plug->fields['version'], '1.1.0', '<')) {
echo "'mhooks 1.1.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
return false;
}
//$plug = new Plugin ;
//if (!$plug->isActivated('mhooks') || version_compare( $plug->fields['version'], '1.2.0', '<')) {
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
// return false;
//}
return true;
}
function plugin_processmaker_check_config($verbose = false){
$plug = new Plugin ;
if ($plug->isActivated('mhooks') && version_compare( $plug->fields['version'], '1.1.0', '>=')) {
return true;
}
// $plug = new Plugin ;
// if ($plug->isActivated('mhooks') && version_compare( $plug->fields['version'], '1.2.0', '>=')) {
// return true;
// }
if ($verbose) {
echo "'mhooks 1.1.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
}
// if ($verbose) {
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
// }
return false;
//return false;
return true;
}
function plugin_processmaker_haveRight($module,$right) {
$matches=array("" => array("", "r", "w"), // should never happend
"r" => array("r", "w"),
"w" => array("w"),
"1" => array("1"),
"0" => array("0", "1")); // should never happend;
if (isset($_SESSION["glpi_plugin_processmaker_profile"][$module])
&& in_array($_SESSION["glpi_plugin_processmaker_profile"][$module], $matches[$right])) {
return true;
} else {
return false;
}
return Session::haveRight("plugin_processmaker_".$module, $right) ;
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB