3
0

Simplified tracking.injector.php file

Changed all PM table names to uppercase in queries (to be compliant with table names in PM DB)
Fixed a lot of CS issues
Deleted obsolete comments
Deleted config folder
Changed version to 3.1.3

Fixes #8
Fixes #13
Fixes #14
This commit is contained in:
tomolimo
2017-05-06 18:38:24 +02:00
parent 72d9aefdcf
commit a499665e77
35 changed files with 4261 additions and 6155 deletions

View File

@@ -12,24 +12,14 @@ if (!defined('GLPI_ROOT')) {
die("Can not access directly to this file");
}
//include_once dirname(__FILE__)."/../inc/asynchronousdata.class.php" ;
include_once dirname(__FILE__)."/../inc/crontaskaction.class.php" ;
if( isset($_SERVER['REQUEST_METHOD']) ) {
switch($_SERVER['REQUEST_METHOD']) {
//case 'OPTIONS' :
// header("Access-Control-Allow-Origin: *") ;
// header("Access-Control-Allow-Methods: POST");
// header("Access-Control-Allow-Headers: Content-Type");
// break ;
case 'POST' :
//header("Access-Control-Allow-Origin: *") ;
//header("Content-Type: application/json; charset=UTF-8");
$request_body = file_get_contents('php://input');
$datas = json_decode($request_body, true);
// $asyncdata = new PluginProcessmakerAsynchronousdata ;
$asyncdata = new PluginProcessmakerCrontaskaction ;
if( isset($datas['id']) && $asyncdata->getFromDB( $datas['id'] ) && $asyncdata->fields['state'] == PluginProcessmakerCrontaskaction::WAITING_DATAS ) {
$initialdatas = json_decode($asyncdata->fields['postdatas'], true);

View File

@@ -6,17 +6,16 @@
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
die("Can not acces directly to this file");
}
//include_once dirname(__FILE__)."/../inc/process.class.php" ;
Session::checkLoginUser();
@@ -29,7 +28,7 @@ if (isset($_REQUEST["entity_restrict"])
// Security
if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
exit();
exit();
}
$one_item = -1;
@@ -40,36 +39,36 @@ if (isset($_POST['_one_id'])) {
$count = 0;
if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
}
$search="";
if (!empty($_REQUEST['searchText'])) {
$search = Search::makeTextSearch($_REQUEST['searchText']);
$search = Search::makeTextSearch($_REQUEST['searchText']);
}
$processes = array();
// Empty search text : display first
if (empty($_REQUEST['searchText'])) {
if ($_REQUEST['display_emptychoice']) {
if (($one_item < 0) || ($one_item == 0)) {
array_push($processes, array('id' => 0,
'text' => $_REQUEST['emptylabel']));
}
}
if ($_REQUEST['display_emptychoice']) {
if (($one_item < 0) || ($one_item == 0)) {
array_push($processes, array('id' => 0,
'text' => $_REQUEST['emptylabel']));
}
}
}
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
if( in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
array_push( $processes, array( 'id' => $data["id"],
'text' => $data["name"] ));
$count++;
}
}
while ($data=$DB->fetch_array($result)) {
if (in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) )) {
array_push( $processes, array( 'id' => $data["id"],
'text' => $data["name"] ));
$count++;
}
}
}
$ret['results'] = $processes;

View File

