Added a call to cases_Open page before map, history, change log and dynaforms to be sure to isolate two different cases in same browser

This commit is contained in:
tomolimo
2018-07-25 14:09:52 +02:00
parent b7cc64c546
commit 361e8f6264
6 changed files with 111 additions and 82 deletions

View File

@@ -56,7 +56,12 @@ if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && iss
} else } else
if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) { if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) {
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
Html::helpHeader(__('Process cases', 'processmaker'), '', $_SESSION["glpiname"]);
} else {
Html::header(__('Process cases', 'processmaker'), $_SERVER['PHP_SELF'], "helpdesk", "PluginProcessmakerCase", "cases"); Html::header(__('Process cases', 'processmaker'), $_SERVER['PHP_SELF'], "helpdesk", "PluginProcessmakerCase", "cases");
}
if ($locCase->getFromDB($_REQUEST['id'])) { if ($locCase->getFromDB($_REQUEST['id'])) {
$locCase->display($_REQUEST); $locCase->display($_REQUEST);

View File

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

View File

@@ -19,89 +19,61 @@ class PluginProcessmakerCasedynaform extends CommonDBTM {
$proj = new PluginProcessmakerProcess; $proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']); $proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
//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=\'".$PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand&glpi_domain={$config->fields['domain']}\' ></iframe>'
// );
// }
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand' echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
echo "<script type='text/javascript'> echo "<script type='text/javascript'>
var historyGridListChangeLogGlobal = { viewIdHistory: '', viewIdDin: '', viewDynaformName: '', idHistory: '' } ; var historyGridListChangeLogGlobal = { viewIdHistory: '', viewIdDin: '', viewDynaformName: '', idHistory: '' } ;
var ActionTabFrameGlobal = { tabData: '', tabName: '', tabTitle: '' } ; var ActionTabFrameGlobal = { tabData: '', tabName: '', tabTitle: '' } ;
function urldecode(url) {
return decodeURIComponent(url.replace(/\+/g, ' '));
}
function addTabPanel(name, title, html){ function addTabPanel(name, title, html){
//debugger ; //debugger ;
var loctabs = $('#tabspanel').next('div[id^=tabs]'); var loctabs = $('#tabspanel').next('div[id^=tabs]');
if( !loctabs[0].children[name] ) { // panel is not yet existing, create one if( !loctabs[0].children[name] ) { // panel is not yet existing, create one
//tabs.tabs('add');
if( loctabs.find('a[href=\"#'+name+'\"]').length == 0 ) { if( loctabs.find('a[href=\"#'+name+'\"]').length == 0 ) {
loctabs.find('ul').append( '<li><a href=\'#' + name + '\'>' + title + '</a></li>' ); loctabs.find('ul').append( '<li><a href=\'#' + name + '\'>' + title + '</a></li>' );
} }
//debugger ; $.ajax( { url: '".$PM_SOAP->serverURL."/cases/cases_Open?sid=".$PM_SOAP->getPMSessionID()."&APP_UID={$case->fields['case_guid']}&DEL_INDEX=1&action=TO_DO&glpi_init_case=1&glpi_domain={$config->fields['domain']}',
complete: function() {
//debugger;
loctabs.append( '<div id=\'' + name + '\'>' + html + '</div>'); loctabs.append( '<div id=\'' + name + '\'>' + html + '</div>');
loctabs.tabs('refresh'); // to show the panel loctabs.tabs('refresh'); // to show the panel
} var tabIndex = loctabs.find('a[href=\"#'+name+'\"]').parent().index();
loctabs.tabs( 'option', 'active', tabIndex) ; // to activate it
} });
} else { // only acitvate it
var tabIndex = loctabs.find('a[href=\"#'+name+'\"]').parent().index(); var tabIndex = loctabs.find('a[href=\"#'+name+'\"]').parent().index();
loctabs.tabs( 'option', 'active', tabIndex) ; // to activate it loctabs.tabs( 'option', 'active', tabIndex) ; // to activate it
} }
}
var Actions = { tabFrame: function( actionToDo ) { var Actions = { tabFrame: function( actionToDo ) {
//debugger ; //debugger ;
//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=\'".$PM_SOAP->serverURL."/cases/ajaxListener?action=dynaformViewFromHistory&DYN_UID=' + historyGridListChangeLogGlobal.viewIdDin + \"&HISTORY_ID=\" + historyGridListChangeLogGlobal.viewIdHistory + '&rand=$rand&glpi_domain={$config->fields['domain']}\' ></iframe>'
// );
// } else
if( actionToDo.search( '^historyDynaformGridPreview' ) == 0 ) { if( actionToDo.search( '^historyDynaformGridPreview' ) == 0 ) {
actionToDo = actionToDo.replace('_', '$') ; actionToDo = actionToDo.replace('_', '$') ;
var act = actionToDo.replace( '$', '&DYN_UID=') ; var act = actionToDo.replace( '$', '&DYN_UID=') ;
addTabPanel( actionToDo, addTabPanel( actionToDo,
ActionTabFrameGlobal.tabTitle, ActionTabFrameGlobal.tabTitle,
'<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"form\", 0 );\' width=\'100%\' src=\'".$PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand&glpi_domain={$config->fields['domain']}\' ></iframe>' '<iframe id=\'caseiframe-' + actionToDo + '\' style=\'border: none;\' onload=\'onOtherFrameLoad( \"'+actionToDo+'\", \"caseiframe-' + actionToDo + '\", \"form\", 0 );\' width=\'100%\' src=\'".$PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand\' ></iframe>'
); );
} }
//if( actionToDo.search( '^historyDynaformGridPreview' ) == 0 ) {
// actionToDo = actionToDo.replace('_', '$') ;
// var act = actionToDo.replace( '$', '&DYN_UID=') ;
// var new_window = window.open('{$PM_SOAP->serverURL}/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand&glpi_domain={$config->fields['domain']}', '_blank');
// if (new_window) {
// // set title
// new_window.document.title = ActionTabFrameGlobal.tabTitle;
// }
//}
//} 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=\'".$PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand&glpi_domain={$config->fields['domain']}\' ></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=\'".$PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=' + act + '&rand=$rand&glpi_domain={$config->fields['domain']}\' ></iframe>'
// );
//}
} }
} ; } ;
</script>"; </script>";
$caseURL = $PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand&glpi_domain={$config->fields['domain']}&GLPI_APP_UID={$case->fields['case_guid']}&GLPI_PRO_UID={$proj->fields['process_guid']}"; $caseURL = $PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand";
$iframe = "<iframe
id='caseiframe-historyDynaformPage'
style='border: none;'
width='100%'
src='$caseURL'
onload=\"onOtherFrameLoad( 'historyDynaformPage', 'caseiframe-historyDynaformPage', 'body', 0 );\">
</iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ;
echo "<iframe id='caseiframe-historyDynaformPage' style='border: none;' width='100%' src='$caseURL'
onload=\"onOtherFrameLoad( 'historyDynaformPage', 'caseiframe-historyDynaformPage', 'body', 0 );\"></iframe>'";
} }
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){

View File

@@ -12,19 +12,23 @@ class PluginProcessmakerCasehistory extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) { static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP; global $CFG_GLPI, $PM_SOAP;
$config = $PM_SOAP->config;
$rand = rand(); $rand = rand();
$proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
$caseHistoryURL = $PM_SOAP->serverURL $caseHistoryURL = $PM_SOAP->serverURL
."/cases/ajaxListener?action=caseHistory&rand=$rand&glpi_domain={$config->fields['domain']}&GLPI_APP_UID={$case->fields['case_guid']}&GLPI_PRO_UID={$proj->fields['process_guid']}"; ."/cases/ajaxListener?action=caseHistory&rand=$rand";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>";
echo "<iframe id='caseiframe-caseHistory' style='border: none;' width='100%' src='$caseHistoryURL' $iframe = "<iframe
onload=\"onOtherFrameLoad( 'caseHistory', 'caseiframe-caseHistory', 'body', 0 );\"></iframe>"; id='caseiframe-caseHistory'
style='border: none;'
width='100%'
src='$caseHistoryURL'
onload=\"onOtherFrameLoad( 'caseHistory', 'caseiframe-caseHistory', 'body', 0 );\">
</iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ;
} }
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){

View File

@@ -13,7 +13,6 @@ class PluginProcessmakerCasemap extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) { static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI, $PM_SOAP; global $CFG_GLPI, $PM_SOAP;
$config = $PM_SOAP->config;
$rand = rand(); $rand = rand();
$proj = new PluginProcessmakerProcess; $proj = new PluginProcessmakerProcess;
@@ -22,15 +21,22 @@ class PluginProcessmakerCasemap extends CommonDBTM {
$caseMapUrl = $PM_SOAP->serverURL.( $caseMapUrl = $PM_SOAP->serverURL.(
$project_type=='bpmn' ? $project_type=='bpmn' ?
"/designer?sid=".$PM_SOAP->getPMSessionID()."&prj_uid=".$proj->fields['process_guid']."&prj_readonly=true&app_uid=".$case->fields['case_guid'] "/designer?prj_uid=".$proj->fields['process_guid']."&prj_readonly=true&app_uid=".$case->fields['case_guid']
: :
"/cases/ajaxListener?sid=".$PM_SOAP->getPMSessionID()."&action=processMap" //&GLPI_PRO_UID={$proj->fields['process_guid']}" "/cases/ajaxListener?action=processMap"
)."&glpi_domain={$config->fields['domain']}&rand=$rand&GLPI_APP_UID={$case->fields['case_guid']}&GLPI_PRO_UID={$proj->fields['process_guid']}"; )."&rand=$rand";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand' echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
echo "<iframe id='caseiframe-caseMap' style='border: none;' width='100%' src='$caseMapUrl' $iframe = "<iframe
onload=\"onOtherFrameLoad( 'caseMap', 'caseiframe-caseMap', 'body', ".($project_type=='bpmn' ? "true" : "false" )." );\"></iframe>"; id='caseiframe-caseMap'
style='border: none;' width='100%'
src='$caseMapUrl'
onload=\"onOtherFrameLoad( 'caseMap', 'caseiframe-caseMap', 'body', ".($project_type=='bpmn' ? "true" : "false" )." );\">
</iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ;
} }
function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){

View File

@@ -2334,6 +2334,48 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
//return ($n < 1 ? false : true) ; //return ($n < 1 ? false : true) ;
} }
/**
* Summary of initCaseAndShowTab
* Is used to workaround a SESSION issue in PM server
* PM server stores case context in SESSION variables,
* which leads to issues when viewing two different cases
* in two different tabs of the same browser.
* This workaround will artificially load cases_Open page to force
* initialization of those SESSION variables to prevent mix of values
* when viewing tabs like map, change log, history, and dynaforms
*
* it will also manage the glpi_domain parameter
*
* @param mixed $currentCase array that contains APP_UID, DEL_INDEX
* @param mixed $iFrameUrl string which is the url of the tab panel
* @param mixed $rand integer
*/
public function initCaseAndShowTab($currentCase, $iFrameUrl, $rand) {
$iFrameUrl = urlencode($iFrameUrl);
echo "<div id='openCase-$rand'></div>";
// will use ajax to be sure that cases_Open page is fully loaded before load of the $iFrameUrl
// this mechanism is mandatory to have correct management of cookies, as cookies transport the session id,
// and such the SESSION variables that contain the case context
echo "<script type='text/javascript'>
(function () {
function urldecode(url) {
return decodeURIComponent(url.replace(/\+/g, ' '));
}
$.ajax( { url: '".$this->serverURL."/cases/cases_Open?sid=".$this->getPMSessionID()."&APP_UID={$currentCase['APP_UID']}&DEL_INDEX={$currentCase['DEL_INDEX']}&action=TO_DO&glpi_init_case=1&glpi_domain={$this->config->fields['domain']}',
complete: function () {
//debugger;
var str = urldecode('$iFrameUrl');
$('#openCase-$rand').after(str);
}
}
);
}) ();
</script>";
}
/** /**
* Summary of plugin_item_get_datas_processmaker * Summary of plugin_item_get_datas_processmaker
* @param mixed $item * @param mixed $item