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

@@ -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();

View File

@@ -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

@@ -16,9 +16,6 @@ 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;
@@ -46,5 +43,4 @@ echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQ
echo "&nbsp;&nbsp;";
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
Html::closeForm(true);
//echo "</form>";

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

@@ -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);

View File

@@ -1,7 +1,6 @@
<?php
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
include_once ("../../../inc/includes.php");
Plugin::load('processmaker', true);
@@ -22,13 +21,10 @@ if (isset($_REQUEST["update"])) {
Html::back();
} else {
// $PluginProcess->checkGlobal(READ);
Html::header($LANG['processmaker']['title'][1], $_SERVER["PHP_SELF"], "plugins", "processmaker");
$PluginProcess->display($_REQUEST);
// $PluginProcess->showForm($_REQUEST["id"]);
Html::footer();
}
?>

View File

@@ -1,7 +1,6 @@
<?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");
@@ -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();
@@ -37,6 +36,4 @@ if (isset($_POST["add"])) {
}
Html::displayErrorAndDie("lost");
?>

View File

@@ -1,7 +1,5 @@
<?php
include_once ("../../../inc/includes.php");
//include_once '../inc/processmaker.class.php' ;
//include_once '../inc/cases.class.php' ;
switch ($_POST["action"]) {
case 'newcase':
@@ -17,13 +15,13 @@ switch( $_POST["action"] ) {
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)
} 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'],
@@ -52,11 +50,10 @@ switch( $_POST["action"] ) {
$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) {
@@ -78,14 +75,13 @@ switch( $_POST["action"] ) {
}
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] );
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
// 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'] );
@@ -97,12 +93,13 @@ switch( $_POST["action"] ) {
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();
@@ -110,13 +107,15 @@ switch( $_POST["action"] ) {
if ($resultPM->status_code === 0) {
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
if( $locCase->cancelCase() )
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;

View File

@@ -1,6 +1,5 @@
<?php
include_once ("../../../inc/includes.php");
//include_once '../inc/processmaker.class.php' ;
function processMakerShowProcessList ($ID, $from_helpdesk) {
global $DB, $CFG_GLPI, $LANG, $_SESSION;
@@ -14,7 +13,6 @@ function processMakerShowProcessList ($ID, $from_helpdesk) {
echo "<div class='center'><table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='2'>".$LANG['processmaker']['item']['tab']."</th></tr>";
echo "<tr class='tab_bg_2'><td class='right' colspan='1'>";
echo $LANG['processmaker']['item']['selectprocess']."&nbsp;";
echo "<input type='hidden' name='action' value='newcase'>";
@@ -22,7 +20,6 @@ function processMakerShowProcessList ($ID, $from_helpdesk) {
echo "<input type='hidden' name='itemtype' value='Ticket'>";
echo "<input type='hidden' name='itilcategories_id' value='".$_REQUEST['itilcategories_id']."'>";
echo "<input type='hidden' name='type' value='".$_REQUEST['type']."'>";
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1 and is_helpdeskvisible=1")); // condition is used to prevent start of none-active and none-helpdesk-visible cases
PluginProcessmakerProcess::dropdown( array( 'value' => 0, 'entity' => $_SESSION['glpiactive_entity'], 'name' => 'plugin_processmaker_process_id' ));
echo "</td><td class='center'>";
echo "<input type='submit' name='additem' value='Start' class='submit'>";
@@ -33,849 +30,6 @@ function processMakerShowProcessList ($ID, $from_helpdesk) {
}
///**
//* Print the helpdesk form
//*
//* @param $ID int : ID of the user who want to display the Helpdesk
//* @param $ticket_template int : ID ticket template for preview : false if not used for preview
//*
//* @return nothing (print the helpdesk)
//**/
//function showFormHelpdeskbak($ID, $pmItem, $caseInfo, $ticket_template=false) {
// global $DB, $CFG_GLPI, $LANG;
// if (!Session::haveRight("ticket", CREATE)) {
// return false;
// }
// $query = "SELECT `realname`, `firstname`, `name`
// FROM `glpi_users`
// WHERE `id` = '$ID'";
// $result = $DB->query($query);
// $email = UserEmail::getDefaultForUser($ID);
// // Set default values...
// $default_values = array('_users_id_requester_notif' => array('use_notification' => ($email==""?0:1),
// 'alternative_email' => ''),
// 'nodelegate' => 1,
// '_users_id_requester' => 0,
// 'name' => '',
// 'content' => '',
// 'itilcategories_id' => 0,
// 'urgency' => 3,
// 'itemtype' => '',
// 'entities_id' => $_SESSION['glpiactive_entity'],
// 'items_id' => 0,
// 'plan' => array(),
// 'global_validation' => 'none',
// 'due_date' => 'NULL',
// 'slas_id' => 0,
// '_add_validation' => 0,
// 'type' => 1,
// '_right' => "id");
// if (!$ticket_template) {
// $options = $_REQUEST;
// }
// // Restore saved value or override with page parameter
// foreach ($default_values as $name => $value) {
// if (!isset($options[$name])) {
// if (isset($_SESSION["helpdeskSaved"][$name])) {
// $options[$name] = $_SESSION["helpdeskSaved"][$name];
// } else {
// $options[$name] = $value;
// }
// }
// }
// // Clean text fields
// $options['name'] = stripslashes($options['name']);
// $options['content'] = Html::cleanPostForTextArea($options['content']);
// if (!$ticket_template) {
// echo "<form method='post' name='helpdeskform' action='".
// $CFG_GLPI["root_doc"]."/front/tracking.injector.php' enctype='multipart/form-data'>";
// }
// $delegating = User::getDelegateGroupsForUser($options['entities_id']);
// if (count($delegating)) {
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th colspan='2'>".$LANG['job'][69]."&nbsp;:&nbsp;";
// $rand = Dropdown::showYesNo("nodelegate", $options['nodelegate']);
// $params = array ('nodelegate' => '__VALUE__',
// 'rand' => $rand,
// 'right' => "delegate",
// '_users_id_requester'
// => $options['_users_id_requester'],
// '_users_id_requester_notif'
// => $options['_users_id_requester_notif'],
// 'use_notification'
// => $options['_users_id_requester_notif']['use_notification'],
// 'entity_restrict'
// => $_SESSION["glpiactive_entity"]);
// Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand,
// $CFG_GLPI["root_doc"]."/ajax/dropdownDelegationUsers.php",
// $params);
// echo "</th></tr>";
// echo "<tr class='tab_bg_1'><td colspan='2' class='center'>";
// echo "<div id='show_result$rand'>";
// $self = new Ticket();
// if ($options["_users_id_requester"] == 0) {
// $options['_users_id_requester'] = Session::getLoginUserID();
// } else {
// $options['_right'] = "delegate";
// }
// $self->showActorAddFormOnCreate(Ticket::REQUESTER, $options);
// echo "</div>";
// echo "</td></tr>";
// echo "</table></div>";
// echo "<input type='hidden' name='_users_id_recipient' value='".Session::getLoginUserID()."'>";
// }
// echo "<input type='hidden' name='_from_helpdesk' value='1'>";
// echo "<input type='hidden' name='requesttypes_id' value='".RequestType::getDefault('helpdesk').
// "'>";
// // Load ticket template if available :
// $tt = new TicketTemplate();
// // First load default entity one
// if ($template_id = EntityData::getUsedConfig('tickettemplates_id', $_SESSION["glpiactive_entity"])) {
// // with type and categ
// $tt->getFromDBWithDatas($template_id, true);
// }
// $field = '';
// if ($options['type'] && $options['itilcategories_id']) {
// $categ = new ITILCategory();
// if ($categ->getFromDB($options['itilcategories_id'])) {
// switch ($options['type']) {
// case Ticket::INCIDENT_TYPE :
// $field = 'tickettemplates_id_incident';
// break;
// case Ticket::DEMAND_TYPE :
// $field = 'tickettemplates_id_demand';
// break;
// }
// if (!empty($field) && $categ->fields[$field]) {
// // without type and categ
// $tt->getFromDBWithDatas($categ->fields[$field], false);
// }
// }
// }
// if ($ticket_template) {
// // with type and categ
// $tt->getFromDBWithDatas($ticket_template, true);
// }
// // Predefined fields from template : reset them
// if (isset($options['_predefined_fields'])) {
// $options['_predefined_fields']
// = unserialize(rawurldecode(stripslashes($options['_predefined_fields'])));
// } else {
// $options['_predefined_fields'] = array();
// }
// // Store predefined fields to be able not to take into account on change template
// $predefined_fields = array();
// if (isset($tt->predefined) && count($tt->predefined)) {
// foreach ($tt->predefined as $predeffield => $predefvalue) {
// if (isset($options[$predeffield]) && isset($default_values[$predeffield])) {
// // Is always default value : not set
// // Set if already predefined field
// // Set if ticket template change
// if ($options[$predeffield] == $default_values[$predeffield]
// || (isset($options['_predefined_fields'][$predeffield])
// && $options[$predeffield] == $options['_predefined_fields'][$predeffield])
// || (isset($options['_tickettemplates_id'])
// && $options['_tickettemplates_id'] != $tt->getID())) {
// $options[$predeffield] = $predefvalue;
// $predefined_fields[$predeffield] = $predefvalue;
// }
// } else { // Not defined options set as hidden field
// echo "<input type='hidden' name='$predeffield' value='$predefvalue'>";
// }
// }
// } else { // No template load : reset predefined values
// if (count($options['_predefined_fields'])) {
// foreach ($options['_predefined_fields'] as $predeffield => $predefvalue) {
// if ($options[$predeffield] == $predefvalue) {
// $options[$predeffield] = $default_values[$predeffield];
// }
// }
// }
// }
// unset($_SESSION["helpdeskSaved"]);
// if ($CFG_GLPI['urgency_mask']==(1<<3) || $tt->isHiddenField('urgency')) {
// // Dont show dropdown if only 1 value enabled or field is hidden
// echo "<input type='hidden' name='urgency' value='".$options['urgency']."'>";
// }
// // Display predefined fields if hidden
// if ($tt->isHiddenField('itemtype')) {
// echo "<input type='hidden' name='itemtype' value='".$options['itemtype']."'>";
// echo "<input type='hidden' name='items_id' value='".$options['items_id']."'>";
// }
// echo "<input type='hidden' name='entities_id' value='".$_SESSION["glpiactive_entity"]."'>";
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th colspan='2'>".$caseInfo->processName."&nbsp;:&nbsp;";
// if (Session::isMultiEntitiesMode()) {
// echo "&nbsp;(".Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]).")";
// }
// echo "</th></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".$LANG['common'][17]."&nbsp;:".$tt->getMandatoryMark('type')."</td>";
// echo "<td>";
// Ticket::dropdownType('type', array('value' => $options['type'],
// 'on_change' => 'submit()'));
// echo "</td></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".$LANG['common'][36]."&nbsp;:";
// echo $tt->getMandatoryMark('itilcategories_id');
// echo "</td><td>";
// $condition = "`is_helpdeskvisible`='1'";
// switch ($options['type']) {
// case Ticket::DEMAND_TYPE :
// $condition .= " AND `is_request`='1'";
// break;
// default: // Ticket::INCIDENT_TYPE :
// $condition .= " AND `is_incident`='1'";
// }
// $opt = array('value' => $options['itilcategories_id'],
// 'condition' => $condition,
// 'on_change' => 'submit()');
// if ($options['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
// $opt['display_emptychoice'] = false;
// }
// Dropdown::show('ITILCategory', $opt);
// echo "</td></tr>";
// if ($CFG_GLPI['urgency_mask']!=(1<<3)) {
// if (!$tt->isHiddenField('urgency')) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".$LANG['joblist'][29]."&nbsp;:".$tt->getMandatoryMark('urgency')."</td>";
// echo "<td>";
// Ticket::dropdownUrgency("urgency", $options['urgency']);
// echo "</td></tr>";
// }
// }
// if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".$LANG['help'][8]."&nbsp;:&nbsp;</td>";
// echo "<td>";
// if ($options["_users_id_requester"] == 0) {
// $options['_users_id_requester'] = Session::getLoginUserID();
// }
// $_REQUEST['value'] = $options['_users_id_requester'];
// $_REQUEST['field'] = '_users_id_requester_notif';
// $_REQUEST['use_notification'] = $options['_users_id_requester_notif']['use_notification'];
// include (GLPI_ROOT."/ajax/uemailUpdate.php");
// echo "</td></tr>";
// }
// if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) {
// if (!$tt->isHiddenField('itemtype')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".$LANG['help'][24]."&nbsp;: ".$tt->getMandatoryMark('itemtype')."</td>";
// echo "<td>";
// Ticket::dropdownMyDevices($options['_users_id_requester'], $_SESSION["glpiactive_entity"],
// $options['itemtype'], $options['items_id']);
// Ticket::dropdownAllDevices("itemtype", $options['itemtype'], $options['items_id'], 0, $options['_users_id_requester'],
// $_SESSION["glpiactive_entity"]);
// echo "<span id='item_ticket_selection_information'></span>";
// echo "</td></tr>";
// }
// }
// if (!$tt->isHiddenField('name')
// || $tt->isPredefinedField('name')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".$LANG['common'][57]."&nbsp;:".
// $tt->getMandatoryMark('name')."</td>";
// echo "<td><input type='text' maxlength='250' size='80' name='name'
// value=\"".$options['name']."\"></td></tr>";
// }
// if (!$tt->isHiddenField('content')
// || $tt->isPredefinedField('content')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".$LANG['joblist'][6]."&nbsp;:".
// $tt->getMandatoryMark('content')."</td>";
// echo "<td><textarea name='content' cols='80' rows='14'>".$options['content']."</textarea>";
// echo "</td></tr>";
// }
// echo "<tr class='tab_bg_1'>";
// echo "<th class='center' colspan=2>&nbsp;";
// echo "</th></tr>";
// echo "<tr class='tab_bg_1'>";
// echo "<td class='center' colspan=2>";
// $rand = rand();
// $pmCaseUser = $caseInfo->currentUsers[0] ; // by default
// $paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
// echo "<iframe onload='onLoadFrame( event, \"".$caseInfo->caseId."\", ".$pmCaseUser->delIndex.", ".$caseInfo->caseNumber.", \"".$caseInfo->processName."\") ;' id='caseiframe' width=100% style='border:none;' src='".$pmItem->serverURL."/cases/cases_Open?sid=". $_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand' ></iframe>";
// echo "</td></tr>";
// echo "<tr><th colspan='2'>&nbsp;";
// echo "</th></tr>";
// echo "<tr class='tab_bg_1'>";
// echo "<td>".$LANG['document'][2]." (".Document::getMaxUploadSize().")&nbsp;:&nbsp;";
// echo "<img src='".$CFG_GLPI["root_doc"]."/pics/aide.png' class='pointer' alt='".
// $LANG['central'][7]."' onclick=\"window.open('".$CFG_GLPI["root_doc"].
// "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
// echo "&nbsp;";
// Ticket::showDocumentAddButton(60);
// echo "</td>";
// echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
// echo "</td></tr>";
// if (!$ticket_template) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td colspan='2' class='center'>";
// if ($tt->isField('id') && $tt->fields['id'] > 0) {
// echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
// echo "<input type='hidden' name='_predefined_fields'
// value=\"".rawurlencode(serialize($predefined_fields))."\">";
// }
// echo "<input type='submit' name='add' value=\"".$LANG['help'][14]."\" class='submit'>";
// echo "</td></tr>";
// }
// echo "</table></div>";
// if (!$ticket_template) {
// Html::closeForm();
// }
//}
/**
* Print the helpdesk form
*
* @param $ID integer ID of the user who want to display the Helpdesk
* @param $ticket_template boolean ticket template for preview : false if not used for preview
* (false by default)
*
* @return nothing (print the helpdesk)
**/
//function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
// global $DB, $CFG_GLPI;
// if (!Ticket::canCreate()) {
// return false;
// }
// if (!$ticket_template
// && Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
// $opt = array();
// $opt['reset'] = 'reset';
// $opt['criteria'][0]['field'] = 55; // validation status
// $opt['criteria'][0]['searchtype'] = 'equals';
// $opt['criteria'][0]['value'] = CommonITILValidation::WAITING;
// $opt['criteria'][0]['link'] = 'AND';
// $opt['criteria'][1]['field'] = 59; // validation aprobator
// $opt['criteria'][1]['searchtype'] = 'equals';
// $opt['criteria'][1]['value'] = Session::getLoginUserID();
// $opt['criteria'][1]['link'] = 'AND';
// $url_validate = $CFG_GLPI["root_doc"]."/front/ticket.php?".Toolbox::append_params($opt,
// '&amp;');
// if (TicketValidation::getNumberToValidate(Session::getLoginUserID()) > 0) {
// echo "<a href='$url_validate' title=\"".__s('Ticket waiting for your approval')."\"
// alt=\"".__s('Ticket waiting for your approval')."\">".
// __('Tickets awaiting approval')."</a><br><br>";
// }
// }
// $query = "SELECT `realname`, `firstname`, `name`
// FROM `glpi_users`
// WHERE `id` = '$ID'";
// $result = $DB->query($query);
// $email = UserEmail::getDefaultForUser($ID);
// $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
// // Set default values...
// $default_values = array('_users_id_requester_notif'
// => array('use_notification'
// => (($email == "")?0:$default_use_notif)),
// 'nodelegate' => 1,
// '_users_id_requester' => 0,
// '_users_id_observer' => 0,
// '_users_id_observer_notif'
// => array('use_notification' => $default_use_notif),
// 'name' => '',
// 'content' => '',
// 'itilcategories_id' => 0,
// 'locations_id' => 0,
// 'urgency' => 3,
// 'itemtype' => '',
// 'items_id' => 0,
// 'entities_id' => $_SESSION['glpiactive_entity'],
// 'plan' => array(),
// 'global_validation' => CommonITILValidation::NONE,
// '_add_validation' => 0,
// 'type' => Entity::getUsedConfig('tickettype',
// $_SESSION['glpiactive_entity'],
// '', Ticket::INCIDENT_TYPE),
// '_right' => "id",
// '_filename' => array(),
// '_tag_filename' => array());
// // Get default values from posted values on reload form
// if (!$ticket_template) {
// if (isset($_POST)) {
// $values = Html::cleanPostForTextArea($_POST);
// }
// }
// $ticket = new Ticket();
// // Restore saved value or override with page parameter
// if( !function_exists('restoreInput') ) {
// function restoreInput(Array $default=array()) {
// if (isset($_SESSION['saveInput']['Ticket'])) {
// $saved = Html::cleanPostForTextArea($_SESSION['saveInput']['Ticket']);
// // clear saved data when restored (only need once)
// unset($_SESSION['saveInput']['Ticket']);
// return $saved;
// }
// return $default;
// }
// }
// $saved = restoreInput();
// foreach ($default_values as $name => $value) {
// if (!isset($values[$name])) {
// if (isset($saved[$name])) {
// $values[$name] = $saved[$name];
// } else {
// $values[$name] = $value;
// }
// }
// }
// if (!$ticket_template) {
// echo "<form method='post' name='helpdeskform' action='".
// $CFG_GLPI["root_doc"]."/front/tracking.injector.php' enctype='multipart/form-data'>";
// }
// $delegating = User::getDelegateGroupsForUser($values['entities_id']);
// if (count($delegating)) {
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th colspan='2'>".__('This ticket concerns me')." ";
// $rand = Dropdown::showYesNo("nodelegate", $values['nodelegate']);
// $params = array('nodelegate' => '__VALUE__',
// 'rand' => $rand,
// 'right' => "delegate",
// '_users_id_requester'
// => $values['_users_id_requester'],
// '_users_id_requester_notif'
// => $values['_users_id_requester_notif'],
// 'use_notification'
// => $values['_users_id_requester_notif']['use_notification'],
// 'entity_restrict'
// => $_SESSION["glpiactive_entity"]);
// Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand,
// $CFG_GLPI["root_doc"]."/ajax/dropdownDelegationUsers.php",
// $params);
// $class = 'right';
// if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
// echo "</th><th>".__('Check your personnal information');
// $class = 'center';
// }
// echo "</th></tr>";
// echo "<tr class='tab_bg_1'><td colspan='2' class='".$class."'>";
// echo "<div id='show_result$rand'>";
// $self = $ticket;
// if ($values["_users_id_requester"] == 0) {
// $values['_users_id_requester'] = Session::getLoginUserID();
// } else {
// $values['_right'] = "delegate";
// }
// $self->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $values);
// echo "</div>";
// if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
// echo "</td><td class='center'>";
// User::showPersonalInformation(Session::getLoginUserID());
// }
// echo "</td></tr>";
// echo "</table></div>";
// echo "<input type='hidden' name='_users_id_recipient' value='".Session::getLoginUserID()."'>";
// } else {
// // User as requester
// $values['_users_id_requester'] = Session::getLoginUserID();
// if ($CFG_GLPI['use_check_pref']) {
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th>".__('Check your personnal information')."</th></tr>";
// echo "<tr class='tab_bg_1'><td class='center'>";
// User::showPersonalInformation(Session::getLoginUserID());
// echo "</td></tr>";
// echo "</table></div>";
// }
// }
// echo "<input type='hidden' name='_from_helpdesk' value='1'>";
// echo "<input type='hidden' name='requesttypes_id' value='".RequestType::getDefault('helpdesk').
// "'>";
// // Load ticket template if available :
// $tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'],
// $values['itilcategories_id'],
// $_SESSION["glpiactive_entity"]);
// // Predefined fields from template : reset them
// if (isset($values['_predefined_fields'])) {
// $values['_predefined_fields']
// = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
// } else {
// $values['_predefined_fields'] = array();
// }
// // Store predefined fields to be able not to take into account on change template
// $predefined_fields = array();
// if (isset($tt->predefined) && count($tt->predefined)) {
// foreach ($tt->predefined as $predeffield => $predefvalue) {
// if (isset($values[$predeffield]) && isset($default_values[$predeffield])) {
// // Is always default value : not set
// // Set if already predefined field
// // Set if ticket template change
// if (((count($values['_predefined_fields']) == 0)
// && ($values[$predeffield] == $default_values[$predeffield]))
// || (isset($values['_predefined_fields'][$predeffield])
// && ($values[$predeffield] == $values['_predefined_fields'][$predeffield]))
// || (isset($values['_tickettemplates_id'])
// && ($values['_tickettemplates_id'] != $tt->getID()))) {
// $values[$predeffield] = $predefvalue;
// $predefined_fields[$predeffield] = $predefvalue;
// }
// } else { // Not defined options set as hidden field
// echo "<input type='hidden' name='$predeffield' value='$predefvalue'>";
// }
// }
// // All predefined override : add option to say predifined exists
// if (count($predefined_fields) == 0) {
// $predefined_fields['_all_predefined_override'] = 1;
// }
// } else { // No template load : reset predefined values
// if (count($values['_predefined_fields'])) {
// foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
// if ($values[$predeffield] == $predefvalue) {
// $values[$predeffield] = $default_values[$predeffield];
// }
// }
// }
// }
// if (($CFG_GLPI['urgency_mask'] == (1<<3))
// || $tt->isHiddenField('urgency')) {
// // Dont show dropdown if only 1 value enabled or field is hidden
// echo "<input type='hidden' name='urgency' value='".$values['urgency']."'>";
// }
// // Display predefined fields if hidden
// if ($tt->isHiddenField('itemtype')) {
// echo "<input type='hidden' name='itemtype' value='".$values['itemtype']."'>";
// echo "<input type='hidden' name='items_id' value='".$values['items_id']."'>";
// }
// if ($tt->isHiddenField('locations_id')) {
// echo "<input type='hidden' name='locations_id' value='".$values['locations_id']."'>";
// }
// echo "<input type='hidden' name='entities_id' value='".$_SESSION["glpiactive_entity"]."'>";
// echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
// echo "<div class='center'><table class='tab_cadre_fixe'>";
// echo "<tr><th>".$caseInfo->processName."</th><th>";
// //echo "<tr><th>".__('Describe the incident or request')."</th><th>";
// if (Session::isMultiEntitiesMode()) {
// echo "(".Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]).")";
// }
// echo "</th></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type'))."</td>";
// echo "<td>";
// Ticket::dropdownType('type', array('value' => $values['type'],
// 'on_change' => 'this.form.submit()'));
// echo "</td></tr>";
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Category'),
// $tt->getMandatoryMark('itilcategories_id'))."</td>";
// echo "<td>";
// $condition = "`is_helpdeskvisible`='1'";
// switch ($values['type']) {
// case Ticket::DEMAND_TYPE :
// $condition .= " AND `is_request`='1'";
// break;
// default: // Ticket::INCIDENT_TYPE :
// $condition .= " AND `is_incident`='1'";
// }
// $opt = array('value' => $values['itilcategories_id'],
// 'condition' => $condition,
// 'on_change' => 'this.form.submit()');
// if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
// $opt['display_emptychoice'] = false;
// }
// ITILCategory::dropdown($opt);
// echo "</td></tr>";
// if ($CFG_GLPI['urgency_mask'] != (1<<3)) {
// if (!$tt->isHiddenField('urgency')) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')).
// "</td>";
// echo "<td>";
// Ticket::dropdownUrgency(array('value' => $values["urgency"]));
// echo "</td></tr>";
// }
// }
// if (empty($delegating)
// && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>".__('Inform me about the actions taken')."</td>";
// echo "<td>";
// if ($values["_users_id_requester"] == 0) {
// $values['_users_id_requester'] = Session::getLoginUserID();
// }
// $_POST['value'] = $values['_users_id_requester'];
// $_POST['field'] = '_users_id_requester_notif';
// $_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification'];
// include (GLPI_ROOT."/ajax/uemailUpdate.php");
// echo "</td></tr>";
// }
// if (($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0)
// && (count($_SESSION["glpiactiveprofile"]["helpdesk_item_type"]))) {
// if (!$tt->isHiddenField('itemtype')) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Hardware type'),
// $tt->getMandatoryMark('itemtype'))."</td>";
// echo "<td>";
// Item_Ticket::dropdownMyDevices($values['_users_id_requester'], $_SESSION["glpiactive_entity"],
// $values['itemtype'], $values['items_id']);
// Item_Ticket::dropdownAllDevices("itemtype", $values['itemtype'], $values['items_id'], 0,
// $values['_users_id_requester'],
// $_SESSION["glpiactive_entity"]);
// echo "<span id='item_ticket_selection_information'></span>";
// echo "</td></tr>";
// }
// }
// if (!$tt->isHiddenField('locations_id')) {
// echo "<tr class='tab_bg_1' style='display:none;'><td>";
// printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
// echo "</td><td>";
// Location::dropdown(array('value' => $values["locations_id"]));
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('_users_id_observer')
// || $tt->isPredefinedField('_users_id_observer')) {
// echo "<tr class='tab_bg_1'><td>".__('Watcher')."</td>";
// echo "<td>";
// $values['_right'] = "groups";
// if (!$tt->isHiddenField('_users_id_observer')) {
// // Observer
// $rand_observer = $ticket->showActorAddFormOnCreate(CommonITILActor::OBSERVER, $values);
// echo '<hr>';
// echo "<span id='observer_$rand_observer'></span>";
// Ajax::updateItemOnSelectEvent("dropdown__users_id_observer[]$rand_observer",
// "observer_$rand_observer",
// $CFG_GLPI["root_doc"]."/ajax/helpdesk_observer.php",
// $values);
// } else { // predefined value
// if (isset($values["_users_id_observer"]) && $values["_users_id_observer"]) {
// echo Ticket::getActorIcon('user', CommonITILActor::OBSERVER)."&nbsp;";
// echo Dropdown::getDropdownName("glpi_users", $values["_users_id_observer"]);
// echo "<input type='hidden' name='_users_id_observer' value=\"".
// $values["_users_id_observer"]."\">";
// echo '<hr>';
// }
// }
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('name')
// || $tt->isPredefinedField('name')) {
// echo "<tr class='tab_bg_1' >";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'))."<td>";
// if (!$tt->isHiddenField('name')) {
// echo "<input type='text' maxlength='250' size='80' name='name'
// value=\"".$values['name']."\">";
// } else {
// echo $values['name'];
// echo "<input type='hidden' name='name' value=\"".$values['name']."\">";
// }
// echo "</td></tr>";
// }
// if (!$tt->isHiddenField('content')
// || $tt->isPredefinedField('content')) {
// echo "<tr class='tab_bg_1' >";
// echo "<td>".sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')).
// "</td><td>";
// $rand = mt_rand();
// $rand_text = mt_rand();
// $cols = 90;
// $rows = 6;
// $content_id = "content$rand";
// //if ($CFG_GLPI["use_rich_text"]) {
// // $values["content"] = $ticket->setRichTextContent($content_id, $values["content"], $rand);
// // $cols = 100;
// // $rows = 10;
// //} else {
// $values["content"] = $ticket->setSimpleTextContent($values["content"]);
// //}
// echo "<div id='content$rand_text'>";
// echo "<textarea id='$content_id' name='content' cols='$cols' rows='$rows'>".
// $values['content']."</textarea></div>";
// echo "</td></tr>";
// }
// echo "<tr class='tab_bg_1'>";
// echo "<td class='center' colspan=2>";
// $rand = rand();
// $pmCaseUser = $caseInfo->currentUsers[0] ; // by default
// $paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
// echo "<iframe onload='onLoadFrame( event, \"".$caseInfo->caseId."\", ".$pmCaseUser->delIndex.", ".$caseInfo->caseNumber.", \"".$caseInfo->processName."\") ;' id='caseiframe' width=100% style='border:none;' src='".$pmItem->serverURL."/cases/cases_Open?sid=". $_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&rand=$rand' ></iframe>";
// echo "</td></tr>";
// // File upload system
// $width = '100%';
// if ($CFG_GLPI['use_rich_text']) {
// $width = '50%';
// }
// echo "<tr class='tab_bg_1'>";
// echo "<td class='top'>".sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
// DocumentType::showAvailableTypesLink();
// echo "</td>";
// echo "<td class='top'>";
// echo "<div id='fileupload_info'></div>";
// echo "</td>";
// echo "</tr>";
// echo "<tr class='tab_bg_1'>";
// echo "<td colspan='4'>";
// echo "<table width='100%'><tr>";
// echo "<td width='$width '>";
// echo Html::file(array('multiple' => true,
// 'values' => array('filename' => $values['_filename'],
// 'tag' => $values['_tag_filename'])
// ));
// // "<div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
// echo "</td>";
// if ($CFG_GLPI['use_rich_text']) {
// echo "<td width='$width '>";
// if (!isset($rand)) {
// $rand = mt_rand();
// }
// echo Html::imagePaste(array('rand' => $rand));
// echo "</td>";
// }
// echo "</tr></table>";
// echo "</td>";
// echo "</tr>";
// if (!$ticket_template) {
// echo "<tr class='tab_bg_1' style='display:none;'>";
// echo "<td colspan='2' class='center'>";
// if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
// echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
// echo "<input type='hidden' name='_predefined_fields'
// value=\"".Toolbox::prepareArrayForInput($predefined_fields)."\">";
// }
// echo "<input type='submit' name='add' value=\"".__s('Submit message')."\" class='submit'>";
// echo "</td></tr>";
// }
// echo "</table></div>";
// if (!$ticket_template) {
// Html::closeForm();
// }
//}
function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
global $DB, $CFG_GLPI;
@@ -1001,7 +155,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
$CFG_GLPI["root_doc"]."/front/tracking.injector.php' enctype='multipart/form-data'>";
}
$delegating = User::getDelegateGroupsForUser($values['entities_id']);
if (count($delegating)) {
@@ -1036,7 +189,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
echo "<tr class='tab_bg_1'><td colspan='2' class='".$class."'>";
echo "<div id='show_result$rand'>";
$self = $ticket; // new self();
if ($values["_users_id_requester"] == 0) {
$values['_users_id_requester'] = Session::getLoginUserID();
@@ -1072,7 +224,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
echo "<input type='hidden' name='requesttypes_id' value='".RequestType::getDefault('helpdesk').
"'>";
// Load ticket template if available :
$tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'],
$values['itilcategories_id'],
@@ -1146,9 +297,8 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
echo "<div class='center'><table class='tab_cadre_fixe'>";
echo "<tr><th width='30%'>".$caseInfo->processName."</th><th>";
//echo "<tr><th>".__('Describe the incident or request')."</th><th>";
if (Session::isMultiEntitiesMode()) {
echo "(".Dropdown::getDropdownName("glpi_entities", $_REQUEST['entities_id']).")";
}
@@ -1187,7 +337,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
ITILCategory::dropdown($opt);
echo "</td></tr>";
if ($CFG_GLPI['urgency_mask'] != (1<<3)) {
if (!$tt->isHiddenField('urgency')) {
echo "<tr class='tab_bg_1'>";
@@ -1260,7 +409,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
$values['_users_id_observer_notif']['use_notification'][1] = 1;
}
echo "<div class='actor_single first-actor'>";
if (isset($values['_users_id_observer'])) {
$observers = $values['_users_id_observer'];
@@ -1283,7 +431,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
echo "</td></tr>";
}
if (!$tt->isHiddenField('name')
|| $tt->isPredefinedField('name')) {
echo "<tr class='tab_bg_1' style='display:none;'>";
@@ -1310,25 +457,14 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
$rows = 6;
$content_id = "content$rand";
//if ($CFG_GLPI["use_rich_text"]) {
// $values["content"] = $ticket->setRichTextContent($content_id, $values["content"], $rand);
// $cols = 100;
// $rows = 10;
//} else {
$values["content"] = $ticket->setSimpleTextContent($values["content"]);
//}
echo "<div id='content$rand_text'>";
echo "<textarea id='$content_id' name='content' cols='$cols' rows='$rows'>".
$values['content']."</textarea></div>";
echo "</td></tr>";
}
echo "<tr class='tab_bg_1'>";
echo "<td class='center' colspan='2'>";
$rand = rand();
@@ -1376,8 +512,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
echo "</td>";
echo "</tr>";
if (!$ticket_template) {
echo "<tr class='tab_bg_1' style='display:none;'>";
echo "<td colspan='2' class='center'>";
@@ -1403,8 +537,6 @@ function showFormHelpdesk($ID, $pmItem, $caseInfo, $ticket_template=false) {
function processMakerShowCase( $ID, $from_helpdesk ) {
global $CFG_GLPI;
//Html::helpHeader($LANG['job'][13], $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
$pmItem = new PluginProcessmakerProcessmaker( );
$pmItem->login( );
@@ -1418,11 +550,8 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.helpdesk.js?rand=$rand'></script>"; //?rand=$rand'
showFormHelpdesk(Session::getLoginUserID(), $pmItem, $caseInfo);
//echo "</table>";
}
}
function in_array_recursive($needle, $haystack) {
@@ -1515,9 +644,9 @@ Html::helpHeader(__('New ticket'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
if (isset($_REQUEST['case_id'])) {
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE id='".$_REQUEST['case_id']."'";
$res = $DB->query( $query );
if( $DB->numrows( $res ) ) // a ticket already exists for this case, then show new cases
if ($DB->numrows( $res )) { // a ticket already exists for this case, then show new cases
processMakerShowProcessList(Session::getLoginUserID(), 1);
else {
} else {
// before showing the case, we must check the rights for this user to view it, if entity has been changed in the meanwhile
// and must check if entity of the ticket is in the tree of authorized entities for current profile
$processList = PluginProcessmakerProcessmaker::getProcessesWithCategoryAndProfile( $_REQUEST["itilcategories_id"], $_REQUEST["type"], $_SESSION['glpiactiveprofile']['id'], $_REQUEST['entities_id'] );
@@ -1528,8 +657,9 @@ if (isset($_REQUEST['case_id'])) {
}
}
} else
} else {
processMakerShowProcessList(Session::getLoginUserID(), 1);
}
Html::helpFooter();

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,7 +10,12 @@
*/
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;
@@ -18,16 +23,17 @@ class PluginProcessmakerCase extends CommonDBTM {
$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;
@@ -43,22 +49,23 @@ class PluginProcessmakerCase extends CommonDBTM {
/**
* 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) )
if ($caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId)) {
return $this->getFromDB( $caseId );
}
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;
@@ -88,7 +95,7 @@ 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;
@@ -98,7 +105,7 @@ class PluginProcessmakerCase extends CommonDBTM {
$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) {
$row = $PM_DB->fetch_assoc($res);
@@ -125,8 +132,7 @@ class PluginProcessmakerCase extends CommonDBTM {
$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) {
$row = $PM_DB->fetch_assoc($res);
@@ -136,7 +142,7 @@ class PluginProcessmakerCase extends CommonDBTM {
$app_data = array_replace( $app_data, $vars );
$serialized = serialize( $app_data );
$query = "UPDATE application SET APP_DATA='$serialized' WHERE APP_UID='$caseId';" ;
$query = "UPDATE APPLICATION SET APP_DATA='$serialized' WHERE APP_UID='$caseId';";
$res = $PM_DB->query( $query );
if ($PM_DB->affected_rows() == 1) {
@@ -149,9 +155,9 @@ class PluginProcessmakerCase extends CommonDBTM {
/**
* 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) {
@@ -173,6 +179,7 @@ class PluginProcessmakerCase extends CommonDBTM {
echo "<div class='center'> <table id='processmakercasemenu' style='margin-bottom: 0px' class='tab_cadre_fixe'>";
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
// first search for the case
if (self::getCaseIdFromItemTypeAndItemId($item_type, $item_id )) {
@@ -190,12 +197,6 @@ class PluginProcessmakerCase extends CommonDBTM {
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) {
@@ -204,16 +205,6 @@ class PluginProcessmakerCase extends CommonDBTM {
$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" :
@@ -250,13 +241,11 @@ class PluginProcessmakerCase extends CommonDBTM {
}
//echo "<td class='tab_bg_2' colspan='1'>";
echo "</form>";
echo "</td></tr>";
}
break;
case "COMPLETED" :
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
@@ -504,14 +493,10 @@ 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' >" ;
@@ -542,8 +527,9 @@ 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>";
@@ -570,9 +556,10 @@ class PluginProcessmakerCase extends CommonDBTM {
$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 )) {
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
if( $DB->query( $query ) )
if ($DB->query( $query )) {
$ret = true;
}
}
return $ret;
}
@@ -586,9 +573,11 @@ class PluginProcessmakerCase extends CommonDBTM {
global $DB;
$ret = false;
if( $this->deleteTasks() )
if( $this->deleteFromDB( ) )
if ($this->deleteTasks()) {
if ($this->deleteFromDB( )) {
$ret = true;
}
}
return $ret;
}
@@ -625,10 +614,13 @@ class PluginProcessmakerCase extends CommonDBTM {
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;
}
@@ -637,12 +629,12 @@ class PluginProcessmakerCase extends CommonDBTM {
* 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() ) ) {
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

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,9 +69,7 @@ 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) {
@@ -90,19 +110,17 @@ class PluginProcessmakerConfig extends CommonDBTM {
/**
* 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))) ;
$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 );
@@ -111,10 +129,17 @@ class PluginProcessmakerConfig extends CommonDBTM {
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;
@@ -138,13 +163,19 @@ class PluginProcessmakerConfig extends CommonDBTM {
echo Html::scriptBlock("
function setCommonDomain() {
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,7 +195,6 @@ 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']."'>";
@@ -184,7 +214,7 @@ 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'] != ''
&& $config->fields['pm_workspace'] != ''
&& $config->fields["pm_admin_user"] != ''
@@ -261,7 +291,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
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;" ;
$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'];
@@ -304,5 +334,4 @@ class PluginProcessmakerConfig extends CommonDBTM {
return true;
}
}

View File

@@ -43,6 +43,8 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* 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;
@@ -65,10 +67,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
$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'")." ;" ;
$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) {
@@ -151,6 +153,7 @@ 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
@@ -179,10 +182,11 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
} else {
// create it
if( isset( $process->project_type ) )
if (isset( $process->project_type )) {
$project_type = $process->project_type;
else
} else {
$project_type = 'classic';
}
if ($glpiprocess->add( array( 'process_guid' => $process->guid, 'name' => $process->name, 'project_type' => $project_type ))) {
// and add main task category for this process
@@ -199,7 +203,8 @@ 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;
@@ -213,7 +218,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
* 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;
@@ -227,7 +232,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
/**
* 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');
@@ -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 {
@@ -506,7 +510,6 @@ class PluginProcessmakerProcess extends CommonDBTM {
echo Html::convDateTime($this->fields["date_mod"]);
echo "</td></tr>";
$this->showFormButtons($options );
//$this->addDivForTabs();
@@ -538,16 +541,13 @@ class PluginProcessmakerProcess extends CommonDBTM {
$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) ";
}
$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";";
return $DB->query($query);
}

View File

@@ -78,7 +78,6 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
Html::showMassiveActions($massiveactionparams);
}
if ($num > 0) {
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";

View File

@@ -40,8 +40,7 @@ if( !function_exists('http_formdata_flat_hierarchy') ) {
$temp[ $key.'['.$k2.']' ] = $val2;
}
$vars = array_merge( $vars, http_formdata_flat_hierarchy($temp) );
}
else {
} else {
$vars[$key]=$value;
}
}
@@ -78,15 +77,13 @@ if( !function_exists('stripcslashes_deep') ){
*/
class PluginProcessmakerProcessmaker extends CommonDBTM {
// const serverURL = "http://localhost:8080/sysworkflow/en/classic" ;
var $serverURL;
//var $database ;
var $config;
private $pmSoapClient = null;
private $pmWorkspace = "";
private $pmAdminSession = false;
//var $pmSession = '' ;
private $taskWriter = 0;
private $pm_group_guid = ''; // guid for default user group in Process Maker is used for all GLPI user synchronization into ProcessMaker
var $lasterror;
@@ -135,7 +132,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* false otherwise
*/
private function openSoap( ) {
//global $DB;
try {
if ($this->pmSoapClient == null) {
$this->lang = substr( $_SESSION["glpilanguage"], 0, 2);
@@ -151,8 +148,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
return true;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
$this->lasterror = $e;
return false; //null ;
@@ -160,35 +156,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
//function getSearchOptions() {
// global $LANG;
// $tab = array();
// $tab['common'] = "Header Needed";
// $tab[1001]['table'] = 'glpi_plugin_processmaker_cases';
// $tab[1001]['field'] = 'case_status';
// $tab[1001]['name'] = 'Case - Status' ; //$LANG['plugin_example']["name"];
// //$tab[2]['table'] = 'glpi_plugin_example_dropdowns';
// //$tab[2]['field'] = 'name';
// //$tab[2]['name'] = 'Dropdown';
// //$tab[3]['table'] = 'glpi_plugin_example_examples';
// //$tab[3]['field'] = 'serial';
// //$tab[3]['name'] = 'Serial';
// //$tab[3]['usehaving'] = true;
// //$tab[3]['searchtype'] = 'equals';
// //$tab[30]['table'] = 'glpi_plugin_example_examples';
// //$tab[30]['field'] = 'id';
// //$tab[30]['name'] = $LANG["common"][2];
// return $tab;
//}
/**
* Summary of login
* @param mixed $admin_or_user if true will be admin, otherwise is user name (or user id), or current user
@@ -197,7 +164,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*/
function login( $admin_or_user=false ) {
global $DB, $PM_DB;
//unset($_SESSION["pluginprocessmaker"]["session"]["date"]) ;
try {
$locSession = new stdClass; // by default empty object
if ($this->openSoap( )) {
@@ -233,8 +199,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
//$DB->query( "UPDATE glpi_plugin_processmaker_users SET password = '".$pass."' WHERE glpi_users_id = ".$pmusr->getID().";" ) ;
//$pmusr->update( array( $pmusr->getIndexName() => $pmusr->getID(), 'password' => $pass) ) ;
// and must be updated also in PM db
$PM_DB->query("UPDATE rbac_users SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ") ;
$PM_DB->query("UPDATE users SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ") ;
$PM_DB->query("UPDATE RBAC_USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
$PM_DB->query("UPDATE USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
}
$locSession = $this->pmSoapClient->login( array( 'userid' => $gusr->fields['name'], 'password' => 'md5:'.$pmusr->fields['password']) );
if (is_object( $locSession ) && $locSession->status_code == 0) {
@@ -244,17 +210,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$this->pmAdminSession = false;
return true;
}
} else
} else {
return true; // means a session is already existing in $_SESSION["pluginprocessmaker"]["session"]
}
}
$this->pmAdminSession = false;
unset($_SESSION["pluginprocessmaker"]["session"]);
Toolbox::logDebug( "Processmaker Plugin: $admin_or_user - Soap problem: ". print_r( $locSession, true ) );
$this->lasterror = $locSession;
return false;
}
catch ( Exception $e ) {
} catch (Exception $e) {
$this->pmAdminSession = false;
unset($_SESSION["pluginprocessmaker"]["session"]);
Toolbox::logDebug( $e );
@@ -262,14 +228,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
}
///**
// * Summary of logout
// * used to clean variable session from current logged in session
// * will not really do a logout from PM, but is used to force cleaning when previously user was admin
// */
//function logout( ) {
// unset($_SESSION["pluginprocessmaker"]["Session"]) ;
//}
/**
* Summary of processList
@@ -283,17 +241,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmProcessList = $this->pmSoapClient->processList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if (isset( $pmProcessList->processes )) {
if( is_array( $pmProcessList->processes ) )
if (is_array( $pmProcessList->processes )) {
return $pmProcessList->processes;
else {
} else {
return array( 0 => $pmProcessList->processes );
}
}
return false;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -317,15 +274,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
case 'DRAFT' :
case 'TO_DO':
// case 'CANCELLED' :
if( is_object( $pmCaseInfo->currentUsers ) )
if (is_object( $pmCaseInfo->currentUsers )) {
$pmCaseInfo->currentUsers = array( 0 => $pmCaseInfo->currentUsers );
if( $pmCaseInfo->currentUsers[0]->delThreadStatus == 'PAUSE' )
}
if ($pmCaseInfo->currentUsers[0]->delThreadStatus == 'PAUSE') {
$pmCaseInfo->caseStatus = "PAUSED";
}
break;
}
return $pmCaseInfo;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -344,15 +302,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
function routeCase( $caseId, $delIndex) {
try {
$pmRouteCaseResponse = $this->pmSoapClient->routeCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseId' => $caseId, 'delIndex' => $delIndex) );
if( $pmRouteCaseResponse->status_code != 0 )
if ($pmRouteCaseResponse->status_code != 0) {
Toolbox::logDebug( 'routeCase res:', $pmRouteCaseResponse );
}
if( property_exists( $pmRouteCaseResponse, 'routing' ) && is_object( $pmRouteCaseResponse->routing ) )
if (property_exists( $pmRouteCaseResponse, 'routing' ) && is_object( $pmRouteCaseResponse->routing )) {
$pmRouteCaseResponse->routing = array( 0 => $pmRouteCaseResponse->routing);
}
return $pmRouteCaseResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -369,12 +328,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
function triggerList( ) {
try {
$pmTriggerList = $this->pmSoapClient->triggerList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if( is_array( $pmTriggerList->triggers ) )
if (is_array( $pmTriggerList->triggers )) {
return $pmTriggerList->triggers;
else
} else {
return array( 0 => $pmTriggerList->triggers );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -392,12 +351,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmTaskList = $this->pmSoapClient->taskList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if( is_array( $pmTaskList->tasks ) )
if (is_array( $pmTaskList->tasks )) {
return $pmTaskList->tasks;
else
} else {
return array( 0 => $pmTaskList->tasks );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -416,12 +375,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmTaskCase = $this->pmSoapClient->taskCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseId' => $caseId ) );
if( is_array( $pmTaskCase->taskCases ) )
if (is_array( $pmTaskCase->taskCases )) {
return $pmTaskCase->taskCases;
else
} else {
return array( 0 => $pmTaskCase->taskCases );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -437,8 +396,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmClaimCase = $this->pmSoapClient->claimCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'guid' => $caseId, 'delIndex' => $delIndex) );
return $pmClaimCase;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -459,12 +417,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmUnpauseCase = $this->pmSoapClient->unpauseCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseUid' => $caseId, 'delIndex' => $delIndex, 'userUid' => $userId) );
if( is_array( $pmUnpauseCase->processes ) )
if (is_array( $pmUnpauseCase->processes )) {
return $pmUnpauseCase->processes;
else
} else {
return array( 0 => $pmUnpauseCase->processes );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -482,12 +440,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmCaseList = $this->pmSoapClient->caseList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if( is_array( $pmCaseList->cases ) )
if (is_array( $pmCaseList->cases )) {
return $pmCaseList->cases;
else
} else {
return array( 0 => $pmCaseList->cases );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -508,8 +466,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmResults = $this->pmSoapClient->reassignCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseId' => $caseId, 'delIndex' => $delIndex, 'userIdSource' => $userIdSource, 'userIdTarget'=> $userIdTarget) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -529,8 +486,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$deleteCaseResponse = $this->pmSoapClient->deleteCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseUid' => $caseUid) );
return $deleteCaseResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -554,8 +510,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$cancelTaskResponse = $this->pmSoapClient->cancelCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseUid' => $caseUid, 'delIndex' => $delIndex, 'userUid' => $userUid) );
return $cancelTaskResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -581,13 +536,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if ($pmCaseInfo->status_code == 0) {
foreach ($pmCaseInfo->currentUsers as $pmUser) {
$pmCancelTask = $this->cancelTask( $caseUid, $pmUser->delIndex, $pmUser->userId );
if( $pmCancelTask->status_code != 0 )
if ($pmCancelTask->status_code != 0) {
return $pmCancelTask;
}
}
return $pmCancelTask ;
}
catch ( Exception $e ) {
return $pmCancelTask;
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -613,19 +568,19 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if ($vars !== null) {
$aVars = array();
foreach ($vars as $key => $val)
{
foreach ($vars as $key => $val) {
$obj = new variableStruct();
$obj->name = $key;
$obj->value = $val;
$aVars[] = $obj;
}
} else $aVars = '' ;
} else {
$aVars = '';
}
$newCaseResponse = $this->pmSoapClient->newCaseImpersonate( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'processId'=> $this->fields['process_guid'], 'userId' => $userId, 'taskId'=>'', 'variables'=> $aVars) );
return $newCaseResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -648,8 +603,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$this->getFromDB( $processId );
$aVars = array();
foreach ($vars as $key => $val)
{
foreach ($vars as $key => $val) {
$obj = new variableStruct();
$obj->name = $key;
$obj->value = $val;
@@ -659,8 +613,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$newCaseResponse = $this->pmSoapClient->newCase( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'processId'=> $this->fields['process_guid'], 'taskId'=>'', 'variables'=> $aVars) );
return $newCaseResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -676,26 +629,26 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* @return A pmResponse object, or false when exception occured
*/
function sendVariables( $caseId, $vars = array() ) {
if( count( $vars ) == 0 ) // nothing to send
if (count( $vars ) == 0) { // nothing to send
return true;
}
try {
$aVars = array();
foreach ($vars as $key => $val)
{
foreach ($vars as $key => $val) {
$obj = new variableStruct();
$obj->name = $key;
if( is_array( $val ) )
if (is_array( $val )) {
$obj->value = join( "|", $val );
else
} else {
$obj->value = $val;
}
$aVars[] = $obj;
}
$pmResponse = $this->pmSoapClient->sendVariables( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseId' => $caseId, 'variables'=> $aVars) );
return $pmResponse;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -709,15 +662,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* Embedded getVariables() PM web service call (definition: http://wiki.processmaker.com/index.php/2.0/ProcessMaker_WSDL_Web_Services#getVariables.28.29)
* A session must be open before with login()
* @param string $caseId The uID of the case
* @param array $vars an array of variable name that will be read from the case as case variables
* @param array $vars an array of variable name that will be read from the case as case variables Normalizes output to an array, even when only one element is returned by PM Normalizes output to an array, even when only one element is returned by PM
* Normalizes output to an array, even when only one element is returned by PM
* @return array: an associative array (variable_name => value), or false when exception occured. The return array can be empty if requested variables are not found.
*/
function getVariables( $caseId, $vars = array() ) {
try {
$aVars = array();
foreach ($vars as $key => $name)
{
foreach ($vars as $key => $name) {
$obj = new getVariableStruct();
$obj->name = $name;
$aVars[] = $obj;
@@ -728,16 +680,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$variablesArray = array();
if ($pmvariableListResponse->status_code == 0 && isset( $pmvariableListResponse->variables )) {
if( is_array( $pmvariableListResponse->variables ) )
foreach ($pmvariableListResponse->variables as $variable)
if (is_array( $pmvariableListResponse->variables )) {
foreach ($pmvariableListResponse->variables as $variable) {
$variablesArray[$variable->name] = $variable->value;
else
} } else {
$variablesArray[$pmvariableListResponse->variables->name] = $pmvariableListResponse->variables->value;
}
}
return $variablesArray;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -755,12 +707,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmGroupList = $this->pmSoapClient->groupList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if( is_array( $pmGroupList->groups ) )
if (is_array( $pmGroupList->groups )) {
return $pmGroupList->groups;
else
} else {
return array( 0 => $pmGroupList->groups );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -782,8 +734,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
'groupId' => $groupId
) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -803,8 +754,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$pmResults = $this->pmSoapClient->createGroup(array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"],
'name' => $name ) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -819,13 +769,14 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*/
function updateGroup( $group_id, $groupStatus ) {
global $PM_DB;
$query = "UPDATE groupwf SET GRP_STATUS='$groupStatus' WHERE GRP_UID=$group_id;";
$query = "UPDATE GROUPWF SET GRP_STATUS='$groupStatus' WHERE GRP_UID='$group_id';";
$PM_DB->query( $query );
if( $PM_DB->affected_rows != 1 )
if ($PM_DB->affected_rows != 1) {
return false;
else
} else {
return true;
}
}
/**
* Summary of userList
@@ -839,12 +790,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmUserList = $this->pmSoapClient->userList( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
if( is_array( $pmUserList->users ) )
if (is_array( $pmUserList->users )) {
return $pmUserList->users;
else
} else {
return array( 0 => $pmUserList->users );
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -866,9 +817,15 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*/
function createUser( $userId, $firstname, $lastname, $email, $role, $password, $status) {
try {
if( $firstname == null || $firstname == "" ) $firstname = $userId ;
if( $lastname == null || $lastname == "" ) $lastname = $userId ;
if( $email == "" ) $email = $userId."@DoNotReply.com" ;
if ($firstname == null || $firstname == "") {
$firstname = $userId;
}
if ($lastname == null || $lastname == "") {
$lastname = $userId;
}
if ($email == "") {
$email = $userId."@DoNotReply.com";
}
$pmResults = $this->pmSoapClient->createUser(array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"],
'userId' => $userId,
@@ -879,8 +836,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
'password' => $password,
'status' => $status ) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -901,8 +857,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*/
function updateUser( $userUid, $userName, $firstName, $lastName, $status) {
try {
if( $firstName == null || $firstName == "" ) $firstName = $userName ;
if( $lastName == null || $lastName == "" ) $lastName = $userName ;
if ($firstName == null || $firstName == "") {
$firstName = $userName;
}
if ($lastName == null || $lastName == "") {
$lastName = $userName;
}
$pmResults = $this->pmSoapClient->updateUser(array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"],
'userUid' => $userUid,
@@ -912,8 +872,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
'status' => $status
) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -934,8 +893,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
try {
$pmResults = $this->pmSoapClient->executeTrigger(array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"], 'caseId' => $caseId, 'triggerIndex'=> $triggerIndex, 'delIndex' => $delIndex ) );
return $pmResults;
}
catch ( Exception $e ) {
} catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
@@ -955,8 +913,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
switch ($name) {
case 'pmusers' :
return array('description' => $LANG['processmaker']['cron']['pmusers'] );
//case 'pmnotifications' :
// return array('description' => $LANG['processmaker']['cron']['pmnotifications'] );
case 'pmorphancases' :
return array('description' => $LANG['processmaker']['cron']['pmorphancases']['description'], 'parameter' => $LANG['processmaker']['cron']['pmorphancases']['parameter'] );
case 'pmtaskactions' :
@@ -1003,8 +959,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if ($taskaction['toclaim']) {
// must do a claim before solving task
if( !$pm->claimCase( $postdatas['APP_UID'], $postdatas['DEL_INDEX'] ) )
if (!$pm->claimCase( $postdatas['APP_UID'], $postdatas['DEL_INDEX'] )) {
throw new Exception("Can't claim case");
}
$donotif = $CFG_GLPI["use_mailing"];
$CFG_GLPI["use_mailing"] = false;
@@ -1043,11 +1000,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
}
if($error)
if ($error) {
return -1;
else
} else {
return $actionCode;
}
}
/**
@@ -1080,7 +1037,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if (count($draftCases) > 0) {
$pm = new self;
$pm->login(true);
$query = "SELECT * FROM application
$query = "SELECT * FROM APPLICATION
WHERE APP_DATA LIKE '%s:24:\"GLPI_SELFSERVICE_CREATED\";s:1:\"1\"%'
AND APP_STATUS = 'DRAFT'
AND DATEDIFF( NOW(), APP_UPDATE_DATE) > ".$task->fields['param']."
@@ -1098,84 +1055,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
}
}
if($error)
if ($error) {
return -1;
else
} else {
return $actionCode;
}
}
///**
//* summary of cronPMNotifications
//* Execute 1 task managed by the plugin
//* @param: $task CronTask class for log / stat
//* @return integer
//* >0 : done
//* <0 : to be run again (not finished)
//* 0 : nothing to do
//*/
//static function cronPMNotifications($task) {
// global $DB, $GLOBALS, $CFG_GLPI ;
// $actionCode = 0; // by default
// $error = false ;
// $task->setVolume(0); // start with zero
// if ( $CFG_GLPI["use_mailing"]) {
// // will simulate a real session
// $oldGlpiCronUserRunning = $_SESSION["glpicronuserrunning"] ;
// // get the complete user list from GLPI DB
// $taskNotificationList = array() ;
// foreach($DB->request("SELECT * FROM glpi_plugin_processmaker_tasksnotifications ORDER BY id") as $locTicketNotification) {
// $locTicketTask = new TicketTask;
// if( $locTicketTask->getFromDB( $locTicketNotification['task_id'] ) ){
// $locTec = new User ;
// $locTec->getFromDB( $locTicketNotification['tech_id'] ) ;
// if( $locTec->getFromDB( $locTicketNotification['tech_id'] ) && substr( $locTec->fields['realname'], 0, 1) != "*" ){
// $_SESSION["glpicronuserrunning"] = $locTec->fields['realname']." ".$locTec->fields['firstname'] ;
// }
// switch( $locTicketNotification['action'] ) {
// case 'INSERT' :
// // in this case, we need the ticket in $locTicketTask->input['_job']
// $item = new Ticket();
// $item->getFromDB( $locTicketTask->fields['tickets_id'] );
// $locTicketTask->input['_job']=$item;
// $locTicketTask->post_addItem( ) ;
// break;
// case 'UPDATE' :
// // in this case we need to add updates array to $locTicketTask
// $locTicketTask->updates[] = 'actiontime' ;
// $locTicketTask->updates[] = 'state' ;
// $locTicketTask->updates[] = 'begin' ;
// $locTicketTask->updates[] = 'end' ;
// $locTicketTask->updates[] = 'users_id_tech' ;
// $locTicketTask->post_updateItem( ) ;
// break ;
// }
// $task->addVolume(1);
// //$task->log( "Notification sent" ) ;
// $_SESSION["glpicronuserrunning"] = $oldGlpiCronUserRunning ;
// }
// $query = "DELETE FROM glpi_plugin_processmaker_tasksnotifications WHERE id=".$locTicketNotification['id'].";" ;
// $DB->query( $query ) ;
// }
// } else {
// $task->log( "Notification are disabled!" ) ;
// // we must delete all existing notifications requests
// $query = "DELETE FROM glpi_plugin_processmaker_tasksnotifications;" ;
// $DB->query( $query ) ;
// }
// if($error)
// return -1 ;
// else
// return $actionCode;
//}
/**
@@ -1207,7 +1093,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$pmGroupList = $myProcessMaker->groupList( );
foreach ($pmGroupList as $pmGroup) {
if( $pmGroup->guid == $myProcessMaker->pm_group_guid ) break ; // to get the name :)
if ($pmGroup->guid == $myProcessMaker->pm_group_guid) {
break; // to get the name :)
}
}
$pmUserList = array();
@@ -1237,10 +1125,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// then assign user to group
$pmResult2 = $myProcessMaker->assignUserToGroup( $pmResult->userUID, $pmGroup->guid );
if( $pmResult2->status_code == 0 )
if ($pmResult2->status_code == 0) {
$task->log( "Added user: '".$user['name']."' to '".$pmGroup->name."' group" );
else
} else {
$task->log( "Error PM: '".$pmResult2->message."'" );
}
// insert into DB the link between glpi users and pm user
$pmuser = new PluginProcessmakerUser;
@@ -1257,9 +1146,10 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$actionCode = -1;
$error = true;
}
} else
} else {
unset( $glpiUserList[$user['name']] );
}
}
if (!$error) {
@@ -1282,10 +1172,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
}
if( $user['is_active'] == 0 || $user['is_deleted'] == 1 )
if ($user['is_active'] == 0 || $user['is_deleted'] == 1) {
$status = "INACTIVE";
else
} else {
$status = "ACTIVE";
}
if ($status != $pmUserList[strtolower($user['name'])]['status']) {
$task->addVolume(1);
$pmResult = $myProcessMaker->updateUser( $pmUserList[strtolower($user['name'])]['guid'], $user['name'], $user['firstname'], $user['realname'], $status );
@@ -1324,8 +1215,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// }
//}
// so now treat GLPI groups
$glpiGroupList = array();
foreach ($DB->request("SELECT id, name, is_task, is_usergroup FROM glpi_groups WHERE is_task=1 AND is_usergroup=1") as $dbgroup) {
@@ -1333,9 +1222,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
$pmGroupList = self::getPMGroups(); // array();
//foreach($PM_DB->request("SELECT * FROM content WHERE content.CON_CATEGORY='GRP_TITLE' AND content.CON_LANG='en'") as $dbgroup){
// $pmGroupList[$dbgroup['CON_VALUE']] = $dbgroup;
//}
// here we can compare group lists like done for the users
$arrayDiff = array_diff_key( $glpiGroupList, $pmGroupList );
@@ -1353,10 +1239,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// review and update all users in each group
$pmGroupList = self::getPMGroups(); // array();
//$pmGroupList = array() ; // reset groups and get the new complete list from PM DB
//foreach($PM_DB->request("SELECT * FROM content WHERE content.CON_CATEGORY='GRP_TITLE' AND content.CON_LANG='en'") as $dbgroup){
// $pmGroupList[$dbgroup['CON_VALUE']] = $dbgroup ;
//}
// now should refresh the existing users into groups
$arrayDiff = array_intersect_key( $glpiGroupList, $pmGroupList );
@@ -1364,7 +1246,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// for each group will delete users and re-create them
// not really optimized, but this way we are sure that groups are synchronized
// must be redesigned
$query = "DELETE FROM group_user WHERE group_user.GRP_UID='".$pmGroupList[$group['name']]['CON_ID']."';";
$query = "DELETE FROM GROUP_USER WHERE GROUP_USER.GRP_UID='".$pmGroupList[$group['name']]['CON_ID']."';";
$PM_DB->query( $query );
// and insert all users from real GLPI group
foreach ($DB->request("SELECT glpi_groups_users.users_id, glpi_plugin_processmaker_users.pm_users_id
@@ -1372,7 +1254,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
JOIN glpi_groups_users ON glpi_groups_users.groups_id=glpi_groups.id
JOIN glpi_plugin_processmaker_users ON glpi_plugin_processmaker_users.id=glpi_groups_users.users_id
WHERE glpi_groups.name='".$group['name']."'") as $user ) {
$query = "INSERT INTO group_user (`GRP_UID`, `USR_UID`) VALUES ( '".$pmGroupList[$group['name']]['CON_ID']."', '".$user['pm_users_id']."' )" ;
$query = "INSERT INTO GROUP_USER (`GRP_UID`, `USR_UID`) VALUES ( '".$pmGroupList[$group['name']]['CON_ID']."', '".$user['pm_users_id']."' )";
$PM_DB->query( $query );
}
$task->addVolume(1);
@@ -1380,14 +1262,15 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
// now should renew the duedate of the users
$PM_DB->query("UPDATE users SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ") ;
$PM_DB->query("UPDATE rbac_users SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ") ;
$PM_DB->query("UPDATE USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
$PM_DB->query("UPDATE RBAC_USERS SET USR_DUE_DATE='2035-12-31' WHERE USR_DUE_DATE<>'2035-12-31'; ");
if($error)
if ($error) {
return -1;
else
} else {
return $actionCode;
}
}
public static function plugin_pre_item_add_processmaker($parm) {
@@ -1468,10 +1351,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if (array_key_exists( 'GLPI_ITEM_SET_STATUS', $txtForTasks )) {
$itemSetStatus = $txtForTasks[ 'GLPI_ITEM_SET_STATUS' ];
}
if( array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $txtForTasks ) )
if (array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $txtForTasks )) {
$txtToAppendToTask = $txtForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ];
else
} else {
$txtToAppendToTask = '';
}
// reset those variables
$resultSave = $myProcessMaker->sendVariables( $myCase->getID(), array( "GLPI_ITEM_APPEND_TO_TASK" => '',
@@ -1535,7 +1419,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
public static function plugin_pre_item_add_processmaker_followup($parm) {
//global $DB ;
}
@@ -1585,8 +1468,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* @param $caseInfo mixed getCaseInfoResponse object (see: getCaseInfo() function)
* @param $delIndex integer index of the delegation
* @param $techId integer GLPI user id to which a task must be assigned, if == 0 will use $groupId and/or $pmTaskId
* @param $groupId string PM group guid to assign to task, used when $techId == 0
* @param $pmTaskId string PM task guid, used when $groupId == 0 AND $techID == 0
* @param groupId string PM group guid to assign to task, used when $techId == 0
* @param pmTaskId string PM task guid, used when $groupId == 0 AND $techID == 0
* @param $options array of options, default values are
* 'txtTaskContent' => '',
* 'start_date' => '',
@@ -1652,12 +1535,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if ($techId == 0) { // then we must look-up DB to get the pseudo-group that will be assigned to the task
$groupname='';
if ($groupId == 0) {
$query = "SELECT content.CON_VALUE FROM task_user
JOIN content ON content.CON_ID=task_user.USR_UID AND content.CON_CATEGORY='GRP_TITLE' AND content.CON_LANG = 'en'
WHERE task_user.tas_uid='$pmTaskId' AND task_user.tu_relation=2 LIMIT 1;" ;
$query = "SELECT CONTENT.CON_VALUE FROM TASK_USER
JOIN CONTENT ON CONTENT.CON_ID=TASK_USER.USR_UID AND CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG = 'en'
WHERE TASK_USER.TAS_UID='$pmTaskId' AND TASK_USER.TU_RELATION=2 LIMIT 1;";
} else {
$query = "SELECT CON_VALUE FROM content
WHERE content.CON_ID='$groupId' AND content.CON_CATEGORY='GRP_TITLE' AND content.CON_LANG = 'en' ;" ;
$query = "SELECT CON_VALUE FROM CONTENT
WHERE CONTENT.CON_ID='$groupId' AND CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG='en' ;";
}
// as there is a LIMIT of 1
// or
@@ -1680,21 +1563,23 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
self::addWatcher( $itemType, $itemId, $techId );
}
// manage task description
$input['content'] = ""; // by default empty :)
if ($options['txtTaskContent'] != '') {
$input['content'] = $options['txtTaskContent'];
}
elseif( !$pmProcess->fields["hide_case_num_title"] ) {
} else if (!$pmProcess->fields["hide_case_num_title"]) {
$input['content'] = $LANG['processmaker']['item']['task']['case'].$caseInfo->caseName;
}
if ($pmProcess->fields["insert_task_comment"]) {
if( $input['content'] != '' ) $input['content'] .= "\n" ;
if ($input['content'] != '') {
$input['content'] .= "\n";
}
$input['content'] .= $LANG['processmaker']['item']['task']['comment'];
}
if( $input['content'] != '' ) $input['content'] .= "\n" ;
if ($input['content'] != '') {
$input['content'] .= "\n";
}
$input['content'] .= $LANG['processmaker']['item']['task']['manage'];
$input['is_private'] = 0;
@@ -1780,10 +1665,10 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
///
/**
* Summary of computeTaskDuration
* Compute duration of the task
* @param mixed $task
* @param mixed $entity
* @return mixed
*/
function computeTaskDuration( $task, $entity ) {
@@ -1953,7 +1838,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
/**
* Summary of getCaseIdFromItem
* get case id for an id item_id of type item_type (if a case if attached to it)
@@ -1990,13 +1874,15 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$caseId = self::getCaseIdFromItem( $item_type, $item_id );
if ($caseId !== false) {
$caseInfo = $this->getCaseInfo( $caseId );
if( $caseInfo !== false && $caseInfo->status_code == 0 )
if ($caseInfo !== false && $caseInfo->status_code == 0) {
return $caseInfo;
else
} else {
return false; // means any error
} else
}
} else {
return false; // means no case
}
}
/**
* Summary of multiexplode
@@ -2343,7 +2229,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* //@param string $cookie: is the $_SERVER['HTTP_COOKIE'] string
* @return mixed: returns false if request failed, otherwise, returns true
*/
public function saveForm( $request ) { //, $cookie ) {
public function saveForm( $request ) {
//, $cookie ) {
if (!function_exists( 'HandleHeaderLine' )) {
function HandleHeaderLine( $curl, $header_line ) {
@@ -2501,7 +2388,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$locItem->fields['due_date'] = "";
}
$resultCase = $this->newCase( $processId,
array('GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_TICKET_ID' => $itemId,
@@ -2554,11 +2440,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* @param mixed $request
* @param mixed $users_id
*/
public function derivateCase( $myCase, $request, $users_id=null ) { //$cookies,
public function derivateCase( $myCase, $request, $users_id=null ) {
//$cookies,
global $PM_DB;
// save the case variables
$resultSave = $this->saveForm( $request ) ;//, $_SERVER['HTTP_COOKIE'] ) ;
$resultSave = $this->saveForm( $request );
// now derivate the case !!!
$pmRouteCaseResponse = $this->routeCase( $myCase->getID(), $request['DEL_INDEX']);
@@ -2691,7 +2578,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
public static function getPMGroups( ) {
global $PM_DB;
$pmGroupList = array();
foreach($PM_DB->request("SELECT * FROM content WHERE content.CON_CATEGORY='GRP_TITLE' AND content.CON_LANG='en'") as $dbgroup){
foreach ($PM_DB->request("SELECT * FROM CONTENT WHERE CONTENT.CON_CATEGORY='GRP_TITLE' AND CONTENT.CON_LANG='en'") as $dbgroup) {
$pmGroupList[$dbgroup['CON_VALUE']] = $dbgroup;
}
return $pmGroupList;

View File

@@ -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'],

View File

@@ -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,18 +31,16 @@ 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
$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;
@@ -50,11 +48,9 @@ class PluginProcessmakerUser extends CommonDBTM {
case "all" :
$where = " `glpi_users`.`id` > '1' ";
break;
}
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
// $where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND TAS_UID = '$taskId' " ;
$where .= " AND `glpi_users`.`is_deleted` = '0'
AND `glpi_users`.`is_active` = '1' ";
@@ -88,10 +84,6 @@ 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 " ;
$query .= " LEFT JOIN `glpi_useremails`
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";

View File

@@ -6,8 +6,9 @@ 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,7 +84,6 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
}
// try to redim caseIFrame
if (!redimIFrame) {
var locElt = contentDocument.getElementsByTagName("form")[0];
@@ -93,13 +93,11 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
}
}
if( caseTimerCounter > 3000 )
if ( caseTimerCounter > 3000 ) {
window.clearInterval(caseTimer);
else
} else {
caseTimerCounter = caseTimerCounter + 1;
},
10) ;
}
}, 10);
}

View File

@@ -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
@@ -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 {
@@ -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

@@ -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,10 +39,6 @@ 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)) {
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
@@ -66,7 +48,6 @@ function plugin_init_processmaker() {
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
);
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
@@ -90,7 +71,6 @@ 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'
);
@@ -104,15 +84,12 @@ function plugin_init_processmaker() {
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';
}
@@ -123,7 +100,7 @@ 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');
@@ -135,25 +112,12 @@ function plugin_processmaker_check_prerequisites(){
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;
// }
// 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;
}
@@ -163,4 +127,3 @@ function plugin_processmaker_haveRight($module,$right) {
return Session::haveRight("plugin_processmaker_".$module, $right);
}
?>