2.4.1 initial commit
Previous releases can be found here: https://forge.glpi-project.org/projects/processmaker
This commit is contained in:
115
ajax/dropdownProcesses.php
Normal file
115
ajax/dropdownProcesses.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Olivier Moron
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/process.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (!isset($_POST['right'])) {
|
||||
$_POST['right'] = "all";
|
||||
}
|
||||
|
||||
// Default view : Nobody
|
||||
if (!isset($_POST['all'])) {
|
||||
$_POST['all'] = 0;
|
||||
}
|
||||
|
||||
$used = array();
|
||||
|
||||
if (isset($_POST['used'])) {
|
||||
if (is_array($_POST['used'])) {
|
||||
$used = $_POST['used'];
|
||||
} else {
|
||||
$used = unserialize(stripslashes($_POST['used']));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["entity_restrict"])
|
||||
&& !is_numeric($_POST["entity_restrict"])
|
||||
&& !is_array($_POST["entity_restrict"])) {
|
||||
|
||||
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
|
||||
}
|
||||
|
||||
$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"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
?>
|
||||
134
ajax/dropdownUsers.php
Normal file
134
ajax/dropdownUsers.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Olivier Moron
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownUsers.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (!isset($_POST['right'])) {
|
||||
$_POST['right'] = "all";
|
||||
}
|
||||
|
||||
// Default view : Nobody
|
||||
if (!isset($_POST['all'])) {
|
||||
$_POST['all'] = 0;
|
||||
}
|
||||
|
||||
$used = array();
|
||||
|
||||
if (isset($_POST['used'])) {
|
||||
if (is_array($_POST['used'])) {
|
||||
$used = $_POST['used'];
|
||||
} else {
|
||||
$used = unserialize(stripslashes($_POST['used']));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["entity_restrict"])
|
||||
&& !is_numeric($_POST["entity_restrict"])
|
||||
&& !is_array($_POST["entity_restrict"])) {
|
||||
|
||||
$_POST["entity_restrict"] = unserialize(stripslashes($_POST["entity_restrict"]));
|
||||
}
|
||||
|
||||
$result = PluginProcessmakerUsers::getSqlSearchResult( $_POST['pmTaskId'], false, $_POST['right'], $_POST["entity_restrict"],
|
||||
$_POST['value'], $used, $_POST['searchText']);
|
||||
|
||||
$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 ;
|
||||
|
||||
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"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dpuser_cmp')) {
|
||||
function dpuser_cmp($a, $b) {
|
||||
return strcasecmp($a, $b);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort non case sensitive
|
||||
uasort($users, 'dpuser_cmp');
|
||||
|
||||
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 = getUserName($_POST['value']);
|
||||
|
||||
if (!empty($output) && $output!=" ") {
|
||||
echo "<option selected value='".$_POST['value']."'>".$output."</option>";
|
||||
}
|
||||
}
|
||||
|
||||
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>";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Ajax::commonDropdownUpdateItem($_POST);
|
||||
?>
|
||||
81
ajax/task_resume.php
Normal file
81
ajax/task_resume.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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>
|
||||
" ;
|
||||
|
||||
50
ajax/task_users.php
Normal file
50
ajax/task_users.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Olivier Moron
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
|
||||
include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
$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 "<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']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$_REQUEST['caseId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$_REQUEST['delIndex']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_userId' value='".$_REQUEST['userId']."'>";
|
||||
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',
|
||||
'rand' => $rand,
|
||||
'pmTaskId' => $_REQUEST['taskId']));
|
||||
echo " ";
|
||||
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
|
||||
echo "</form>";
|
||||
|
||||
?>
|
||||
51
config/db_updates.txt
Normal file
51
config/db_updates.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `is_helpdeskvisible` TINYINT(1) NOT NULL DEFAULT '1' AFTER `trigger_guid`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `comment` TEXT NULL AFTER `is_helpdeskvisible`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_cases`
|
||||
ADD COLUMN `processes_id` VARCHAR(32) NULL AFTER `case_status`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_helpdeskvisible`,
|
||||
CHANGE COLUMN `comment` `comment` TEXT NULL AFTER `is_active`,
|
||||
ADD COLUMN `date_mod` DATETIME NULL DEFAULT NULL AFTER `comment`,
|
||||
DROP COLUMN `trigger_guid`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `taskcategories_id` INT(11) NULL AFTER `comment`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `taskcategories_id` INT(11) NULL AFTER `comment`;
|
||||
|
||||
CREATE TABLE `glpi_plugin_processmaker_taskcategories` (
|
||||
`id` INT(11) NOT NULL,
|
||||
`pm_task_guid` VARCHAR(32) NOT NULL,
|
||||
`processes_id` INT(11) NOT NULL
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_profiles`
|
||||
ADD COLUMN `profiles_id` INT(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_profiles (id)' AFTER `id`,
|
||||
DROP COLUMN `name`,
|
||||
DROP INDEX `name`,
|
||||
ADD INDEX `profiles_id` (`profiles_id`);
|
||||
ALTER TABLE `glpi_plugin_processmaker_profiles`
|
||||
CHANGE COLUMN `process` `process_config` CHAR(1) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci' AFTER `profiles_id`;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `hide_case_num_title` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_active`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `insert_task_comment` TINYINT(1) NOT NULL DEFAULT '0' AFTER `hide_case_num_title`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `users_id` INT(11) NULL DEFAULT NULL AFTER `taskcategories_id`;
|
||||
|
||||
ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `pm_group_guid` VARCHAR(32) NULL AFTER `users_id`;
|
||||
175
config/pm_db_config.sql
Normal file
175
config/pm_db_config.sql
Normal file
@@ -0,0 +1,175 @@
|
||||
|
||||
USE wf_workflow;
|
||||
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_DELETE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_DELETE` ;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APPLICATION_DELETE` AFTER DELETE ON `application` FOR EACH ROW BEGIN
|
||||
DECLARE loc_Ticket_id INT(11) ;
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=OLD.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=OLD.APP_UID ;
|
||||
END IF;
|
||||
END //
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_INSERT` AFTER INSERT ON `app_delay` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_cat_id, loc_Ticket_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_Ticket INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
DECLARE loc_pm_user_id VARCHAR(32) ;
|
||||
|
||||
IF NEW.APP_TYPE = 'PAUSE' THEN
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=NEW.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SET APP_TAS_TITLE = 'Case is paused';
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DELEGATION_USER LIMIT 1;
|
||||
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
INSERT INTO glpi.glpi_tickettasks
|
||||
( `tickets_id`, `taskcategories_id`, `date`, `users_id`, `content`, `is_private`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( loc_Ticket_id,
|
||||
loc_task_cat_id,
|
||||
Now(),
|
||||
1,
|
||||
CONCAT( 'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_Ticket_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>' ),
|
||||
0,
|
||||
0,
|
||||
NEW.APP_ENABLE_ACTION_DATE,
|
||||
NEW.APP_DISABLE_ACTION_DATE,
|
||||
1,
|
||||
loc_glpi_users_id);
|
||||
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (LAST_INSERT_ID(), NEW.APP_DELAY_UID, 0 );
|
||||
|
||||
END IF;
|
||||
END IF;
|
||||
END //
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_UPDATE` AFTER UPDATE ON `app_delay` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_DELAY_UID ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DISABLE_ACTION_USER LIMIT 1;
|
||||
|
||||
IF NEW.APP_DISABLE_ACTION_DATE IS NOT NULL THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`end`=NEW.APP_DISABLE_ACTION_DATE
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
END IF;
|
||||
END //
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_DELETE` AFTER DELETE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_Ticket_id, loc_tickettask_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tcase.ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase as glpi_pm_tcase WHERE glpi_pm_tcase.case_id=OLD.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettask_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=OLD.APP_UID AND glpi_pm_tasks.del_index=OLD.DEL_INDEX LIMIT 1;
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_tasks WHERE tickettasks_id = loc_tickettask_id ;
|
||||
DELETE FROM glpi.glpi_tickettasks WHERE id = loc_tickettask_id ;
|
||||
END IF;
|
||||
|
||||
END //
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_INSERT` AFTER INSERT ON `app_delegation` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_cat_id, loc_Ticket_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_Ticket INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=NEW.APP_UID;
|
||||
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SELECT CONTENT.CON_VALUE into APP_TAS_TITLE FROM CONTENT WHERE NEW.TAS_UID=CON_ID AND CON_CATEGORY='TAS_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
/* we must find a user linked to a group */ /* task is NEW.TAS_UID */
|
||||
select glpi.glpi_users.id INTO loc_glpi_users_id from task_user
|
||||
join content on content.CON_ID=task_user.USR_UID and content.CON_CATEGORY='GRP_TITLE'
|
||||
join glpi.glpi_users on glpi.glpi_users.name=content.CON_VALUE COLLATE utf8_unicode_ci
|
||||
where tas_uid=NEW.TAS_UID and tu_relation=2 ;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
INSERT INTO glpi.glpi_tickettasks
|
||||
( `tickets_id`, `taskcategories_id`, `date`, `users_id`, `content`, `is_private`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( loc_Ticket_id,
|
||||
loc_task_cat_id,
|
||||
Now(),
|
||||
1,
|
||||
CONCAT( 'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_Ticket_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>' ),
|
||||
0,
|
||||
0,
|
||||
NEW.DEL_DELEGATE_DATE,
|
||||
NEW.DEL_TASK_DUE_DATE,
|
||||
1,
|
||||
loc_glpi_users_id);
|
||||
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (LAST_INSERT_ID(), NEW.APP_UID, NEW.DEL_INDEX );
|
||||
|
||||
END IF;
|
||||
END //
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_UPDATE` AFTER UPDATE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_UID AND glpi_pm_tasks.del_index=NEW.DEL_INDEX ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
|
||||
IF NEW.DEL_THREAD_STATUS = 'CLOSED' THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`begin`=NEW.DEL_DELEGATE_DATE,
|
||||
`end`=NEW.DEL_FINISH_DATE
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
ELSE
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET users_id_tech=loc_glpi_users_id
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
END IF;
|
||||
END //
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
218
config/pm_db_install.mysql
Normal file
218
config/pm_db_install.mysql
Normal file
@@ -0,0 +1,218 @@
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_DELETE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_DELETE` ;
|
||||
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APPLICATION_DELETE` AFTER DELETE ON `application` FOR EACH ROW BEGIN
|
||||
DECLARE loc_item_id INT(11) ;
|
||||
SELECT items_id INTO loc_item_id FROM glpi.glpi_plugin_processmaker_cases WHERE case_id=OLD.APP_UID;
|
||||
IF loc_item_id IS NOT NULL THEN
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_cases WHERE case_id=OLD.APP_UID ;
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APPLICATION_UPDATE` AFTER UPDATE ON `application` FOR EACH ROW BEGIN
|
||||
DECLARE loc_item_id INT(11) ;
|
||||
SELECT items_id INTO loc_item_id FROM glpi.glpi_plugin_processmaker_cases WHERE case_id=NEW.APP_UID;
|
||||
IF loc_item_id IS NOT NULL THEN
|
||||
UPDATE glpi.glpi_plugin_processmaker_cases SET case_status=NEW.APP_STATUS WHERE case_id=NEW.APP_UID ;
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_INSERT` AFTER INSERT ON `app_delay` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_id, loc_task_cat_id, loc_item_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_item INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
DECLARE loc_pm_user_id, loc_item_type VARCHAR(32) ;
|
||||
DECLARE locDate DATETIME ;
|
||||
|
||||
IF NEW.APP_TYPE = 'PAUSE' THEN
|
||||
|
||||
SELECT items_id, itemtype INTO loc_item_id, loc_item_type FROM glpi.glpi_plugin_processmaker_cases WHERE case_id=NEW.APP_UID;
|
||||
|
||||
IF loc_item_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SET APP_TAS_TITLE = 'Task is paused';
|
||||
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DELEGATION_USER LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
SET locDate = Now() ;
|
||||
SET @table_name = CONCAT('glpi.glpi_', loc_item_type, 'tasks') ;
|
||||
SET @field_name = CONCAT( loc_item_type, 's_id' ) ;
|
||||
SET @query = CONCAT( 'INSERT INTO ', @table_name, '
|
||||
( `', @field_name, '`, `taskcategories_id`, `date`, `users_id`, `content`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( ',loc_item_id,',
|
||||
',loc_task_cat_id,',
|
||||
',locDate,',
|
||||
1,
|
||||
\'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_item_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>', '\',
|
||||
0,',
|
||||
NEW.APP_ENABLE_ACTION_DATE, ',',
|
||||
NEW.APP_DISABLE_ACTION_DATE, ',
|
||||
1,',
|
||||
loc_glpi_users_id,');') ;
|
||||
|
||||
SET loc_task_id = LAST_INSERT_ID();
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (loc_task_id, NEW.APP_DELAY_UID, 0 );
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( locDate, loc_task_id, 1, loc_glpi_users_id, 'INSERT');
|
||||
|
||||
END IF;
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_UPDATE` AFTER UPDATE ON `app_delay` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_DELAY_UID ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DISABLE_ACTION_USER LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
IF NEW.APP_DISABLE_ACTION_DATE IS NOT NULL THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`end`=NEW.APP_DISABLE_ACTION_DATE
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( Now(), loc_tickettasks_id, 1, loc_glpi_users_id, 'UPDATE');
|
||||
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_DELETE` AFTER DELETE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_Ticket_id, loc_tickettask_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tcase.ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_cases as glpi_pm_tcase WHERE glpi_pm_tcase.case_id=OLD.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettask_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=OLD.APP_UID AND glpi_pm_tasks.del_index=OLD.DEL_INDEX LIMIT 1;
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_tasks WHERE tickettasks_id = loc_tickettask_id ;
|
||||
DELETE FROM glpi.glpi_tickettasks WHERE id = loc_tickettask_id ;
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_INSERT` AFTER INSERT ON `app_delegation` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_id, loc_task_cat_id, loc_Ticket_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_Ticket INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
DECLARE locDate DATETIME ;
|
||||
/*DECLARE loc_pm_user_id VARCHAR(32) ;*/
|
||||
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_cases WHERE case_id=NEW.APP_UID;
|
||||
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SELECT CONTENT.CON_VALUE into APP_TAS_TITLE FROM CONTENT WHERE NEW.TAS_UID=CON_ID AND CON_CATEGORY='TAS_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
/* we must find a user linked to a group */ /* task is NEW.TAS_UID */
|
||||
select glpi.glpi_users.id INTO loc_glpi_users_id from task_user
|
||||
join content on content.CON_ID=task_user.USR_UID and content.CON_CATEGORY='GRP_TITLE' and CON_LANG = 'en'
|
||||
join glpi.glpi_users on glpi.glpi_users.name=content.CON_VALUE COLLATE utf8_unicode_ci
|
||||
where tas_uid=NEW.TAS_UID and tu_relation=2 LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
END IF;
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE LIMIT 1;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
SET locDate = Now() ;
|
||||
INSERT INTO glpi.glpi_tickettasks
|
||||
( `tickets_id`, `taskcategories_id`, `date`, `users_id`, `content`, `is_private`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( loc_Ticket_id,
|
||||
loc_task_cat_id,
|
||||
locDate,
|
||||
1,
|
||||
CONCAT( 'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_Ticket_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>' ),
|
||||
0,
|
||||
0,
|
||||
NEW.DEL_DELEGATE_DATE,
|
||||
NEW.DEL_TASK_DUE_DATE,
|
||||
1,
|
||||
loc_glpi_users_id);
|
||||
|
||||
SET loc_task_id = LAST_INSERT_ID();
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (loc_task_id, NEW.APP_UID, NEW.DEL_INDEX );
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( locDate, loc_task_id, 1, loc_glpi_users_id, 'INSERT');
|
||||
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_UPDATE` AFTER UPDATE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_UID AND glpi_pm_tasks.del_index=NEW.DEL_INDEX ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
IF NEW.DEL_THREAD_STATUS = 'CLOSED' THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`begin`=NEW.DEL_INIT_DATE,
|
||||
`end`=NEW.DEL_FINISH_DATE,
|
||||
`actiontime`= IFNULL(TIMESTAMPDIFF(SECOND,NEW.DEL_INIT_DATE,NEW.DEL_FINISH_DATE),0)
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
ELSE
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET users_id_tech=loc_glpi_users_id
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( Now(), loc_tickettasks_id, 1, loc_glpi_users_id, 'UPDATE');
|
||||
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
UPDATE glpi.glpi_plugin_processmaker_cases INNER JOIN wf_workflow.application on wf_workflow.application.APP_UID=glpi.glpi_plugin_processmaker_cases.case_id
|
||||
SET glpi.glpi_plugin_processmaker_cases.case_status=wf_workflow.application.APP_STATUS ;
|
||||
|
||||
|
||||
203
config/pm_db_install.sql
Normal file
203
config/pm_db_install.sql
Normal file
@@ -0,0 +1,203 @@
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_DELETE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_DELETE` ;
|
||||
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APPLICATION_DELETE` AFTER DELETE ON `application` FOR EACH ROW BEGIN
|
||||
DECLARE loc_Ticket_id INT(11) ;
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=OLD.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=OLD.APP_UID ;
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_INSERT` AFTER INSERT ON `app_delay` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_id, loc_task_cat_id, loc_Ticket_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_Ticket INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
DECLARE loc_pm_user_id VARCHAR(32) ;
|
||||
DECLARE locDate DATETIME ;
|
||||
|
||||
IF NEW.APP_TYPE = 'PAUSE' THEN
|
||||
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=NEW.APP_UID;
|
||||
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SET APP_TAS_TITLE = 'Task is paused';
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DELEGATION_USER LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
SET locDate = Now() ;
|
||||
INSERT INTO glpi.glpi_tickettasks
|
||||
( `tickets_id`, `taskcategories_id`, `date`, `users_id`, `content`, `is_private`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( loc_Ticket_id,
|
||||
loc_task_cat_id,
|
||||
locDate,
|
||||
1,
|
||||
CONCAT( 'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_Ticket_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>' ),
|
||||
0,
|
||||
0,
|
||||
NEW.APP_ENABLE_ACTION_DATE,
|
||||
NEW.APP_DISABLE_ACTION_DATE,
|
||||
1,
|
||||
loc_glpi_users_id);
|
||||
|
||||
SET loc_task_id = LAST_INSERT_ID();
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (loc_task_id, NEW.APP_DELAY_UID, 0 );
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( locDate, loc_task_id, 1, loc_glpi_users_id, 'INSERT');
|
||||
|
||||
END IF;
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELAY_UPDATE` AFTER UPDATE ON `app_delay` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_DELAY_UID ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.APP_DISABLE_ACTION_USER LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
IF NEW.APP_DISABLE_ACTION_DATE IS NOT NULL THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`end`=NEW.APP_DISABLE_ACTION_DATE
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( Now(), loc_tickettasks_id, 1, loc_glpi_users_id, 'UPDATE');
|
||||
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_DELETE` AFTER DELETE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_Ticket_id, loc_tickettask_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tcase.ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase as glpi_pm_tcase WHERE glpi_pm_tcase.case_id=OLD.APP_UID;
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettask_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=OLD.APP_UID AND glpi_pm_tasks.del_index=OLD.DEL_INDEX LIMIT 1;
|
||||
DELETE FROM glpi.glpi_plugin_processmaker_tasks WHERE tickettasks_id = loc_tickettask_id ;
|
||||
DELETE FROM glpi.glpi_tickettasks WHERE id = loc_tickettask_id ;
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_INSERT` AFTER INSERT ON `app_delegation` FOR EACH ROW BEGIN
|
||||
DECLARE loc_task_id, loc_task_cat_id, loc_Ticket_id, loc_Found_Pos, loc_glpi_users_id, loc_Count_Ticket INT(11) ;
|
||||
DECLARE APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE VARCHAR(255);
|
||||
DECLARE locDate DATETIME ;
|
||||
/*DECLARE loc_pm_user_id VARCHAR(32) ;*/
|
||||
|
||||
SELECT ticket_id INTO loc_Ticket_id FROM glpi.glpi_plugin_processmaker_ticketcase WHERE case_id=NEW.APP_UID;
|
||||
|
||||
IF loc_Ticket_id IS NOT NULL THEN
|
||||
|
||||
SELECT CONTENT.CON_VALUE into APP_TITLE FROM CONTENT WHERE NEW.APP_UID=CON_ID AND CON_CATEGORY='APP_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
IF APP_TITLE IS NULL THEN
|
||||
SET APP_TITLE = '';
|
||||
END IF;
|
||||
SELECT CONTENT.CON_VALUE into APP_PRO_TITLE FROM CONTENT WHERE NEW.PRO_UID=CON_ID AND CON_CATEGORY='PRO_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
SELECT CONTENT.CON_VALUE into APP_TAS_TITLE FROM CONTENT WHERE NEW.TAS_UID=CON_ID AND CON_CATEGORY='TAS_TITLE' and CON_LANG = 'en' LIMIT 1;
|
||||
|
||||
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
/* we must find a user linked to a group */ /* task is NEW.TAS_UID */
|
||||
select glpi.glpi_users.id INTO loc_glpi_users_id from task_user
|
||||
join content on content.CON_ID=task_user.USR_UID and content.CON_CATEGORY='GRP_TITLE' and CON_LANG = 'en'
|
||||
join glpi.glpi_users on glpi.glpi_users.name=content.CON_VALUE COLLATE utf8_unicode_ci
|
||||
where tas_uid=NEW.TAS_UID and tu_relation=2 LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
END IF;
|
||||
SELECT id INTO loc_task_cat_id FROM glpi.glpi_taskcategories WHERE name=APP_PRO_TITLE LIMIT 1;
|
||||
IF loc_task_cat_id IS NULL THEN
|
||||
SET loc_task_cat_id=0 ;
|
||||
END IF ;
|
||||
|
||||
SET locDate = Now() ;
|
||||
INSERT INTO glpi.glpi_tickettasks
|
||||
( `tickets_id`, `taskcategories_id`, `date`, `users_id`, `content`, `is_private`, `actiontime`, `begin`, `end`, `state`, `users_id_tech`)
|
||||
VALUES ( loc_Ticket_id,
|
||||
loc_task_cat_id,
|
||||
locDate,
|
||||
1,
|
||||
CONCAT( 'Bound to process: ', APP_PRO_TITLE, ',<br/>case title: ', APP_TITLE, ',<br/>task: ', APP_TAS_TITLE,'.<br/><a href="?id=', loc_Ticket_id, '&forcetab=processmaker_1">Go to Case tab to manage!</a>' ),
|
||||
0,
|
||||
0,
|
||||
NEW.DEL_DELEGATE_DATE,
|
||||
NEW.DEL_TASK_DUE_DATE,
|
||||
1,
|
||||
loc_glpi_users_id);
|
||||
|
||||
SET loc_task_id = LAST_INSERT_ID();
|
||||
INSERT INTO glpi.glpi_plugin_processmaker_tasks (`tickettasks_id`, `case_id`, `del_index`) VALUES (loc_task_id, NEW.APP_UID, NEW.DEL_INDEX );
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( locDate, loc_task_id, 1, loc_glpi_users_id, 'INSERT');
|
||||
|
||||
END IF;
|
||||
END ;
|
||||
|
||||
|
||||
CREATE DEFINER=CURRENT_USER TRIGGER `GLPI_APP_DELEGATION_UPDATE` AFTER UPDATE ON `app_delegation` FOR EACH ROW BEGIN
|
||||
|
||||
DECLARE loc_tickettasks_id, loc_Count_Task INT(11) ;
|
||||
DECLARE loc_glpi_users_id INT(11) ;
|
||||
|
||||
SELECT glpi_pm_tasks.tickettasks_id INTO loc_tickettasks_id FROM glpi.glpi_plugin_processmaker_tasks as glpi_pm_tasks WHERE glpi_pm_tasks.case_id=NEW.APP_UID AND glpi_pm_tasks.del_index=NEW.DEL_INDEX ;
|
||||
IF loc_tickettasks_id IS NOT NULL THEN
|
||||
SELECT glpi_users_id INTO loc_glpi_users_id FROM glpi.glpi_plugin_processmaker_users WHERE pm_users_id=NEW.USR_UID LIMIT 1;
|
||||
IF loc_glpi_users_id IS NULL THEN
|
||||
SET loc_glpi_users_id = 2 ;
|
||||
END IF ;
|
||||
|
||||
IF NEW.DEL_THREAD_STATUS = 'CLOSED' THEN
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET state=2,
|
||||
`begin`=NEW.DEL_INIT_DATE,
|
||||
`end`=NEW.DEL_FINISH_DATE,
|
||||
`actiontime`= IFNULL(TIMESTAMPDIFF(SECOND,NEW.DEL_INIT_DATE,NEW.DEL_FINISH_DATE),0)
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
ELSE
|
||||
UPDATE glpi.glpi_tickettasks
|
||||
SET users_id_tech=loc_glpi_users_id
|
||||
WHERE id=loc_tickettasks_id ;
|
||||
END IF ;
|
||||
|
||||
REPLACE INTO glpi.glpi_plugin_processmaker_tasksnotifications (`date`, `task_id`, `user_id`, `tech_id`, `action`) VALUES ( Now(), loc_tickettasks_id, 1, loc_glpi_users_id, 'UPDATE');
|
||||
|
||||
END IF;
|
||||
|
||||
END ;
|
||||
|
||||
|
||||
7
config/pm_db_uninstall.mysql
Normal file
7
config/pm_db_uninstall.mysql
Normal file
@@ -0,0 +1,7 @@
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_DELETE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_DELETE` ;
|
||||
6
config/pm_db_uninstall.sql
Normal file
6
config/pm_db_uninstall.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
DROP TRIGGER IF EXISTS `GLPI_APPLICATION_DELETE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELAY_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_INSERT` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_UPDATE` ;
|
||||
DROP TRIGGER IF EXISTS `GLPI_APP_DELEGATION_DELETE` ;
|
||||
86
front/cases.front.php
Normal file
86
front/cases.front.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include_once '../inc/processmaker.class.php' ;
|
||||
include_once '../inc/cases.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 ;
|
||||
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'] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 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>" ;
|
||||
|
||||
|
||||
?>
|
||||
23
front/config.form.php
Normal file
23
front/config.form.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
*/
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT . "/inc/includes.php");
|
||||
|
||||
// No autoload when plugin is not activated
|
||||
require_once('../inc/config.class.php');
|
||||
|
||||
$config = new PluginProcessmakerConfig();
|
||||
if (isset($_POST["update"])) {
|
||||
$config->check($_POST['id'],'w');
|
||||
|
||||
$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'));
|
||||
33
front/process.form.php
Normal file
33
front/process.form.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
|
||||
Plugin::load('processmaker',true);
|
||||
|
||||
if (!isset($_REQUEST["id"])) {
|
||||
$_REQUEST["id"] = "";
|
||||
}
|
||||
|
||||
$PluginProcess = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_REQUEST["update"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], 'w');
|
||||
$PluginProcess->update($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} elseif (isset($_REQUEST["refreshtask"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], 'w');
|
||||
$PluginProcess->refreshTasks($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} else {
|
||||
$PluginProcess->checkGlobal('r');
|
||||
|
||||
Html::header($LANG['processmaker']['title'][1],$_SERVER["PHP_SELF"],"plugins","processmaker");
|
||||
|
||||
$PluginProcess->showForm($_REQUEST["id"]);
|
||||
|
||||
Html::footer();
|
||||
}
|
||||
?>
|
||||
25
front/process.php
Normal file
25
front/process.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
define('GLPI_ROOT', '../../..');
|
||||
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")) {
|
||||
$process=new PluginProcessmakerProcess();
|
||||
|
||||
if( isset( $_REQUEST['refresh'] ) && plugin_processmaker_haveRight("process_config","w") ) {
|
||||
$process->refresh();
|
||||
Html::back();
|
||||
}
|
||||
|
||||
$process->title();
|
||||
|
||||
Search::show('PluginProcessmakerProcess');
|
||||
|
||||
} else {
|
||||
Html::displayRightError();
|
||||
}
|
||||
Html::footer();
|
||||
|
||||
?>
|
||||
42
front/process_profile.form.php
Normal file
42
front/process_profile.form.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
|
||||
Session::checkCentralAccess();
|
||||
|
||||
$profile = new Profile();
|
||||
$right = new PluginProcessmakerProcess_Profile();
|
||||
$process = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_POST["add"])) {
|
||||
|
||||
$right->check(-1,'w',$_POST);
|
||||
if ($right->add($_POST)) {
|
||||
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
|
||||
}
|
||||
Html::back();
|
||||
|
||||
} else if (isset($_POST["delete"])) {
|
||||
|
||||
if (isset($_POST["item"]) && count($_POST["item"])) {
|
||||
foreach ($_POST["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
if ($right->can($key,'w')) {
|
||||
$right->delete(array('id' => $key));
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (isset($_POST["processes_id"])) {
|
||||
// Event::log($_POST["processes_id"], "users", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
|
||||
// }
|
||||
}
|
||||
Html::back();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Html::displayErrorAndDie("lost");
|
||||
?>
|
||||
201
front/processmaker.form.php
Normal file
201
front/processmaker.form.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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' ;
|
||||
|
||||
switch( $_POST["action"] ) {
|
||||
case 'newcase':
|
||||
if( isset($_POST['id']) && $_POST['id'] > 0 ) { // then this case will be bound to an item
|
||||
// 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) {
|
||||
$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']
|
||||
) ) ;
|
||||
|
||||
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
|
||||
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" ;
|
||||
$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
|
||||
// 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"]);
|
||||
|
||||
} 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;
|
||||
|
||||
case 'unpausecase_or_reassign_or_delete' :
|
||||
if( isset( $_POST['unpause'] ) ) {
|
||||
$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
|
||||
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'] ) ;
|
||||
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 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'] ) ;
|
||||
$newDelIndex = 0 ;
|
||||
foreach( $newCaseInfo->currentUsers as $newCaseUser ){
|
||||
if( $newCaseUser->taskId == $_POST['plugin_processmaker_taskId'] && $newCaseUser->delThread == $_POST['plugin_processmaker_delThread'] ) {
|
||||
$newDelIndex = $newCaseUser->delIndex ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] ) ;
|
||||
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']['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->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->deleteCase() ) {
|
||||
// request delete from pm itself
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
|
||||
if( $resultPM->status_code == 0 ) {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
} else
|
||||
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'] ) ;
|
||||
if( $resultPM->status_code === 0 ) {
|
||||
$locCase = new PluginProcessmakerCases ;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->cancelCase() )
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// to return to ticket
|
||||
Html::back();
|
||||
|
||||
?>
|
||||
509
front/processmaker.helpdesk.form.php
Normal file
509
front/processmaker.helpdesk.form.php
Normal file
File diff suppressed because it is too large
Load Diff
15
front/profile.form.php
Normal file
15
front/profile.form.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?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();
|
||||
}
|
||||
?>
|
||||
109
front/tracking.injector.php
Normal file
109
front/tracking.injector.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if( !defined('GLPI_ROOT' ) ) {
|
||||
define('GLPI_ROOT', '../../..');
|
||||
}
|
||||
include_once (GLPI_ROOT . "/inc/includes.php");
|
||||
|
||||
if (empty($_POST["_type"])
|
||||
|| ($_POST["_type"] != "Helpdesk")
|
||||
|| !$CFG_GLPI["use_anonymous_helpdesk"]) {
|
||||
Session::checkRight("create_ticket", "1");
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (empty($_POST) || count($_POST) == 0) {
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php");
|
||||
}
|
||||
|
||||
// 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
|
||||
&& 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 ) {
|
||||
$_POST['action']='newcase';
|
||||
$_POST['plugin_processmaker_process_id'] = $processList[0]['id'];
|
||||
include (GLPI_ROOT . "/plugins/processmaker/front/processmaker.form.php");
|
||||
die() ;
|
||||
} elseif( $processQt > 1 ) {
|
||||
// in this case we should show the process dropdown selection
|
||||
include (GLPI_ROOT . "/plugins/processmaker/front/processmaker.helpdesk.form.php");
|
||||
die() ;
|
||||
} else{
|
||||
// in this case should start RUMT
|
||||
// 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 ;
|
||||
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('http_formdata_flat_hierarchy') ) {
|
||||
/**
|
||||
* Summary of http_formdata_flat_hierarchy
|
||||
* @param mixed $data
|
||||
* @return array
|
||||
*/
|
||||
function http_formdata_flat_hierarchy($data) {
|
||||
$vars=array();
|
||||
foreach($data as $key=>$value) {
|
||||
if(is_array($value)) {
|
||||
$temp = array() ;
|
||||
foreach($value as $k2 => $val2){
|
||||
$temp[ $key.'['.$k2.']' ] = $val2 ;
|
||||
}
|
||||
$vars = array_merge( $vars, http_formdata_flat_hierarchy($temp) );
|
||||
}
|
||||
else {
|
||||
$vars[$key]=$value;
|
||||
}
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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" ) ;
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
$data = http_formdata_flat_hierarchy( $_REQUEST ) ;
|
||||
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");
|
||||
|
||||
// as sessions in PHP are not re-entrant, we MUST close current one before curl_exec
|
||||
@session_write_close() ;
|
||||
|
||||
curl_exec ($ch);
|
||||
|
||||
curl_close ($ch);
|
||||
|
||||
32
importUsersGLPI2PM.php
Normal file
32
importUsersGLPI2PM.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* */
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Olivier Moron
|
||||
// Purpose of file: script to be used to purge logos from DB
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Ensure current directory as run command prompt
|
||||
chdir(dirname($_SERVER["SCRIPT_FILENAME"]));
|
||||
|
||||
define('DO_NOT_CHECK_HTTP_REFERER', 1);
|
||||
define('GLPI_ROOT', '../..');
|
||||
include (GLPI_ROOT . "/inc/includes.php");
|
||||
include_once 'inc/processmaker.class.php' ;
|
||||
|
||||
$myCronTask = new CronTask;
|
||||
|
||||
if( $myCronTask->getFromDBbyName( "PluginProcessmakerProcessmaker", "pmusers" ) ) {
|
||||
$myCronTask->start();
|
||||
|
||||
$ret = PluginProcessmakerProcessmaker::cronPMUsers( $myCronTask ) ;
|
||||
|
||||
$myCronTask->end( $ret ) ;
|
||||
} else
|
||||
echo "Cron not found!\n" ;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
14
inc/case.class.php
Normal file
14
inc/case.class.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* case short summary.
|
||||
*
|
||||
* case description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerCase extends CommonDBTM {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
713
inc/cases.class.php
Normal file
713
inc/cases.class.php
Normal file
File diff suppressed because it is too large
Load Diff
208
inc/config.class.php
Normal file
208
inc/config.class.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
*/
|
||||
|
||||
class PluginProcessmakerConfig extends CommonDBTM {
|
||||
|
||||
static private $_instance = NULL;
|
||||
|
||||
function canCreate() {
|
||||
return Session::haveRight('config', 'w');
|
||||
}
|
||||
|
||||
function canView() {
|
||||
return Session::haveRight('config', 'r');
|
||||
}
|
||||
|
||||
static function getTypeName() {
|
||||
global $LANG;
|
||||
|
||||
return $LANG['common'][12];
|
||||
}
|
||||
|
||||
function getName($with_comment=0) {
|
||||
global $LANG;
|
||||
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton for the unique config record
|
||||
*/
|
||||
static function getInstance() {
|
||||
|
||||
if (!isset(self::$_instance)) {
|
||||
self::$_instance = new self();
|
||||
if (!self::$_instance->getFromDB(1)) {
|
||||
self::$_instance->getEmpty();
|
||||
}
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
//static function install(Migration $mig) {
|
||||
// global $DB, $LANG;
|
||||
|
||||
// $table = 'glpi_plugin_behaviors_configs';
|
||||
// if (!TableExists($table)) { //not installed
|
||||
|
||||
// $query = "CREATE TABLE `$table` (
|
||||
// `id` int(11) NOT NULL,
|
||||
// `use_requester_item_group` tinyint(1) NOT NULL default '0',
|
||||
// `use_requester_user_group` tinyint(1) NOT NULL default '0',
|
||||
// `is_ticketsolutiontype_mandatory` tinyint(1) NOT NULL default '0',
|
||||
// `is_ticketrealtime_mandatory` tinyint(1) NOT NULL default '0',
|
||||
// `is_requester_mandatory` tinyint(1) NOT NULL default '0',
|
||||
// `is_ticketdate_locked` tinyint(1) NOT NULL default '0',
|
||||
// `use_assign_user_group` tinyint(1) NOT NULL default '0',
|
||||
// `tickets_id_format` VARCHAR(15) NULL,
|
||||
// `remove_from_ocs` tinyint(1) NOT NULL default '0',
|
||||
// `add_notif` tinyint(1) NOT NULL default '0',
|
||||
// `use_lock` tinyint(1) NOT NULL default '0',
|
||||
// `date_mod` datetime default NULL,
|
||||
// `comment` text,
|
||||
// PRIMARY KEY (`id`)
|
||||
// ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
||||
// $DB->query($query) or die($LANG['update'][90] . " :<br>" . $DB->error());
|
||||
|
||||
// $query = "INSERT INTO `$table` (id, date_mod) VALUES (1, NOW())";
|
||||
// $DB->query($query) or die($LANG['update'][90] . " :<br>" . $DB->error());
|
||||
|
||||
// } else {
|
||||
// // Upgrade
|
||||
|
||||
// $mig->addField($table, 'tickets_id_format', 'string');
|
||||
// $mig->addField($table, 'remove_from_ocs', 'bool');
|
||||
// $mig->addField($table, 'is_requester_mandatory', 'bool');
|
||||
|
||||
// // version 0.78.0 - feature #2801 Forbid change of ticket's creation date
|
||||
// $mig->addField($table, 'is_ticketdate_locked', 'bool');
|
||||
|
||||
// // Version 0.80.0 - set_use_date_on_state now handle in GLPI
|
||||
// $mig->dropField($table, 'set_use_date_on_state');
|
||||
|
||||
// // Version 0.80.4 - feature #3171 additional notifications
|
||||
// $mig->addField($table, 'add_notif', 'bool');
|
||||
|
||||
// // Version 0.83.0 - groups now have is_requester and is_assign attribute
|
||||
// $mig->dropField($table, 'sql_user_group_filter');
|
||||
// $mig->dropField($table, 'sql_tech_group_filter');
|
||||
|
||||
// // Version 0.83.1 - prevent update on ticket updated by another user
|
||||
// $mig->addField($table, 'use_lock', 'bool');
|
||||
|
||||
// }
|
||||
|
||||
// return true;
|
||||
//}
|
||||
|
||||
//static function uninstall() {
|
||||
// global $DB;
|
||||
|
||||
// if (TableExists('glpi_plugin_behaviors_configs')) { //not installed
|
||||
|
||||
// $query = "DROP TABLE `glpi_plugin_behaviors_configs`";
|
||||
// $DB->query($query) or die($DB->error());
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
static function showConfigForm($item) {
|
||||
global $LANG, $DB;
|
||||
|
||||
|
||||
$ui_theme = array(
|
||||
'classic' => 'classic',
|
||||
'neoclassic' => 'neoclassic',
|
||||
'uxmodern' => 'uxmodern' ,
|
||||
'uxs' => 'uxs'
|
||||
);
|
||||
|
||||
$config = self::getInstance();
|
||||
|
||||
$config->showFormHeader();
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['name']." :</td><td>";
|
||||
echo $config->fields['name'];
|
||||
echo "</td><td colspan='2' class='center'>".$LANG['processmaker']['config']['comments']." :";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['URL']." :</td><td>";
|
||||
echo "<input type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>" ;
|
||||
echo "</td><td rowspan='5' colspan='2' class='center'>";
|
||||
echo "<textarea cols='60' rows='8' name='comment' >".$config->fields['comment']."</textarea>";
|
||||
echo "<br>".$LANG['common'][26]." : ";
|
||||
echo Html::convDateTime($config->fields["date_mod"]);
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['workspace']." :</td><td>";
|
||||
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>" ;
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['theme']." :</td><td>";
|
||||
Dropdown::showFromArray('pm_theme', $ui_theme,
|
||||
array('value' => $config->fields['pm_theme']));
|
||||
echo "</td></tr>";
|
||||
|
||||
$taskCatogrie = new TaskCategory;
|
||||
$taskCatogrie->getFromDB( $config->fields['taskcategories_id'] ) ;
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['main_task_category']." :</td><td>";
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=". $config->fields['taskcategories_id']."'>".str_replace(" ", " ", $taskCatogrie->fields['name']);
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$config->fields['taskcategories_id'].")";
|
||||
}
|
||||
echo "</a>" ;
|
||||
echo "</td></tr>\n";
|
||||
|
||||
$taskUser = new User;
|
||||
$taskUser->getFromDB( $config->fields['users_id'] ) ;
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['taskwriter']." :</td><td>";
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL( 'User' )."?id=". $config->fields['users_id']."'>".str_replace(" ", " ", $taskUser->getName());
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$config->fields['users_id'].")";
|
||||
}
|
||||
echo "</a>" ;
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>".$LANG['processmaker']['config']['pm_group_name']." :</td><td>";
|
||||
$query = "SELECT * FROM wf_".$config->fields['pm_workspace'].".content WHERE CON_CATEGORY='GRP_TITLE' and CON_ID='".$config->fields['pm_group_guid']."' ;" ;
|
||||
echo "<table>";
|
||||
foreach( $DB->request( $query ) as $row ) {
|
||||
echo "<tr><td>".$row['CON_LANG']."</td><td>".$row['CON_VALUE']."</td>";
|
||||
}
|
||||
echo "</table>" ;
|
||||
echo "</td></tr>\n";
|
||||
|
||||
|
||||
$config->showFormButtons(array('candel'=>false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
|
||||
if ($item->getType()=='Config') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
if ($item->getType()=='Config') {
|
||||
self::showConfigForm($item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
767
inc/process.class.php
Normal file
767
inc/process.class.php
Normal file
File diff suppressed because it is too large
Load Diff
124
inc/process_profile.class.php
Normal file
124
inc/process_profile.class.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* process_profile short summary.
|
||||
*
|
||||
* process_profile description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
{
|
||||
function can($ID, $right, &$input = NULL) {
|
||||
return plugin_processmaker_haveRight('process_config', $right) ;
|
||||
}
|
||||
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][4];
|
||||
}
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
global $DB,$CFG_GLPI, $LANG;
|
||||
|
||||
$ID = $item->getField('id');
|
||||
|
||||
$canshowentity = Session::haveRight("entity","r");
|
||||
$canedit = plugin_processmaker_haveRight('process_config', 'w') ;
|
||||
|
||||
$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 "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr class='tab_bg_1'><th colspan='4'>".$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]." : ";
|
||||
Profile::dropdownUnder(array('value' => Profile::getDefault()));
|
||||
echo "</td><td class='center'>".$LANG['profiles'][28]." : ";
|
||||
Dropdown::showYesNo("is_recursive",0);
|
||||
echo "</td><td class='center'>";
|
||||
echo "<input type='submit' name='add' value=\"".$LANG['buttons'][8]."\" class='submit'>";
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</table></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`,
|
||||
`glpi_plugin_processmaker_processes_profiles`.`is_recursive`,
|
||||
`glpi_entities`.`completename`,
|
||||
`glpi_plugin_processmaker_processes_profiles`.`entities_id`
|
||||
FROM `glpi_plugin_processmaker_processes_profiles`
|
||||
LEFT JOIN `glpi_profiles`
|
||||
ON (`glpi_plugin_processmaker_processes_profiles`.`profiles_id` = `glpi_profiles`.`id`)
|
||||
LEFT JOIN `glpi_entities`
|
||||
ON (`glpi_plugin_processmaker_processes_profiles`.`entities_id` = `glpi_entities`.`id`)
|
||||
WHERE `glpi_plugin_processmaker_processes_profiles`.`processes_id` = '$ID'
|
||||
ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
|
||||
$result = $DB->query($query);
|
||||
|
||||
if ($DB->numrows($result) >0) {
|
||||
while ($data = $DB->fetch_array($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];
|
||||
}
|
||||
echo "<td>";
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".$data["entities_id"]."'>";
|
||||
}
|
||||
echo $data["completename"].
|
||||
($_SESSION["glpiis_ids_visible"]?" (".$data["entities_id"].")":"");
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td>".$data["name"];
|
||||
|
||||
if ($data["is_recursive"]) {
|
||||
echo "<span class='b'> (";
|
||||
echo "R";
|
||||
echo ")</span>";
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
if ($canedit) {
|
||||
Html::openArrowMassives("entityprocess_form$rand",true);
|
||||
Html::closeArrowMassives(array('delete' => $LANG['buttons'][6]));
|
||||
}
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
1905
inc/processmaker.class.php
Normal file
1905
inc/processmaker.class.php
Normal file
File diff suppressed because it is too large
Load Diff
190
inc/processmakerconfig.class.php
Normal file
190
inc/processmakerconfig.class.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
/**
|
||||
* This class manages the mail settings
|
||||
*/
|
||||
class ProcessmakerConfig extends CommonDBTM {
|
||||
|
||||
var $table = 'glpi_plugins_processmaker_config';
|
||||
|
||||
|
||||
static function getTypeName() {
|
||||
global $LANG;
|
||||
|
||||
return 'Process Maker Plugin Configuration';
|
||||
}
|
||||
|
||||
|
||||
function defineTabs($options=array()) {
|
||||
|
||||
$ong = array();
|
||||
$this->addStandardTab(__CLASS__, $ong, $options);
|
||||
|
||||
return $ong;
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
switch ($item->getType()) {
|
||||
case __CLASS__ :
|
||||
$tabs[1] = $LANG['common'][12];
|
||||
return $tabs;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if($item->getType() == __CLASS__) {
|
||||
switch ($tabnum) {
|
||||
case 1 :
|
||||
$item->showFormMailServerConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print the mailing config form
|
||||
*
|
||||
* @param $ID integer ID of the item
|
||||
* @param $options array
|
||||
* - target filename : where to go when done.
|
||||
* - tabs integer : ID of the tab to display
|
||||
*
|
||||
* @return Nothing (display)
|
||||
*
|
||||
**/
|
||||
function showForm($ID, $options=array()) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
if (!Session::haveRight("config", "w")) {
|
||||
return false;
|
||||
}
|
||||
if (!$CFG_GLPI['use_mailing']) {
|
||||
$options['colspan'] = 1;
|
||||
}
|
||||
|
||||
$this->getFromDB($ID);
|
||||
$this->showTabs($options);
|
||||
$this->addDivForTabs();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function canCreate() {
|
||||
return Session::haveRight('config', 'w');
|
||||
}
|
||||
|
||||
|
||||
function canView() {
|
||||
return Session::haveRight('config', 'r');
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
143
inc/profile.class.php
Normal file
143
inc/profile.class.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
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()) {
|
||||
global $LANG;
|
||||
|
||||
$target = $this->getFormURL();
|
||||
if (isset($options['target'])) {
|
||||
$target = $options['target'];
|
||||
}
|
||||
|
||||
if (!Session::haveRight("profile","r")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$canedit = Session::haveRight("profile", "w");
|
||||
$prof = new Profile();
|
||||
if ($ID) {
|
||||
$this->getFromDBByProfile($ID);
|
||||
$prof->getFromDB($ID);
|
||||
}
|
||||
echo "<form action='".$target."' method='post'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
|
||||
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;
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static function createAdminAccess($ID) {
|
||||
|
||||
$myProf = new self();
|
||||
if (!$myProf->getFromDBByProfile($ID)) {
|
||||
|
||||
$myProf->add(array(
|
||||
'profiles_id' => $ID,
|
||||
'process_config' => 'w'
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createUserAccess($Profile) {
|
||||
|
||||
return $this->add(array('profiles_id' => $Profile->getID()
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
|
||||
if ($item->getType()=='Profile') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
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)) {
|
||||
$prof->showForm($ID);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
116
inc/taskcategory.class.php
Normal file
116
inc/taskcategory.class.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerTaskCategory short summary.
|
||||
*
|
||||
* PluginProcessmakerTaskCategory description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
{
|
||||
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][3];
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
global $LANG, $DB ;
|
||||
|
||||
self::title($item) ;
|
||||
|
||||
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
||||
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
|
||||
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th></tr>";
|
||||
|
||||
$query = "select pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment` from glpi_plugin_processmaker_taskcategories as pm
|
||||
left join glpi_taskcategories as gl on pm.taskcategories_id=gl.id
|
||||
where pm.processes_id=".$item->getID().";" ;
|
||||
|
||||
foreach ($DB->request($query) as $taskCat) {
|
||||
echo "<tr class='tab_bg_1'><td class='b'><a href='".
|
||||
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
|
||||
$taskCat['taskcategories_id']."'>".str_replace(" ", " ", $taskCat['name']);
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$taskCat['taskcategories_id'].")";
|
||||
}
|
||||
echo "</a></td><td >".str_replace(" ", " ", $taskCat['completename'])."</td>
|
||||
<td >".$taskCat['pm_task_guid']."</td>".
|
||||
"<td>".($taskCat['start']?'x':'')."</td><td >".
|
||||
$taskCat['comment']."</td></tr>";
|
||||
}
|
||||
echo "</table></div>";
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a good title for task categories tab
|
||||
* add button for re-synchro of taskcategory list (only if rigths are w)
|
||||
* @return nothing (display)
|
||||
**/
|
||||
static function title(CommonGLPI $item) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
$buttons = array();
|
||||
$title = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
|
||||
if (plugin_processmaker_haveRight('process_config', 'w')) {
|
||||
$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,
|
||||
$buttons);
|
||||
}
|
||||
}
|
||||
|
||||
function getLinkItemFromExternalID($extId) {
|
||||
if( $this->getFromDBbyExternalID( $extId ) ) {
|
||||
$taskcat = new TaskCategory ;
|
||||
return $taskcat->getFromDB( $this->fields['items_id'] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a TaskCat from the database using its external id (unique index): pm_task_guid
|
||||
*
|
||||
* @param $extid string externalid
|
||||
*
|
||||
* @return true if succeed else false
|
||||
**/
|
||||
function getFromDBbyExternalID($extid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `pm_task_guid` = '$extid'";
|
||||
|
||||
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