Changed EOL to CRLF

This commit is contained in:
Moron, Olivier
2023-10-16 14:15:32 +02:00
parent e5ccb43e95
commit 78ead76101
36 changed files with 2016 additions and 2016 deletions

View File

@@ -1,38 +1,38 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: '' title: ''
labels: '' labels: ''
assignees: '' assignees: ''
--- ---
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **To Reproduce**
Steps to reproduce the behavior: Steps to reproduce the behavior:
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
4. See error 4. See error
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
**Screenshots** **Screenshots**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):** **Desktop (please complete the following information):**
- OS: [e.g. iOS] - OS: [e.g. iOS]
- Browser [e.g. chrome, safari] - Browser [e.g. chrome, safari]
- Version [e.g. 22] - Version [e.g. 22]
**Smartphone (please complete the following information):** **Smartphone (please complete the following information):**
- Device: [e.g. iPhone6] - Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1] - OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari] - Browser [e.g. stock browser, safari]
- Version [e.g. 22] - Version [e.g. 22]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

View File

@@ -1,20 +1,20 @@
--- ---
name: Feature request name: Feature request
about: Suggest an idea for this project about: Suggest an idea for this project
title: '' title: ''
labels: '' labels: ''
assignees: '' assignees: ''
--- ---
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like** **Describe the solution you'd like**
A clear and concise description of what you want to happen. A clear and concise description of what you want to happen.
**Describe alternatives you've considered** **Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered. A clear and concise description of any alternative solutions or features you've considered.
**Additional context** **Additional context**
Add any other context or screenshots about the feature request here. Add any other context or screenshots about the feature request here.

View File

@@ -1,47 +1,47 @@
<?php <?php
if (strpos($_SERVER['PHP_SELF'], "asynchronousdatas.php")) { if (strpos($_SERVER['PHP_SELF'], "asynchronousdatas.php")) {
$AJAX_INCLUDE = 1; $AJAX_INCLUDE = 1;
define('GLPI_ROOT', '../../..'); define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php"); include (GLPI_ROOT."/inc/includes.php");
Html::header_nocache(); Html::header_nocache();
} }
if (!defined('GLPI_ROOT')) { if (!defined('GLPI_ROOT')) {
die("Can not access directly to this file"); die("Can not access directly to this file");
} }
include_once dirname(__FILE__)."/../inc/crontaskaction.class.php"; include_once dirname(__FILE__)."/../inc/crontaskaction.class.php";
if (isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD']=='OPTIONS') { if (isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD']=='OPTIONS') {
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST"); header("Access-Control-Allow-Methods: POST");
header("Access-Control-Allow-Headers: Content-Type"); header("Access-Control-Allow-Headers: Content-Type");
} else { } else {
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8"); header("Content-Type: application/json; charset=UTF-8");
if (isset($_SERVER['REQUEST_METHOD'])) { if (isset($_SERVER['REQUEST_METHOD'])) {
switch ($_SERVER['REQUEST_METHOD']) { switch ($_SERVER['REQUEST_METHOD']) {
case 'POST' : case 'POST' :
$request_body = file_get_contents('php://input'); $request_body = file_get_contents('php://input');
$datas = json_decode($request_body, true); $datas = json_decode($request_body, true);
$asyncdata = new PluginProcessmakerCrontaskaction; $asyncdata = new PluginProcessmakerCrontaskaction;
if (isset($datas['id']) && $asyncdata->getFromDB( $datas['id'] ) && $asyncdata->fields['state'] == PluginProcessmakerCrontaskaction::WAITING_DATA) { if (isset($datas['id']) && $asyncdata->getFromDB( $datas['id'] ) && $asyncdata->fields['state'] == PluginProcessmakerCrontaskaction::WAITING_DATA) {
$initialdatas = json_decode($asyncdata->fields['postdata'], true); $initialdatas = json_decode($asyncdata->fields['postdata'], true);
$initialdatas['form'] = array_merge( $initialdatas['form'], $datas['form'] ); $initialdatas['form'] = array_merge( $initialdatas['form'], $datas['form'] );
$postdata = json_encode($initialdatas, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE); $postdata = json_encode($initialdatas, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE);
$asyncdata->update( [ 'id' => $datas['id'], 'state' => PluginProcessmakerCrontaskaction::DATA_READY, 'postdata' => $postdata ] ); $asyncdata->update( [ 'id' => $datas['id'], 'state' => PluginProcessmakerCrontaskaction::DATA_READY, 'postdata' => $postdata ] );
$ret = [ 'code' => '0', 'message' => 'Done' ]; $ret = [ 'code' => '0', 'message' => 'Done' ];
} else { } else {
$ret = [ 'code' => '2', 'message' => 'Case is not existing, or state is not WAITING_DATA' ]; $ret = [ 'code' => '2', 'message' => 'Case is not existing, or state is not WAITING_DATA' ];
} }
break; break;
default: default:
$ret = [ 'code' => '1', 'message' => 'Method '.$_SERVER['REQUEST_METHOD'].' not supported' ]; $ret = [ 'code' => '1', 'message' => 'Method '.$_SERVER['REQUEST_METHOD'].' not supported' ];
} }
echo json_encode( $ret, JSON_HEX_APOS | JSON_HEX_QUOT ); echo json_encode( $ret, JSON_HEX_APOS | JSON_HEX_QUOT );
} }
} }

View File

@@ -1,89 +1,89 @@
<?php <?php
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Original Author of file: Olivier Moron // Original Author of file: Olivier Moron
// Purpose of file: to return list of processes which can be started by end-user // Purpose of file: to return list of processes which can be started by end-user
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Direct access to file // Direct access to file
if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) { if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) {
include ("../../../inc/includes.php"); include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache(); Html::header_nocache();
} }
if (!defined('GLPI_ROOT')) { if (!defined('GLPI_ROOT')) {
die("Can not access directly to this file"); die("Can not access directly to this file");
} }
Session::checkLoginUser(); Session::checkLoginUser();
if (isset($_REQUEST["entity_restrict"]) if (isset($_REQUEST["entity_restrict"])
&& !is_array($_REQUEST["entity_restrict"]) && !is_array($_REQUEST["entity_restrict"])
&& (substr($_REQUEST["entity_restrict"], 0, 1) === '[') && (substr($_REQUEST["entity_restrict"], 0, 1) === '[')
&& (substr($_REQUEST["entity_restrict"], -1) === ']')) { && (substr($_REQUEST["entity_restrict"], -1) === ']')) {
$_REQUEST["entity_restrict"] = json_decode($_REQUEST["entity_restrict"]); $_REQUEST["entity_restrict"] = json_decode($_REQUEST["entity_restrict"]);
$_REQUEST["entity_restrict"] = $_REQUEST["entity_restrict"][0]; $_REQUEST["entity_restrict"] = $_REQUEST["entity_restrict"][0];
} }
// Security // Security
if (!($item = getItemForItemtype($_REQUEST['itemtype']))) { if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
exit(); exit();
} }
$one_item = -1; $one_item = -1;
if (isset($_POST['_one_id'])) { if (isset($_POST['_one_id'])) {
$one_item = $_POST['_one_id']; $one_item = $_POST['_one_id'];
} }
// Count real items returned // Count real items returned
$count = 0; $count = 0;
if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) { if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE; $_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
} }
$search=""; $search="";
if (!empty($_REQUEST['searchText'])) { if (!empty($_REQUEST['searchText'])) {
$search = ['LIKE', Search::makeTextSearchValue($_REQUEST['searchText'])]; $search = ['LIKE', Search::makeTextSearchValue($_REQUEST['searchText'])];
} }
$processes = []; $processes = [];
// Empty search text : display first // Empty search text : display first
if (empty($_REQUEST['searchText'])) { if (empty($_REQUEST['searchText'])) {
if ($_REQUEST['display_emptychoice']) { if ($_REQUEST['display_emptychoice']) {
if (($one_item < 0) || ($one_item == 0)) { if (($one_item < 0) || ($one_item == 0)) {
array_push($processes, ['id' => 0, array_push($processes, ['id' => 0,
'text' => $_REQUEST['emptylabel']]); 'text' => $_REQUEST['emptylabel']]);
} }
} }
} }
$processall = (isset($_REQUEST['specific_tags']['process_restrict']) && !$_REQUEST['specific_tags']['process_restrict']); $processall = (isset($_REQUEST['specific_tags']['process_restrict']) && !$_REQUEST['specific_tags']['process_restrict']);
$count_cases_per_item = isset($_REQUEST['specific_tags']['count_cases_per_item']) ? $_REQUEST['specific_tags']['count_cases_per_item'] : []; $count_cases_per_item = isset($_REQUEST['specific_tags']['count_cases_per_item']) ? $_REQUEST['specific_tags']['count_cases_per_item'] : [];
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search); $result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
//if ($DB->numrows($result)) { //if ($DB->numrows($result)) {
// while ($data = $DB->fetch_array($result)) { // while ($data = $DB->fetch_array($result)) {
//if ($result->numrows()) { //if ($result->numrows()) {
foreach ($result as $data) { foreach ($result as $data) {
$process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true); $process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true);
$can_add = $data['max_cases_per_item'] == 0 || !isset($count_cases_per_item[$data["id"]]) || $count_cases_per_item[$data["id"]] < $data['max_cases_per_item']; $can_add = $data['max_cases_per_item'] == 0 || !isset($count_cases_per_item[$data["id"]]) || $count_cases_per_item[$data["id"]] < $data['max_cases_per_item'];
if ($processall if ($processall
|| ($data['maintenance'] != 1 || ($data['maintenance'] != 1
&& in_array( $_REQUEST["entity_restrict"], $process_entities) && in_array( $_REQUEST["entity_restrict"], $process_entities)
&& $can_add) ) { && $can_add) ) {
array_push( $processes, ['id' => $data["id"], array_push( $processes, ['id' => $data["id"],
'text' => $data["name"] 'text' => $data["name"]
]); ]);
$count++; $count++;
} }
} }
//} //}
$ret['results'] = $processes; $ret['results'] = $processes;
$ret['count'] = $count; $ret['count'] = $count;
echo json_encode($ret); echo json_encode($ret);