@@ -9,7 +9,7 @@
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"dropdownUsers.php")) {
if (strpos($_SERVER['PHP_SELF'], "dropdownUsers.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
@@ -24,7 +24,7 @@ if (!defined('GLPI_ROOT')) {
Session::checkLoginUser();
$PM_DB = new PluginProcessmakerDB ;
$PM_DB = new PluginProcessmakerDB;
if (!isset($_REQUEST['right'])) {
$_REQUEST['right'] = "all";
@@ -35,13 +35,6 @@ if (!isset($_REQUEST['all'])) {
$_REQUEST['all'] = 0;
}
$used = array();
if (isset($_REQUEST['used'])) {
@@ -64,9 +57,6 @@ if (!isset($_REQUEST['page'])) {
if ($one_item < 0) {
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
//$result = User::getSqlSearchResult(false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
// $_REQUEST['value'], $used, $_REQUEST['searchText'], $start,
// $_REQUEST['page_limit']);
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['pmTaskId'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
$_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT);
@@ -94,9 +84,6 @@ if (!function_exists('dpuser_cmp')) {
}
}
// Sort non case sensitive
//uasort($users, 'dpuser_cmp');
$datas = array();
// Display first if empty search

View File

@@ -6,45 +6,41 @@
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (strpos($_SERVER['PHP_SELF'], "task_users.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
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();
$PM_DB = new PluginProcessmakerDB ;
$PM_DB = new PluginProcessmakerDB;
$rand = rand();
echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQUEST['delIndex']."' id='processmaker_form_task$rand-".$_REQUEST['delIndex']."' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo $LANG['processmaker']['item']['reassigncase']."&nbsp;";
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']."'>";
echo $LANG['processmaker']['item']['reassigncase']."&nbsp;";
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']."'>";
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
'entity_sons' => false, // not used, as any user can be assigned to any tasks
'right' => 'all',
'rand' => $rand,
'width' => '',
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
echo "&nbsp;&nbsp;";
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
Html::closeForm(true);
//echo "</form>";
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
'entity_sons' => false, // not used, as any user can be assigned to any tasks
'right' => 'all',
'rand' => $rand,
'width' => '',
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
echo "&nbsp;&nbsp;";
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
Html::closeForm(true);

View File

@@ -1,51 +0,0 @@
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`;

View File

@@ -1,175 +0,0 @@

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 ;

View File

@@ -1,218 +0,0 @@
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 ;

View File

@@ -1,203 +0,0 @@
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 ;

View File

@@ -1,7 +0,0 @@
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` ;

View File

@@ -1,6 +0,0 @@
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` ;

View File

@@ -2,39 +2,39 @@
include_once '../../../inc/includes.php';
// check if it is from PM pages
if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] ) ) {
if (isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) {
// then get item id from DB
$myCase = new PluginProcessmakerCase ;
if( $myCase->getFromDB( $_REQUEST['APP_UID'] ) ) {
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login( ) ;
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromDB( $_REQUEST['APP_UID'] )) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login( );
if( isset( $_REQUEST['form'] ) ) {
if (isset( $_REQUEST['form'] )) {
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
}
}
} elseif ( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ) {
} else if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID'])) {
// Claim task management
// here we are in a Claim request
$myCase = new PluginProcessmakerCase ;
if( $myCase->getFromDB( $_REQUEST['form']['APP_UID'] ) ) {
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login( ) ;
$myCase = new PluginProcessmakerCase;
if ($myCase->getFromDB( $_REQUEST['form']['APP_UID'] )) {
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login( );
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
// now manage tasks associated with item
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
}
}
// now redirect to item form page
$config = PluginProcessmakerConfig::getInstance() ;
$config = PluginProcessmakerConfig::getInstance();
echo "<html><body><script>";
if( isset($config->fields['domain']) && $config->fields['domain'] != '' ) {
if (isset($config->fields['domain']) && $config->fields['domain'] != '') {
echo "document.domain='{$config->fields['domain']}';";
}
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>";

View File

@@ -1,26 +1,21 @@
<?php
/**
*/
include ( "../../../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'], UPDATE);
// save
$config->update($_POST);
$config->check($_POST['id'], UPDATE);
// save
$config->update($_POST);
Html::back();
Html::back();
} elseif (isset($_POST["refresh"])) {
$config->refresh($_POST); // used to refresh process list, task category list
Html::back();
}
} else if (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'));

View File

@@ -1,34 +1,30 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
include_once ("../../../inc/includes.php");
Plugin::load('processmaker',true);
Plugin::load('processmaker', true);
if (!isset($_REQUEST["id"])) {
$_REQUEST["id"] = "";
$_REQUEST["id"] = "";
}
$PluginProcess = new PluginProcessmakerProcess();
if (isset($_REQUEST["update"])) {
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->update($_REQUEST);
Html::back();
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->update($_REQUEST);
Html::back();
} else if (isset($_REQUEST["refreshtask"])) {
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->refreshTasks($_REQUEST);
Html::back();
} elseif (isset($_REQUEST["refreshtask"])) {
$PluginProcess->check($_REQUEST['id'], UPDATE);
$PluginProcess->refreshTasks($_REQUEST);
Html::back();
} else {
// $PluginProcess->checkGlobal(READ);
Html::header($LANG['processmaker']['title'][1],$_SERVER["PHP_SELF"],"plugins","processmaker");
$PluginProcess->display($_REQUEST) ;
// $PluginProcess->showForm($_REQUEST["id"]);
Html::footer();
Html::header($LANG['processmaker']['title'][1], $_SERVER["PHP_SELF"], "plugins", "processmaker");
$PluginProcess->display($_REQUEST);
Html::footer();
}
?>

View File

@@ -1,25 +1,23 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
include_once ("../../../inc/includes.php");
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "plugins", "processmaker");
if (Session::haveRight("plugin_processmaker_config",READ) || Session::haveRight("config", UPDATE)) {
$process=new PluginProcessmakerProcess();
if (Session::haveRight("plugin_processmaker_config", READ) || Session::haveRight("config", UPDATE)) {
$process=new PluginProcessmakerProcess();
if( isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config",UPDATE) ) {
$process->refresh();
Html::back();
}
$process->title();
if (isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config", UPDATE)) {
$process->refresh();
Html::back();
}
Search::show('PluginProcessmakerProcess');
$process->title();
Search::show('PluginProcessmakerProcess');
} else {
Html::displayRightError();
Html::displayRightError();
}
Html::footer();
?>

View File

@@ -1,42 +1,39 @@
<?php
//define('GLPI_ROOT', '../../..');
include_once ("../../../inc/includes.php");
Session::checkCentralAccess();
$profile = new Profile();
$right = new PluginProcessmakerProcess_Profile();
$process = new PluginProcessmakerProcess();
$process = new PluginProcessmakerProcess();
if (isset($_POST["add"])) {
$right->check(-1,UPDATE,$_POST);
if ($right->add($_POST)) {
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
}
Html::back();
$right->check(-1, UPDATE, $_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,UPDATE)) {
$right->delete(array('id' => $key));
}
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($right->can($key, UPDATE)) {
$right->delete(array('id' => $key));
}
}
//if (isset($_POST["processes_id"])) {
// Event::log($_POST["processes_id"], "users", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
// }
}
}
}
//if (isset($_POST["processes_id"])) {
// Event::log($_POST["processes_id"], "users", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
// }
}
Html::back();
}
}
Html::displayErrorAndDie("lost");
?>

View File

@@ -1,124 +1,123 @@
<?php
include_once ("../../../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();
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();
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() ) ;
if ($resultCase->status_code == 0){
Html::back();
}
else
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
} else
Html::back();
}
else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login() ;
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ) ;
if ($resultCase->status_code == 0){
// case is created
// Must show it...
//
$rand = rand( ) ;
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() );
if ($resultCase->status_code == 0) {
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";
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
}
} else {
Html::back();
}
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login();
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) );
if ($resultCase->status_code == 0) {
// case is created
// Must show it...
//
$rand = rand( );
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
}
} 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";
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();
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 = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] );
if ($_POST['plugin_processmaker_userId'] != $GLPINewPMUserId) {
$locPM = new PluginProcessmakerProcessmaker();
$locPM->login( );
$pmResponse = $locPM->reassignCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'], $GLPINewPMUserId );
if ($pmResponse->status_code == 0) {
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
// we need 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);
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
}
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 = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] ) ;
if( $_POST['plugin_processmaker_userId'] != $GLPINewPMUserId ) {
$locPM = new PluginProcessmakerProcessmaker() ;
$locPM->login( ) ;
} 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 PluginProcessmakerCase;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
if ($locCase->deleteCase()) {
// request delete from pm itself
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login(true);
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] );
$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 PluginProcessmakerCase ;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
if( $locCase->deleteCase() ) {
// request delete from pm itself
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
$myProcessMaker->login(true) ;
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
if ($resultPM->status_code == 0) {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
} 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 PluginProcessmakerCase;
$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);
}
}
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 PluginProcessmakerCase ;
$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;
break;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
<?php
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// Original Author of file: MoronO
// Purpose of file: mimic tracking.injector.php
// ----------------------------------------------------------------------
include( "../../../inc/includes.php");
@@ -56,129 +56,5 @@ if( isset($_POST["_from_helpdesk"]) && $_POST["_from_helpdesk"] == 1
}
if( !function_exists('stripcslashes_deep') ){
/**
* Strip c slash for variable & array
*
* @param $value array or string: item to stripslashes (array or string)
*
* @return stripcslashes item
**/
function stripcslashes_deep($value) {
$value = is_array($value) ?
array_map('stripcslashes_deep', $value) :
stripcslashes($value);
return $value;
}
}
if( !function_exists('http_formdata_flat_hierarchy') ) {
/**
* Summary of http_formdata_flat_hierarchy
* @param mixed $data
* @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;
}
}
if( !function_exists('tmpdir') ) {
/**
* Summary of tmpdir
* Will attempts $attempts to create a random temp dir in $path
* see: http://php.net/manual/en/function.mkdir.php
* @param string $path: dir into the temp subdir will be created
* @param string $prefix: used to prefix the random number for dir name
* @param int $attempts: is the quantity of attempts trying to create tempdir
* @return bool|string: false if $attempts has been reached, otherwise the path to the newly created dir
*/
function tmpdir($path, $prefix='', $attempts=3){
$count = 1 ;
do {
$rand=$prefix.rand() ;
} while( !mkdir($path.'/'.$rand) && $count++ < $attempts ) ;
return ($count < $attempts ? $path.'/'.$rand : false ) ;
}
}
// by default loads standard page from GLPI
//include (GLPI_ROOT . "/front/tracking.injector.php");
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']);
// why not [HTTP_REFERER] "http://fry07689-glpi090.fr.ray.group/front/helpdesk.public.php?create_ticket=1" string
curl_setopt($ch, CURLOPT_REFERER, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php" ) ;
curl_setopt($ch, CURLOPT_POST, 1);
$data = http_formdata_flat_hierarchy( $_REQUEST ) ;
// CSRF management
if( GLPI_USE_CSRF_CHECK ) {
// must set a csrf token
$data['_glpi_csrf_token'] = Session::getNewCSRFToken() ;
}
$data = array_map('Toolbox::unclean_cross_side_scripting_deep', $data);
$data = array_map('stripcslashes_deep', $data);
// Files are uploaded via ajax, so need to pass them to next page
//// need to add files if some are uploaded
//$files = array() ;
//$paths = array() ;
//if( isset( $_FILES['filename']['name'] ) && is_array($_FILES['filename']['name']) && count($_FILES['filename']['name']) > 0) {
// foreach( $_FILES['filename']['name'] as $num => $file ){
// if( $file <> '' ){
// $path = str_replace( '\\', '/', $_FILES['filename']['tmp_name'][$num] ) ;
// $path = explode('/', $path);
// array_pop( $path ) ;
// $path = tmpdir(implode( '/', $path ), 'php_tmp') ;
// if( $path !== false ) {
// $paths[$num] = $path;
// $files[$num] = $paths[$num].'/'.$file;
// copy( $_FILES['filename']['tmp_name'][$num], $files[$num] ) ;
// $data['filename['.$num.']']='@'.$files[$num] ;
// }
// }
// }
//}
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
//curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI["root_doc"]."/front/tracking.injector.php");
// as sessions in PHP are not re-entrant, we MUST close current one before curl_exec
@session_write_close() ;
curl_exec ($ch);
curl_close ($ch);
// need to delete temp files
foreach( $files as $file ) {
unlink( $file ) ;
}
foreach( $paths as $path ) {
rmdir( $path ) ;
}
chdir(GLPI_ROOT."/front");
include (GLPI_ROOT . "/front/tracking.injector.php");

156
hook.php
View File

@@ -3,27 +3,26 @@
include_once 'inc/processmaker.class.php';
function plugin_processmaker_MassiveActions($type) {
global $LANG;
global $LANG;
switch ($type) {
case 'PluginProcessmakerProcess' :
if (plugin_processmaker_haveRight('config', UPDATE )) {
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
}
break;
case 'PluginProcessmakerProcess_Profile' :
if (plugin_processmaker_haveRight('config', UPDATE )) {
return array('purge' => $LANG['processmaker']['process']['profile']);
return array('purge' => $LANG['processmaker']['process']['profile']);
}
break;
break;
}
return array();
return array();
}
function plugin_processmaker_MassiveActionsDisplay($options) {
global $LANG;
global $LANG;
switch ($options['itemtype']) {
case 'PluginProcessmakerProcess' :
@@ -31,19 +30,18 @@ function plugin_processmaker_MassiveActionsDisplay($options) {
// No case for add_document : use GLPI core one
case "plugin_processmaker_taskrefresh" :
echo "<input type='submit' name='massiveaction' class='submit' ".
"value='".$LANG['buttons'][2]."'>";
break;
"value='".$LANG['buttons'][2]."'>";
break;
}
break;
break;
}
return "";
return "";
}
function plugin_processmaker_MassiveActionsProcess($data) {
//global $LANG,$DB;
switch ($data['action']) {
@@ -80,7 +78,7 @@ function plugin_processmaker_MassiveActionsProcess($data) {
* @return true or die!
*/
function plugin_processmaker_install() {
global $DB;
global $DB;
if (TableExists("glpi_plugin_processmaker_config")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_config`
@@ -307,43 +305,43 @@ function plugin_processmaker_install() {
}
if (!TableExists("glpi_plugin_processmaker_processes_profiles")) { // since version 2.2
$query = "CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`processes_id` INT(11) NOT NULL DEFAULT '0',
`profiles_id` INT(11) NOT NULL DEFAULT '0',
`entities_id` INT(11) NOT NULL DEFAULT '0',
`is_recursive` TINYINT(1) NOT NULL DEFAULT '1',
$query = "CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`processes_id` INT(11) NOT NULL DEFAULT '0',
`profiles_id` INT(11) NOT NULL DEFAULT '0',
`entities_id` INT(11) NOT NULL DEFAULT '0',
`is_recursive` TINYINT(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
INDEX `entities_id` (`entities_id`),
INDEX `profiles_id` (`profiles_id`),
INDEX `processes_id` (`processes_id`),
INDEX `is_recursive` (`is_recursive`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB;";
$DB->query($query) or die("error creating glpi_plugin_processmaker_processes_profiles" . $DB->error());
PRIMARY KEY (`id`),
INDEX `entities_id` (`entities_id`),
INDEX `profiles_id` (`profiles_id`),
INDEX `processes_id` (`processes_id`),
INDEX `is_recursive` (`is_recursive`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB;";
$DB->query($query) or die("error creating glpi_plugin_processmaker_processes_profiles" . $DB->error());
}
if (!TableExists("glpi_plugin_processmaker_taskcategories")) {
$query = "CREATE TABLE `glpi_plugin_processmaker_taskcategories` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`processes_id` INT(11) NOT NULL,
`pm_task_guid` VARCHAR(32) NOT NULL,
`taskcategories_id` INT(11) NOT NULL,
`start` BIT(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`id`),
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
UNIQUE INDEX `items` (`taskcategories_id`),
INDEX `processes_id` (`processes_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;
";
$query = "CREATE TABLE `glpi_plugin_processmaker_taskcategories` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`processes_id` INT(11) NOT NULL,
`pm_task_guid` VARCHAR(32) NOT NULL,
`taskcategories_id` INT(11) NOT NULL,
`start` BIT(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`id`),
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
UNIQUE INDEX `items` (`taskcategories_id`),
INDEX `processes_id` (`processes_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;
";
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
}
@@ -422,24 +420,23 @@ function plugin_processmaker_install() {
// To be called for each task managed by the plugin
// task in class
CronTask::Register('PluginProcessmakerProcessmaker', 'pmusers', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
//CronTask::Register('PluginProcessmakerProcessmaker', 'pmnotifications', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
CronTask::Register('PluginProcessmakerProcessmaker', 'pmorphancases', DAY_TIMESTAMP, array('param' => 10, 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
CronTask::Register('PluginProcessmakerProcessmaker', 'pmusers', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
CronTask::Register('PluginProcessmakerProcessmaker', 'pmorphancases', DAY_TIMESTAMP, array('param' => 10, 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
CronTask::Register('PluginProcessmakerProcessmaker', 'pmtaskactions', MINUTE_TIMESTAMP, array('state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php");
PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php");
PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
return true;
return true;
}
function plugin_processmaker_uninstall() {
global $DB;
global $DB;
CronTask::Unregister('PluginProcessmakerProcessmaker');
CronTask::Unregister('PluginProcessmakerProcessmaker');
return true;
return true;
}
@@ -486,12 +483,12 @@ function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,
case "glpi_plugin_processmaker_cases" :
$out= " LEFT JOIN `glpi_plugin_processmaker_cases`
ON (`$ref_table`.`id` = `glpi_plugin_processmaker_cases`.`items_id` AND `glpi_plugin_processmaker_cases`.`itemtype` like 'Ticket') ";
return $out;
break;
return $out;
}
return "";
break;
return "";
}
return "";
@@ -587,7 +584,7 @@ function plugin_pre_item_purge_processmaker ( $parm ) {
/**
* Summary of plugin_item_purge_processmaker
* @param mixed $parm is the object
* @param mixed $parm is the object
*/
function plugin_item_purge_processmaker($parm) {
global $DB;
@@ -674,18 +671,8 @@ function plugin_item_update_processmaker_tasks($parm) {
&& in_array( 'state', $parm->updates )
&& $parm->input['state'] == 2) { // the task has just been set to DONE state
//$taskList = array( array( 'sourcetaskguid' => '54949951157c000b2336474053483376',
// 'sourcecondition' => '@@RELEASE_DONE == 1' ,
// 'targettaskguid' => '95599365257bffa6d6170d9068913760',
// 'targetprocessguid' => '51126098657bd96b286ded7016691792',
// 'targetdynaformguid' => '28421020557bffc5b374850018853291',
// 'targettoclaim' => true,
// 'targetactions' => array( 'RELEASE_DONE' => '@@RELEASE_DONE' )
// ) ) ;
$itemtype = str_replace( 'Task', '', $parm->getType() );
//foreach( $taskList as $targetTask ) {
foreach ($DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask) {
$srcCaseId = PluginProcessmakerProcessmaker::getCaseIdFromItem( $itemtype, $parm->fields['tickets_id']);
@@ -697,7 +684,7 @@ function plugin_item_update_processmaker_tasks($parm) {
if (preg_match_all( "/@@(\w+)/u", $targetTask['sourcecondition'], $matches )) {
$casevariables = $matches[1];
}
//foreach( $targetTask['targetactions'] as $actionvalue ){
$targetTask['targetactions'] = array(); // empty array by default
foreach ($DB->request( 'glpi_plugin_processmaker_caselinkactions', 'plugin_processmaker_caselinks_id = '.$targetTask['id']) as $actionvalue) {
$targetTask['targetactions'][$actionvalue['name']] = $actionvalue['value'];
@@ -746,10 +733,6 @@ function plugin_item_update_processmaker_tasks($parm) {
$postdatas['DynaformRequiredFields'] = '[]';
$postdatas['form']['btnGLPISendRequest'] = 'submit';
//foreach ( $externalapplication['params'] as $paramname => $variable ) {
// $externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" ) ;
//}
$externalapplicationparams = array();
if ($externalapplication) {
// must call curl
@@ -809,7 +792,6 @@ function plugin_item_update_processmaker_tasks($parm) {
$externalapplicationparams['id'] = $cronaction->getID();
$externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT);
//$externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
@@ -817,7 +799,7 @@ function plugin_item_update_processmaker_tasks($parm) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
// curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
// curl_setopt($ch, CURLOPT_PROXY, "fry07689.fr.ray.group:8888");
// curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
$response = curl_exec ($ch);
@@ -852,26 +834,6 @@ function plugin_item_update_processmaker_tasks($parm) {
null,
false);
}
//if( $externalapplication ) {
// // must call external application in order to get the needed data asynchroneously
// // must be of the form
// // {"method":"POST","url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
// // Where method is the POST, GET
// // url is the URL to be called
// $externalapplicationparams['record_id']=$cronaction->getID();
// $externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
// if( $externalapplication['method'] != 'GET') {
// switch($externalapplication['method']) {
// case 'POST' :
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
// break;
// }
// }
// $response = curl_exec ($ch);
// curl_close ($ch);
//}
}
}
}
@@ -879,4 +841,4 @@ function plugin_item_update_processmaker_tasks($parm) {
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,26 @@
<?php
class PluginProcessmakerDB extends DBmysql {
class PluginProcessmakerDB extends DBmysql {
var $dbhost ;
var $dbhost;
var $dbuser ;
var $dbuser;
var $dbpassword ;
var $dbpassword;
var $dbdefault ;
var $dbdefault;
function __construct() {
$config = PluginProcessmakerConfig::getInstance() ;
if( $config->fields['pm_dbserver_name'] != ''
&& $config->fields['pm_dbserver_user'] != ''
&& $config->fields['pm_workspace'] != '' ) {
$this->dbhost = $config->fields['pm_dbserver_name'] ;
$this->dbuser = $config->fields['pm_dbserver_user'] ;
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
$this->dbdefault = "wf_".$config->fields['pm_workspace'] ;
parent::__construct();
}
}
function __construct() {
$config = PluginProcessmakerConfig::getInstance();
if ($config->fields['pm_dbserver_name'] != ''
&& $config->fields['pm_dbserver_user'] != ''
&& $config->fields['pm_workspace'] != '' ) {
$this->dbhost = $config->fields['pm_dbserver_name'];
$this->dbuser = $config->fields['pm_dbserver_user'];
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
$this->dbdefault = "wf_".$config->fields['pm_workspace'];
parent::__construct();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,50 +10,50 @@
*/
class PluginProcessmakerProcess_Profile extends CommonDBTM
{
function can($ID, $right, array &$input = NULL) {
return Session::haveRight('plugin_processmaker_config', $right) ;
}
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
global $LANG;
return $LANG['processmaker']['title'][4];
}
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
function can($ID, $right, array &$input = NULL) {
return Session::haveRight('plugin_processmaker_config', $right);
}
global $DB,$CFG_GLPI, $LANG;
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
global $LANG;
return $LANG['processmaker']['title'][4];
}
$ID = $item->getField('id');
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
$canshowentity = Session::haveRight("entity", READ);
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE) ;
$rand=mt_rand();
global $DB,$CFG_GLPI, $LANG;
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
$ID = $item->getField('id');
echo "<tr class='tab_bg_2'><td class='center'>";
echo "<input type='hidden' name='processes_id' value='$ID'>";
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
echo "</td><td class='center'>".__('Recursive')."</td><td>";
Dropdown::showYesNo("is_recursive",0);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
echo "</td></tr>";
$canshowentity = Session::haveRight("entity", READ);
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE);
echo "</table>";
Html::closeForm();
echo "</div>";
}
$rand=mt_rand();
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
echo "<input type='hidden' name='processes_id' value='$ID'>";
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
echo "</td><td class='center'>".__('Recursive')."</td><td>";
Dropdown::showYesNo("is_recursive", 0);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
`glpi_profiles`.`id`,
`glpi_profiles`.`name`,
`glpi_plugin_processmaker_processes_profiles`.`is_recursive`,
@@ -66,103 +66,102 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
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);
$num = $DB->numrows($result);
$result = $DB->query($query);
$num = $DB->numrows($result);
echo "<div class='spaced'>";
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
echo "<div class='spaced'>";
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
if ($canedit && $num) {
$massiveactionparams = array('num_displayed' => $num,
'container' => 'mass'.__CLASS__.$rand);
Html::showMassiveActions($massiveactionparams);
}
if ($canedit && $num) {
$massiveactionparams = array('num_displayed' => $num,
'container' => 'mass'.__CLASS__.$rand);
Html::showMassiveActions($massiveactionparams);
}
if ($num > 0) {
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_begin .= "<th>";
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_end .= "</th>";
}
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
__('D=Dynamic, R=Recursive'));
$header_end .= "</th></tr>";
echo $header_begin.$header_top.$header_end;
if ($num > 0) {
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_1'>";
if ($canedit) {
$header_begin .= "<th>";
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
$header_end .= "</th>";
}
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
__('D=Dynamic, R=Recursive'));
$header_end .= "</th></tr>";
echo $header_begin.$header_top.$header_end;
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
} else {
echo "&nbsp;";
}
echo "</td>";
}
echo "<td>";
$link = $data["completename"];
if ($_SESSION["glpiis_ids_visible"]) {
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
}
if ($canshowentity) {
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
$data["entities_id"]."'>";
}
echo $link.($canshowentity ? "</a>" : '');
echo "<td width='10'>";
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
} else {
echo "&nbsp;";
}
echo "</td>";
if (Profile::canView()) {
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
$data["name"]."</a>";
} else {
$entname = $data["name"];
}
// if ($data["is_dynamic"] || $data["is_recursive"]) {
if ($data["is_recursive"]) {
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
//if ($data["is_dynamic"]) {
// //TRANS: letter 'D' for Dynamic
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
//}
//if ($data["is_dynamic"] && $data["is_recursive"]) {
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
//}
if ($data["is_recursive"]) {
//TRANS: letter 'R' for Recursive
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
}
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
}
echo "<td>".$entname."</td>";
echo "</tr>";
}
echo $header_begin.$header_bottom.$header_end;
echo "</table>";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>".__('No item found')."</th></tr>";
echo "</table>\n";
}
echo "<td>";
if ($canedit && $num) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
}
Html::closeForm();
echo "</div>";
}
$link = $data["completename"];
if ($_SESSION["glpiis_ids_visible"]) {
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
}
if ($canshowentity) {
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
$data["entities_id"]."'>";
}
echo $link.($canshowentity ? "</a>" : '');
echo "</td>";
if (Profile::canView()) {
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
$data["name"]."</a>";
} else {
$entname = $data["name"];
}
// if ($data["is_dynamic"] || $data["is_recursive"]) {
if ($data["is_recursive"]) {
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
//if ($data["is_dynamic"]) {
// //TRANS: letter 'D' for Dynamic
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
//}
//if ($data["is_dynamic"] && $data["is_recursive"]) {
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
//}
if ($data["is_recursive"]) {
//TRANS: letter 'R' for Recursive
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
}
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
}
echo "<td>".$entname."</td>";
echo "</tr>";
}
echo $header_begin.$header_bottom.$header_end;
echo "</table>";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>".__('No item found')."</th></tr>";
echo "</table>\n";
}
if ($canedit && $num) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
}
Html::closeForm();
echo "</div>";
}
//static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) {
// global $CFG_GLPI;
@@ -187,5 +186,5 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
// break ;
// }
//}
}

File diff suppressed because it is too large Load Diff

View File

@@ -11,47 +11,47 @@ class ProcessmakerConfig extends CommonDBTM {
var $table = 'glpi_plugins_processmaker_config';
static function getTypeName($nb=0) {
global $LANG;
return 'Process Maker Plugin Configuration';
}
static function getTypeName($nb=0) {
global $LANG;
return 'Process Maker Plugin Configuration';
}
function defineTabs($options=array()) {
function defineTabs($options=array()) {
$ong = array();
$this->addStandardTab(__CLASS__, $ong, $options);
$ong = array();
$this->addStandardTab(__CLASS__, $ong, $options);
return $ong;
}
return $ong;
}
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG, $CFG_GLPI;
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG, $CFG_GLPI;
switch ($item->getType()) {
case __CLASS__ :
$tabs[1] = $LANG['common'][12];
return $tabs;
}
return '';
}
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;
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;
}
if ($item->getType() == __CLASS__) {
switch ($tabnum) {
case 1 :
$item->showFormMailServerConfig();
break;
}
}
return true;
}
/**
@@ -65,35 +65,34 @@ class ProcessmakerConfig extends CommonDBTM {
* @return Nothing (display)
*
**/
function showForm($ID, $options=array()) {
global $LANG, $CFG_GLPI;
function showForm($ID, $options=array()) {
global $LANG, $CFG_GLPI;
if (!Session::haveRight("config", UPDATE)) {
return false;
}
if (!$CFG_GLPI['use_mailing']) {
$options['colspan'] = 1;
}
if (!Session::haveRight("config", UPDATE)) {
return false;
}
if (!$CFG_GLPI['use_mailing']) {
$options['colspan'] = 1;
}
$this->getFromDB($ID);
$this->showTabs($options);
$this->addDivForTabs();
return true;
}
$this->getFromDB($ID);
$this->showTabs($options);
$this->addDivForTabs();
return true;
}
static function canCreate() {
return Session::haveRight('config', UPDATE);
}
static function canCreate() {
return Session::haveRight('config', UPDATE);
}
static function canView() {
return Session::haveRight('config', READ);
}
static function canView() {
return Session::haveRight('config', READ);
}
}
?>

View File

@@ -12,23 +12,22 @@ class PluginProcessmakerProfile extends CommonDBTM {
* Summary of getAllRights
* @return array[]
*/
static function getAllRights() {
global $LANG;
static function getAllRights() {
global $LANG;
$rights = array(
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['process_config'],
'field' => 'plugin_processmaker_config',
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['case_delete'],
'field' => 'plugin_processmaker_deletecase',
'rights' => array(DELETE => __('Delete')))
);
$rights = array(
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['process_config'],
'field' => 'plugin_processmaker_config',
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['case_delete'],
'field' => 'plugin_processmaker_deletecase',
'rights' => array(DELETE => __('Delete')))
);
return $rights;
}
return $rights;
}
/**
@@ -38,106 +37,106 @@ class PluginProcessmakerProfile extends CommonDBTM {
* @param mixed $closeform
* @return bool
*/
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
global $LANG;
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
global $LANG;
if (!Session::haveRight("profile",READ)) {
return false;
}
if (!Session::haveRight("profile", READ)) {
return false;
}
$canedit = Session::haveRight("profile", UPDATE);
$prof = new Profile();
if ($ID) {
$prof->getFromDB($ID);
}
echo "<form action='".$prof->getFormURL()."' method='post'>";
$rights = $this->getAllRights();
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
'default_class' => 'tab_bg_2',
'title' => $LANG['processmaker']['title'][1]));
$canedit = Session::haveRight("profile", UPDATE);
$prof = new Profile();
if ($ID) {
$prof->getFromDB($ID);
}
echo "<form action='".$prof->getFormURL()."' method='post'>";
$rights = $this->getAllRights();
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
'default_class' => 'tab_bg_2',
'title' => $LANG['processmaker']['title'][1]));
if ($canedit && $closeform) {
echo "<div class='center'>";
echo Html::hidden('id', array('value' => $ID));
echo Html::submit(_sx('button', 'Save'),
array('name' => 'update'));
echo "</div>\n";
}
if ($canedit && $closeform) {
echo "<div class='center'>";
echo Html::hidden('id', array('value' => $ID));
echo Html::submit(_sx('button', 'Save'),
array('name' => 'update'));
echo "</div>\n";
}
Html::closeForm();
Html::closeForm();
}
}
/**
* Summary of createAdminAccess
* @param mixed $ID
*/
static function createAdminAccess($ID) {
static function createAdminAccess($ID) {
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
}
}
/**
* Summary of getTabNameForItem
* @param CommonGLPI $item
* @param mixed $withtemplate
* @param mixed $withtemplate
* @return string|string[]
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
if ($item->getType()=='Profile') {
return $LANG['processmaker']['title'][1];
}
return '';
}
if ($item->getType()=='Profile') {
return $LANG['processmaker']['title'][1];
}
return '';
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $item
* @param mixed $tabnum
* @param mixed $withtemplate
* @param mixed $tabnum
* @param mixed $withtemplate
* @return bool
*/
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI;
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI;
if ($item->getType()=='Profile') {
$ID = $item->getID();
$prof = new self();
self::addDefaultProfileInfos($ID,
array('plugin_processmaker_config' => 0,
'plugin_processmaker_deletecase' => 0
));
if ($item->getType()=='Profile') {
$ID = $item->getID();
$prof = new self();
self::addDefaultProfileInfos($ID,
array('plugin_processmaker_config' => 0,
'plugin_processmaker_deletecase' => 0
));
$prof->showForm($ID);
}
return true;
}
$prof->showForm($ID);
}
return true;
}
/**
* @param $profile
**/
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
global $DB;
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
global $DB;
$profileRight = new ProfileRight();
foreach ($rights as $right => $value) {
if (countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
}
if (!countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
$myright['profiles_id'] = $profiles_id;
$myright['name'] = $right;
$myright['rights'] = $value;
$profileRight->add($myright);
$profileRight = new ProfileRight();
foreach ($rights as $right => $value) {
if (countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
}
if (!countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
$myright['profiles_id'] = $profiles_id;
$myright['name'] = $right;
$myright['rights'] = $value;
$profileRight->add($myright);
//Add right to the current session
$_SESSION['glpiactiveprofile'][$right] = $value;
}
}
}
//Add right to the current session
$_SESSION['glpiactiveprofile'][$right] = $value;
}
}
}
}

