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,7 +6,7 @@
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
@@ -16,7 +16,6 @@ if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
//include_once dirname(__FILE__)."/../inc/process.class.php" ;
Session::checkLoginUser();
@@ -64,7 +63,7 @@ $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) ) ) {
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++;

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,7 +6,7 @@
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
if (strpos($_SERVER['PHP_SELF'], "task_users.php")) {
include ("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
@@ -16,26 +16,23 @@ if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
//include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
Session::checkLoginUser();
$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',
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
@@ -43,8 +40,7 @@ echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQ
'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>";
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,12 +1,7 @@
<?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);
@@ -17,7 +12,7 @@ if (isset($_POST["update"])) {
Html::back();
} elseif (isset($_POST["refresh"])) {
} else if (isset($_POST["refresh"])) {
$config->refresh($_POST); // used to refresh process list, task category list
Html::back();
}

View File

@@ -1,9 +1,8 @@
<?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"] = "";
@@ -16,19 +15,16 @@ if (isset($_REQUEST["update"])) {
$PluginProcess->update($_REQUEST);
Html::back();
} elseif (isset($_REQUEST["refreshtask"])) {
} else if (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) ;
Html::header($LANG['processmaker']['title'][1], $_SERVER["PHP_SELF"], "plugins", "processmaker");
// $PluginProcess->showForm($_REQUEST["id"]);
$PluginProcess->display($_REQUEST);
Html::footer();
}
?>

View File

@@ -1,14 +1,13 @@
<?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)) {
if (Session::haveRight("plugin_processmaker_config", READ) || Session::haveRight("config", UPDATE)) {
$process=new PluginProcessmakerProcess();
if( isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config",UPDATE) ) {
if (isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config", UPDATE)) {
$process->refresh();
Html::back();
}
@@ -22,4 +21,3 @@ if (Session::haveRight("plugin_processmaker_config",READ) || Session::haveRight(
}
Html::footer();
?>

View File

@@ -1,6 +1,5 @@
<?php
//define('GLPI_ROOT', '../../..');
include_once ("../../../inc/includes.php");
Session::checkCentralAccess();
@@ -11,7 +10,7 @@ $process = new PluginProcessmakerProcess();
if (isset($_POST["add"])) {
$right->check(-1,UPDATE,$_POST);
$right->check(-1, UPDATE, $_POST);
if ($right->add($_POST)) {
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
@@ -23,7 +22,7 @@ if (isset($_POST["add"])) {
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($right->can($key,UPDATE)) {
if ($right->can($key, UPDATE)) {
$right->delete(array('id' => $key));
}
}
@@ -37,6 +36,4 @@ if (isset($_POST["add"])) {
}
Html::displayErrorAndDie("lost");
?>

View File

@@ -1,40 +1,38 @@
<?php
include_once ("../../../inc/includes.php");
//include_once '../inc/processmaker.class.php' ;
//include_once '../inc/cases.class.php' ;
switch( $_POST["action"] ) {
switch ($_POST["action"]) {
case 'newcase':
if( isset($_POST['id']) && $_POST['id'] > 0 ) { // then this case will be bound to an item
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();
$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() ) ;
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() );
if ($resultCase->status_code == 0){
if ($resultCase->status_code == 0) {
Html::back();
}
else
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
} else
}
} 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() ;
} 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){
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) );
if ($resultCase->status_code == 0) {
// case is created
// Must show it...
//
$rand = rand( ) ;
$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 {
@@ -46,77 +44,78 @@ switch( $_POST["action"] ) {
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){
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
} else {
echo "Error unpausing case: ".$pmResultUnpause->message." \n";
}
else if( isset( $_POST['reassign'] ) ) {
} 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( ) ;
$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){
$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 ;
$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'] ) ;
$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
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
} else
}
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['assignedtoyou'], true, ERROR); // Html::back();
}
else if( isset($_POST['delete']) ) {
} 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() ) {
$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'] ) ;
$myProcessMaker = new PluginProcessmakerProcessmaker();
$myProcessMaker->login(true);
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] );
if( $resultPM->status_code == 0 ) {
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
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
}
else if( isset($_POST['cancel']) ) {
} 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() )
$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
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
} else
}
} else {
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
}
}
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");

View File

@@ -16,7 +16,6 @@ function plugin_processmaker_MassiveActions($type) {
return array('purge' => $LANG['processmaker']['process']['profile']);
}
break;
}
return array();
}
@@ -43,7 +42,6 @@ function plugin_processmaker_MassiveActionsDisplay($options) {
function plugin_processmaker_MassiveActionsProcess($data) {
//global $LANG,$DB;
switch ($data['action']) {
@@ -423,7 +421,6 @@ 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', 'pmtaskactions', MINUTE_TIMESTAMP, array('state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
@@ -487,11 +484,11 @@ function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,
$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 "";
break;
}
return "";
@@ -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);
//}
}
}
}

View File