View File

@@ -1,68 +1,68 @@
<?php <?php
//// ---------------------------------------------------------------------- //// ----------------------------------------------------------------------
//// Original Author of file: Olivier Moron //// Original Author of file: Olivier Moron
//// Purpose of file: to return list of processes which can be started by end-user //// Purpose of file: to return list of processes which can be started by end-user
//// ---------------------------------------------------------------------- //// ----------------------------------------------------------------------
//// Direct access to file //// Direct access to file
//if (strpos($_SERVER['PHP_SELF'], "dropdownTaskcategories.php")) { //if (strpos($_SERVER['PHP_SELF'], "dropdownTaskcategories.php")) {
// include ("../../../inc/includes.php"); // include ("../../../inc/includes.php");
// header("Content-Type: text/html; charset=UTF-8"); // header("Content-Type: text/html; charset=UTF-8");
// Html::header_nocache(); // Html::header_nocache();
//} //}
//if (!defined('GLPI_ROOT')) { //if (!defined('GLPI_ROOT')) {
// die("Can not access directly to this file"); // die("Can not access directly to this file");
//} //}
//Session::checkLoginUser(); //Session::checkLoginUser();
//// Security //// Security
//if (!($item = getItemForItemtype($_REQUEST['itemtype']))) { //if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
// exit(); // exit();
//} //}
//$one_item = -1; //$one_item = -1;
//if (isset($_POST['_one_id'])) { //if (isset($_POST['_one_id'])) {
// $one_item = $_POST['_one_id']; // $one_item = $_POST['_one_id'];
//} //}
//// Count real items returned //// Count real items returned
//$count = 0; //$count = 0;
//if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) { //if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
// $_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE; // $_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
//} //}
//$search=""; //$search="";
//if (!empty($_REQUEST['searchText'])) { //if (!empty($_REQUEST['searchText'])) {
// $search = Search::makeTextSearch($_REQUEST['searchText']); // $search = Search::makeTextSearch($_REQUEST['searchText']);
//} //}
//$taskcategories = array(); //$taskcategories = array();
//// Empty search text : display first //// Empty search text : display first
//if (empty($_REQUEST['searchText'])) { //if (empty($_REQUEST['searchText'])) {
// if ($_REQUEST['display_emptychoice']) { // if ($_REQUEST['display_emptychoice']) {
// if (($one_item < 0) || ($one_item == 0)) { // if (($one_item < 0) || ($one_item == 0)) {
// array_push($taskcategories, array('id' => 0, // array_push($taskcategories, array('id' => 0,
// 'text' => $_REQUEST['emptylabel'])); // 'text' => $_REQUEST['emptylabel']));
// } // }
// } // }
//} //}
//$result = PluginProcessmakerTaskCategory::getSqlSearchResult(false, $search); //$result = PluginProcessmakerTaskCategory::getSqlSearchResult(false, $search);
//if ($DB->numrows($result)) { //if ($DB->numrows($result)) {
// while ($data=$DB->fetch_array($result)) { // while ($data=$DB->fetch_array($result)) {
// array_push( $taskcategories, array( 'id' => $data["id"], // array_push( $taskcategories, array( 'id' => $data["id"],
// 'text' => $data["name"] )); // 'text' => $data["name"] ));
// $count++; // $count++;
// } // }
//} //}
//$ret['results'] = $taskcategories; //$ret['results'] = $taskcategories;
//$ret['count'] = $count; //$ret['count'] = $count;
//echo json_encode($ret); //echo json_encode($ret);

View File

@@ -1,40 +1,40 @@
<?php <?php
/** /**
*/ */
if (strpos($_SERVER['PHP_SELF'], "dropdownTicketCategories.php")) { if (strpos($_SERVER['PHP_SELF'], "dropdownTicketCategories.php")) {
include ("../../../inc/includes.php"); include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache(); Html::header_nocache();
} else if (!defined('GLPI_ROOT')) { } else if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access this file directly"); die("Sorry. You can't access this file directly");
} }
$opt['entity'] = $_POST["entity_restrict"] ?? -1; $opt['entity'] = $_POST["entity_restrict"] ?? -1;
if (isset($_POST["condition"])) { if (isset($_POST["condition"])) {
$opt['condition'] = $_POST["condition"]; $opt['condition'] = $_POST["condition"];
} }
$currentcateg = new ITILCategory(); $currentcateg = new ITILCategory();
$currentcateg->getFromDB($_POST['value']); $currentcateg->getFromDB($_POST['value']);
if ($_POST["type"]) { if ($_POST["type"]) {
switch ($_POST['type']) { switch ($_POST['type']) {
case Ticket::INCIDENT_TYPE : case Ticket::INCIDENT_TYPE :
$opt['condition']['is_incident'] = '1'; $opt['condition']['is_incident'] = '1';
if ($currentcateg->getField('is_incident') == 1) { if ($currentcateg->getField('is_incident') == 1) {
$opt['value'] = $_POST['value']; $opt['value'] = $_POST['value'];
} }
break; break;
case Ticket::DEMAND_TYPE: case Ticket::DEMAND_TYPE:
$opt['condition']['is_request'] = '1'; $opt['condition']['is_request'] = '1';
if ($currentcateg->getField('is_request') == 1) { if ($currentcateg->getField('is_request') == 1) {
$opt['value'] = $_POST['value']; $opt['value'] = $_POST['value'];
} }
break; break;
} }
} }
ITILCategory::dropdown($opt); ITILCategory::dropdown($opt);

View File

@@ -1,2 +1,2 @@
<?php <?php

View File

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

View File

@@ -1,34 +1,34 @@
<?php <?php
include_once ("../../../inc/includes.php"); include_once ("../../../inc/includes.php");
Session::checkLoginUser(); Session::checkLoginUser();
Plugin::load('processmaker', true); // ??? Plugin::load('processmaker', true); // ???
if (!isset($_REQUEST["id"])) { if (!isset($_REQUEST["id"])) {
$_REQUEST["id"] = ""; $_REQUEST["id"] = "";
} }
$PluginCaselink = new PluginProcessmakerCaselink(); $PluginCaselink = new PluginProcessmakerCaselink();
if (isset($_REQUEST["update"])) { if (isset($_REQUEST["update"])) {
$PluginCaselink->check($_REQUEST['id'], UPDATE); $PluginCaselink->check($_REQUEST['id'], UPDATE);
$PluginCaselink->update($_REQUEST); $PluginCaselink->update($_REQUEST);
Html::back(); Html::back();
} else if (isset($_REQUEST['add'])) { } else if (isset($_REQUEST['add'])) {
$PluginCaselink->check($_REQUEST['id'], UPDATE); $PluginCaselink->check($_REQUEST['id'], UPDATE);
$PluginCaselink->add($_REQUEST); $PluginCaselink->add($_REQUEST);
Html::back(); Html::back();
} else if (isset($_REQUEST['purge'])) { } else if (isset($_REQUEST['purge'])) {
$PluginCaselink->check($_REQUEST['id'], PURGE); $PluginCaselink->check($_REQUEST['id'], PURGE);
$PluginCaselink->delete($_REQUEST, true); $PluginCaselink->delete($_REQUEST, true);
$PluginCaselink->redirectToList(); $PluginCaselink->redirectToList();
} else { } else {
Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "caselinks"); Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "caselinks");
$PluginCaselink->display($_REQUEST); $PluginCaselink->display($_REQUEST);
Html::footer(); Html::footer();
} }

View File

@@ -1,15 +1,15 @@
<?php <?php
include_once ("../../../inc/includes.php"); include_once ("../../../inc/includes.php");
Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "caselinks"); Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "caselinks");
if (Session::haveRightsOr("plugin_processmaker_config", [READ, UPDATE])) { if (Session::haveRightsOr("plugin_processmaker_config", [READ, UPDATE])) {
Search::show('PluginProcessmakerCaselink'); Search::show('PluginProcessmakerCaselink');
} else { } else {
Html::displayRightError(); Html::displayRightError();
} }
Html::footer(); Html::footer();

View File

@@ -1,21 +1,21 @@
<?php <?php
include ( "../../../inc/includes.php"); include ( "../../../inc/includes.php");
$config = new PluginProcessmakerConfig(); $config = new PluginProcessmakerConfig();
if (isset($_POST["update"])) { if (isset($_POST["update"])) {
$config->check($_POST['id'], UPDATE); $config->check($_POST['id'], UPDATE);
// save // save
$config->update($_POST); $config->update($_POST);
Html::back(); Html::back();
} else if (isset($_POST["refresh"])) { } else if (isset($_POST["refresh"])) {
$config->refresh($_POST); // used to refresh process list, task category list $config->refresh($_POST); // used to refresh process list, task category list
Html::back(); Html::back();
} }
Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=". Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=".
urlencode('PluginProcessmakerConfig$1')); urlencode('PluginProcessmakerConfig$1'));

View File

@@ -1,32 +1,32 @@
<?php <?php
include_once ("../../../inc/includes.php"); include_once ("../../../inc/includes.php");
Session::checkLoginUser(); Session::checkLoginUser();
Plugin::load('processmaker', true); // ??? Plugin::load('processmaker', true); // ???
if (!isset($_REQUEST["id"])) { if (!isset($_REQUEST["id"])) {
$_REQUEST["id"] = ""; $_REQUEST["id"] = "";
} }
$PluginProcess = new PluginProcessmakerProcess(); $PluginProcess = new PluginProcessmakerProcess();
if (isset($_REQUEST["update"])) { if (isset($_REQUEST["update"])) {
$PluginProcess->check($_REQUEST['id'], UPDATE); $PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->update($_REQUEST); $PluginProcess->update($_REQUEST);
Html::back(); Html::back();
} else if (isset($_REQUEST["refreshtask"])) { } else if (isset($_REQUEST["refreshtask"])) {
$PluginProcess->check($_REQUEST['id'], UPDATE); $PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->refreshTasks($_REQUEST); $PluginProcess->refreshTasks($_REQUEST);
Html::back(); Html::back();
} else { } else {
Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "processes"); Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "processes");
$PluginProcess->display($_REQUEST); $PluginProcess->display($_REQUEST);
Html::footer(); Html::footer();
} }

