@@ -1,4 +1,4 @@
|
||||
# processmaker
|
||||
GLPI plugin that provides an interface with ProcessMaker (http://www.processmaker.com/).
|
||||
Is currently compatible to GLPI 0.83.8 and ProcessMaker 2.5, 2.8 and 3.0 (see note below)
|
||||
Note: for ProcessMaker 3.0, this plugin can run old (2.x) and new (3.x) processes, but the process map view (for new BMPN process) has a bug.
|
||||
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
|
||||
|
||||
50
ajax/asynchronousdatas.php
Normal file
50
ajax/asynchronousdatas.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if (strpos($_SERVER['PHP_SELF'],"asynchronousdatas.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
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();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not access directly to this file");
|
||||
}
|
||||
|
||||
//include_once dirname(__FILE__)."/../inc/asynchronousdata.class.php" ;
|
||||
include_once dirname(__FILE__)."/../inc/crontaskaction.class.php" ;
|
||||
|
||||
if( isset($_SERVER['REQUEST_METHOD']) ) {
|
||||
switch($_SERVER['REQUEST_METHOD']) {
|
||||
//case 'OPTIONS' :
|
||||
// header("Access-Control-Allow-Origin: *") ;
|
||||
// header("Access-Control-Allow-Methods: POST");
|
||||
// header("Access-Control-Allow-Headers: Content-Type");
|
||||
// break ;
|
||||
case 'POST' :
|
||||
//header("Access-Control-Allow-Origin: *") ;
|
||||
//header("Content-Type: application/json; charset=UTF-8");
|
||||
|
||||
$request_body = file_get_contents('php://input');
|
||||
$datas = json_decode($request_body, true);
|
||||
|
||||
// $asyncdata = new PluginProcessmakerAsynchronousdata ;
|
||||
$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' );
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
$ret = array( 'code' => '1', 'message' => 'Method not supported' ) ;
|
||||
}
|
||||
|
||||
echo json_encode( $ret, JSON_HEX_APOS | JSON_HEX_QUOT ) ;
|
||||
|
||||
}
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Olivier Moron
|
||||
// Purpose of file:
|
||||
// Purpose of file: to return list of processes which can be started by end-user
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
@@ -18,98 +16,62 @@ if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/process.class.php" ;
|
||||
//include_once dirname(__FILE__)."/../inc/process.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (!isset($_POST['right'])) {
|
||||
$_POST['right'] = "all";
|
||||
if (isset($_REQUEST["entity_restrict"])
|
||||
&& !is_array($_REQUEST["entity_restrict"])
|
||||
&& (substr($_REQUEST["entity_restrict"], 0, 1) === '[')
|
||||
&& (substr($_REQUEST["entity_restrict"], -1) === ']')) {
|
||||
$_REQUEST["entity_restrict"] = json_decode($_REQUEST["entity_restrict"]);
|
||||
}
|
||||
|
||||
// Default view : Nobody
|
||||
if (!isset($_POST['all'])) {
|
||||
$_POST['all'] = 0;
|
||||
// Security
|
||||
if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$used = array();
|
||||
$one_item = -1;
|
||||
if (isset($_POST['_one_id'])) {
|
||||
$one_item = $_POST['_one_id'];
|
||||
}
|
||||
// Count real items returned
|
||||
$count = 0;
|
||||
|
||||
if (isset($_POST['used'])) {
|
||||
if (is_array($_POST['used'])) {
|
||||
$used = $_POST['used'];
|
||||
} else {
|
||||
$used = unserialize(stripslashes($_POST['used']));
|
||||
}
|
||||
if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
|
||||
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
|
||||
}
|
||||
|
||||
if (isset($_POST["entity_restrict"])
|
||||
&& !is_numeric($_POST["entity_restrict"])
|
||||
&& !is_array($_POST["entity_restrict"])) {
|
||||
|
||||
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
|
||||
$search="";
|
||||
if (!empty($_REQUEST['searchText'])) {
|
||||
$search = Search::makeTextSearch($_REQUEST['searchText']);
|
||||
}
|
||||
|
||||
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $_POST['right'], $_POST["entity_restrict"],
|
||||
$_POST['value'], $used, $_POST['searchText']);
|
||||
|
||||
$processes = array();
|
||||
|
||||
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data=$DB->fetch_array($result)) {
|
||||
if( in_array( $_POST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
|
||||
$processes[$data["id"]] = $data["name"];
|
||||
// Empty search text : display first
|
||||
if (empty($_REQUEST['searchText'])) {
|
||||
if ($_REQUEST['display_emptychoice']) {
|
||||
if (($one_item < 0) || ($one_item == 0)) {
|
||||
array_push($processes, array('id' => 0,
|
||||
'text' => $_REQUEST['emptylabel']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
|
||||
|
||||
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name='".$_POST['myname']."'";
|
||||
|
||||
if (isset($_POST["on_change"]) && !empty($_POST["on_change"])) {
|
||||
echo " onChange='".$_POST["on_change"]."'";
|
||||
}
|
||||
|
||||
echo ">";
|
||||
|
||||
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]
|
||||
&& $DB->numrows($result)==$CFG_GLPI["dropdown_max"]) {
|
||||
|
||||
echo "<option value='0'>--".$LANG['common'][11]."--</option>";
|
||||
}
|
||||
|
||||
if ($_POST['all']==0) {
|
||||
echo "<option value='0'>".Dropdown::EMPTY_VALUE."</option>";
|
||||
} else if ($_POST['all']==1) {
|
||||
echo "<option value='0'>[".$LANG['common'][66]."]</option>";
|
||||
}
|
||||
|
||||
if (isset($_POST['value'])) {
|
||||
$output = PluginProcessmakerProcess::getProcessName($_POST['value']);
|
||||
|
||||
if (!empty($output) && $output!=" ") {
|
||||
echo "<option selected value='".$_POST['value']."'>".$output."</option>";
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data=$DB->fetch_array($result)) {
|
||||
if( in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
|
||||
array_push( $processes, array( 'id' => $data["id"],
|
||||
'text' => $data["name"] ));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($processes)) {
|
||||
foreach ($processes as $ID => $output) {
|
||||
echo "<option value='$ID' title=\"".Html::cleanInputText($output)."\">".
|
||||
Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"])."</option>";
|
||||
}
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
if (isset($_POST["comment"]) && $_POST["comment"]) {
|
||||
$paramscomment = array('value' => '__VALUE__',
|
||||
'table' => "glpi_plugin_processmaker_processes");
|
||||
|
||||
if (isset($_POST['update_link'])) {
|
||||
$paramscomment['withlink'] = "comment_link_".$_POST["myname"].$_POST["rand"];
|
||||
}
|
||||
Ajax::updateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],
|
||||
"comment_".$_POST["myname"].$_POST["rand"],
|
||||
$CFG_GLPI["root_doc"]."/ajax/comments.php", $paramscomment);
|
||||
}
|
||||
|
||||
Ajax::commonDropdownUpdateItem($_POST);
|
||||
?>
|
||||
$ret['results'] = $processes;
|
||||
$ret['count'] = $count;
|
||||
echo json_encode($ret);
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownUsers.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
@@ -21,114 +19,117 @@ if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (!isset($_POST['right'])) {
|
||||
$_POST['right'] = "all";
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
|
||||
if (!isset($_REQUEST['right'])) {
|
||||
$_REQUEST['right'] = "all";
|
||||
}
|
||||
|
||||
// Default view : Nobody
|
||||
if (!isset($_POST['all'])) {
|
||||
$_POST['all'] = 0;
|
||||
if (!isset($_REQUEST['all'])) {
|
||||
$_REQUEST['all'] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$used = array();
|
||||
|
||||
if (isset($_POST['used'])) {
|
||||
if (is_array($_POST['used'])) {
|
||||
$used = $_POST['used'];
|
||||
} else {
|
||||
$used = unserialize(stripslashes($_POST['used']));
|
||||
}
|
||||
if (isset($_REQUEST['used'])) {
|
||||
$used = $_REQUEST['used'];
|
||||
}
|
||||
|
||||
if (isset($_POST["entity_restrict"])
|
||||
&& !is_numeric($_POST["entity_restrict"])
|
||||
&& !is_array($_POST["entity_restrict"])) {
|
||||
|
||||
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
|
||||
if (!isset($_REQUEST['value'])) {
|
||||
$_REQUEST['value'] = 0;
|
||||
}
|
||||
|
||||
$result = PluginProcessmakerUsers::getSqlSearchResult( $_POST['pmTaskId'], false, $_POST['right'], $_POST["entity_restrict"],
|
||||
$_POST['value'], $used, $_POST['searchText']);
|
||||
$one_item = -1;
|
||||
if (isset($_REQUEST['_one_id'])) {
|
||||
$one_item = $_REQUEST['_one_id'];
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['page'])) {
|
||||
$_REQUEST['page'] = 1;
|
||||
$_REQUEST['page_limit'] = $CFG_GLPI['dropdown_max'];
|
||||
}
|
||||
|
||||
if ($one_item < 0) {
|
||||
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
|
||||
//$result = User::getSqlSearchResult(false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
// $_REQUEST['value'], $used, $_REQUEST['searchText'], $start,
|
||||
// $_REQUEST['page_limit']);
|
||||
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
|
||||
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['pmTaskId'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
$_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT);
|
||||
} else {
|
||||
$query = "SELECT DISTINCT `glpi_users`.*
|
||||
FROM `glpi_users`
|
||||
WHERE `glpi_users`.`id` = '$one_item';";
|
||||
$result = $DB->query($query);
|
||||
}
|
||||
$users = array();
|
||||
|
||||
// check if $_POST["myname"] matches _itil_\w+\[users_id\]
|
||||
if( preg_match( "/^_itil_\\w+\\[users_id\\]/", $_POST["myname"] ) || preg_match( "/^_users_id_\\w+/", $_POST["myname"] )) {
|
||||
// prevent use of pseudo-groups like *Raynet-Development_Intranet (TASK USE ONLY!)
|
||||
$raynetPseudoGroupNoUse = true ;
|
||||
} else $raynetPseudoGroupNoUse = false ;
|
||||
|
||||
// Count real items returned
|
||||
$count = 0;
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data=$DB->fetch_array($result)) {
|
||||
if( !$raynetPseudoGroupNoUse || mb_strpos( $data["name"], "*" ) === false ) {
|
||||
$users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"],
|
||||
$data["firstname"]);
|
||||
$logins[$data["id"]] = $data["name"];
|
||||
}
|
||||
}
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
$users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"],
|
||||
$data["firstname"]);
|
||||
$logins[$data["id"]] = $data["name"];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dpuser_cmp')) {
|
||||
function dpuser_cmp($a, $b) {
|
||||
return strcasecmp($a, $b);
|
||||
}
|
||||
function dpuser_cmp($a, $b) {
|
||||
return strcasecmp($a, $b);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort non case sensitive
|
||||
uasort($users, 'dpuser_cmp');
|
||||
//uasort($users, 'dpuser_cmp');
|
||||
|
||||
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name='".$_POST['myname']."'";
|
||||
$datas = array();
|
||||
|
||||
if (isset($_POST["on_change"]) && !empty($_POST["on_change"])) {
|
||||
echo " onChange='".$_POST["on_change"]."'";
|
||||
}
|
||||
|
||||
echo ">";
|
||||
|
||||
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]
|
||||
&& $DB->numrows($result)==$CFG_GLPI["dropdown_max"]) {
|
||||
|
||||
echo "<option value='0'>--".$LANG['common'][11]."--</option>";
|
||||
}
|
||||
|
||||
if ($_POST['all']==0) {
|
||||
echo "<option value='0'>".Dropdown::EMPTY_VALUE."</option>";
|
||||
} else if ($_POST['all']==1) {
|
||||
echo "<option value='0'>[".$LANG['common'][66]."]</option>";
|
||||
}
|
||||
|
||||
if (isset($_POST['value'])) {
|
||||
$output = getUserName($_POST['value']);
|
||||
|
||||
if (!empty($output) && $output!=" ") {
|
||||
echo "<option selected value='".$_POST['value']."'>".$output."</option>";
|
||||
}
|
||||
// Display first if empty search
|
||||
if ($_REQUEST['page'] == 1 && empty($_REQUEST['searchText'])) {
|
||||
if (($one_item < 0) || ($one_item == 0)) {
|
||||
if ($_REQUEST['all'] == 0) {
|
||||
array_push($datas, array('id' => 0,
|
||||
'text' => Dropdown::EMPTY_VALUE));
|
||||
} else if ($_REQUEST['all'] == 1) {
|
||||
array_push($datas, array('id' => 0,
|
||||
'text' => __('All')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($users)) {
|
||||
foreach ($users as $ID => $output) {
|
||||
echo "<option value='$ID' title=\"".Html::cleanInputText($output." - ".$logins[$ID])."\">".
|
||||
Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"])."</option>";
|
||||
}
|
||||
}
|
||||
echo "</select>";
|
||||
foreach ($users as $ID => $output) {
|
||||
$title = sprintf(__('%1$s - %2$s'), $output, $logins[$ID]);
|
||||
|
||||
if (isset($_POST["comment"]) && $_POST["comment"]) {
|
||||
$paramscomment = array('value' => '__VALUE__',
|
||||
'table' => "glpi_users");
|
||||
|
||||
if (isset($_POST['update_link'])) {
|
||||
$paramscomment['withlink'] = "comment_link_".$_POST["myname"].$_POST["rand"];
|
||||
}
|
||||
Ajax::updateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],
|
||||
"comment_".$_POST["myname"].$_POST["rand"],
|
||||
$CFG_GLPI["root_doc"]."/ajax/comments.php", $paramscomment);
|
||||
array_push($datas, array('id' => $ID,
|
||||
'text' => $output,
|
||||
'title' => $title));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($one_item >= 0)
|
||||
&& isset($datas[0])) {
|
||||
echo json_encode($datas[0]);
|
||||
} else {
|
||||
$ret['results'] = $datas;
|
||||
$ret['count'] = $count;
|
||||
echo json_encode($ret);
|
||||
}
|
||||
|
||||
Ajax::commonDropdownUpdateItem($_POST);
|
||||
?>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
function HandleHeaderLine( $curl, $header_line ) {
|
||||
$temp = explode( ": ", $header_line ) ;
|
||||
if( is_array( $temp ) && $temp[0] == 'Set-Cookie' ) {
|
||||
header("Set-Cookie: ".$temp[1], false) ;
|
||||
}
|
||||
return strlen($header_line);
|
||||
}
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
$pmURL = urldecode($_REQUEST['url']) ;
|
||||
curl_setopt($ch, CURLOPT_URL, $pmURL);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine");
|
||||
$body = curl_exec($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
|
||||
$pmBaseURL = explode( "/", $pmURL, 4 ) ;
|
||||
array_pop( $pmBaseURL ) ;
|
||||
|
||||
echo "
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<title></title>
|
||||
<link href='".implode("/", $pmBaseURL)."/css/classic-blank.css' rel='stylesheet' type='text/css'/>
|
||||
</head>
|
||||
<body aLink='#999999' leftMargin='0' rightMargin='0' topMargin='0' bgColor='#ffffff' text='#000000' vLink='#000000' link='#000000' marginwidth='0' marginheight='0'>
|
||||
<table cellSpacing='0' cellPadding='0' width='100%' height='100%'>
|
||||
|
||||
<tbody><tr>
|
||||
<td vAlign='top' width='100%'>
|
||||
|
||||
<table style='padding-top: 3px;' border='0' cellSpacing='0' cellPadding='0' width='100%'>
|
||||
<tbody><tr>
|
||||
<td align='center'>
|
||||
<div style='margin: 0px;' id='publisherContent[0]' align='center'> <form style='margin: 0px;' id='bHNTajBhT2lsNUhqMmFUTXg1cXM1NTdTWWR1ZDJB' class='formDefault' onsubmit='return validateForm(\"[]\");' encType='multipart/form-data' method='post' name='cases_Resume' action=''> <div style='border-width: 1px; width: 550px; padding-right: 0px; padding-left: 0px;' class='borderForm'>
|
||||
<div class='boxTop'><div class='a'> </div><div class='b'> </div><div class='c'> </div></div>
|
||||
<div style='height: 100%;' class='content'>
|
||||
<table width='99%'>
|
||||
<tbody><tr>
|
||||
<td vAlign='top'>
|
||||
<table border='0' cellSpacing='0' cellPadding='0' width='100%'>
|
||||
<tbody><tr>
|
||||
<td class='FormTitle' colSpan='2' align=''><span >Task Properties</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='FormLabel' width='150'><label >Ongoing Task</label></td>
|
||||
<td class='FormFieldContent' width='400'>".urldecode($_REQUEST['taskname'])."</td>
|
||||
<tr>
|
||||
<td class='FormLabel' width='150'><label >By</label></td>
|
||||
<td class='FormFieldContent' width='400'>".urldecode($_REQUEST['username'])."</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
<div class='boxBottom'><div class='a'> </div><div class='b'> </div><div class='c'> </div></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
" ;
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
@@ -18,15 +16,16 @@ if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
|
||||
include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
//include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
|
||||
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
$rand = rand();
|
||||
|
||||
echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQUEST['delIndex']."' id='processmaker_form_task$rand-".$_REQUEST['delIndex']."' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
|
||||
echo $LANG['processmaker']['item']['reassigncase']." ";
|
||||
echo $LANG['processmaker']['item']['reassigncase']." ";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='id' value='".$_REQUEST['itemId']."'>";
|
||||
echo "<input type='hidden' name='itemtype' value='".$_REQUEST['itemType']."'>";
|
||||
@@ -36,15 +35,16 @@ echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQ
|
||||
echo "<input type='hidden' name='plugin_processmaker_taskId' value='".$_REQUEST['taskId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delThread' value='".$_REQUEST['delThread']."'>";
|
||||
|
||||
PluginProcessmakerUsers::dropdown( array('name' => 'users_id_recipient',
|
||||
'value' => PluginProcessmakerProcessmaker::getGLPIUserId( $_REQUEST['userId'] ),
|
||||
'entity' => 0, //$item->fields["entities_id"],
|
||||
'entity_sons' => true,
|
||||
'right' => 'all',
|
||||
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
|
||||
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
|
||||
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
|
||||
'entity_sons' => false, // not used, as any user can be assigned to any tasks
|
||||
'right' => 'all',
|
||||
'rand' => $rand,
|
||||
'pmTaskId' => $_REQUEST['taskId']));
|
||||
'width' => '',
|
||||
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
|
||||
echo " ";
|
||||
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
|
||||
echo "</form>";
|
||||
|
||||
?>
|
||||
Html::closeForm(true);
|
||||
//echo "</form>";
|
||||
|
||||
|
||||
@@ -1,86 +1,40 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include_once '../inc/processmaker.class.php' ;
|
||||
include_once '../inc/cases.class.php' ;
|
||||
include_once '../../../inc/includes.php';
|
||||
|
||||
// check if it is from PM pages
|
||||
if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] ) ) {
|
||||
// then get item id from DB
|
||||
$myCase = new PluginProcessmakerCases ;
|
||||
if( $myCase->getFromDB( $_REQUEST['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
if( isset( $_REQUEST['form'] ) ) {
|
||||
// save the case variables
|
||||
//$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , $_REQUEST['form'] ) ;
|
||||
$resultSave = $myProcessMaker->saveForm( $_REQUEST, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
//$myCase->sendVariables( $_REQUEST['form'] ) ;
|
||||
|
||||
// now derivate the case !!!
|
||||
$pmRouteCaseResponse = $myProcessMaker->routeCase( $myCase->getID(), $_REQUEST['DEL_INDEX']) ;
|
||||
|
||||
// now tries to get some variables to setup content for new task and to append text to solved task
|
||||
$txtForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_TASK_CONTENT", "GLPI_ITEM_APPEND_TO_TASK", "GLPI_NEXT_GROUP_TO_BE_ASSIGNED" ) );
|
||||
if( array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $txtForTasks ) )
|
||||
$txtToAppendToTask = $txtForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ] ;
|
||||
else
|
||||
$txtToAppendToTask = '' ;
|
||||
if( array_key_exists( 'GLPI_ITEM_TASK_CONTENT', $txtForTasks ) )
|
||||
$txtTaskContent = $txtForTasks[ 'GLPI_ITEM_TASK_CONTENT' ] ;
|
||||
else
|
||||
$txtTaskContent = '' ;
|
||||
if( array_key_exists( 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED', $txtForTasks ) )
|
||||
$groupId = $txtForTasks[ 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' ] ;
|
||||
else
|
||||
$groupId = 0 ;
|
||||
|
||||
// reset those variables
|
||||
$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , array( "GLPI_ITEM_APPEND_TO_TASK" => '', 'GLPI_ITEM_TASK_CONTENT' => '', 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' => '' ) ) ;
|
||||
|
||||
// print_r( $pmRouteCaseResponse ) ;
|
||||
// die() ;
|
||||
|
||||
// now manage tasks associated with item
|
||||
$itemType = $myCase->getField('itemtype');
|
||||
$itemId = $myCase->getField('items_id');
|
||||
|
||||
// switch own task to 'done' and create a new one
|
||||
$myProcessMaker->solveTask( $myCase->getID(), $_REQUEST['DEL_INDEX'], $txtToAppendToTask ) ;
|
||||
$caseInfo = $myProcessMaker->getCaseInfo( $myCase->getID(), $_REQUEST['DEL_INDEX']) ;
|
||||
if( property_exists( $pmRouteCaseResponse, 'routing' ) ) {
|
||||
foreach( $pmRouteCaseResponse->routing as $route ) {
|
||||
$myProcessMaker->addTask( $itemType, $itemId, $caseInfo, $route->delIndex, PluginProcessmakerProcessmaker::getGLPIUserId( $route->userId ), $groupId, $route->taskId, $txtTaskContent ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// evolution of case status: DRAFT, TO_DO, COMPLETED, CANCELLED
|
||||
$myCase->update( array( 'id' => $myCase->getID(), 'case_status' => $caseInfo->caseStatus ) ) ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// Claim task management
|
||||
elseif( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ){
|
||||
// here we are in a Claim request
|
||||
$myCase = new PluginProcessmakerCases ;
|
||||
if( $myCase->getFromDB( $_REQUEST['form']['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
|
||||
// now manage tasks associated with item
|
||||
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
}
|
||||
|
||||
// then get item id from DB
|
||||
$myCase = new PluginProcessmakerCase ;
|
||||
if( $myCase->getFromDB( $_REQUEST['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
if( isset( $_REQUEST['form'] ) ) {
|
||||
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ) {
|
||||
// Claim task management
|
||||
// here we are in a Claim request
|
||||
$myCase = new PluginProcessmakerCase ;
|
||||
if( $myCase->getFromDB( $_REQUEST['form']['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
|
||||
// now manage tasks associated with item
|
||||
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// now redirect to item form page
|
||||
//Html::redirect( Toolbox::getItemTypeFormURL($myCase->getField('itemtype')));
|
||||
echo "<html><body><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
echo "<html><body><script>";
|
||||
if( isset($config->fields['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>" ;
|
||||
|
||||
|
||||
?>
|
||||
@@ -2,22 +2,25 @@
|
||||
/**
|
||||
*/
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT . "/inc/includes.php");
|
||||
include ( "../../../inc/includes.php");
|
||||
|
||||
// No autoload when plugin is not activated
|
||||
require_once('../inc/config.class.php');
|
||||
//require_once('../inc/config.class.php');
|
||||
|
||||
$config = new PluginProcessmakerConfig();
|
||||
if (isset($_POST["update"])) {
|
||||
$config->check($_POST['id'],'w');
|
||||
|
||||
$config->check($_POST['id'], UPDATE);
|
||||
|
||||
// save
|
||||
$config->update($_POST);
|
||||
|
||||
|
||||
Html::back();
|
||||
|
||||
} elseif (isset($_POST["refresh"])) {
|
||||
$config->refresh($_POST); // used to refresh process list, task category list
|
||||
Html::back();
|
||||
}
|
||||
}
|
||||
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=".
|
||||
urlencode('PluginProcessmakerConfig$1'));
|
||||
|
||||
@@ -12,21 +12,22 @@ if (!isset($_REQUEST["id"])) {
|
||||
$PluginProcess = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_REQUEST["update"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], 'w');
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->update($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} elseif (isset($_REQUEST["refreshtask"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], 'w');
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->refreshTasks($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} else {
|
||||
$PluginProcess->checkGlobal('r');
|
||||
|
||||
// $PluginProcess->checkGlobal(READ);
|
||||
Html::header($LANG['processmaker']['title'][1],$_SERVER["PHP_SELF"],"plugins","processmaker");
|
||||
|
||||
$PluginProcess->showForm($_REQUEST["id"]);
|
||||
$PluginProcess->display($_REQUEST) ;
|
||||
|
||||
// $PluginProcess->showForm($_REQUEST["id"]);
|
||||
|
||||
Html::footer();
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ include (GLPI_ROOT."/inc/includes.php");
|
||||
|
||||
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "plugins", "processmaker");
|
||||
|
||||
if (plugin_processmaker_haveRight("process_config","r") || Session::haveRight("config","w")) {
|
||||
if (Session::haveRight("plugin_processmaker_config",READ) || Session::haveRight("config", UPDATE)) {
|
||||
$process=new PluginProcessmakerProcess();
|
||||
|
||||
if( isset( $_REQUEST['refresh'] ) && plugin_processmaker_haveRight("process_config","w") ) {
|
||||
if( isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config",UPDATE) ) {
|
||||
$process->refresh();
|
||||
Html::back();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
//define('GLPI_ROOT', '../../..');
|
||||
include_once ("../../../inc/includes.php");
|
||||
|
||||
Session::checkCentralAccess();
|
||||
|
||||
@@ -11,7 +11,7 @@ $process = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_POST["add"])) {
|
||||
|
||||
$right->check(-1,'w',$_POST);
|
||||
$right->check(-1,UPDATE,$_POST);
|
||||
if ($right->add($_POST)) {
|
||||
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
|
||||
@@ -23,7 +23,7 @@ if (isset($_POST["add"])) {
|
||||
if (isset($_POST["item"]) && count($_POST["item"])) {
|
||||
foreach ($_POST["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
if ($right->can($key,'w')) {
|
||||
if ($right->can($key,UPDATE)) {
|
||||
$right->delete(array('id' => $key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
if( !defined ('GLPI_ROOT' ) )
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include_once (GLPI_ROOT."/inc/includes.php");
|
||||
include_once '../inc/processmaker.class.php' ;
|
||||
include_once '../inc/cases.class.php' ;
|
||||
include_once ("../../../inc/includes.php");
|
||||
//include_once '../inc/processmaker.class.php' ;
|
||||
//include_once '../inc/cases.class.php' ;
|
||||
|
||||
switch( $_POST["action"] ) {
|
||||
case 'newcase':
|
||||
@@ -11,134 +9,63 @@ switch( $_POST["action"] ) {
|
||||
// we must check if a case is not already existing
|
||||
// to manage the problem of F5 (Refresh)
|
||||
$hasCase = PluginProcessmakerProcessmaker::getCaseIdFromItem( $_POST['itemtype'], $_POST['id'] ) ;
|
||||
if( $hasCase === false && $_POST['plugin_processmaker_process_id'] > 0 ) { //$DB->numrows($res) == 0) {
|
||||
if( $hasCase === false && $_POST['plugin_processmaker_process_id'] > 0 ) { //$DB->numrows($res) == 0) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ; //openSession();
|
||||
|
||||
$requesters = PluginProcessmakerProcessmaker::getItemUsers( $_POST['itemtype'], $_POST['id'], 1 ) ; // 1 for requesters
|
||||
if( !key_exists( 0, $requesters ) ) {
|
||||
$requesters[0]['glpi_id'] = 0 ;
|
||||
$requesters[0]['pm_id'] = 0 ;
|
||||
}
|
||||
|
||||
//$technicians = PluginProcessmakerProcessmaker::getItemUsers( $_POST['itemtype'], $_POST['id'], 2 ) ; // 2 for technicians
|
||||
//if( !key_exists( 0, $technicians ) ) {
|
||||
// $technicians[0]['glpi_id'] = Session::getLoginUserID() ;
|
||||
// $technicians[0]['pm_id'] = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) ;
|
||||
//}
|
||||
|
||||
// get item info to retreive title, description and duedate
|
||||
$locTicket = new $_POST['itemtype'] ; //Ticket();
|
||||
$locTicket->getFromDB( $_POST['id'] ) ;
|
||||
|
||||
if($locTicket->countUsers($locTicket::ASSIGN) == 0
|
||||
|| !$locTicket->isUser($locTicket::ASSIGN, Session::getLoginUserID()) ){
|
||||
$locTicket->update( array( 'id' => $_POST['id'], '_itil_assign' => array( '_type' => 'user', 'users_id' => Session::getLoginUserID() ) ) ) ;
|
||||
}
|
||||
|
||||
//$writer = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() );
|
||||
if( !isset($locTicket->fields['due_date']) || $locTicket->fields['due_date'] == null ) {
|
||||
$locTicket->fields['due_date'] = "";
|
||||
}
|
||||
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() ) ;
|
||||
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
|
||||
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
|
||||
'GLPI_TICKET_ID' => $_POST['id'],
|
||||
'GLPI_ITEM_TYPE' => $_POST['itemtype'],
|
||||
'GLPI_TICKET_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'],
|
||||
'GLPI_TICKET_REQUESTER_PM_ID' => $requesters[0]['pm_id'],
|
||||
'GLPI_TICKET_TITLE' => $locTicket->fields['name'],
|
||||
'GLPI_TICKET_DESCRIPTION' => $locTicket->fields['content'],
|
||||
'GLPI_TICKET_DUE_DATE' => $locTicket->fields['due_date'],
|
||||
'GLPI_TICKET_URGENCY' => $locTicket->fields['urgency'],
|
||||
'GLPI_ITEM_IMPACT' => $locTicket->fields['impact'],
|
||||
'GLPI_ITEM_PRIORITY' => $locTicket->fields['priority'],
|
||||
'GLPI_TICKET_GLOBAL_VALIDATION' => $locTicket->fields['global_validation'] ,
|
||||
'GLPI_TICKET_TECHNICIAN_GLPI_ID' => Session::getLoginUserID(), //$technicians[0]['glpi_id'],
|
||||
'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() ) //$technicians[0]['pm_id']
|
||||
) ) ;
|
||||
|
||||
if ($resultCase->status_code == 0){
|
||||
$caseInfo = $myProcessMaker->getCaseInfo( $resultCase->caseId );
|
||||
|
||||
//$query = "UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='".$resultCase->caseId."' AND APP_STATUS='DRAFT'" ;
|
||||
//$res = $DB->query($query) ;
|
||||
// save info to DB
|
||||
$query = "INSERT INTO glpi_plugin_processmaker_cases (items_id, itemtype, id, case_num, case_status, processes_id) VALUES (".$_POST['id'].", '".$_POST['itemtype']."', '".$resultCase->caseId."', ".$resultCase->caseNumber.", '".$caseInfo->caseStatus."', '".$caseInfo->processId."');" ;
|
||||
$res = $DB->query($query) ;
|
||||
|
||||
$myProcessMaker->add1stTask($_POST['itemtype'], $_POST['id'], $caseInfo ) ;
|
||||
|
||||
//echo "New case ID: $result->caseId, Case No: $result->caseNumber \n";
|
||||
Html::back();
|
||||
}
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
|
||||
} else
|
||||
Html::back();
|
||||
Html::back();
|
||||
}
|
||||
else { // the case is created before the ticket (used for user management before ticket creation)
|
||||
// list of requesters is needed
|
||||
// so read ticket
|
||||
//$requesters = array( ) ;
|
||||
|
||||
|
||||
//foreach( $DB->request( $query ) as $dbuser ) {
|
||||
// $requesters[] = $dbuser['pm_users_id'] ;
|
||||
//}
|
||||
//$writer = PluginProcessmakerProcessmaker::getPMUserId( Session::getLoginUserID() );
|
||||
//$userGLPI = new User();
|
||||
//$userGLPI->getFromDB( Session::getLoginUserID() ) ;
|
||||
//if( $userGLPI->fields['language'] != null )
|
||||
// $lang = substr( $userGLPI->fields['language'], 0, 2) ;
|
||||
//else
|
||||
// $lang = "en" ;
|
||||
else { // the case is created before the ticket (used for post-only case creation before ticket creation)
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ; //openSession( $userGLPI->fields['name'], "md5:37d442efb43ebb80ec6f9649b375ab72", $lang) ;
|
||||
|
||||
//$resultCase = $myProcessMaker->newCaseImpersonate( $_POST['plugin_processmaker_process_id'], $writer) ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0 ) ) ;
|
||||
if ($resultCase->status_code == 0){
|
||||
// case is created
|
||||
$myProcessMaker->login() ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
|
||||
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
|
||||
'GLPI_SELFSERVICE_CREATED' => '1',
|
||||
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ) ;
|
||||
if ($resultCase->status_code == 0){
|
||||
// case is created
|
||||
// Must show it...
|
||||
//
|
||||
//
|
||||
$rand = rand( ) ;
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]);
|
||||
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
|
||||
|
||||
} else {
|
||||
//Html::helpHeader($LANG['job'][13], $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
|
||||
//// case is not created show error message
|
||||
//echo "Error : ".$resultCase->status_code."</br>" ;
|
||||
//echo $resultCase->message."</br>" ;
|
||||
//Html::helpFooter();
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'unpausecase_or_reassign_or_delete' :
|
||||
if( isset( $_POST['unpause'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ; //openSession();
|
||||
$pmResultUnpause = $myProcessMaker->unpauseCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
if ($pmResultUnpause->status_code == 0){
|
||||
Html::back();
|
||||
}
|
||||
else
|
||||
else
|
||||
echo "Error unpausing case: ".$pmResultUnpause->message." \n";
|
||||
}
|
||||
else if( isset( $_POST['reassign'] ) ) {
|
||||
// here we should re-assign the current task to $_POST['users_id_recipient']
|
||||
$GLPINewPMUserId = PluginProcessmakerProcessmaker::getPMUserId( $_POST['users_id_recipient'] ) ;
|
||||
$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] ) ;
|
||||
if( $_POST['plugin_processmaker_userId'] != $GLPINewPMUserId ) {
|
||||
$locPM = new PluginProcessmakerProcessmaker() ;
|
||||
$locPM->login( ) ;
|
||||
|
||||
$pmResponse = $locPM->reassignCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'], $GLPINewPMUserId ) ;
|
||||
if ($pmResponse->status_code == 0){
|
||||
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
|
||||
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
|
||||
// we need the delindex of the current glpi task, and the delindex of the new one
|
||||
// search for new delindex
|
||||
$newCaseInfo = $locPM->getCaseInfo( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
@@ -150,52 +77,51 @@ switch( $_POST["action"] ) {
|
||||
}
|
||||
}
|
||||
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] ) ;
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
|
||||
// Html::back();
|
||||
}
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['assignedtoyou'], true, ERROR); // Html::back();
|
||||
}
|
||||
else if( isset($_POST['delete']) ) {
|
||||
// delete case from case table, this will also delete the tasks
|
||||
$locCase = new PluginProcessmakerCases ;
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->deleteCase() ) {
|
||||
// request delete from pm itself
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login(true) ;
|
||||
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
|
||||
|
||||
if( $resultPM->status_code == 0 ) {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
}
|
||||
else if( isset($_POST['cancel']) ) {
|
||||
// cancel case from PM
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ) ; //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ) ; //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
if( $resultPM->status_code === 0 ) {
|
||||
$locCase = new PluginProcessmakerCases ;
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->cancelCase() )
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
|
||||
if( $locCase->cancelCase() )
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// to return to ticket
|
||||
Html::back();
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
Session::checkRight("profile", "r");
|
||||
|
||||
$prof = new PluginProcessmakerProfile();
|
||||
|
||||
//Save profile
|
||||
if (isset ($_POST['update_user_profile'])) {
|
||||
$prof->update($_POST);
|
||||
Html::back();
|
||||
}
|
||||
?>
|
||||
@@ -5,15 +5,12 @@
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if( !defined('GLPI_ROOT' ) ) {
|
||||
define('GLPI_ROOT', '../../..');
|
||||
}
|
||||
include_once (GLPI_ROOT . "/inc/includes.php");
|
||||
include( "../../../inc/includes.php");
|
||||
|
||||
if (empty($_POST["_type"])
|
||||
|| ($_POST["_type"] != "Helpdesk")
|
||||
|| !$CFG_GLPI["use_anonymous_helpdesk"]) {
|
||||
Session::checkRight("create_ticket", "1");
|
||||
Session::checkRight("ticket", CREATE);
|
||||
}
|
||||
|
||||
// Security check
|
||||
@@ -22,17 +19,17 @@ if (empty($_POST) || count($_POST) == 0) {
|
||||
}
|
||||
|
||||
// here we are going to test if we must start a process
|
||||
if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
|
||||
&& isset($_POST["type"]) && $_POST["type"] == Ticket::DEMAND_TYPE
|
||||
if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
|
||||
&& isset($_POST["type"]) //&& $_POST["type"] == Ticket::DEMAND_TYPE
|
||||
&& isset($_POST["itilcategories_id"])
|
||||
&& isset($_POST["entities_id"])) {
|
||||
// here we have to check if there is an existing process in the entity and with the category
|
||||
// if yes we will start it
|
||||
// if not we will continue
|
||||
// special case if RUMT plugin is enabled and no process is available and category is 'User Management' then must start RUMT.
|
||||
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_POST["itilcategories_id"], $_POST["type"], $_SESSION['glpiactiveprofile']['id'], $_SESSION['glpiactive_entity'] ) ;
|
||||
|
||||
|
||||
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_POST["itilcategories_id"], $_POST["type"], $_SESSION['glpiactiveprofile']['id'], $_POST["entities_id"] ) ;
|
||||
|
||||
// currently only one process should be assigned to this itilcategory so this array should contain only one row
|
||||
$processQt = count( $processList ) ;
|
||||
if( $processQt == 1 ) {
|
||||
@@ -49,20 +46,38 @@ if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
|
||||
// if and only if itilcategories_id matches one of the 'User Management' categories
|
||||
// could be done via ARBehviours or RUMT itself
|
||||
$userManagementCat = array( 100556, 100557, 100558 ) ;
|
||||
$plug = new Plugin ;
|
||||
$plug = new Plugin ;
|
||||
if( $processQt == 0 && in_array( $_POST["itilcategories_id"], $userManagementCat) && $plug->isActivated('rayusermanagementticket' )) {
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/rayusermanagementticket/front/rayusermanagementticket.helpdesk.public.php");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if( !function_exists('stripcslashes_deep') ){
|
||||
/**
|
||||
* Strip c slash for variable & array
|
||||
*
|
||||
* @param $value array or string: item to stripslashes (array or string)
|
||||
*
|
||||
* @return stripcslashes item
|
||||
**/
|
||||
function stripcslashes_deep($value) {
|
||||
|
||||
$value = is_array($value) ?
|
||||
array_map('stripcslashes_deep', $value) :
|
||||
stripcslashes($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if( !function_exists('http_formdata_flat_hierarchy') ) {
|
||||
/**
|
||||
* Summary of http_formdata_flat_hierarchy
|
||||
* @param mixed $data
|
||||
* @param mixed $data
|
||||
* @return array
|
||||
*/
|
||||
function http_formdata_flat_hierarchy($data) {
|
||||
@@ -83,22 +98,73 @@ if( !function_exists('http_formdata_flat_hierarchy') ) {
|
||||
}
|
||||
}
|
||||
|
||||
if( !function_exists('tmpdir') ) {
|
||||
/**
|
||||
* Summary of tmpdir
|
||||
* Will attempts $attempts to create a random temp dir in $path
|
||||
* see: http://php.net/manual/en/function.mkdir.php
|
||||
* @param string $path: dir into the temp subdir will be created
|
||||
* @param string $prefix: used to prefix the random number for dir name
|
||||
* @param int $attempts: is the quantity of attempts trying to create tempdir
|
||||
* @return bool|string: false if $attempts has been reached, otherwise the path to the newly created dir
|
||||
*/
|
||||
function tmpdir($path, $prefix='', $attempts=3){
|
||||
$count = 1 ;
|
||||
do {
|
||||
$rand=$prefix.rand() ;
|
||||
} while( !mkdir($path.'/'.$rand) && $count++ < $attempts ) ;
|
||||
|
||||
return ($count < $attempts ? $path.'/'.$rand : false ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// by default loads standard page from GLPI
|
||||
//include (GLPI_ROOT . "/front/tracking.injector.php");
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']);
|
||||
curl_setopt($ch, CURLOPT_REFERER, "http://localhost".$CFG_GLPI["root_doc"]."/front/tracking.injector.php" ) ;
|
||||
|
||||
// why not [HTTP_REFERER] "http://fry07689-glpi090.fr.ray.group/front/helpdesk.public.php?create_ticket=1" string
|
||||
curl_setopt($ch, CURLOPT_REFERER, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php" ) ;
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
$data = http_formdata_flat_hierarchy( $_REQUEST ) ;
|
||||
|
||||
// CSRF management
|
||||
if( GLPI_USE_CSRF_CHECK ) {
|
||||
// must set a csrf token
|
||||
$data['_glpi_csrf_token'] = Session::getNewCSRFToken() ;
|
||||
}
|
||||
|
||||
$data = array_map('Toolbox::unclean_cross_side_scripting_deep', $data);
|
||||
$data = array_map('stripcslashes_deep', $data);
|
||||
|
||||
// need to add files if some are uploaded
|
||||
$files = array() ;
|
||||
$paths = array() ;
|
||||
if( isset( $_FILES['filename']['name'] ) && is_array($_FILES['filename']['name']) && count($_FILES['filename']['name']) > 0) {
|
||||
foreach( $_FILES['filename']['name'] as $num => $file ){
|
||||
if( $file <> '' ){
|
||||
$path = str_replace( '\\', '/', $_FILES['filename']['tmp_name'][$num] ) ;
|
||||
$path = explode('/', $path);
|
||||
array_pop( $path ) ;
|
||||
$path = tmpdir(implode( '/', $path ), 'php_tmp') ;
|
||||
if( $path !== false ) {
|
||||
$paths[$num] = $path;
|
||||
$files[$num] = $paths[$num].'/'.$file;
|
||||
copy( $_FILES['filename']['tmp_name'][$num], $files[$num] ) ;
|
||||
$data['filename['.$num.']']='@'.$files[$num] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
|
||||
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
|
||||
//curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, "http://localhost".$CFG_GLPI["root_doc"]."/front/tracking.injector.php");
|
||||
curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php");
|
||||
|
||||
// as sessions in PHP are not re-entrant, we MUST close current one before curl_exec
|
||||
@session_write_close() ;
|
||||
@@ -107,3 +173,11 @@ curl_exec ($ch);
|
||||
|
||||
curl_close ($ch);
|
||||
|
||||
// need to delete temp files
|
||||
foreach( $files as $file ) {
|
||||
unlink( $file ) ;
|
||||
}
|
||||
foreach( $paths as $path ) {
|
||||
rmdir( $path ) ;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
12
inc/caselink.class.php
Normal file
12
inc/caselink.class.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCaselink short summary.
|
||||
*
|
||||
* PluginProcessmakerCaselink description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCaselink extends CommonDBTM {
|
||||
}
|
||||
12
inc/caselinkaction.class.php
Normal file
12
inc/caselinkaction.class.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCaselinkaction short summary.
|
||||
*
|
||||
* PluginProcessmakerCaselinkaction description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCaselinkaction extends CommonDBTM {
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
22
inc/crontaskaction.class.php
Normal file
22
inc/crontaskaction.class.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerCrontaskaction is used to manage actions between cases
|
||||
*
|
||||
* Allows actions: routing cases (called slaves) from another case (called master)
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCrontaskaction extends CommonDBTM {
|
||||
|
||||
// postdatas 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 DONE = 3 ;
|
||||
|
||||
}
|
||||
26
inc/db.class.php
Normal file
26
inc/db.class.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class PluginProcessmakerDB extends DBmysql {
|
||||
|
||||
var $dbhost ;
|
||||
|
||||
var $dbuser ;
|
||||
|
||||
var $dbpassword ;
|
||||
|
||||
var $dbdefault ;
|
||||
|
||||
function __construct() {
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
if( $config->fields['pm_dbserver_name'] != ''
|
||||
&& $config->fields['pm_dbserver_user'] != ''
|
||||
&& $config->fields['pm_workspace'] != '' ) {
|
||||
$this->dbhost = $config->fields['pm_dbserver_name'] ;
|
||||
$this->dbuser = $config->fields['pm_dbserver_user'] ;
|
||||
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
|
||||
$this->dbdefault = "wf_".$config->fields['pm_workspace'] ;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
{
|
||||
function can($ID, $right, &$input = NULL) {
|
||||
return plugin_processmaker_haveRight('process_config', $right) ;
|
||||
function can($ID, $right, array &$input = NULL) {
|
||||
return Session::haveRight('plugin_processmaker_config', $right) ;
|
||||
}
|
||||
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
@@ -25,37 +25,34 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
|
||||
$ID = $item->getField('id');
|
||||
|
||||
$canshowentity = Session::haveRight("entity","r");
|
||||
$canedit = plugin_processmaker_haveRight('process_config', 'w') ;
|
||||
$canshowentity = Session::haveRight("entity", READ);
|
||||
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE) ;
|
||||
|
||||
$rand=mt_rand();
|
||||
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
|
||||
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
|
||||
|
||||
if ($canedit) {
|
||||
echo "<div class='firstbloc'>";
|
||||
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
|
||||
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['processmaker']['title'][4]."</tr>";
|
||||
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
|
||||
|
||||
echo "<tr class='tab_bg_2'><td class='center'>";
|
||||
echo "<input type='hidden' name='processes_id' value='$ID'>";
|
||||
Dropdown::show('Entity', array('entity' => $_SESSION['glpiactiveentities']));
|
||||
echo "</td><td class='center'>".$LANG['profiles'][22]." : ";
|
||||
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
|
||||
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
|
||||
Profile::dropdownUnder(array('value' => Profile::getDefault()));
|
||||
echo "</td><td class='center'>".$LANG['profiles'][28]." : ";
|
||||
echo "</td><td class='center'>".__('Recursive')."</td><td>";
|
||||
Dropdown::showYesNo("is_recursive",0);
|
||||
echo "</td><td class='center'>";
|
||||
echo "<input type='submit' name='add' value=\"".$LANG['buttons'][8]."\" class='submit'>";
|
||||
echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</table></div>";
|
||||
echo "</table>";
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "<div class='spaced'><table class='tab_cadre_fixehov'>";
|
||||
echo "<tr><th colspan='2'>".$LANG['Menu'][37]."</th>";
|
||||
echo "<th>".$LANG['profiles'][22]." (D=".$LANG['profiles'][29].", R=".$LANG['profiles'][28].")";
|
||||
echo "</th></tr>";
|
||||
|
||||
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
|
||||
`glpi_profiles`.`id`,
|
||||
`glpi_profiles`.`name`,
|
||||
@@ -70,55 +67,125 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
WHERE `glpi_plugin_processmaker_processes_profiles`.`processes_id` = '$ID'
|
||||
ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
|
||||
$result = $DB->query($query);
|
||||
$num = $DB->numrows($result);
|
||||
|
||||
if ($DB->numrows($result) >0) {
|
||||
while ($data = $DB->fetch_array($result)) {
|
||||
echo "<div class='spaced'>";
|
||||
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
|
||||
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams = array('num_displayed' => $num,
|
||||
'container' => 'mass'.__CLASS__.$rand);
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
|
||||
|
||||
if ($num > 0) {
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
$header_begin = "<tr>";
|
||||
$header_top = '';
|
||||
$header_bottom = '';
|
||||
$header_end = '';
|
||||
if ($canedit) {
|
||||
$header_begin .= "<th>";
|
||||
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_end .= "</th>";
|
||||
}
|
||||
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
|
||||
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
|
||||
__('D=Dynamic, R=Recursive'));
|
||||
$header_end .= "</th></tr>";
|
||||
echo $header_begin.$header_top.$header_end;
|
||||
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td width='10'>";
|
||||
|
||||
if ($canedit && in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
|
||||
echo "<input type='checkbox' name='item[".$data["linkID"]."]' value='1'>";
|
||||
} else {
|
||||
echo " ";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
if ($data["entities_id"] == 0) {
|
||||
$data["completename"] = $LANG['entity'][2];
|
||||
if ($canedit) {
|
||||
echo "<td width='10'>";
|
||||
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
|
||||
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
|
||||
} else {
|
||||
echo " ";
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
echo "<td>";
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".$data["entities_id"]."'>";
|
||||
$link = $data["completename"];
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
|
||||
}
|
||||
echo $data["completename"].
|
||||
($_SESSION["glpiis_ids_visible"]?" (".$data["entities_id"].")":"");
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "</a>";
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
|
||||
$data["entities_id"]."'>";
|
||||
}
|
||||
echo $link.($canshowentity ? "</a>" : '');
|
||||
echo "</td>";
|
||||
echo "<td>".$data["name"];
|
||||
|
||||
if (Profile::canView()) {
|
||||
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
|
||||
$data["name"]."</a>";
|
||||
} else {
|
||||
$entname = $data["name"];
|
||||
}
|
||||
|
||||
// if ($data["is_dynamic"] || $data["is_recursive"]) {
|
||||
if ($data["is_recursive"]) {
|
||||
echo "<span class='b'> (";
|
||||
echo "R";
|
||||
echo ")</span>";
|
||||
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
|
||||
//if ($data["is_dynamic"]) {
|
||||
// //TRANS: letter 'D' for Dynamic
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
|
||||
//}
|
||||
//if ($data["is_dynamic"] && $data["is_recursive"]) {
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
|
||||
//}
|
||||
if ($data["is_recursive"]) {
|
||||
//TRANS: letter 'R' for Recursive
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
|
||||
}
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td>".$entname."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</tr>";
|
||||
echo $header_begin.$header_bottom.$header_end;
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th>".__('No item found')."</th></tr>";
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
if ($canedit) {
|
||||
Html::openArrowMassives("entityprocess_form$rand",true);
|
||||
Html::closeArrowMassives(array('delete' => $LANG['buttons'][6]));
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams['ontop'] = false;
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
//static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) {
|
||||
// global $CFG_GLPI;
|
||||
|
||||
// $action = $ma->getAction();
|
||||
|
||||
// switch ($action) {
|
||||
// case 'profile_delete' :
|
||||
// foreach ($ids as $id) {
|
||||
// if ($item->can($id, DELETE)) {
|
||||
// if ($item->delete(array("id" => $id))) {
|
||||
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
|
||||
// } else {
|
||||
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
|
||||
// $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
|
||||
// }
|
||||
// } else {
|
||||
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
|
||||
// $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
|
||||
// }
|
||||
// }
|
||||
// break ;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@ class ProcessmakerConfig extends CommonDBTM {
|
||||
var $table = 'glpi_plugins_processmaker_config';
|
||||
|
||||
|
||||
static function getTypeName() {
|
||||
static function getTypeName($nb=0) {
|
||||
global $LANG;
|
||||
|
||||
return 'Process Maker Plugin Configuration';
|
||||
@@ -68,7 +68,7 @@ class ProcessmakerConfig extends CommonDBTM {
|
||||
function showForm($ID, $options=array()) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
if (!Session::haveRight("config", "w")) {
|
||||
if (!Session::haveRight("config", UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
if (!$CFG_GLPI['use_mailing']) {
|
||||
@@ -82,108 +82,17 @@ class ProcessmakerConfig extends CommonDBTM {
|
||||
}
|
||||
|
||||
|
||||
function canCreate() {
|
||||
return Session::haveRight('config', 'w');
|
||||
static function canCreate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
|
||||
|
||||
function canView() {
|
||||
return Session::haveRight('config', 'r');
|
||||
static function canView() {
|
||||
return Session::haveRight('config', READ);
|
||||
}
|
||||
|
||||
|
||||
//function showFormMailServerConfig() {
|
||||
// global $LANG, $CFG_GLPI;
|
||||
|
||||
// echo "<form action='".Toolbox::getItemTypeFormURL(__CLASS__)."' method='post'>";
|
||||
// echo "<div>";
|
||||
// echo "<table class='tab_cadre_fixe'>";
|
||||
// echo "<input type='hidden' name='id' value='1'>";
|
||||
|
||||
// echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['setup'][704]."</th></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][202] . " :</td><td>";
|
||||
// Dropdown::showYesNo("use_mailing", $CFG_GLPI["use_mailing"]);
|
||||
// echo "</td>";
|
||||
|
||||
// if ($CFG_GLPI['use_mailing']) {
|
||||
|
||||
// echo "<td >" . $LANG['setup'][227] . " :</td>";
|
||||
// echo "<td><input type='text' name='url_base' size='40' value='".$CFG_GLPI["url_base"]."'>";
|
||||
// echo "</td></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_2'>";
|
||||
// echo "<td>" . $LANG['setup'][203] . " :</td>";
|
||||
// echo "<td><input type='text' name='admin_email' size='40' value='".
|
||||
// $CFG_GLPI["admin_email"]."'>";
|
||||
// if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_email"])) {
|
||||
// echo "<span class='red'> ".$LANG['mailing'][110]."</span>";
|
||||
// }
|
||||
// echo "</td>";
|
||||
// echo "<td >" . $LANG['setup'][208] . " :</td>";
|
||||
// echo "<td><input type='text' name='admin_email_name' size='40' value='" .
|
||||
// $CFG_GLPI["admin_email_name"] . "'>";
|
||||
// echo " </td></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_2'>";
|
||||
// echo "<td >" . $LANG['setup'][207] . " :</td>";
|
||||
// echo "<td><input type='text' name='admin_reply' size='40' value='" .
|
||||
// $CFG_GLPI["admin_reply"] . "'>";
|
||||
// if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_reply"])) {
|
||||
// echo "<span class='red'> ".$LANG['mailing'][110]."</span>";
|
||||
// }
|
||||
// echo " </td>";
|
||||
// echo "<td >" . $LANG['setup'][209] . " :</td>";
|
||||
// echo "<td><input type='text' name='admin_reply_name' size='40' value='" .
|
||||
// $CFG_GLPI["admin_reply_name"] . "'>";
|
||||
// echo " </td></tr>";
|
||||
// if (!function_exists('mail')) {
|
||||
// echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
|
||||
// echo "<span class='red'>" . $LANG['setup'][217] . " :</span>".
|
||||
// $LANG['setup'][218] . "</td></tr>";
|
||||
// }
|
||||
|
||||
// echo "<tr class='tab_bg_2'>";
|
||||
// echo "<td>" . $LANG['setup'][204] . " :</td>";
|
||||
// echo "<td colspan='3'><textarea cols='60' rows='3' name='mailing_signature'>".
|
||||
// $CFG_GLPI["mailing_signature"]."</textarea></td></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_1'><th colspan='4'>".$LANG['setup'][660]."</th></tr>";
|
||||
// echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][231] . " :</td><td>";
|
||||
// $mail_methods = array(MAIL_MAIL => $LANG['setup'][650],
|
||||
// MAIL_SMTP => $LANG['setup'][651],
|
||||
// MAIL_SMTPSSL => $LANG['setup'][652],
|
||||
// MAIL_SMTPTLS => $LANG['setup'][653]);
|
||||
// Dropdown::showFromArray("smtp_mode", $mail_methods,
|
||||
// array('value' => $CFG_GLPI["smtp_mode"]));
|
||||
// echo "</td><td colspan='2' class='center'> ";
|
||||
// echo "</td></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][232] . " :</td>";
|
||||
// echo "<td><input type='text' name='smtp_host' size='40' value='".$CFG_GLPI["smtp_host"]."'>";
|
||||
// echo "</td>";
|
||||
// echo "<td >" . $LANG['setup'][234] . " :</td>";
|
||||
// echo "<td><input type='text' name='smtp_username' size='40' value='" .
|
||||
// $CFG_GLPI["smtp_username"] . "'></td></tr>";
|
||||
|
||||
// echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][175] . " :</td>";
|
||||
// echo "<td><input type='text' name='smtp_port' size='5' value='".$CFG_GLPI["smtp_port"]."'>";
|
||||
// echo "</td>";
|
||||
// echo "<td >" . $LANG['setup'][235] . " :</td>";
|
||||
// echo "<td><input type='password' name='smtp_passwd' size='40' value='' autocomplete='off'>";
|
||||
// echo "<br><input type='checkbox' name='_blank_smtp_passwd'> ".$LANG['setup'][284];
|
||||
|
||||
// echo "</td></tr>";
|
||||
|
||||
// } else {
|
||||
// echo "<td colspan='2'></td></tr>";
|
||||
// }
|
||||
// $options['candel'] = false;
|
||||
// $options['addbuttons'] = array('test_smtp_send' => $LANG['setup'][229]);
|
||||
// $this->showFormButtons($options);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,114 +8,82 @@ if (!defined('GLPI_ROOT')) {
|
||||
|
||||
class PluginProcessmakerProfile extends CommonDBTM {
|
||||
|
||||
|
||||
//if profile deleted
|
||||
static function cleanProfiles(Profile $prof) {
|
||||
|
||||
$plugprof = new self();
|
||||
$plugprof->delete(array('id' => $prof->getID()));
|
||||
}
|
||||
|
||||
|
||||
static function select() {
|
||||
|
||||
$prof = new self();
|
||||
if ($prof->getFromDBByProfile($_SESSION['glpiactiveprofile']['id'])) {
|
||||
$_SESSION["glpi_plugin_processmaker_profile"] = $prof->fields;
|
||||
} else {
|
||||
unset($_SESSION["glpi_plugin_processmaker_profile"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//profiles modification
|
||||
function showForm($ID, $options=array()) {
|
||||
/**
|
||||
* Summary of getAllRights
|
||||
* @return array[]
|
||||
*/
|
||||
static function getAllRights() {
|
||||
global $LANG;
|
||||
|
||||
$target = $this->getFormURL();
|
||||
if (isset($options['target'])) {
|
||||
$target = $options['target'];
|
||||
}
|
||||
|
||||
if (!Session::haveRight("profile","r")) {
|
||||
$rights = array(
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['process_config'],
|
||||
'field' => 'plugin_processmaker_config',
|
||||
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['case_delete'],
|
||||
'field' => 'plugin_processmaker_deletecase',
|
||||
'rights' => array(DELETE => __('Delete')))
|
||||
);
|
||||
|
||||
return $rights;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of showForm
|
||||
* @param mixed $ID
|
||||
* @param mixed $openform
|
||||
* @param mixed $closeform
|
||||
* @return bool
|
||||
*/
|
||||
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
|
||||
global $LANG;
|
||||
|
||||
if (!Session::haveRight("profile",READ)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$canedit = Session::haveRight("profile", "w");
|
||||
$canedit = Session::haveRight("profile", UPDATE);
|
||||
$prof = new Profile();
|
||||
if ($ID) {
|
||||
$this->getFromDBByProfile($ID);
|
||||
$prof->getFromDB($ID);
|
||||
}
|
||||
echo "<form action='".$target."' method='post'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<form action='".$prof->getFormURL()."' method='post'>";
|
||||
$rights = $this->getAllRights();
|
||||
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
|
||||
'default_class' => 'tab_bg_2',
|
||||
'title' => $LANG['processmaker']['title'][1]));
|
||||
|
||||
echo "<tr><th colspan='2'>".$LANG['processmaker']['profile']['rightmgt']." : ".$prof->fields["name"].
|
||||
"</th></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_2'>";
|
||||
echo "<td>".$LANG['processmaker']['profile']['process_config']." :</td><td>";
|
||||
|
||||
if ($prof->fields['interface']!='helpdesk') {
|
||||
Profile::dropdownNoneReadWrite("process_config", $this->fields["process_config"], 1, 1, 1);
|
||||
} else {
|
||||
echo $LANG['profiles'][12]; // No access;
|
||||
if ($canedit && $closeform) {
|
||||
echo "<div class='center'>";
|
||||
echo Html::hidden('id', array('value' => $ID));
|
||||
echo Html::submit(_sx('button', 'Save'),
|
||||
array('name' => 'update'));
|
||||
echo "</div>\n";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
Html::closeForm();
|
||||
|
||||
if ($canedit) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td class='center' colspan='2'>";
|
||||
echo "<input type='hidden' name='id' value=".$this->getID().">";
|
||||
echo "<input type='submit' name='update_user_profile' value=\"".$LANG['buttons'][7]."\"
|
||||
class='submit'>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
Html::closeForm();
|
||||
}
|
||||
|
||||
function getFromDBByProfile($profiles_id) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM `".$this->getTable()."`
|
||||
WHERE `profiles_id` = '" . $profiles_id . "' ";
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of createAdminAccess
|
||||
* @param mixed $ID
|
||||
*/
|
||||
static function createAdminAccess($ID) {
|
||||
|
||||
$myProf = new self();
|
||||
if (!$myProf->getFromDBByProfile($ID)) {
|
||||
|
||||
$myProf->add(array(
|
||||
'profiles_id' => $ID,
|
||||
'process_config' => 'w'
|
||||
));
|
||||
|
||||
}
|
||||
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function createUserAccess($Profile) {
|
||||
|
||||
return $this->add(array('profiles_id' => $Profile->getID()
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of getTabNameForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $withtemplate
|
||||
* @return string|string[]
|
||||
*/
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
|
||||
@@ -125,19 +93,51 @@ class PluginProcessmakerProfile extends CommonDBTM {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of displayTabContentForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @return bool
|
||||
*/
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if ($item->getType()=='Profile') {
|
||||
$ID = $item->getID();
|
||||
$prof = new self();
|
||||
if ($prof->getFromDBByProfile($ID) || $prof->createUserAccess($item)) {
|
||||
self::addDefaultProfileInfos($ID,
|
||||
array('plugin_processmaker_config' => 0,
|
||||
'plugin_processmaker_deletecase' => 0
|
||||
));
|
||||
|
||||
$prof->showForm($ID);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* @param $profile
|
||||
**/
|
||||
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
|
||||
global $DB;
|
||||
|
||||
$profileRight = new ProfileRight();
|
||||
foreach ($rights as $right => $value) {
|
||||
if (countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
|
||||
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
|
||||
}
|
||||
if (!countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
|
||||
$myright['profiles_id'] = $profiles_id;
|
||||
$myright['name'] = $right;
|
||||
$myright['rights'] = $value;
|
||||
$profileRight->add($myright);
|
||||
|
||||
//Add right to the current session
|
||||
$_SESSION['glpiactiveprofile'][$right] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
134
inc/task.class.php
Normal file
134
inc/task.class.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* tasks short summary.
|
||||
*
|
||||
* tasks description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerTask extends CommonITILTask
|
||||
{
|
||||
private $itemtype ;
|
||||
function __construct($itemtype) {
|
||||
parent::__construct();
|
||||
$this->itemtype=$itemtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getFromDB
|
||||
* @param mixed $items_id
|
||||
* @param mixed $itemtype
|
||||
* @return bool
|
||||
*/
|
||||
function getFromDB($items_id) {
|
||||
global $DB ;
|
||||
|
||||
if( $this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ) ) {
|
||||
$task = new $this->itemtype;
|
||||
if( $task->getFromDB( $items_id ) ) {
|
||||
// then we should add our own fields
|
||||
$task->fields['items_id'] = $this->fields['id'] ;
|
||||
$task->fields['itemtype'] = $this->fields['itemtype'] ;
|
||||
unset( $this->fields['id'] ) ;
|
||||
unset( $this->fields['items_id'] ) ;
|
||||
unset( $this->fields['itemtype'] ) ;
|
||||
foreach( $this->fields as $field => $val) {
|
||||
$task->fields[ $field ] = $val ;
|
||||
}
|
||||
$this->fields = $task->fields ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
|
||||
|
||||
//$ret = $DB->query( $query ) ;
|
||||
//if( $ret && $DB->numrows( $ret ) == 1 ) {
|
||||
// $row = $DB->fetch_assoc( $ret ) ;
|
||||
// $task = new $this->itemtype;
|
||||
// if( $task->getFromDB( $row['items_id'] ) ) {
|
||||
// // then we should add our own fields
|
||||
// unset( $row['id'] ) ;
|
||||
// unset( $row['items_id'] ) ;
|
||||
// unset( $row['itemtype'] ) ;
|
||||
// foreach( $row as $field => $val) {
|
||||
// $task->fields[ $field ] = $val ;
|
||||
// }
|
||||
// $this->fields = $task->fields ;
|
||||
// return true ;
|
||||
// }
|
||||
//}
|
||||
return false ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getToDoTasks
|
||||
* returns all 'to do' tasks associated with this case
|
||||
* @param mixed $case_id
|
||||
*/
|
||||
public static function getToDoTasks( $case_id, $itemtype ) {
|
||||
global $DB ;
|
||||
$ret = array();
|
||||
$selfTable = getTableForItemType( __CLASS__) ;
|
||||
$itemTypeTaskTable = getTableForItemType( $itemtype );
|
||||
|
||||
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
|
||||
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
|
||||
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
|
||||
foreach($DB->request($query) as $row){
|
||||
$ret[$row['taskID']]=$row['taskID'];
|
||||
}
|
||||
return $ret ;
|
||||
}
|
||||
|
||||
static function canView( ) {
|
||||
return true ;
|
||||
}
|
||||
|
||||
static function populatePlanning($params) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
$ret = array();
|
||||
$events = array() ;
|
||||
if( isset($params['start']) ) {
|
||||
$params['begin'] = '2000-01-01 00:00:00';
|
||||
if ($params['type'] == 'group') {
|
||||
$params['who_group'] = $params['who'];
|
||||
$params['whogroup'] = $params['who'];
|
||||
$params['who'] = 0 ;
|
||||
}
|
||||
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
|
||||
|
||||
foreach( $ret as $key => $event ) {
|
||||
if( $event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
|
||||
// check if task is one within a case
|
||||
$pmTask = new self('TicketTask');
|
||||
if( $pmTask->getFromDB( $event['tickettasks_id'] ) ) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
|
||||
$event['editable'] = false;
|
||||
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases' ;
|
||||
|
||||
$taskCat = new TaskCategory ;
|
||||
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] ) ;
|
||||
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '' ;
|
||||
if( Session::haveTranslations('TaskCategory', 'comment') ) {
|
||||
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment ) ;
|
||||
}
|
||||
|
||||
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] ) ;
|
||||
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ) ; //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
|
||||
//if( $event['state'] == 1 && $event['end'] < $params['start'] ) { // if todo and late
|
||||
// $event['name'] = $event['end'].' '.$event['name'] ; //$event['begin'].' to '.$event['end'].' '.$event['name'] ;
|
||||
// $event['end'] = $params['start'].' 24:00:00'; //.$CFG_GLPI['planning_end'];
|
||||
//}
|
||||
$events[$key] = $event ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $events ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
$buttons = array();
|
||||
$title = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
|
||||
if (plugin_processmaker_haveRight('process_config', 'w')) {
|
||||
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
|
||||
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
$title = "";
|
||||
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
|
||||
@@ -78,12 +78,12 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
}
|
||||
}
|
||||
|
||||
function getLinkItemFromExternalID($extId) {
|
||||
if( $this->getFromDBbyExternalID( $extId ) ) {
|
||||
$taskcat = new TaskCategory ;
|
||||
return $taskcat->getFromDB( $this->fields['items_id'] ) ;
|
||||
}
|
||||
}
|
||||
//function getLinkItemFromExternalID($extId) {
|
||||
// if( $this->getFromDBbyExternalID( $extId ) ) {
|
||||
// $taskcat = new TaskCategory ;
|
||||
// return $taskcat->getFromDB( $this->fields['items_id'] ) ;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
@@ -112,5 +112,30 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a TaskCat from the database using its category id (unique index): taskcategories_id
|
||||
*
|
||||
* @param $catid string task category id
|
||||
*
|
||||
* @return true if succeed else false
|
||||
**/
|
||||
function getFromDBbyCategory($catid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `taskcategories_id` = $catid";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user