@@ -10,55 +10,62 @@
*/
class PluginProcessmakerCase extends CommonDBTM {
/**
* Summary of getTabNameForItem
* @param CommonGLPI $item is the item
* @param mixed $withtemplate has template
* @return array os strings
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
$item_id = $item->getID() ;
$item_type = $item->getType() ;
if( self::getCaseFromItemTypeAndItemId($item_type, $item_id ) ){
$item_id = $item->getID();
$item_type = $item->getType();
if (self::getCaseFromItemTypeAndItemId($item_type, $item_id )) {
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
} else
} else {
return array( 'processmakercases' => $LANG['processmaker']['item']['tab'] );
}
}
/**
* Summary of getCaseIdFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @return mixed
* @param mixed $itemType is the item type
* @param mixed $itemId is the item id
* @return mixed case id
*/
static function getCaseIdFromItemTypeAndItemId( $itemType, $itemId) {
global $DB;
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';" ;
if( ($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';";
if (($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
$row = $DB->fetch_array($res);
return $row['id'] ;
return $row['id'];
}
return false ;
return false;
}
/**
* Summary of getCaseFromItemTypeAndItemId
* @param mixed $itemType
* @param mixed $itemId
* @param mixed $itemType is the item type
* @param mixed $itemId is the item id
* @return mixed: returns false when there is no case associated with the item, else fills in the item fields from DB, and returns true
*/
function getCaseFromItemTypeAndItemId($itemType, $itemId) {
if( $caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId) )
return $this->getFromDB( $caseId ) ;
if ($caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId)) {
return $this->getFromDB( $caseId );
}
return false ;
return false;
}
/**
* Summary of getFromDB
* @param mixed $ID
* @return mixed
* @param mixed $ID id of needed object
* @return mixed object if found, else false
*/
function getFromDB($ID) {
global $DB;
@@ -73,7 +80,7 @@ class PluginProcessmakerCase extends CommonDBTM {
FROM `".$this->getTable()."`
WHERE `".$this->getIndexName()."` = '".$ID."'";
if ( ($result = $DB->query($query)) && $DB->numrows($result)==1) {
if (($result = $DB->query($query)) && $DB->numrows($result)==1) {
$this->fields = $DB->fetch_assoc($result);
$this->post_getFromDB();
@@ -88,25 +95,25 @@ class PluginProcessmakerCase extends CommonDBTM {
* Summary of getVariables
* Gets variables from a case.
* @param array $vars an array of variable name that will be read from the case as case variables
* @return an associative array (variable_name => value). The returned array can be empty if requested variables are not found.
* @return array an associative array (variable_name => value). The returned array can be empty if requested variables are not found.
*/
function getVariables( $vars = array() ) {
global $PM_DB ;
global $PM_DB;
$locVars = array( ) ;
$app_data = array() ; // by default
$locVars = array( );
$app_data = array(); // by default
$caseId = $this->getID() ;
$caseId = $this->getID();
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
$query = "SELECT APP_DATA FROM APPLICATION WHERE APP_UID='$caseId';";
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
if (($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
$row = $PM_DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
$locVars = array_intersect_key( $app_data, array_flip($vars) ) ;
$app_data = unserialize($row['APP_DATA'] );
$locVars = array_intersect_key( $app_data, array_flip($vars) );
}
return $locVars ;
return $locVars;
}
/**
@@ -118,51 +125,50 @@ class PluginProcessmakerCase extends CommonDBTM {
* @return true if variables have been saved to the case, false otherwise
*/
function sendVariables( $vars = array() ) {
global $PM_DB ;
global $PM_DB;
$variablesSent = false ; // be default
$app_data = array() ; // by default
$variablesSent = false; // be default
$app_data = array(); // by default
$caseId = $this->getID() ;
$caseId = $this->getID();
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
$query = "SELECT APP_DATA FROM APPLICATION WHERE APP_UID='$caseId';";
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
if (($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
$row = $PM_DB->fetch_assoc($res);
$app_data = unserialize($row['APP_DATA'] ) ;
$app_data = unserialize($row['APP_DATA'] );
}
$app_data = array_replace( $app_data, $vars ) ;
$serialized = serialize( $app_data ) ;
$app_data = array_replace( $app_data, $vars );
$serialized = serialize( $app_data );
$query = "UPDATE application SET APP_DATA='$serialized' WHERE APP_UID='$caseId';" ;
$res = $PM_DB->query( $query ) ;
$query = "UPDATE APPLICATION SET APP_DATA='$serialized' WHERE APP_UID='$caseId';";
$res = $PM_DB->query( $query );
if( $PM_DB->affected_rows() == 1 ) {
$variablesSent = true ;
if ($PM_DB->affected_rows() == 1) {
$variablesSent = true;
}
return $variablesSent ;
return $variablesSent;
}
/**
* Summary of displayTabContentForItem
* @param CommonGLPI $item
* @param mixed $tabnum
* @param mixed $withtemplate
* @param CommonGLPI $item is the item
* @param mixed $tabnum is the tab num
* @param mixed $withtemplate has template
* @return mixed
*/
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG, $DB, $CFG_GLPI ;
global $LANG, $DB, $CFG_GLPI;
$config = PluginProcessmakerConfig::getInstance() ;
$config = PluginProcessmakerConfig::getInstance();
if( $config->fields['maintenance'] == 0 ) {
if ($config->fields['maintenance'] == 0) {
$item_id = $item->getID() ;
$item_type = $item->getType() ;
$item_id = $item->getID();
$item_type = $item->getType();
////retrieve container for current tab
//$container = new self;
//$found_c = $container->find("`itemtype` = '$item_type' AND `items_id` = $item_id ");
@@ -171,62 +177,47 @@ class PluginProcessmakerCase extends CommonDBTM {
$rand = rand();
echo "<form style='margin-bottom: 0px' name='processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
echo "<div class='center'> <table id='processmakercasemenu' style='margin-bottom: 0px' class='tab_cadre_fixe'>";
echo Html::scriptBlock("$('#processmakercasemenu').css('max-width', 'none');") ;
echo Html::scriptBlock("$('#processmakercasemenu').css('max-width', 'none');");
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['tab']."</th></tr>";
$pmCaseUser = false ; // initial value: no user
$pmCaseUser = false; // initial value: no user
// first search for the case
if( self::getCaseIdFromItemTypeAndItemId($item_type, $item_id ) ){
$myProcessMaker = new PluginProcessmakerProcessmaker( ) ;
if (self::getCaseIdFromItemTypeAndItemId($item_type, $item_id )) {
$myProcessMaker = new PluginProcessmakerProcessmaker( );
$myProcessMaker->login();
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id ) ;
if( $caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED' ) {
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id );
if ($caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED') {
// need to get info on the thread of the GLPI current user
// we must retreive currentGLPI user from this array
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ) ;
$pmCaseUser = $caseInfo->currentUsers[0] ; // by default currently manage only one task at a time, must define tab management for several tasks
foreach( $caseInfo->currentUsers as $caseUser) {
if( $caseUser->userId == $GLPICurrentPMUserId ){
$pmCaseUser = $caseUser ;
break ;
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
$pmCaseUser = $caseInfo->currentUsers[0]; // by default currently manage only one task at a time, must define tab management for several tasks
foreach ($caseInfo->currentUsers as $caseUser) {
if ($caseUser->userId == $GLPICurrentPMUserId) {
$pmCaseUser = $caseUser;
break;
}
}
//if( $pmCaseUser->delThreadStatus == 'PAUSE' ) {
// // means the case itself may not be PAUSED, but task assigned to current GLPI user is paused...
// // then forced PAUSE view for this thread
// // and give possibility to unpause it
// $caseInfo->caseStatus = 'PAUSED' ;
//}
}
$locDelIndex = 1 ; // by default
switch ( $caseInfo->caseStatus ) {
$locDelIndex = 1; // by default
switch ($caseInfo->caseStatus) {
case "CANCELLED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['cancelledcase']."</th></tr>";
$paramsURL = "DEL_INDEX=1" ;
$paramsURL = "DEL_INDEX=1";
// echo "<tr class='tab_bg_1' ><td id='GLPI-PM-DEL_INDEX' ><script>var GLPI_DEL_INDEX = 1; </script></td></tr>" ;
break;
//case 'PAUSED' :
// // we need to add a button to unpause the case
// //echo "<input type='hidden' name='id' value='$item_id'>";
// //echo "<input type='hidden' name='itemtype' value='$item_type'>";
// //echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
// //echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
// //echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
// echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['pausedtask']."</th><th>";
// echo "<input type='submit' name='unpausecase' value='".$LANG['processmaker']['item']['unpause']."' class='submit'>";
// echo "</th></tr>";
case "DRAFT" :
case "TO_DO" :
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
$locDelIndex = $pmCaseUser->delIndex ;
if( $pmCaseUser->userId != '' ) {
echo "<tr class='tab_bg_1'>" ;
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus;
$locDelIndex = $pmCaseUser->delIndex;
if ($pmCaseUser->userId != '') {
echo "<tr class='tab_bg_1'>";
if( $GLPICurrentPMUserId == $pmCaseUser->userId) {
if ($GLPICurrentPMUserId == $pmCaseUser->userId) {
// then propose a button to cancel case only when assigned user is == to glpi current user
echo "<td class='tab_bg_2' >";
echo $LANG['processmaker']['item']['cancelcase'] ;
echo $LANG['processmaker']['item']['cancelcase'];
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
@@ -236,10 +227,10 @@ class PluginProcessmakerCase extends CommonDBTM {
echo "</td>";
}
if( $caseInfo->caseStatus == "DRAFT" || (plugin_processmaker_haveRight("deletecase", DELETE) && $_SESSION['glpiactiveprofile']['interface'] == 'central') ) {
if ($caseInfo->caseStatus == "DRAFT" || (plugin_processmaker_haveRight("deletecase", DELETE) && $_SESSION['glpiactiveprofile']['interface'] == 'central')) {
// then propose a button to delete case
echo "<td class='tab_bg_2'>";
echo $LANG['processmaker']['item']['deletecase'] ;
echo $LANG['processmaker']['item']['deletecase'];
echo "</td><td class='tab_bg_2'>";
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
@@ -250,25 +241,23 @@ class PluginProcessmakerCase extends CommonDBTM {
}
//echo "<td class='tab_bg_2' colspan='1'>";
echo "</form>";
echo "</td></tr>";
}
break ;
break;
case "COMPLETED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
$paramsURL = "DEL_INDEX=" ; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
break ;
$paramsURL = "DEL_INDEX="; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
break;
}
$proj = new PluginProcessmakerProcess ;
$proj->getFromDBbyExternalID( $caseInfo->processId ) ;
$project_type = $proj->fields['project_type'] ;
$proj = new PluginProcessmakerProcess;
$proj->getFromDBbyExternalID( $caseInfo->processId );
$project_type = $proj->fields['project_type'];
// then propose a button to view case history
echo "<tr class='tab_bg_1' >" ;
echo "<tr class='tab_bg_1' >";
echo "<td class='tab_bg_2' colspan='1'>";
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
echo "</td>";
@@ -283,25 +272,25 @@ class PluginProcessmakerCase extends CommonDBTM {
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>" ; //?rand=$rand'
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
// processmakertabpaneltable is used to align the tabs
echo "<table id=processmakertabpaneltable style='margin-bottom: 0px; width:100%;' class='tab_cadre_fixe'>";
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');") ;
echo "<tr><td>" ;
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');");
echo "<tr><td>";
//
// Processmaker tab panels
// need to have a global variable which contains tab id
// used only one time for activated panel
$arrayProcessmakerTabPanel = array() ;
$arrayProcessmakerTabPanel = array();
echo "<div id=processmakertabpanel >";
// first define tabs
echo " <ul>";
//echo " <li><a href='#tabs-1'>Nunc tincidunt</a></li>";
$arrayProcessmakerTabPanel[] = "tabs-1";
if( $pmCaseUser ) {
foreach($caseInfo->currentUsers as $caseUser) {
if ($pmCaseUser) {
foreach ($caseInfo->currentUsers as $caseUser) {
echo "<li><a href='#task-".$caseUser->delIndex."'>".($caseUser->userId != $GLPICurrentPMUserId?"<i><sub>".$LANG['processmaker']['item']['task']['task'].$caseUser->taskName."</sub></i>":$LANG['processmaker']['item']['task']['task'].$caseUser->taskName)."</a></li>";
$arrayProcessmakerTabPanel[] = "task-".$caseUser->delIndex;
}
@@ -317,35 +306,35 @@ class PluginProcessmakerCase extends CommonDBTM {
//echo "<div id='tabs-1'>
// <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
// </div>";
if( $pmCaseUser ) {
$csrf = Session::getNewCSRFToken() ;
foreach($caseInfo->currentUsers as $caseUser) {
if ($pmCaseUser) {
$csrf = Session::getNewCSRFToken();
foreach ($caseInfo->currentUsers as $caseUser) {
// for each task, if task is to be claimed, we need to verify that current user can claim it by checking if he/she is in the group assigned to the task
$hide_claim_button=false; // by default
if( !$caseUser->userId ) {
if (!$caseUser->userId) {
// current task is to claimed
// get task user list
$query = "SELECT items_id, itemtype FROM glpi_plugin_processmaker_tasks WHERE case_id = '".$caseInfo->caseId."' AND del_index =".$caseUser->delIndex;
foreach( $DB->request($query) as $row ) {
foreach ($DB->request($query) as $row) {
// normally there is only one task
$task = getItemForItemtype( $row['itemtype'] ) ;
$task->getFromDB( $row['items_id'] ) ;
$task = getItemForItemtype( $row['itemtype'] );
$task->getFromDB( $row['items_id'] );
// check if this group can be found in the current user's groups
if( !isset($_SESSION['glpigroups']) || !in_array( $task->fields['groups_id_tech'], $_SESSION['glpigroups'] ) ) {
if (!isset($_SESSION['glpigroups']) || !in_array( $task->fields['groups_id_tech'], $_SESSION['glpigroups'] )) {
$hide_claim_button=true;
}
}
}
echo "<div id='task-".$caseUser->delIndex."'>";
// to load users for task re-assign only when task is not to be 'claimed'
if( $caseUser->userId ) {
if ($caseUser->userId) {
echo "<div class='tab_bg_2' id='divUsers-".$caseUser->delIndex."' >Loading...</div>";
echo "<script>$('#divUsers-".$caseUser->delIndex."').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand' ); </script>" ;
echo "<script>$('#divUsers-".$caseUser->delIndex."').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand' ); </script>";
}
echo "<iframe id='caseiframe-task-".$caseUser->delIndex."' onload='onTaskFrameLoad( event, ".$caseUser->delIndex.", ".($hide_claim_button?"true":"false").", \"$csrf\" );' style='border:none;' class='tab_bg_2' width='100%' src='";
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO" ;
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO";
//if( $caseUser->userId == $GLPICurrentPMUserId || $caseUser->userId == '' ) {
echo $url ;
echo $url;
//} else {
// echo $CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_resume.php?username=".urlencode( $caseUser->userName )."&taskname=".urlencode( $caseUser->taskName )."&url=".urlencode( $url ) ;
//}
@@ -355,20 +344,20 @@ class PluginProcessmakerCase extends CommonDBTM {
// no user means CANCELLED or COMPLETED
// then create artificial panel to host case infos
echo "<div id='caseInfo'>";
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO" ;
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO";
echo "<iframe id=\"caseiframe-caseInfo\" onload=\"onOtherFrameLoad( 'caseInfo', 'caseiframe-caseInfo', 'body' );\" style=\"border:none;\" class=\"tab_bg_2\" width=\"100%\" src=\"$url&rand=$rand\"></iframe></div>";
}
echo "</div>" ;
echo "</div>";
// end of tabs/panels
echo "</td></tr>";
echo "<tr class='tab_bg_1' ><td colspan=4 >" ;
if( $pmCaseUser ) {
$activePanel = 'task-'.$pmCaseUser->delIndex ;
echo "<tr class='tab_bg_1' ><td colspan=4 >";
if ($pmCaseUser) {
$activePanel = 'task-'.$pmCaseUser->delIndex;
} else {
$activePanel = 'caseInfo' ;
$activePanel = 'caseInfo';
}
$caseMapUrl = $myProcessMaker->serverURL.($project_type=='bpmn' ? "/designer?prj_uid=".$caseInfo->processId."&prj_readonly=true&app_uid=".$caseInfo->caseId : "/cases/ajaxListener?action=processMap&rand=$rand") ;
$caseMapUrl = $myProcessMaker->serverURL.($project_type=='bpmn' ? "/designer?prj_uid=".$caseInfo->processId."&prj_readonly=true&app_uid=".$caseInfo->caseId : "/cases/ajaxListener?action=processMap&rand=$rand");
echo "<script>
function addTabPanel( name, title, html ){
//debugger ;
@@ -502,16 +491,12 @@ class PluginProcessmakerCase extends CommonDBTM {
}
});
" ;
";
echo "});
";
echo "</script>";
//////echo "<iframe id='caseiframe' onload='onGLPILoadFrame( event ) ;' height='1080px' style='border:none;' width='100%' src='".$myProcessMaker->serverURL."/cases/open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand' >" ;
@@ -524,10 +509,10 @@ class PluginProcessmakerCase extends CommonDBTM {
// no running case for this ticket
// propose to start one
//********************************
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'] ;
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'];
// check if item is not solved nor closed
if( $item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk' ) {
if ($item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
// propose case start
echo "&nbsp;-&nbsp;".$LANG['processmaker']['item']['startone'];
echo "</th></tr>";
@@ -542,12 +527,13 @@ class PluginProcessmakerCase extends CommonDBTM {
echo "</td><td class='tab_bg_2'>";
echo "<input type='submit' name='additem' value='".$LANG['processmaker']['item']['start']."' class='submit'>";
echo "</td></tr>";
} else {
echo "</th></tr>";
}
else echo "</th></tr>";
}
echo "</table>";
Html::closeForm(true ) ;
Html::closeForm(true );
//echo "</form>";
} else {
@@ -555,7 +541,7 @@ class PluginProcessmakerCase extends CommonDBTM {
echo $LANG['processmaker']['config']['undermaintenance'];
}
return true ;
return true;
}
/**
@@ -564,16 +550,17 @@ class PluginProcessmakerCase extends CommonDBTM {
* @return true if tasks have been deleted from associated item and from case table
*/
private function deleteTasks( ) {
global $DB ;
$ret = false ;
global $DB;
$ret = false;
$query = "DELETE from glpi_".$this->fields['itemtype']."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
if ($DB->query( $query )) {
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
if( $DB->query( $query ) )
$ret = true ;
if ($DB->query( $query )) {
$ret = true;
}
return $ret ;
}
return $ret;
}
@@ -583,13 +570,15 @@ class PluginProcessmakerCase extends CommonDBTM {
* @return true if case and tasks have been deleted from associated item and from case table
*/
function deleteCase( ) {
global $DB ;
$ret = false ;
global $DB;
$ret = false;
if( $this->deleteTasks() )
if( $this->deleteFromDB( ) )
$ret = true ;
return $ret ;
if ($this->deleteTasks()) {
if ($this->deleteFromDB( )) {
$ret = true;
}
}
return $ret;
}
@@ -601,16 +590,16 @@ class PluginProcessmakerCase extends CommonDBTM {
* @return true if tasks have been deleted from associated item and from case table
*/
private function cancelTasks( ) {
global $DB ;
$ret = false ;
global $DB;
$ret = false;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" ) {
if (isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO") {
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
if( $DB->query( $query ) ) {
$ret = true ;
if ($DB->query( $query )) {
$ret = true;
}
}
return $ret ;
return $ret;
}
@@ -622,34 +611,37 @@ class PluginProcessmakerCase extends CommonDBTM {
* @return true if case and tasks have been cancelled or marked from associated item and from case table
*/
function cancelCase( ) {
global $DB ;
$ret = false ;
global $DB;
$ret = false;
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" )
if( $this->cancelTasks() )
if( $this->update( array( 'id' => $this->getID(), 'case_status' => 'CANCELLED' ) ) )
if (isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO") {
if ($this->cancelTasks()) {
if ($this->update( array( 'id' => $this->getID(), 'case_status' => 'CANCELLED' ) )) {
$ret=true;
}
}
}
return $ret ;
return $ret;
}
/**
* Summary of canSolve
* To know if a Ticket (Problem or Change) can be solved
* i.e. the case permits solving of item
* @param mixed $parm
* @return bool
* @param mixed $item is the item
* @return bool true to permit solve, false otherwise
*/
public static function canSolve ($parm) {
public static function canSolve ($item) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm['item']->getType(), $parm['item']->getID() ) ) {
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) ) ;
if( $myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1) ) {
if ($myCase->getCaseFromItemTypeAndItemId( $item['item']->getType(), $item['item']->getID() )) {
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) );
if ($myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1)) {
// then item can't be solved
return false ;
return false;
}
}
return true ;
return true;
}
/**
@@ -660,8 +652,8 @@ class PluginProcessmakerCase extends CommonDBTM {
public static function getToDoTasks($parm) {
$myCase = new self;
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
return PluginProcessmakerTask::getToDoTasks( $myCase->getID(), $parm->getType()."Task" ) ;
if ($myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() )) {
return PluginProcessmakerTask::getToDoTasks( $myCase->getID(), $parm->getType()."Task" );
}
return array();
}

View File

@@ -5,26 +5,47 @@
class PluginProcessmakerConfig extends CommonDBTM {
static private $_instance = NULL;
//static private $db = NULL ;
/**
* Summary of canCreate
* @return boolean
*/
static function canCreate() {
return Session::haveRight('config', UPDATE);
}
/**
* Summary of canView
* @return boolean
*/
static function canView() {
return Session::haveRight('config', READ);
}
/**
* Summary of canUpdate
* @return boolean
*/
static function canUpdate() {
return Session::haveRight('config', UPDATE);
}
/**
* Summary of getTypeName
* @param mixed $nb plural
* @return mixed
*/
static function getTypeName($nb=0) {
global $LANG;
return $LANG['processmaker']['config']['setup'];
}
/**
* Summary of getName
* @param mixed $with_comment with comment
* @return mixed
*/
function getName($with_comment=0) {
global $LANG;
@@ -32,7 +53,8 @@ class PluginProcessmakerConfig extends CommonDBTM {
}
/**
* Singleton for the unique config record
* Summary of getInstance
* @return PluginProcessmakerConfig
*/
static function getInstance() {
@@ -47,16 +69,14 @@ class PluginProcessmakerConfig extends CommonDBTM {
/**
* Prepare input datas for updating the item
*
* @param $input array used to update the item
*
* @param array $input used to update the item
* @return array the modified $input array
**/
function prepareInputForUpdate($input) {
global $CFG_GLPI;
if( !isset($input["maintenance"]) ) {
$input["maintenance"] = 0 ;
if (!isset($input["maintenance"])) {
$input["maintenance"] = 0;
}
if (isset($input["pm_dbserver_passwd"])) {
@@ -83,38 +103,43 @@ class PluginProcessmakerConfig extends CommonDBTM {
$input['pm_admin_passwd'] = '';
}
$input['domain'] = self::getCommonDomain( $CFG_GLPI['url_base'], $input['pm_server_URL'] ) ;
$input['domain'] = self::getCommonDomain( $CFG_GLPI['url_base'], $input['pm_server_URL'] );
return $input;
}
/**
* Summary of getCommonDomain
* @param mixed $url1
* @param mixed $url2
* @param mixed $url1 first url
* @param mixed $url2 second url
* @return string the common domain part of the given urls
*/
static function getCommonDomain($url1, $url2) {
$domain = '';
try {
$glpi = explode( "/", $url1) ;
$glpi = explode( ".", $glpi[2] );
$pm = explode( "/", $url2) ;
$pm = explode( ".", $pm[2] );
$cglpi = array_shift(explode(":", array_pop( $glpi ))) ;
$cpm = array_shift(explode(":", array_pop( $pm))) ;
while( $cglpi && $cpm && $cglpi == $cpm ) {
$domain = $cglpi.($domain==''?'':'.'.$domain) ;
$cglpi = array_pop( $glpi ) ;
$cpm = array_pop( $pm ) ;
$glpi = explode(".", parse_url($url1, PHP_URL_HOST));
$pm = explode( ".", parse_url($url2, PHP_URL_HOST));
$cglpi = array_pop( $glpi );
$cpm = array_pop( $pm );
while ($cglpi && $cpm && $cglpi == $cpm) {
$domain = $cglpi.($domain==''?'':'.'.$domain);
$cglpi = array_pop( $glpi );
$cpm = array_pop( $pm );
}
if( $domain != '' ) {
return $domain ;
if ($domain != '') {
return $domain;
}
} catch(Exception $e) {}
return '';
} catch (Exception $e) {
$domain = '';
}
return $domain;
}
/**
* Summary of showConfigForm
* @param mixed $item is the config
* @return boolean
*/
static function showConfigForm($item) {
global $LANG, $PM_DB, $CFG_GLPI;
@@ -129,7 +154,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['URL']."</td><td >";
echo "<input size='50' type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>" ;
echo "<input size='50' type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
@@ -138,13 +163,19 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo Html::scriptBlock("
function setCommonDomain() {
//debugger;
function parseUrl( url ) {
var a = document.createElement('a');
a.href = url;
// debugger;
return { host: a.hostname, port: a.port, scheme: a.protocol.slice(0, -1), path: a.pathname, query: a.search.slice(1), fragment: a.hash.slice(1) } ;
}
var domain = '';
try {
var glpi= '".$CFG_GLPI['url_base']."'.split('/')[2].split('.') ;
var pm = $('input[name=pm_server_URL]').val().split('/')[2].split('.');
var cglpi = glpi.pop().split(':')[0] ;
var cpm = pm.pop().split(':')[0] ;
var glpi = parseUrl( '".$CFG_GLPI['url_base']."' ).host.split('.') ;
var pm = parseUrl( $('input[name=pm_server_URL]').val()).host.split('.');
var cglpi = glpi.pop() ;
var cpm = pm.pop() ;
while( cglpi && cpm && cglpi == cpm ) {
domain = cglpi + (domain==''?'':'.' + domain) ;
cglpi = glpi.pop() ;
@@ -164,10 +195,9 @@ class PluginProcessmakerConfig extends CommonDBTM {
");
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['workspace']."</td><td >";
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>" ;
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>";
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
@@ -183,15 +213,15 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
$pm = new PluginProcessmakerProcessmaker ;
//$pmconnected=false ; // by default
if( $config->fields['pm_server_URL'] != ''
$pm = new PluginProcessmakerProcessmaker;
if ($config->fields['pm_server_URL'] != ''
&& $config->fields['pm_workspace'] != ''
&& $config->fields["pm_admin_user"] != ''
&& ($pm->login(true))) {
echo "<font color='green'>".__('Test successful');
} else {
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror,true);
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror, true);
}
echo "</font></span></td></tr>\n";
@@ -215,7 +245,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
if( $PM_DB->connected ) {
if ($PM_DB->connected) {
echo "<font color='green'>".__('Test successful');
} else {
echo "<font color='red'>".__('Test failed');
@@ -239,7 +269,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['taskwriter']."</td><td >";
$rand = mt_rand() ;
$rand = mt_rand();
User::dropdown(array('name' => 'users_id',
'display_emptychoice' => true,
'right' => 'all',
@@ -260,13 +290,13 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['config']['pm_group_name']."</td><td >";
$pmGroups = array( 0 => Dropdown::EMPTY_VALUE ) ;
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM content WHERE CON_CATEGORY='GRP_TITLE' AND CON_LANG='".$pm->lang."' ORDER BY CON_VALUE;" ;
if( $PM_DB->connected ) {
foreach( $PM_DB->request( $query ) as $row ) {
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'] ;
$pmGroups = array( 0 => Dropdown::EMPTY_VALUE );
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE' AND CON_LANG='".$pm->lang."' ORDER BY CON_VALUE;";
if ($PM_DB->connected) {
foreach ($PM_DB->request( $query ) as $row) {
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
}
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, array('value' => $config->fields['pm_group_guid']) ) ;
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, array('value' => $config->fields['pm_group_guid']) );
} else {
echo "<font color='red'>".__('Not connected');
}
@@ -304,5 +334,4 @@ class PluginProcessmakerConfig extends CommonDBTM {
return true;
}
}

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 = 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->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'] ;
$this->dbdefault = "wf_".$config->fields['pm_workspace'];
parent::__construct();
}
}
}
}

View File

@@ -36,108 +36,110 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
function maybeDeleted(){
return false ;
function maybeDeleted() {
return false;
}
/**
* Summary of refreshTasks
* will refresh (re-synch) all process task list
* @param array $post is the $_POST
* @return void
*/
function refreshTasks( $post ) {
global $PM_DB, $CFG_GLPI ;
global $PM_DB, $CFG_GLPI;
if( $this->getFromDB( $post['id'] ) ) {
if ($this->getFromDB( $post['id'] )) {
// here we are in the right process
// we need to get the tasks + content from PM db
//$config = PluginProcessmakerConfig::getInstance() ;
//$database = $config->fields['pm_workspace'] ;
$translates = false ;
$mapLangs = array( ) ;
if( TableExists( 'glpi_dropdowntranslations' ) && class_exists('DropdownTranslation') ){
$translates = false;
$mapLangs = array( );
if (TableExists( 'glpi_dropdowntranslations' ) && class_exists('DropdownTranslation')) {
// to force rigths to add translations
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name' ;
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['completename'] = 'completename' ;
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['comment'] = 'comment' ;
$translates = true ;
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name';
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['completename'] = 'completename';
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['comment'] = 'comment';
$translates = true;
// create a reversed map for languages
foreach( $CFG_GLPI['languages'] as $key => $valArray){
$mapLangs[ locale_get_primary_language( $key ) ][] = $key ;
foreach ($CFG_GLPI['languages'] as $key => $valArray) {
$mapLangs[ locale_get_primary_language( $key ) ][] = $key;
}
}
$lang = locale_get_primary_language( $CFG_GLPI['language'] ) ; // $CFG_GLPI['languages'][ $CFG_GLPI['language'] ][ 3 ] ;
$query = "select task.TAS_UID, task.TAS_START, content.CON_LANG, content.CON_CATEGORY, content.CON_VALUE from task
inner join content on content.CON_ID=task.TAS_UID
where task.PRO_UID = '".$this->fields['process_guid']."' and content.CON_CATEGORY in ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates?"":"and content.CON_LANG='$lang'")." ;" ;
$taskArray = array() ;
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
WHERE TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
$taskArray = array();
$defaultLangTaskArray=array();
foreach( $PM_DB->request( $query ) as $task ) {
if( $task['CON_LANG'] == $lang ) {
$defaultLangTaskArray[ $task['TAS_UID'] ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'] ;
foreach ($PM_DB->request( $query ) as $task) {
if ($task['CON_LANG'] == $lang) {
$defaultLangTaskArray[ $task['TAS_UID'] ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
$defaultLangTaskArray[ $task['TAS_UID'] ]['start']=($task['TAS_START']=='TRUE'?true:false);
} else {
foreach( $mapLangs[ $task['CON_LANG'] ] as $valL ) {
$taskArray[ $task['TAS_UID'] ][ $valL ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'] ;
foreach ($mapLangs[ $task['CON_LANG'] ] as $valL) {
$taskArray[ $task['TAS_UID'] ][ $valL ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
}
}
}
foreach( $defaultLangTaskArray as $taskGUID => $task ) {
$pmTaskCat = new PluginProcessmakerTaskCategory ;
$taskCat = new TaskCategory ;
if( $pmTaskCat->getFromDBbyExternalID( $taskGUID ) ){
foreach ($defaultLangTaskArray as $taskGUID => $task) {
$pmTaskCat = new PluginProcessmakerTaskCategory;
$taskCat = new TaskCategory;
if ($pmTaskCat->getFromDBbyExternalID( $taskGUID )) {
// got it then check names, and if != update
if( $taskCat->getFromDB( $pmTaskCat->fields['taskcategories_id'] ) ) {
if ($taskCat->getFromDB( $pmTaskCat->fields['taskcategories_id'] )) {
// found it must test if should be updated
if( $taskCat->fields['name'] != $task['TAS_TITLE'] || $taskCat->fields['comment'] != $task['TAS_DESCRIPTION'] ) {
$taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) ) ;
if ($taskCat->fields['name'] != $task['TAS_TITLE'] || $taskCat->fields['comment'] != $task['TAS_DESCRIPTION']) {
$taskCat->update( array( 'id' => $taskCat->getID(), 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
}
if( $pmTaskCat->fields['start'] != $task['start'] ) {
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'start' => $task['start'] ) ) ;
if ($pmTaskCat->fields['start'] != $task['start']) {
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'start' => $task['start'] ) );
}
} else {
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) ) ;
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// update pmTaskCat
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) ) ;
$pmTaskCat->update( array( 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
}
} else {
// should create a new one
// taskcat must be created
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) ) ;
$taskCat->add( array( 'is_recursive' => true, 'name' => $task['TAS_TITLE'], 'comment' => $task['TAS_DESCRIPTION'], 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
// pmTaskCat must be created too
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) ) ;
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
}
// here we should take into account translations if any
if( $translates && isset($taskArray[ $taskGUID ]) ) {
foreach( $taskArray[ $taskGUID ] as $langTask => $taskL ) {
if ($translates && isset($taskArray[ $taskGUID ])) {
foreach ($taskArray[ $taskGUID ] as $langTask => $taskL) {
// look for 'name' field
if( $loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'name', $langTask ) ) {
if( DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'name', $langTask ) != $taskL[ 'TAS_TITLE' ] ) {
if ($loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'name', $langTask )) {
if (DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'name', $langTask ) != $taskL[ 'TAS_TITLE' ]) {
// must be updated
$trans = new DropdownTranslation ;
$trans->update( array( 'id' => $loc_id, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]), 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) ) ;
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) ) ;
$trans = new DropdownTranslation;
$trans->update( array( 'id' => $loc_id, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]), 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) );
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask ) );
}
} else {
// must be added
// must be updated
$trans = new DropdownTranslation ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]) ) ) ;
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(),'language' => $langTask ) ) ;
$trans = new DropdownTranslation;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'name', 'value' => $PM_DB->escape($taskL[ 'TAS_TITLE' ]) ) );
$trans->generateCompletename( array( 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(),'language' => $langTask ) );
}
// look for 'comment' field
if( $loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'comment', $langTask ) ) {
if( DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $langTask ) != $taskL[ 'TAS_DESCRIPTION' ] ) {
if ($loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'comment', $langTask )) {
if (DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $langTask ) != $taskL[ 'TAS_DESCRIPTION' ]) {
// must be updated
$trans = new DropdownTranslation ;
$trans->update( array( 'id' => $loc_id, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) , 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask) ) ;
$trans = new DropdownTranslation;
$trans->update( array( 'id' => $loc_id, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) , 'itemtype' => 'TaskCategory', 'items_id' => $taskCat->getID(), 'language' => $langTask) );
}
} else {
// must be added
$trans = new DropdownTranslation ;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) ) ) ;
$trans = new DropdownTranslation;
$trans->add( array( 'items_id' => $taskCat->getID(), 'itemtype' => 'TaskCategory', 'language' => $langTask, 'field' => 'comment', 'value' => $PM_DB->escape($taskL[ 'TAS_DESCRIPTION' ]) ) );
}
}
@@ -151,42 +153,44 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* Summary of refresh
* used to refresh process list and task category list
* @return void
*/
function refresh( ) {
// then refresh list of available process from PM to inner table
$pm = new PluginProcessmakerProcessmaker ;
$pm->login( true ) ;
$pmProcessList = $pm->processList() ;
$pm = new PluginProcessmakerProcessmaker;
$pm->login( true );
$pmProcessList = $pm->processList();
$config = PluginProcessmakerConfig::getInstance() ;
$pmMainTaskCat = $config->fields['taskcategories_id'] ;
$config = PluginProcessmakerConfig::getInstance();
$pmMainTaskCat = $config->fields['taskcategories_id'];
// and get processlist from GLPI
if( $pmProcessList ) {
foreach( $pmProcessList as $process ) {
$glpiprocess = new PluginProcessmakerProcess ;
if( $glpiprocess->getFromDBbyExternalID($process->guid) ) {
if ($pmProcessList) {
foreach ($pmProcessList as $process) {
$glpiprocess = new PluginProcessmakerProcess;
if ($glpiprocess->getFromDBbyExternalID($process->guid)) {
// then update it only if name has changed
if( $glpiprocess->fields['name'] != $process->name ) {
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name ) ) ;
if ($glpiprocess->fields['name'] != $process->name) {
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name ) );
}
// and check if main task category needs update
if( !$glpiprocess->fields['taskcategories_id'] ) {
if (!$glpiprocess->fields['taskcategories_id']) {
// then needs to be added
$glpiprocess->addTaskCategory( $pmMainTaskCat ) ;
$glpiprocess->addTaskCategory( $pmMainTaskCat );
} else {
$glpiprocess->updateTaskCategory( $pmMainTaskCat ) ;
$glpiprocess->updateTaskCategory( $pmMainTaskCat );
}
} else {
// create it
if( isset( $process->project_type ) )
if (isset( $process->project_type )) {
$project_type = $process->project_type;
else
$project_type = 'classic' ;
} else {
$project_type = 'classic';
}
if( $glpiprocess->add( array( 'process_guid' => $process->guid, 'name' => $process->name, 'project_type' => $project_type )) ){
if ($glpiprocess->add( array( 'process_guid' => $process->guid, 'name' => $process->name, 'project_type' => $project_type ))) {
// and add main task category for this process
$glpiprocess->addTaskCategory( $pmMainTaskCat ) ;
$glpiprocess->addTaskCategory( $pmMainTaskCat );
}
}
}
@@ -199,35 +203,36 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* Summary of updateTaskCategory
* Updates TaskCategory for current process, only if needed (i.e. name has changed)
* returns true if update is done, false otherwise
* @param integer $pmMainTaskCat is the id of the main task category
* @return boolean true if update is done, false otherwise
*/
function updateTaskCategory( $pmMainTaskCat ) {
$taskCat = new TaskCategory ;
if( $taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name'] ) {
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name'] ) ) ;
$taskCat = new TaskCategory;
if ($taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name']) {
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name'] ) );
}
return false ;
return false;
}
/**
* Summary of addTaskCategory
* Adds a new TaskCategory for $this process
* @param int $pmMainTaskCat is the main TaskCategory from PM configuration
* returns true if TaskCategory has been created and updated into $this process, else otherwise
* @return boolean true if TaskCategory has been created and updated into $this process, else otherwise
*/
function addTaskCategory( $pmMainTaskCat ) {
$taskCat = new TaskCategory ;
if( $taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name']) ) ) {
return $this->update( array( 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ) ) ;
$taskCat = new TaskCategory;
if ($taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name']) )) {
return $this->update( array( 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ) );
}
return false ;
return false;
}
/**
* Print a good title for process pages
* add button for re-synchro of process list (only if rigths are w)
* @return nothing (display)
* @return void (display)
**/
function title() {
global $LANG, $CFG_GLPI;
@@ -246,10 +251,8 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* Retrieve a Process from the database using its external id (unique index): process_guid
*
* @param $extid string externalid
*
* @return true if succeed else false
* @param string $extid guid of the process
* @return bool true if succeed else false
**/
public function getFromDBbyExternalID($extid) {
global $DB;
@@ -336,7 +339,6 @@ class PluginProcessmakerProcess extends CommonDBTM {
$tab[13]['massiveaction'] = true;
$tab[13]['datatype'] = 'bool';
$tab[14]['table'] = 'glpi_itilcategories';
$tab[14]['field'] = 'completename';
$tab[14]['name'] = __('Category');
@@ -370,7 +372,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
switch ($field) {
case 'project_type':
return $LANG['processmaker']['process']['project_type_'.$values[$field]] ;
return $LANG['processmaker']['process']['project_type_'.$values[$field]];
case 'type':
return Ticket::getTicketTypeName($values[$field]);
@@ -390,7 +392,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
function defineTabs($options=array()) {
// $ong = array('empty' => $this->getTypeName(1));
// $ong = array('empty' => $this->getTypeName(1));
$ong = array();
$this->addDefaultFormTab($ong);
$this->addStandardTab(__CLASS__, $ong, $options);
@@ -433,7 +435,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".__("Active")."&nbsp;:</td><td>";
Dropdown::showYesNo("is_active",$this->fields["is_active"]);
Dropdown::showYesNo("is_active", $this->fields["is_active"]);
echo "</td></tr>";
//echo "<tr class='tab_bg_1'>";
@@ -443,19 +445,19 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['hide_case_num_title']."&nbsp;:</td><td>";
Dropdown::showYesNo("hide_case_num_title",$this->fields["hide_case_num_title"]);
Dropdown::showYesNo("hide_case_num_title", $this->fields["hide_case_num_title"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['insert_task_comment']."&nbsp;:</td><td>";
Dropdown::showYesNo("insert_task_comment",$this->fields["insert_task_comment"]);
Dropdown::showYesNo("insert_task_comment", $this->fields["insert_task_comment"]);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['type']."&nbsp;:</td><td>";
if (true) { // $canupdate || !$ID
$idticketcategorysearch = mt_rand(); $opt = array('value' => $this->fields["type"]);
$rand = $idtype = Ticket::dropdownType('type', $opt, array(),array('toupdate' => "search_".$idticketcategorysearch ));
$rand = $idtype = Ticket::dropdownType('type', $opt, array(), array('toupdate' => "search_".$idticketcategorysearch ));
$opt = array('value' => $this->fields["type"]);
$params = array('type' => '__VALUE__',
//'entity_restrict' => -1, //$this->fields['entities_id'],
@@ -471,7 +473,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "</td>";
echo "<td >".$LANG['processmaker']['process']['itilcategory']."&nbsp;:</td><td>";
if (true ) { // $canupdate || !$ID || $canupdate_descr
if (true) { // $canupdate || !$ID || $canupdate_descr
$opt = array('value' => $this->fields["itilcategories_id"]);
switch ($this->fields['type']) {
@@ -488,7 +490,9 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
echo "<span id='show_category_by_type'>";
if( isset($idticketcategorysearch) ) $opt['rand'] = $idticketcategorysearch;
if (isset($idticketcategorysearch)) {
$opt['rand'] = $idticketcategorysearch;
}
Dropdown::show('ITILCategory', $opt);
echo "</span>";
} else {
@@ -498,7 +502,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['processmaker']['process']['project_type']."&nbsp;:</td><td>";
Dropdown::showFromArray( 'project_type', array( 'classic' => $LANG['processmaker']['process']['project_type_classic'], 'bpmn' => $LANG['processmaker']['process']['project_type_bpmn'] ), array( 'value' => $this->fields["project_type"] ) ) ;
Dropdown::showFromArray( 'project_type', array( 'classic' => $LANG['processmaker']['process']['project_type_classic'], 'bpmn' => $LANG['processmaker']['process']['project_type_bpmn'] ), array( 'value' => $this->fields["project_type"] ) );
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
@@ -506,7 +510,6 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo Html::convDateTime($this->fields["date_mod"]);
echo "</td></tr>";
$this->showFormButtons($options );
//$this->addDivForTabs();
@@ -527,26 +530,23 @@ class PluginProcessmakerProcess extends CommonDBTM {
static function getSqlSearchResult ($count=true, $search='') {
global $DB, $CFG_GLPI;
$orderby = '' ;
$orderby = '';
$where = ' WHERE glpi_plugin_processmaker_processes.is_active=1 ' ;
$where = ' WHERE glpi_plugin_processmaker_processes.is_active=1 ';
if( $count ) {
$fields = " COUNT(DISTINCT glpi_plugin_processmaker_processes.id) AS cpt " ;
if ($count) {
$fields = " COUNT(DISTINCT glpi_plugin_processmaker_processes.id) AS cpt ";
} else {
$fields = " DISTINCT glpi_plugin_processmaker_processes.* " ;
$orderby = " ORDER BY glpi_plugin_processmaker_processes.name ASC" ;
$fields = " DISTINCT glpi_plugin_processmaker_processes.* ";
$orderby = " ORDER BY glpi_plugin_processmaker_processes.name ASC";
}
if( strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"] )
{
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$where .= " AND (glpi_plugin_processmaker_processes.name $search
OR glpi_plugin_processmaker_processes.comment $search) " ;
OR glpi_plugin_processmaker_processes.comment $search) ";
}
$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";" ;
$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";";
return $DB->query($query);
}
@@ -570,14 +570,14 @@ class PluginProcessmakerProcess extends CommonDBTM {
$result = $DB->query($query);
if ($result && $DB->numrows($result)==1) {
$data = $DB->fetch_assoc($result);
$processname = $data["name"] ;
$processname = $data["name"];
if ($link==2) {
$process["name"] = $processname ;
$process["name"] = $processname;
$process["link"] = $CFG_GLPI["root_doc"]."/plugins/processmaker/front/process.form.php?id=".$pid;
$process["comment"] = __('Name')."&nbsp;: ".$processname."<br>".__('Comments').
"&nbsp;: ".$data["comment"]."<br>";
} else {
$process = $processname ;
$process = $processname;
}
}
@@ -621,8 +621,8 @@ class PluginProcessmakerProcess extends CommonDBTM {
*/
static function dropdown($options=array()) {
global $CFG_GLPI;
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownProcesses.php' ;
return Dropdown::show( __CLASS__, $options ) ;
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownProcesses.php';
return Dropdown::show( __CLASS__, $options );
}

View File

@@ -11,7 +11,7 @@
class PluginProcessmakerProcess_Profile extends CommonDBTM
{
function can($ID, $right, array &$input = NULL) {
return Session::haveRight('plugin_processmaker_config', $right) ;
return Session::haveRight('plugin_processmaker_config', $right);
}
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
@@ -26,7 +26,7 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
$ID = $item->getField('id');
$canshowentity = Session::haveRight("entity", READ);
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE) ;
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE);
$rand=mt_rand();
@@ -43,9 +43,9 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
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);
Dropdown::showYesNo("is_recursive", 0);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
echo "</td></tr>";
echo "</table>";
@@ -78,7 +78,6 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
Html::showMassiveActions($massiveactionparams);
}
if ($num > 0) {
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
@@ -129,7 +128,7 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
$entname = $data["name"];
}
// if ($data["is_dynamic"] || $data["is_recursive"]) {
// 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"]) {

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@ class ProcessmakerConfig extends CommonDBTM {
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $CFG_GLPI;
if($item->getType() == __CLASS__) {
if ($item->getType() == __CLASS__) {
switch ($tabnum) {
case 1 :
$item->showFormMailServerConfig();
@@ -96,4 +96,3 @@ class ProcessmakerConfig extends CommonDBTM {
}
?>

View File

@@ -15,7 +15,6 @@ class PluginProcessmakerProfile extends CommonDBTM {
static function getAllRights() {
global $LANG;
$rights = array(
array('itemtype' => 'PluginProcessmakerConfig',
'label' => $LANG['processmaker']['profile']['process_config'],
@@ -41,7 +40,7 @@ class PluginProcessmakerProfile extends CommonDBTM {
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
global $LANG;
if (!Session::haveRight("profile",READ)) {
if (!Session::haveRight("profile", READ)) {
return false;
}

View File

@@ -10,7 +10,7 @@
*/
class PluginProcessmakerTask extends CommonITILTask
{
private $itemtype ;
private $itemtype;
function __construct($itemtype) {
parent::__construct();
$this->itemtype=$itemtype;
@@ -23,22 +23,22 @@ class PluginProcessmakerTask extends CommonITILTask
* @return bool
*/
function getFromDB($items_id) {
global $DB ;
global $DB;
if( $this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ) ) {
if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) {
$task = new $this->itemtype;
if( $task->getFromDB( $items_id ) ) {
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 ;
$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 ;
$this->fields = $task->fields;
return true;
}
}
@@ -60,7 +60,7 @@ class PluginProcessmakerTask extends CommonITILTask
// return true ;
// }
//}
return false ;
return false;
}
/**
@@ -69,65 +69,65 @@ class PluginProcessmakerTask extends CommonITILTask
* @param mixed $case_id
*/
public static function getToDoTasks( $case_id, $itemtype ) {
global $DB ;
global $DB;
$ret = array();
$selfTable = getTableForItemType( __CLASS__) ;
$selfTable = getTableForItemType( __CLASS__);
$itemTypeTaskTable = getTableForItemType( $itemtype );
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
foreach($DB->request($query) as $row){
foreach ($DB->request($query) as $row) {
$ret[$row['taskID']]=$row['taskID'];
}
return $ret ;
return $ret;
}
static function canView( ) {
return true ;
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

@@ -25,9 +25,9 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG, $DB ;
global $LANG, $DB;
self::title($item) ;
self::title($item);
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
@@ -37,9 +37,9 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
"<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().";" ;
$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='".
@@ -55,7 +55,6 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
}
echo "</table></div>";
return true;
}

View File

@@ -31,30 +31,26 @@ class PluginProcessmakerUser extends CommonDBTM {
// 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' ] ;
$pmQuery = "SELECT GROUP_USER.USR_UID AS pm_user_id FROM TASK_USER
JOIN GROUP_USER ON GROUP_USER.GRP_UID=TASK_USER.USR_UID AND TASK_USER.TU_RELATION = 2 AND TASK_USER.TU_TYPE=1
WHERE TAS_UID = '$taskId'; ";
$pmUsers = array( );
foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
$pmUsers[ ] = $pmUser[ 'pm_user_id' ];
}
$joinprofile = false;
switch ($right) {
case "id" :
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
break;
case "all" :
$where = " `glpi_users`.`id` > '1' " ;
$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`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
$where .= " AND `glpi_users`.`is_deleted` = '0'
AND `glpi_users`.`is_active` = '1' ";
@@ -87,11 +83,7 @@ class PluginProcessmakerUser extends CommonDBTM {
}
$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 " ;
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id ";
$query .= " LEFT JOIN `glpi_useremails`
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
@@ -167,10 +159,10 @@ class PluginProcessmakerUser extends CommonDBTM {
* @return int (print out an HTML select box)
**/
static function dropdown($options=array()) {
global $CFG_GLPI ;
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,12 +172,12 @@ 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'] ;
public static function getGLPIUserId( $pmUserId ) {
$obj = new self;
if ($obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'")) {
return $obj->fields['id'];
}
return 0 ;
return 0;
}
/**
@@ -196,10 +188,10 @@ class PluginProcessmakerUser extends CommonDBTM {
*/
public static function getPMUserId( $glpiUserId ) {
$obj = new self;
if( $obj->getFromDB( Toolbox::cleanInteger($glpiUserId) ) ) {
return $obj->fields['pm_users_id'] ;
if ($obj->getFromDB( Toolbox::cleanInteger($glpiUserId) )) {
return $obj->fields['pm_users_id'];
}
return false ;
return false;
}
///**

View File

@@ -1,13 +1,14 @@

var oldHandler ;
var oldHandler;
var submitButton;
var caseIFrame;
function onClickContinue(obj) {
//debugger;
// call old handler
if (obj != undefined && oldHandler)
if (obj != undefined && oldHandler) {
oldHandler(obj.target);
}
// hide the iFrame
caseIFrame.style.visibility = 'hidden';
@@ -54,8 +55,9 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
if (txtAreaUseRequestSumUp != undefined) {
//debugger;
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
} else
} else {
$("textarea[name='content']")[0].value = '_';
}
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) {
bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
@@ -72,7 +74,6 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
oldHandler = buttonContinue.onclick;
buttonContinue.onclick = onClickContinue;
submitButton = $("input[name='add'][type=submit]")[0];
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_action' value='routecase'/>");
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseid' value='" + caseId + "'/>");
@@ -83,23 +84,20 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
}
// try to redim caseIFrame
if (!redimIFrame) {
var locElt = contentDocument.getElementsByTagName("form")[0];
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10;
caseIFrame.height = newHeight;
redimIFrame = true;
}
}
if( caseTimerCounter > 3000 )
window.clearInterval(caseTimer) ;
else
if ( caseTimerCounter > 3000 ) {
window.clearInterval(caseTimer);
} else {
caseTimerCounter = caseTimerCounter + 1;
}
},
10) ;
}, 10);
}

View File

@@ -44,7 +44,7 @@ function displayOverlay() {
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
//alert("Loaded frame " + delIndex);
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
var bShowHideNextStep = false ; // not done yet!
var bShowHideNextStep = false; // not done yet!
var bHideClaimCancelButton = false; // To manage 'Claim' button
var taskFrameTimerCounter = 0;
var redimIFrame = false;
@@ -90,8 +90,8 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
//debugger;
var csrfElt = document.createElement("input");
csrfElt.setAttribute("type", "hidden");
csrfElt.setAttribute("name", "_glpi_csrf_token") ;
csrfElt.setAttribute("value", csrf) ;
csrfElt.setAttribute("name", "_glpi_csrf_token");
csrfElt.setAttribute("value", csrf);
node.appendChild(csrfElt);
// add showMask function to submit event
@@ -148,8 +148,9 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
taskFrameTimerCounter = taskFrameTimerCounter + 1;
if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) // either timeout or hiding is done
if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) { // either timeout or hiding is done
window.clearInterval(taskFrameTimer);
}
} catch (evt) {
// nothing to do here for the moment
@@ -161,10 +162,10 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
function redimTaskFrame(taskFrame, delIndex) {
var newHeight;
try{
try {
//var locElt = locContentDocument.getElementsByTagName("table")[0];
var locElt = taskFrame.contentDocument.getElementsByTagName("body")[0];
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) ;
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
if (newHeight < 500) {
newHeight = 500;
}
@@ -192,7 +193,7 @@ function onTaskFrameActivation(delIndex) {
if (!redimIFrame) {
var newHeight;
var locElt = locContentDocument.getElementsByTagName("body")[0];
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) ;
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
tabs.getItem('task-' + delIndex).setHeight(newHeight);
taskFrame.height = newHeight;
@@ -202,8 +203,9 @@ function onTaskFrameActivation(delIndex) {
taskFrameTimerCounter = taskFrameTimerCounter + 1;
if (taskFrameTimerCounter > 3000 || redimIFrame) // timeout
if (taskFrameTimerCounter > 3000 || redimIFrame) { // timeout
window.clearInterval(taskFrameTimer);
}
} catch (evt) {
// nothing to do here for the moment
@@ -230,8 +232,9 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
var otherFrameTimerCounter = 0;
var redimIFrame = false;
//debugger;
if (isMap3 == undefined)
if (isMap3 == undefined) {
isMap3 = false;
}
var otherFrameTimer = window.setInterval(function () {
try {
@@ -254,7 +257,7 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div
if (!isMap3) {
if (tabPanelName == 'caseMap') {
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
locElt2 = locContentDocument.getElementById('pm_target');
locElt2.style.height = locElt.clientHeight + 'px';
@@ -272,7 +275,7 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) + locElt.offsetParent.offsetTop + 30;
} else {
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) ;
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight);
}
if (tabPanelName == 'caseMap') {
// trick to force scrollbar to be shown
@@ -283,7 +286,7 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
newHeight = locElt.scrollHeight;
}
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
otherFrame.height = newHeight ;
otherFrame.height = newHeight;
redimIFrame = true;
}
}
@@ -291,8 +294,9 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
otherFrameTimerCounter = otherFrameTimerCounter + 1;
if (otherFrameTimerCounter > 3000 || redimIFrame)
if (otherFrameTimerCounter > 3000 || redimIFrame) {
window.clearInterval(otherFrameTimer);
}
} catch (ev) {
// nothing to do here for the moment
@@ -300,7 +304,3 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
}, 10);
}

View File

@@ -1,8 +1,8 @@
<?php
// Direct access to file
if (strpos($_SERVER['PHP_SELF'],"processmaker/js/helpdesk.public.js.php")) {
if (strpos($_SERVER['PHP_SELF'], "processmaker/js/helpdesk.public.js.php")) {
$AJAX_INCLUDE = 1;
define('GLPI_ROOT','../../..');
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
header("Content-type: application/javascript");
Html::header_nocache();
@@ -13,28 +13,12 @@ if (!defined('GLPI_ROOT')) {
}
echo "$(function () {
/*function showMask(){Ext.getBody().moveTo( 0, 0); var myMask = new Ext.LoadMask(Ext.getBody(), {removeMask:false}); myMask.show();};*/
// look if name='helpdeskform' is present. If yes replace the form.location
var ahrefTI = '".$CFG_GLPI["root_doc"]."/plugins/processmaker/front/tracking.injector.php';
var formLink = $(\"form[name='helpdeskform']\")[0];
if (formLink != undefined) {
formLink.action = ahrefTI;
}
/*
var ticketType = $(\"select[name='type']\")$[0];
if (ticketType != undefined) {
ticketType.addEventListener( 'change', showMask );
}
var ticketCat = $(\"select[name='itilcategories_id']\")[0];
if (ticketCat!= undefined) {
ticketCat.addEventListener( 'change', showMask );
}
*/
});
"; // end of echo
?>

View File

@@ -23,7 +23,7 @@
</authors>
<versions>
<version>
<num>3.1.2</num>
<num>3.1.3</num>
<compatibility>9.1</compatibility>
</version>
</versions>

View File

@@ -12,14 +12,10 @@ function plugin_init_processmaker() {
&& $plugin->isActivated('processmaker')
&& Session::getLoginUserID() ) {
Plugin::registerClass('PluginProcessmakerProcessmaker');
Plugin::registerClass('PluginProcessmakerProcessmaker');//, array(
// 'notificationtemplates_types' => true,
// 'addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerCase', array('addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerCase', array(
'notificationtemplates_types' => true,
'addtabon' => array('Ticket')));
Plugin::registerClass('PluginProcessmakerTaskCategory');
if (Session::haveRight('config', UPDATE)) {
@@ -27,24 +23,14 @@ function plugin_init_processmaker() {
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
}
Plugin::registerClass('PluginProcessmakerProfile',
array('addtabon' => 'Profile'));
Plugin::registerClass('PluginProcessmakerProfile', array('addtabon' => 'Profile'));
$PLUGIN_HOOKS['change_profile']['processmaker'] = array('PluginProcessmakerProfile','select');
Plugin::registerClass('PluginProcessmakerProcess_Profile');
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
// tabs management
//$PLUGIN_HOOKS['headings']['processmaker'] = 'plugin_get_headings_processmaker';
//$PLUGIN_HOOKS['headings_action']['processmaker'] = 'plugin_headings_actions_processmaker';
//$PLUGIN_HOOKS['canedit']['processmaker']
//= array('TicketTask' => array('PluginProcessmakerProcessmaker',
// 'canedit_item_processmakertickettask'));
$PLUGIN_HOOKS['pre_show_item']['processmaker']
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
@@ -53,20 +39,15 @@ function plugin_init_processmaker() {
$PLUGIN_HOOKS['post_show_tab']['processmaker']
= array('PluginProcessmakerProcessmaker', 'post_show_tab_processmaker');
//$PLUGIN_HOOKS['post_show_item']['processmaker']
// = array('Ticket' => array('PluginProcessmakerProcessmaker',
// 'post_show_item_processmakerticket'));
// Display a menu entry ?
if (Session::haveRight('config', READ) ) {
if (Session::haveRight('config', READ)) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
}
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) ) ;
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) );
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
);
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
@@ -90,77 +71,59 @@ function plugin_init_processmaker() {
'PluginPdfTicketTask' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdatas_processmaker')
);
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
) ;
);
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
'Ticket_User' => 'plugin_item_purge_processmaker'
) ;
);
$PLUGIN_HOOKS['add_javascript']['processmaker'] = array("js/domain.js.php");
$url = explode("/", $_SERVER['PHP_SELF']);
$pageName = explode("?", array_pop($url));
switch($pageName[0]) {
switch ($pageName[0]) {
case "tracking.injector.php":
case "helpdesk.public.php":
//$plug = new Plugin;
//if( !$plug->isActivated('rayusermanagementticket') )
$PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/helpdesk.public.js.php";
break;
}
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
//$PLUGIN_HOOKS['planning_populate']['processmaker'] = "plugin_planning_populate_processmaker"; // used for task descriptions
$CFG_GLPI['planning_types'][] = 'PluginProcessmakerTask';
$PLUGIN_HOOKS['post_init']['processmaker'] = 'plugin_processmaker_post_init';
}
}
// Get the name and the version of the plugin - Needed
function plugin_version_processmaker(){
function plugin_version_processmaker() {
global $LANG;
return array ('name' => 'Process Maker',
'version' => '3.1.2',
'version' => '3.1.3',
'author' => 'Olivier Moron',
'homepage' => '',
'minGlpiVersion' => '9.1');
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_processmaker_check_prerequisites(){
if (version_compare(GLPI_VERSION,'9.1','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
function plugin_processmaker_check_prerequisites() {
if (version_compare(GLPI_VERSION, '9.1', 'lt') || version_compare(GLPI_VERSION, '9.2', 'ge')) {
echo "This plugin requires GLPI 9.1 or higher";
return false;
}
//$plug = new Plugin ;
//if (!$plug->isActivated('mhooks') || version_compare( $plug->fields['version'], '1.2.0', '<')) {
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
// return false;
//}
return true;
}
function plugin_processmaker_check_config($verbose = false){
// $plug = new Plugin ;
// if ($plug->isActivated('mhooks') && version_compare( $plug->fields['version'], '1.2.0', '>=')) {
// return true;
// }
function plugin_processmaker_check_config($verbose = false) {
// if ($verbose) {
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
// }
//return false;
return true;
}
function plugin_processmaker_haveRight($module,$right) {
return Session::haveRight("plugin_processmaker_".$module, $right) ;
return Session::haveRight("plugin_processmaker_".$module, $right);
}
?>