View File

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

View File

@@ -1,16 +1,16 @@
<?php <?php
include_once ("../../../inc/includes.php"); include_once ("../../../inc/includes.php");
Session::checkCentralAccess(); Session::checkCentralAccess();
$right = new PluginProcessmakerProcess_Profile(); $right = new PluginProcessmakerProcess_Profile();
if (isset($_POST["add"])) { if (isset($_POST["add"])) {
$right->check(-1, UPDATE, $_POST); $right->check(-1, UPDATE, $_POST);
$right->add($_POST); $right->add($_POST);
Html::back(); Html::back();
} }
Html::displayErrorAndDie("lost"); Html::displayErrorAndDie("lost");

View File

@@ -1,38 +1,38 @@
<?php <?php
/** /**
* casechangelog short summary. * casechangelog short summary.
* *
* casechangelog description. * casechangelog description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCasechangelog extends CommonDBTM { 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;
$rand = rand(); $rand = rand();
$caseHistoryURL = $PM_SOAP->serverURL."/cases/ajaxListener?action=changeLogHistory&rand=$rand"; $caseHistoryURL = $PM_SOAP->serverURL."/cases/ajaxListener?action=changeLogHistory&rand=$rand";
$PM_SOAP->echoDomain(); $PM_SOAP->echoDomain();
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'
$iframe = "<iframe $iframe = "<iframe
id='caseiframe-caseChangeLogHistory' id='caseiframe-caseChangeLogHistory'
style='border: none;' style='border: none;'
width='100%' width='100%'
src='$caseHistoryURL' src='$caseHistoryURL'
onload=\"onOtherFrameLoad( 'caseChangeLogHistory', 'caseiframe-caseChangeLogHistory', 'body', 0 );\"> onload=\"onOtherFrameLoad( 'caseChangeLogHistory', 'caseiframe-caseChangeLogHistory', 'body', 0 );\">
</iframe>"; </iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); $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) {
return __('Change log', 'processmaker'); return __('Change log', 'processmaker');
} }
} }

View File

@@ -1,86 +1,86 @@
<?php <?php
/** /**
* PluginProcessmakerCasemap short summary. * PluginProcessmakerCasemap short summary.
* *
* casemap description. * casemap description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCasedynaform extends CommonDBTM { class PluginProcessmakerCasedynaform 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; $config = $PM_SOAP->config;
$rand = rand(); $rand = rand();
$proj = new PluginProcessmakerProcess; $proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']); $proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
$PM_SOAP->echoDomain(); $PM_SOAP->echoDomain();
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) { function urldecode(url) {
return decodeURIComponent(url.replace(/\+/g, ' ')); 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
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>' );
} }
$.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']}', $.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']}',
xhrFields: { withCredentials: true }, xhrFields: { withCredentials: true },
cache: false, cache: false,
crossDomain: true, crossDomain: true,
success: function(jqXHR) { success: function(jqXHR) {
//debugger; //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(); 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
} }); } });
} else { // only activate it } else { // only activate 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.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\' ></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>'
); );
} }
} }
} ; } ;
</script>"; </script>";
$caseURL = $PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand"; $caseURL = $PM_SOAP->serverURL."/cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage&rand=$rand";
$iframe = "<iframe $iframe = "<iframe
id='caseiframe-historyDynaformPage' id='caseiframe-historyDynaformPage'
style='border: none;' style='border: none;'
width='100%' width='100%'
src='$caseURL' src='$caseURL'
onload=\"onOtherFrameLoad( 'historyDynaformPage', 'caseiframe-historyDynaformPage', 'body', 0 );\"> onload=\"onOtherFrameLoad( 'historyDynaformPage', 'caseiframe-historyDynaformPage', 'body', 0 );\">
</iframe>"; </iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); $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) {
return __('Dynaforms', 'processmaker'); return __('Dynaforms', 'processmaker');
} }
} }

View File

@@ -1,38 +1,38 @@
<?php <?php
/** /**
* casehistory short summary. * casehistory short summary.
* *
* casehistory description. * casehistory description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCasehistory extends CommonDBTM { 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;
$rand = rand(); $rand = rand();
$caseHistoryURL = $PM_SOAP->serverURL $caseHistoryURL = $PM_SOAP->serverURL
."/cases/ajaxListener?action=caseHistory&rand=$rand"; ."/cases/ajaxListener?action=caseHistory&rand=$rand";
$PM_SOAP->echoDomain(); $PM_SOAP->echoDomain();
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>";
$iframe = "<iframe $iframe = "<iframe
id='caseiframe-caseHistory' id='caseiframe-caseHistory'
style='border: none;' style='border: none;'
width='100%' width='100%'
src='$caseHistoryURL' src='$caseHistoryURL'
onload=\"onOtherFrameLoad( 'caseHistory', 'caseiframe-caseHistory', 'body', 0 );\"> onload=\"onOtherFrameLoad( 'caseHistory', 'caseiframe-caseHistory', 'body', 0 );\">
</iframe>"; </iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); $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) {
return __('History', 'processmaker'); return __('History', 'processmaker');
} }
} }

View File

@@ -1,285 +1,285 @@
<?php <?php
/** /**
* PluginProcessmakerCaselink short summary. * PluginProcessmakerCaselink short summary.
* *
* PluginProcessmakerCaselink description. * PluginProcessmakerCaselink description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCaselink extends CommonDBTM { class PluginProcessmakerCaselink extends CommonDBTM {
static function canCreate() { static function canCreate() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
static function canView() { static function canView() {
return Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE]); return Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE]);
} }
static function canUpdate() { static function canUpdate() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
static function canDelete() { static function canDelete() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
static function canPurge() { static function canPurge() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
function canUpdateItem() { function canUpdateItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
function canDeleteItem() { function canDeleteItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
function canPurgeItem() { function canPurgeItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE); return Session::haveRight('plugin_processmaker_config', UPDATE);
} }
function maybeDeleted() { function maybeDeleted() {
return false; return false;
} }
static function getTypeName($nb = 0) { static function getTypeName($nb = 0) {
if ($nb>1) { if ($nb>1) {
return __('Case-links', 'processmaker'); return __('Case-links', 'processmaker');
} }
return __('Case-link', 'processmaker'); return __('Case-link', 'processmaker');
} }
function showForm ($ID, $options = ['candel'=>false]) { function showForm ($ID, $options = ['candel'=>false]) {
global $DB, $CFG_GLPI; global $DB, $CFG_GLPI;
$options['candel'] = true; $options['candel'] = true;
$this->initForm($ID, $options); $this->initForm($ID, $options);
$this->showFormHeader($options); $this->showFormHeader($options);
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td>".__('Name')."</td><td>"; echo "<td>".__('Name')."</td><td>";
echo "<input size='100' type='text' name='name' value='".Html::cleanInputText($this->fields["name"])."'>"; echo "<input size='100' type='text' name='name' value='".Html::cleanInputText($this->fields["name"])."'>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Active')."</td><td>"; echo "<td >".__('Active')."</td><td>";
Dropdown::showYesNo("is_active", $this->fields["is_active"]); Dropdown::showYesNo("is_active", $this->fields["is_active"]);
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Synchronous', 'processmaker')."</td><td>"; echo "<td >".__('Synchronous', 'processmaker')."</td><td>";
Dropdown::showYesNo("is_synchronous", $this->fields["is_synchronous"]); Dropdown::showYesNo("is_synchronous", $this->fields["is_synchronous"]);
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('External data', 'processmaker')."</td><td>"; echo "<td >".__('External data', 'processmaker')."</td><td>";
Dropdown::showYesNo("is_externaldata", $this->fields["is_externaldata"]); Dropdown::showYesNo("is_externaldata", $this->fields["is_externaldata"]);
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Self', 'processmaker')."</td><td>"; echo "<td >".__('Self', 'processmaker')."</td><td>";
Dropdown::showYesNo("is_self", $this->fields["is_self"]); Dropdown::showYesNo("is_self", $this->fields["is_self"]);
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Source task GUID', 'processmaker')."</td><td>"; echo "<td >".__('Source task GUID', 'processmaker')."</td><td>";
//PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_source', //PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_source',
// 'display_emptychoice' => false, // 'display_emptychoice' => false,
// 'value' => $this->fields['plugin_processmaker_taskcategories_id_source'])); // 'value' => $this->fields['plugin_processmaker_taskcategories_id_source']));
echo "<input size='100' type='text' name='sourcetask_guid' value='".$this->fields["sourcetask_guid"]."'>"; echo "<input size='100' type='text' name='sourcetask_guid' value='".$this->fields["sourcetask_guid"]."'>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Target task GUID', 'processmaker')."</td><td>"; echo "<td >".__('Target task GUID', 'processmaker')."</td><td>";
//PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_target', //PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_target',
// 'display_emptychoice' => false, // 'display_emptychoice' => false,
// 'value' => $this->fields['plugin_processmaker_taskcategories_id_target'])); // 'value' => $this->fields['plugin_processmaker_taskcategories_id_target']));
echo "<input size='100' type='text' name='targettask_guid' value='".$this->fields["targettask_guid"]."'>"; echo "<input size='100' type='text' name='targettask_guid' value='".$this->fields["targettask_guid"]."'>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Target process GUID', 'processmaker')."</td><td>"; echo "<td >".__('Target process GUID', 'processmaker')."</td><td>";
//Dropdown::show( 'PluginProcessmakerProcess', array('name' => 'plugin_processmaker_processes_id', //Dropdown::show( 'PluginProcessmakerProcess', array('name' => 'plugin_processmaker_processes_id',
// 'display_emptychoice' => true, // 'display_emptychoice' => true,
// 'value' => $this->fields['plugin_processmaker_processes_id'], // 'value' => $this->fields['plugin_processmaker_processes_id'],
// 'condition' => 'is_active = 1')); // 'condition' => 'is_active = 1'));
echo "<input size='100' type='text' name='targetprocess_guid' value='".$this->fields["targetprocess_guid"]."'>"; echo "<input size='100' type='text' name='targetprocess_guid' value='".$this->fields["targetprocess_guid"]."'>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td>".__('Target dynaform GUID', 'processmaker')."</td><td>"; echo "<td>".__('Target dynaform GUID', 'processmaker')."</td><td>";
echo "<input size='100' type='text' name='targetdynaform_guid' value='".$this->fields["targetdynaform_guid"]."'>"; echo "<input size='100' type='text' name='targetdynaform_guid' value='".$this->fields["targetdynaform_guid"]."'>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td>".__('Source condition', 'processmaker')."</td><td>"; echo "<td>".__('Source condition', 'processmaker')."</td><td>";
//echo "<input size='100' type='text' name='sourcecondition' value='".$this->fields["sourcecondition"]."'>"; //echo "<input size='100' type='text' name='sourcecondition' value='".$this->fields["sourcecondition"]."'>";
echo "<textarea cols='100' rows='3' name='sourcecondition' >".$this->fields["sourcecondition"]."</textarea>"; echo "<textarea cols='100' rows='3' name='sourcecondition' >".$this->fields["sourcecondition"]."</textarea>";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Claim target task', 'processmaker')."</td><td>"; echo "<td >".__('Claim target task', 'processmaker')."</td><td>";
Dropdown::showYesNo("is_targettoclaim", $this->fields["is_targettoclaim"]); Dropdown::showYesNo("is_targettoclaim", $this->fields["is_targettoclaim"]);
echo "</td></tr>"; echo "</td></tr>";
//echo "<tr class='tab_bg_1'>"; //echo "<tr class='tab_bg_1'>";
//echo "<td >".__('Reassign target task', 'processmaker')."</td><td>"; //echo "<td >".__('Reassign target task', 'processmaker')."</td><td>";
//Dropdown::showYesNo("is_targettoreassign", $this->fields["is_targettoreassign"]); //Dropdown::showYesNo("is_targettoreassign", $this->fields["is_targettoreassign"]);
//echo "</td></tr>"; //echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td >".__('Impersonate target task user', 'processmaker')."</td><td>"; echo "<td >".__('Impersonate target task user', 'processmaker')."</td><td>";
Dropdown::showYesNo("is_targettoimpersonate", $this->fields["is_targettoimpersonate"]); Dropdown::showYesNo("is_targettoimpersonate", $this->fields["is_targettoimpersonate"]);
echo "</td></tr>"; echo "</td></tr>";
echo "<tr class='tab_bg_1'>"; echo "<tr class='tab_bg_1'>";
echo "<td>".__('External application JSON config', 'processmaker')."</td><td>"; echo "<td>".__('External application JSON config', 'processmaker')."</td><td>";
echo "<textarea cols='100' rows='6' name='externalapplication' >".$this->fields["externalapplication"]."</textarea>"; echo "<textarea cols='100' rows='6' name='externalapplication' >".$this->fields["externalapplication"]."</textarea>";
echo "</td></tr>"; echo "</td></tr>";
$this->showFormButtons($options ); $this->showFormButtons($options );
} }
/** /**
* Summary of rawSearchOptions * Summary of rawSearchOptions
* @return mixed * @return mixed
*/ */
function rawSearchOptions() { function rawSearchOptions() {
$tab = []; $tab = [];
$tab[] = [ $tab[] = [
'id' => 'common', 'id' => 'common',
'name' => __('ProcessMaker', 'processmaker') 'name' => __('ProcessMaker', 'processmaker')
]; ];
$tab[] = [ $tab[] = [
'id' => '1', 'id' => '1',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'name', 'field' => 'name',
'name' => __('Name'), 'name' => __('Name'),
'datatype' => 'itemlink', 'datatype' => 'itemlink',
'itemlink_type' => 'PluginProcessmakerCaselink', 'itemlink_type' => 'PluginProcessmakerCaselink',
'massiveaction' => false 'massiveaction' => false
]; ];
$tab[] = [ $tab[] = [
'id' => '8', 'id' => '8',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'is_active', 'field' => 'is_active',
'name' => __('Active'), 'name' => __('Active'),
'massiveaction' => true, 'massiveaction' => true,
'datatype' => 'bool' 'datatype' => 'bool'
]; ];
$tab[] = [ $tab[] = [
'id' => '9', 'id' => '9',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'date_mod', 'field' => 'date_mod',
'name' => __('Last update'), 'name' => __('Last update'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'datetime' 'datatype' => 'datetime'
]; ];
$tab[] = [ $tab[] = [
'id' => '10', 'id' => '10',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'is_externaldata', 'field' => 'is_externaldata',
'name' => __('External data', 'processmaker'), 'name' => __('External data', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'bool' 'datatype' => 'bool'
]; ];
$tab[] = [ $tab[] = [
'id' => '11', 'id' => '11',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'is_self', 'field' => 'is_self',
'name' => __('Self', 'processmaker'), 'name' => __('Self', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'bool' 'datatype' => 'bool'
]; ];
$tab[] = [ $tab[] = [
'id' => '12', 'id' => '12',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'is_targettoclaim', 'field' => 'is_targettoclaim',
'name' => __('Claim target task', 'processmaker'), 'name' => __('Claim target task', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'bool' 'datatype' => 'bool'
]; ];
$tab[] = [ $tab[] = [
'id' => '13', 'id' => '13',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'externalapplication', 'field' => 'externalapplication',
'name' => __('External application JSON config', 'processmaker'), 'name' => __('External application JSON config', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
$tab[] = [ $tab[] = [
'id' => '14', 'id' => '14',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'sourcetask_guid', 'field' => 'sourcetask_guid',
'name' => __('Source task GUID', 'processmaker'), 'name' => __('Source task GUID', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
$tab[] = [ $tab[] = [
'id' => '15', 'id' => '15',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'targettask_guid', 'field' => 'targettask_guid',
'name' => __('Target task GUID', 'processmaker'), 'name' => __('Target task GUID', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
$tab[] = [ $tab[] = [
'id' => '16', 'id' => '16',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'targetdynaform_guid', 'field' => 'targetdynaform_guid',
'name' => __('Target dynaform GUID', 'processmaker'), 'name' => __('Target dynaform GUID', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
$tab[] = [ $tab[] = [
'id' => '17', 'id' => '17',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'targetprocess_guid', 'field' => 'targetprocess_guid',
'name' => __('Target process GUID', 'processmaker'), 'name' => __('Target process GUID', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
$tab[] = [ $tab[] = [
'id' => '18', 'id' => '18',
'table' => $this->getTable(), 'table' => $this->getTable(),
'field' => 'sourcecondition', 'field' => 'sourcecondition',
'name' => __('Source condition', 'processmaker'), 'name' => __('Source condition', 'processmaker'),
'massiveaction' => false, 'massiveaction' => false,
'datatype' => 'text' 'datatype' => 'text'
]; ];
return $tab; return $tab;
} }
function prepareInputForUpdate($input) { function prepareInputForUpdate($input) {
return Toolbox::unclean_cross_side_scripting_deep($input); return Toolbox::unclean_cross_side_scripting_deep($input);
} }
function prepareInputForAdd($input) { function prepareInputForAdd($input) {
return Toolbox::unclean_cross_side_scripting_deep($input); return Toolbox::unclean_cross_side_scripting_deep($input);
} }
} }

View File

@@ -1,12 +1,12 @@
<?php <?php
/** /**
* PluginProcessmakerCaselinkaction short summary. * PluginProcessmakerCaselinkaction short summary.
* *
* PluginProcessmakerCaselinkaction description. * PluginProcessmakerCaselinkaction description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCaselinkaction extends CommonDBTM { class PluginProcessmakerCaselinkaction extends CommonDBTM {
} }

View File

@@ -1,47 +1,47 @@
<?php <?php
/** /**
* PluginProcessmakerCasemap short summary. * PluginProcessmakerCasemap short summary.
* *
* casemap description. * casemap description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerCasemap extends CommonDBTM { 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;
$rand = rand(); $rand = rand();
$proj = new PluginProcessmakerProcess; $proj = new PluginProcessmakerProcess;
$proj->getFromDB($case->fields['plugin_processmaker_processes_id']); $proj->getFromDB($case->fields['plugin_processmaker_processes_id']);
$project_type = $proj->fields['project_type']; $project_type = $proj->fields['project_type'];
$caseMapUrl = $PM_SOAP->serverURL.( $caseMapUrl = $PM_SOAP->serverURL.(
$project_type=='bpmn' ? $project_type=='bpmn' ?
"/designer?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?action=processMap" "/cases/ajaxListener?action=processMap"
)."&rand=$rand"; )."&rand=$rand";
$PM_SOAP->echoDomain(); $PM_SOAP->echoDomain();
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'
$iframe = "<iframe $iframe = "<iframe
id='caseiframe-caseMap' id='caseiframe-caseMap'
style='border: none;' width='100%' style='border: none;' width='100%'
src='$caseMapUrl' src='$caseMapUrl'
onload=\"onOtherFrameLoad( 'caseMap', 'caseiframe-caseMap', 'body', ".($project_type=='bpmn' ? "true" : "false" )." );\"> onload=\"onOtherFrameLoad( 'caseMap', 'caseiframe-caseMap', 'body', ".($project_type=='bpmn' ? "true" : "false" )." );\">
</iframe>"; </iframe>";
$PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); $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) {
return __('Map', 'processmaker'); return __('Map', 'processmaker');
} }
} }

View File

@@ -1,20 +1,20 @@
<?php <?php
/** /**
* PluginProcessmakerGlpikey short summary. * PluginProcessmakerGlpikey short summary.
* *
* PluginProcessmakerGlpikey description. * PluginProcessmakerGlpikey description.
* *
* @version 1.0 * @version 1.0
* @author MoronO * @author MoronO
*/ */
class PluginProcessmakerGlpikey extends GLPIKey { class PluginProcessmakerGlpikey extends GLPIKey {
protected $fields = [ protected $fields = [
'glpi_plugin_processmaker_configs.pm_admin_passwd', 'glpi_plugin_processmaker_configs.pm_admin_passwd',
'glpi_plugin_processmaker_configs.pm_dbserver_passwd', 'glpi_plugin_processmaker_configs.pm_dbserver_passwd',
]; ];
/** /**
* Get fields * Get fields
* *
@@ -22,9 +22,9 @@ class PluginProcessmakerGlpikey extends GLPIKey {
*/ */
public function getFields() :array { public function getFields() :array {
return $this->fields; return $this->fields;
} }
/** /**
* Generate GLPI security key used for decryptable passwords * Generate GLPI security key used for decryptable passwords
* and update values in DB if necessary. * and update values in DB if necessary.
@@ -43,6 +43,6 @@ class PluginProcessmakerGlpikey extends GLPIKey {
return false; return false;
} }
} }

View File

@@ -1,133 +1,133 @@
<?php <?php
if (!defined('GLPI_ROOT')) { if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file"); die("Sorry. You can't access directly to this file");
} }
class PluginProcessmakerProfile extends CommonDBTM { class PluginProcessmakerProfile extends CommonDBTM {
/** /**
* Summary of getAllRights * Summary of getAllRights
* @return array[] * @return array[]
*/ */
static function getAllRights() { static function getAllRights() {
$rights = [ $rights = [
['itemtype' => 'PluginProcessmakerConfig', ['itemtype' => 'PluginProcessmakerConfig',
'label' => __('Process configuration', 'processmaker'), 'label' => __('Process configuration', 'processmaker'),
'field' => 'plugin_processmaker_config', 'field' => 'plugin_processmaker_config',
'rights' => [READ => __('Read'), UPDATE => __('Update')]], 'rights' => [READ => __('Read'), UPDATE => __('Update')]],
['itemtype' => 'PluginProcessmakerConfig', ['itemtype' => 'PluginProcessmakerConfig',
'label' => __('Cases', 'processmaker'), 'label' => __('Cases', 'processmaker'),
'field' => 'plugin_processmaker_case', 'field' => 'plugin_processmaker_case',
'rights' => [READ => __('Read'), CANCEL => __('Cancel', 'processmaker'), DELETE => __('Delete'), ADHOC_REASSIGN => __('Ad Hoc user re-assign', 'processmaker')]] 'rights' => [READ => __('Read'), CANCEL => __('Cancel', 'processmaker'), DELETE => __('Delete'), ADHOC_REASSIGN => __('Ad Hoc user re-assign', 'processmaker')]]
]; ];
return $rights; return $rights;
} }
/** /**
* Summary of showForm * Summary of showForm
* @param mixed $ID * @param mixed $ID
* @param mixed $openform * @param mixed $openform
* @param mixed $closeform * @param mixed $closeform
* @return bool * @return bool
*/ */
function showForm($ID = 0, $openform = true, $closeform = true) { function showForm($ID = 0, $openform = true, $closeform = true) {
if (!Session::haveRight("profile", READ)) { if (!Session::haveRight("profile", READ)) {
return false; return false;
} }
$canedit = Session::haveRight("profile", UPDATE); $canedit = Session::haveRight("profile", UPDATE);
$prof = new Profile(); $prof = new Profile();
if ($ID) { if ($ID) {
$prof->getFromDB($ID); $prof->getFromDB($ID);
} }
echo "<form action='".$prof->getFormURL()."' method='post'>"; echo "<form action='".$prof->getFormURL()."' method='post'>";
$rights = $this->getAllRights(); $rights = $this->getAllRights();
$prof->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, $prof->displayRightsChoiceMatrix($rights, ['canedit' => $canedit,
'default_class' => 'tab_bg_2', 'default_class' => 'tab_bg_2',
'title' => __('ProcessMaker', 'processmaker')]); 'title' => __('ProcessMaker', 'processmaker')]);
if ($canedit && $closeform) { if ($canedit && $closeform) {
echo "<div class='center'>"; echo "<div class='center'>";
echo Html::hidden('id', ['value' => $ID]); echo Html::hidden('id', ['value' => $ID]);
echo Html::submit(_sx('button', 'Save'), echo Html::submit(_sx('button', 'Save'),
['name' => 'update']); ['name' => 'update']);
echo "</div>\n"; echo "</div>\n";
} }
Html::closeForm(); Html::closeForm();
return true; return true;
} }
/** /**
* Summary of createAdminAccess * Summary of createAdminAccess
* @param mixed $ID * @param mixed $ID
*/ */
static function createAdminAccess($ID) { static function createAdminAccess($ID) {
self::addDefaultProfileInfos($ID, ['plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_case' => READ + DELETE + CANCEL + ADHOC_REASSIGN], true); self::addDefaultProfileInfos($ID, ['plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_case' => READ + DELETE + CANCEL + ADHOC_REASSIGN], true);
} }
/** /**
* Summary of getTabNameForItem * Summary of getTabNameForItem
* @param CommonGLPI $item * @param CommonGLPI $item
* @param mixed $withtemplate * @param mixed $withtemplate
* @return string|string[] * @return string|string[]
*/ */
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
if ($item->getType()=='Profile') { if ($item->getType()=='Profile') {
return __('ProcessMaker', 'processmaker'); return __('ProcessMaker', 'processmaker');
} }
return ''; return '';
} }
/** /**
* Summary of displayTabContentForItem * Summary of displayTabContentForItem
* @param CommonGLPI $item * @param CommonGLPI $item
* @param mixed $tabnum * @param mixed $tabnum
* @param mixed $withtemplate * @param mixed $withtemplate
* @return bool * @return bool
*/ */
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
global $CFG_GLPI; global $CFG_GLPI;
if ($item->getType()=='Profile') { if ($item->getType()=='Profile') {
$ID = $item->getID(); $ID = $item->getID();
$prof = new self(); $prof = new self();
self::addDefaultProfileInfos($ID, self::addDefaultProfileInfos($ID,
['plugin_processmaker_config' => 0, ['plugin_processmaker_config' => 0,
'plugin_processmaker_case' => 0 'plugin_processmaker_case' => 0
]); ]);
$prof->showForm($ID); $prof->showForm($ID);
} }
return true; return true;
} }
/** /**
* @param $profile * @param $profile
**/ **/
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) { static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
global $DB; global $DB;
$dbu = new DbUtils; $dbu = new DbUtils;
$profileRight = new ProfileRight(); $profileRight = new ProfileRight();
foreach ($rights as $right => $value) { foreach ($rights as $right => $value) {
if ($dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]]) && $drop_existing) { if ($dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]]) && $drop_existing) {
$profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]); $profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]);
} }
if (!$dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]])) { if (!$dbu->countElementsInTable('glpi_profilerights', ['AND' => ['profiles_id' => $profiles_id, 'name' => $right]])) {
$myright['profiles_id'] = $profiles_id; $myright['profiles_id'] = $profiles_id;
$myright['name'] = $right; $myright['name'] = $right;
$myright['rights'] = $value; $myright['rights'] = $value;
$profileRight->add($myright); $profileRight->add($myright);
//Add right to the current session //Add right to the current session
$_SESSION['glpiactiveprofile'][$right] = $value; $_SESSION['glpiactiveprofile'][$right] = $value;
} }
} }
} }
} }