View File

@@ -10,11 +10,11 @@
*/
class PluginProcessmakerTask extends CommonITILTask
{
private $itemtype ;
function __construct($itemtype) {
parent::__construct();
$this->itemtype=$itemtype;
}
private $itemtype;
function __construct($itemtype) {
parent::__construct();
$this->itemtype=$itemtype;
}
/**
* Summary of getFromDB
@@ -22,112 +22,112 @@ class PluginProcessmakerTask extends CommonITILTask
* @param mixed $itemtype
* @return bool
*/
function getFromDB($items_id) {
global $DB ;
function getFromDB($items_id) {
global $DB;
if( $this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ) ) {
$task = new $this->itemtype;
if( $task->getFromDB( $items_id ) ) {
// then we should add our own fields
$task->fields['items_id'] = $this->fields['id'] ;
$task->fields['itemtype'] = $this->fields['itemtype'] ;
unset( $this->fields['id'] ) ;
unset( $this->fields['items_id'] ) ;
unset( $this->fields['itemtype'] ) ;
foreach( $this->fields as $field => $val) {
$task->fields[ $field ] = $val ;
}
$this->fields = $task->fields ;
return true ;
}
}
if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) {
$task = new $this->itemtype;
if ($task->getFromDB( $items_id )) {
// then we should add our own fields
$task->fields['items_id'] = $this->fields['id'];
$task->fields['itemtype'] = $this->fields['itemtype'];
unset( $this->fields['id'] );
unset( $this->fields['items_id'] );
unset( $this->fields['itemtype'] );
foreach ($this->fields as $field => $val) {
$task->fields[ $field ] = $val;
}
$this->fields = $task->fields;
return true;
}
}
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
//$ret = $DB->query( $query ) ;
//if( $ret && $DB->numrows( $ret ) == 1 ) {
// $row = $DB->fetch_assoc( $ret ) ;
// $task = new $this->itemtype;
// if( $task->getFromDB( $row['items_id'] ) ) {
// // then we should add our own fields
// unset( $row['id'] ) ;
// unset( $row['items_id'] ) ;
// unset( $row['itemtype'] ) ;
// foreach( $row as $field => $val) {
// $task->fields[ $field ] = $val ;
// }
// $this->fields = $task->fields ;
// return true ;
// }
//}
return false ;
}
//$ret = $DB->query( $query ) ;
//if( $ret && $DB->numrows( $ret ) == 1 ) {
// $row = $DB->fetch_assoc( $ret ) ;
// $task = new $this->itemtype;
// if( $task->getFromDB( $row['items_id'] ) ) {
// // then we should add our own fields
// unset( $row['id'] ) ;
// unset( $row['items_id'] ) ;
// unset( $row['itemtype'] ) ;
// foreach( $row as $field => $val) {
// $task->fields[ $field ] = $val ;
// }
// $this->fields = $task->fields ;
// return true ;
// }
//}
return false;
}
/**
* Summary of getToDoTasks
* returns all 'to do' tasks associated with this case
* @param mixed $case_id
*/
public static function getToDoTasks( $case_id, $itemtype ) {
global $DB ;
$ret = array();
$selfTable = getTableForItemType( __CLASS__) ;
$itemTypeTaskTable = getTableForItemType( $itemtype );
public static function getToDoTasks( $case_id, $itemtype ) {
global $DB;
$ret = array();
$selfTable = getTableForItemType( __CLASS__);
$itemTypeTaskTable = getTableForItemType( $itemtype );
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
foreach($DB->request($query) as $row){
$ret[$row['taskID']]=$row['taskID'];
}
return $ret ;
}
foreach ($DB->request($query) as $row) {
$ret[$row['taskID']]=$row['taskID'];
}
return $ret;
}
static function canView( ) {
return true ;
static function canView( ) {
return true;
}
static function populatePlanning($params) {
global $CFG_GLPI;
$ret = array();
$events = array() ;
if( isset($params['start']) ) {
$events = array();
if (isset($params['start'])) {
$params['begin'] = '2000-01-01 00:00:00';
if ($params['type'] == 'group') {
$params['who_group'] = $params['who'];
$params['whogroup'] = $params['who'];
$params['who'] = 0 ;
$params['who'] = 0;
}
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params );
foreach( $ret as $key => $event ) {
if( $event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
foreach ($ret as $key => $event) {
if ($event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
// check if task is one within a case
$pmTask = new self('TicketTask');
if( $pmTask->getFromDB( $event['tickettasks_id'] ) ) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
if ($pmTask->getFromDB( $event['tickettasks_id'] )) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
$event['editable'] = false;
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases' ;
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases';
$taskCat = new TaskCategory ;
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] ) ;
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '' ;
if( Session::haveTranslations('TaskCategory', 'comment') ) {
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment ) ;
$taskCat = new TaskCategory;
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] );
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '';
if (Session::haveTranslations('TaskCategory', 'comment')) {
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment );
}
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] ) ;
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ) ; //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] );
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ); //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
//if( $event['state'] == 1 && $event['end'] < $params['start'] ) { // if todo and late
// $event['name'] = $event['end'].' '.$event['name'] ; //$event['begin'].' to '.$event['end'].' '.$event['name'] ;
// $event['end'] = $params['start'].' 24:00:00'; //.$CFG_GLPI['planning_end'];
//}
$events[$key] = $event ;
$events[$key] = $event;
}
}
}
}
return $events ;
return $events;
}

