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

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