Skip to content

Commit

Permalink
Improved rights management
Browse files Browse the repository at this point in the history
Improved cases.js
Merged 3.2.0 and 3.1.7 versions
Changed release version 3.2.1
  • Loading branch information
tomolimo committed Dec 29, 2017
1 parent 8168c7a commit 3dd1c31
Show file tree
Hide file tree
Showing 21 changed files with 920 additions and 205 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
48 changes: 28 additions & 20 deletions ajax/asynchronousdatas.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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();
}

Expand All @@ -13,28 +12,37 @@
}

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 not supported' ) ;
}
break;
default:
$ret = array( '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 ) ;

}
}
68 changes: 68 additions & 0 deletions ajax/dropdownTaskcategories.php
Original file line number Diff line number Diff line change
@@ -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);
File renamed without changes.
32 changes: 32 additions & 0 deletions front/caselink.form.php
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions front/caselink.php
Original file line number Diff line number Diff line change
@@ -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();

2 changes: 1 addition & 1 deletion front/process.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

} 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);

Expand Down
4 changes: 2 additions & 2 deletions front/process.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading

0 comments on commit 3dd1c31

Please sign in to comment.