View File

@@ -10,82 +10,81 @@
*/
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
die("Sorry. You can't access directly to this file");
}
class PluginProcessmakerTaskCategory extends CommonDBTM
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) {
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
global $LANG;
return $LANG['processmaker']['title'][3];
}
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(" ", "&nbsp;", $taskCat['name']);
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$taskCat['taskcategories_id'].")";
}
echo "</a></td><td >".str_replace(" ", "&nbsp;", $taskCat['completename'])."</td>
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(" ", "&nbsp;", $taskCat['name']);
if ($_SESSION["glpiis_ids_visible"]) {
echo " (".$taskCat['taskcategories_id'].")";
}
echo "</a></td><td >".str_replace(" ", "&nbsp;", $taskCat['completename'])."</td>
<td >".$taskCat['pm_task_guid']."</td>".
"<td>".($taskCat['start']?'x':'')."</td><td >".
$taskCat['comment']."</td></tr>";
}
echo "</table></div>";
$taskCat['comment']."</td></tr>";
}
echo "</table></div>";
return true;
}
return true;
}
/**
* Print a good title for task categories tab
* 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;
static function title(CommonGLPI $item) {
global $LANG, $CFG_GLPI;
$buttons = array();
$title = $LANG['processmaker']['config']['refreshtasklist'];
$buttons = array();
$title = $LANG['processmaker']['config']['refreshtasklist'];
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
$title = "";
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
$buttons);
}
}
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
$title = "";
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
$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
*
@@ -93,25 +92,25 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
*
* @return true if succeed else false
**/
function getFromDBbyExternalID($extid) {
global $DB;
function getFromDBbyExternalID($extid) {
global $DB;
$query = "SELECT *
$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;
}
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;
}
/**
* Retrieve a TaskCat from the database using its category id (unique index): taskcategories_id
*
@@ -119,23 +118,23 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
*
* @return true if succeed else false
**/
function getFromDBbyCategory($catid) {
global $DB;
function getFromDBbyCategory($catid) {
global $DB;
$query = "SELECT *
$query = "SELECT *
FROM `".$this->getTable()."`
WHERE `taskcategories_id` = $catid";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) != 1) {
return false;
}
$this->fields = $DB->fetch_assoc($result);
if (is_array($this->fields) && count($this->fields)) {
return true;
}
}
return false;
}
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;
}
}