View File

@@ -1,13 +1,13 @@
<?php <?php
/** /**
* selfservicedraft short summary. * selfservicedraft short summary.
* *
* selfservicedraft description. * selfservicedraft description.
* *
* @version 1.0 * @version 1.0
* @author morono * @author morono
*/ */
class PluginProcessmakerSelfservicedraft extends CommonDBTM { class PluginProcessmakerSelfservicedraft extends CommonDBTM {
} }

View File

@@ -1,13 +1,13 @@
<?php <?php
function processmaker_install() { function processmaker_install() {
global $DB; global $DB;
// installation from scratch // installation from scratch
$DB->runFile(GLPI_ROOT . "/plugins/processmaker/install/mysql/processmaker-empty.sql"); $DB->runFile(GLPI_ROOT . "/plugins/processmaker/install/mysql/processmaker-empty.sql");
// add configuration singleton // add configuration singleton
$query = "INSERT INTO `glpi_plugin_processmaker_configs` (`id`) VALUES (1);"; $query = "INSERT INTO `glpi_plugin_processmaker_configs` (`id`) VALUES (1);";
$DB->query( $query ) or die("error creating default record in glpi_plugin_processmaker_configs" . $DB->error()); $DB->query( $query ) or die("error creating default record in glpi_plugin_processmaker_configs" . $DB->error());
} }

