Version 3.0.0 first version compatible with GLPi 9.1.1
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,57 @@ 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();
|
||||
// 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"]));
|
||||
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();
|
||||
|
||||
// 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);
|
||||
|
||||
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"];
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 (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,153 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include_once '../inc/processmaker.class.php' ;
|
||||
include_once '../inc/cases.class.php' ;
|
||||
define('DO_NOT_CHECK_HTTP_REFERER', 1);
|
||||
include_once '../../../inc/includes.php';
|
||||
//include_once '../inc/processmaker.class.php' ;
|
||||
//include_once '../inc/case.class.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 ;
|
||||
$myCase = new PluginProcessmakerCase ;
|
||||
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'] ) ;
|
||||
$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 ;
|
||||
|
||||
$infoForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_TASK_CONTENT",
|
||||
"GLPI_ITEM_APPEND_TO_TASK",
|
||||
"GLPI_NEXT_GROUP_TO_BE_ASSIGNED",
|
||||
"GLPI_ITEM_TITLE",
|
||||
"GLPI_TICKET_FOLLOWUP_CONTENT",
|
||||
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE",
|
||||
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID",
|
||||
"GLPI_ITEM_TASK_ENDDATE",
|
||||
"GLPI_ITEM_TASK_STARTDATE",
|
||||
"GLPI_ITEM_SET_STATUS"
|
||||
) );
|
||||
$itemSetStatus = '';
|
||||
if( array_key_exists( 'GLPI_ITEM_SET_STATUS', $infoForTasks ) ) {
|
||||
$itemSetStatus = $infoForTasks[ 'GLPI_ITEM_SET_STATUS' ] ;
|
||||
}
|
||||
|
||||
$txtItemTitle = '' ;
|
||||
if( array_key_exists( 'GLPI_ITEM_TITLE', $infoForTasks ) ) {
|
||||
$txtItemTitle = $infoForTasks[ 'GLPI_ITEM_TITLE' ] ;
|
||||
}
|
||||
|
||||
$txtToAppendToTask = '' ;
|
||||
if( array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $infoForTasks ) ) {
|
||||
$txtToAppendToTask = $infoForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ] ;
|
||||
}
|
||||
|
||||
$txtTaskContent = '' ;
|
||||
if( array_key_exists( 'GLPI_ITEM_TASK_CONTENT', $infoForTasks ) ) {
|
||||
$txtTaskContent = $infoForTasks[ 'GLPI_ITEM_TASK_CONTENT' ] ;
|
||||
}
|
||||
|
||||
$groupId = 0 ;
|
||||
if( array_key_exists( 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED', $infoForTasks ) ) {
|
||||
$groupId = $infoForTasks[ 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' ] ;
|
||||
}
|
||||
|
||||
$taskStartDate = '' ;
|
||||
$taskEndDate = '' ;
|
||||
if( array_key_exists( 'GLPI_ITEM_TASK_ENDDATE', $infoForTasks ) ) {
|
||||
$taskEndDate = $infoForTasks[ 'GLPI_ITEM_TASK_ENDDATE' ] ;
|
||||
}
|
||||
if( array_key_exists( 'GLPI_ITEM_TASK_STARTDATE', $infoForTasks ) ) {
|
||||
$taskStartDate = $infoForTasks[ 'GLPI_ITEM_TASK_STARTDATE' ] ;
|
||||
if( $taskEndDate == '' ) {
|
||||
// at least
|
||||
$taskEndDate = $taskStartDate ;
|
||||
}
|
||||
}
|
||||
|
||||
$createFollowup = false ; // by default
|
||||
if( array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $infoForTasks ) && $infoForTasks[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') {
|
||||
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_IS_PRIVATE', $infoForTasks )
|
||||
//&& array_key_exists( 'GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID', $infoForTasks )
|
||||
$createFollowup = true ;
|
||||
}
|
||||
// reset those variables
|
||||
$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , array( "GLPI_ITEM_APPEND_TO_TASK" => '', 'GLPI_ITEM_TASK_CONTENT' => '', 'GLPI_NEXT_GROUP_TO_BE_ASSIGNED' => '' ) ) ;
|
||||
|
||||
$resultSave = $myProcessMaker->sendVariables( $myCase->getID() , array( "GLPI_ITEM_APPEND_TO_TASK" => '',
|
||||
"GLPI_ITEM_TASK_CONTENT" => '',
|
||||
"GLPI_NEXT_GROUP_TO_BE_ASSIGNED" => '',
|
||||
"GLPI_TICKET_FOLLOWUP_CONTENT" => '',
|
||||
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE" => '',
|
||||
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" => '',
|
||||
"GLPI_ITEM_TASK_ENDDATE" => '',
|
||||
"GLPI_ITEM_TASK_STARTDATE" => '',
|
||||
'GLPI_ITEM_TITLE' => '',
|
||||
"GLPI_ITEM_SET_STATUS" => ''
|
||||
) ) ;
|
||||
|
||||
// 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 ) ;
|
||||
|
||||
// create a followup if requested
|
||||
if( $createFollowup && $itemType == 'Ticket' ) {
|
||||
$myProcessMaker->addTicketFollowup( $itemId, $infoForTasks ) ;
|
||||
}
|
||||
$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 ) ;
|
||||
foreach( $pmRouteCaseResponse->routing as $route ) {
|
||||
$myProcessMaker->addTask( $itemType, $itemId, $caseInfo, $route->delIndex, PluginProcessmakerUser::getGLPIUserId( $route->userId ), $groupId, $route->taskId, $txtTaskContent, $taskStartDate, $taskEndDate ) ;
|
||||
// if end date was specicied, then must change due date of the PM task
|
||||
if( $taskEndDate != '' ) {
|
||||
$PM_DB->query( "UPDATE APP_DELEGATION SET DEL_TASK_DUE_DATE='$taskEndDate' WHERE APP_UID='".$caseInfo->caseId."' AND DEL_INDEX=".$route->delIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $txtItemTitle != '') {
|
||||
// we are going to change the title of current GLPI Item
|
||||
$item = new $itemType ;
|
||||
$item->getFromDB( $itemId ) ;
|
||||
$item->update( array('id' => $itemId, 'name' => $txtItemTitle) ) ;
|
||||
}
|
||||
|
||||
if( $itemSetStatus != '' ) {
|
||||
$myProcessMaker->setItemStatus($itemType, $itemId, $itemSetStatus ) ;
|
||||
}
|
||||
// evolution of case status: DRAFT, TO_DO, COMPLETED, CANCELLED
|
||||
$myCase->update( array( 'id' => $myCase->getID(), 'case_status' => $caseInfo->caseStatus ) ) ;
|
||||
|
||||
}
|
||||
}
|
||||
$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 ;
|
||||
$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'] ) ;
|
||||
$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>" ;
|
||||
echo "<html><body><script></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':
|
||||
@@ -15,89 +13,21 @@ switch( $_POST["action"] ) {
|
||||
$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->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']
|
||||
) ) ;
|
||||
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() ) ;
|
||||
|
||||
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";
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
|
||||
} else
|
||||
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) ;
|
||||
$myProcessMaker->login() ;
|
||||
|
||||
//$resultCase = $myProcessMaker->newCaseImpersonate( $_POST['plugin_processmaker_process_id'], $writer) ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0 ) ) ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, 'GLPI_SELFSERVICE_CREATED' => '1') ) ;
|
||||
if ($resultCase->status_code == 0){
|
||||
// case is created
|
||||
// Must show it...
|
||||
@@ -106,11 +36,6 @@ switch( $_POST["action"] ) {
|
||||
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"]);
|
||||
|
||||
} 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");
|
||||
}
|
||||
@@ -131,7 +56,7 @@ switch( $_POST["action"] ) {
|
||||
}
|
||||
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( ) ;
|
||||
@@ -160,12 +85,12 @@ switch( $_POST["action"] ) {
|
||||
}
|
||||
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->login(true) ;
|
||||
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
|
||||
if( $resultPM->status_code == 0 ) {
|
||||
@@ -181,7 +106,7 @@ switch( $_POST["action"] ) {
|
||||
$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);
|
||||
@@ -198,4 +123,3 @@ switch( $_POST["action"] ) {
|
||||
// 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'] ) ;
|
||||
|
||||
|
||||
// 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,11 +46,11 @@ 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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +59,7 @@ if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
|
||||
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 +80,70 @@ 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() ;
|
||||
}
|
||||
|
||||
// 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 +152,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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
22
inc/db.class.php
Normal file
22
inc/db.class.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class PluginProcessmakerDB extends DBmysql {
|
||||
|
||||
var $dbhost ;
|
||||
|
||||
var $dbuser ;
|
||||
|
||||
var $dbpassword ;
|
||||
|
||||
var $dbdefault ;
|
||||
|
||||
function __construct() {
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
127
inc/task.class.php
Normal file
127
inc/task.class.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?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;
|
||||
//echo 'Test' ;
|
||||
$ret = array();
|
||||
$events = array() ;
|
||||
$params['begin'] = '2000-01-01 00:00:00';
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* tasks short summary.
|
||||
*
|
||||
* tasks description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerTasks 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 ;
|
||||
|
||||
$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 ;
|
||||
}
|
||||
}
|
||||
219
inc/user.class.php
Normal file
219
inc/user.class.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* user short summary.
|
||||
*
|
||||
* user description.
|
||||
*
|
||||
* @version 2.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerUser extends CommonDBTM {
|
||||
|
||||
|
||||
/**
|
||||
* Execute the query to select box with all glpi users where select key = name
|
||||
*
|
||||
* Internaly used by showGroup_Users, dropdownUsers and ajax/dropdownUsers.php
|
||||
*
|
||||
* @param $count true if execute an count(*),
|
||||
* @param $right limit user who have specific right
|
||||
* @param $entity_restrict Restrict to a defined entity
|
||||
* @param $value default value
|
||||
* @param $used Already used items ID: not to display in dropdown
|
||||
* @param $search pattern
|
||||
*
|
||||
* @return mysql result set.
|
||||
**/
|
||||
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
|
||||
$used=array(), $search='', $limit='') {
|
||||
global $DB, $PM_DB, $CFG_GLPI;
|
||||
|
||||
// first need to get all users from $taskId
|
||||
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
|
||||
$pmQuery = "SELECT group_user.USR_UID as pm_user_id FROM task_user
|
||||
JOIN group_user on group_user.GRP_UID=task_user.USR_UID AND task_user.TU_RELATION = 2 AND task_user.TU_TYPE=1
|
||||
WHERE TAS_UID = '$taskId'; " ;
|
||||
$pmUsers = array( ) ;
|
||||
foreach( $PM_DB->request( $pmQuery ) as $pmUser ) {
|
||||
$pmUsers[ ] = $pmUser[ 'pm_user_id' ] ;
|
||||
}
|
||||
|
||||
|
||||
$joinprofile = false;
|
||||
switch ($right) {
|
||||
|
||||
case "id" :
|
||||
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
|
||||
break;
|
||||
|
||||
case "all" :
|
||||
$where = " `glpi_users`.`id` > '1' " ;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') " ;
|
||||
// $where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND TAS_UID = '$taskId' " ;
|
||||
|
||||
$where .= " AND `glpi_users`.`is_deleted` = '0'
|
||||
AND `glpi_users`.`is_active` = '1' ";
|
||||
|
||||
if ((is_numeric($value) && $value)
|
||||
|| count($used)) {
|
||||
|
||||
$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
if (is_numeric($value)) {
|
||||
$first = false;
|
||||
$where .= $value;
|
||||
} else {
|
||||
$first = true;
|
||||
}
|
||||
foreach ($used as $val) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$where .= ",";
|
||||
}
|
||||
$where .= $val;
|
||||
}
|
||||
$where .= ")";
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
|
||||
} else {
|
||||
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
|
||||
}
|
||||
|
||||
$query .= "FROM glpi_plugin_processmaker_users
|
||||
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id " ;
|
||||
//$query .= "from wf_workflow.task_user
|
||||
// join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
|
||||
// join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
|
||||
// join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
|
||||
|
||||
$query .= " LEFT JOIN `glpi_useremails`
|
||||
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
|
||||
$query .= " LEFT JOIN `glpi_profiles_users`
|
||||
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
|
||||
|
||||
if ($joinprofile) {
|
||||
$query .= " LEFT JOIN `glpi_profiles`
|
||||
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query .= " WHERE $where ";
|
||||
} else {
|
||||
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
|
||||
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
|
||||
Search::makeTextSearch($search).")";
|
||||
}
|
||||
$query .= " WHERE $where ";
|
||||
|
||||
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
|
||||
$query.=" ORDER BY `glpi_users`.`firstname`,
|
||||
`glpi_users`.`realname`,
|
||||
`glpi_users`.`name` ";
|
||||
} else {
|
||||
$query.=" ORDER BY `glpi_users`.`realname`,
|
||||
`glpi_users`.`firstname`,
|
||||
`glpi_users`.`name` ";
|
||||
}
|
||||
|
||||
if ($search != $CFG_GLPI["ajax_wildcard"]) {
|
||||
$query .= " $limit";
|
||||
}
|
||||
}
|
||||
|
||||
return $DB->query($query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make a select box with all glpi users where select key = name
|
||||
*
|
||||
* Parameters which could be used in options array :
|
||||
* - name : string / name of the select (default is users_id)
|
||||
* - right : string / limit user who have specific right :
|
||||
* id -> only current user (default case);
|
||||
* interface -> central ;
|
||||
* all -> all users ;
|
||||
* specific right like show_all_ticket, create_ticket....
|
||||
* - comments : boolean / is the comments displayed near the dropdown (default true)
|
||||
* - entity : integer or array / restrict to a defined entity or array of entities
|
||||
* (default -1 : no restriction)
|
||||
* - entity_sons : boolean / if entity restrict specified auto select its sons
|
||||
* only available if entity is a single value not an array(default false)
|
||||
* - all : Nobody or All display for none selected
|
||||
* all=0 (default) -> Nobody
|
||||
* all=1 -> All
|
||||
* all=-1-> nothing
|
||||
* - rand : integer / already computed rand value
|
||||
* - toupdate : array / Update a specific item on select change on dropdown
|
||||
* (need value_fieldname, to_update, url (see Ajax::updateItemOnSelectEvent for informations)
|
||||
* and may have moreparams)
|
||||
* - used : array / Already used items ID: not to display in dropdown (default empty)
|
||||
* - on_change : string / value to transmit to "onChange"
|
||||
*
|
||||
* @param $options possible options
|
||||
*
|
||||
* @return int (print out an HTML select box)
|
||||
**/
|
||||
static function dropdown($options=array()) {
|
||||
global $CFG_GLPI ;
|
||||
|
||||
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php' ;
|
||||
return User::dropdown( $options ) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of getGLPIUserId
|
||||
* returns GLPI user ID from a Processmaker user ID
|
||||
* @param string $pmUserId
|
||||
* @return int, GLPI user id, or 0 if not found
|
||||
*/
|
||||
public static function getGLPIUserId( $pmUserId ){
|
||||
$obj = new self ;
|
||||
if( $obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'") ) {
|
||||
return $obj->fields['id'] ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getPMUserId
|
||||
* returns processmaker user id for given GLPI user id
|
||||
* @param int $glpi_userId id of user from GLPI database
|
||||
* @return string which is the uid of user in Processmaker database, or false if not found
|
||||
*/
|
||||
public static function getPMUserId( $glpiUserId ) {
|
||||
$obj = new self;
|
||||
if( $obj->getFromDB( Toolbox::cleanInteger($glpiUserId) ) ) {
|
||||
return $obj->fields['pm_users_id'] ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
///**
|
||||
// * Summary of getNewPassword
|
||||
// * @param mixed $username
|
||||
// * @return string a new password computed
|
||||
// * from uppercasing first letter of $username
|
||||
// * and encoding
|
||||
// * and adding a ramdon number (4 digits)
|
||||
// * and truncating it to a length of 20 chars
|
||||
// */
|
||||
//public static function getNewPassword( $username ) {
|
||||
// $newPass = Toolbox::encrypt( ucfirst( stripslashes( $username ) ), GLPIKEY) ;
|
||||
// return substr( rand(1000,9999).$newPass, 0, 19) ;
|
||||
//}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,18 @@
|
||||
|
||||
var oldHandler ;
|
||||
var submitButton ;
|
||||
function onClickContinue( obj ) {
|
||||
var submitButton;
|
||||
var caseIFrame;
|
||||
|
||||
function onClickContinue(obj) {
|
||||
//debugger;
|
||||
// call old handler
|
||||
if (obj != undefined && oldHandler)
|
||||
oldHandler(obj.target);
|
||||
submitButton.click() ;
|
||||
// hide the iFrame
|
||||
caseIFrame.style.visibility = 'hidden';
|
||||
|
||||
// call new handler
|
||||
submitButton.click();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +46,11 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
|
||||
var linkList = contentDocument.getElementsByTagName('a');
|
||||
if (txtAreaUseRequestSumUp != undefined) { // !bAreaUseRequestSumUp &&
|
||||
//bAreaUseRequestSumUp = true; // to prevent multiple adds
|
||||
Ext.select("textarea[name='content']").elements[0].value = txtAreaUseRequestSumUp.value;
|
||||
if (txtAreaUseRequestSumUp != undefined) {
|
||||
//debugger;
|
||||
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
|
||||
} else
|
||||
Ext.select("textarea[name='content']").elements[0].value = '_';
|
||||
$("textarea[name='content']")[0].value = '_';
|
||||
|
||||
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) {
|
||||
bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
|
||||
@@ -61,13 +68,13 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
buttonContinue.onclick = onClickContinue;
|
||||
|
||||
|
||||
submitButton = Ext.select("input[name='add'][type=submit]").elements[0];
|
||||
submitButton = $("input[name='add'][type=submit]")[0];
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_action' value='routecase'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseid' value='" + caseId + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
|
||||
|
||||
Ext.select("input[name='name'][type=text]").elements[0].value = processName;
|
||||
$("input[name='name'][type=text]")[0].value = processName;
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +82,7 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var locElt = contentDocument.getElementsByTagName("form")[0];
|
||||
var newHeight = (locElt.clientHeight < 100 ? 100 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
|
||||
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
|
||||
caseIFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user