View File

@@ -25,115 +25,107 @@ class PluginProcessmakerUser extends CommonDBTM {
*
* @return mysql result set.
**/
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
$used=array(), $search='', $limit='') {
global $DB, $PM_DB, $CFG_GLPI;
global $DB, $PM_DB, $CFG_GLPI;
// first need to get all users from $taskId
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
$pmQuery = "SELECT group_user.USR_UID as pm_user_id FROM task_user
JOIN group_user on group_user.GRP_UID=task_user.USR_UID AND task_user.TU_RELATION = 2 AND task_user.TU_TYPE=1
WHERE TAS_UID = '$taskId'; " ;
$pmUsers = array( ) ;
foreach( $PM_DB->request( $pmQuery ) as $pmUser ) {
$pmUsers[ ] = $pmUser[ 'pm_user_id' ] ;
}
// first need to get all users from $taskId
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
$pmQuery = "SELECT GROUP_USER.USR_UID AS pm_user_id FROM TASK_USER
JOIN GROUP_USER ON GROUP_USER.GRP_UID=TASK_USER.USR_UID AND TASK_USER.TU_RELATION = 2 AND TASK_USER.TU_TYPE=1
WHERE TAS_UID = '$taskId'; ";
$pmUsers = array( );
foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
$pmUsers[ ] = $pmUser[ 'pm_user_id' ];
}
$joinprofile = false;
switch ($right) {
case "id" :
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
break;
$joinprofile = false;
switch ($right) {
case "all" :
$where = " `glpi_users`.`id` > '1' ";
break;
}
case "id" :
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
break;
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
case "all" :
$where = " `glpi_users`.`id` > '1' " ;
break;
}
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') " ;
// $where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND TAS_UID = '$taskId' " ;
$where .= " AND `glpi_users`.`is_deleted` = '0'
$where .= " AND `glpi_users`.`is_deleted` = '0'
AND `glpi_users`.`is_active` = '1' ";
if ((is_numeric($value) && $value)
|| count($used)) {
if ((is_numeric($value) && $value)
|| count($used)) {
$where .= " AND `glpi_users`.`id` NOT IN (";
if (is_numeric($value)) {
$first = false;
$where .= $value;
$where .= " AND `glpi_users`.`id` NOT IN (";
if (is_numeric($value)) {
$first = false;
$where .= $value;
} else {
$first = true;
}
foreach ($used as $val) {
if ($first) {
$first = false;
} else {
$first = true;
$where .= ",";
}
foreach ($used as $val) {
if ($first) {
$first = false;
} else {
$where .= ",";
}
$where .= $val;
}
$where .= ")";
}
$where .= $val;
}
$where .= ")";
}
if ($count) {
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
} else {
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
}
if ($count) {
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
} else {
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
}
$query .= "FROM glpi_plugin_processmaker_users
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id " ;
//$query .= "from wf_workflow.task_user
// join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
// join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
// join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
$query .= "FROM glpi_plugin_processmaker_users
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id ";
$query .= " LEFT JOIN `glpi_useremails`
$query .= " LEFT JOIN `glpi_useremails`
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
$query .= " LEFT JOIN `glpi_profiles_users`
$query .= " LEFT JOIN `glpi_profiles_users`
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
if ($joinprofile) {
$query .= " LEFT JOIN `glpi_profiles`
if ($joinprofile) {
$query .= " LEFT JOIN `glpi_profiles`
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
}
}
if ($count) {
$query .= " WHERE $where ";
} else {
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
if ($count) {
$query .= " WHERE $where ";
} else {
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
Search::makeTextSearch($search).")";
}
$query .= " WHERE $where ";
Search::makeTextSearch($search).")";
}
$query .= " WHERE $where ";
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
$query.=" ORDER BY `glpi_users`.`firstname`,
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
$query.=" ORDER BY `glpi_users`.`firstname`,
`glpi_users`.`realname`,
`glpi_users`.`name` ";
} else {
$query.=" ORDER BY `glpi_users`.`realname`,
} else {
$query.=" ORDER BY `glpi_users`.`realname`,
`glpi_users`.`firstname`,
`glpi_users`.`name` ";
}
}
if ($search != $CFG_GLPI["ajax_wildcard"]) {
$query .= " $limit";
}
}
if ($search != $CFG_GLPI["ajax_wildcard"]) {
$query .= " $limit";
}
}
return $DB->query($query);
}
return $DB->query($query);
}
/**
@@ -166,12 +158,12 @@ class PluginProcessmakerUser extends CommonDBTM {
*
* @return int (print out an HTML select box)
**/
static function dropdown($options=array()) {
global $CFG_GLPI ;
static function dropdown($options=array()) {
global $CFG_GLPI;
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php' ;
return User::dropdown( $options ) ;
}
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php';
return User::dropdown( $options );
}
/**
@@ -180,13 +172,13 @@ class PluginProcessmakerUser extends CommonDBTM {
* @param string $pmUserId
* @return int GLPI user id, or 0 if not found
*/
public static function getGLPIUserId( $pmUserId ){
$obj = new self ;
if( $obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'") ) {
return $obj->fields['id'] ;
}
return 0 ;
}
public static function getGLPIUserId( $pmUserId ) {
$obj = new self;
if ($obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'")) {
return $obj->fields['id'];
}
return 0;
}
/**
* Summary of getPMUserId
@@ -194,13 +186,13 @@ class PluginProcessmakerUser extends CommonDBTM {
* @param int $glpi_userId id of user from GLPI database
* @return string which is the uid of user in Processmaker database, or false if not found
*/
public static function getPMUserId( $glpiUserId ) {
$obj = new self;
if( $obj->getFromDB( Toolbox::cleanInteger($glpiUserId) ) ) {
return $obj->fields['pm_users_id'] ;
}
return false ;
}
public static function getPMUserId( $glpiUserId ) {
$obj = new self;
if ($obj->getFromDB( Toolbox::cleanInteger($glpiUserId) )) {
return $obj->fields['pm_users_id'];
}
return false;
}
///**
// * Summary of getNewPassword

Some files were not shown because too many files have changed in this diff Show More