RC1
This commit is contained in:
50
ajax/asynchronousdatas.php
Normal file
50
ajax/asynchronousdatas.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if (strpos($_SERVER['PHP_SELF'],"asynchronousdatas.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
//header("Content-Type: text/html; charset=UTF-8");
|
||||
header("Content-Type: application/json; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not access directly to this file");
|
||||
}
|
||||
|
||||
//include_once dirname(__FILE__)."/../inc/asynchronousdata.class.php" ;
|
||||
include_once dirname(__FILE__)."/../inc/crontaskaction.class.php" ;
|
||||
|
||||
if( isset($_SERVER['REQUEST_METHOD']) ) {
|
||||
switch($_SERVER['REQUEST_METHOD']) {
|
||||
//case 'OPTIONS' :
|
||||
// header("Access-Control-Allow-Origin: *") ;
|
||||
// header("Access-Control-Allow-Methods: POST");
|
||||
// header("Access-Control-Allow-Headers: Content-Type");
|
||||
// break ;
|
||||
case 'POST' :
|
||||
//header("Access-Control-Allow-Origin: *") ;
|
||||
//header("Content-Type: application/json; charset=UTF-8");
|
||||
|
||||
$request_body = file_get_contents('php://input');
|
||||
$datas = json_decode($request_body, true);
|
||||
|
||||
// $asyncdata = new PluginProcessmakerAsynchronousdata ;
|
||||
$asyncdata = new PluginProcessmakerCrontaskaction ;
|
||||
if( isset($datas['id']) && $asyncdata->getFromDB( $datas['id'] ) && $asyncdata->fields['state'] == PluginProcessmakerCrontaskaction::WAITING_DATAS ) {
|
||||
$initialdatas = json_decode($asyncdata->fields['postdatas'], true);
|
||||
$initialdatas['form'] = array_merge( $initialdatas['form'], $datas['form'] ) ;
|
||||
$asyncdata->update( array( 'id' => $datas['id'], 'state' => PluginProcessmakerCrontaskaction::DATAS_READY, 'postdatas' => json_encode($initialdatas, JSON_HEX_APOS | JSON_HEX_QUOT) ) ) ;
|
||||
$ret = array( 'code' => '0', 'message' => 'Done' );
|
||||
} else {
|
||||
$ret = array( 'code' => '2', 'message' => 'Case is not existing, or state is not WAITING_DATAS' );
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
$ret = array( 'code' => '1', 'message' => 'Method not supported' ) ;
|
||||
}
|
||||
|
||||
echo json_encode( $ret, JSON_HEX_APOS | JSON_HEX_QUOT ) ;
|
||||
|
||||
}
|
||||
@@ -32,6 +32,10 @@ if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$one_item = -1;
|
||||
if (isset($_POST['_one_id'])) {
|
||||
$one_item = $_POST['_one_id'];
|
||||
}
|
||||
// Count real items returned
|
||||
$count = 0;
|
||||
|
||||
@@ -39,6 +43,7 @@ if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
|
||||
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
|
||||
}
|
||||
|
||||
$search="";
|
||||
if (!empty($_REQUEST['searchText'])) {
|
||||
$search = Search::makeTextSearch($_REQUEST['searchText']);
|
||||
}
|
||||
@@ -46,14 +51,14 @@ if (!empty($_REQUEST['searchText'])) {
|
||||
$processes = array();
|
||||
|
||||
// Empty search text : display first
|
||||
//if (empty($_REQUEST['searchText'])) {
|
||||
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);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
define('DO_NOT_CHECK_HTTP_REFERER', 1);
|
||||
//define('DO_NOT_CHECK_HTTP_REFERER', 1);
|
||||
include_once '../../../inc/includes.php';
|
||||
//include_once '../inc/processmaker.class.php' ;
|
||||
//include_once '../inc/case.class.php' ;
|
||||
@@ -13,119 +13,8 @@ if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUE
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
if( isset( $_REQUEST['form'] ) ) {
|
||||
// save the case variables
|
||||
//$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , $_REQUEST['form'] ) ;
|
||||
$resultSave = $myProcessMaker->saveForm( $_REQUEST, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
//$myCase->sendVariables( $_REQUEST['form'] ) ;
|
||||
|
||||
// now derivate the case !!!
|
||||
$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
|
||||
$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" => '',
|
||||
"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() ;
|
||||
|
||||
// now manage tasks associated with item
|
||||
$itemType = $myCase->getField('itemtype');
|
||||
$itemId = $myCase->getField('items_id');
|
||||
|
||||
// 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, 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 ) ) ;
|
||||
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ switch( $_POST["action"] ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, 'GLPI_SELFSERVICE_CREATED' => '1') ) ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, 'GLPI_SELFSERVICE_CREATED' => '1', 'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ) ;
|
||||
if ($resultCase->status_code == 0){
|
||||
// case is created
|
||||
// Must show it...
|
||||
//
|
||||
$rand = rand( ) ;
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]);
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
|
||||
|
||||
} 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";
|
||||
|
||||
@@ -20,8 +20,10 @@ function processMakerShowProcessList ($ID, $from_helpdesk) {
|
||||
echo "<input type='hidden' name='action' value='newcase'>";
|
||||
echo "<input type='hidden' name='id' value='-1'>";
|
||||
echo "<input type='hidden' name='itemtype' value='Ticket'>";
|
||||
echo "<input type='hidden' name='itilcategories_id' value='".$_REQUEST['itilcategories_id']."'>";
|
||||
echo "<input type='hidden' name='type' value='".$_REQUEST['type']."'>";
|
||||
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1 and is_helpdeskvisible=1")); // condition is used to prevent start of none-active and none-helpdesk-visible cases
|
||||
PluginProcessmakerProcess::dropdown( array( 'entity' => $_SESSION['glpiactive_entity'], 'name' => 'plugin_processmaker_process_id' ));
|
||||
PluginProcessmakerProcess::dropdown( array( 'value' => 0, 'entity' => $_SESSION['glpiactive_entity'], 'name' => 'plugin_processmaker_process_id' ));
|
||||
echo "</td><td class='center'>";
|
||||
echo "<input type='submit' name='additem' value='Start' class='submit'>";
|
||||
echo "</td></tr>";
|
||||
@@ -907,7 +909,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
}
|
||||
|
||||
$email = UserEmail::getDefaultForUser($ID);
|
||||
$default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
|
||||
$default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_REQUEST['entities_id'], '', 1);
|
||||
|
||||
// Set default values...
|
||||
$default_values = array('_users_id_requester_notif'
|
||||
@@ -925,12 +927,12 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
'urgency' => 3,
|
||||
|
||||
'items_id' => 0,
|
||||
'entities_id' => $_SESSION['glpiactive_entity'],
|
||||
'entities_id' => $_REQUEST['entities_id'],
|
||||
'plan' => array(),
|
||||
'global_validation' => CommonITILValidation::NONE,
|
||||
'_add_validation' => 0,
|
||||
'type' => Entity::getUsedConfig('tickettype',
|
||||
$_SESSION['glpiactive_entity'],
|
||||
$_REQUEST['entities_id'],
|
||||
'', Ticket::INCIDENT_TYPE),
|
||||
'_right' => "id",
|
||||
'_filename' => array(),
|
||||
@@ -1018,7 +1020,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
'use_notification'
|
||||
=> $values['_users_id_requester_notif']['use_notification'],
|
||||
'entity_restrict'
|
||||
=> $_SESSION["glpiactive_entity"]);
|
||||
=> $_REQUEST['entities_id']);
|
||||
|
||||
Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand,
|
||||
$CFG_GLPI["root_doc"]."/ajax/dropdownDelegationUsers.php",
|
||||
@@ -1074,7 +1076,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
// Load ticket template if available :
|
||||
$tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'],
|
||||
$values['itilcategories_id'],
|
||||
$_SESSION["glpiactive_entity"]);
|
||||
$_REQUEST['entities_id']);
|
||||
|
||||
// Predefined fields from template : reset them
|
||||
if (isset($values['_predefined_fields'])) {
|
||||
@@ -1140,7 +1142,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
if ($tt->isHiddenField('locations_id')) {
|
||||
echo "<input type='hidden' name='locations_id' value='".$values['locations_id']."'>";
|
||||
}
|
||||
echo "<input type='hidden' name='entities_id' value='".$_SESSION["glpiactive_entity"]."'>";
|
||||
echo "<input type='hidden' name='entities_id' value='".$_REQUEST['entities_id']."'>";
|
||||
echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
|
||||
echo "<div class='center'><table class='tab_cadre_fixe'>";
|
||||
|
||||
@@ -1148,7 +1150,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
echo "<tr><th width='30%'>".$caseInfo->processName."</th><th>";
|
||||
//echo "<tr><th>".__('Describe the incident or request')."</th><th>";
|
||||
if (Session::isMultiEntitiesMode()) {
|
||||
echo "(".Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]).")";
|
||||
echo "(".Dropdown::getDropdownName("glpi_entities", $_REQUEST['entities_id']).")";
|
||||
}
|
||||
echo "</th></tr>";
|
||||
|
||||
@@ -1175,7 +1177,7 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
|
||||
}
|
||||
$opt = array('value' => $values['itilcategories_id'],
|
||||
'condition' => $condition,
|
||||
'entity' => $_SESSION["glpiactive_entity"],
|
||||
'entity' => $_REQUEST['entities_id'],
|
||||
'on_change' => 'this.form.submit()');
|
||||
|
||||
if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
|
||||
@@ -1517,8 +1519,9 @@ if (isset($_REQUEST['case_id'])) {
|
||||
processMakerShowProcessList(Session::getLoginUserID(), 1);
|
||||
else {
|
||||
// before showing the case, we must check the rights for this user to view it, if entity has been changed in the meanwhile
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_REQUEST["itilcategories_id"], $_REQUEST["type"], $_SESSION['glpiactiveprofile']['id'], $_SESSION['glpiactive_entity'] ) ;
|
||||
if( in_array_recursive( $_REQUEST['process_id'], $processList ) ) {
|
||||
// and must check if entity of the ticket is in the tree of authorized entities for current profile
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_REQUEST["itilcategories_id"], $_REQUEST["type"], $_SESSION['glpiactiveprofile']['id'], $_REQUEST['entities_id'] ) ;
|
||||
if( in_array( $_REQUEST['entities_id'], $_SESSION['glpiactiveentities']) && in_array_recursive( $_REQUEST['process_id'], $processList ) ) {
|
||||
processMakerShowCase(Session::getLoginUserID(), 1);
|
||||
} else {
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
|
||||
|
||||
@@ -28,7 +28,7 @@ if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
|
||||
// if not we will continue
|
||||
// special case if RUMT plugin is enabled and no process is available and category is 'User Management' then must start RUMT.
|
||||
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_POST["itilcategories_id"], $_POST["type"], $_SESSION['glpiactiveprofile']['id'], $_SESSION['glpiactive_entity'] ) ;
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_POST["itilcategories_id"], $_POST["type"], $_SESSION['glpiactiveprofile']['id'], $_POST["entities_id"] ) ;
|
||||
|
||||
// currently only one process should be assigned to this itilcategory so this array should contain only one row
|
||||
$processQt = count( $processList ) ;
|
||||
|
||||
279
hook.php
279
hook.php
@@ -310,7 +310,7 @@ 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
|
||||
if( !FieldExists( 'glpi_plugin_processmaker_processes', 'project_type') ) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';" ;
|
||||
|
||||
@@ -352,7 +352,6 @@ function plugin_processmaker_install() {
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
AUTO_INCREMENT=57
|
||||
;
|
||||
";
|
||||
|
||||
@@ -375,6 +374,66 @@ function plugin_processmaker_install() {
|
||||
// $config->update( array( 'id' => $config->getID(), 'taskcategories_id' => $pmCategory ) ) ;
|
||||
//}
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_crontaskactions")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_crontaskactions` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`plugin_processmaker_caselinks_id` INT(11) NULL DEFAULT NULL,
|
||||
`itemtype` VARCHAR(100) NOT NULL,
|
||||
`items_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`users_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`toclaim` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`postdatas` TEXT NULL DEFAULT NULL,
|
||||
`state` INT(11) NOT NULL ,
|
||||
`date_mod` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;" ;
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_crontaskactions" . $DB->error());
|
||||
}
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_caselinks")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_caselinks` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`is_active` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`is_externaldata` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '0:insert data from case,1:wait for external application to set datas',
|
||||
`is_self` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '0:use linked tickets, 1:use self',
|
||||
`sourcetask_guid` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`targettask_guid` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`targetprocess_guid` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`targetdynaform_guid` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`sourcecondition` TEXT NULL,
|
||||
`targettoclaim` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`externalapplication` TEXT NULL,
|
||||
`date_mod` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `is_active` (`is_active`),
|
||||
INDEX `is_externaldata` (`is_externaldata`),
|
||||
INDEX `is_self` (`is_self`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;" ;
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_caselinks" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_caselinkactions")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_caselinkactions` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`plugin_processmaker_caselinks_id` INT(11) NULL DEFAULT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`value` TEXT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `caselinks_id_name` (`plugin_processmaker_caselinks_id`, `name`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;" ;
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_caselinkactions" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
// no longer used since 2.6
|
||||
//$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
//$myProcessMaker->login(true) ; // to force admin login
|
||||
@@ -393,6 +452,7 @@ function plugin_processmaker_install() {
|
||||
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));
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmtaskactions', MINUTE_TIMESTAMP, array('state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
|
||||
|
||||
// required because autoload doesn't work for unactive plugin'
|
||||
@@ -641,3 +701,218 @@ function plugin_processmaker_giveItem($itemtype,$ID,$data,$num){
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of plugin_item_add_update_processmaker_tasks
|
||||
* @param mixed $parm
|
||||
*/
|
||||
function plugin_item_update_processmaker_tasks($parm){
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
// we need to test if a specific case is completed, and if so
|
||||
// we should complete the linked cases (via linked tickets)
|
||||
$pmTaskCat = new PluginProcessmakerTaskCategory ;
|
||||
if( $pmTaskCat->getFromDBbyCategory( $parm->fields['taskcategories_id'] )
|
||||
&& in_array( 'state', $parm->updates )
|
||||
&& $parm->input['state'] == 2) { // the task has just been set to DONE state
|
||||
|
||||
//$taskList = array( array( 'sourcetaskguid' => '54949951157c000b2336474053483376',
|
||||
// 'sourcecondition' => '@@RELEASE_DONE == 1' ,
|
||||
// 'targettaskguid' => '95599365257bffa6d6170d9068913760',
|
||||
// 'targetprocessguid' => '51126098657bd96b286ded7016691792',
|
||||
// 'targetdynaformguid' => '28421020557bffc5b374850018853291',
|
||||
// 'targettoclaim' => true,
|
||||
// 'targetactions' => array( 'RELEASE_DONE' => '@@RELEASE_DONE' )
|
||||
// ) ) ;
|
||||
|
||||
$itemtype = str_replace( 'Task', '', $parm->getType() ) ;
|
||||
|
||||
//foreach( $taskList as $targetTask ) {
|
||||
foreach( $DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask ) {
|
||||
|
||||
$srcCaseId = PluginProcessmakerProcessmaker::getCaseIdFromItem( $itemtype, $parm->fields['tickets_id']) ;
|
||||
|
||||
// Must check the condition
|
||||
$casevariables = array();
|
||||
$matches = array() ;
|
||||
if( preg_match_all( "/@@(\w+)/u", $targetTask['sourcecondition'], $matches ) ) {
|
||||
$casevariables = $matches[1] ;
|
||||
}
|
||||
//foreach( $targetTask['targetactions'] as $actionvalue ){
|
||||
foreach( $DB->request( 'glpi_plugin_processmaker_caselinkactions', 'plugin_processmaker_caselinks_id = '.$targetTask['id']) as $actionvalue ){
|
||||
$targetTask['targetactions'][$actionvalue['name']] = $actionvalue['value'];
|
||||
if( preg_match_all( "/@@(\w+)/u", $actionvalue['value'], $matches ) ) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] ) ;
|
||||
}
|
||||
}
|
||||
$externalapplication = false ; // by default
|
||||
if( $targetTask['is_externaldata'] && isset($targetTask['externalapplication']) ) {
|
||||
// must read some values
|
||||
$externalapplication = json_decode( $targetTask['externalapplication'], true ) ;
|
||||
// must be of the form
|
||||
// {"method":"POST","url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
|
||||
// Where method is the POST, GET, ... method
|
||||
// url is the URL to be called
|
||||
// params is a list of parameters to get from running case
|
||||
foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
if( preg_match_all( "/@@(\w+)/u", $variable, $matches ) ) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ask for those case variables
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
// now tries to get the variables to check condition
|
||||
$infoForTasks = $myProcessMaker->getVariables( $srcCaseId, $casevariables );
|
||||
foreach($infoForTasks as $casevar => $varval ){
|
||||
$infoForTasks[ "@@$casevar" ] = "'$varval'" ;
|
||||
unset( $infoForTasks[ $casevar ] ) ;
|
||||
}
|
||||
$targetTask['sourcecondition'] = str_replace( array_keys($infoForTasks), $infoForTasks, $targetTask['sourcecondition'] ) ;
|
||||
|
||||
|
||||
if( eval( "return ".$targetTask['sourcecondition'].";" ) ){
|
||||
// look at each linked ticket if a case is attached and then if a task like $val is TO_DO
|
||||
// then will try to routeCase for each tasks in $val
|
||||
|
||||
$postdatas = array();
|
||||
foreach( $targetTask['targetactions'] as $action => $actionvalue) {
|
||||
$postdatas['form'][$action] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $actionvalue)." ;" ) ;
|
||||
}
|
||||
$postdatas['UID'] = $targetTask['targetdynaform_guid'];
|
||||
$postdatas['__DynaformName__'] = $targetTask['targetprocess_guid']."_".$targetTask['targetdynaform_guid'] ;
|
||||
$postdatas['__notValidateThisFields__'] = '[]';
|
||||
$postdatas['DynaformRequiredFields'] = '[]';
|
||||
$postdatas['form']['btnGLPISendRequest'] = 'submit' ;
|
||||
|
||||
//foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
// $externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" ) ;
|
||||
//}
|
||||
|
||||
$externalapplicationparams = array() ;
|
||||
if( $externalapplication ) {
|
||||
// must call curl
|
||||
foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
$externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" ) ;
|
||||
}
|
||||
$externalapplicationparams['callback']=$CFG_GLPI['root_doc']."/plugins/processmaker/ajax/asynchronousdatas.php";
|
||||
$ch = curl_init();
|
||||
$externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ) ; // '???
|
||||
curl_setopt($ch, CURLOPT_URL, $externalapplication['url'] );
|
||||
}
|
||||
|
||||
if( $targetTask['is_self'] ) {
|
||||
// MUST BE done on a add task hook, and not on an update task hook
|
||||
|
||||
//$query = "SELECT glpi_plugin_processmaker_cases.id, MAX(glpi_plugin_processmaker_tasks.del_index) AS del_index FROM glpi_tickettasks
|
||||
// JOIN glpi_plugin_processmaker_taskcategories ON glpi_plugin_processmaker_taskcategories.taskcategories_id=glpi_tickettasks.taskcategories_id
|
||||
// JOIN glpi_plugin_processmaker_cases ON glpi_plugin_processmaker_cases.processes_id=glpi_plugin_processmaker_taskcategories.processes_id
|
||||
// RIGHT JOIN glpi_plugin_processmaker_tasks ON glpi_plugin_processmaker_tasks.items_id=glpi_tickettasks.id AND glpi_plugin_processmaker_tasks.case_id=glpi_plugin_processmaker_cases.id
|
||||
// WHERE glpi_plugin_processmaker_taskcategories.pm_task_guid = '".$targetTask['targettask_guid']."' AND glpi_tickettasks.state = 1 AND glpi_tickettasks.tickets_id=".$parm->fields['tickets_id'] ;
|
||||
|
||||
//$res = $DB->query($query) ;
|
||||
//if( $res && $DB->numrows($res) > 0 && $case=$DB->fetch_assoc($res) && isset($case['id']) && isset($case['del_index']) ) {
|
||||
//foreach( $DB->request($query) as $case ) {
|
||||
$taskCase = $myProcessMaker->taskCase( $srcCaseId ) ;
|
||||
foreach( $taskCase as $task ) {
|
||||
// search for target task guid
|
||||
if( $task->guid == $targetTask['targettask_guid'] )
|
||||
break ;
|
||||
}
|
||||
|
||||
$postdatas['APP_UID'] = $srcCaseId;
|
||||
$postdatas['DEL_INDEX'] = $task->delegate;
|
||||
|
||||
//need to get the 'ProcessMaker' user
|
||||
$pmconfig = PluginProcessmakerConfig::getInstance() ;
|
||||
|
||||
$cronaction = new PluginProcessmakerCrontaskaction;
|
||||
$cronaction->add( array( 'plugin_processmaker_caselinks_id' => $targetTask['id'],
|
||||
'itemtype' => $itemtype,
|
||||
'items_id' => $parm->fields['tickets_id'],
|
||||
'users_id' => $pmconfig->fields['users_id'],
|
||||
'toclaim' => $targetTask['targettoclaim'],
|
||||
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATAS : PluginProcessmakerCrontaskaction::DATAS_READY),
|
||||
'postdatas' => json_encode( $postdatas, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
),
|
||||
null,
|
||||
false) ;
|
||||
|
||||
if( $externalapplication ) {
|
||||
// must call external application in order to get the needed data asynchroneously
|
||||
// must be of the form
|
||||
// {"url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
|
||||
// url is the URL to be called
|
||||
|
||||
$externalapplicationparams['record_id'] = $cronaction->getID();
|
||||
|
||||
$externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT);
|
||||
//$externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($externalapplicationparams)));
|
||||
|
||||
$response = curl_exec ($ch);
|
||||
|
||||
curl_close ($ch);
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
foreach( Ticket_Ticket::getLinkedTicketsTo( $parm->fields['tickets_id'] ) as $tlink ){
|
||||
if( $tlink['link'] == Ticket_Ticket::LINK_TO ) {
|
||||
$query = "SELECT glpi_plugin_processmaker_cases.id, MAX(glpi_plugin_processmaker_tasks.del_index) AS del_index FROM glpi_tickettasks
|
||||
JOIN glpi_plugin_processmaker_taskcategories ON glpi_plugin_processmaker_taskcategories.taskcategories_id=glpi_tickettasks.taskcategories_id
|
||||
JOIN glpi_plugin_processmaker_cases ON glpi_plugin_processmaker_cases.processes_id=glpi_plugin_processmaker_taskcategories.processes_id
|
||||
RIGHT JOIN glpi_plugin_processmaker_tasks ON glpi_plugin_processmaker_tasks.items_id=glpi_tickettasks.id AND glpi_plugin_processmaker_tasks.case_id=glpi_plugin_processmaker_cases.id
|
||||
WHERE glpi_plugin_processmaker_taskcategories.pm_task_guid = '".$targetTask['targettask_guid']."' AND glpi_tickettasks.state = 1 AND glpi_tickettasks.tickets_id=".$tlink['tickets_id'] ;
|
||||
foreach( $DB->request($query) as $case ) {
|
||||
// must be only one row
|
||||
|
||||
$postdatas['APP_UID'] = $case['id'];
|
||||
$postdatas['DEL_INDEX'] = $case['del_index'];
|
||||
|
||||
$cronaction = new PluginProcessmakerCrontaskaction;
|
||||
$cronaction->add( array( 'plugin_processmaker_caselinks_id' => $targetTask['id'],
|
||||
'itemtype' => $itemtype,
|
||||
'items_id' => $parm->fields['tickets_id'],
|
||||
'users_id' => Session::getLoginUserID(),
|
||||
'toclaim' => $targetTask['targettoclaim'],
|
||||
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATAS : PluginProcessmakerCrontaskaction::DATAS_READY),
|
||||
'postdatas' => json_encode( $postdatas, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
),
|
||||
null,
|
||||
false) ;
|
||||
}
|
||||
//if( $externalapplication ) {
|
||||
// // must call external application in order to get the needed data asynchroneously
|
||||
// // must be of the form
|
||||
// // {"method":"POST","url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
|
||||
// // Where method is the POST, GET
|
||||
// // url is the URL to be called
|
||||
// $externalapplicationparams['record_id']=$cronaction->getID();
|
||||
// $externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
|
||||
// if( $externalapplication['method'] != 'GET') {
|
||||
// switch($externalapplication['method']) {
|
||||
// case 'POST' :
|
||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// $response = curl_exec ($ch);
|
||||
|
||||
// curl_close ($ch);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +544,7 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
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"));
|
||||
PluginProcessmakerProcess::dropdown(array( 'value' => 0, '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>";
|
||||
@@ -648,7 +648,7 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
*/
|
||||
public static function canSolve ($parm) {
|
||||
$myCase = new self;
|
||||
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
|
||||
if( $myCase->getCaseFromItemTypeAndItemId( $parm['item']->getType(), $parm['item']->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
|
||||
|
||||
12
inc/caselink.class.php
Normal file
12
inc/caselink.class.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCaselink short summary.
|
||||
*
|
||||
* PluginProcessmakerCaselink description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCaselink extends CommonDBTM {
|
||||
}
|
||||
12
inc/caselinkaction.class.php
Normal file
12
inc/caselinkaction.class.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCaselinkaction short summary.
|
||||
*
|
||||
* PluginProcessmakerCaselinkaction description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCaselinkaction extends CommonDBTM {
|
||||
}
|
||||
22
inc/crontaskaction.class.php
Normal file
22
inc/crontaskaction.class.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCrontaskaction is used to manage actions between cases
|
||||
*
|
||||
* Allows actions: routing cases (called slaves) from another case (called master)
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCrontaskaction extends CommonDBTM {
|
||||
|
||||
// postdatas are of the form:
|
||||
// {"form":{"RELEASE_DONE":"0","btnGLPISendRequest":"submit"},"UID":"28421020557bffc5b374850018853291","__DynaformName__":"51126098657bd96b286ded7016691792_28421020557bffc5b374850018853291","__notValidateThisFields__":"[]","DynaformRequiredFields":"[]","APP_UID":"6077575685836f7d89cabe6013770123","DEL_INDEX":"4"}
|
||||
|
||||
|
||||
const WAITING_DATAS = 1 ;
|
||||
const DATAS_READY = 2 ;
|
||||
const DONE = 3 ;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,9 +89,10 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
|
||||
static function populatePlanning($params) {
|
||||
global $CFG_GLPI;
|
||||
//echo 'Test' ;
|
||||
|
||||
$ret = array();
|
||||
$events = array() ;
|
||||
if( isset($params['start']) ) {
|
||||
$params['begin'] = '2000-01-01 00:00:00';
|
||||
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
|
||||
|
||||
@@ -112,14 +113,15 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
|
||||
$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'];
|
||||
}
|
||||
//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 ;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
* 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
|
||||
* @return int GLPI user id, or 0 if not found
|
||||
*/
|
||||
public static function getGLPIUserId( $pmUserId ){
|
||||
$obj = new self ;
|
||||
|
||||
@@ -41,8 +41,13 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
|
||||
caseIFrame = document.getElementById('caseiframe');
|
||||
|
||||
if (caseIFrame != undefined && caseIFrame.contentDocument != undefined) {
|
||||
var contentDocument = caseIFrame.contentDocument;
|
||||
var contentDocument;
|
||||
try {
|
||||
contentDocument = caseIFrame.contentDocument;
|
||||
} catch (ex) {
|
||||
contentDocument = false;
|
||||
}
|
||||
if (caseIFrame != undefined && contentDocument) {
|
||||
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
|
||||
var linkList = contentDocument.getElementsByTagName('a');
|
||||
|
||||
92
js/cases.js
92
js/cases.js
@@ -20,13 +20,25 @@ function bGLPIHideElement(eltList, attribute, value) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function showMask(elt) {
|
||||
if( !elt.defaultPrevented ) {
|
||||
Ext.getBody().moveTo(0, 0);
|
||||
var myMask = new Ext.LoadMask(Ext.getBody(), { removeMask: false });
|
||||
myMask.show();
|
||||
|
||||
function displayOverlay() {
|
||||
//debugger;
|
||||
// don't use displayOverlay when submit input open new tab or update parent ( example: pdf generation )
|
||||
if (!($(this).is('input[type=submit]')
|
||||
&& $(this).parents('form').length > 0
|
||||
&& ($(this).parents('form').first().attr('target') == '_blank' || $(this).parents('form').first().attr('target') == '_parent'))) {
|
||||
$("<div class='ui-widget-overlay ui-front'></div>").appendTo("body");
|
||||
|
||||
var timer = window.setInterval(function () {
|
||||
var count = $('.ui-widget-overlay.ui-front').length;
|
||||
if (count == 2) {
|
||||
$($('.ui-widget-overlay.ui-front')[1]).remove();
|
||||
window.clearInterval(timer);
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
@@ -41,12 +53,22 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
try {
|
||||
var locContentDocument;
|
||||
var taskFrame = document.getElementById(taskFrameId);
|
||||
|
||||
if (taskFrame != undefined && taskFrame.contentDocument != undefined) {
|
||||
try {
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
} catch (ex) {
|
||||
locContentDocument = false;
|
||||
}
|
||||
if (taskFrame != undefined && locContentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
|
||||
// if task resumé, then hide the form part
|
||||
//debugger;
|
||||
var form_resume = locContentDocument.getElementsByName('cases_Resume');
|
||||
if (form_resume.length > 0 && form_resume[0].style.display != 'none') {
|
||||
form_resume[0].style.display = 'none';
|
||||
}
|
||||
|
||||
// then look if btnGLPISendRequest exists,
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
var locElt = locContentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
if (!bShowHideNextStep && locElt != undefined ) {
|
||||
var linkList = locContentDocument.getElementsByTagName('a');
|
||||
@@ -60,6 +82,7 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
|
||||
// if yes then change the action of the form POST
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
@@ -71,9 +94,8 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
csrfElt.setAttribute("value", csrf) ;
|
||||
node.appendChild(csrfElt);
|
||||
|
||||
// try to add showMask function to submit event
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask, true);
|
||||
// add showMask function to submit event
|
||||
//node.addEventListener('submit', displayOverlay, true);
|
||||
} else {
|
||||
// then hide the button itself
|
||||
locElt.style.display = 'none';
|
||||
@@ -94,8 +116,11 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
// 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
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
bHideClaimCancelButton = true;
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask);
|
||||
@@ -112,20 +137,11 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var newHeight;
|
||||
//var locElt = locContentDocument.getElementsByTagName("table")[0];
|
||||
var locElt = locContentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) + 60;
|
||||
//if (locElt)
|
||||
// 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
|
||||
//NOT NEEDED WITH jQuery: var elts = $('#processmakertabpanel').tabs();//.getItem('task-' + delIndex).setHeight(newHeight);
|
||||
//debugger;
|
||||
taskFrame.height = newHeight ;
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
var redimFrameTimer = window.setInterval(function () {
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
}, 1000);
|
||||
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
@@ -143,6 +159,21 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
|
||||
}
|
||||
|
||||
function redimTaskFrame(taskFrame, delIndex) {
|
||||
var newHeight;
|
||||
try{
|
||||
//var locElt = locContentDocument.getElementsByTagName("table")[0];
|
||||
var locElt = taskFrame.contentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) ;
|
||||
if (newHeight < 500) {
|
||||
newHeight = 500;
|
||||
}
|
||||
|
||||
taskFrame.height = newHeight;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function onTaskFrameActivation(delIndex) {
|
||||
var taskFrameId = "caseiframe-" + delIndex;
|
||||
var taskFrameTimerCounter = 0;
|
||||
@@ -182,23 +213,16 @@ function onTaskFrameActivation(delIndex) {
|
||||
}
|
||||
function clearClass(lociFrame) {
|
||||
|
||||
//var otherFrameTimerCounter = 0;
|
||||
//var otherFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locElt = lociFrame.contentDocument.getElementsByTagName('body')[0];
|
||||
if (locElt != undefined && locElt.className != '') {
|
||||
//debugger;
|
||||
locElt.className = '';
|
||||
// window.clearInterval(otherFrameTimer);
|
||||
//} else {
|
||||
// otherFrameTimerCounter = otherFrameTimerCounter + 1;
|
||||
// if (otherFrameTimerCounter > 3000 )
|
||||
// window.clearInterval(otherFrameTimer);
|
||||
|
||||
}
|
||||
} catch (ev) {
|
||||
|
||||
}
|
||||
//}, 10);
|
||||
}
|
||||
|
||||
function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
|
||||
|
||||
@@ -12,8 +12,8 @@ $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']['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";
|
||||
@@ -112,8 +112,8 @@ $LANG['processmaker']['search']['processtitle']="Process Title";
|
||||
$LANG['processmaker']['search']['casetitle']="Case Title";
|
||||
$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']['pmusers']="Syncs GLPI users and groups into ProcessMaker." ;
|
||||
|
||||
$LANG['processmaker']['cron']['pmtaskactions']="To apply task actions between cases." ;
|
||||
$LANG['processmaker']['cron']['pmorphancases']['description']="Cleaning of orphan cases." ;
|
||||
$LANG['processmaker']['cron']['pmorphancases']['parameter']="Number of days to keep orphan cases";
|
||||
|
||||
@@ -112,7 +112,8 @@ $LANG['processmaker']['search']['processtitle']="Nom du processus";
|
||||
$LANG['processmaker']['search']['casetitle']="Titre du cas";
|
||||
$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']['pmusers']="Synchro des utilisateurs GLPI et des groups avec ProcessMaker." ;
|
||||
//$LANG['processmaker']['cron']['pmnotifications']="Notifications des tâches GLPI liées à des tâches de ProcessMaker." ;
|
||||
$LANG['processmaker']['cron']['pmtaskactions']="Pour appliquer les actions de tâches entre cas." ;
|
||||
$LANG['processmaker']['cron']['pmorphancases']['description']="Nettoyage des cas orphelins." ;
|
||||
$LANG['processmaker']['cron']['pmorphancases']['parameter']="Nombre de jours avant nettoyage des cas orphelins.";
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</authors>
|
||||
<versions>
|
||||
<version>
|
||||
<num>3.0.0</num>
|
||||
<num>3.1.0</num>
|
||||
<compatibility>9.1</compatibility>
|
||||
</version>
|
||||
</versions>
|
||||
|
||||
25
setup.php
25
setup.php
@@ -48,9 +48,14 @@ function plugin_init_processmaker() {
|
||||
$PLUGIN_HOOKS['pre_show_item']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
|
||||
|
||||
$PLUGIN_HOOKS['post_show_item']['processmaker']
|
||||
= array('Ticket' => array('PluginProcessmakerProcessmaker',
|
||||
'post_show_item_processmakerticket'));
|
||||
$PLUGIN_HOOKS['pre_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_tab_processmaker');
|
||||
$PLUGIN_HOOKS['post_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'post_show_tab_processmaker');
|
||||
|
||||
//$PLUGIN_HOOKS['post_show_item']['processmaker']
|
||||
// = array('Ticket' => array('PluginProcessmakerProcessmaker',
|
||||
// 'post_show_item_processmakerticket'));
|
||||
|
||||
// Display a menu entry ?
|
||||
if (Session::haveRight('config', READ) ) {
|
||||
@@ -70,7 +75,8 @@ function plugin_init_processmaker() {
|
||||
// , 'TicketFollowup' => 'plugin_pre_item_update_processmaker_followup'
|
||||
|
||||
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
|
||||
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction'
|
||||
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction',
|
||||
'TicketTask' => 'plugin_item_update_processmaker_tasks'
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
|
||||
@@ -81,6 +87,9 @@ function plugin_init_processmaker() {
|
||||
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['item_get_pdfdatas']['processmaker'] = array(
|
||||
'PluginPdfTicketTask' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdatas_processmaker')
|
||||
);
|
||||
|
||||
|
||||
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
|
||||
@@ -115,16 +124,16 @@ function plugin_version_processmaker(){
|
||||
global $LANG;
|
||||
|
||||
return array ('name' => 'Process Maker',
|
||||
'version' => '3.0.0',
|
||||
'version' => '3.1.0',
|
||||
'author' => 'Olivier Moron',
|
||||
'homepage' => '',
|
||||
'minGlpiVersion' => '0.85.0');
|
||||
'minGlpiVersion' => '9.1');
|
||||
}
|
||||
|
||||
// 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.85','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
|
||||
echo "This plugin requires GLPI 0.85.0 or higher";
|
||||
if (version_compare(GLPI_VERSION,'9.1','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
|
||||
echo "This plugin requires GLPI 9.1 or higher";
|
||||
return false;
|
||||
}
|
||||
//$plug = new Plugin ;
|
||||
|
||||
Reference in New Issue
Block a user