View File

@@ -1,14 +1,14 @@
<?php <?php
function update_3_2_8_to_3_2_9() { function update_3_2_8_to_3_2_9() {
global $DB; global $DB;
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "db_version")) { if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "db_version")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs` $query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `db_version` VARCHAR(10) NULL;"; ADD COLUMN `db_version` VARCHAR(10) NULL;";
$DB->query($query) or die("error adding db_version field to glpi_plugin_processmaker_configs" . $DB->error()); $DB->query($query) or die("error adding db_version field to glpi_plugin_processmaker_configs" . $DB->error());
} }
return '3.2.9'; return '3.2.9';
} }

View File

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

View File

@@ -1,30 +1,30 @@
<?php <?php
function update_3_3_0_to_3_3_1() { function update_3_3_0_to_3_3_1() {
global $DB; global $DB;
// Alter table glpi_plugin_processmaker_processes // Alter table glpi_plugin_processmaker_processes
if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "is_change" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "is_change" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes` $query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `is_change` TINYINT(1) NOT NULL DEFAULT '0' AFTER `project_type`, ADD COLUMN `is_change` TINYINT(1) NOT NULL DEFAULT '0' AFTER `project_type`,
ADD COLUMN `is_problem` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_change`, ADD COLUMN `is_problem` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_change`,
ADD COLUMN `is_incident` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_problem`, ADD COLUMN `is_incident` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_problem`,
ADD COLUMN `is_request` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_incident`;"; ADD COLUMN `is_request` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_incident`;";
$DB->query($query) or die("error adding is_change, etc... to glpi_plugin_processmaker_processes table" . $DB->error()); $DB->query($query) or die("error adding is_change, etc... to glpi_plugin_processmaker_processes table" . $DB->error());
} }
// Alter table glpi_plugin_processmaker_caselinks // Alter table glpi_plugin_processmaker_caselinks
if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "is_targettoreassign" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "is_targettoreassign" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_caselinks` $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
ADD COLUMN `is_targettoreassign` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_targettoclaim`, ADD COLUMN `is_targettoreassign` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_targettoclaim`,
ADD COLUMN `is_targettoimpersonate` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_targettoreassign`, ADD COLUMN `is_targettoimpersonate` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_targettoreassign`,
ADD COLUMN `is_synchronous` TINYINT(1) NOT NULL DEFAULT '0' AFTER `externalapplication`;"; ADD COLUMN `is_synchronous` TINYINT(1) NOT NULL DEFAULT '0' AFTER `externalapplication`;";
$DB->query($query) or die("error adding is_targettoreassign, etc... to glpi_plugin_processmaker_caselinks table" . $DB->error()); $DB->query($query) or die("error adding is_targettoreassign, etc... to glpi_plugin_processmaker_caselinks table" . $DB->error());
} }
return '3.3.1'; return '3.3.1';
} }

View File

@@ -1,15 +1,15 @@
<?php <?php
function update_3_3_1_to_3_3_8() { function update_3_3_1_to_3_3_8() {
global $DB; global $DB;
// Alter table glpi_plugin_processmaker_configs // Alter table glpi_plugin_processmaker_configs
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "ssl_verify" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "ssl_verify" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs` $query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `ssl_verify` TINYINT(1) NOT NULL DEFAULT '0' AFTER `maintenance`;"; ADD COLUMN `ssl_verify` TINYINT(1) NOT NULL DEFAULT '0' AFTER `maintenance`;";
$DB->query($query) or die("error adding ssl_verify to glpi_plugin_processmaker_configs table" . $DB->error()); $DB->query($query) or die("error adding ssl_verify to glpi_plugin_processmaker_configs table" . $DB->error());
} }
return '3.3.8'; return '3.3.8';
} }

