3
0

Improved rights management

Improved cases.js
Merged 3.2.0 and 3.1.7 versions
Changed release version 3.2.1
This commit is contained in:
tomolimo
2017-12-29 16:32:39 +01:00
parent 8168c7a8ed
commit 3dd1c31621
21 changed files with 922 additions and 207 deletions

View File

@@ -1,4 +1,7 @@
# processmaker
GLPI plugin that provides an interface with ProcessMaker (http://www.processmaker.com/).
Is currently compatible to GLPI 9.1 and ProcessMaker 3.0 (see note below)
Note: for ProcessMaker 3.0, this plugin can run old (2.x) and new (3.x) processes
GLPI plugin that provides an interface with ProcessMaker server (http://www.processmaker.com/).
Is currently compatible with GLPI 9.1 and 9.2
Is currently compatible with ProcessMaker 3.0.1.8-RE-1.7 (see https://github.com/tomolimo/processmaker-server/releases/latest)
This plugin can run classic and bpmn processes

View File

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

View File

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

32
front/caselink.form.php Normal file
View File

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

15
front/caselink.php Normal file
View File

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

View File

@@ -22,7 +22,7 @@ if (isset($_REQUEST["update"])) {
} else {
Html::header($LANG['processmaker']['title'][1], $_SERVER["PHP_SELF"], "plugins", "processmaker");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "processes");
$PluginProcess->display($_REQUEST);

View File

@@ -2,9 +2,9 @@
include_once ("../../../inc/includes.php");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "plugins", "processmaker");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "tools", "PluginProcessmakerMenu", "processes");
if (Session::haveRight("plugin_processmaker_config", READ) || Session::haveRight("config", UPDATE)) {
if (Session::haveRightsOr("plugin_processmaker_config", [READ, UPDATE])) {
$process=new PluginProcessmakerProcess();
if (isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config", UPDATE)) {

218
hook.php

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@ class PluginProcessmakerCase extends CommonDBTM {
$item_id = $item->getID();
$item_type = $item->getType();
if (self::getCaseFromItemTypeAndItemId($item_type, $item_id )) {
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup class='tab_nb'> ".$this->fields['case_status']."</sup>" );
} else {
return array( 'processmakercases' => $LANG['processmaker']['item']['tab'] );
}
@@ -257,20 +257,20 @@ class PluginProcessmakerCase extends CommonDBTM {
$proj->getFromDBbyExternalID( $caseInfo->processId );
$project_type = $proj->fields['project_type'];
// then propose a button to view case history
echo "<tr class='tab_bg_1' >";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseChangeLogHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasechangeloghistory']."'>";
echo "</td>";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
echo "</td>";
echo "</tr>";
//echo "<tr class='tab_bg_1' >";
//echo "<td class='tab_bg_2' colspan='1'>";
//echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
//echo "</td>";
//echo "<td class='tab_bg_2' colspan='1'>";
//echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
//echo "</td>";
//echo "<td class='tab_bg_2' colspan='1'>";
//echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseChangeLogHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasechangeloghistory']."'>";
//echo "</td>";
//echo "<td class='tab_bg_2' colspan='1'>";
//echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
//echo "</td>";
//echo "</tr>";
echo "</table>";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
@@ -279,33 +279,44 @@ class PluginProcessmakerCase extends CommonDBTM {
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');");
echo "<tr><td>";
//
//////////////////////////
// Processmaker tab panels
// need to have a global variable which contains tab id
// used only one time for activated panel
//////////////////////////
$arrayProcessmakerTabPanel = array();
echo "<div id=processmakertabpanel >";
// first define tabs
//////////////
// Define tabs
//////////////
echo " <ul>";
//echo " <li><a href='#tabs-1'>Nunc tincidunt</a></li>";
$arrayProcessmakerTabPanel[] = "tabs-1";
//$arrayProcessmakerTabPanel[] = "tabs-1";
$arrayProcessmakerTabPanel = [];
if ($pmCaseUser) {
foreach ($caseInfo->currentUsers as $caseUser) {
echo "<li><a href='#task-".$caseUser->delIndex."'>".($caseUser->userId != $GLPICurrentPMUserId?"<i><sub>".$LANG['processmaker']['item']['task']['task'].$caseUser->taskName."</sub></i>":$LANG['processmaker']['item']['task']['task'].$caseUser->taskName)."</a></li>";
$title = $LANG['processmaker']['item']['task']['task'].$caseUser->taskName;
echo "<li><a href='#task-".$caseUser->delIndex."' title='$title'>". ($caseUser->userId != $GLPICurrentPMUserId ? "<i><sub>$title</sub></i>" : $title) ."</a></li>";
$arrayProcessmakerTabPanel[] = "task-".$caseUser->delIndex;
}
} else {
// no user means CANCELLED or COMPLETED
// then create artificial panel to host case infos
echo "<li><a href='#caseInfo'>".$LANG['processmaker']['item']['case']['caseinfo']."</a></li>";
echo "<li><a href='#caseInfo' title='".$LANG['processmaker']['item']['case']['caseinfo']."'>".$LANG['processmaker']['item']['case']['caseinfo']."</a></li>";
$arrayProcessmakerTabPanel[] = "caseInfo";
}
// add default panels: map, history, log and dynaforms
$defaultTabs = ['caseMap' => 'viewcasemap', 'caseHistory' => 'viewcasehistory', 'caseChangeLogHistory' => 'viewcasechangeloghistory', 'historyDynaformPage' => 'viewdynaforms' ];
foreach ($defaultTabs as $tab => $tabText) {
echo "<li><a href='#$tab' onclick=\"javascript:Actions.tabFrame('$tab');return false;\" title='".$LANG['processmaker']['item']['case'][$tabText]."'>".$LANG['processmaker']['item']['case'][$tabText]."</a></li>";
}
echo "</ul>";
// second define panels
//echo "<div id='tabs-1'>
// <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
// </div>";
////////////////
// Define panels
////////////////
if ($pmCaseUser) {
$csrf = Session::getNewCSRFToken();
foreach ($caseInfo->currentUsers as $caseUser) {
@@ -347,6 +358,11 @@ class PluginProcessmakerCase extends CommonDBTM {
$url = $myProcessMaker->serverURL."/cases/cases_Open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO";
echo "<iframe id=\"caseiframe-caseInfo\" onload=\"onOtherFrameLoad( 'caseInfo', 'caseiframe-caseInfo', 'body' );\" style=\"border:none;\" class=\"tab_bg_2\" width=\"100%\" src=\"$url&rand=$rand\"></iframe></div>";
}
// default panels
// map, history, log and dynaforms
// will be added dynamically by the addTabPanel function
echo "</div>";
// end of tabs/panels
@@ -363,7 +379,9 @@ class PluginProcessmakerCase extends CommonDBTM {
//debugger ;
if( !$('#processmakertabpanel')[0].children[name] ) { // panel is not yet existing, create one
//var num_tabs = $('#processmakertabpanel ul li').length ;
$('#processmakertabpanel ul').append( '<li><a href=\'#' + name + '\'>' + title + '</a></li>' );
if( $('#processmakertabpanel a[href=\"#'+name+'\"]').length == 0 ) {
$('#processmakertabpanel ul').append( '<li><a href=\'#' + name + '\'>' + title + '</a></li>' );
}
//debugger ;
$('#processmakertabpanel').append( '<div id=\'' + name + '\'>' + html + '</div>');
$('#processmakertabpanel').tabs('refresh'); // to show the panel
@@ -553,7 +571,7 @@ class PluginProcessmakerCase extends CommonDBTM {
global $DB;
$ret = false;
$query = "DELETE from glpi_".$this->fields['itemtype']."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
$query = "DELETE from glpi_".strtolower($this->fields['itemtype'])."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if ($DB->query( $query )) {
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
if ($DB->query( $query )) {

View File

@@ -9,4 +9,266 @@
* @author MoronO
*/
class PluginProcessmakerCaselink extends CommonDBTM {
static function canCreate() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
static function canView() {
return Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE]);
}
static function canUpdate( ) {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
static function canDelete( ) {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
static function canPurge() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function canUpdateItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function canDeleteItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function canPurgeItem() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
function maybeDeleted() {
return false;
}
static function getTypeName($nb=0) {
global $LANG;
if ($nb>1) {
return $LANG['processmaker']['title'][7];
}
return $LANG['processmaker']['title'][6];
}
function showForm ($ID, $options=array('candel'=>false)) {
global $DB, $CFG_GLPI, $LANG;
$options['candel'] = true;
$this->initForm($ID, $options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Name")."</td><td>";
echo "<input size='100' type='text' name='name' value='".Html::cleanInputText($this->fields["name"])."'>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Active")."</td><td>";
Dropdown::showYesNo("is_active", $this->fields["is_active"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("External data")."</td><td>";
Dropdown::showYesNo("is_externaldata", $this->fields["is_externaldata"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Self")."</td><td>";
Dropdown::showYesNo("is_self", $this->fields["is_self"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Source task GUID")."</td><td>";
//PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_source',
// 'display_emptychoice' => false,
// 'value' => $this->fields['plugin_processmaker_taskcategories_id_source']));
echo "<input size='100' type='text' name='sourcetask_guid' value='".$this->fields["sourcetask_guid"]."'>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Target task GUID")."</td><td>";
//PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_target',
// 'display_emptychoice' => false,
// 'value' => $this->fields['plugin_processmaker_taskcategories_id_target']));
echo "<input size='100' type='text' name='targettask_guid' value='".$this->fields["targettask_guid"]."'>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Target process GUID")."</td><td>";
//Dropdown::show( 'PluginProcessmakerProcess', array('name' => 'plugin_processmaker_processes_id',
// 'display_emptychoice' => true,
// 'value' => $this->fields['plugin_processmaker_processes_id'],
// 'condition' => 'is_active = 1'));
echo "<input size='100' type='text' name='targetprocess_guid' value='".$this->fields["targetprocess_guid"]."'>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Target dynaform GUID")."</td><td>";
echo "<input size='100' type='text' name='targetdynaform_guid' value='".$this->fields["targetdynaform_guid"]."'>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Source condition")."</td><td>";
//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 "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Claim target task")."</td><td>";
Dropdown::showYesNo("is_targettoclaim", $this->fields["is_targettoclaim"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__("External application JSON config")."</td><td>";
echo "<textarea cols='100' rows='6' name='externalapplication' >".$this->fields["externalapplication"]."</textarea>";
echo "</td></tr>";
$this->showFormButtons($options );
}
/**
* Summary of getSearchOptions
* @return mixed
*/
function getSearchOptions() {
global $LANG;
$tab = array();
$tab['common'] = $LANG['processmaker']['title'][1];
$tab[1]['table'] = $this->getTable();
$tab[1]['field'] = 'name';
$tab[1]['name'] = __('Name');
$tab[1]['datatype'] = 'itemlink';
$tab[1]['itemlink_type'] = $this->getType();
$tab[8]['table'] = $this->getTable();
$tab[8]['field'] = 'is_active';
$tab[8]['name'] = __('Active');
$tab[8]['massiveaction'] = true;
$tab[8]['datatype'] = 'bool';
$tab[9]['table'] = $this->getTable();
$tab[9]['field'] = 'date_mod';
$tab[9]['name'] = __('Last update');
$tab[9]['massiveaction'] = false;
$tab[9]['datatype'] = 'datetime';
$tab[10]['table'] = $this->getTable();
$tab[10]['field'] = 'is_externaldata';
$tab[10]['name'] = __('External data');
$tab[10]['massiveaction'] = false;
$tab[10]['datatype'] = 'bool';
$tab[11]['table'] = $this->getTable();
$tab[11]['field'] = 'is_self';
$tab[11]['name'] = __('Self');
$tab[11]['massiveaction'] = false;
$tab[11]['datatype'] = 'bool';
$tab[12]['table'] = $this->getTable();
$tab[12]['field'] = 'is_targettoclaim';
$tab[12]['name'] = __('Claim target task');
$tab[12]['massiveaction'] = false;
$tab[12]['datatype'] = 'bool';
$tab[13]['table'] = $this->getTable();
$tab[13]['field'] = 'externalapplication';
$tab[13]['name'] = __('External application JSON config');
$tab[13]['massiveaction'] = false;
$tab[13]['datatype'] = 'text';
$tab[14]['table'] = $this->getTable();
$tab[14]['field'] = 'sourcetask_guid';
$tab[14]['name'] = __('Source task GUID');
$tab[14]['massiveaction'] = false;
$tab[14]['datatype'] = 'text';
$tab[15]['table'] = $this->getTable();
$tab[15]['field'] = 'targettask_guid';
$tab[15]['name'] = __('Target task GUID');
$tab[15]['massiveaction'] = false;
$tab[15]['datatype'] = 'text';
$tab[16]['table'] = $this->getTable();
$tab[16]['field'] = 'targetdynaform_guid';
$tab[16]['name'] = __('Target dynaform GUID');
$tab[16]['massiveaction'] = false;
$tab[16]['datatype'] = 'text';
$tab[17]['table'] = $this->getTable();
$tab[17]['field'] = 'targetprocess_guid';
$tab[17]['name'] = __('Target process GUID');
$tab[17]['massiveaction'] = false;
$tab[17]['datatype'] = 'text';
$tab[18]['table'] = $this->getTable();
$tab[18]['field'] = 'sourcecondition';
$tab[18]['name'] = __('Source condition');
$tab[18]['massiveaction'] = false;
$tab[18]['datatype'] = 'text';
//$tab[14]['table'] = 'glpi_taskcategories';
//$tab[14]['field'] = 'completename'; //'plugin_processmaker_taskcategories_id_source';
//$tab[14]['name'] = __('Source task');
//$tab[14]['massiveaction'] = false;
//$tab[14]['datatype'] = 'dropdown';
//$tab[14]['forcegroupby'] = true;
//$tab[14]['joinparams'] =
// [
// 'beforejoin' => [
// 'table' => 'glpi_plugin_processmaker_taskcategories',
// 'joinparams' => [
// 'beforejoin' => [
// 'table' => 'glpi_plugin_processmaker_caselinks'
// ]
// ]
// ]
// ];
return $tab;
}
//static function getMenuContent() {
// if (!Session::haveRight('entity', READ)) {
// return;
// }
// $front_page = "/plugins/processmaker/front";
// $menu = array();
// //$menu['title'] = self::getMenuName();
// //$menu['page'] = "$front_page/caselink.php";
// $itemtypes = array('PluginProcessmakerCaselink' => 'processmakercaselinks');
// foreach ($itemtypes as $itemtype => $option) {
// $menu['options'][$option]['title'] = $itemtype::getTypeName(Session::getPluralNumber());
// switch( $itemtype ) {
// case 'PluginProcessmakerCaselink':
// $menu['options'][$option]['page'] = $itemtype::getSearchURL(false);
// $menu['options'][$option]['links']['search'] = $itemtype::getSearchURL(false);
// if ($itemtype::canCreate()) {
// $menu['options'][$option]['links']['add'] = $itemtype::getFormURL(false);
// }
// break ;
// default :
// $menu['options'][$option]['page'] = PluginProcessmakerCaselink::getSearchURL(false);
// break ;
// }
// }
// return $menu;
//}
}

View File

@@ -11,12 +11,12 @@
*/
class PluginProcessmakerCrontaskaction extends CommonDBTM {
// postdatas are of the form:
// postdata are of the form:
// {"form":{"RELEASE_DONE":"0","btnGLPISendRequest":"submit"},"UID":"28421020557bffc5b374850018853291","__DynaformName__":"51126098657bd96b286ded7016691792_28421020557bffc5b374850018853291","__notValidateThisFields__":"[]","DynaformRequiredFields":"[]","APP_UID":"6077575685836f7d89cabe6013770123","DEL_INDEX":"4"}
const WAITING_DATAS = 1 ;
const DATAS_READY = 2 ;
const WAITING_DATA = 1 ;
const DATA_READY = 2 ;
const DONE = 3 ;
}

58
inc/menu.class.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
class PluginProcessmakerMenu extends CommonGLPI {
static $rightname = 'plugin_processmaker_config';
static function getMenuName() {
return 'ProcessMaker';
}
static function getMenuContent() {
if (!Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE])) {
return;
}
$front_page = "/plugins/processmaker/front";
$menu = array();
$menu['title'] = self::getMenuName();
$menu['page'] = "$front_page/process.php";
$menu['links']['search'] = PluginProcessmakerProcess::getSearchURL(false);
if (Session::haveRightsOr("config", [READ, UPDATE])) {
$menu['links']['config'] = PluginProcessmakerConfig::getFormURL(false);
}
$itemtypes = ['PluginProcessmakerProcess' => 'processes',
'PluginProcessmakerCaselink' => 'caselinks'
];
foreach ($itemtypes as $itemtype => $option) {
$menu['options'][$option]['title'] = $itemtype::getTypeName(Session::getPluralNumber());
$menu['options'][$option]['page'] = $itemtype::getSearchURL(false);
$menu['options'][$option]['links']['search'] = $itemtype::getSearchURL(false);
if (Session::haveRightsOr("config", [READ, UPDATE])) {
$menu['options'][$option]['links']['config'] = PluginProcessmakerConfig::getFormURL(false);
}
switch( $itemtype ) {
case 'PluginProcessmakerProcess':
//if ($itemtype::canCreate()) {
// $menu['options'][$option]['links']['add'] = $itemtype::getFormURL(false);
//}
break ;
case 'PluginProcessmakerCaselink':
if (Session::haveRight("plugin_processmaker_config", UPDATE)) {
$menu['options'][$option]['links']['add'] = $itemtype::getFormURL(false);
}
break;
default :
$menu['options'][$option]['page'] = PluginProcessmakerProcess::getSearchURL(false);
break ;
}
}
return $menu;
}
}

View File

@@ -14,17 +14,13 @@ if (!defined('GLPI_ROOT')) {
*/
class PluginProcessmakerProcess extends CommonDBTM {
static function getMenuName() {
return 'ProcessMaker';
}
static function canCreate() {
return Session::haveRight('plugin_processmaker_config', UPDATE);
}
static function canView() {
return Session::haveRight('plugin_processmaker_config', READ);
return Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE]);
}
static function canUpdate( ) {
@@ -56,8 +52,8 @@ class PluginProcessmakerProcess extends CommonDBTM {
//$database = $config->fields['pm_workspace'] ;
$translates = false;
$mapLangs = array( );
if (TableExists( 'glpi_dropdowntranslations' ) && class_exists('DropdownTranslation')) {
// to force rigths to add translations
// if (class_exists('DropdownTranslation')) {
// to force rights to add translations
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name';
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['completename'] = 'completename';
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['comment'] = 'comment';
@@ -66,11 +62,11 @@ class PluginProcessmakerProcess extends CommonDBTM {
foreach ($CFG_GLPI['languages'] as $key => $valArray) {
$mapLangs[ locale_get_primary_language( $key ) ][] = $key;
}
}
//}
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
WHERE TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
WHERE TASK.TAS_TYPE = 'NORMAL' AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
$taskArray = array();
$defaultLangTaskArray=array();
foreach ($PM_DB->request( $query ) as $task) {
@@ -84,6 +80,33 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
}
$pmtask = new PluginProcessmakerTaskCategory;
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), 'is_active = 1 AND processes_id = '.$this->getID());
foreach($currentasksinprocess as $task){
$tasks[$task['pm_task_guid']] = $task;
}
$inactivetasks = array_diff_key($tasks, $defaultLangTaskArray);
foreach($inactivetasks as $taskkey => $task) {
// must verify if this taskcategory are used in a task somewhere
$objs = ['TicketTask', 'ProblemTask', 'ChangeTask'];
$countElt = 0 ;
foreach($objs as $obj) {
$countElt += countElementsInTable( getTableForItemType($obj), "taskcategories_id = ".$task['taskcategories_id'] );
if ($countElt != 0) {
// just set 'is_active' to 0
$pmtask->Update( array( 'id' => $task['id'], 'start' => 0, 'is_active' => 0 ) );
break;
}
}
if ($countElt == 0) {
// purge this category as it is not used anywhere
$taskCat = new TaskCategory;
$taskCat->delete(array( 'id' => $task['taskcategories_id'] ), 1);
$pmTaskCat = new PluginProcessmakerTaskCategory;
$pmTaskCat->delete(array( 'id' => $task['id'] ), 1);
}
}
foreach ($defaultLangTaskArray as $taskGUID => $task) {
$pmTaskCat = new PluginProcessmakerTaskCategory;
$taskCat = new TaskCategory;
@@ -92,23 +115,23 @@ class PluginProcessmakerProcess extends CommonDBTM {
if ($taskCat->getFromDB( $pmTaskCat->fields['taskcategories_id'] )) {
// found it must test if should be updated
if ($taskCat->fields['name'] != $task['TAS_TITLE'] || $taskCat->fields['comment'] != $task['TAS_DESCRIPTION']) {
$taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
$taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
}
if ($pmTaskCat->fields['start'] != $task['start']) {
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'start' => $task['start'] ) );
}
} else {
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// update pmTaskCat
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
}
} else {
// should create a new one
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// pmTaskCat must be created too
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'], 'is_active' => 1 ) );
}
// here we should take into account translations if any
if ($translates && isset($taskArray[ $taskGUID ])) {
@@ -150,6 +173,30 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
function prepareInputForAdd($input){
global $PM_DB;
if (isset($input['name'])) {
$input['name'] = $PM_DB->escape($input['name']);
}
return $input;
}
function prepareInputForUpdate($input){
global $PM_DB;
if (isset($input['name'])) {
$input['name'] = $PM_DB->escape($input['name']);
}
return $input;
}
function post_addItem() {
$this->getFromDB($this->getID());
}
function post_updateItem($history = 1) {
$this->getFromDB($this->getID());
}
/**
* Summary of refresh
* used to refresh process list and task category list
@@ -171,7 +218,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
if ($glpiprocess->getFromDBbyExternalID($process->guid)) {
// then update it only if name has changed
if ($glpiprocess->fields['name'] != $process->name) {
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name ) );
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name) );
}
// and check if main task category needs update
if (!$glpiprocess->fields['taskcategories_id']) {
@@ -207,9 +254,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
* @return boolean true if update is done, false otherwise
*/
function updateTaskCategory( $pmMainTaskCat ) {
global $PM_DB;
$taskCat = new TaskCategory;
if ($taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name']) {
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name'] ) );
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])) );
}
return false;
}
@@ -221,8 +269,9 @@ class PluginProcessmakerProcess extends CommonDBTM {
* @return boolean true if TaskCategory has been created and updated into $this process, else otherwise
*/
function addTaskCategory( $pmMainTaskCat ) {
global $PM_DB;
$taskCat = new TaskCategory;
if ($taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name']) )) {
if ($taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])) )) {
return $this->update( array( 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ) );
}
return false;
@@ -385,7 +434,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
global $LANG;
if ($nb>1) {
return $LANG['processmaker']['title'][1];
return $LANG['processmaker']['title'][5];
}
return $LANG['processmaker']['title'][2];
}

View File

@@ -95,7 +95,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*
* @return string
**/
static function getTable() {
static function getTable($classname = null) {
return "glpi_plugin_processmaker_processes";
}
@@ -193,7 +193,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$gusr->getFromDBbyName( $admin_or_user !== false ? $admin_or_user : $_SESSION["glpiname"]);
}
$pmusr->getFromDB( $gusr->getID() );
if (!isset($pmusr->fields['password']) || $pmusr->fields['password'] == "") {
//if (!isset($pmusr->fields['password']) || $pmusr->fields['password'] == "") {
$pass = md5(Toolbox::encrypt( $gusr->getID().$gusr->getName().time(), GLPIKEY) );
$pmusr->update( array('id' => $pmusr->getID(), 'password' => $pass) );
//$DB->query( "UPDATE glpi_plugin_processmaker_users SET password = '".$pass."' WHERE glpi_users_id = ".$pmusr->getID().";" ) ;
@@ -201,7 +201,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// and must be updated also in PM db
$PM_DB->query("UPDATE RBAC_USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
$PM_DB->query("UPDATE USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
}
//}
$locSession = $this->pmSoapClient->login( array( 'userid' => $gusr->fields['name'], 'password' => 'md5:'.$pmusr->fields['password']) );
if (is_object( $locSession ) && $locSession->status_code == 0) {
$_SESSION["pluginprocessmaker"]["session"]["id"] = $locSession->message;
@@ -945,7 +945,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$existingpmsession = isset($_SESSION["pluginprocessmaker"]["session"]);
$formerusers_id = 0;
// get the list of taskactions to be done
foreach ($DB->request( getTableForItemType('PluginProcessmakerCrontaskaction'), ' `state` = '.PluginProcessmakerCrontaskaction::DATAS_READY ) as $taskaction) {
foreach ($DB->request( getTableForItemType('PluginProcessmakerCrontaskaction'), ' `state` = '.PluginProcessmakerCrontaskaction::DATA_READY ) as $taskaction) {
try {
@@ -955,11 +955,24 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$pm->login($taskaction['users_id']);
$postdatas = json_decode($taskaction['postdatas'], true);
$postdata = json_decode($taskaction['postdata'], true);
if ($taskaction['toclaim']) {
// must filter arrays as arrays are grids and index must start at 1 instead of 0 like in json
foreach($postdata['form'] as &$field) {
if (is_array($field)) {
if (count($field) > 0){
// then must reindex the array starting to 1 instead of 0
array_unshift($field, '');
unset($field[0]);
} else {
$field[] = "";
}
}
}
if ($taskaction['is_targettoclaim']) {
// must do a claim before solving task
if (!$pm->claimCase( $postdatas['APP_UID'], $postdatas['DEL_INDEX'] )) {
if (!$pm->claimCase( $postdata['APP_UID'], $postdata['DEL_INDEX'] )) {
throw new Exception("Can't claim case");
}
@@ -967,16 +980,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$CFG_GLPI["use_mailing"] = false;
// now manage tasks associated with item
$pm->claimTask( $postdatas['APP_UID'], $postdatas['DEL_INDEX'], $taskaction['users_id'] );
$pm->claimTask( $postdata['APP_UID'], $postdata['DEL_INDEX'], $taskaction['users_id'] );
$CFG_GLPI["use_mailing"] = $donotif;
}
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromDB( $postdatas['APP_UID'] )) {
if ($myCase->getFromDB( $postdata['APP_UID'] )) {
//$cookies = json_decode($taskaction['cookies'], true) ;
$pm->derivateCase( $myCase, $postdatas, $taskaction['users_id'] );
$pm->derivateCase( $myCase, $postdata, $taskaction['users_id'] );
}
$tkaction = new PluginProcessmakerCrontaskaction;

View File

@@ -25,33 +25,54 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG, $DB;
global $LANG, $DB, $CFG_GLPI;
self::title($item);
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
echo "<tr><th colspan='6'>".$LANG['processmaker']['title'][3]."</th></tr>";
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th></tr>";
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th>" .
"<th>".$LANG['processmaker']['process']['taskcategories']['is_active']."</th>" .
"</tr>";
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment` FROM glpi_plugin_processmaker_taskcategories AS pm
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment`, pm.is_active FROM glpi_plugin_processmaker_taskcategories AS pm
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
WHERE pm.processes_id=".$item->getID().";";
foreach ($DB->request($query) as $taskCat) {
echo "<tr class='tab_bg_1'><td class='b'><a href='".
echo "<tr class='tab_bg_1'>";
echo "<td class='b'><a href='".
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
$taskCat['taskcategories_id']."'>".str_replace(" ", "&nbsp;", $taskCat['name']);
$taskCat['taskcategories_id']."'>".$taskCat['name']; //str_replace(" ", "&nbsp;", $taskCat['name']);
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$taskCat['taskcategories_id'].")";
}
echo "</a></td><td >".str_replace(" ", "&nbsp;", $taskCat['completename'])."</td>
<td >".$taskCat['pm_task_guid']."</td>".
"<td>".($taskCat['start']?'x':'')."</td><td >".
$taskCat['comment']."</td></tr>";
echo "</a></td>";
echo "<td >".$taskCat['completename']."</td>"; //str_replace(" ", "&nbsp;", $taskCat['completename'])."</td>";
echo "<td class='center'>";
if ($taskCat['start']) {
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
$LANG['processmaker']['process']['taskcategories']['start']."\">";
}
echo "</td>";
echo "<td >".$taskCat['pm_task_guid']."</td>";
echo "<td>".$taskCat['comment']."</td>";
echo "<td class='center'>";
if ($taskCat['is_active']) {
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
$LANG['processmaker']['process']['taskcategories']['is_active']."\">";
}
echo "</td></tr>";
}
echo "</table></div>";
@@ -137,4 +158,57 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
return false;
}
///**
// * Summary of dropdown
// * @param mixed $options
// * @return mixed
// */
//static function dropdown($options=array()) {
// global $CFG_GLPI;
// if (isset($options['value'])) {
// $that = new self;
// $that->getFromDB($options['value']);
// $options['value'] = $that->fields['taskcategories_id'];
// }
// $options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownTaskcategories.php';
// return Dropdown::show( 'TaskCategory', $options );
//}
///**
// * Execute the query to select ProcesssmakerTaskcategories
// *
// * @param $count true if execute an count(*),
// * @param $search pattern
// *
// * @return mysql result set.
// **/
//static function getSqlSearchResult ($count=true, $search='') {
// global $DB, $CFG_GLPI;
// $orderby = '';
// $where = ' WHERE glpi_plugin_processmaker_taskcategories.is_active=1 ';
// $join = ' LEFT JOIN glpi_taskcategories ON glpi_taskcategories.id = glpi_plugin_processmaker_taskcategories.taskcategories_id';
// if ($count) {
// $fields = " COUNT(DISTINCT glpi_plugin_processmaker_taskcategories.id) AS cpt ";
// } else {
// $fields = " DISTINCT glpi_taskcategories.id, glpi_taskcategories.completename AS name ";
// $orderby = " ORDER BY glpi_taskcategories.completename ASC";
// }
// if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
// $where .= " AND (glpi_taskcategories.completename $search
// OR glpi_taskcategories.comment $search) ";
// }
// $query = "SELECT $fields FROM glpi_plugin_processmaker_taskcategories $join ".$where." ".$orderby.";";
// return $DB->query($query);
//}
}

View File

@@ -1,7 +1,7 @@
//debugger;
// To manage submits to cases.front.php
// To manage submits to case.front.php
var loc_split = window.location.href.split('/');
var GLPI_HTTP_CASE_FORM = window.location.href.split('/', loc_split.length-2 ).join('/') + '/plugins/processmaker/front/cases.front.php'; // http://hostname/glpi/...
var GLPI_HTTP_CASE_FORM = window.location.href.split('/', loc_split.length-2 ).join('/') + '/plugins/processmaker/front/case.front.php'; // http://hostname/glpi/...
// to manage reloads
var GLPI_RELOAD_PARENT = window; //.location;
var GLPI_DURING_RELOAD = false;
@@ -43,6 +43,7 @@ function displayOverlay() {
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
//alert("Loaded frame " + delIndex);
//debugger;
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
var bShowHideNextStep = false; // not done yet!
var bHideClaimCancelButton = false; // To manage 'Claim' button
@@ -93,9 +94,6 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
csrfElt.setAttribute("name", "_glpi_csrf_token");
csrfElt.setAttribute("value", csrf);
node.appendChild(csrfElt);
// add showMask function to submit event
//node.addEventListener('submit', displayOverlay, true);
} else {
// then hide the button itself
locElt.style.display = 'none';
@@ -107,6 +105,7 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
// Hide 'Cancel' button on 'Claim' form
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
if (cancelButton != undefined && !bHideClaimCancelButton) {
//debugger;
cancelButton.style.display = 'none';
// hides claim button if asked for
if (hideClaimButton) {
@@ -119,7 +118,15 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
node.setAttribute('actionBackup', node.action);
var action = node.action.split('?');
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
//debugger;
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
//debugger;
var csrfElt = document.createElement("input");
csrfElt.setAttribute("type", "hidden");
csrfElt.setAttribute("name", "_glpi_csrf_token");
csrfElt.setAttribute("value", csrf);
node.appendChild(csrfElt);
bHideClaimCancelButton = true;
// TODO

View File

@@ -4,6 +4,9 @@ $LANG['processmaker']['title'][1]="ProcessMaker";
$LANG['processmaker']['title'][2]="Process";
$LANG['processmaker']['title'][3]="Task List";
$LANG['processmaker']['title'][4]="Authorizations";
$LANG['processmaker']['title'][5]="Processes";
$LANG['processmaker']['title'][6]="Case-link";
$LANG['processmaker']['title'][7]="Case-links";
$LANG['processmaker']['profile']['rightmgt']="Rights Management";
$LANG['processmaker']['profile']['process_config']="Process configuration";
@@ -25,6 +28,7 @@ $LANG['processmaker']['process']['taskcategories']['name']="Task name";
$LANG['processmaker']['process']['taskcategories']['completename']="Complete name";
$LANG['processmaker']['process']['taskcategories']['start']="Start";
$LANG['processmaker']['process']['taskcategories']['comment']="Comment";
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
$LANG['processmaker']['process']['profile']="Delete permanently";
$LANG['processmaker']['config']['name']="Name";
@@ -79,10 +83,10 @@ $LANG['processmaker']['item']['case']['casehistory']='Case history' ;
$LANG['processmaker']['item']['case']['dynaforms']='Dynaforms';
$LANG['processmaker']['item']['case']['changelog']='Change log';
$LANG['processmaker']['item']['case']['caseinfo']='Case info';
$LANG['processmaker']['item']['case']['viewcasemap']='View case map';
$LANG['processmaker']['item']['case']['viewcasehistory']='View case history';
$LANG['processmaker']['item']['case']['viewdynaforms']='View dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='View change log' ;
$LANG['processmaker']['item']['case']['viewcasemap']='View: case map';
$LANG['processmaker']['item']['case']['viewcasehistory']='View: case history';
$LANG['processmaker']['item']['case']['viewdynaforms']='View: dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='View: change log' ;
$LANG['processmaker']['item']['case']['casechangeloghistory']='Change log history' ;
$LANG['processmaker']['item']['error'][11]="Error creating case!";

View File

@@ -4,6 +4,9 @@ $LANG['processmaker']['title'][1]="ProcessMaker";
$LANG['processmaker']['title'][2]="Processus";
$LANG['processmaker']['title'][3]="Liste des tâches";
$LANG['processmaker']['title'][4]="Autorisations";
$LANG['processmaker']['title'][5]="Processus";
$LANG['processmaker']['title'][6]="Lien-cas";
$LANG['processmaker']['title'][7]="Liens-cas";
$LANG['processmaker']['profile']['rightmgt']="Gestion des droits";
$LANG['processmaker']['profile']['process_config']="Configuration des Processus";
@@ -25,6 +28,7 @@ $LANG['processmaker']['process']['taskcategories']['name']="Nom de la Tâche";
$LANG['processmaker']['process']['taskcategories']['completename']="Nom complet";
$LANG['processmaker']['process']['taskcategories']['start']="Début";
$LANG['processmaker']['process']['taskcategories']['comment']="Commentaire";
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
$LANG['processmaker']['process']['profile']="Effacer définitivement";
$LANG['processmaker']['config']['name']="Nom";
@@ -79,10 +83,10 @@ $LANG['processmaker']['item']['case']['casehistory']='Historique du cas' ;
$LANG['processmaker']['item']['case']['dynaforms']='Dynaforms';
$LANG['processmaker']['item']['case']['changelog']='Historique des modifications';
$LANG['processmaker']['item']['case']['caseinfo']='Infos du cas';
$LANG['processmaker']['item']['case']['viewcasemap']='Voir carte du cas';
$LANG['processmaker']['item']['case']['viewcasehistory']='Voir historique du cas';
$LANG['processmaker']['item']['case']['viewdynaforms']='Voir dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='Voir historique évolutions' ;
$LANG['processmaker']['item']['case']['viewcasemap']='Voir: carte du cas';
$LANG['processmaker']['item']['case']['viewcasehistory']='Voir: historique du cas';
$LANG['processmaker']['item']['case']['viewdynaforms']='Voir: dynaforms';
$LANG['processmaker']['item']['case']['viewcasechangeloghistory']='Voir: historique évolutions' ;
$LANG['processmaker']['item']['case']['casechangeloghistory']='Historique évolutions' ;
$LANG['processmaker']['item']['error'][11]="Erreur à la création du cas !";

View File

@@ -7,7 +7,7 @@
<description>
<short>
<fr>Ce plugin fournit la possibilité d'intégrer un processus (workflow) aux tickets.</fr>
<en>This plugin provides a process (workflow) management linked to tickets></en>
<en>This plugin provides a process (workflow) management linked to tickets.</en>
</short>
<long>
<en>This plugin is dedicated to provide a process (workflow) management linked to tickets. This goal is achieved using ProcessMaker (URL: http://www.processmaker.com/). ProcessMaker will provide Process design and Workflow execution. This plugin is the glue between GLPI and ProcessMaker.</en>
@@ -22,8 +22,12 @@
<author>Olivier Moron</author>
</authors>
<versions>
<version>
<num>3.1.6</num>
<version>
<num>3.2.1</num>
<compatibility>9.2</compatibility>
</version>
<version>
<num>3.2.1</num>
<compatibility>9.1</compatibility>
</version>
</versions>

View File

@@ -7,6 +7,9 @@ function plugin_init_processmaker() {
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
// $objects = ['Ticket', 'Change', 'Problem'];
$objects = ['Ticket'];
$plugin = new Plugin();
if ($plugin->isInstalled('processmaker')
&& $plugin->isActivated('processmaker')
@@ -18,7 +21,7 @@ function plugin_init_processmaker() {
Plugin::registerClass('PluginProcessmakerTaskCategory');
if (Session::haveRight('config', UPDATE)) {
if (Session::haveRightsOr("config", [READ, UPDATE])) {
Plugin::registerClass('PluginProcessmakerConfig', array('addtabon' => 'Config'));
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
}
@@ -40,29 +43,35 @@ function plugin_init_processmaker() {
= array('PluginProcessmakerProcessmaker', 'post_show_tab_processmaker');
// Display a menu entry ?
if (Session::haveRight('config', READ)) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
if (Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE])) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = ['tools' => 'PluginProcessmakerMenu'];
}
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) );
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
);
$hooks = [];
foreach($objects as $obj){
$hooks[$obj] = ['PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker'];
}
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = $hooks;
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
'Ticket' => 'plugin_pre_item_update_processmaker'
);
$hooks = [];
foreach($objects as $obj){
$hooks[$obj] = 'plugin_pre_item_update_processmaker';
}
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = $hooks;
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction',
'TicketTask' => 'plugin_item_update_processmaker_tasks'
);
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker')
);
$hooks = ['TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction'];
foreach($objects as $obj){
$hooks[$obj.'Task'] = 'plugin_item_update_processmaker_tasks';
}
$PLUGIN_HOOKS['item_update']['processmaker'] = $hooks;
$hooks = [];
foreach($objects as $obj){
$hooks[$obj] = ['PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker'];
}
$PLUGIN_HOOKS['item_add']['processmaker'] = $hooks;
$PLUGIN_HOOKS['item_get_datas']['processmaker'] = array(
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
);
@@ -71,12 +80,17 @@ function plugin_init_processmaker() {
'PluginPdfTicketTask' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdatas_processmaker')
);
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
);
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_item_purge_processmaker'
);
$hooks = [];
foreach($objects as $obj){
$hooks[$obj.'_User'] = 'plugin_pre_item_purge_processmaker';
}
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = $hooks;
$hooks = [];
foreach($objects as $obj){
$hooks[$obj.'_User'] = 'plugin_item_purge_processmaker';
}
$PLUGIN_HOOKS['item_purge']['processmaker'] = $hooks;
$PLUGIN_HOOKS['add_javascript']['processmaker'] = array("js/domain.js.php");
$url = explode("/", $_SERVER['PHP_SELF']);
@@ -89,7 +103,7 @@ function plugin_init_processmaker() {
}
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
$CFG_GLPI['planning_types'][] = 'PluginProcessmakerTask';
$PLUGIN_HOOKS['post_init']['processmaker'] = 'plugin_processmaker_post_init';
}
@@ -100,16 +114,16 @@ function plugin_version_processmaker() {
global $LANG;
return array ('name' => 'Process Maker',
'version' => '3.1.6',
'version' => '3.2.1',
'author' => 'Olivier Moron',
'homepage' => '',
'homepage' => 'https://github.com/tomolimo/processmaker',
'minGlpiVersion' => '9.1');
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_processmaker_check_prerequisites() {
if (version_compare(GLPI_VERSION, '9.1', 'lt') || version_compare(GLPI_VERSION, '9.2', 'ge')) {
echo "This plugin requires GLPI 9.1 or higher";
if (version_compare(GLPI_VERSION, '9.1', 'lt') || version_compare(GLPI_VERSION, '9.3', 'ge')) {
echo "This plugin requires GLPI >= 9.1 and < 9.3";
return false;
}