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:
@@ -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);
|
||||
|
||||
@@ -6,17 +6,16 @@
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownProcesses.php")) {
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
if (strpos($_SERVER['PHP_SELF'], "dropdownProcesses.php")) {
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
//include_once dirname(__FILE__)."/../inc/process.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
@@ -29,7 +28,7 @@ if (isset($_REQUEST["entity_restrict"])
|
||||
|
||||
// Security
|
||||
if (!($item = getItemForItemtype($_REQUEST['itemtype']))) {
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
$one_item = -1;
|
||||
@@ -40,36 +39,36 @@ if (isset($_POST['_one_id'])) {
|
||||
$count = 0;
|
||||
|
||||
if (!isset($_REQUEST['emptylabel']) || ($_REQUEST['emptylabel'] == '')) {
|
||||
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
|
||||
$_REQUEST['emptylabel'] = Dropdown::EMPTY_VALUE;
|
||||
}
|
||||
|
||||
$search="";
|
||||
if (!empty($_REQUEST['searchText'])) {
|
||||
$search = Search::makeTextSearch($_REQUEST['searchText']);
|
||||
$search = Search::makeTextSearch($_REQUEST['searchText']);
|
||||
}
|
||||
|
||||
$processes = array();
|
||||
|
||||
// Empty search text : display first
|
||||
if (empty($_REQUEST['searchText'])) {
|
||||
if ($_REQUEST['display_emptychoice']) {
|
||||
if (($one_item < 0) || ($one_item == 0)) {
|
||||
array_push($processes, array('id' => 0,
|
||||
'text' => $_REQUEST['emptylabel']));
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['display_emptychoice']) {
|
||||
if (($one_item < 0) || ($one_item == 0)) {
|
||||
array_push($processes, array('id' => 0,
|
||||
'text' => $_REQUEST['emptylabel']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
|
||||
|
||||
if ($DB->numrows($result)) {
|
||||
while ($data=$DB->fetch_array($result)) {
|
||||
if( in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) ) ) {
|
||||
array_push( $processes, array( 'id' => $data["id"],
|
||||
'text' => $data["name"] ));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
while ($data=$DB->fetch_array($result)) {
|
||||
if (in_array( $_REQUEST["entity_restrict"], PluginProcessmakerProcess::getEntitiesForProfileByProcess( $data["id"], $_SESSION['glpiactiveprofile']['id'], true) )) {
|
||||
array_push( $processes, array( 'id' => $data["id"],
|
||||
'text' => $data["name"] ));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ret['results'] = $processes;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"dropdownUsers.php")) {
|
||||
if (strpos($_SERVER['PHP_SELF'], "dropdownUsers.php")) {
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
@@ -24,7 +24,7 @@ if (!defined('GLPI_ROOT')) {
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
$PM_DB = new PluginProcessmakerDB;
|
||||
|
||||
if (!isset($_REQUEST['right'])) {
|
||||
$_REQUEST['right'] = "all";
|
||||
@@ -35,13 +35,6 @@ if (!isset($_REQUEST['all'])) {
|
||||
$_REQUEST['all'] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$used = array();
|
||||
|
||||
if (isset($_REQUEST['used'])) {
|
||||
@@ -64,9 +57,6 @@ if (!isset($_REQUEST['page'])) {
|
||||
|
||||
if ($one_item < 0) {
|
||||
$start = ($_REQUEST['page']-1)*$_REQUEST['page_limit'];
|
||||
//$result = User::getSqlSearchResult(false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
// $_REQUEST['value'], $used, $_REQUEST['searchText'], $start,
|
||||
// $_REQUEST['page_limit']);
|
||||
$LIMIT = "LIMIT $start,".$_REQUEST['page_limit'];
|
||||
$result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['pmTaskId'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"],
|
||||
$_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT);
|
||||
@@ -94,9 +84,6 @@ if (!function_exists('dpuser_cmp')) {
|
||||
}
|
||||
}
|
||||
|
||||
// Sort non case sensitive
|
||||
//uasort($users, 'dpuser_cmp');
|
||||
|
||||
$datas = array();
|
||||
|
||||
// Display first if empty search
|
||||
|
||||
@@ -6,45 +6,41 @@
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"task_users.php")) {
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
if (strpos($_SERVER['PHP_SELF'], "task_users.php")) {
|
||||
include ("../../../inc/includes.php");
|
||||
header("Content-Type: text/html; charset=UTF-8");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not acces directly to this file");
|
||||
die("Can not acces directly to this file");
|
||||
}
|
||||
|
||||
//include_once dirname(__FILE__)."/../inc/processmaker.class.php" ;
|
||||
//include_once dirname(__FILE__)."/../inc/users.class.php" ;
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
$PM_DB = new PluginProcessmakerDB;
|
||||
$rand = rand();
|
||||
|
||||
echo "<form style='margin-bottom: 0px' name='processmaker_form_task$rand-".$_REQUEST['delIndex']."' id='processmaker_form_task$rand-".$_REQUEST['delIndex']."' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
|
||||
echo $LANG['processmaker']['item']['reassigncase']." ";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='id' value='".$_REQUEST['itemId']."'>";
|
||||
echo "<input type='hidden' name='itemtype' value='".$_REQUEST['itemType']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$_REQUEST['caseId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$_REQUEST['delIndex']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_userId' value='".$_REQUEST['userId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_taskId' value='".$_REQUEST['taskId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delThread' value='".$_REQUEST['delThread']."'>";
|
||||
echo $LANG['processmaker']['item']['reassigncase']." ";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='id' value='".$_REQUEST['itemId']."'>";
|
||||
echo "<input type='hidden' name='itemtype' value='".$_REQUEST['itemType']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$_REQUEST['caseId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$_REQUEST['delIndex']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_userId' value='".$_REQUEST['userId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_taskId' value='".$_REQUEST['taskId']."'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_delThread' value='".$_REQUEST['delThread']."'>";
|
||||
|
||||
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
|
||||
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
|
||||
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
|
||||
'entity_sons' => false, // not used, as any user can be assigned to any tasks
|
||||
'right' => 'all',
|
||||
'rand' => $rand,
|
||||
'width' => '',
|
||||
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
|
||||
echo " ";
|
||||
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
|
||||
Html::closeForm(true);
|
||||
//echo "</form>";
|
||||
PluginProcessmakerUser::dropdown( array('name' => 'users_id_recipient',
|
||||
'value' => PluginProcessmakerUser::getGLPIUserId( $_REQUEST['userId'] ),
|
||||
'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks
|
||||
'entity_sons' => false, // not used, as any user can be assigned to any tasks
|
||||
'right' => 'all',
|
||||
'rand' => $rand,
|
||||
'width' => '',
|
||||
'specific_tags' => array('pmTaskId' => $_REQUEST['taskId'])));
|
||||
echo " ";
|
||||
echo "<input type='submit' name='reassign' value='".$LANG['processmaker']['item']['buttonreassigncase']."' class='submit'>";
|
||||
Html::closeForm(true);
|
||||
|
||||
|
||||
@@ -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`;
|
||||
@@ -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 ;
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
|
||||
@@ -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` ;
|
||||
@@ -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` ;
|
||||
@@ -2,39 +2,39 @@
|
||||
include_once '../../../inc/includes.php';
|
||||
|
||||
// check if it is from PM pages
|
||||
if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] ) ) {
|
||||
if (isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) {
|
||||
// then get item id from DB
|
||||
$myCase = new PluginProcessmakerCase ;
|
||||
if( $myCase->getFromDB( $_REQUEST['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
$myCase = new PluginProcessmakerCase;
|
||||
if ($myCase->getFromDB( $_REQUEST['APP_UID'] )) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login( );
|
||||
|
||||
if( isset( $_REQUEST['form'] ) ) {
|
||||
if (isset( $_REQUEST['form'] )) {
|
||||
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ) {
|
||||
} else if (isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID'])) {
|
||||
// Claim task management
|
||||
// here we are in a Claim request
|
||||
$myCase = new PluginProcessmakerCase ;
|
||||
if( $myCase->getFromDB( $_REQUEST['form']['APP_UID'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
$myCase = new PluginProcessmakerCase;
|
||||
if ($myCase->getFromDB( $_REQUEST['form']['APP_UID'] )) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login( );
|
||||
|
||||
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
$pmClaimCase = $myProcessMaker->claimCase( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
|
||||
|
||||
// now manage tasks associated with item
|
||||
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] );
|
||||
}
|
||||
}
|
||||
|
||||
// now redirect to item form page
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
$config = PluginProcessmakerConfig::getInstance();
|
||||
echo "<html><body><script>";
|
||||
if( isset($config->fields['domain']) && $config->fields['domain'] != '' ) {
|
||||
if (isset($config->fields['domain']) && $config->fields['domain'] != '') {
|
||||
echo "document.domain='{$config->fields['domain']}';";
|
||||
}
|
||||
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
|
||||
echo "</script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>";
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
<?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);
|
||||
$config->check($_POST['id'], UPDATE);
|
||||
|
||||
// save
|
||||
$config->update($_POST);
|
||||
// save
|
||||
$config->update($_POST);
|
||||
|
||||
|
||||
Html::back();
|
||||
Html::back();
|
||||
|
||||
} elseif (isset($_POST["refresh"])) {
|
||||
$config->refresh($_POST); // used to refresh process list, task category list
|
||||
Html::back();
|
||||
} else if (isset($_POST["refresh"])) {
|
||||
$config->refresh($_POST); // used to refresh process list, task category list
|
||||
Html::back();
|
||||
}
|
||||
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/config.form.php?forcetab=".
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
<?php
|
||||
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
include_once ("../../../inc/includes.php");
|
||||
|
||||
Plugin::load('processmaker',true);
|
||||
Plugin::load('processmaker', true);
|
||||
|
||||
if (!isset($_REQUEST["id"])) {
|
||||
$_REQUEST["id"] = "";
|
||||
$_REQUEST["id"] = "";
|
||||
}
|
||||
|
||||
$PluginProcess = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_REQUEST["update"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->update($_REQUEST);
|
||||
Html::back();
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->update($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} elseif (isset($_REQUEST["refreshtask"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->refreshTasks($_REQUEST);
|
||||
Html::back();
|
||||
} else if (isset($_REQUEST["refreshtask"])) {
|
||||
$PluginProcess->check($_REQUEST['id'], UPDATE);
|
||||
$PluginProcess->refreshTasks($_REQUEST);
|
||||
Html::back();
|
||||
|
||||
} else {
|
||||
// $PluginProcess->checkGlobal(READ);
|
||||
Html::header($LANG['processmaker']['title'][1],$_SERVER["PHP_SELF"],"plugins","processmaker");
|
||||
|
||||
$PluginProcess->display($_REQUEST) ;
|
||||
Html::header($LANG['processmaker']['title'][1], $_SERVER["PHP_SELF"], "plugins", "processmaker");
|
||||
|
||||
// $PluginProcess->showForm($_REQUEST["id"]);
|
||||
$PluginProcess->display($_REQUEST);
|
||||
|
||||
Html::footer();
|
||||
Html::footer();
|
||||
}
|
||||
?>
|
||||
@@ -1,25 +1,23 @@
|
||||
<?php
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
|
||||
include_once ("../../../inc/includes.php");
|
||||
|
||||
Html::header($LANG['processmaker']['title'][1], $_SERVER['PHP_SELF'], "plugins", "processmaker");
|
||||
|
||||
if (Session::haveRight("plugin_processmaker_config",READ) || Session::haveRight("config", UPDATE)) {
|
||||
$process=new PluginProcessmakerProcess();
|
||||
if (Session::haveRight("plugin_processmaker_config", READ) || Session::haveRight("config", UPDATE)) {
|
||||
$process=new PluginProcessmakerProcess();
|
||||
|
||||
if( isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config",UPDATE) ) {
|
||||
$process->refresh();
|
||||
Html::back();
|
||||
}
|
||||
if (isset( $_REQUEST['refresh'] ) && Session::haveRight("plugin_processmaker_config", UPDATE)) {
|
||||
$process->refresh();
|
||||
Html::back();
|
||||
}
|
||||
|
||||
$process->title();
|
||||
$process->title();
|
||||
|
||||
Search::show('PluginProcessmakerProcess');
|
||||
Search::show('PluginProcessmakerProcess');
|
||||
|
||||
} else {
|
||||
Html::displayRightError();
|
||||
Html::displayRightError();
|
||||
}
|
||||
Html::footer();
|
||||
|
||||
?>
|
||||
@@ -1,42 +1,39 @@
|
||||
<?php
|
||||
|
||||
//define('GLPI_ROOT', '../../..');
|
||||
include_once ("../../../inc/includes.php");
|
||||
|
||||
Session::checkCentralAccess();
|
||||
|
||||
$profile = new Profile();
|
||||
$right = new PluginProcessmakerProcess_Profile();
|
||||
$process = new PluginProcessmakerProcess();
|
||||
$process = new PluginProcessmakerProcess();
|
||||
|
||||
if (isset($_POST["add"])) {
|
||||
|
||||
$right->check(-1,UPDATE,$_POST);
|
||||
if ($right->add($_POST)) {
|
||||
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
|
||||
}
|
||||
Html::back();
|
||||
$right->check(-1, UPDATE, $_POST);
|
||||
if ($right->add($_POST)) {
|
||||
//Event::log($_POST["processes_id"], "PluginProcessMakerProcess", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][61]);
|
||||
}
|
||||
Html::back();
|
||||
|
||||
} else if (isset($_POST["delete"])) {
|
||||
|
||||
if (isset($_POST["item"]) && count($_POST["item"])) {
|
||||
foreach ($_POST["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
if ($right->can($key,UPDATE)) {
|
||||
$right->delete(array('id' => $key));
|
||||
}
|
||||
if (isset($_POST["item"]) && count($_POST["item"])) {
|
||||
foreach ($_POST["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
if ($right->can($key, UPDATE)) {
|
||||
$right->delete(array('id' => $key));
|
||||
}
|
||||
}
|
||||
//if (isset($_POST["processes_id"])) {
|
||||
// Event::log($_POST["processes_id"], "users", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (isset($_POST["processes_id"])) {
|
||||
// Event::log($_POST["processes_id"], "users", 4, "setup",
|
||||
// $_SESSION["glpiname"]." ".$LANG['log'][62]);
|
||||
// }
|
||||
}
|
||||
Html::back();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Html::displayErrorAndDie("lost");
|
||||
?>
|
||||
@@ -1,124 +1,123 @@
|
||||
<?php
|
||||
include_once ("../../../inc/includes.php");
|
||||
//include_once '../inc/processmaker.class.php' ;
|
||||
//include_once '../inc/cases.class.php' ;
|
||||
|
||||
switch( $_POST["action"] ) {
|
||||
case 'newcase':
|
||||
if( isset($_POST['id']) && $_POST['id'] > 0 ) { // then this case will be bound to an item
|
||||
// we must check if a case is not already existing
|
||||
// to manage the problem of F5 (Refresh)
|
||||
$hasCase = PluginProcessmakerProcessmaker::getCaseIdFromItem( $_POST['itemtype'], $_POST['id'] ) ;
|
||||
if( $hasCase === false && $_POST['plugin_processmaker_process_id'] > 0 ) { //$DB->numrows($res) == 0) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ; //openSession();
|
||||
switch ($_POST["action"]) {
|
||||
case 'newcase':
|
||||
if (isset($_POST['id']) && $_POST['id'] > 0) { // then this case will be bound to an item
|
||||
// we must check if a case is not already existing
|
||||
// to manage the problem of F5 (Refresh)
|
||||
$hasCase = PluginProcessmakerProcessmaker::getCaseIdFromItem( $_POST['itemtype'], $_POST['id'] );
|
||||
if ($hasCase === false && $_POST['plugin_processmaker_process_id'] > 0) { //$DB->numrows($res) == 0) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login(); //openSession();
|
||||
|
||||
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() ) ;
|
||||
|
||||
if ($resultCase->status_code == 0){
|
||||
Html::back();
|
||||
}
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
|
||||
} else
|
||||
Html::back();
|
||||
}
|
||||
else { // the case is created before the ticket (used for post-only case creation before ticket creation)
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
|
||||
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
|
||||
'GLPI_SELFSERVICE_CREATED' => '1',
|
||||
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ) ;
|
||||
if ($resultCase->status_code == 0){
|
||||
// case is created
|
||||
// Must show it...
|
||||
//
|
||||
$rand = rand( ) ;
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
|
||||
$resultCase = $myProcessMaker->startNewCase( $_POST['plugin_processmaker_process_id'], $_POST['itemtype'], $_POST['id'], Session::getLoginUserID() );
|
||||
|
||||
if ($resultCase->status_code == 0) {
|
||||
Html::back();
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR);
|
||||
}
|
||||
} else {
|
||||
Html::back();
|
||||
}
|
||||
} else { // the case is created before the ticket (used for post-only case creation before ticket creation)
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login();
|
||||
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
|
||||
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
|
||||
'GLPI_SELFSERVICE_CREATED' => '1',
|
||||
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) );
|
||||
if ($resultCase->status_code == 0) {
|
||||
// case is created
|
||||
// Must show it...
|
||||
//
|
||||
$rand = rand( );
|
||||
Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?process_id=".$_POST['plugin_processmaker_process_id']."&case_id=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']);
|
||||
|
||||
}
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['error'][$resultCase->status_code]."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); //echo "Error creating case: $resultCase->message \n";
|
||||
Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1");
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unpausecase_or_reassign_or_delete' :
|
||||
if( isset( $_POST['unpause'] ) ) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ; //openSession();
|
||||
$pmResultUnpause = $myProcessMaker->unpauseCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
if ($pmResultUnpause->status_code == 0){
|
||||
Html::back();
|
||||
case 'unpausecase_or_reassign_or_delete' :
|
||||
if (isset( $_POST['unpause'] )) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login(); //openSession();
|
||||
$pmResultUnpause = $myProcessMaker->unpauseCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] );
|
||||
if ($pmResultUnpause->status_code == 0) {
|
||||
Html::back();
|
||||
} else {
|
||||
echo "Error unpausing case: ".$pmResultUnpause->message." \n";
|
||||
}
|
||||
} else if (isset( $_POST['reassign'] )) {
|
||||
// here we should re-assign the current task to $_POST['users_id_recipient']
|
||||
$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] );
|
||||
if ($_POST['plugin_processmaker_userId'] != $GLPINewPMUserId) {
|
||||
$locPM = new PluginProcessmakerProcessmaker();
|
||||
$locPM->login( );
|
||||
|
||||
$pmResponse = $locPM->reassignCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'], $GLPINewPMUserId );
|
||||
if ($pmResponse->status_code == 0) {
|
||||
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
|
||||
// we need the delindex of the current glpi task, and the delindex of the new one
|
||||
// search for new delindex
|
||||
$newCaseInfo = $locPM->getCaseInfo( $_POST['plugin_processmaker_caseId'] );
|
||||
$newDelIndex = 0;
|
||||
foreach ($newCaseInfo->currentUsers as $newCaseUser) {
|
||||
if ($newCaseUser->taskId == $_POST['plugin_processmaker_taskId'] && $newCaseUser->delThread == $_POST['plugin_processmaker_delThread']) {
|
||||
$newDelIndex = $newCaseUser->delIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] );
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
|
||||
}
|
||||
else
|
||||
echo "Error unpausing case: ".$pmResultUnpause->message." \n";
|
||||
}
|
||||
else if( isset( $_POST['reassign'] ) ) {
|
||||
// here we should re-assign the current task to $_POST['users_id_recipient']
|
||||
$GLPINewPMUserId = PluginProcessmakerUser::getPMUserId( $_POST['users_id_recipient'] ) ;
|
||||
if( $_POST['plugin_processmaker_userId'] != $GLPINewPMUserId ) {
|
||||
$locPM = new PluginProcessmakerProcessmaker() ;
|
||||
$locPM->login( ) ;
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['assignedtoyou'], true, ERROR); // Html::back();
|
||||
}
|
||||
} else if (isset($_POST['delete'])) {
|
||||
// delete case from case table, this will also delete the tasks
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
|
||||
if ($locCase->deleteCase()) {
|
||||
// request delete from pm itself
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login(true);
|
||||
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] );
|
||||
|
||||
$pmResponse = $locPM->reassignCase( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'], $GLPINewPMUserId ) ;
|
||||
if ($pmResponse->status_code == 0){
|
||||
// we need to change the delindex of the glpi task and the assigned tech to prevent creation of new tasks
|
||||
// we need the delindex of the current glpi task, and the delindex of the new one
|
||||
// search for new delindex
|
||||
$newCaseInfo = $locPM->getCaseInfo( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
$newDelIndex = 0 ;
|
||||
foreach( $newCaseInfo->currentUsers as $newCaseUser ){
|
||||
if( $newCaseUser->taskId == $_POST['plugin_processmaker_taskId'] && $newCaseUser->delThread == $_POST['plugin_processmaker_delThread'] ) {
|
||||
$newDelIndex = $newCaseUser->delIndex ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
$locPM->reassignTask( $_POST['plugin_processmaker_caseId'], $_POST['plugin_processmaker_delIndex'], $newDelIndex, $_POST['users_id_recipient'] ) ;
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['reassigned'], true, INFO);
|
||||
// Html::back();
|
||||
}
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['notreassigned'].$pmResponse->message, true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['assignedtoyou'], true, ERROR); // Html::back();
|
||||
}
|
||||
else if( isset($_POST['delete']) ) {
|
||||
// delete case from case table, this will also delete the tasks
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->deleteCase() ) {
|
||||
// request delete from pm itself
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login(true) ;
|
||||
$resultPM = $myProcessMaker->deleteCase( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if ($resultPM->status_code == 0) {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
}
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
}
|
||||
} else if (isset($_POST['cancel'])) {
|
||||
// cancel case from PM
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login();
|
||||
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ); //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
if ($resultPM->status_code === 0) {
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] );
|
||||
if ($locCase->cancelCase()) {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
}
|
||||
} else {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if( $resultPM->status_code == 0 ) {
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['deleted'], true, INFO);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errordeleted'], true, ERROR);
|
||||
}
|
||||
else if( isset($_POST['cancel']) ) {
|
||||
// cancel case from PM
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login() ;
|
||||
$resultPM = $myProcessMaker->cancelCase( $_POST['plugin_processmaker_caseId'] ) ; //, $_POST['plugin_processmaker_delIndex'], $_POST['plugin_processmaker_userId'] ) ;
|
||||
if( $resultPM->status_code === 0 ) {
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
$locCase->getFromDB( $_POST['plugin_processmaker_caseId'] ) ;
|
||||
if( $locCase->cancelCase() )
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['cancelled'], true, INFO);
|
||||
else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
} else
|
||||
Session::addMessageAfterRedirect($LANG['processmaker']['item']['case']['errorcancelled'], true, ERROR);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
|
||||
154
hook.php
154
hook.php
@@ -3,27 +3,26 @@
|
||||
include_once 'inc/processmaker.class.php';
|
||||
|
||||
function plugin_processmaker_MassiveActions($type) {
|
||||
global $LANG;
|
||||
global $LANG;
|
||||
|
||||
switch ($type) {
|
||||
case 'PluginProcessmakerProcess' :
|
||||
if (plugin_processmaker_haveRight('config', UPDATE )) {
|
||||
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
|
||||
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
|
||||
}
|
||||
break;
|
||||
case 'PluginProcessmakerProcess_Profile' :
|
||||
if (plugin_processmaker_haveRight('config', UPDATE )) {
|
||||
return array('purge' => $LANG['processmaker']['process']['profile']);
|
||||
return array('purge' => $LANG['processmaker']['process']['profile']);
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
return array();
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function plugin_processmaker_MassiveActionsDisplay($options) {
|
||||
global $LANG;
|
||||
global $LANG;
|
||||
|
||||
switch ($options['itemtype']) {
|
||||
case 'PluginProcessmakerProcess' :
|
||||
@@ -31,19 +30,18 @@ function plugin_processmaker_MassiveActionsDisplay($options) {
|
||||
// No case for add_document : use GLPI core one
|
||||
case "plugin_processmaker_taskrefresh" :
|
||||
echo "<input type='submit' name='massiveaction' class='submit' ".
|
||||
"value='".$LANG['buttons'][2]."'>";
|
||||
break;
|
||||
"value='".$LANG['buttons'][2]."'>";
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function plugin_processmaker_MassiveActionsProcess($data) {
|
||||
//global $LANG,$DB;
|
||||
|
||||
switch ($data['action']) {
|
||||
|
||||
@@ -80,7 +78,7 @@ function plugin_processmaker_MassiveActionsProcess($data) {
|
||||
* @return true or die!
|
||||
*/
|
||||
function plugin_processmaker_install() {
|
||||
global $DB;
|
||||
global $DB;
|
||||
|
||||
if (TableExists("glpi_plugin_processmaker_config")) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_config`
|
||||
@@ -307,43 +305,43 @@ function plugin_processmaker_install() {
|
||||
}
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_processes_profiles")) { // since version 2.2
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`processes_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`profiles_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`entities_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`is_recursive` TINYINT(1) NOT NULL DEFAULT '1',
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_processes_profiles` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`processes_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`profiles_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`entities_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`is_recursive` TINYINT(1) NOT NULL DEFAULT '1',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `entities_id` (`entities_id`),
|
||||
INDEX `profiles_id` (`profiles_id`),
|
||||
INDEX `processes_id` (`processes_id`),
|
||||
INDEX `is_recursive` (`is_recursive`)
|
||||
)
|
||||
COLLATE='utf8_unicode_ci'
|
||||
ENGINE=InnoDB;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_processes_profiles" . $DB->error());
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `entities_id` (`entities_id`),
|
||||
INDEX `profiles_id` (`profiles_id`),
|
||||
INDEX `processes_id` (`processes_id`),
|
||||
INDEX `is_recursive` (`is_recursive`)
|
||||
)
|
||||
COLLATE='utf8_unicode_ci'
|
||||
ENGINE=InnoDB;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_processes_profiles" . $DB->error());
|
||||
|
||||
}
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_taskcategories")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_taskcategories` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`processes_id` INT(11) NOT NULL,
|
||||
`pm_task_guid` VARCHAR(32) NOT NULL,
|
||||
`taskcategories_id` INT(11) NOT NULL,
|
||||
`start` BIT(1) NOT NULL DEFAULT b'0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
|
||||
UNIQUE INDEX `items` (`taskcategories_id`),
|
||||
INDEX `processes_id` (`processes_id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
";
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_taskcategories` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`processes_id` INT(11) NOT NULL,
|
||||
`pm_task_guid` VARCHAR(32) NOT NULL,
|
||||
`taskcategories_id` INT(11) NOT NULL,
|
||||
`start` BIT(1) NOT NULL DEFAULT b'0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
|
||||
UNIQUE INDEX `items` (`taskcategories_id`),
|
||||
INDEX `processes_id` (`processes_id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
";
|
||||
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
|
||||
|
||||
}
|
||||
|
||||
@@ -422,24 +420,23 @@ function plugin_processmaker_install() {
|
||||
|
||||
// To be called for each task managed by the plugin
|
||||
// task in class
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmusers', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
//CronTask::Register('PluginProcessmakerProcessmaker', 'pmnotifications', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmorphancases', DAY_TIMESTAMP, array('param' => 10, 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmusers', DAY_TIMESTAMP, array( 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmorphancases', DAY_TIMESTAMP, array('param' => 10, 'state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
CronTask::Register('PluginProcessmakerProcessmaker', 'pmtaskactions', MINUTE_TIMESTAMP, array('state' => CronTask::STATE_DISABLE, 'mode' => CronTask::MODE_EXTERNAL));
|
||||
|
||||
// required because autoload doesn't work for unactive plugin'
|
||||
include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php");
|
||||
PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
|
||||
// required because autoload doesn't work for unactive plugin'
|
||||
include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php");
|
||||
PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
function plugin_processmaker_uninstall() {
|
||||
global $DB;
|
||||
global $DB;
|
||||
|
||||
CronTask::Unregister('PluginProcessmakerProcessmaker');
|
||||
CronTask::Unregister('PluginProcessmakerProcessmaker');
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -486,12 +483,12 @@ function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,
|
||||
case "glpi_plugin_processmaker_cases" :
|
||||
$out= " LEFT JOIN `glpi_plugin_processmaker_cases`
|
||||
ON (`$ref_table`.`id` = `glpi_plugin_processmaker_cases`.`items_id` AND `glpi_plugin_processmaker_cases`.`itemtype` like 'Ticket') ";
|
||||
return $out;
|
||||
break;
|
||||
return $out;
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
break;
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -587,7 +584,7 @@ function plugin_pre_item_purge_processmaker ( $parm ) {
|
||||
|
||||
/**
|
||||
* Summary of plugin_item_purge_processmaker
|
||||
* @param mixed $parm is the object
|
||||
* @param mixed $parm is the object
|
||||
*/
|
||||
function plugin_item_purge_processmaker($parm) {
|
||||
global $DB;
|
||||
@@ -674,18 +671,8 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
&& in_array( 'state', $parm->updates )
|
||||
&& $parm->input['state'] == 2) { // the task has just been set to DONE state
|
||||
|
||||
//$taskList = array( array( 'sourcetaskguid' => '54949951157c000b2336474053483376',
|
||||
// 'sourcecondition' => '@@RELEASE_DONE == 1' ,
|
||||
// 'targettaskguid' => '95599365257bffa6d6170d9068913760',
|
||||
// 'targetprocessguid' => '51126098657bd96b286ded7016691792',
|
||||
// 'targetdynaformguid' => '28421020557bffc5b374850018853291',
|
||||
// 'targettoclaim' => true,
|
||||
// 'targetactions' => array( 'RELEASE_DONE' => '@@RELEASE_DONE' )
|
||||
// ) ) ;
|
||||
|
||||
$itemtype = str_replace( 'Task', '', $parm->getType() );
|
||||
|
||||
//foreach( $taskList as $targetTask ) {
|
||||
foreach ($DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask) {
|
||||
|
||||
$srcCaseId = PluginProcessmakerProcessmaker::getCaseIdFromItem( $itemtype, $parm->fields['tickets_id']);
|
||||
@@ -697,7 +684,7 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
if (preg_match_all( "/@@(\w+)/u", $targetTask['sourcecondition'], $matches )) {
|
||||
$casevariables = $matches[1];
|
||||
}
|
||||
//foreach( $targetTask['targetactions'] as $actionvalue ){
|
||||
|
||||
$targetTask['targetactions'] = array(); // empty array by default
|
||||
foreach ($DB->request( 'glpi_plugin_processmaker_caselinkactions', 'plugin_processmaker_caselinks_id = '.$targetTask['id']) as $actionvalue) {
|
||||
$targetTask['targetactions'][$actionvalue['name']] = $actionvalue['value'];
|
||||
@@ -746,10 +733,6 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
$postdatas['DynaformRequiredFields'] = '[]';
|
||||
$postdatas['form']['btnGLPISendRequest'] = 'submit';
|
||||
|
||||
//foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
// $externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" ) ;
|
||||
//}
|
||||
|
||||
$externalapplicationparams = array();
|
||||
if ($externalapplication) {
|
||||
// must call curl
|
||||
@@ -809,7 +792,6 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
$externalapplicationparams['id'] = $cronaction->getID();
|
||||
|
||||
$externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT);
|
||||
//$externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
|
||||
@@ -817,7 +799,7 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
|
||||
// curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
|
||||
// curl_setopt($ch, CURLOPT_PROXY, "fry07689.fr.ray.group:8888");
|
||||
// curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
|
||||
|
||||
$response = curl_exec ($ch);
|
||||
|
||||
@@ -852,26 +834,6 @@ function plugin_item_update_processmaker_tasks($parm) {
|
||||
null,
|
||||
false);
|
||||
}
|
||||
//if( $externalapplication ) {
|
||||
// // must call external application in order to get the needed data asynchroneously
|
||||
// // must be of the form
|
||||
// // {"method":"POST","url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
|
||||
// // Where method is the POST, GET
|
||||
// // url is the URL to be called
|
||||
// $externalapplicationparams['record_id']=$cronaction->getID();
|
||||
// $externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
|
||||
// if( $externalapplication['method'] != 'GET') {
|
||||
// switch($externalapplication['method']) {
|
||||
// case 'POST' :
|
||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// $response = curl_exec ($ch);
|
||||
|
||||
// curl_close ($ch);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,104 +10,111 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
$item_id = $item->getID();
|
||||
$item_type = $item->getType();
|
||||
if (self::getCaseFromItemTypeAndItemId($item_type, $item_id )) {
|
||||
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
|
||||
} else {
|
||||
return array( 'processmakercases' => $LANG['processmaker']['item']['tab'] );
|
||||
}
|
||||
|
||||
$item_id = $item->getID() ;
|
||||
$item_type = $item->getType() ;
|
||||
if( self::getCaseFromItemTypeAndItemId($item_type, $item_id ) ){
|
||||
return array( 'processmakercases' => $LANG['processmaker']['item']['tab']."<sup>(".$this->fields['case_status'].")</sup>" );
|
||||
} else
|
||||
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;
|
||||
static function getCaseIdFromItemTypeAndItemId( $itemType, $itemId) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';" ;
|
||||
if( ($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
|
||||
$row = $DB->fetch_array($res);
|
||||
return $row['id'] ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
$query = "SELECT * FROM glpi_plugin_processmaker_cases WHERE items_id=$itemId and itemtype='$itemType';";
|
||||
if (($res = $DB->query($query) ) && $DB->numrows($res) > 0) {
|
||||
$row = $DB->fetch_array($res);
|
||||
return $row['id'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of getCaseFromItemTypeAndItemId
|
||||
* @param mixed $itemType
|
||||
* @param mixed $itemId
|
||||
* @param mixed $itemType is the item type
|
||||
* @param mixed $itemId is the item id
|
||||
* @return mixed: returns false when there is no case associated with the item, else fills in the item fields from DB, and returns true
|
||||
*/
|
||||
function getCaseFromItemTypeAndItemId($itemType, $itemId) {
|
||||
function getCaseFromItemTypeAndItemId($itemType, $itemId) {
|
||||
|
||||
if( $caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId) )
|
||||
return $this->getFromDB( $caseId ) ;
|
||||
if ($caseId = self::getCaseIdFromItemTypeAndItemId( $itemType, $itemId)) {
|
||||
return $this->getFromDB( $caseId );
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getFromDB
|
||||
* @param mixed $ID
|
||||
* @return mixed
|
||||
* @param mixed $ID id of needed object
|
||||
* @return mixed object if found, else false
|
||||
*/
|
||||
function getFromDB($ID) {
|
||||
global $DB;
|
||||
// Search for object in database and fills 'fields'
|
||||
function getFromDB($ID) {
|
||||
global $DB;
|
||||
// Search for object in database and fills 'fields'
|
||||
|
||||
// != 0 because 0 is consider as empty
|
||||
if (strlen($ID)==0) {
|
||||
return false;
|
||||
}
|
||||
// != 0 because 0 is consider as empty
|
||||
if (strlen($ID)==0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = "SELECT *
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `".$this->getIndexName()."` = '".$ID."'";
|
||||
|
||||
if ( ($result = $DB->query($query)) && $DB->numrows($result)==1) {
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
$this->post_getFromDB();
|
||||
if (($result = $DB->query($query)) && $DB->numrows($result)==1) {
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
$this->post_getFromDB();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 ;
|
||||
function getVariables( $vars = array() ) {
|
||||
global $PM_DB;
|
||||
|
||||
$locVars = array( ) ;
|
||||
$app_data = array() ; // by default
|
||||
$locVars = array( );
|
||||
$app_data = array(); // by default
|
||||
|
||||
$caseId = $this->getID() ;
|
||||
$caseId = $this->getID();
|
||||
|
||||
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
|
||||
$query = "SELECT APP_DATA FROM APPLICATION WHERE APP_UID='$caseId';";
|
||||
|
||||
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$app_data = unserialize($row['APP_DATA'] ) ;
|
||||
$locVars = array_intersect_key( $app_data, array_flip($vars) ) ;
|
||||
}
|
||||
if (($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$app_data = unserialize($row['APP_DATA'] );
|
||||
$locVars = array_intersect_key( $app_data, array_flip($vars) );
|
||||
}
|
||||
|
||||
return $locVars ;
|
||||
}
|
||||
return $locVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of sendVariables
|
||||
@@ -117,259 +124,241 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
* @param array $vars an array of associative variables (name => value) that will be injected into the case as case variables
|
||||
* @return true if variables have been saved to the case, false otherwise
|
||||
*/
|
||||
function sendVariables( $vars = array() ) {
|
||||
global $PM_DB ;
|
||||
function sendVariables( $vars = array() ) {
|
||||
global $PM_DB;
|
||||
|
||||
$variablesSent = false ; // be default
|
||||
$app_data = array() ; // by default
|
||||
$variablesSent = false; // be default
|
||||
$app_data = array(); // by default
|
||||
|
||||
$caseId = $this->getID() ;
|
||||
$caseId = $this->getID();
|
||||
|
||||
$query = "SELECT APP_DATA FROM application WHERE APP_UID='$caseId';" ;
|
||||
$query = "SELECT APP_DATA FROM APPLICATION WHERE APP_UID='$caseId';";
|
||||
|
||||
if (($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$app_data = unserialize($row['APP_DATA'] );
|
||||
}
|
||||
|
||||
if( ($res = $PM_DB->query($query)) && $PM_DB->numrows($res) > 0) {
|
||||
$row = $PM_DB->fetch_assoc($res);
|
||||
$app_data = unserialize($row['APP_DATA'] ) ;
|
||||
}
|
||||
$app_data = array_replace( $app_data, $vars );
|
||||
$serialized = serialize( $app_data );
|
||||
|
||||
$app_data = array_replace( $app_data, $vars ) ;
|
||||
$serialized = serialize( $app_data ) ;
|
||||
$query = "UPDATE APPLICATION SET APP_DATA='$serialized' WHERE APP_UID='$caseId';";
|
||||
$res = $PM_DB->query( $query );
|
||||
|
||||
$query = "UPDATE application SET APP_DATA='$serialized' WHERE APP_UID='$caseId';" ;
|
||||
$res = $PM_DB->query( $query ) ;
|
||||
if ($PM_DB->affected_rows() == 1) {
|
||||
$variablesSent = true;
|
||||
}
|
||||
|
||||
if( $PM_DB->affected_rows() == 1 ) {
|
||||
$variablesSent = true ;
|
||||
}
|
||||
|
||||
return $variablesSent ;
|
||||
}
|
||||
return $variablesSent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of displayTabContentForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @param CommonGLPI $item is the item
|
||||
* @param mixed $tabnum is the tab num
|
||||
* @param mixed $withtemplate has template
|
||||
* @return mixed
|
||||
*/
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $LANG, $DB, $CFG_GLPI ;
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $LANG, $DB, $CFG_GLPI;
|
||||
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
$config = PluginProcessmakerConfig::getInstance();
|
||||
|
||||
if( $config->fields['maintenance'] == 0 ) {
|
||||
if ($config->fields['maintenance'] == 0) {
|
||||
|
||||
$item_id = $item->getID() ;
|
||||
$item_type = $item->getType() ;
|
||||
////retrieve container for current tab
|
||||
//$container = new self;
|
||||
//$found_c = $container->find("`itemtype` = '$item_type' AND `items_id` = $item_id ");
|
||||
$item_id = $item->getID();
|
||||
$item_type = $item->getType();
|
||||
////retrieve container for current tab
|
||||
//$container = new self;
|
||||
//$found_c = $container->find("`itemtype` = '$item_type' AND `items_id` = $item_id ");
|
||||
|
||||
//echo "Show the frame";
|
||||
$rand = rand();
|
||||
echo "<form style='margin-bottom: 0px' name='processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
|
||||
echo "<div class='center'> <table id='processmakercasemenu' style='margin-bottom: 0px' class='tab_cadre_fixe'>";
|
||||
echo Html::scriptBlock("$('#processmakercasemenu').css('max-width', 'none');") ;
|
||||
echo "<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 ) ){
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker( ) ;
|
||||
$myProcessMaker->login();
|
||||
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id ) ;
|
||||
if( $caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED' ) {
|
||||
// need to get info on the thread of the GLPI current user
|
||||
// we must retreive currentGLPI user from this array
|
||||
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ) ;
|
||||
$pmCaseUser = $caseInfo->currentUsers[0] ; // by default currently manage only one task at a time, must define tab management for several tasks
|
||||
foreach( $caseInfo->currentUsers as $caseUser) {
|
||||
if( $caseUser->userId == $GLPICurrentPMUserId ){
|
||||
$pmCaseUser = $caseUser ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
//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 ) {
|
||||
case "CANCELLED" :
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['cancelledcase']."</th></tr>";
|
||||
$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>";
|
||||
//echo "Show the frame";
|
||||
$rand = rand();
|
||||
echo "<form style='margin-bottom: 0px' name='processmaker_form$rand' id='processmaker_form$rand' method='post' action='".Toolbox::getItemTypeFormURL("PluginProcessmakerProcessmaker")."'>";
|
||||
echo "<div class='center'> <table id='processmakercasemenu' style='margin-bottom: 0px' class='tab_cadre_fixe'>";
|
||||
echo Html::scriptBlock("$('#processmakercasemenu').css('max-width', 'none');");
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['tab']."</th></tr>";
|
||||
|
||||
case "DRAFT" :
|
||||
case "TO_DO" :
|
||||
$pmCaseUser = false; // initial value: no user
|
||||
// first search for the case
|
||||
if (self::getCaseIdFromItemTypeAndItemId($item_type, $item_id )) {
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker( );
|
||||
$myProcessMaker->login();
|
||||
$caseInfo = $myProcessMaker->getCaseFromItem( $item_type, $item_id );
|
||||
if ($caseInfo->caseStatus != 'CANCELLED' && $caseInfo->caseStatus != 'COMPLETED') {
|
||||
// need to get info on the thread of the GLPI current user
|
||||
// we must retreive currentGLPI user from this array
|
||||
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() );
|
||||
$pmCaseUser = $caseInfo->currentUsers[0]; // by default currently manage only one task at a time, must define tab management for several tasks
|
||||
foreach ($caseInfo->currentUsers as $caseUser) {
|
||||
if ($caseUser->userId == $GLPICurrentPMUserId) {
|
||||
$pmCaseUser = $caseUser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$locDelIndex = 1; // by default
|
||||
switch ($caseInfo->caseStatus) {
|
||||
case "CANCELLED" :
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['cancelledcase']."</th></tr>";
|
||||
$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;
|
||||
|
||||
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus ;
|
||||
$locDelIndex = $pmCaseUser->delIndex ;
|
||||
if( $pmCaseUser->userId != '' ) {
|
||||
echo "<tr class='tab_bg_1'>" ;
|
||||
case "DRAFT" :
|
||||
case "TO_DO" :
|
||||
|
||||
if( $GLPICurrentPMUserId == $pmCaseUser->userId) {
|
||||
// then propose a button to cancel case only when assigned user is == to glpi current user
|
||||
echo "<td class='tab_bg_2' >";
|
||||
echo $LANG['processmaker']['item']['cancelcase'] ;
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
|
||||
//echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
|
||||
//echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
|
||||
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttoncancelcaseconfirmation']."\") ; cancelMyMask = !ret ; return ret;' type='submit' name='cancel' value='".$LANG['processmaker']['item']['buttoncancelcase']."' class='submit'>";
|
||||
echo "</td>";
|
||||
}
|
||||
$paramsURL = "DEL_INDEX=".$pmCaseUser->delIndex."&action=".$caseInfo->caseStatus;
|
||||
$locDelIndex = $pmCaseUser->delIndex;
|
||||
if ($pmCaseUser->userId != '') {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
|
||||
if( $caseInfo->caseStatus == "DRAFT" || (plugin_processmaker_haveRight("deletecase", DELETE) && $_SESSION['glpiactiveprofile']['interface'] == 'central') ) {
|
||||
// then propose a button to delete case
|
||||
echo "<td class='tab_bg_2'>";
|
||||
echo $LANG['processmaker']['item']['deletecase'] ;
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
|
||||
if ($GLPICurrentPMUserId == $pmCaseUser->userId) {
|
||||
// then propose a button to cancel case only when assigned user is == to glpi current user
|
||||
echo "<td class='tab_bg_2' >";
|
||||
echo $LANG['processmaker']['item']['cancelcase'];
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
|
||||
//echo "<input type='hidden' name='plugin_processmaker_delIndex' value='".$pmCaseUser->delIndex."'>";
|
||||
//echo "<input type='hidden' name='plugin_processmaker_userId' value='".$pmCaseUser->userId."'>";
|
||||
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttoncancelcaseconfirmation']."\") ; cancelMyMask = !ret ; return ret;' type='submit' name='cancel' value='".$LANG['processmaker']['item']['buttoncancelcase']."' class='submit'>";
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttondeletecaseconfirmation']."\"); cancelMyMask = !ret ; return ret;' type='submit' name='delete' value='".$LANG['processmaker']['item']['buttondeletecase']."' class='submit' >";
|
||||
if ($caseInfo->caseStatus == "DRAFT" || (plugin_processmaker_haveRight("deletecase", DELETE) && $_SESSION['glpiactiveprofile']['interface'] == 'central')) {
|
||||
// then propose a button to delete case
|
||||
echo "<td class='tab_bg_2'>";
|
||||
echo $LANG['processmaker']['item']['deletecase'];
|
||||
echo "</td><td class='tab_bg_2'>";
|
||||
echo "<input type='hidden' name='action' value='unpausecase_or_reassign_or_delete'>";
|
||||
echo "<input type='hidden' name='plugin_processmaker_caseId' value='".$caseInfo->caseId."'>";
|
||||
|
||||
echo "</td>";
|
||||
echo "<input onclick='ret = confirm(\"".$LANG['processmaker']['item']['buttondeletecaseconfirmation']."\"); cancelMyMask = !ret ; return ret;' type='submit' name='delete' value='".$LANG['processmaker']['item']['buttondeletecase']."' class='submit' >";
|
||||
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
//echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo "</form>";
|
||||
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
break ;
|
||||
case "COMPLETED" :
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
|
||||
$paramsURL = "DEL_INDEX=" ; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
|
||||
break ;
|
||||
}
|
||||
break;
|
||||
case "COMPLETED" :
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['completedcase']."</th></tr>";
|
||||
$paramsURL = "DEL_INDEX="; // DEL_INDEX is not set to tell PM to show the current task i.e.: the last one
|
||||
break;
|
||||
}
|
||||
|
||||
$proj = new PluginProcessmakerProcess ;
|
||||
$proj->getFromDBbyExternalID( $caseInfo->processId ) ;
|
||||
$project_type = $proj->fields['project_type'] ;
|
||||
// then propose a button to view case history
|
||||
echo "<tr class='tab_bg_1' >" ;
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseChangeLogHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasechangeloghistory']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
$proj = new PluginProcessmakerProcess;
|
||||
$proj->getFromDBbyExternalID( $caseInfo->processId );
|
||||
$project_type = $proj->fields['project_type'];
|
||||
// then propose a button to view case history
|
||||
echo "<tr class='tab_bg_1' >";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseMap');\" value='".$LANG['processmaker']['item']['case']['viewcasemap']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasehistory']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('caseChangeLogHistory');\" value='".$LANG['processmaker']['item']['case']['viewcasechangeloghistory']."'>";
|
||||
echo "</td>";
|
||||
echo "<td class='tab_bg_2' colspan='1'>";
|
||||
echo "<input type='button' class='submit' onclick=\"javascript:Actions.tabFrame('historyDynaformPage');\" value='".$LANG['processmaker']['item']['case']['viewdynaforms']."'>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>" ; //?rand=$rand'
|
||||
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/plugins/processmaker/js/cases.js'></script>"; //?rand=$rand'
|
||||
|
||||
// processmakertabpaneltable is used to align the tabs
|
||||
echo "<table id=processmakertabpaneltable style='margin-bottom: 0px; width:100%;' class='tab_cadre_fixe'>";
|
||||
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');") ;
|
||||
echo "<tr><td>" ;
|
||||
echo Html::scriptBlock("$('#processmakertabpaneltable').css('max-width', 'none');");
|
||||
echo "<tr><td>";
|
||||
|
||||
//
|
||||
// Processmaker tab panels
|
||||
// need to have a global variable which contains tab id
|
||||
// used only one time for activated panel
|
||||
$arrayProcessmakerTabPanel = array() ;
|
||||
$arrayProcessmakerTabPanel = array();
|
||||
echo "<div id=processmakertabpanel >";
|
||||
// first define tabs
|
||||
echo " <ul>";
|
||||
//echo " <li><a href='#tabs-1'>Nunc tincidunt</a></li>";
|
||||
$arrayProcessmakerTabPanel[] = "tabs-1";
|
||||
if( $pmCaseUser ) {
|
||||
foreach($caseInfo->currentUsers as $caseUser) {
|
||||
echo "<li><a href='#task-".$caseUser->delIndex."'>".($caseUser->userId != $GLPICurrentPMUserId?"<i><sub>".$LANG['processmaker']['item']['task']['task'].$caseUser->taskName."</sub></i>":$LANG['processmaker']['item']['task']['task'].$caseUser->taskName)."</a></li>";
|
||||
$arrayProcessmakerTabPanel[] = "task-".$caseUser->delIndex;
|
||||
}
|
||||
} else {
|
||||
// no user means CANCELLED or COMPLETED
|
||||
// then create artificial panel to host case infos
|
||||
echo "<li><a href='#caseInfo'>".$LANG['processmaker']['item']['case']['caseinfo']."</a></li>";
|
||||
$arrayProcessmakerTabPanel[] = "caseInfo";
|
||||
}
|
||||
if ($pmCaseUser) {
|
||||
foreach ($caseInfo->currentUsers as $caseUser) {
|
||||
echo "<li><a href='#task-".$caseUser->delIndex."'>".($caseUser->userId != $GLPICurrentPMUserId?"<i><sub>".$LANG['processmaker']['item']['task']['task'].$caseUser->taskName."</sub></i>":$LANG['processmaker']['item']['task']['task'].$caseUser->taskName)."</a></li>";
|
||||
$arrayProcessmakerTabPanel[] = "task-".$caseUser->delIndex;
|
||||
}
|
||||
} else {
|
||||
// no user means CANCELLED or COMPLETED
|
||||
// then create artificial panel to host case infos
|
||||
echo "<li><a href='#caseInfo'>".$LANG['processmaker']['item']['case']['caseinfo']."</a></li>";
|
||||
$arrayProcessmakerTabPanel[] = "caseInfo";
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
// second define panels
|
||||
//echo "<div id='tabs-1'>
|
||||
// <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
|
||||
// </div>";
|
||||
if( $pmCaseUser ) {
|
||||
$csrf = Session::getNewCSRFToken() ;
|
||||
foreach($caseInfo->currentUsers as $caseUser) {
|
||||
// for each task, if task is to be claimed, we need to verify that current user can claim it by checking if he/she is in the group assigned to the task
|
||||
$hide_claim_button=false; // by default
|
||||
if( !$caseUser->userId ) {
|
||||
// current task is to claimed
|
||||
// get task user list
|
||||
$query = "SELECT items_id, itemtype FROM glpi_plugin_processmaker_tasks WHERE case_id = '".$caseInfo->caseId."' AND del_index =".$caseUser->delIndex;
|
||||
foreach( $DB->request($query) as $row ) {
|
||||
// normally there is only one task
|
||||
$task = getItemForItemtype( $row['itemtype'] ) ;
|
||||
$task->getFromDB( $row['items_id'] ) ;
|
||||
// check if this group can be found in the current user's groups
|
||||
if( !isset($_SESSION['glpigroups']) || !in_array( $task->fields['groups_id_tech'], $_SESSION['glpigroups'] ) ) {
|
||||
$hide_claim_button=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "<div id='task-".$caseUser->delIndex."'>";
|
||||
// to load users for task re-assign only when task is not to be 'claimed'
|
||||
if( $caseUser->userId ) {
|
||||
echo "<div class='tab_bg_2' id='divUsers-".$caseUser->delIndex."' >Loading...</div>";
|
||||
echo "<script>$('#divUsers-".$caseUser->delIndex."').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand' ); </script>" ;
|
||||
}
|
||||
echo "<iframe id='caseiframe-task-".$caseUser->delIndex."' onload='onTaskFrameLoad( event, ".$caseUser->delIndex.", ".($hide_claim_button?"true":"false").", \"$csrf\" );' style='border:none;' class='tab_bg_2' width='100%' src='";
|
||||
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO" ;
|
||||
//if( $caseUser->userId == $GLPICurrentPMUserId || $caseUser->userId == '' ) {
|
||||
echo $url ;
|
||||
//} else {
|
||||
// echo $CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_resume.php?username=".urlencode( $caseUser->userName )."&taskname=".urlencode( $caseUser->taskName )."&url=".urlencode( $url ) ;
|
||||
//}
|
||||
echo "&rand=$rand'></iframe></div>";
|
||||
}
|
||||
} else {
|
||||
if ($pmCaseUser) {
|
||||
$csrf = Session::getNewCSRFToken();
|
||||
foreach ($caseInfo->currentUsers as $caseUser) {
|
||||
// for each task, if task is to be claimed, we need to verify that current user can claim it by checking if he/she is in the group assigned to the task
|
||||
$hide_claim_button=false; // by default
|
||||
if (!$caseUser->userId) {
|
||||
// current task is to claimed
|
||||
// get task user list
|
||||
$query = "SELECT items_id, itemtype FROM glpi_plugin_processmaker_tasks WHERE case_id = '".$caseInfo->caseId."' AND del_index =".$caseUser->delIndex;
|
||||
foreach ($DB->request($query) as $row) {
|
||||
// normally there is only one task
|
||||
$task = getItemForItemtype( $row['itemtype'] );
|
||||
$task->getFromDB( $row['items_id'] );
|
||||
// check if this group can be found in the current user's groups
|
||||
if (!isset($_SESSION['glpigroups']) || !in_array( $task->fields['groups_id_tech'], $_SESSION['glpigroups'] )) {
|
||||
$hide_claim_button=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "<div id='task-".$caseUser->delIndex."'>";
|
||||
// to load users for task re-assign only when task is not to be 'claimed'
|
||||
if ($caseUser->userId) {
|
||||
echo "<div class='tab_bg_2' id='divUsers-".$caseUser->delIndex."' >Loading...</div>";
|
||||
echo "<script>$('#divUsers-".$caseUser->delIndex."').load( '".$CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_users.php?caseId=".$caseInfo->caseId."&itemId=".$item_id."&itemType=".$item_type."&userId=".$caseUser->userId."&taskId=".$caseUser->taskId."&delIndex=".$caseUser->delIndex."&delThread=".$caseUser->delThread."&rand=$rand' ); </script>";
|
||||
}
|
||||
echo "<iframe id='caseiframe-task-".$caseUser->delIndex."' onload='onTaskFrameLoad( event, ".$caseUser->delIndex.", ".($hide_claim_button?"true":"false").", \"$csrf\" );' style='border:none;' class='tab_bg_2' width='100%' src='";
|
||||
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&DEL_INDEX=".$caseUser->delIndex."&action=TO_DO";
|
||||
//if( $caseUser->userId == $GLPICurrentPMUserId || $caseUser->userId == '' ) {
|
||||
echo $url;
|
||||
//} else {
|
||||
// echo $CFG_GLPI["root_doc"]."/plugins/processmaker/ajax/task_resume.php?username=".urlencode( $caseUser->userName )."&taskname=".urlencode( $caseUser->taskName )."&url=".urlencode( $url ) ;
|
||||
//}
|
||||
echo "&rand=$rand'></iframe></div>";
|
||||
}
|
||||
} else {
|
||||
// no user means CANCELLED or COMPLETED
|
||||
// then create artificial panel to host case infos
|
||||
echo "<div id='caseInfo'>";
|
||||
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO" ;
|
||||
$url = $myProcessMaker->serverURL."/cases/cases_open?sid=".$_SESSION["pluginprocessmaker"]["session"]["id"]."&APP_UID=".$caseInfo->caseId."&".$paramsURL."&action=TO_DO";
|
||||
echo "<iframe id=\"caseiframe-caseInfo\" onload=\"onOtherFrameLoad( 'caseInfo', 'caseiframe-caseInfo', 'body' );\" style=\"border:none;\" class=\"tab_bg_2\" width=\"100%\" src=\"$url&rand=$rand\"></iframe></div>";
|
||||
}
|
||||
echo "</div>" ;
|
||||
echo "</div>";
|
||||
// end of tabs/panels
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "<tr class='tab_bg_1' ><td colspan=4 >" ;
|
||||
if( $pmCaseUser ) {
|
||||
$activePanel = 'task-'.$pmCaseUser->delIndex ;
|
||||
echo "<tr class='tab_bg_1' ><td colspan=4 >";
|
||||
if ($pmCaseUser) {
|
||||
$activePanel = 'task-'.$pmCaseUser->delIndex;
|
||||
} else {
|
||||
$activePanel = 'caseInfo' ;
|
||||
$activePanel = 'caseInfo';
|
||||
}
|
||||
$caseMapUrl = $myProcessMaker->serverURL.($project_type=='bpmn' ? "/designer?prj_uid=".$caseInfo->processId."&prj_readonly=true&app_uid=".$caseInfo->caseId : "/cases/ajaxListener?action=processMap&rand=$rand") ;
|
||||
echo "<script>
|
||||
$caseMapUrl = $myProcessMaker->serverURL.($project_type=='bpmn' ? "/designer?prj_uid=".$caseInfo->processId."&prj_readonly=true&app_uid=".$caseInfo->caseId : "/cases/ajaxListener?action=processMap&rand=$rand");
|
||||
echo "<script>
|
||||
function addTabPanel( name, title, html ){
|
||||
//debugger ;
|
||||
if( !$('#processmakertabpanel')[0].children[name] ) { // panel is not yet existing, create one
|
||||
@@ -502,61 +491,58 @@ 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' >" ;
|
||||
//////echo "</iframe>";
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</script>";
|
||||
} else {
|
||||
|
||||
//////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' >" ;
|
||||
//////echo "</iframe>";
|
||||
echo "</td></tr>";
|
||||
//********************************
|
||||
// no running case for this ticket
|
||||
// propose to start one
|
||||
//********************************
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'];
|
||||
|
||||
} else {
|
||||
// check if item is not solved nor closed
|
||||
if ($item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
|
||||
// propose case start
|
||||
echo " - ".$LANG['processmaker']['item']['startone'];
|
||||
echo "</th></tr>";
|
||||
|
||||
//********************************
|
||||
// no running case for this ticket
|
||||
// propose to start one
|
||||
//********************************
|
||||
echo "<tr><th colspan='4'>".$LANG['processmaker']['item']['nocase'] ;
|
||||
echo "<tr class='tab_bg_2'><td class='tab_bg_2' colspan='1'>";
|
||||
echo $LANG['processmaker']['item']['selectprocess']." ";
|
||||
echo "<input type='hidden' name='action' value='newcase'>";
|
||||
echo "<input type='hidden' name='id' value='$item_id'>";
|
||||
echo "<input type='hidden' name='itemtype' value='$item_type'>";
|
||||
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1")); // condition is used to prevent start of none-active cases
|
||||
PluginProcessmakerProcess::dropdown(array( 'value' => 0, 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1"));
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
// check if item is not solved nor closed
|
||||
if( $item->fields['status'] != 'solved' && $item->fields['status'] != 'closed' && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk' ) {
|
||||
// propose case start
|
||||
echo " - ".$LANG['processmaker']['item']['startone'];
|
||||
echo "</th></tr>";
|
||||
echo "</table>";
|
||||
Html::closeForm(true );
|
||||
//echo "</form>";
|
||||
|
||||
echo "<tr class='tab_bg_2'><td class='tab_bg_2' colspan='1'>";
|
||||
echo $LANG['processmaker']['item']['selectprocess']." ";
|
||||
echo "<input type='hidden' name='action' value='newcase'>";
|
||||
echo "<input type='hidden' name='id' value='$item_id'>";
|
||||
echo "<input type='hidden' name='itemtype' value='$item_type'>";
|
||||
// Dropdown::show('PluginProcessmakerProcessmaker', array( 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1")); // condition is used to prevent start of none-active cases
|
||||
PluginProcessmakerProcess::dropdown(array( 'value' => 0, 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_process_id', 'condition' => "is_active=1"));
|
||||
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 {
|
||||
// under maintenance
|
||||
echo $LANG['processmaker']['config']['undermaintenance'];
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
Html::closeForm(true ) ;
|
||||
//echo "</form>";
|
||||
|
||||
} else {
|
||||
// under maintenance
|
||||
echo $LANG['processmaker']['config']['undermaintenance'];
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of deleteTasks
|
||||
@@ -564,16 +550,17 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
* @return true if tasks have been deleted from associated item and from case table
|
||||
*/
|
||||
private function deleteTasks( ) {
|
||||
global $DB ;
|
||||
$ret = false ;
|
||||
global $DB;
|
||||
$ret = false;
|
||||
|
||||
$query = "DELETE from glpi_".$this->fields['itemtype']."tasks where id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
|
||||
if( $DB->query( $query ) ) {
|
||||
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
|
||||
if( $DB->query( $query ) )
|
||||
$ret = true ;
|
||||
if ($DB->query( $query )) {
|
||||
$query = "DELETE from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."'";
|
||||
if ($DB->query( $query )) {
|
||||
$ret = true;
|
||||
}
|
||||
return $ret ;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -582,15 +569,17 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
* will delete case and all tasks associated with this case from the item
|
||||
* @return true if case and tasks have been deleted from associated item and from case table
|
||||
*/
|
||||
function deleteCase( ) {
|
||||
global $DB ;
|
||||
$ret = false ;
|
||||
function deleteCase( ) {
|
||||
global $DB;
|
||||
$ret = false;
|
||||
|
||||
if( $this->deleteTasks() )
|
||||
if( $this->deleteFromDB( ) )
|
||||
$ret = true ;
|
||||
return $ret ;
|
||||
}
|
||||
if ($this->deleteTasks()) {
|
||||
if ($this->deleteFromDB( )) {
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -600,18 +589,18 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
* BEWARE that this will only be done when case is in TO_DO status
|
||||
* @return true if tasks have been deleted from associated item and from case table
|
||||
*/
|
||||
private function cancelTasks( ) {
|
||||
global $DB ;
|
||||
$ret = false ;
|
||||
private function cancelTasks( ) {
|
||||
global $DB;
|
||||
$ret = false;
|
||||
|
||||
if( isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO" ) {
|
||||
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
|
||||
if( $DB->query( $query ) ) {
|
||||
$ret = true ;
|
||||
}
|
||||
}
|
||||
return $ret ;
|
||||
}
|
||||
if (isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO") {
|
||||
$query = "UPDATE glpi_".$this->fields['itemtype']."tasks SET state=0,users_id_tech=0,begin=NULL,end=NULL WHERE state=1 AND id in (select items_id from glpi_plugin_processmaker_tasks where case_id='".$this->fields['id']."')";
|
||||
if ($DB->query( $query )) {
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -621,48 +610,51 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
* BEWARE that this will only be done when case is in TO_DO status
|
||||
* @return true if case and tasks have been cancelled or marked from associated item and from case table
|
||||
*/
|
||||
function cancelCase( ) {
|
||||
global $DB ;
|
||||
$ret = false ;
|
||||
function cancelCase( ) {
|
||||
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' ) ) )
|
||||
$ret=true;
|
||||
if (isset($this->fields['case_status']) && $this->fields['case_status'] == "TO_DO") {
|
||||
if ($this->cancelTasks()) {
|
||||
if ($this->update( array( 'id' => $this->getID(), 'case_status' => 'CANCELLED' ) )) {
|
||||
$ret=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret ;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of canSolve
|
||||
* To know if a Ticket (Problem or Change) can be solved
|
||||
* i.e. the case permits solving of item
|
||||
* @param mixed $parm
|
||||
* @return bool
|
||||
* @param mixed $item is the item
|
||||
* @return bool true to permit solve, false otherwise
|
||||
*/
|
||||
public static function canSolve ($parm) {
|
||||
$myCase = new self;
|
||||
if( $myCase->getCaseFromItemTypeAndItemId( $parm['item']->getType(), $parm['item']->getID() ) ) {
|
||||
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) ) ;
|
||||
if( $myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1) ) {
|
||||
// then item can't be solved
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
public static function canSolve ($item) {
|
||||
$myCase = new self;
|
||||
if ($myCase->getCaseFromItemTypeAndItemId( $item['item']->getType(), $item['item']->getID() )) {
|
||||
$pmVar = $myCase->getVariables( array( 'GLPI_ITEM_CAN_BE_SOLVED' ) );
|
||||
if ($myCase->fields['case_status'] != 'COMPLETED' && $myCase->fields['case_status'] != 'CANCELLED' && (!isset($pmVar['GLPI_ITEM_CAN_BE_SOLVED']) || $pmVar['GLPI_ITEM_CAN_BE_SOLVED'] != 1)) {
|
||||
// then item can't be solved
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getToDoTasks
|
||||
* @param mixed $parm is a Ticket, a Problem or a Change
|
||||
* @return array list of tasks with status 'to do' for case associated with item
|
||||
*/
|
||||
public static function getToDoTasks($parm) {
|
||||
$myCase = new self;
|
||||
public static function getToDoTasks($parm) {
|
||||
$myCase = new self;
|
||||
|
||||
if( $myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() ) ) {
|
||||
return PluginProcessmakerTask::getToDoTasks( $myCase->getID(), $parm->getType()."Task" ) ;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
if ($myCase->getCaseFromItemTypeAndItemId( $parm->getType(), $parm->getID() )) {
|
||||
return PluginProcessmakerTask::getToDoTasks( $myCase->getID(), $parm->getType()."Task" );
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -4,59 +4,79 @@
|
||||
|
||||
class PluginProcessmakerConfig extends CommonDBTM {
|
||||
|
||||
static private $_instance = NULL;
|
||||
//static private $db = NULL ;
|
||||
static private $_instance = NULL;
|
||||
|
||||
static function canCreate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
/**
|
||||
* Summary of canCreate
|
||||
* @return boolean
|
||||
*/
|
||||
static function canCreate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
|
||||
static function canView() {
|
||||
return Session::haveRight('config', READ);
|
||||
}
|
||||
/**
|
||||
* Summary of canView
|
||||
* @return boolean
|
||||
*/
|
||||
static function canView() {
|
||||
return Session::haveRight('config', READ);
|
||||
}
|
||||
|
||||
static function canUpdate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
/**
|
||||
* Summary of canUpdate
|
||||
* @return boolean
|
||||
*/
|
||||
static function canUpdate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
|
||||
static function getTypeName($nb=0) {
|
||||
global $LANG;
|
||||
/**
|
||||
* Summary of getTypeName
|
||||
* @param mixed $nb plural
|
||||
* @return mixed
|
||||
*/
|
||||
static function getTypeName($nb=0) {
|
||||
global $LANG;
|
||||
|
||||
return $LANG['processmaker']['config']['setup'];
|
||||
}
|
||||
return $LANG['processmaker']['config']['setup'];
|
||||
}
|
||||
|
||||
function getName($with_comment=0) {
|
||||
global $LANG;
|
||||
/**
|
||||
* Summary of getName
|
||||
* @param mixed $with_comment with comment
|
||||
* @return mixed
|
||||
*/
|
||||
function getName($with_comment=0) {
|
||||
global $LANG;
|
||||
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton for the unique config record
|
||||
*/
|
||||
static function getInstance() {
|
||||
/**
|
||||
* Summary of getInstance
|
||||
* @return PluginProcessmakerConfig
|
||||
*/
|
||||
static function getInstance() {
|
||||
|
||||
if (!isset(self::$_instance)) {
|
||||
self::$_instance = new self();
|
||||
if (!self::$_instance->getFromDB(1)) {
|
||||
self::$_instance->getEmpty();
|
||||
}
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
if (!isset(self::$_instance)) {
|
||||
self::$_instance = new self();
|
||||
if (!self::$_instance->getFromDB(1)) {
|
||||
self::$_instance->getEmpty();
|
||||
}
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare input datas for updating the item
|
||||
*
|
||||
* @param $input array used to update the item
|
||||
*
|
||||
* @param array $input used to update the item
|
||||
* @return array the modified $input array
|
||||
**/
|
||||
function prepareInputForUpdate($input) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if( !isset($input["maintenance"]) ) {
|
||||
$input["maintenance"] = 0 ;
|
||||
if (!isset($input["maintenance"])) {
|
||||
$input["maintenance"] = 0;
|
||||
}
|
||||
|
||||
if (isset($input["pm_dbserver_passwd"])) {
|
||||
@@ -83,68 +103,79 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
$input['pm_admin_passwd'] = '';
|
||||
}
|
||||
|
||||
$input['domain'] = self::getCommonDomain( $CFG_GLPI['url_base'], $input['pm_server_URL'] ) ;
|
||||
$input['domain'] = self::getCommonDomain( $CFG_GLPI['url_base'], $input['pm_server_URL'] );
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getCommonDomain
|
||||
* @param mixed $url1
|
||||
* @param mixed $url2
|
||||
* @param mixed $url1 first url
|
||||
* @param mixed $url2 second url
|
||||
* @return string the common domain part of the given urls
|
||||
*/
|
||||
static function getCommonDomain($url1, $url2) {
|
||||
$domain = '';
|
||||
try {
|
||||
$glpi = explode( "/", $url1) ;
|
||||
$glpi = explode( ".", $glpi[2] );
|
||||
$pm = explode( "/", $url2) ;
|
||||
$pm = explode( ".", $pm[2] );
|
||||
$cglpi = array_shift(explode(":", array_pop( $glpi ))) ;
|
||||
$cpm = array_shift(explode(":", array_pop( $pm))) ;
|
||||
while( $cglpi && $cpm && $cglpi == $cpm ) {
|
||||
$domain = $cglpi.($domain==''?'':'.'.$domain) ;
|
||||
$cglpi = array_pop( $glpi ) ;
|
||||
$cpm = array_pop( $pm ) ;
|
||||
$glpi = explode(".", parse_url($url1, PHP_URL_HOST));
|
||||
$pm = explode( ".", parse_url($url2, PHP_URL_HOST));
|
||||
$cglpi = array_pop( $glpi );
|
||||
$cpm = array_pop( $pm );
|
||||
while ($cglpi && $cpm && $cglpi == $cpm) {
|
||||
$domain = $cglpi.($domain==''?'':'.'.$domain);
|
||||
$cglpi = array_pop( $glpi );
|
||||
$cpm = array_pop( $pm );
|
||||
}
|
||||
if( $domain != '' ) {
|
||||
return $domain ;
|
||||
if ($domain != '') {
|
||||
return $domain;
|
||||
}
|
||||
} catch(Exception $e) {}
|
||||
return '';
|
||||
} catch (Exception $e) {
|
||||
$domain = '';
|
||||
}
|
||||
return $domain;
|
||||
}
|
||||
|
||||
static function showConfigForm($item) {
|
||||
global $LANG, $PM_DB, $CFG_GLPI;
|
||||
/**
|
||||
* Summary of showConfigForm
|
||||
* @param mixed $item is the config
|
||||
* @return boolean
|
||||
*/
|
||||
static function showConfigForm($item) {
|
||||
global $LANG, $PM_DB, $CFG_GLPI;
|
||||
|
||||
$ui_theme = array(
|
||||
'glpi_classic' => 'glpi_classic',
|
||||
'glpi_neoclassic' => 'glpi_neoclassic'
|
||||
);
|
||||
$ui_theme = array(
|
||||
'glpi_classic' => 'glpi_classic',
|
||||
'glpi_neoclassic' => 'glpi_neoclassic'
|
||||
);
|
||||
|
||||
$config = self::getInstance();
|
||||
$config = self::getInstance();
|
||||
|
||||
$config->showFormHeader();
|
||||
$config->showFormHeader();
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['URL']."</td><td >";
|
||||
echo "<input size='50' type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>" ;
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['URL']."</td><td >";
|
||||
echo "<input size='50' type='text' name='pm_server_URL' value='".$config->fields['pm_server_URL']."'>";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . $LANG['processmaker']['config']['domain'] . "</td>";
|
||||
echo "<td><font color='red'><div name='domain'>".$config->fields['domain']."</div></font>";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . $LANG['processmaker']['config']['domain'] . "</td>";
|
||||
echo "<td><font color='red'><div name='domain'>".$config->fields['domain']."</div></font>";
|
||||
|
||||
echo Html::scriptBlock("
|
||||
echo Html::scriptBlock("
|
||||
function setCommonDomain() {
|
||||
//debugger;
|
||||
|
||||
function parseUrl( url ) {
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
// debugger;
|
||||
return { host: a.hostname, port: a.port, scheme: a.protocol.slice(0, -1), path: a.pathname, query: a.search.slice(1), fragment: a.hash.slice(1) } ;
|
||||
}
|
||||
var domain = '';
|
||||
try {
|
||||
var glpi= '".$CFG_GLPI['url_base']."'.split('/')[2].split('.') ;
|
||||
var pm = $('input[name=pm_server_URL]').val().split('/')[2].split('.');
|
||||
var cglpi = glpi.pop().split(':')[0] ;
|
||||
var cpm = pm.pop().split(':')[0] ;
|
||||
var glpi = parseUrl( '".$CFG_GLPI['url_base']."' ).host.split('.') ;
|
||||
var pm = parseUrl( $('input[name=pm_server_URL]').val()).host.split('.');
|
||||
var cglpi = glpi.pop() ;
|
||||
var cpm = pm.pop() ;
|
||||
while( cglpi && cpm && cglpi == cpm ) {
|
||||
domain = cglpi + (domain==''?'':'.' + domain) ;
|
||||
cglpi = glpi.pop() ;
|
||||
@@ -162,147 +193,145 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
$('input[name=pm_server_URL]').on('keyup', setCommonDomain ) ;
|
||||
setCommonDomain() ;
|
||||
");
|
||||
echo "</td></tr>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['workspace']."</td><td >";
|
||||
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['workspace']."</td><td >";
|
||||
echo "<input type='text' name='pm_workspace' value='".$config->fields['pm_workspace']."'>" ;
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . $LANG['processmaker']['config']['admin']['user'] . "</td>";
|
||||
echo "<td ><input type='text' name='pm_admin_user' value='".$config->fields["pm_admin_user"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . $LANG['processmaker']['config']['admin']['user'] . "</td>";
|
||||
echo "<td ><input type='text' name='pm_admin_user' value='".$config->fields["pm_admin_user"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . $LANG['processmaker']['config']['admin']['password'] . "</td>";
|
||||
echo "<td ><input type='password' name='pm_admin_passwd' value='' autocomplete='off'>";
|
||||
echo " <input type='checkbox' name='_blank_pm_admin_passwd'> ".__('Clear');
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . $LANG['processmaker']['config']['admin']['password'] . "</td>";
|
||||
echo "<td ><input type='password' name='pm_admin_passwd' value='' autocomplete='off'>";
|
||||
echo " <input type='checkbox' name='_blank_pm_admin_passwd'> ".__('Clear');
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
|
||||
$pm = new PluginProcessmakerProcessmaker;
|
||||
|
||||
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"] != ''
|
||||
&& ($pm->login(true))) {
|
||||
echo "<font color='green'>".__('Test successful');
|
||||
} else {
|
||||
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror,true);
|
||||
}
|
||||
echo "</font></span></td></tr>\n";
|
||||
if ($config->fields['pm_server_URL'] != ''
|
||||
&& $config->fields['pm_workspace'] != ''
|
||||
&& $config->fields["pm_admin_user"] != ''
|
||||
&& ($pm->login(true))) {
|
||||
echo "<font color='green'>".__('Test successful');
|
||||
} else {
|
||||
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror, true);
|
||||
}
|
||||
echo "</font></span></td></tr>\n";
|
||||
|
||||
echo "<tr><td colspan='4' class='center b'>".$LANG['processmaker']['config']['mysql']."</td></tr>";
|
||||
echo "<tr><td colspan='4' class='center b'>".$LANG['processmaker']['config']['mysql']."</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL server (MariaDB or MySQL)') . "</td>";
|
||||
echo "<td ><input type='text' size=50 name='pm_dbserver_name' value='".$config->fields["pm_dbserver_name"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL server (MariaDB or MySQL)') . "</td>";
|
||||
echo "<td ><input type='text' size=50 name='pm_dbserver_name' value='".$config->fields["pm_dbserver_name"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL user') . "</td>";
|
||||
echo "<td ><input type='text' name='pm_dbserver_user' value='".$config->fields["pm_dbserver_user"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL user') . "</td>";
|
||||
echo "<td ><input type='text' name='pm_dbserver_user' value='".$config->fields["pm_dbserver_user"]."'>";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL password') . "</td>";
|
||||
echo "<td ><input type='password' name='pm_dbserver_passwd' value='' autocomplete='off'>";
|
||||
echo " <input type='checkbox' name='_blank_pm_dbserver_passwd'> ".__('Clear');
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >" . __('SQL password') . "</td>";
|
||||
echo "<td ><input type='password' name='pm_dbserver_passwd' value='' autocomplete='off'>";
|
||||
echo " <input type='checkbox' name='_blank_pm_dbserver_passwd'> ".__('Clear');
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
|
||||
if( $PM_DB->connected ) {
|
||||
echo "<font color='green'>".__('Test successful');
|
||||
} else {
|
||||
echo "<font color='red'>".__('Test failed');
|
||||
}
|
||||
echo "</font></span></td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
|
||||
if ($PM_DB->connected) {
|
||||
echo "<font color='green'>".__('Test successful');
|
||||
} else {
|
||||
echo "<font color='red'>".__('Test failed');
|
||||
}
|
||||
echo "</font></span></td></tr>\n";
|
||||
|
||||
echo "<tr><td colspan='4' class='center b'>".__('Settings')."</td></tr>";
|
||||
echo "<tr><td colspan='4' class='center b'>".__('Settings')."</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['theme']."</td><td >";
|
||||
Dropdown::showFromArray('pm_theme', $ui_theme,
|
||||
array('value' => $config->fields['pm_theme']));
|
||||
echo "</td></tr>";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['theme']."</td><td >";
|
||||
Dropdown::showFromArray('pm_theme', $ui_theme,
|
||||
array('value' => $config->fields['pm_theme']));
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['main_task_category']."</td><td >";
|
||||
TaskCategory::dropdown(array('name' => 'taskcategories_id',
|
||||
'display_emptychoice' => true,
|
||||
'value' => $config->fields['taskcategories_id']));
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['main_task_category']."</td><td >";
|
||||
TaskCategory::dropdown(array('name' => 'taskcategories_id',
|
||||
'display_emptychoice' => true,
|
||||
'value' => $config->fields['taskcategories_id']));
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['taskwriter']."</td><td >";
|
||||
$rand = mt_rand() ;
|
||||
User::dropdown(array('name' => 'users_id',
|
||||
'display_emptychoice' => true,
|
||||
'right' => 'all',
|
||||
'rand' => $rand,
|
||||
'value' => $config->fields['users_id']));
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['taskwriter']."</td><td >";
|
||||
$rand = mt_rand();
|
||||
User::dropdown(array('name' => 'users_id',
|
||||
'display_emptychoice' => true,
|
||||
'right' => 'all',
|
||||
'rand' => $rand,
|
||||
'value' => $config->fields['users_id']));
|
||||
|
||||
// this code adds the + sign to the form
|
||||
echo "<img alt='' title=\"".__s('Add')."\" src='".$CFG_GLPI["root_doc"].
|
||||
"/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'
|
||||
// this code adds the + sign to the form
|
||||
echo "<img alt='' title=\"".__s('Add')."\" src='".$CFG_GLPI["root_doc"].
|
||||
"/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'
|
||||
onClick=\"".Html::jsGetElementbyID('add_dropdown'.$rand).".dialog('open');\">";
|
||||
echo Ajax::createIframeModalWindow('add_dropdown'.$rand,
|
||||
User::getFormURL(),
|
||||
array('display' => false));
|
||||
// end of + sign
|
||||
echo Ajax::createIframeModalWindow('add_dropdown'.$rand,
|
||||
User::getFormURL(),
|
||||
array('display' => false));
|
||||
// end of + sign
|
||||
|
||||
echo "</td></tr>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['pm_group_name']."</td><td >";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['pm_group_name']."</td><td >";
|
||||
|
||||
$pmGroups = array( 0 => Dropdown::EMPTY_VALUE ) ;
|
||||
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM content WHERE CON_CATEGORY='GRP_TITLE' AND CON_LANG='".$pm->lang."' ORDER BY CON_VALUE;" ;
|
||||
if( $PM_DB->connected ) {
|
||||
foreach( $PM_DB->request( $query ) as $row ) {
|
||||
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'] ;
|
||||
}
|
||||
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, array('value' => $config->fields['pm_group_guid']) ) ;
|
||||
} else {
|
||||
echo "<font color='red'>".__('Not connected');
|
||||
}
|
||||
$pmGroups = array( 0 => Dropdown::EMPTY_VALUE );
|
||||
$query = "SELECT DISTINCT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE' AND CON_LANG='".$pm->lang."' ORDER BY CON_VALUE;";
|
||||
if ($PM_DB->connected) {
|
||||
foreach ($PM_DB->request( $query ) as $row) {
|
||||
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
|
||||
}
|
||||
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, array('value' => $config->fields['pm_group_guid']) );
|
||||
} else {
|
||||
echo "<font color='red'>".__('Not connected');
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr><td colspan='4' class='center b'>".__('Maintenance')."</td></tr>";
|
||||
echo "<tr><td colspan='4' class='center b'>".__('Maintenance')."</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['maintenance']."</td><td >";
|
||||
Dropdown::showYesNo("maintenance", $config->fields['maintenance']);
|
||||
echo "</td></tr>";
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['maintenance']."</td><td >";
|
||||
Dropdown::showYesNo("maintenance", $config->fields['maintenance']);
|
||||
echo "</td></tr>";
|
||||
|
||||
$config->showFormButtons(array('candel'=>false));
|
||||
$config->showFormButtons(array('candel'=>false));
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
|
||||
if ($item->getType()=='Config') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
if ($item->getType()=='Config') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
if ($item->getType()=='Config') {
|
||||
self::showConfigForm($item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
if ($item->getType()=='Config') {
|
||||
self::showConfigForm($item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
class PluginProcessmakerDB extends DBmysql {
|
||||
class PluginProcessmakerDB extends DBmysql {
|
||||
|
||||
var $dbhost ;
|
||||
var $dbhost;
|
||||
|
||||
var $dbuser ;
|
||||
var $dbuser;
|
||||
|
||||
var $dbpassword ;
|
||||
var $dbpassword;
|
||||
|
||||
var $dbdefault ;
|
||||
var $dbdefault;
|
||||
|
||||
function __construct() {
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
if( $config->fields['pm_dbserver_name'] != ''
|
||||
&& $config->fields['pm_dbserver_user'] != ''
|
||||
&& $config->fields['pm_workspace'] != '' ) {
|
||||
$this->dbhost = $config->fields['pm_dbserver_name'] ;
|
||||
$this->dbuser = $config->fields['pm_dbserver_user'] ;
|
||||
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
|
||||
$this->dbdefault = "wf_".$config->fields['pm_workspace'] ;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
function __construct() {
|
||||
$config = PluginProcessmakerConfig::getInstance();
|
||||
if ($config->fields['pm_dbserver_name'] != ''
|
||||
&& $config->fields['pm_dbserver_user'] != ''
|
||||
&& $config->fields['pm_workspace'] != '' ) {
|
||||
$this->dbhost = $config->fields['pm_dbserver_name'];
|
||||
$this->dbuser = $config->fields['pm_dbserver_user'];
|
||||
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
|
||||
$this->dbdefault = "wf_".$config->fields['pm_workspace'];
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,50 +10,50 @@
|
||||
*/
|
||||
class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
{
|
||||
function can($ID, $right, array &$input = NULL) {
|
||||
return Session::haveRight('plugin_processmaker_config', $right) ;
|
||||
}
|
||||
function can($ID, $right, array &$input = NULL) {
|
||||
return Session::haveRight('plugin_processmaker_config', $right);
|
||||
}
|
||||
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][4];
|
||||
}
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][4];
|
||||
}
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
global $DB,$CFG_GLPI, $LANG;
|
||||
global $DB,$CFG_GLPI, $LANG;
|
||||
|
||||
$ID = $item->getField('id');
|
||||
$ID = $item->getField('id');
|
||||
|
||||
$canshowentity = Session::haveRight("entity", READ);
|
||||
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE) ;
|
||||
$canshowentity = Session::haveRight("entity", READ);
|
||||
$canedit = Session::haveRight('plugin_processmaker_config', UPDATE);
|
||||
|
||||
$rand=mt_rand();
|
||||
$rand=mt_rand();
|
||||
|
||||
if ($canedit) {
|
||||
echo "<div class='firstbloc'>";
|
||||
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
|
||||
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
|
||||
if ($canedit) {
|
||||
echo "<div class='firstbloc'>";
|
||||
echo "<form name='entityprocess_form$rand' id='entityprocess_form$rand' method='post' action='";
|
||||
echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr class='tab_bg_1'><th colspan='6'>".$LANG['processmaker']['title'][4]."</tr>";
|
||||
|
||||
echo "<tr class='tab_bg_2'><td class='center'>";
|
||||
echo "<input type='hidden' name='processes_id' value='$ID'>";
|
||||
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
|
||||
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
|
||||
Profile::dropdownUnder(array('value' => Profile::getDefault()));
|
||||
echo "</td><td class='center'>".__('Recursive')."</td><td>";
|
||||
Dropdown::showYesNo("is_recursive",0);
|
||||
echo "</td><td class='center'>";
|
||||
echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
|
||||
echo "</td></tr>";
|
||||
echo "<tr class='tab_bg_2'><td class='center'>";
|
||||
echo "<input type='hidden' name='processes_id' value='$ID'>";
|
||||
Entity::Dropdown( array('entity' => $_SESSION['glpiactiveentities']));
|
||||
echo "</td><td class='center'>".Profile::getTypeName(1)."</td><td>";
|
||||
Profile::dropdownUnder(array('value' => Profile::getDefault()));
|
||||
echo "</td><td class='center'>".__('Recursive')."</td><td>";
|
||||
Dropdown::showYesNo("is_recursive", 0);
|
||||
echo "</td><td class='center'>";
|
||||
echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
echo "</table>";
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
|
||||
$query = "SELECT DISTINCT `glpi_plugin_processmaker_processes_profiles`.`id` AS linkID,
|
||||
`glpi_profiles`.`id`,
|
||||
`glpi_profiles`.`name`,
|
||||
`glpi_plugin_processmaker_processes_profiles`.`is_recursive`,
|
||||
@@ -66,103 +66,102 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM
|
||||
ON (`glpi_plugin_processmaker_processes_profiles`.`entities_id` = `glpi_entities`.`id`)
|
||||
WHERE `glpi_plugin_processmaker_processes_profiles`.`processes_id` = '$ID'
|
||||
ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
|
||||
$result = $DB->query($query);
|
||||
$num = $DB->numrows($result);
|
||||
$result = $DB->query($query);
|
||||
$num = $DB->numrows($result);
|
||||
|
||||
echo "<div class='spaced'>";
|
||||
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
|
||||
echo "<div class='spaced'>";
|
||||
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
|
||||
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams = array('num_displayed' => $num,
|
||||
'container' => 'mass'.__CLASS__.$rand);
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams = array('num_displayed' => $num,
|
||||
'container' => 'mass'.__CLASS__.$rand);
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
|
||||
if ($num > 0) {
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
$header_begin = "<tr>";
|
||||
$header_top = '';
|
||||
$header_bottom = '';
|
||||
$header_end = '';
|
||||
if ($canedit) {
|
||||
$header_begin .= "<th>";
|
||||
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_end .= "</th>";
|
||||
}
|
||||
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
|
||||
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
|
||||
__('D=Dynamic, R=Recursive'));
|
||||
$header_end .= "</th></tr>";
|
||||
echo $header_begin.$header_top.$header_end;
|
||||
|
||||
if ($num > 0) {
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
$header_begin = "<tr>";
|
||||
$header_top = '';
|
||||
$header_bottom = '';
|
||||
$header_end = '';
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
if ($canedit) {
|
||||
$header_begin .= "<th>";
|
||||
$header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
|
||||
$header_end .= "</th>";
|
||||
}
|
||||
$header_end .= "<th>"._n('Entity', 'Entities', Session::getPluralNumber())."</th>";
|
||||
$header_end .= "<th>".sprintf(__('%1$s (%2$s)'), Profile::getTypeName(Session::getPluralNumber()),
|
||||
__('D=Dynamic, R=Recursive'));
|
||||
$header_end .= "</th></tr>";
|
||||
echo $header_begin.$header_top.$header_end;
|
||||
|
||||
while ($data = $DB->fetch_assoc($result)) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
if ($canedit) {
|
||||
echo "<td width='10'>";
|
||||
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
|
||||
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
|
||||
} else {
|
||||
echo " ";
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
echo "<td>";
|
||||
|
||||
$link = $data["completename"];
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
|
||||
}
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
|
||||
$data["entities_id"]."'>";
|
||||
}
|
||||
echo $link.($canshowentity ? "</a>" : '');
|
||||
echo "<td width='10'>";
|
||||
if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
|
||||
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
|
||||
} else {
|
||||
echo " ";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
if (Profile::canView()) {
|
||||
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
|
||||
$data["name"]."</a>";
|
||||
} else {
|
||||
$entname = $data["name"];
|
||||
}
|
||||
|
||||
// if ($data["is_dynamic"] || $data["is_recursive"]) {
|
||||
if ($data["is_recursive"]) {
|
||||
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
|
||||
//if ($data["is_dynamic"]) {
|
||||
// //TRANS: letter 'D' for Dynamic
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
|
||||
//}
|
||||
//if ($data["is_dynamic"] && $data["is_recursive"]) {
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
|
||||
//}
|
||||
if ($data["is_recursive"]) {
|
||||
//TRANS: letter 'R' for Recursive
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
|
||||
}
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
|
||||
}
|
||||
echo "<td>".$entname."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo $header_begin.$header_bottom.$header_end;
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th>".__('No item found')."</th></tr>";
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "<td>";
|
||||
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams['ontop'] = false;
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
$link = $data["completename"];
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
$link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
|
||||
}
|
||||
|
||||
if ($canshowentity) {
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL('Entity')."?id=".
|
||||
$data["entities_id"]."'>";
|
||||
}
|
||||
echo $link.($canshowentity ? "</a>" : '');
|
||||
echo "</td>";
|
||||
|
||||
if (Profile::canView()) {
|
||||
$entname = "<a href='".Toolbox::getItemTypeFormURL('Profile')."?id=".$data["id"]."'>".
|
||||
$data["name"]."</a>";
|
||||
} else {
|
||||
$entname = $data["name"];
|
||||
}
|
||||
|
||||
// if ($data["is_dynamic"] || $data["is_recursive"]) {
|
||||
if ($data["is_recursive"]) {
|
||||
$entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
|
||||
//if ($data["is_dynamic"]) {
|
||||
// //TRANS: letter 'D' for Dynamic
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
|
||||
//}
|
||||
//if ($data["is_dynamic"] && $data["is_recursive"]) {
|
||||
// $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
|
||||
//}
|
||||
if ($data["is_recursive"]) {
|
||||
//TRANS: letter 'R' for Recursive
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
|
||||
}
|
||||
$entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
|
||||
}
|
||||
echo "<td>".$entname."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo $header_begin.$header_bottom.$header_end;
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th>".__('No item found')."</th></tr>";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
if ($canedit && $num) {
|
||||
$massiveactionparams['ontop'] = false;
|
||||
Html::showMassiveActions($massiveactionparams);
|
||||
}
|
||||
Html::closeForm();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
//static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) {
|
||||
// global $CFG_GLPI;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,46 +12,46 @@ class ProcessmakerConfig extends CommonDBTM {
|
||||
var $table = 'glpi_plugins_processmaker_config';
|
||||
|
||||
|
||||
static function getTypeName($nb=0) {
|
||||
global $LANG;
|
||||
static function getTypeName($nb=0) {
|
||||
global $LANG;
|
||||
|
||||
return 'Process Maker Plugin Configuration';
|
||||
}
|
||||
return 'Process Maker Plugin Configuration';
|
||||
}
|
||||
|
||||
|
||||
function defineTabs($options=array()) {
|
||||
function defineTabs($options=array()) {
|
||||
|
||||
$ong = array();
|
||||
$this->addStandardTab(__CLASS__, $ong, $options);
|
||||
$ong = array();
|
||||
$this->addStandardTab(__CLASS__, $ong, $options);
|
||||
|
||||
return $ong;
|
||||
}
|
||||
return $ong;
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
switch ($item->getType()) {
|
||||
case __CLASS__ :
|
||||
$tabs[1] = $LANG['common'][12];
|
||||
return $tabs;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
switch ($item->getType()) {
|
||||
case __CLASS__ :
|
||||
$tabs[1] = $LANG['common'][12];
|
||||
return $tabs;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if($item->getType() == __CLASS__) {
|
||||
switch ($tabnum) {
|
||||
case 1 :
|
||||
$item->showFormMailServerConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ($item->getType() == __CLASS__) {
|
||||
switch ($tabnum) {
|
||||
case 1 :
|
||||
$item->showFormMailServerConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,35 +65,34 @@ class ProcessmakerConfig extends CommonDBTM {
|
||||
* @return Nothing (display)
|
||||
*
|
||||
**/
|
||||
function showForm($ID, $options=array()) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
function showForm($ID, $options=array()) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
if (!Session::haveRight("config", UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
if (!$CFG_GLPI['use_mailing']) {
|
||||
$options['colspan'] = 1;
|
||||
}
|
||||
if (!Session::haveRight("config", UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
if (!$CFG_GLPI['use_mailing']) {
|
||||
$options['colspan'] = 1;
|
||||
}
|
||||
|
||||
$this->getFromDB($ID);
|
||||
$this->showTabs($options);
|
||||
$this->addDivForTabs();
|
||||
return true;
|
||||
}
|
||||
$this->getFromDB($ID);
|
||||
$this->showTabs($options);
|
||||
$this->addDivForTabs();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static function canCreate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
static function canCreate() {
|
||||
return Session::haveRight('config', UPDATE);
|
||||
}
|
||||
|
||||
|
||||
static function canView() {
|
||||
return Session::haveRight('config', READ);
|
||||
}
|
||||
static function canView() {
|
||||
return Session::haveRight('config', READ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -12,23 +12,22 @@ class PluginProcessmakerProfile extends CommonDBTM {
|
||||
* Summary of getAllRights
|
||||
* @return array[]
|
||||
*/
|
||||
static function getAllRights() {
|
||||
global $LANG;
|
||||
static function getAllRights() {
|
||||
global $LANG;
|
||||
|
||||
$rights = array(
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['process_config'],
|
||||
'field' => 'plugin_processmaker_config',
|
||||
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['case_delete'],
|
||||
'field' => 'plugin_processmaker_deletecase',
|
||||
'rights' => array(DELETE => __('Delete')))
|
||||
);
|
||||
|
||||
$rights = array(
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['process_config'],
|
||||
'field' => 'plugin_processmaker_config',
|
||||
'rights' => array(READ => __('Read'), UPDATE => __('Update'))),
|
||||
array('itemtype' => 'PluginProcessmakerConfig',
|
||||
'label' => $LANG['processmaker']['profile']['case_delete'],
|
||||
'field' => 'plugin_processmaker_deletecase',
|
||||
'rights' => array(DELETE => __('Delete')))
|
||||
);
|
||||
|
||||
return $rights;
|
||||
}
|
||||
return $rights;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,106 +37,106 @@ class PluginProcessmakerProfile extends CommonDBTM {
|
||||
* @param mixed $closeform
|
||||
* @return bool
|
||||
*/
|
||||
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
|
||||
global $LANG;
|
||||
function showForm($ID=0, $openform=TRUE, $closeform=TRUE) {
|
||||
global $LANG;
|
||||
|
||||
if (!Session::haveRight("profile",READ)) {
|
||||
return false;
|
||||
}
|
||||
if (!Session::haveRight("profile", READ)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$canedit = Session::haveRight("profile", UPDATE);
|
||||
$prof = new Profile();
|
||||
if ($ID) {
|
||||
$prof->getFromDB($ID);
|
||||
}
|
||||
echo "<form action='".$prof->getFormURL()."' method='post'>";
|
||||
$rights = $this->getAllRights();
|
||||
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
|
||||
'default_class' => 'tab_bg_2',
|
||||
'title' => $LANG['processmaker']['title'][1]));
|
||||
$canedit = Session::haveRight("profile", UPDATE);
|
||||
$prof = new Profile();
|
||||
if ($ID) {
|
||||
$prof->getFromDB($ID);
|
||||
}
|
||||
echo "<form action='".$prof->getFormURL()."' method='post'>";
|
||||
$rights = $this->getAllRights();
|
||||
$prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit,
|
||||
'default_class' => 'tab_bg_2',
|
||||
'title' => $LANG['processmaker']['title'][1]));
|
||||
|
||||
if ($canedit && $closeform) {
|
||||
echo "<div class='center'>";
|
||||
echo Html::hidden('id', array('value' => $ID));
|
||||
echo Html::submit(_sx('button', 'Save'),
|
||||
array('name' => 'update'));
|
||||
echo "</div>\n";
|
||||
}
|
||||
if ($canedit && $closeform) {
|
||||
echo "<div class='center'>";
|
||||
echo Html::hidden('id', array('value' => $ID));
|
||||
echo Html::submit(_sx('button', 'Save'),
|
||||
array('name' => 'update'));
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
Html::closeForm();
|
||||
Html::closeForm();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of createAdminAccess
|
||||
* @param mixed $ID
|
||||
*/
|
||||
static function createAdminAccess($ID) {
|
||||
static function createAdminAccess($ID) {
|
||||
|
||||
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
|
||||
self::addDefaultProfileInfos($ID, array('plugin_processmaker_config' => READ + UPDATE, 'plugin_processmaker_deletecase' => DELETE), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getTabNameForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $withtemplate
|
||||
* @param mixed $withtemplate
|
||||
* @return string|string[]
|
||||
*/
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
|
||||
if ($item->getType()=='Profile') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
if ($item->getType()=='Profile') {
|
||||
return $LANG['processmaker']['title'][1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of displayTabContentForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @return bool
|
||||
*/
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if ($item->getType()=='Profile') {
|
||||
$ID = $item->getID();
|
||||
$prof = new self();
|
||||
self::addDefaultProfileInfos($ID,
|
||||
array('plugin_processmaker_config' => 0,
|
||||
'plugin_processmaker_deletecase' => 0
|
||||
));
|
||||
if ($item->getType()=='Profile') {
|
||||
$ID = $item->getID();
|
||||
$prof = new self();
|
||||
self::addDefaultProfileInfos($ID,
|
||||
array('plugin_processmaker_config' => 0,
|
||||
'plugin_processmaker_deletecase' => 0
|
||||
));
|
||||
|
||||
$prof->showForm($ID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
$prof->showForm($ID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $profile
|
||||
**/
|
||||
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
|
||||
global $DB;
|
||||
static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) {
|
||||
global $DB;
|
||||
|
||||
$profileRight = new ProfileRight();
|
||||
foreach ($rights as $right => $value) {
|
||||
if (countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
|
||||
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
|
||||
}
|
||||
if (!countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
|
||||
$myright['profiles_id'] = $profiles_id;
|
||||
$myright['name'] = $right;
|
||||
$myright['rights'] = $value;
|
||||
$profileRight->add($myright);
|
||||
$profileRight = new ProfileRight();
|
||||
foreach ($rights as $right => $value) {
|
||||
if (countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
|
||||
$profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right));
|
||||
}
|
||||
if (!countElementsInTable('glpi_profilerights',
|
||||
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
|
||||
$myright['profiles_id'] = $profiles_id;
|
||||
$myright['name'] = $right;
|
||||
$myright['rights'] = $value;
|
||||
$profileRight->add($myright);
|
||||
|
||||
//Add right to the current session
|
||||
$_SESSION['glpiactiveprofile'][$right] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Add right to the current session
|
||||
$_SESSION['glpiactiveprofile'][$right] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
*/
|
||||
class PluginProcessmakerTask extends CommonITILTask
|
||||
{
|
||||
private $itemtype ;
|
||||
function __construct($itemtype) {
|
||||
parent::__construct();
|
||||
$this->itemtype=$itemtype;
|
||||
}
|
||||
private $itemtype;
|
||||
function __construct($itemtype) {
|
||||
parent::__construct();
|
||||
$this->itemtype=$itemtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getFromDB
|
||||
@@ -22,112 +22,112 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
* @param mixed $itemtype
|
||||
* @return bool
|
||||
*/
|
||||
function getFromDB($items_id) {
|
||||
global $DB ;
|
||||
function getFromDB($items_id) {
|
||||
global $DB;
|
||||
|
||||
if( $this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ) ) {
|
||||
$task = new $this->itemtype;
|
||||
if( $task->getFromDB( $items_id ) ) {
|
||||
// then we should add our own fields
|
||||
$task->fields['items_id'] = $this->fields['id'] ;
|
||||
$task->fields['itemtype'] = $this->fields['itemtype'] ;
|
||||
unset( $this->fields['id'] ) ;
|
||||
unset( $this->fields['items_id'] ) ;
|
||||
unset( $this->fields['itemtype'] ) ;
|
||||
foreach( $this->fields as $field => $val) {
|
||||
$task->fields[ $field ] = $val ;
|
||||
}
|
||||
$this->fields = $task->fields ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) {
|
||||
$task = new $this->itemtype;
|
||||
if ($task->getFromDB( $items_id )) {
|
||||
// then we should add our own fields
|
||||
$task->fields['items_id'] = $this->fields['id'];
|
||||
$task->fields['itemtype'] = $this->fields['itemtype'];
|
||||
unset( $this->fields['id'] );
|
||||
unset( $this->fields['items_id'] );
|
||||
unset( $this->fields['itemtype'] );
|
||||
foreach ($this->fields as $field => $val) {
|
||||
$task->fields[ $field ] = $val;
|
||||
}
|
||||
$this->fields = $task->fields;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
|
||||
//$query = "SELECT * FROM ".self::getTable()." WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" ;
|
||||
|
||||
//$ret = $DB->query( $query ) ;
|
||||
//if( $ret && $DB->numrows( $ret ) == 1 ) {
|
||||
// $row = $DB->fetch_assoc( $ret ) ;
|
||||
// $task = new $this->itemtype;
|
||||
// if( $task->getFromDB( $row['items_id'] ) ) {
|
||||
// // then we should add our own fields
|
||||
// unset( $row['id'] ) ;
|
||||
// unset( $row['items_id'] ) ;
|
||||
// unset( $row['itemtype'] ) ;
|
||||
// foreach( $row as $field => $val) {
|
||||
// $task->fields[ $field ] = $val ;
|
||||
// }
|
||||
// $this->fields = $task->fields ;
|
||||
// return true ;
|
||||
// }
|
||||
//}
|
||||
return false ;
|
||||
}
|
||||
//$ret = $DB->query( $query ) ;
|
||||
//if( $ret && $DB->numrows( $ret ) == 1 ) {
|
||||
// $row = $DB->fetch_assoc( $ret ) ;
|
||||
// $task = new $this->itemtype;
|
||||
// if( $task->getFromDB( $row['items_id'] ) ) {
|
||||
// // then we should add our own fields
|
||||
// unset( $row['id'] ) ;
|
||||
// unset( $row['items_id'] ) ;
|
||||
// unset( $row['itemtype'] ) ;
|
||||
// foreach( $row as $field => $val) {
|
||||
// $task->fields[ $field ] = $val ;
|
||||
// }
|
||||
// $this->fields = $task->fields ;
|
||||
// return true ;
|
||||
// }
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getToDoTasks
|
||||
* returns all 'to do' tasks associated with this case
|
||||
* @param mixed $case_id
|
||||
*/
|
||||
public static function getToDoTasks( $case_id, $itemtype ) {
|
||||
global $DB ;
|
||||
$ret = array();
|
||||
$selfTable = getTableForItemType( __CLASS__) ;
|
||||
$itemTypeTaskTable = getTableForItemType( $itemtype );
|
||||
public static function getToDoTasks( $case_id, $itemtype ) {
|
||||
global $DB;
|
||||
$ret = array();
|
||||
$selfTable = getTableForItemType( __CLASS__);
|
||||
$itemTypeTaskTable = getTableForItemType( $itemtype );
|
||||
|
||||
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
|
||||
$query = "SELECT glpi_tickettasks.id as taskID from $itemTypeTaskTable
|
||||
INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
|
||||
WHERE $itemTypeTaskTable.state=1 and $selfTable.case_id='$case_id';";
|
||||
foreach($DB->request($query) as $row){
|
||||
$ret[$row['taskID']]=$row['taskID'];
|
||||
}
|
||||
return $ret ;
|
||||
}
|
||||
foreach ($DB->request($query) as $row) {
|
||||
$ret[$row['taskID']]=$row['taskID'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
static function canView( ) {
|
||||
return true ;
|
||||
static function canView( ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static function populatePlanning($params) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
$ret = array();
|
||||
$events = array() ;
|
||||
if( isset($params['start']) ) {
|
||||
$events = array();
|
||||
if (isset($params['start'])) {
|
||||
$params['begin'] = '2000-01-01 00:00:00';
|
||||
if ($params['type'] == 'group') {
|
||||
$params['who_group'] = $params['who'];
|
||||
$params['whogroup'] = $params['who'];
|
||||
$params['who'] = 0 ;
|
||||
$params['who'] = 0;
|
||||
}
|
||||
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
|
||||
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params );
|
||||
|
||||
foreach( $ret as $key => $event ) {
|
||||
if( $event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
|
||||
foreach ($ret as $key => $event) {
|
||||
if ($event['state'] == 1 || ($params['display_done_events'] == 1 && $event['state'] == 2)) { // if todo or done but need to show them (=planning)
|
||||
// check if task is one within a case
|
||||
$pmTask = new self('TicketTask');
|
||||
if( $pmTask->getFromDB( $event['tickettasks_id'] ) ) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
|
||||
if ($pmTask->getFromDB( $event['tickettasks_id'] )) { // $pmTask->getFromDBByQuery( " WHERE itemtype = 'TicketTask' AND items_id = ". $event['tickettasks_id'] ) ) {
|
||||
$event['editable'] = false;
|
||||
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases' ;
|
||||
$event['url'] .= '&forcetab=PluginProcessmakerCase$processmakercases';
|
||||
|
||||
$taskCat = new TaskCategory ;
|
||||
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] ) ;
|
||||
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '' ;
|
||||
if( Session::haveTranslations('TaskCategory', 'comment') ) {
|
||||
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment ) ;
|
||||
$taskCat = new TaskCategory;
|
||||
$taskCat->getFromDB( $pmTask->fields['taskcategories_id'] );
|
||||
$taskComment = isset($taskCat->fields['comment']) ? $taskCat->fields['comment'] : '';
|
||||
if (Session::haveTranslations('TaskCategory', 'comment')) {
|
||||
$taskComment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskComment );
|
||||
}
|
||||
|
||||
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] ) ;
|
||||
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ) ; //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
|
||||
$event['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $event['content'] );
|
||||
$event['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $event['content'] ); //<a href=\"".$event['url']."\">"."Click to manage task"."</a>
|
||||
//if( $event['state'] == 1 && $event['end'] < $params['start'] ) { // if todo and late
|
||||
// $event['name'] = $event['end'].' '.$event['name'] ; //$event['begin'].' to '.$event['end'].' '.$event['name'] ;
|
||||
// $event['end'] = $params['start'].' 24:00:00'; //.$CFG_GLPI['planning_end'];
|
||||
//}
|
||||
$events[$key] = $event ;
|
||||
$events[$key] = $event;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $events ;
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,73 +10,72 @@
|
||||
*/
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
{
|
||||
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][3];
|
||||
}
|
||||
function getTabNameForItem( CommonGLPI $item, $withtemplate=0) {
|
||||
global $LANG;
|
||||
return $LANG['processmaker']['title'][3];
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||
|
||||
global $LANG, $DB ;
|
||||
global $LANG, $DB;
|
||||
|
||||
self::title($item) ;
|
||||
self::title($item);
|
||||
|
||||
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
||||
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
|
||||
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th></tr>";
|
||||
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
||||
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
|
||||
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
|
||||
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th></tr>";
|
||||
|
||||
$query = "select pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment` from glpi_plugin_processmaker_taskcategories as pm
|
||||
left join glpi_taskcategories as gl on pm.taskcategories_id=gl.id
|
||||
where pm.processes_id=".$item->getID().";" ;
|
||||
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment` FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||
WHERE pm.processes_id=".$item->getID().";";
|
||||
|
||||
foreach ($DB->request($query) as $taskCat) {
|
||||
echo "<tr class='tab_bg_1'><td class='b'><a href='".
|
||||
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
|
||||
$taskCat['taskcategories_id']."'>".str_replace(" ", " ", $taskCat['name']);
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$taskCat['taskcategories_id'].")";
|
||||
}
|
||||
echo "</a></td><td >".str_replace(" ", " ", $taskCat['completename'])."</td>
|
||||
foreach ($DB->request($query) as $taskCat) {
|
||||
echo "<tr class='tab_bg_1'><td class='b'><a href='".
|
||||
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
|
||||
$taskCat['taskcategories_id']."'>".str_replace(" ", " ", $taskCat['name']);
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$taskCat['taskcategories_id'].")";
|
||||
}
|
||||
echo "</a></td><td >".str_replace(" ", " ", $taskCat['completename'])."</td>
|
||||
<td >".$taskCat['pm_task_guid']."</td>".
|
||||
"<td>".($taskCat['start']?'x':'')."</td><td >".
|
||||
$taskCat['comment']."</td></tr>";
|
||||
}
|
||||
echo "</table></div>";
|
||||
$taskCat['comment']."</td></tr>";
|
||||
}
|
||||
echo "</table></div>";
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a good title for task categories tab
|
||||
* add button for re-synchro of taskcategory list (only if rigths are w)
|
||||
* @return nothing (display)
|
||||
**/
|
||||
static function title(CommonGLPI $item) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
static function title(CommonGLPI $item) {
|
||||
global $LANG, $CFG_GLPI;
|
||||
|
||||
$buttons = array();
|
||||
$title = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
$buttons = array();
|
||||
$title = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
|
||||
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
|
||||
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
$title = "";
|
||||
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
|
||||
$buttons);
|
||||
}
|
||||
}
|
||||
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
|
||||
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $LANG['processmaker']['config']['refreshtasklist'];
|
||||
$title = "";
|
||||
Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $LANG['processmaker']['config']['refreshtasklist'], $title,
|
||||
$buttons);
|
||||
}
|
||||
}
|
||||
|
||||
//function getLinkItemFromExternalID($extId) {
|
||||
// if( $this->getFromDBbyExternalID( $extId ) ) {
|
||||
@@ -93,24 +92,24 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
*
|
||||
* @return true if succeed else false
|
||||
**/
|
||||
function getFromDBbyExternalID($extid) {
|
||||
global $DB;
|
||||
function getFromDBbyExternalID($extid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `pm_task_guid` = '$extid'";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a TaskCat from the database using its category id (unique index): taskcategories_id
|
||||
@@ -119,23 +118,23 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
*
|
||||
* @return true if succeed else false
|
||||
**/
|
||||
function getFromDBbyCategory($catid) {
|
||||
global $DB;
|
||||
function getFromDBbyCategory($catid) {
|
||||
global $DB;
|
||||
|
||||
$query = "SELECT *
|
||||
$query = "SELECT *
|
||||
FROM `".$this->getTable()."`
|
||||
WHERE `taskcategories_id` = $catid";
|
||||
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if ($result = $DB->query($query)) {
|
||||
if ($DB->numrows($result) != 1) {
|
||||
return false;
|
||||
}
|
||||
$this->fields = $DB->fetch_assoc($result);
|
||||
if (is_array($this->fields) && count($this->fields)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,115 +25,107 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
*
|
||||
* @return mysql result set.
|
||||
**/
|
||||
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
|
||||
static function getSqlSearchResult ($taskId, $count=true, $right="all", $entity_restrict=-1, $value=0,
|
||||
$used=array(), $search='', $limit='') {
|
||||
global $DB, $PM_DB, $CFG_GLPI;
|
||||
global $DB, $PM_DB, $CFG_GLPI;
|
||||
|
||||
// first need to get all users from $taskId
|
||||
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
|
||||
$pmQuery = "SELECT group_user.USR_UID as pm_user_id FROM task_user
|
||||
JOIN group_user on group_user.GRP_UID=task_user.USR_UID AND task_user.TU_RELATION = 2 AND task_user.TU_TYPE=1
|
||||
WHERE TAS_UID = '$taskId'; " ;
|
||||
$pmUsers = array( ) ;
|
||||
foreach( $PM_DB->request( $pmQuery ) as $pmUser ) {
|
||||
$pmUsers[ ] = $pmUser[ 'pm_user_id' ] ;
|
||||
}
|
||||
// first need to get all users from $taskId
|
||||
//$db_pm = PluginProcessmakerConfig::getInstance()->getProcessMakerDB();
|
||||
$pmQuery = "SELECT GROUP_USER.USR_UID AS pm_user_id FROM TASK_USER
|
||||
JOIN GROUP_USER ON GROUP_USER.GRP_UID=TASK_USER.USR_UID AND TASK_USER.TU_RELATION = 2 AND TASK_USER.TU_TYPE=1
|
||||
WHERE TAS_UID = '$taskId'; ";
|
||||
$pmUsers = array( );
|
||||
foreach ($PM_DB->request( $pmQuery ) as $pmUser) {
|
||||
$pmUsers[ ] = $pmUser[ 'pm_user_id' ];
|
||||
}
|
||||
|
||||
$joinprofile = false;
|
||||
switch ($right) {
|
||||
case "id" :
|
||||
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
|
||||
break;
|
||||
|
||||
$joinprofile = false;
|
||||
switch ($right) {
|
||||
case "all" :
|
||||
$where = " `glpi_users`.`id` > '1' ";
|
||||
break;
|
||||
}
|
||||
|
||||
case "id" :
|
||||
$where = " `glpi_users`.`id` = '".Session::getLoginUserID()."' ";
|
||||
break;
|
||||
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') ";
|
||||
|
||||
case "all" :
|
||||
$where = " `glpi_users`.`id` > '1' " ;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND glpi_plugin_processmaker_users.pm_users_id IN ('".join("', '", $pmUsers)."') " ;
|
||||
// $where .= " AND `glpi_users`.`realname` <> '' AND `glpi_users`.`firstname` <> '' AND `glpi_useremails`.`email` <> '' AND TAS_UID = '$taskId' " ;
|
||||
|
||||
$where .= " AND `glpi_users`.`is_deleted` = '0'
|
||||
$where .= " AND `glpi_users`.`is_deleted` = '0'
|
||||
AND `glpi_users`.`is_active` = '1' ";
|
||||
|
||||
if ((is_numeric($value) && $value)
|
||||
|| count($used)) {
|
||||
if ((is_numeric($value) && $value)
|
||||
|| count($used)) {
|
||||
|
||||
$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
if (is_numeric($value)) {
|
||||
$first = false;
|
||||
$where .= $value;
|
||||
$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
if (is_numeric($value)) {
|
||||
$first = false;
|
||||
$where .= $value;
|
||||
} else {
|
||||
$first = true;
|
||||
}
|
||||
foreach ($used as $val) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$first = true;
|
||||
$where .= ",";
|
||||
}
|
||||
foreach ($used as $val) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$where .= ",";
|
||||
}
|
||||
$where .= $val;
|
||||
}
|
||||
$where .= ")";
|
||||
}
|
||||
$where .= $val;
|
||||
}
|
||||
$where .= ")";
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
|
||||
} else {
|
||||
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
|
||||
}
|
||||
if ($count) {
|
||||
$query = "SELECT COUNT(DISTINCT glpi_users.id ) AS cpt ";
|
||||
} else {
|
||||
$query = "SELECT DISTINCT glpi_users.id , `glpi_users`.`realname`, `glpi_users`.`firstname`, `glpi_users`.`name`, `glpi_useremails`.`email` ";
|
||||
}
|
||||
|
||||
$query .= "FROM glpi_plugin_processmaker_users
|
||||
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id " ;
|
||||
//$query .= "from wf_workflow.task_user
|
||||
// join wf_workflow.group_user on wf_workflow.group_user.GRP_UID=wf_workflow.task_user.USR_UID and wf_workflow.task_user.TU_RELATION = 2 and wf_workflow.task_user.TU_TYPE=1
|
||||
// join glpi_plugin_processmaker_users on glpi_plugin_processmaker_users.pm_users_id=wf_workflow.group_user.USR_UID
|
||||
// join glpi_users on glpi_users.id=glpi_plugin_processmaker_users.glpi_users_id " ;
|
||||
$query .= "FROM glpi_plugin_processmaker_users
|
||||
JOIN glpi_users ON glpi_users.id=glpi_plugin_processmaker_users.id ";
|
||||
|
||||
$query .= " LEFT JOIN `glpi_useremails`
|
||||
$query .= " LEFT JOIN `glpi_useremails`
|
||||
ON (`glpi_users`.`id` = `glpi_useremails`.`users_id` AND `glpi_useremails`.is_default = 1)";
|
||||
$query .= " LEFT JOIN `glpi_profiles_users`
|
||||
$query .= " LEFT JOIN `glpi_profiles_users`
|
||||
ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)";
|
||||
|
||||
if ($joinprofile) {
|
||||
$query .= " LEFT JOIN `glpi_profiles`
|
||||
if ($joinprofile) {
|
||||
$query .= " LEFT JOIN `glpi_profiles`
|
||||
ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`) ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$query .= " WHERE $where ";
|
||||
} else {
|
||||
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
|
||||
if ($count) {
|
||||
$query .= " WHERE $where ";
|
||||
} else {
|
||||
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
$where .= " AND (`glpi_users`.`name` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`realname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`firstname` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_users`.`phone` ".Search::makeTextSearch($search)."
|
||||
OR `glpi_useremails`.`email` ".Search::makeTextSearch($search)."
|
||||
OR CONCAT(`glpi_users`.`realname`,' ',`glpi_users`.`firstname`) ".
|
||||
Search::makeTextSearch($search).")";
|
||||
}
|
||||
$query .= " WHERE $where ";
|
||||
Search::makeTextSearch($search).")";
|
||||
}
|
||||
$query .= " WHERE $where ";
|
||||
|
||||
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
|
||||
$query.=" ORDER BY `glpi_users`.`firstname`,
|
||||
if ($_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE) {
|
||||
$query.=" ORDER BY `glpi_users`.`firstname`,
|
||||
`glpi_users`.`realname`,
|
||||
`glpi_users`.`name` ";
|
||||
} else {
|
||||
$query.=" ORDER BY `glpi_users`.`realname`,
|
||||
} else {
|
||||
$query.=" ORDER BY `glpi_users`.`realname`,
|
||||
`glpi_users`.`firstname`,
|
||||
`glpi_users`.`name` ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search != $CFG_GLPI["ajax_wildcard"]) {
|
||||
$query .= " $limit";
|
||||
}
|
||||
}
|
||||
if ($search != $CFG_GLPI["ajax_wildcard"]) {
|
||||
$query .= " $limit";
|
||||
}
|
||||
}
|
||||
|
||||
return $DB->query($query);
|
||||
}
|
||||
return $DB->query($query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -166,12 +158,12 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
*
|
||||
* @return int (print out an HTML select box)
|
||||
**/
|
||||
static function dropdown($options=array()) {
|
||||
global $CFG_GLPI ;
|
||||
static function dropdown($options=array()) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php' ;
|
||||
return User::dropdown( $options ) ;
|
||||
}
|
||||
$options['url'] = $CFG_GLPI["root_doc"].'/plugins/processmaker/ajax/dropdownUsers.php';
|
||||
return User::dropdown( $options );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -180,13 +172,13 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
* @param string $pmUserId
|
||||
* @return int GLPI user id, or 0 if not found
|
||||
*/
|
||||
public static function getGLPIUserId( $pmUserId ){
|
||||
$obj = new self ;
|
||||
if( $obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'") ) {
|
||||
return $obj->fields['id'] ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
public static function getGLPIUserId( $pmUserId ) {
|
||||
$obj = new self;
|
||||
if ($obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'")) {
|
||||
return $obj->fields['id'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getPMUserId
|
||||
@@ -194,13 +186,13 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
* @param int $glpi_userId id of user from GLPI database
|
||||
* @return string which is the uid of user in Processmaker database, or false if not found
|
||||
*/
|
||||
public static function getPMUserId( $glpiUserId ) {
|
||||
$obj = new self;
|
||||
if( $obj->getFromDB( Toolbox::cleanInteger($glpiUserId) ) ) {
|
||||
return $obj->fields['pm_users_id'] ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
public static function getPMUserId( $glpiUserId ) {
|
||||
$obj = new self;
|
||||
if ($obj->getFromDB( Toolbox::cleanInteger($glpiUserId) )) {
|
||||
return $obj->fields['pm_users_id'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///**
|
||||
// * Summary of getNewPassword
|
||||
|
||||
@@ -1,45 +1,46 @@
|
||||
|
||||
var oldHandler ;
|
||||
var oldHandler;
|
||||
var submitButton;
|
||||
var caseIFrame;
|
||||
|
||||
function onClickContinue(obj) {
|
||||
//debugger;
|
||||
// call old handler
|
||||
if (obj != undefined && oldHandler)
|
||||
oldHandler(obj.target);
|
||||
// hide the iFrame
|
||||
caseIFrame.style.visibility = 'hidden';
|
||||
//debugger;
|
||||
// call old handler
|
||||
if (obj != undefined && oldHandler) {
|
||||
oldHandler(obj.target);
|
||||
}
|
||||
// hide the iFrame
|
||||
caseIFrame.style.visibility = 'hidden';
|
||||
|
||||
// call new handler
|
||||
submitButton.click();
|
||||
// call new handler
|
||||
submitButton.click();
|
||||
}
|
||||
|
||||
|
||||
// used to find an element in a list and to hide it!
|
||||
function bGLPIHideElement(eltList, attribute, value) {
|
||||
var ret = false;
|
||||
for (var i = 0; i < eltList.length; i++) {
|
||||
var node = eltList[i];
|
||||
if (node.getAttribute(attribute) == value) {
|
||||
// hide the link
|
||||
node.style.display = 'none';
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
var ret = false;
|
||||
for (var i = 0; i < eltList.length; i++) {
|
||||
var node = eltList[i];
|
||||
if (node.getAttribute(attribute) == value) {
|
||||
// hide the link
|
||||
node.style.display = 'none';
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
var caseTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//var bAreaUseRequestSumUp = false;
|
||||
var bButtonContinue = false;
|
||||
var caseTimer = window.setInterval(function () {
|
||||
//debugger ;
|
||||
// look for frmDerivation form
|
||||
var caseTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//var bAreaUseRequestSumUp = false;
|
||||
var bButtonContinue = false;
|
||||
var caseTimer = window.setInterval(function () {
|
||||
//debugger ;
|
||||
// look for frmDerivation form
|
||||
|
||||
caseIFrame = document.getElementById('caseiframe');
|
||||
caseIFrame = document.getElementById('caseiframe');
|
||||
|
||||
var contentDocument;
|
||||
try {
|
||||
@@ -48,58 +49,55 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
contentDocument = false;
|
||||
}
|
||||
if (caseIFrame != undefined && contentDocument) {
|
||||
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
|
||||
var linkList = contentDocument.getElementsByTagName('a');
|
||||
if (txtAreaUseRequestSumUp != undefined) {
|
||||
//debugger;
|
||||
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
|
||||
} else
|
||||
$("textarea[name='content']")[0].value = '_';
|
||||
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
|
||||
var linkList = contentDocument.getElementsByTagName('a');
|
||||
if (txtAreaUseRequestSumUp != undefined) {
|
||||
//debugger;
|
||||
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
|
||||
} 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
|
||||
// change action for the attached form and add some parameters
|
||||
//debugger;
|
||||
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
|
||||
// change action for the attached form and add some parameters
|
||||
//debugger;
|
||||
|
||||
bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN');
|
||||
bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN');
|
||||
|
||||
//buttonContinue.form.action = null; //'';
|
||||
//if (buttonContinue.addEventListener)
|
||||
// buttonContinue.addEventListener("click", onClickContinue, false);
|
||||
//else
|
||||
// buttonContinue.attachEvent("onclick", onClickContinue);
|
||||
oldHandler = buttonContinue.onclick;
|
||||
buttonContinue.onclick = onClickContinue;
|
||||
//buttonContinue.form.action = null; //'';
|
||||
//if (buttonContinue.addEventListener)
|
||||
// buttonContinue.addEventListener("click", onClickContinue, false);
|
||||
//else
|
||||
// buttonContinue.attachEvent("onclick", onClickContinue);
|
||||
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 + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
|
||||
|
||||
submitButton = $("input[name='add'][type=submit]")[0];
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_action' value='routecase'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseid' value='" + caseId + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
|
||||
|
||||
$("input[name='name'][type=text]")[0].value = processName;
|
||||
|
||||
}
|
||||
$("input[name='name'][type=text]")[0].value = processName;
|
||||
|
||||
}
|
||||
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var locElt = contentDocument.getElementsByTagName("form")[0];
|
||||
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
|
||||
caseIFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
if (!redimIFrame) {
|
||||
var locElt = contentDocument.getElementsByTagName("form")[0];
|
||||
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10;
|
||||
caseIFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( caseTimerCounter > 3000 ) {
|
||||
window.clearInterval(caseTimer);
|
||||
} else {
|
||||
caseTimerCounter = caseTimerCounter + 1;
|
||||
}
|
||||
|
||||
if( caseTimerCounter > 3000 )
|
||||
window.clearInterval(caseTimer) ;
|
||||
else
|
||||
caseTimerCounter = caseTimerCounter + 1;
|
||||
|
||||
},
|
||||
10) ;
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
||||
422
js/cases.js
422
js/cases.js
@@ -9,14 +9,14 @@ var GLPI_DURING_RELOAD = false;
|
||||
// used to find an element in a list and to hide it!
|
||||
function bGLPIHideElement(eltList, attribute, value) {
|
||||
var ret = false;
|
||||
for (var i = 0; i < eltList.length && !ret; i++) {
|
||||
var node = eltList[i];
|
||||
if (node.getAttribute(attribute) == value) {
|
||||
// hide the link
|
||||
node.style.display = 'none';
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < eltList.length && !ret; i++) {
|
||||
var node = eltList[i];
|
||||
if (node.getAttribute(attribute) == value) {
|
||||
// hide the link
|
||||
node.style.display = 'none';
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -42,172 +42,174 @@ function displayOverlay() {
|
||||
|
||||
|
||||
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
//alert("Loaded frame " + delIndex);
|
||||
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
|
||||
var bShowHideNextStep = false ; // not done yet!
|
||||
var bHideClaimCancelButton = false; // To manage 'Claim' button
|
||||
var taskFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//debugger;
|
||||
var taskFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locContentDocument;
|
||||
var taskFrame = document.getElementById(taskFrameId);
|
||||
try {
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
} catch (ex) {
|
||||
locContentDocument = false;
|
||||
}
|
||||
if (taskFrame != undefined && locContentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
//alert("Loaded frame " + delIndex);
|
||||
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
|
||||
var bShowHideNextStep = false; // not done yet!
|
||||
var bHideClaimCancelButton = false; // To manage 'Claim' button
|
||||
var taskFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//debugger;
|
||||
var taskFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locContentDocument;
|
||||
var taskFrame = document.getElementById(taskFrameId);
|
||||
try {
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
} catch (ex) {
|
||||
locContentDocument = false;
|
||||
}
|
||||
if (taskFrame != undefined && locContentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
|
||||
// if task resumé, then hide the form part
|
||||
//debugger;
|
||||
//var form_resume = locContentDocument.getElementsByName('cases_Resume');
|
||||
//if (form_resume.length > 0 && form_resume[0].style.display != 'none') {
|
||||
// form_resume[0].style.display = 'none';
|
||||
//}
|
||||
// if task resumé, then hide the form part
|
||||
//debugger;
|
||||
//var form_resume = locContentDocument.getElementsByName('cases_Resume');
|
||||
//if (form_resume.length > 0 && form_resume[0].style.display != 'none') {
|
||||
// form_resume[0].style.display = 'none';
|
||||
//}
|
||||
|
||||
// then look if btnGLPISendRequest exists,
|
||||
var locElt = locContentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
if (!bShowHideNextStep && locElt != undefined ) {
|
||||
var linkList = locContentDocument.getElementsByTagName('a');
|
||||
if (bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN')) {
|
||||
// the next step link is hidden
|
||||
// then look if btnGLPISendRequest exists,
|
||||
var locElt = locContentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
if (!bShowHideNextStep && locElt != undefined ) {
|
||||
var linkList = locContentDocument.getElementsByTagName('a');
|
||||
if (bGLPIHideElement(linkList, 'href', 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN')) {
|
||||
// the next step link is hidden
|
||||
|
||||
// if yes then change the link behind the button itself
|
||||
locElt.type = 'submit';
|
||||
locElt.onclick = null; // in order to force use of the action of form POST
|
||||
var formList = locContentDocument.getElementsByTagName('form');
|
||||
// if yes then change the link behind the button itself
|
||||
locElt.type = 'submit';
|
||||
locElt.onclick = null; // in order to force use of the action of form POST
|
||||
var formList = locContentDocument.getElementsByTagName('form');
|
||||
|
||||
// if yes then change the action of the form POST
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
// if yes then change the action of the form POST
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
// add an element that will be the csrf data code for the POST
|
||||
//debugger;
|
||||
var csrfElt = document.createElement("input");
|
||||
csrfElt.setAttribute("type", "hidden");
|
||||
csrfElt.setAttribute("name", "_glpi_csrf_token") ;
|
||||
csrfElt.setAttribute("value", csrf) ;
|
||||
node.appendChild(csrfElt);
|
||||
// add an element that will be the csrf data code for the POST
|
||||
//debugger;
|
||||
var csrfElt = document.createElement("input");
|
||||
csrfElt.setAttribute("type", "hidden");
|
||||
csrfElt.setAttribute("name", "_glpi_csrf_token");
|
||||
csrfElt.setAttribute("value", csrf);
|
||||
node.appendChild(csrfElt);
|
||||
|
||||
// add showMask function to submit event
|
||||
//node.addEventListener('submit', displayOverlay, true);
|
||||
} else {
|
||||
// then hide the button itself
|
||||
locElt.style.display = 'none';
|
||||
}
|
||||
|
||||
bShowHideNextStep = true;
|
||||
}
|
||||
|
||||
// Hide 'Cancel' button on 'Claim' form
|
||||
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
|
||||
if (cancelButton != undefined && !bHideClaimCancelButton) {
|
||||
cancelButton.style.display = 'none';
|
||||
// hides claim button if asked for
|
||||
if (hideClaimButton) {
|
||||
claimButton = locContentDocument.getElementById('form[BTN_CATCH]');
|
||||
claimButton.style.display = 'none';
|
||||
}
|
||||
// to manage Claim
|
||||
var formList = locContentDocument.getElementsByTagName('form');
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
bHideClaimCancelButton = true;
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask);
|
||||
}
|
||||
|
||||
// to force immediate reload of GLPI item form
|
||||
var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD');
|
||||
if (forcedReload != undefined && !GLPI_DURING_RELOAD) {
|
||||
//showMask();
|
||||
GLPI_DURING_RELOAD = true; // to prevent double reload
|
||||
window.clearInterval(taskFrameTimer); // stop timer
|
||||
GLPI_RELOAD_PARENT.location.reload();
|
||||
}
|
||||
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
var redimFrameTimer = window.setInterval(function () {
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
}, 1000);
|
||||
|
||||
redimIFrame = true;
|
||||
// add showMask function to submit event
|
||||
//node.addEventListener('submit', displayOverlay, true);
|
||||
} else {
|
||||
// then hide the button itself
|
||||
locElt.style.display = 'none';
|
||||
}
|
||||
|
||||
bShowHideNextStep = true;
|
||||
}
|
||||
|
||||
taskFrameTimerCounter = taskFrameTimerCounter + 1;
|
||||
// Hide 'Cancel' button on 'Claim' form
|
||||
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
|
||||
if (cancelButton != undefined && !bHideClaimCancelButton) {
|
||||
cancelButton.style.display = 'none';
|
||||
// hides claim button if asked for
|
||||
if (hideClaimButton) {
|
||||
claimButton = locContentDocument.getElementById('form[BTN_CATCH]');
|
||||
claimButton.style.display = 'none';
|
||||
}
|
||||
// to manage Claim
|
||||
var formList = locContentDocument.getElementsByTagName('form');
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
node.setAttribute('actionBackup', node.action);
|
||||
|
||||
if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) // either timeout or hiding is done
|
||||
window.clearInterval(taskFrameTimer);
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
} catch (evt) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
bHideClaimCancelButton = true;
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask);
|
||||
}
|
||||
|
||||
// to force immediate reload of GLPI item form
|
||||
var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD');
|
||||
if (forcedReload != undefined && !GLPI_DURING_RELOAD) {
|
||||
//showMask();
|
||||
GLPI_DURING_RELOAD = true; // to prevent double reload
|
||||
window.clearInterval(taskFrameTimer); // stop timer
|
||||
GLPI_RELOAD_PARENT.location.reload();
|
||||
}
|
||||
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
var redimFrameTimer = window.setInterval(function () {
|
||||
redimTaskFrame(taskFrame, delIndex);
|
||||
}, 1000);
|
||||
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
taskFrameTimerCounter = taskFrameTimerCounter + 1;
|
||||
|
||||
if (taskFrameTimerCounter > 3000 || bShowHideNextStep || bHideClaimCancelButton) { // either timeout or hiding is done
|
||||
window.clearInterval(taskFrameTimer);
|
||||
}
|
||||
|
||||
} catch (evt) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
|
||||
}, 10);
|
||||
|
||||
}
|
||||
|
||||
function redimTaskFrame(taskFrame, delIndex) {
|
||||
var newHeight;
|
||||
try{
|
||||
//var locElt = locContentDocument.getElementsByTagName("table")[0];
|
||||
var locElt = taskFrame.contentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) ;
|
||||
if (newHeight < 500) {
|
||||
newHeight = 500;
|
||||
}
|
||||
var newHeight;
|
||||
try {
|
||||
//var locElt = locContentDocument.getElementsByTagName("table")[0];
|
||||
var locElt = taskFrame.contentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
|
||||
if (newHeight < 500) {
|
||||
newHeight = 500;
|
||||
}
|
||||
|
||||
taskFrame.height = newHeight;
|
||||
} catch (e) {
|
||||
}
|
||||
taskFrame.height = newHeight;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function onTaskFrameActivation(delIndex) {
|
||||
var taskFrameId = "caseiframe-" + delIndex;
|
||||
var taskFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
var taskFrameId = "caseiframe-" + delIndex;
|
||||
var taskFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
|
||||
var taskFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locContentDocument;
|
||||
var taskFrame = document.getElementById(taskFrameId);
|
||||
var taskFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locContentDocument;
|
||||
var taskFrame = document.getElementById(taskFrameId);
|
||||
|
||||
if (taskFrame != undefined && taskFrame.contentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
if (taskFrame != undefined && taskFrame.contentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
locContentDocument = taskFrame.contentDocument;
|
||||
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var newHeight;
|
||||
var locElt = locContentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10) ;
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var newHeight;
|
||||
var locElt = locContentDocument.getElementsByTagName("body")[0];
|
||||
newHeight = parseInt(getComputedStyle(locElt, null).getPropertyValue('height'), 10);
|
||||
|
||||
tabs.getItem('task-' + delIndex).setHeight(newHeight);
|
||||
taskFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
tabs.getItem('task-' + delIndex).setHeight(newHeight);
|
||||
taskFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
taskFrameTimerCounter = taskFrameTimerCounter + 1;
|
||||
taskFrameTimerCounter = taskFrameTimerCounter + 1;
|
||||
|
||||
if (taskFrameTimerCounter > 3000 || redimIFrame) // timeout
|
||||
window.clearInterval(taskFrameTimer);
|
||||
if (taskFrameTimerCounter > 3000 || redimIFrame) { // timeout
|
||||
window.clearInterval(taskFrameTimer);
|
||||
}
|
||||
|
||||
} catch (evt) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
} catch (evt) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
@@ -226,81 +228,79 @@ function clearClass(lociFrame) {
|
||||
}
|
||||
|
||||
function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
|
||||
var otherFrameId = frameName;
|
||||
var otherFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//debugger;
|
||||
if (isMap3 == undefined)
|
||||
isMap3 = false;
|
||||
var otherFrameId = frameName;
|
||||
var otherFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//debugger;
|
||||
if (isMap3 == undefined) {
|
||||
isMap3 = false;
|
||||
}
|
||||
|
||||
var otherFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var otherFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
|
||||
var locContentDocument;
|
||||
var otherFrame = document.getElementById(otherFrameId);
|
||||
var locContentDocument;
|
||||
var otherFrame = document.getElementById(otherFrameId);
|
||||
|
||||
if (otherFrame != undefined && otherFrame.contentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
clearClass(otherFrame);
|
||||
if (otherFrame != undefined && otherFrame.contentDocument != undefined) {
|
||||
// here we've caught the content of the iframe
|
||||
clearClass(otherFrame);
|
||||
|
||||
locContentDocument = otherFrame.contentDocument;
|
||||
locContentDocument = otherFrame.contentDocument;
|
||||
|
||||
// try to redim otherFrame
|
||||
// and tabPanel
|
||||
if (!redimIFrame) {
|
||||
var locElt;
|
||||
// isMap3 == true
|
||||
// map is bpmn
|
||||
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div
|
||||
if (!isMap3) {
|
||||
if (tabPanelName == 'caseMap') {
|
||||
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
|
||||
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
|
||||
locElt2 = locContentDocument.getElementById('pm_target');
|
||||
locElt2.style.height = locElt.clientHeight + 'px';
|
||||
} else {
|
||||
locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
|
||||
}
|
||||
} else {
|
||||
locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0];
|
||||
}
|
||||
if (locElt != undefined) {
|
||||
var newHeight;
|
||||
if (isMap3) {
|
||||
locElt.offsetParent.style.top = 0;
|
||||
locElt.offsetParent.style.width = locElt.offsetWidth + 10 + locElt.offsetLeft + 'px';
|
||||
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
|
||||
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) + locElt.offsetParent.offsetTop + 30;
|
||||
} else {
|
||||
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) ;
|
||||
}
|
||||
if (tabPanelName == 'caseMap') {
|
||||
// trick to force scrollbar to be shown
|
||||
locElt.offsetParent.style.overflow = 'visible';
|
||||
locElt.offsetParent.style.overflow = 'hidden';
|
||||
}
|
||||
if (locElt.scrollHeight && locElt.scrollHeight > newHeight) {
|
||||
newHeight = locElt.scrollHeight;
|
||||
}
|
||||
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
|
||||
otherFrame.height = newHeight ;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
// try to redim otherFrame
|
||||
// and tabPanel
|
||||
if (!redimIFrame) {
|
||||
var locElt;
|
||||
// isMap3 == true
|
||||
// map is bpmn
|
||||
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div
|
||||
if (!isMap3) {
|
||||
if (tabPanelName == 'caseMap') {
|
||||
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
|
||||
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
|
||||
locElt2 = locContentDocument.getElementById('pm_target');
|
||||
locElt2.style.height = locElt.clientHeight + 'px';
|
||||
} else {
|
||||
locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
|
||||
}
|
||||
} else {
|
||||
locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0];
|
||||
}
|
||||
if (locElt != undefined) {
|
||||
var newHeight;
|
||||
if (isMap3) {
|
||||
locElt.offsetParent.style.top = 0;
|
||||
locElt.offsetParent.style.width = locElt.offsetWidth + 10 + locElt.offsetLeft + 'px';
|
||||
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
|
||||
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight) + locElt.offsetParent.offsetTop + 30;
|
||||
} else {
|
||||
newHeight = (locElt.offsetHeight < 500 ? 500 : locElt.offsetHeight);
|
||||
}
|
||||
if (tabPanelName == 'caseMap') {
|
||||
// trick to force scrollbar to be shown
|
||||
locElt.offsetParent.style.overflow = 'visible';
|
||||
locElt.offsetParent.style.overflow = 'hidden';
|
||||
}
|
||||
if (locElt.scrollHeight && locElt.scrollHeight > newHeight) {
|
||||
newHeight = locElt.scrollHeight;
|
||||
}
|
||||
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
|
||||
otherFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
otherFrameTimerCounter = otherFrameTimerCounter + 1;
|
||||
otherFrameTimerCounter = otherFrameTimerCounter + 1;
|
||||
|
||||
if (otherFrameTimerCounter > 3000 || redimIFrame)
|
||||
window.clearInterval(otherFrameTimer);
|
||||
if (otherFrameTimerCounter > 3000 || redimIFrame) {
|
||||
window.clearInterval(otherFrameTimer);
|
||||
}
|
||||
|
||||
} catch (ev) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
} catch (ev) {
|
||||
// nothing to do here for the moment
|
||||
}
|
||||
}, 10);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +1,24 @@
|
||||
<?php
|
||||
// Direct access to file
|
||||
if (strpos($_SERVER['PHP_SELF'],"processmaker/js/helpdesk.public.js.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-type: application/javascript");
|
||||
Html::header_nocache();
|
||||
if (strpos($_SERVER['PHP_SELF'], "processmaker/js/helpdesk.public.js.php")) {
|
||||
$AJAX_INCLUDE = 1;
|
||||
define('GLPI_ROOT', '../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-type: application/javascript");
|
||||
Html::header_nocache();
|
||||
}
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Can not access directly to this file");
|
||||
die("Can not access directly to this file");
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
"; // end of echo
|
||||
|
||||
|
||||
?>
|
||||
@@ -23,7 +23,7 @@
|
||||
</authors>
|
||||
<versions>
|
||||
<version>
|
||||
<num>3.1.2</num>
|
||||
<num>3.1.3</num>
|
||||
<compatibility>9.1</compatibility>
|
||||
</version>
|
||||
</versions>
|
||||
|
||||
173
setup.php
173
setup.php
@@ -3,164 +3,127 @@
|
||||
|
||||
// Init the hooks of the plugins -Needed
|
||||
function plugin_init_processmaker() {
|
||||
global $PLUGIN_HOOKS, $CFG_GLPI;
|
||||
global $PLUGIN_HOOKS, $CFG_GLPI;
|
||||
|
||||
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
|
||||
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
|
||||
|
||||
$plugin = new Plugin();
|
||||
if ($plugin->isInstalled('processmaker')
|
||||
$plugin = new Plugin();
|
||||
if ($plugin->isInstalled('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');
|
||||
Plugin::registerClass('PluginProcessmakerTaskCategory');
|
||||
|
||||
if (Session::haveRight('config', UPDATE)) {
|
||||
Plugin::registerClass('PluginProcessmakerConfig', array('addtabon' => 'Config'));
|
||||
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
|
||||
}
|
||||
if (Session::haveRight('config', UPDATE)) {
|
||||
Plugin::registerClass('PluginProcessmakerConfig', array('addtabon' => 'Config'));
|
||||
$PLUGIN_HOOKS['config_page']['processmaker'] = 'front/config.form.php';
|
||||
}
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerProfile',
|
||||
array('addtabon' => 'Profile'));
|
||||
$PLUGIN_HOOKS['change_profile']['processmaker'] = array('PluginProcessmakerProfile','select');
|
||||
Plugin::registerClass('PluginProcessmakerProfile', array('addtabon' => 'Profile'));
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerProcess_Profile');
|
||||
$PLUGIN_HOOKS['change_profile']['processmaker'] = array('PluginProcessmakerProfile','select');
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerProcess_Profile');
|
||||
|
||||
$PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true;
|
||||
$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['pre_show_item']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
|
||||
|
||||
//$PLUGIN_HOOKS['canedit']['processmaker']
|
||||
//= array('TicketTask' => array('PluginProcessmakerProcessmaker',
|
||||
// 'canedit_item_processmakertickettask'));
|
||||
$PLUGIN_HOOKS['pre_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_tab_processmaker');
|
||||
$PLUGIN_HOOKS['post_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'post_show_tab_processmaker');
|
||||
|
||||
// Display a menu entry ?
|
||||
if (Session::haveRight('config', READ)) {
|
||||
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS['pre_show_item']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_item_processmakerticket');
|
||||
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) );
|
||||
|
||||
$PLUGIN_HOOKS['pre_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'pre_show_tab_processmaker');
|
||||
$PLUGIN_HOOKS['post_show_tab']['processmaker']
|
||||
= array('PluginProcessmakerProcessmaker', 'post_show_tab_processmaker');
|
||||
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
|
||||
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
|
||||
);
|
||||
|
||||
//$PLUGIN_HOOKS['post_show_item']['processmaker']
|
||||
// = array('Ticket' => array('PluginProcessmakerProcessmaker',
|
||||
// 'post_show_item_processmakerticket'));
|
||||
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
|
||||
'Ticket' => 'plugin_pre_item_update_processmaker'
|
||||
);
|
||||
|
||||
// Display a menu entry ?
|
||||
if (Session::haveRight('config', READ) ) {
|
||||
$PLUGIN_HOOKS['menu_toadd']['processmaker'] = array('tools' => 'PluginProcessmakerProcess');
|
||||
}
|
||||
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
|
||||
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction',
|
||||
'TicketTask' => 'plugin_item_update_processmaker_tasks'
|
||||
);
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerProcess', array( 'massiveaction_nodelete_types' => true) ) ;
|
||||
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
|
||||
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker')
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['pre_item_add']['processmaker'] = array(
|
||||
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_pre_item_add_processmaker')
|
||||
$PLUGIN_HOOKS['item_get_datas']['processmaker'] = array(
|
||||
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
|
||||
);
|
||||
|
||||
);
|
||||
$PLUGIN_HOOKS['item_get_pdfdatas']['processmaker'] = array(
|
||||
'PluginPdfTicketTask' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdatas_processmaker')
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
|
||||
'Ticket' => 'plugin_pre_item_update_processmaker'
|
||||
);
|
||||
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
|
||||
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
|
||||
);
|
||||
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
|
||||
'Ticket_User' => 'plugin_item_purge_processmaker'
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
|
||||
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction',
|
||||
'TicketTask' => 'plugin_item_update_processmaker_tasks'
|
||||
);
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'] = array("js/domain.js.php");
|
||||
$url = explode("/", $_SERVER['PHP_SELF']);
|
||||
$pageName = explode("?", array_pop($url));
|
||||
switch ($pageName[0]) {
|
||||
case "tracking.injector.php":
|
||||
case "helpdesk.public.php":
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/helpdesk.public.js.php";
|
||||
break;
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS['item_add']['processmaker'] = array(
|
||||
'Ticket' => array('PluginProcessmakerProcessmaker', 'plugin_item_add_processmaker')
|
||||
);
|
||||
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
|
||||
|
||||
$PLUGIN_HOOKS['item_get_datas']['processmaker'] = array(
|
||||
'NotificationTargetTicket' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_datas_processmaker')
|
||||
);
|
||||
|
||||
$PLUGIN_HOOKS['item_get_pdfdatas']['processmaker'] = array(
|
||||
'PluginPdfTicketTask' => array('PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdatas_processmaker')
|
||||
);
|
||||
|
||||
|
||||
$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = array(
|
||||
'Ticket_User' => 'plugin_pre_item_purge_processmaker'
|
||||
) ;
|
||||
$PLUGIN_HOOKS['item_purge']['processmaker'] = array(
|
||||
'Ticket_User' => 'plugin_item_purge_processmaker'
|
||||
) ;
|
||||
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'] = array("js/domain.js.php");
|
||||
$url = explode("/", $_SERVER['PHP_SELF']);
|
||||
$pageName = explode("?", array_pop($url));
|
||||
switch($pageName[0]) {
|
||||
case "tracking.injector.php":
|
||||
case "helpdesk.public.php":
|
||||
//$plug = new Plugin;
|
||||
//if( !$plug->isActivated('rayusermanagementticket') )
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/helpdesk.public.js.php";
|
||||
break;
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
|
||||
|
||||
//$PLUGIN_HOOKS['planning_populate']['processmaker'] = "plugin_planning_populate_processmaker"; // used for task descriptions
|
||||
$CFG_GLPI['planning_types'][] = 'PluginProcessmakerTask';
|
||||
$PLUGIN_HOOKS['post_init']['processmaker'] = 'plugin_processmaker_post_init';
|
||||
}
|
||||
}
|
||||
|
||||
// Get the name and the version of the plugin - Needed
|
||||
function plugin_version_processmaker(){
|
||||
function plugin_version_processmaker() {
|
||||
global $LANG;
|
||||
|
||||
return array ('name' => 'Process Maker',
|
||||
'version' => '3.1.2',
|
||||
'version' => '3.1.3',
|
||||
'author' => 'Olivier Moron',
|
||||
'homepage' => '',
|
||||
'minGlpiVersion' => '9.1');
|
||||
}
|
||||
|
||||
// Optional : check prerequisites before install : may print errors or add to message after redirect
|
||||
function plugin_processmaker_check_prerequisites(){
|
||||
if (version_compare(GLPI_VERSION,'9.1','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
|
||||
function plugin_processmaker_check_prerequisites() {
|
||||
if (version_compare(GLPI_VERSION, '9.1', 'lt') || version_compare(GLPI_VERSION, '9.2', 'ge')) {
|
||||
echo "This plugin requires GLPI 9.1 or higher";
|
||||
return false;
|
||||
}
|
||||
//$plug = new Plugin ;
|
||||
//if (!$plug->isActivated('mhooks') || version_compare( $plug->fields['version'], '1.2.0', '<')) {
|
||||
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function plugin_processmaker_check_config($verbose = false){
|
||||
// $plug = new Plugin ;
|
||||
// if ($plug->isActivated('mhooks') && version_compare( $plug->fields['version'], '1.2.0', '>=')) {
|
||||
// return true;
|
||||
// }
|
||||
function plugin_processmaker_check_config($verbose = false) {
|
||||
|
||||
// if ($verbose) {
|
||||
// echo "'mhooks 1.2.0' plugin is needed to run 'processmaker' plugin, please add it to your GLPI plugin configuration.";
|
||||
// }
|
||||
|
||||
//return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function plugin_processmaker_haveRight($module,$right) {
|
||||
|
||||
return Session::haveRight("plugin_processmaker_".$module, $right) ;
|
||||
return Session::haveRight("plugin_processmaker_".$module, $right);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user