View File

@@ -1,30 +1,30 @@
<?php <?php
function update_3_3_8_to_3_4_9() { function update_3_3_8_to_3_4_9() {
global $DB; global $DB;
// Alter table glpi_plugin_processmaker_configs // Alter table glpi_plugin_processmaker_configs
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "max_cases_per_item" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "max_cases_per_item" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs` $query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `db_version`;"; ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `db_version`;";
$DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_configs table" . $DB->error()); $DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_configs table" . $DB->error());
} }
// Alter table glpi_plugin_processmaker_processes // Alter table glpi_plugin_processmaker_processes
if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "maintenance" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "maintenance" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes` $query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_request`;"; ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_request`;";
$DB->query($query) or die("error adding maintenance to glpi_plugin_processmaker_processes table" . $DB->error()); $DB->query($query) or die("error adding maintenance to glpi_plugin_processmaker_processes table" . $DB->error());
} }
// Alter table glpi_plugin_processmaker_processes // Alter table glpi_plugin_processmaker_processes
if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "max_cases_per_item" )) { if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "max_cases_per_item" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes` $query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `maintenance`;"; ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `maintenance`;";
$DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_processes table" . $DB->error()); $DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_processes table" . $DB->error());
} }
return '3.4.9'; return '3.4.9';
} }

View File

@@ -1,14 +1,14 @@
<?php <?php
function update_3_4_10_to_4_0_0() { function update_3_4_10_to_4_0_0() {
global $DB; global $DB;
// needs to change password encryption // needs to change password encryption
$pmglpikey = new PluginProcessmakerGlpikey; $pmglpikey = new PluginProcessmakerGlpikey;
if ($pmglpikey->migratePasswords()) { if ($pmglpikey->migratePasswords()) {
return '4.0.0'; return '4.0.0';
} }
return false; return false;
} }

View File

@@ -1,12 +1,12 @@
<?php <?php
function update_3_4_9_to_3_4_10() { function update_3_4_9_to_3_4_10() {
global $DB; global $DB;
// needs to change _update_ into _reassign_ in the events field of the glpi_notifications table // needs to change _update_ into _reassign_ in the events field of the glpi_notifications table
$query = "UPDATE `glpi_notifications` SET `event` = REPLACE( `event`, '_update_', '_reassign_') WHERE `event` LIKE '%_update_%' AND `itemtype` = 'PluginProcessmakerTask';"; $query = "UPDATE `glpi_notifications` SET `event` = REPLACE( `event`, '_update_', '_reassign_') WHERE `event` LIKE '%_update_%' AND `itemtype` = 'PluginProcessmakerTask';";
$DB->query($query) or die("error when updating event field in glpi_notifications" . $DB->error()); $DB->query($query) or die("error when updating event field in glpi_notifications" . $DB->error());
return '3.4.10'; return '3.4.10';
} }

View File

@@ -1,121 +1,121 @@
 
var oldHandler; var oldHandler;
var submitButton; var submitButton;
var caseIFrame; var caseIFrame;
function onClickContinue(obj) { function onClickContinue(obj) {
//debugger; //debugger;
contentDocument = caseIFrame.contentDocument; contentDocument = caseIFrame.contentDocument;
var txtAreaUserRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]'); var txtAreaUserRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
if ($("textarea[name='content']").val() == '') { if ($("textarea[name='content']").val() == '') {
if (txtAreaUserRequestSumUp) { if (txtAreaUserRequestSumUp) {
tinymce.activeEditor.setContent($(txtAreaUserRequestSumUp).val().replace(/(\r\n)|(\r)|(\n)/g, '<br>')); tinymce.activeEditor.setContent($(txtAreaUserRequestSumUp).val().replace(/(\r\n)|(\r)|(\n)/g, '<br>'));
} else { } else {
tinymce.activeEditor.setContent('_'); tinymce.activeEditor.setContent('_');
} }
} }
// call old handler if any // call old handler if any
//debugger; //debugger;
if (obj != undefined && oldHandler) { if (obj != undefined && oldHandler) {
oldHandler(obj.target); oldHandler(obj.target);
} }
// hide the iFrame // hide the iFrame
caseIFrame.style.visibility = 'hidden'; caseIFrame.style.visibility = 'hidden';
// trigger a click on the 'add' button of the ticket // trigger a click on the 'add' button of the ticket
submitButton.click(); submitButton.click();
} }
// used to find an element in a list and to hide it! // used to find an element in a list and to hide it!
function bGLPIHideElement(eltList, attribute, value) { function bGLPIHideElement(eltList, attribute, value) {
var ret = false; var ret = false;
for (var i = 0; i < eltList.length; i++) { for (var i = 0; i < eltList.length; i++) {
var node = eltList[i]; var node = eltList[i];
if (node.getAttribute(attribute) == value) { if (node.getAttribute(attribute) == value) {
// hide the link // hide the link
node.style.display = 'none'; node.style.display = 'none';
ret = true; ret = true;
} }
} }
return ret; return ret;
} }
function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
var caseTimerCounter = 0; var caseTimerCounter = 0;
var redimIFrame = false; var redimIFrame = false;
var bButtonContinue = false; var bButtonContinue = false;
var caseTimer = window.setInterval(function () { var caseTimer = window.setInterval(function () {
//debugger ; //debugger ;
// look for caseiframe iFrame // look for caseiframe iFrame
caseIFrame = document.getElementById('caseiframe'); caseIFrame = document.getElementById('caseiframe');
var contentDocument; var contentDocument;
try { try {
contentDocument = caseIFrame.contentDocument; contentDocument = caseIFrame.contentDocument;
} catch (ex) { } catch (ex) {
contentDocument = false; contentDocument = false;
} }
if (caseIFrame != undefined && contentDocument) { if (caseIFrame != undefined && contentDocument) {
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]'); var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
var linkList = contentDocument.getElementsByTagName('a'); var linkList = contentDocument.getElementsByTagName('a');
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) { 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 bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
// change action for the attached form and add some parameters // change action for the attached form and add some parameters
//debugger; //debugger;
bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN'); bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN');
oldHandler = buttonContinue.onclick; oldHandler = buttonContinue.onclick;
buttonContinue.onclick = onClickContinue; buttonContinue.onclick = onClickContinue;
submitButton = $("input[name='add'][type=submit]")[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_action' value='routecase'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseguid' value='" + caseId + "'/>"); submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseguid' value='" + caseId + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>"); submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>"); submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
$("input[name='name'][type=text]")[0].value = processName; $("input[name='name'][type=text]")[0].value = processName;
} }
// try to redim caseIFrame // try to redim caseIFrame
if (!redimIFrame) { if (!redimIFrame) {
redimIFrame = true; // to prevent several timer creation redimIFrame = true; // to prevent several timer creation
// redim one time // redim one time
redimTaskFrame(caseIFrame); redimTaskFrame(caseIFrame);
// redim each second // redim each second
var redimFrameTimer = window.setInterval(function () { var redimFrameTimer = window.setInterval(function () {
redimTaskFrame(caseIFrame); redimTaskFrame(caseIFrame);
}, 1000); }, 1000);
} }
} }
if ( caseTimerCounter > 3000 ) { if ( caseTimerCounter > 3000 ) {
window.clearInterval(caseTimer); window.clearInterval(caseTimer);
} else { } else {
caseTimerCounter = caseTimerCounter + 1; caseTimerCounter = caseTimerCounter + 1;
} }
}, 10); }, 10);
} }
function redimTaskFrame(taskFrame) { function redimTaskFrame(taskFrame) {
var newHeight; var newHeight;
try { try {
//var locElt = locContentDocument.getElementsByTagName("table")[0]; //var locElt = locContentDocument.getElementsByTagName("table")[0];
var locElt = taskFrame.contentDocument.getElementsByTagName("html")[0]; var locElt = taskFrame.contentDocument.getElementsByTagName("html")[0];
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10); newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
if (newHeight < 400) { if (newHeight < 400) {
newHeight = 400; newHeight = 400;
} }
taskFrame.height = newHeight; taskFrame.height = newHeight;
} catch (e) { } catch (e) {
} }
} }

View File

@@ -1,312 +1,312 @@
//debugger; //debugger;
// To manage submits to case.front.php // To manage submits to case.front.php
var GLPI_HTTP_CASE_FORM = window.location.href.replace(window.location.search, ''); //window.location.href.split('/', loc_split.length - 2).join('/') + '/plugins/processmaker/front/case.front.php'; // http://hostname/glpi/... var GLPI_HTTP_CASE_FORM = window.location.href.replace(window.location.search, ''); //window.location.href.split('/', loc_split.length - 2).join('/') + '/plugins/processmaker/front/case.front.php'; // http://hostname/glpi/...
// to manage reloads // to manage reloads
var GLPI_RELOAD_PARENT = window; //.location; var GLPI_RELOAD_PARENT = window; //.location;
var GLPI_DURING_RELOAD = false; var GLPI_DURING_RELOAD = false;
// used to find an element in a list and to hide it! // used to find an element in a list and to hide it!
function bGLPIHideElement(eltList, attribute, value) { function bGLPIHideElement(eltList, attribute, value) {
var ret = false; var ret = false;
for (var i = 0; i < eltList.length && !ret; i++) { for (var i = 0; i < eltList.length && !ret; i++) {
var node = eltList[i]; var node = eltList[i];
if (node.getAttribute(attribute) == value) { if (node.getAttribute(attribute) == value) {
// hide the link // hide the link
node.style.display = 'none'; node.style.display = 'none';
ret = true; ret = true;
} }
} }
return ret; return ret;
} }
function displayOverlay() { function displayOverlay() {
//debugger; //debugger;
// don't use displayOverlay when submit input open new tab or update parent ( example: pdf generation ) // don't use displayOverlay when submit input open new tab or update parent ( example: pdf generation )
if (!($(this).is('input[type=submit]') if (!($(this).is('input[type=submit]')
&& $(this).parents('form').length > 0 && $(this).parents('form').length > 0
&& ($(this).parents('form').first().attr('target') == '_blank' || $(this).parents('form').first().attr('target') == '_parent'))) { && ($(this).parents('form').first().attr('target') == '_blank' || $(this).parents('form').first().attr('target') == '_parent'))) {
$("<div class='ui-widget-overlay ui-front'></div>").appendTo("body"); $("<div class='ui-widget-overlay ui-front'></div>").appendTo("body");
var timer = window.setInterval(function () { var timer = window.setInterval(function () {
var count = $('.ui-widget-overlay.ui-front').length; var count = $('.ui-widget-overlay.ui-front').length;
if (count == 2) { if (count == 2) {
$($('.ui-widget-overlay.ui-front')[1]).remove(); $($('.ui-widget-overlay.ui-front')[1]).remove();
window.clearInterval(timer); window.clearInterval(timer);
} }
}, 10); }, 10);
} }
} }
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) { function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
//alert("Loaded frame " + delIndex); //alert("Loaded frame " + delIndex);
//debugger; //debugger;
var taskFrameId = event.target.id; //"caseiframe-" + delIndex; var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
var bShowHideNextStep = false; // not done yet! var bShowHideNextStep = false; // not done yet!
var bHideClaimCancelButton = false; // To manage 'Claim' button var bHideClaimCancelButton = false; // To manage 'Claim' button
var taskFrameTimerCounter = 0; var taskFrameTimerCounter = 0;
var redimIFrame = false; var redimIFrame = false;
//debugger; //debugger;
var taskFrameTimer = window.setInterval(function () { var taskFrameTimer = window.setInterval(function () {
try { try {
var locContentDocument; var locContentDocument;
var taskFrame = document.getElementById(taskFrameId); var taskFrame = document.getElementById(taskFrameId);
try { try {
locContentDocument = taskFrame.contentDocument; locContentDocument = taskFrame.contentDocument;
} catch (ex) { } catch (ex) {
locContentDocument = false; locContentDocument = false;
} }
if (taskFrame != undefined && locContentDocument != undefined) { if (taskFrame != undefined && locContentDocument != undefined) {
// here we've caught the content of the iframe // here we've caught the content of the iframe
// if task resumé, then hide the form part // if task resumé, then hide the form part
//debugger; //debugger;
//var form_resume = locContentDocument.getElementsByName('cases_Resume'); //var form_resume = locContentDocument.getElementsByName('cases_Resume');
//if (form_resume.length > 0 && form_resume[0].style.display != 'none') { //if (form_resume.length > 0 && form_resume[0].style.display != 'none') {
// form_resume[0].style.display = 'none'; // form_resume[0].style.display = 'none';
//} //}
// then look if btnGLPISendRequest exists, // then look if btnGLPISendRequest exists,
var locElt = locContentDocument.getElementById('form[btnGLPISendRequest]'); var locElt = locContentDocument.getElementById('form[btnGLPISendRequest]');
if (!bShowHideNextStep && locElt != undefined ) { if (!bShowHideNextStep && locElt != undefined ) {
var linkList = locContentDocument.getElementsByTagName('a'); var linkList = locContentDocument.getElementsByTagName('a');
if (bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN')) { if (bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN')) {
// the next step link is hidden // the next step link is hidden
// if yes then change the link behind the button itself // if yes then change the link behind the button itself
locElt.type = 'submit'; locElt.type = 'submit';
locElt.onclick = null; // in order to force use of the action of form POST locElt.onclick = null; // in order to force use of the action of form POST
var formList = locContentDocument.getElementsByTagName('form'); var formList = locContentDocument.getElementsByTagName('form');
// if yes then change the action of the form POST // 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 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); node.setAttribute('actionBackup', node.action);
var action = node.action.split('?'); var action = node.action.split('?');
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex + '&action=route'; node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex + '&action=route';
// add an element that will be the csrf data code for the POST // add an element that will be the csrf data code for the POST
//debugger; //debugger;
var csrfElt = document.createElement("input"); var csrfElt = document.createElement("input");
csrfElt.setAttribute("type", "hidden"); csrfElt.setAttribute("type", "hidden");
csrfElt.setAttribute("name", "_glpi_csrf_token"); csrfElt.setAttribute("name", "_glpi_csrf_token");
csrfElt.setAttribute("value", csrf); csrfElt.setAttribute("value", csrf);
node.appendChild(csrfElt); node.appendChild(csrfElt);
} else { } else {
// then hide the button itself // then hide the button itself
locElt.style.display = 'none'; locElt.style.display = 'none';
} }
bShowHideNextStep = true; bShowHideNextStep = true;
} }
// Hide 'Cancel' button on 'Claim' form // Hide 'Cancel' button on 'Claim' form
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]'); var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
if (cancelButton != undefined && !bHideClaimCancelButton) { if (cancelButton != undefined && !bHideClaimCancelButton) {
//debugger; //debugger;
cancelButton.style.display = 'none'; cancelButton.style.display = 'none';
// hides claim button if asked for // hides claim button if asked for
if (hideClaimButton) { if (hideClaimButton) {
claimButton = locContentDocument.getElementById('form[BTN_CATCH]'); claimButton = locContentDocument.getElementById('form[BTN_CATCH]');
claimButton.style.display = 'none'; claimButton.style.display = 'none';
} }
// to manage Claim // to manage Claim
var formList = locContentDocument.getElementsByTagName('form'); 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 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); node.setAttribute('actionBackup', node.action);
var action = node.action.split('?'); var action = node.action.split('?');
//debugger; //debugger;
node.action = GLPI_HTTP_CASE_FORM + '?' + (action[1]?action[1]+'&':'') + 'DEL_INDEX=' + delIndex; node.action = GLPI_HTTP_CASE_FORM + '?' + (action[1]?action[1]+'&':'') + 'DEL_INDEX=' + delIndex;
// add an element that will be the csrf data code for the POST // add an element that will be the csrf data code for the POST
//debugger; //debugger;
var csrfElt = document.createElement("input"); var csrfElt = document.createElement("input");
csrfElt.setAttribute("type", "hidden"); csrfElt.setAttribute("type", "hidden");
csrfElt.setAttribute("name", "_glpi_csrf_token"); csrfElt.setAttribute("name", "_glpi_csrf_token");
csrfElt.setAttribute("value", csrf); csrfElt.setAttribute("value", csrf);
node.appendChild(csrfElt); node.appendChild(csrfElt);
bHideClaimCancelButton = true; bHideClaimCancelButton = true;
// TODO // TODO
//node.addEventListener('submit', showMask); //node.addEventListener('submit', showMask);
} }
// to force immediate reload of GLPI item form // to force immediate reload of GLPI item form
var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD'); var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD');
if (forcedReload != undefined && !GLPI_DURING_RELOAD) { if (forcedReload != undefined && !GLPI_DURING_RELOAD) {
//showMask(); //showMask();
GLPI_DURING_RELOAD = true; // to prevent double reload GLPI_DURING_RELOAD = true; // to prevent double reload
window.clearInterval(taskFrameTimer); // stop timer window.clearInterval(taskFrameTimer); // stop timer
GLPI_RELOAD_PARENT.location.reload(); GLPI_RELOAD_PARENT.location.reload();
} }
// try to redim caseIFrame // try to redim caseIFrame
if (!redimIFrame) { if (!redimIFrame) {
redimTaskFrame(taskFrame, delIndex); redimTaskFrame(taskFrame, delIndex);
var redimFrameTimer = window.setInterval(function () { var redimFrameTimer = window.setInterval(function () {
redimTaskFrame(taskFrame, delIndex); redimTaskFrame(taskFrame, delIndex);
}, 1000); }, 1000);
redimIFrame = true; redimIFrame = true;
} }
} }
taskFrameTimerCounter = taskFrameTimerCounter + 1; taskFrameTimerCounter = taskFrameTimerCounter + 1;
if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) { // either timeout or hiding is done if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) { // either timeout or hiding is done
window.clearInterval(taskFrameTimer); window.clearInterval(taskFrameTimer);
} }
} catch (evt) { } catch (evt) {
// nothing to do here for the moment // nothing to do here for the moment
} }
}, 10); }, 10);
} }
function redimTaskFrame(taskFrame, delIndex) { function redimTaskFrame(taskFrame, delIndex) {
var newHeight; var newHeight;
try { try {
//var locElt = locContentDocument.getElementsByTagName("table")[0]; //var locElt = locContentDocument.getElementsByTagName("table")[0];
var locElt = taskFrame.contentDocument.getElementsByTagName("html")[0]; var locElt = taskFrame.contentDocument.getElementsByTagName("html")[0];
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10); newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
if (newHeight < 500) { if (newHeight < 500) {
newHeight = 500; newHeight = 500;
} }
taskFrame.height = newHeight; taskFrame.height = newHeight;
} catch (e) { } catch (e) {
} }
} }
//function onTaskFrameActivation(delIndex) { //function onTaskFrameActivation(delIndex) {
// var taskFrameId = "caseiframe-" + delIndex; // var taskFrameId = "caseiframe-" + delIndex;
// var taskFrameTimerCounter = 0; // var taskFrameTimerCounter = 0;
// var redimIFrame = false; // var redimIFrame = false;
// var taskFrameTimer = window.setInterval(function () { // var taskFrameTimer = window.setInterval(function () {
// try { // try {
// var locContentDocument; // var locContentDocument;
// var taskFrame = document.getElementById(taskFrameId); // var taskFrame = document.getElementById(taskFrameId);
// if (taskFrame != undefined && taskFrame.contentDocument != undefined) { // if (taskFrame != undefined && taskFrame.contentDocument != undefined) {
// // here we've caught the content of the iframe // // here we've caught the content of the iframe
// locContentDocument = taskFrame.contentDocument; // locContentDocument = taskFrame.contentDocument;
// // try to redim caseIFrame // // try to redim caseIFrame
// if (!redimIFrame) { // if (!redimIFrame) {
// var newHeight; // var newHeight;
// var locElt = locContentDocument.getElementsByTagName("html")[0]; // var locElt = locContentDocument.getElementsByTagName("html")[0];
// newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10); // newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
// tabs.getItem('task-' + delIndex).setHeight(newHeight); // tabs.getItem('task-' + delIndex).setHeight(newHeight);
// taskFrame.height = newHeight; // taskFrame.height = newHeight;
// redimIFrame = true; // redimIFrame = true;
// } // }
// } // }
// taskFrameTimerCounter = taskFrameTimerCounter + 1; // taskFrameTimerCounter = taskFrameTimerCounter + 1;
// if (taskFrameTimerCounter > 3000 || redimIFrame) { // timeout // if (taskFrameTimerCounter > 3000 || redimIFrame) { // timeout
// window.clearInterval(taskFrameTimer); // window.clearInterval(taskFrameTimer);
// } // }
// } catch (evt) { // } catch (evt) {
// // nothing to do here for the moment // // nothing to do here for the moment
// } // }
// }, 10); // }, 10);
//} //}
function clearClass(lociFrame) { function clearClass(lociFrame) {
try { try {
var locElt = lociFrame.contentDocument.getElementsByTagName('body')[0]; var locElt = lociFrame.contentDocument.getElementsByTagName('body')[0];
if (locElt != undefined && locElt.className != '') { if (locElt != undefined && locElt.className != '') {
//debugger; //debugger;
locElt.className = ''; locElt.className = '';
} }
} catch (ev) { } catch (ev) {
} }
} }
function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) { function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
var otherFrameId = frameName; var otherFrameId = frameName;
var otherFrameTimerCounter = 0; var otherFrameTimerCounter = 0;
var redimIFrame = false; var redimIFrame = false;
//debugger; //debugger;
if (isMap3 == undefined) { if (isMap3 == undefined) {
isMap3 = false; isMap3 = false;
} }
var otherFrameTimer = window.setInterval(function () { var otherFrameTimer = window.setInterval(function () {
try { try {
var locContentDocument; var locContentDocument;
var otherFrame = document.getElementById(otherFrameId); var otherFrame = document.getElementById(otherFrameId);
if (otherFrame != undefined && otherFrame.contentDocument != undefined) { if (otherFrame != undefined && otherFrame.contentDocument != undefined) {
// here we've caught the content of the iframe // here we've caught the content of the iframe
clearClass(otherFrame); clearClass(otherFrame);
locContentDocument = otherFrame.contentDocument; locContentDocument = otherFrame.contentDocument;
// try to redim otherFrame // try to redim otherFrame
// and tabPanel // and tabPanel
if (!redimIFrame) { if (!redimIFrame) {
var locElt; var locElt;
// isMap3 == true // isMap3 == true
// map is bpmn // map is bpmn
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div // must look at div with special CSS class name to get newHeight and should change offset and size of parent div
if (!isMap3) { if (!isMap3) {
if (tabPanelName == 'caseMap') { if (tabPanelName == 'caseMap') {
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0]; // locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0]; locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
locElt2 = locContentDocument.getElementById('pm_target'); locElt2 = locContentDocument.getElementById('pm_target');
locElt2.style.height = locElt.clientHeight + 'px'; locElt2.style.height = locElt.clientHeight + 'px';
} else { } else {
locElt = locContentDocument.getElementsByTagName(eltTagName)[0]; locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
} }
} else { } else {
locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0]; locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0];
} }
if (locElt != undefined) { if (locElt != undefined) {
var newHeight; var newHeight;
if (isMap3) { if (isMap3) {
locElt.offsetParent.style.top = 0; locElt.offsetParent.style.top = 0;
locElt.offsetParent.style.width = locElt.offsetWidth + 10 + locElt.offsetLeft + 'px'; locElt.offsetParent.style.width = locElt.offsetWidth + 10 + locElt.offsetLeft + 'px';
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px'; locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) + locElt.offsetParent.offsetTop + 30; newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) + locElt.offsetParent.offsetTop + 30;
} else { } else {
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight); newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight);
} }
if (tabPanelName == 'caseMap') { if (tabPanelName == 'caseMap') {
// trick to force scrollbar to be shown // trick to force scrollbar to be shown
locElt.offsetParent.style.overflow = 'visible'; locElt.offsetParent.style.overflow = 'visible';
locElt.offsetParent.style.overflow = 'hidden'; locElt.offsetParent.style.overflow = 'hidden';
} }
if (locElt.scrollHeight && locElt.scrollHeight > newHeight) { if (locElt.scrollHeight && locElt.scrollHeight > newHeight) {
newHeight = locElt.scrollHeight; newHeight = locElt.scrollHeight;
} }
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight); //NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
otherFrame.height = newHeight; otherFrame.height = newHeight;
redimIFrame = true; redimIFrame = true;
} }
} }
} }
otherFrameTimerCounter = otherFrameTimerCounter + 1; otherFrameTimerCounter = otherFrameTimerCounter + 1;
if (otherFrameTimerCounter > 3000 || redimIFrame) { if (otherFrameTimerCounter > 3000 || redimIFrame) {
window.clearInterval(otherFrameTimer); window.clearInterval(otherFrameTimer);
} }
} catch (ev) { } catch (ev) {
// nothing to do here for the moment // nothing to do here for the moment
} }
}, 10); }, 10);
} }

View File

@@ -1,20 +1,20 @@
$(function () { $(function () {
$(document).ajaxComplete(function (event, jqXHR, ajaxOptions) { $(document).ajaxComplete(function (event, jqXHR, ajaxOptions) {
//debugger; //debugger;
var pattern = /##processmaker.*(##|...)/g; var pattern = /##processmaker.*(##|...)/g;
$('tr.tab_bg_2 td a').each(function (index) { $('tr.tab_bg_2 td a').each(function (index) {
var textToChange = $(this).text(); var textToChange = $(this).text();
var matches = textToChange.match(pattern); var matches = textToChange.match(pattern);
if (matches) { if (matches) {
textToChange = textToChange.replace(pattern, ''); textToChange = textToChange.replace(pattern, '');
if (!textToChange.trim().length>0) { if (!textToChange.trim().length>0) {
var title = $(this).parent().prev().text(); var title = $(this).parent().prev().text();
textToChange = title; textToChange = title;
} }
$(this).text(textToChange); $(this).text(textToChange);
} }
}); });
}); });
}); });

View File

@@ -1,26 +1,26 @@
<?php <?php
// Direct access to file // Direct access to file
if (strpos($_SERVER['PHP_SELF'], "processmaker/js/helpdesk.public.js.php")) { if (strpos($_SERVER['PHP_SELF'], "processmaker/js/helpdesk.public.js.php")) {
$AJAX_INCLUDE = 1; $AJAX_INCLUDE = 1;
define('GLPI_ROOT', '../../..'); define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php"); include (GLPI_ROOT."/inc/includes.php");
header("Content-type: application/javascript"); header("Content-type: application/javascript");
Html::header_nocache(); Html::header_nocache();
} }
if (!defined('GLPI_ROOT')) { if (!defined('GLPI_ROOT')) {
die("Can not access directly to this file"); die("Can not access directly to this file");
} }
$config = PluginProcessmakerConfig::getInstance(); $config = PluginProcessmakerConfig::getInstance();
if (!$config->fields['maintenance']) { if (!$config->fields['maintenance']) {
echo "$(function () { echo "$(function () {
// look if name='helpdeskform' is present. If yes replace the form.location // 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 ahrefTI = '".$CFG_GLPI["root_doc"]."/plugins/processmaker/front/tracking.injector.php';
var formLink = $(\"form[name='helpdeskform']\")[0]; var formLink = $(\"form[name='helpdeskform']\")[0];
if (formLink != undefined) { if (formLink != undefined) {
formLink.action = ahrefTI; formLink.action = ahrefTI;
} }
}); });
"; // end of echo "; // end of echo
} }

View File

@@ -1,9 +1,9 @@
$(function () { $(function () {
$(document).ajaxComplete(function (event, jqXHR, ajaxOptions) { $(document).ajaxComplete(function (event, jqXHR, ajaxOptions) {
//debugger; //debugger;
if (!$('input[type="checkbox"][value="PluginProcessmakerTask"]').is(':checked')) { if (!$('input[type="checkbox"][value="PluginProcessmakerTask"]').is(':checked')) {
$('input[type="checkbox"][value="PluginProcessmakerTask"]').trigger('click'); $('input[type="checkbox"][value="PluginProcessmakerTask"]').trigger('click');
} }
$('input[type="checkbox"][value="PluginProcessmakerTask"]').parents('li').first().hide(); $('input[type="checkbox"][value="PluginProcessmakerTask"]').parents('li').first().hide();
}); });
}); });