3.1.1
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<?php
|
||||
//define('DO_NOT_CHECK_HTTP_REFERER', 1);
|
||||
include_once '../../../inc/includes.php';
|
||||
//include_once '../inc/processmaker.class.php' ;
|
||||
//include_once '../inc/case.class.php' ;
|
||||
|
||||
// check if it is from PM pages
|
||||
if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] ) ) {
|
||||
@@ -13,14 +10,12 @@ if( isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUE
|
||||
$myProcessMaker->login( ) ;
|
||||
|
||||
if( isset( $_REQUEST['form'] ) ) {
|
||||
|
||||
$myProcessMaker->derivateCase( $myCase, $_REQUEST); //, $_SERVER['HTTP_COOKIE'] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// Claim task management
|
||||
elseif( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) && isset( $_REQUEST['form']['APP_UID']) ){
|
||||
} elseif ( 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'] ) ) {
|
||||
@@ -32,11 +27,14 @@ elseif( isset( $_REQUEST['form'] ) && isset( $_REQUEST['form']['BTN_CATCH'] ) &&
|
||||
// now manage tasks associated with item
|
||||
$myProcessMaker->claimTask( $myCase->getID(), $_REQUEST['DEL_INDEX'] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// now redirect to item form page
|
||||
//Html::redirect( Toolbox::getItemTypeFormURL($myCase->getField('itemtype')));
|
||||
echo "<html><body><script></script><input id='GLPI_FORCE_RELOAD' type='hidden' value='GLPI_FORCE_RELOAD'/></body></html>" ;
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
echo "<html><body><script>";
|
||||
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>" ;
|
||||
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@ switch( $_POST["action"] ) {
|
||||
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']) ) ;
|
||||
$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...
|
||||
|
||||
@@ -56,6 +56,24 @@ 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
|
||||
@@ -118,6 +136,9 @@ if( GLPI_USE_CSRF_CHECK ) {
|
||||
$data['_glpi_csrf_token'] = Session::getNewCSRFToken() ;
|
||||
}
|
||||
|
||||
$data = array_map('Toolbox::unclean_cross_side_scripting_deep', $data);
|
||||
$data = array_map('stripcslashes_deep', $data);
|
||||
|
||||
// need to add files if some are uploaded
|
||||
$files = array() ;
|
||||
$paths = array() ;
|
||||
|
||||
466
hook.php
466
hook.php
@@ -1,21 +1,21 @@
|
||||
<?php
|
||||
|
||||
include_once 'inc/processmaker.class.php' ;
|
||||
|
||||
|
||||
include_once 'inc/processmaker.class.php';
|
||||
|
||||
function plugin_processmaker_MassiveActions($type) {
|
||||
global $LANG;
|
||||
|
||||
switch ($type) {
|
||||
case 'PluginProcessmakerProcess' :
|
||||
if( plugin_processmaker_haveRight('config', UPDATE ) )
|
||||
if (plugin_processmaker_haveRight('config', UPDATE )) {
|
||||
return array('plugin_processmaker_taskrefresh' => $LANG['processmaker']['config']['refreshtasklist']);
|
||||
break ;
|
||||
}
|
||||
break;
|
||||
case 'PluginProcessmakerProcess_Profile' :
|
||||
if( plugin_processmaker_haveRight('config', UPDATE ) )
|
||||
if (plugin_processmaker_haveRight('config', UPDATE )) {
|
||||
return array('purge' => $LANG['processmaker']['process']['profile']);
|
||||
break ;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return array();
|
||||
@@ -52,7 +52,7 @@ function plugin_processmaker_MassiveActionsProcess($data) {
|
||||
foreach ($data["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
$process = new PluginProcessmakerProcess;
|
||||
$process->refreshTasks( array( 'id' => $key ) ) ;
|
||||
$process->refreshTasks( array( 'id' => $key ) );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ function plugin_processmaker_MassiveActionsProcess($data) {
|
||||
foreach ($data["item"] as $key => $val) {
|
||||
if ($val == 1) {
|
||||
$process_profile = new PluginProcessmakerProcess_Profile;
|
||||
$process_profile->delete( array( 'id' => $key ), true ) ;
|
||||
$process_profile->delete( array( 'id' => $key ), true );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -80,20 +80,18 @@ 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`
|
||||
ADD COLUMN `date_mod` DATETIME NULL DEFAULT NULL AFTER `pm_theme`,
|
||||
ADD COLUMN `comment` TEXT NULL AFTER `date_mod`;
|
||||
RENAME TABLE `glpi_plugin_processmaker_config` TO `glpi_plugin_processmaker_configs`;" ;
|
||||
RENAME TABLE `glpi_plugin_processmaker_config` TO `glpi_plugin_processmaker_configs`;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
else
|
||||
if (!TableExists("glpi_plugin_processmaker_configs")) {
|
||||
} else if (!TableExists("glpi_plugin_processmaker_configs")) {
|
||||
$query = " CREATE TABLE `glpi_plugin_processmaker_configs` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL DEFAULT 'ProcessMaker',
|
||||
`pm_server_URL` VARCHAR(250) NOT NULL DEFAULT 'http://localhost/',
|
||||
`pm_workspace` VARCHAR(50) NOT NULL DEFAULT 'workflow',
|
||||
`pm_admin_user` VARCHAR(255) NULL DEFAULT NULL,
|
||||
@@ -104,9 +102,10 @@ function plugin_processmaker_install() {
|
||||
`users_id` INT(11) NULL DEFAULT NULL,
|
||||
`pm_group_guid` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`comment` TEXT NULL,
|
||||
`pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`pm_dbserver_name` VARCHAR(255) NULL DEFAULT 'localhost',
|
||||
`pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`domain` VARCHAR(50) NULL DEFAULT '',
|
||||
`maintenance` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
@@ -116,15 +115,14 @@ function plugin_processmaker_install() {
|
||||
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
|
||||
|
||||
// ProcessMaker user creation
|
||||
//$user = new User;
|
||||
//$user->add( array( 'name' => 'ProcessMaker', 'realname' => 'Process', 'firstname' => 'Maker') ) ;
|
||||
|
||||
//// ProcessMaker plugin configuration
|
||||
//$DB->query("INSERT INTO glpi_plugin_processmaker_configs ( id, name, users_id) VALUES ( 1, 'Process Maker 1', ".$user->getID()." );" ) or die("error when inserting default config" . $DB->error());
|
||||
//add a default configuration
|
||||
$query = "
|
||||
INSERT INTO `glpi_plugin_processmaker_configs` (`id`) VALUES (1);
|
||||
";
|
||||
$DB->query( $query ) or die("error creating default record in glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
if( !FieldExists("glpi_plugin_processmaker_configs","pm_dbserver_name" ) ) {
|
||||
if (!FieldExists("glpi_plugin_processmaker_configs", "pm_dbserver_name" )) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_group_guid`,
|
||||
ADD COLUMN `pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_name`,
|
||||
@@ -132,36 +130,29 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error adding fields pm_dbserver_name, pm_dbserver_user, pm_dbserver_passwd to glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
if( !FieldExists("glpi_plugin_processmaker_configs","maintenance" ) ) {
|
||||
if (!FieldExists("glpi_plugin_processmaker_configs", "maintenance" )) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `pm_dbserver_passwd`;
|
||||
;";
|
||||
$DB->query($query) or die("error adding field maintenance to glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
if (!FieldExists("glpi_plugin_processmaker_configs", "domain" )) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `domain` VARCHAR(50) NULL DEFAULT '' AFTER `pm_dbserver_passwd`;
|
||||
";
|
||||
$DB->query($query) or die("error adding field domain to glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
if (!FieldExists("glpi_plugin_processmaker_configs", "maintenance" )) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `domain`;
|
||||
;";
|
||||
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
if( !FieldExists("glpi_plugin_processmaker_configs","pm_admin_user" ) ) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
|
||||
ADD COLUMN `pm_admin_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_workspace`,
|
||||
ADD COLUMN `pm_admin_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_admin_user`;
|
||||
";
|
||||
$DB->query($query) or die("error adding fields pm_admin_user and pm_admin_passwd to glpi_plugin_processmaker_configs" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
//if (!TableExists("glpi_plugin_processmaker_profiles")) {
|
||||
// $query = "CREATE TABLE `glpi_plugin_processmaker_profiles` (
|
||||
// `id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
// `profiles_id` INT(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_profiles (id)',
|
||||
// `process_config` CHAR(1) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
|
||||
// PRIMARY KEY (`id`),
|
||||
// INDEX `profiles_id` (`profiles_id`)
|
||||
// )
|
||||
// COLLATE='utf8_unicode_ci'
|
||||
// ENGINE=InnoDB;" ;
|
||||
// $DB->query($query) or die("error creating glpi_plugin_processmaker_profiles" . $DB->error());
|
||||
//}
|
||||
if (TableExists("glpi_plugin_processmaker_profiles")) {
|
||||
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;" ;
|
||||
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
|
||||
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
|
||||
}
|
||||
|
||||
@@ -172,7 +163,7 @@ function plugin_processmaker_install() {
|
||||
`itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket',
|
||||
`case_num` INT(11) NOT NULL,
|
||||
`case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT',
|
||||
`processes_id` INT(11) NULL DEFAULT NULL
|
||||
`processes_id` INT(11) NULL DEFAULT NULL,
|
||||
UNIQUE INDEX `items` (`itemtype`, `items_id`),
|
||||
INDEX `case_status` (`case_status`)
|
||||
)
|
||||
@@ -183,26 +174,26 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_cases" . $DB->error());
|
||||
}
|
||||
|
||||
if(!FieldExists("glpi_plugin_processmaker_cases", "processes_id")){
|
||||
if (!FieldExists("glpi_plugin_processmaker_cases", "processes_id")) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
|
||||
ADD COLUMN `processes_id` INT(11) NULL DEFAULT NULL;
|
||||
";
|
||||
$DB->query($query) or die("error adding column processes_id into glpi_plugin_processmaker_cases" . $DB->error());
|
||||
} else {
|
||||
$flds = $DB::list_fields('glpi_plugin_processmaker_cases') ;
|
||||
if( strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0 ) {
|
||||
$flds = $DB->list_fields('glpi_plugin_processmaker_cases');
|
||||
if (strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0) {
|
||||
// required because autoload doesn't work for unactive plugin'
|
||||
include_once(GLPI_ROOT."/plugins/processmaker/inc/process.class.php");
|
||||
include_once(GLPI_ROOT."/plugins/processmaker/inc/case.class.php");
|
||||
$proc = new PluginProcessmakerProcess ;
|
||||
$proc = new PluginProcessmakerProcess;
|
||||
$case = new PluginProcessmakerCase;
|
||||
foreach($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
|
||||
$proc->getFromDBbyExternalID( $row['processes_id'] ) ;
|
||||
$case->update(array( 'id' => $row['id'], 'processes_id' => $proc->getID() ) ) ;
|
||||
foreach ($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
|
||||
$proc->getFromDBbyExternalID( $row['processes_id'] );
|
||||
$case->update(array( 'id' => $row['id'], 'processes_id' => $proc->getID() ) );
|
||||
}
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
|
||||
CHANGE COLUMN `processes_id` `processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`;
|
||||
" ;
|
||||
";
|
||||
$DB->query($query) or die("error converting column processes_id into INT(11) in glpi_plugin_processmaker_cases" . $DB->error());
|
||||
}
|
||||
}
|
||||
@@ -225,7 +216,6 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_tasks" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_users")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_users` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -241,21 +231,21 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_users" . $DB->error());
|
||||
}
|
||||
|
||||
if( !FieldExists('glpi_plugin_processmaker_users', 'password') ) {
|
||||
if (!FieldExists('glpi_plugin_processmaker_users', 'password')) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
|
||||
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
|
||||
ADD COLUMN `password` VARCHAR(32) NULL DEFAULT NULL AFTER `pm_users_id`,
|
||||
ADD PRIMARY KEY (`id`);
|
||||
" ;
|
||||
";
|
||||
$DB->query($query) or die("error adding column 'password' to glpi_plugin_processmaker_users" . $DB->error());
|
||||
|
||||
// also need to change text of tasks for tasks linked to cases
|
||||
$query = "UPDATE glpi_tickettasks SET content=REPLACE(content,'##_PluginProcessmakerCases\$processmakercases','##_PluginProcessmakerCase\$processmakercases')
|
||||
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'" ;
|
||||
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'";
|
||||
$DB->query($query) or die("error updating TicketTask" . $DB->error());
|
||||
}
|
||||
|
||||
if( FieldExists('glpi_plugin_processmaker_users', 'glpi_users_id') ) {
|
||||
if (FieldExists('glpi_plugin_processmaker_users', 'glpi_users_id')) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
|
||||
ALTER `glpi_users_id` DROP DEFAULT,
|
||||
DROP PRIMARY KEY,
|
||||
@@ -271,7 +261,6 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error renaming 'glpi_users_id' into 'id' to glpi_plugin_processmaker_users" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_processes")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_processes` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -281,7 +270,7 @@ function plugin_processmaker_install() {
|
||||
`hide_case_num_title` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`insert_task_comment` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`comment` TEXT NULL,
|
||||
`task_category_id` INT(11) NULL ,
|
||||
`taskcategories_id` INT(11) NULL ,
|
||||
`itilcategories_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets',
|
||||
`date_mod` DATETIME NULL DEFAULT NULL,
|
||||
@@ -296,23 +285,23 @@ function plugin_processmaker_install() {
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_processes" . $DB->error());
|
||||
}
|
||||
|
||||
if( FieldExists( 'glpi_plugin_processmaker_processes', 'is_helpdeskvisible') ) {
|
||||
if (FieldExists( 'glpi_plugin_processmaker_processes', 'is_helpdeskvisible')) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
CHANGE COLUMN `is_helpdeskvisible` `is_helpdeskvisible_notusedanymore` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Not used any more since version 2.2' AFTER `name`;" ;
|
||||
$DB->query($query) ;
|
||||
CHANGE COLUMN `is_helpdeskvisible` `is_helpdeskvisible_notusedanymore` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Not used any more since version 2.2' AFTER `name`;";
|
||||
$DB->query($query);
|
||||
}
|
||||
|
||||
if( !FieldExists( 'glpi_plugin_processmaker_processes', 'itilcategories_id') ) {
|
||||
if (!FieldExists( 'glpi_plugin_processmaker_processes', 'itilcategories_id')) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `itilcategories_id` INT(11) NOT NULL DEFAULT '0',
|
||||
ADD COLUMN `type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets';" ;
|
||||
ADD COLUMN `type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets';";
|
||||
|
||||
$DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error());
|
||||
}
|
||||
|
||||
if( !FieldExists( 'glpi_plugin_processmaker_processes', 'project_type') ) {
|
||||
if (!FieldExists( 'glpi_plugin_processmaker_processes', 'project_type')) {
|
||||
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
|
||||
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';" ;
|
||||
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';";
|
||||
|
||||
$DB->query($query) or die("error adding columns 'project_type' to glpi_plugin_processmaker_processes" . $DB->error());
|
||||
}
|
||||
@@ -332,12 +321,11 @@ function plugin_processmaker_install() {
|
||||
INDEX `is_recursive` (`is_recursive`)
|
||||
)
|
||||
COLLATE='utf8_unicode_ci'
|
||||
ENGINE=InnoDB;" ;
|
||||
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,
|
||||
@@ -359,21 +347,6 @@ function plugin_processmaker_install() {
|
||||
|
||||
}
|
||||
|
||||
//// create default TaskCategory if needed
|
||||
//// verify if taskcategory_id is set in config
|
||||
//// required cause autoload don't work for unactive plugin'
|
||||
//include_once(GLPI_ROOT."/plugins/processmaker/inc/config.class.php");
|
||||
//$config = new PluginProcessmakerConfig ;
|
||||
//$config->getFromDB( 1 ) ;
|
||||
//$pmCategory = $config->fields['taskcategories_id'] ;
|
||||
//if( !$pmCategory ) {
|
||||
// // add main category into config and glpi_taskcategories
|
||||
// $taskCat = new TaskCategory;
|
||||
// $pmCategory = $taskCat->add( array( 'is_recursive' => 1, 'name' => 'Process Maker', 'comment' => 'Is top category for Process Maker tasks. Name can be changed if desired.' ) ) ;
|
||||
// if( $pmCategory )
|
||||
// $config->update( array( 'id' => $config->getID(), 'taskcategories_id' => $pmCategory ) ) ;
|
||||
//}
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_crontaskactions")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_crontaskactions` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -388,7 +361,7 @@ function plugin_processmaker_install() {
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;" ;
|
||||
ENGINE=InnoDB;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_crontaskactions" . $DB->error());
|
||||
}
|
||||
|
||||
@@ -413,11 +386,10 @@ function plugin_processmaker_install() {
|
||||
INDEX `is_self` (`is_self`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;" ;
|
||||
ENGINE=InnoDB;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_caselinks" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
if (!TableExists("glpi_plugin_processmaker_caselinkactions")) {
|
||||
$query = "CREATE TABLE `glpi_plugin_processmaker_caselinkactions` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -429,24 +401,25 @@ function plugin_processmaker_install() {
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;" ;
|
||||
;";
|
||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_caselinkactions" . $DB->error());
|
||||
}
|
||||
|
||||
|
||||
// no longer used since 2.6
|
||||
//$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
//$myProcessMaker->login(true) ; // to force admin login
|
||||
|
||||
//// verify if group 'GLPI Requesters' exists in config, if not will create it in PM and add GUID in config
|
||||
//$pmGroup = $config->fields['pm_group_guid'] ;
|
||||
//if( !$pmGroup ) {
|
||||
// $pmres = $myProcessMaker->createGroup( "GLPI Users" ) ;
|
||||
// if( $pmres->status_code == 0 )
|
||||
// $config->update( array( 'id' => $config->getID(), 'pm_group_guid' => $pmres->groupUID ) ) ;
|
||||
//if( !TableExists('glpi_plugin_processmaker_selfservicedrafts')){
|
||||
// $query = "CREATE TABLE `glpi_plugin_processmaker_selfservicedrafts` (
|
||||
// `id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
// `users_id` INT(11) NOT NULL,
|
||||
// `plugin_processmaker_processes_id` INT(11) NOT NULL,
|
||||
// `url` TEXT NOT NULL,
|
||||
// PRIMARY KEY (`id`),
|
||||
// INDEX `users_id` (`users_id`)
|
||||
// )
|
||||
// COLLATE='utf8_general_ci'
|
||||
// ENGINE=InnoDB
|
||||
// ;" ;
|
||||
// $DB->query($query) or die("error creating glpi_plugin_processmaker_selfservicedrafts" . $DB->error());
|
||||
//}
|
||||
|
||||
|
||||
// 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));
|
||||
@@ -454,34 +427,18 @@ function plugin_processmaker_install() {
|
||||
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']);
|
||||
|
||||
// since version 3.0
|
||||
// needs to update rights values
|
||||
// 'r' -> READ
|
||||
// 'w' -> UPDATE
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// to migrate rights!!!!
|
||||
// TODO
|
||||
//$query = "UPDATE glpi_plugin_processmaker_profiles SET process_config=".READ." WHERE process_config='r';" ;
|
||||
//$DB->query($query) or die("error updating profiles" . $DB->error());
|
||||
//$query = "UPDATE glpi_plugin_processmaker_profiles SET process_config=".UPDATE." WHERE process_config='w';" ;
|
||||
//$DB->query($query) or die("error updating profiles" . $DB->error());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function plugin_processmaker_uninstall() {
|
||||
global $DB;
|
||||
|
||||
|
||||
CronTask::Unregister('PluginProcessmakerProcessmaker');
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -497,7 +454,7 @@ function plugin_processmaker_getAddSearchOptions($itemtype) {
|
||||
$sopt[10001]['massiveaction'] = false;
|
||||
$sopt[10001]['name'] = $LANG['processmaker']['search']['case'].' - '.$LANG['processmaker']['search']['status'];
|
||||
$sopt[10001]['datatype'] = 'text';
|
||||
$sopt[10001]['forcegroupby'] = true ;
|
||||
$sopt[10001]['forcegroupby'] = true;
|
||||
//$sopt[10001]['searchtype'] = 'equals';
|
||||
|
||||
//$sopt[1001]['itemlink_type'] = 'PluginProcessmakerTicketcase';
|
||||
@@ -513,8 +470,6 @@ function plugin_processmaker_getAddSearchOptions($itemtype) {
|
||||
// => array('table' => 'glpi_plugin_processmaker_ticketcase',
|
||||
// 'linkfield' => 'ticket_id'));
|
||||
|
||||
|
||||
|
||||
//$sopt[1001]['joinparams']['jointype'] = "itemtype_id";
|
||||
//$sopt[1001]['pfields_type'] = ;
|
||||
}
|
||||
@@ -523,10 +478,10 @@ function plugin_processmaker_getAddSearchOptions($itemtype) {
|
||||
|
||||
function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,&$already_link_tables) {
|
||||
|
||||
switch ($type){
|
||||
switch ($type) {
|
||||
|
||||
case 'Ticket':
|
||||
switch ($new_table){
|
||||
switch ($new_table) {
|
||||
|
||||
case "glpi_plugin_processmaker_cases" :
|
||||
$out= " LEFT JOIN `glpi_plugin_processmaker_cases`
|
||||
@@ -544,144 +499,146 @@ function plugin_processmaker_addLeftJoin($type,$ref_table,$new_table,$linkfield,
|
||||
|
||||
/**
|
||||
* Summary of plugin_pre_item_update_processmaker
|
||||
* @param CommonITILObject $parm
|
||||
* @param CommonITILObject $parm is an object
|
||||
* @return void
|
||||
*/
|
||||
function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
|
||||
global $DB ;
|
||||
global $DB;
|
||||
|
||||
if( isset($_SESSION['glpiname']) && $parm->getType() == 'Ticket' ) {
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
if (isset($_SESSION['glpiname']) && $parm->getType() == 'Ticket') {
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
|
||||
$itemId = $parm->getID() ;
|
||||
$itemType = $parm->getType() ;
|
||||
$itemId = $parm->getID();
|
||||
$itemType = $parm->getType();
|
||||
|
||||
if( $locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId ) ) {
|
||||
$locPM = new PluginProcessmakerProcessmaker ;
|
||||
$locPM->login() ;
|
||||
if ($locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId )) {
|
||||
$locPM = new PluginProcessmakerProcessmaker;
|
||||
$locPM->login();
|
||||
|
||||
// case is existing for this item
|
||||
// $technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
|
||||
|
||||
// beware to empty injection when not modified!!!
|
||||
$locVar = array( ) ;
|
||||
foreach( $parm->input as $key => $val ) {
|
||||
switch( $key ) {
|
||||
$locVar = array( );
|
||||
foreach ($parm->input as $key => $val) {
|
||||
switch ($key) {
|
||||
case 'global_validation' :
|
||||
$locVar[ 'GLPI_TICKET_GLOBAL_VALIDATION' ] = $val ;
|
||||
$locVar[ 'GLPI_TICKET_GLOBAL_VALIDATION' ] = $val;
|
||||
break;
|
||||
case 'itilcategories_id' :
|
||||
$locVar[ 'GLPI_ITEM_ITIL_CATEGORY_ID' ] = $val ;
|
||||
$locVar[ 'GLPI_ITEM_ITIL_CATEGORY_ID' ] = $val;
|
||||
break;
|
||||
case 'due_date' :
|
||||
$locVar[ 'GLPI_TICKET_DUE_DATE' ] = $val ;
|
||||
$locVar[ 'GLPI_TICKET_DUE_DATE' ] = $val;
|
||||
break;
|
||||
case 'urgency' :
|
||||
$locVar[ 'GLPI_TICKET_URGENCY' ] = $val ;
|
||||
$locVar[ 'GLPI_TICKET_URGENCY' ] = $val;
|
||||
break;
|
||||
case 'impact' :
|
||||
$locVar[ 'GLPI_ITEM_IMPACT' ] = $val ;
|
||||
$locVar[ 'GLPI_ITEM_IMPACT' ] = $val;
|
||||
break;
|
||||
case 'priority' :
|
||||
$locVar[ 'GLPI_ITEM_PRIORITY' ] = $val ;
|
||||
$locVar[ 'GLPI_ITEM_PRIORITY' ] = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// $locVar['GLPI_TICKET_TECHNICIAN_GLPI_ID']=$technicians[0]['glpi_id'];
|
||||
// $locVar['GLPI_TICKET_TECHNICIAN_PM_ID']=$technicians[0]['pm_id'];
|
||||
|
||||
$pmResponse = $locPM->sendVariables( $locCase->getID(), $locVar) ;
|
||||
//$locCase->sendVariables( $locVar ) ;
|
||||
$pmResponse = $locPM->sendVariables( $locCase->getID(), $locVar);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of plugin_item_update_processmaker_satisfaction
|
||||
* inject satisfaction survey into case
|
||||
* @param mixed $parm is the object
|
||||
*/
|
||||
function plugin_item_update_processmaker_satisfaction($parm) {
|
||||
global $DB, $GLOBALS ;
|
||||
global $DB, $GLOBALS;
|
||||
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
if( $locCase->getCaseFromItemTypeAndItemId( 'Ticket', $parm->fields['tickets_id'] ) ) {
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
if ($locCase->getCaseFromItemTypeAndItemId( 'Ticket', $parm->fields['tickets_id'] )) {
|
||||
// case is existing for this item
|
||||
|
||||
|
||||
|
||||
$locPM = new PluginProcessmakerProcessmaker ;
|
||||
$locPM->login() ;
|
||||
$locPM = new PluginProcessmakerProcessmaker;
|
||||
$locPM->login();
|
||||
|
||||
$pmResponse = $locPM->sendVariables( $locCase->getID(), array(
|
||||
'GLPI_SATISFACTION_QUALITY' => $parm->fields['satisfaction'],
|
||||
'GLPI_SATISFACTION_RESPONSETIME' => $parm->fields['responsetime'],
|
||||
'GLPI_SATISFACTION_FRIENDLINESS' => $parm->fields['friendliness']
|
||||
)) ;
|
||||
'GLPI_SATISFACTION_QUALITY' => $parm->fields['satisfaction']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function plugin_pre_item_update_processmaker_followup($parm) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of plugin_pre_item_purge_processmaker
|
||||
* @param mixed $parm is the object
|
||||
*/
|
||||
function plugin_pre_item_purge_processmaker ( $parm ) {
|
||||
|
||||
if( $parm->getType() == 'Ticket_User' && is_array( $parm->fields ) && isset( $parm->fields['type'] ) && $parm->fields['type'] == 2 ) {
|
||||
$itemId = $parm->fields['tickets_id'] ;
|
||||
$itemType = 'Ticket' ;
|
||||
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
|
||||
if ($parm->getType() == 'Ticket_User' && is_array( $parm->fields ) && isset( $parm->fields['type'] ) && $parm->fields['type'] == 2) {
|
||||
$itemId = $parm->fields['tickets_id'];
|
||||
$itemType = 'Ticket';
|
||||
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ); // 2 for technicians
|
||||
|
||||
if( PluginProcessmakerCase::getCaseIdFromItemTypeAndItemId( $itemType, $itemId ) && count($technicians) == 1 ) {
|
||||
$parm->input = null ; // to cancel deletion of the last tech in the ticket
|
||||
if (PluginProcessmakerCase::getCaseIdFromItemTypeAndItemId( $itemType, $itemId ) && count($technicians) == 1) {
|
||||
$parm->input = null; // to cancel deletion of the last tech in the ticket
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of plugin_item_purge_processmaker
|
||||
* @param mixed $parm is the object
|
||||
*/
|
||||
function plugin_item_purge_processmaker($parm) {
|
||||
global $DB ;
|
||||
global $DB;
|
||||
|
||||
if( $parm->getType() == 'Ticket_User' && is_array( $parm->fields ) && isset( $parm->fields['type'] ) && $parm->fields['type'] == 2 ) {
|
||||
if ($parm->getType() == 'Ticket_User' && is_array( $parm->fields ) && isset( $parm->fields['type'] ) && $parm->fields['type'] == 2) {
|
||||
|
||||
// We just deleted a tech from this ticket then we must if needed "de-assign" the tasks assigned to this tech
|
||||
// and re-assign them to the first tech in the list !!!!
|
||||
|
||||
$locCase = new PluginProcessmakerCase ;
|
||||
$locCase = new PluginProcessmakerCase;
|
||||
|
||||
$itemId = $parm->fields['tickets_id'] ;
|
||||
$itemType = 'Ticket' ;
|
||||
$itemId = $parm->fields['tickets_id'];
|
||||
$itemType = 'Ticket';
|
||||
|
||||
if( $locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId ) ) {
|
||||
if ($locCase->getCaseFromItemTypeAndItemId( $itemType, $itemId )) {
|
||||
// case is existing for this item
|
||||
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ) ; // 2 for technicians
|
||||
$locPM = new PluginProcessmakerProcessmaker ;
|
||||
$locPM->login() ;
|
||||
$technicians = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $itemId, 2 ); // 2 for technicians
|
||||
$locPM = new PluginProcessmakerProcessmaker;
|
||||
$locPM->login();
|
||||
$locVars = array( 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'],
|
||||
'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id'] ) ;
|
||||
'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id'] );
|
||||
|
||||
// and we must find all tasks assigned to this former user and re-assigned them to new user (if any :))!
|
||||
$caseInfo = $locPM->getCaseInfo( $locCase->getID() ) ;
|
||||
if( $caseInfo !== false ){
|
||||
$locPM->sendVariables( $locCase->getID( ), $locVars ) ;
|
||||
$caseInfo = $locPM->getCaseInfo( $locCase->getID() );
|
||||
if ($caseInfo !== false) {
|
||||
$locPM->sendVariables( $locCase->getID( ), $locVars );
|
||||
// need to get info on the thread of the GLPI current user
|
||||
// we must retreive currentGLPI user from this array
|
||||
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( $parm->fields['users_id'] ) ;
|
||||
foreach( $caseInfo->currentUsers as $caseUser) {
|
||||
if( $caseUser->userId == $GLPICurrentPMUserId && in_array( $caseUser->delThreadStatus, array('DRAFT', 'OPEN', 'PAUSE' ) ) ){
|
||||
$pmResponse = $locPM->reassignCase( $locCase->getID(), $caseUser->delIndex, $GLPICurrentPMUserId, $technicians[0]['pm_id'] ) ;
|
||||
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId( $parm->fields['users_id'] );
|
||||
if (isset( $caseInfo->currentUsers ) && is_array( $caseInfo->currentUsers )) {
|
||||
foreach ($caseInfo->currentUsers as $caseUser) {
|
||||
if ($caseUser->userId == $GLPICurrentPMUserId && in_array( $caseUser->delThreadStatus, array('DRAFT', 'OPEN', 'PAUSE' ) )) {
|
||||
$pmResponse = $locPM->reassignCase( $locCase->getID(), $caseUser->delIndex, $GLPICurrentPMUserId, $technicians[0]['pm_id'] );
|
||||
// now should managed GLPI Tasks previously assigned to the $GLPICurrentPMUserId
|
||||
if( $pmResponse->status_code == 0 ) {
|
||||
if ($pmResponse->status_code == 0) {
|
||||
// ATTENTION: should be aware of: ticket tech == task tech
|
||||
// In this particular flow due to 'Change Management'
|
||||
|
||||
// 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( $locCase->getID() ) ;
|
||||
$newDelIndex = 0 ;
|
||||
foreach( $newCaseInfo->currentUsers as $newCaseUser ){
|
||||
if( $newCaseUser->taskId == $caseUser->taskId && $newCaseUser->delThread == $caseUser->delThread ) {
|
||||
$newDelIndex = $newCaseUser->delIndex ;
|
||||
break ;
|
||||
$newCaseInfo = $locPM->getCaseInfo( $locCase->getID() );
|
||||
$newDelIndex = 0;
|
||||
foreach ($newCaseInfo->currentUsers as $newCaseUser) {
|
||||
if ($newCaseUser->taskId == $caseUser->taskId && $newCaseUser->delThread == $caseUser->delThread) {
|
||||
$newDelIndex = $newCaseUser->delIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$locPM->reassignTask( $locCase->getID(), $caseUser->delIndex, $newDelIndex, $technicians[0]['glpi_id'] ) ;
|
||||
$locPM->reassignTask( $locCase->getID(), $caseUser->delIndex, $newDelIndex, $technicians[0]['glpi_id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -691,15 +648,15 @@ function plugin_item_purge_processmaker($parm) {
|
||||
}
|
||||
}
|
||||
|
||||
function plugin_processmaker_post_init(){
|
||||
global $PM_DB ;
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
function plugin_processmaker_post_init() {
|
||||
global $PM_DB;
|
||||
$PM_DB = new PluginProcessmakerDB;
|
||||
}
|
||||
|
||||
|
||||
function plugin_processmaker_giveItem($itemtype,$ID,$data,$num){
|
||||
function plugin_processmaker_giveItem($itemtype,$ID,$data,$num) {
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -707,13 +664,13 @@ function plugin_processmaker_giveItem($itemtype,$ID,$data,$num){
|
||||
* Summary of plugin_item_add_update_processmaker_tasks
|
||||
* @param mixed $parm
|
||||
*/
|
||||
function plugin_item_update_processmaker_tasks($parm){
|
||||
function plugin_item_update_processmaker_tasks($parm) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
// we need to test if a specific case is completed, and if so
|
||||
// we should complete the linked cases (via linked tickets)
|
||||
$pmTaskCat = new PluginProcessmakerTaskCategory ;
|
||||
if( $pmTaskCat->getFromDBbyCategory( $parm->fields['taskcategories_id'] )
|
||||
$pmTaskCat = new PluginProcessmakerTaskCategory;
|
||||
if ($pmTaskCat->getFromDBbyCategory( $parm->fields['taskcategories_id'] )
|
||||
&& in_array( 'state', $parm->updates )
|
||||
&& $parm->input['state'] == 2) { // the task has just been set to DONE state
|
||||
|
||||
@@ -726,86 +683,86 @@ function plugin_item_update_processmaker_tasks($parm){
|
||||
// 'targetactions' => array( 'RELEASE_DONE' => '@@RELEASE_DONE' )
|
||||
// ) ) ;
|
||||
|
||||
$itemtype = str_replace( 'Task', '', $parm->getType() ) ;
|
||||
$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 ) {
|
||||
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']) ;
|
||||
$srcCaseId = PluginProcessmakerProcessmaker::getCaseIdFromItem( $itemtype, $parm->fields['tickets_id']);
|
||||
|
||||
// Must check the condition
|
||||
$casevariables = array();
|
||||
$matches = array() ;
|
||||
if( preg_match_all( "/@@(\w+)/u", $targetTask['sourcecondition'], $matches ) ) {
|
||||
$casevariables = $matches[1] ;
|
||||
|
||||
$matches = array();
|
||||
if (preg_match_all( "/@@(\w+)/u", $targetTask['sourcecondition'], $matches )) {
|
||||
$casevariables = $matches[1];
|
||||
}
|
||||
//foreach( $targetTask['targetactions'] as $actionvalue ){
|
||||
foreach( $DB->request( 'glpi_plugin_processmaker_caselinkactions', 'plugin_processmaker_caselinks_id = '.$targetTask['id']) 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'];
|
||||
if( preg_match_all( "/@@(\w+)/u", $actionvalue['value'], $matches ) ) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] ) ;
|
||||
if (preg_match_all( "/@@(\w+)/u", $actionvalue['value'], $matches )) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] );
|
||||
}
|
||||
}
|
||||
$externalapplication = false ; // by default
|
||||
if( $targetTask['is_externaldata'] && isset($targetTask['externalapplication']) ) {
|
||||
$externalapplication = false; // by default
|
||||
if ($targetTask['is_externaldata'] && isset($targetTask['externalapplication'])) {
|
||||
// must read some values
|
||||
$externalapplication = json_decode( $targetTask['externalapplication'], true ) ;
|
||||
$externalapplication = json_decode( $targetTask['externalapplication'], true );
|
||||
// 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, ... method
|
||||
// url is the URL to be called
|
||||
// params is a list of parameters to get from running case
|
||||
foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
if( preg_match_all( "/@@(\w+)/u", $variable, $matches ) ) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] ) ;
|
||||
foreach ($externalapplication['params'] as $paramname => $variable) {
|
||||
if (preg_match_all( "/@@(\w+)/u", $variable, $matches )) {
|
||||
$casevariables = array_merge( $casevariables, $matches[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ask for those case variables
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker() ;
|
||||
$myProcessMaker->login( ) ;
|
||||
$myProcessMaker = new PluginProcessmakerProcessmaker();
|
||||
$myProcessMaker->login( );
|
||||
// now tries to get the variables to check condition
|
||||
$infoForTasks = $myProcessMaker->getVariables( $srcCaseId, $casevariables );
|
||||
foreach($infoForTasks as $casevar => $varval ){
|
||||
$infoForTasks[ "@@$casevar" ] = "'$varval'" ;
|
||||
unset( $infoForTasks[ $casevar ] ) ;
|
||||
foreach ($infoForTasks as $casevar => $varval) {
|
||||
$infoForTasks[ "@@$casevar" ] = "'$varval'";
|
||||
unset( $infoForTasks[ $casevar ] );
|
||||
}
|
||||
$targetTask['sourcecondition'] = str_replace( array_keys($infoForTasks), $infoForTasks, $targetTask['sourcecondition'] ) ;
|
||||
$targetTask['sourcecondition'] = str_replace( array_keys($infoForTasks), $infoForTasks, $targetTask['sourcecondition'] );
|
||||
|
||||
|
||||
if( eval( "return ".$targetTask['sourcecondition'].";" ) ){
|
||||
if (eval( "return ".$targetTask['sourcecondition'].";" )) {
|
||||
// look at each linked ticket if a case is attached and then if a task like $val is TO_DO
|
||||
// then will try to routeCase for each tasks in $val
|
||||
|
||||
$postdatas = array();
|
||||
foreach( $targetTask['targetactions'] as $action => $actionvalue) {
|
||||
$postdatas['form'][$action] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $actionvalue)." ;" ) ;
|
||||
foreach ($targetTask['targetactions'] as $action => $actionvalue) {
|
||||
$postdatas['form'][$action] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $actionvalue)." ;" );
|
||||
}
|
||||
$postdatas['UID'] = $targetTask['targetdynaform_guid'];
|
||||
$postdatas['__DynaformName__'] = $targetTask['targetprocess_guid']."_".$targetTask['targetdynaform_guid'] ;
|
||||
$postdatas['__DynaformName__'] = $targetTask['targetprocess_guid']."_".$targetTask['targetdynaform_guid'];
|
||||
$postdatas['__notValidateThisFields__'] = '[]';
|
||||
$postdatas['DynaformRequiredFields'] = '[]';
|
||||
$postdatas['form']['btnGLPISendRequest'] = 'submit' ;
|
||||
$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 ) {
|
||||
$externalapplicationparams = array();
|
||||
if ($externalapplication) {
|
||||
// must call curl
|
||||
foreach ( $externalapplication['params'] as $paramname => $variable ) {
|
||||
$externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" ) ;
|
||||
foreach ($externalapplication['params'] as $paramname => $variable) {
|
||||
$externalapplicationparams[$paramname] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $variable)." ;" );
|
||||
}
|
||||
$externalapplicationparams['callback']=$CFG_GLPI['root_doc']."/plugins/processmaker/ajax/asynchronousdatas.php";
|
||||
$externalapplicationparams['callback']="http://".$_SERVER['SERVER_NAME' ].$CFG_GLPI['root_doc']."/plugins/processmaker/ajax/asynchronousdatas.php";
|
||||
$ch = curl_init();
|
||||
$externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ) ; // '???
|
||||
$externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ); // '???
|
||||
curl_setopt($ch, CURLOPT_URL, $externalapplication['url'] );
|
||||
}
|
||||
|
||||
if( $targetTask['is_self'] ) {
|
||||
if ($targetTask['is_self']) {
|
||||
// MUST BE done on a add task hook, and not on an update task hook
|
||||
|
||||
//$query = "SELECT glpi_plugin_processmaker_cases.id, MAX(glpi_plugin_processmaker_tasks.del_index) AS del_index FROM glpi_tickettasks
|
||||
@@ -817,18 +774,19 @@ function plugin_item_update_processmaker_tasks($parm){
|
||||
//$res = $DB->query($query) ;
|
||||
//if( $res && $DB->numrows($res) > 0 && $case=$DB->fetch_assoc($res) && isset($case['id']) && isset($case['del_index']) ) {
|
||||
//foreach( $DB->request($query) as $case ) {
|
||||
$taskCase = $myProcessMaker->taskCase( $srcCaseId ) ;
|
||||
foreach( $taskCase as $task ) {
|
||||
$taskCase = $myProcessMaker->taskCase( $srcCaseId );
|
||||
foreach ($taskCase as $task) {
|
||||
// search for target task guid
|
||||
if( $task->guid == $targetTask['targettask_guid'] )
|
||||
break ;
|
||||
if ($task->guid == $targetTask['targettask_guid']) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$postdatas['APP_UID'] = $srcCaseId;
|
||||
$postdatas['DEL_INDEX'] = $task->delegate;
|
||||
|
||||
//need to get the 'ProcessMaker' user
|
||||
$pmconfig = PluginProcessmakerConfig::getInstance() ;
|
||||
$pmconfig = PluginProcessmakerConfig::getInstance();
|
||||
|
||||
$cronaction = new PluginProcessmakerCrontaskaction;
|
||||
$cronaction->add( array( 'plugin_processmaker_caselinks_id' => $targetTask['id'],
|
||||
@@ -840,15 +798,15 @@ function plugin_item_update_processmaker_tasks($parm){
|
||||
'postdatas' => json_encode( $postdatas, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
),
|
||||
null,
|
||||
false) ;
|
||||
false);
|
||||
|
||||
if( $externalapplication ) {
|
||||
if ($externalapplication) {
|
||||
// must call external application in order to get the needed data asynchroneously
|
||||
// must be of the form
|
||||
// {"url":"http://arsupd201.ar.ray.group:8000/search_by_userid/","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}}
|
||||
// url is the URL to be called
|
||||
|
||||
$externalapplicationparams['record_id'] = $cronaction->getID();
|
||||
$externalapplicationparams['id'] = $cronaction->getID();
|
||||
|
||||
$externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT);
|
||||
//$externalapplicationparams = http_formdata_flat_hierarchy( $externalapplicationparams ) ;
|
||||
@@ -856,21 +814,27 @@ function plugin_item_update_processmaker_tasks($parm){
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($externalapplicationparams)));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
|
||||
// curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
|
||||
// curl_setopt($ch, CURLOPT_PROXY, "fry07689.fr.ray.group:8888");
|
||||
|
||||
$response = curl_exec ($ch);
|
||||
|
||||
//Toolbox::logDebug( $response ) ;
|
||||
|
||||
curl_close ($ch);
|
||||
}
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
foreach( Ticket_Ticket::getLinkedTicketsTo( $parm->fields['tickets_id'] ) as $tlink ){
|
||||
if( $tlink['link'] == Ticket_Ticket::LINK_TO ) {
|
||||
foreach (Ticket_Ticket::getLinkedTicketsTo( $parm->fields['tickets_id'] ) as $tlink) {
|
||||
if ($tlink['link'] == Ticket_Ticket::LINK_TO) {
|
||||
$query = "SELECT glpi_plugin_processmaker_cases.id, MAX(glpi_plugin_processmaker_tasks.del_index) AS del_index FROM glpi_tickettasks
|
||||
JOIN glpi_plugin_processmaker_taskcategories ON glpi_plugin_processmaker_taskcategories.taskcategories_id=glpi_tickettasks.taskcategories_id
|
||||
JOIN glpi_plugin_processmaker_cases ON glpi_plugin_processmaker_cases.processes_id=glpi_plugin_processmaker_taskcategories.processes_id
|
||||
RIGHT JOIN glpi_plugin_processmaker_tasks ON glpi_plugin_processmaker_tasks.items_id=glpi_tickettasks.id AND glpi_plugin_processmaker_tasks.case_id=glpi_plugin_processmaker_cases.id
|
||||
WHERE glpi_plugin_processmaker_taskcategories.pm_task_guid = '".$targetTask['targettask_guid']."' AND glpi_tickettasks.state = 1 AND glpi_tickettasks.tickets_id=".$tlink['tickets_id'] ;
|
||||
foreach( $DB->request($query) as $case ) {
|
||||
WHERE glpi_plugin_processmaker_taskcategories.pm_task_guid = '".$targetTask['targettask_guid']."' AND glpi_tickettasks.state = 1 AND glpi_tickettasks.tickets_id=".$tlink['tickets_id'];
|
||||
foreach ($DB->request($query) as $case) {
|
||||
// must be only one row
|
||||
|
||||
$postdatas['APP_UID'] = $case['id'];
|
||||
@@ -886,7 +850,7 @@ function plugin_item_update_processmaker_tasks($parm){
|
||||
'postdatas' => json_encode( $postdatas, JSON_HEX_APOS | JSON_HEX_QUOT)
|
||||
),
|
||||
null,
|
||||
false) ;
|
||||
false);
|
||||
}
|
||||
//if( $externalapplication ) {
|
||||
// // must call external application in order to get the needed data asynchroneously
|
||||
|
||||
@@ -330,17 +330,11 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
// normally there is only one task
|
||||
$task = getItemForItemtype( $row['itemtype'] ) ;
|
||||
$task->getFromDB( $row['items_id'] ) ;
|
||||
$user = new User; // pseudo-group
|
||||
$user->getFromDB( $task->fields['users_id_tech'] ) ;
|
||||
// check if this pseudo-group can be found in the current user's groups
|
||||
foreach($DB->request("SELECT id FROM ".getTableForItemType( 'Group' )." WHERE name = '".$user->fields['name']."'") as $grp ){
|
||||
// normally there is only one record
|
||||
if( isset($_SESSION['glpigroups']) && !in_array( $grp['id'], $_SESSION['glpigroups'] ) ) {
|
||||
// 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'
|
||||
|
||||
@@ -53,6 +53,7 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
* @return array the modified $input array
|
||||
**/
|
||||
function prepareInputForUpdate($input) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if( !isset($input["maintenance"]) ) {
|
||||
$input["maintenance"] = 0 ;
|
||||
@@ -82,10 +83,40 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
$input['pm_admin_passwd'] = '';
|
||||
}
|
||||
|
||||
$input['domain'] = self::getCommonDomain( $CFG_GLPI['url_base'], $input['pm_server_URL'] ) ;
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of getCommonDomain
|
||||
* @param mixed $url1
|
||||
* @param mixed $url2
|
||||
* @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_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 ;
|
||||
}
|
||||
} catch(Exception $e) {}
|
||||
return '';
|
||||
}
|
||||
|
||||
static function showConfigForm($item) {
|
||||
global $LANG, $PM_DB;
|
||||
global $LANG, $PM_DB, $CFG_GLPI;
|
||||
|
||||
$ui_theme = array(
|
||||
'glpi_classic' => 'glpi_classic',
|
||||
@@ -101,6 +132,38 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
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 Html::scriptBlock("
|
||||
function setCommonDomain() {
|
||||
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() ;
|
||||
var cpm = pm.pop() ;
|
||||
while( cglpi && cpm && cglpi == cpm ) {
|
||||
domain = cglpi + (domain==''?'':'.' + domain) ;
|
||||
cglpi = glpi.pop() ;
|
||||
cpm = pm.pop() ;
|
||||
}
|
||||
if( domain != '' ) {
|
||||
$('div[name=domain]').text(domain) ;
|
||||
$('div[name=domain]').parent().attr('color', 'green');
|
||||
return;
|
||||
}
|
||||
} catch(ex) {}
|
||||
$('div[name=domain]').text('".$LANG['processmaker']['config']['domain-error']."') ;
|
||||
$('div[name=domain]').parent().attr('color', 'red');
|
||||
};
|
||||
$('input[name=pm_server_URL]').on('keyup', setCommonDomain ) ;
|
||||
setCommonDomain() ;
|
||||
");
|
||||
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']."'>" ;
|
||||
@@ -120,8 +183,11 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['connectionstatus']."</td><td >";
|
||||
$pm = new PluginProcessmakerProcessmaker ;
|
||||
$ret = $pm->login(true);
|
||||
if( $ret ) {
|
||||
//$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);
|
||||
@@ -163,26 +229,31 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
array('value' => $config->fields['pm_theme']));
|
||||
echo "</td></tr>";
|
||||
|
||||
$taskCatogrie = new TaskCategory;
|
||||
$taskCatogrie->getFromDB( $config->fields['taskcategories_id'] ) ;
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['main_task_category']."</td><td >";
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=". $config->fields['taskcategories_id']."'>".str_replace(" ", " ", $taskCatogrie->fields['name']);
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$config->fields['taskcategories_id'].")";
|
||||
}
|
||||
echo "</a>" ;
|
||||
TaskCategory::dropdown(array('name' => 'taskcategories_id',
|
||||
'display_emptychoice' => true,
|
||||
'value' => $config->fields['taskcategories_id']));
|
||||
echo "</td></tr>\n";
|
||||
|
||||
$taskUser = new User;
|
||||
$taskUser->getFromDB( $config->fields['users_id'] ) ;
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td >".$LANG['processmaker']['config']['taskwriter']."</td><td >";
|
||||
echo "<a href='".Toolbox::getItemTypeFormURL( 'User' )."?id=". $config->fields['users_id']."'>".str_replace(" ", " ", $taskUser->getName());
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (".$config->fields['users_id'].")";
|
||||
}
|
||||
echo "</a>" ;
|
||||
$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;'
|
||||
onClick=\"".Html::jsGetElementbyID('add_dropdown'.$rand).".dialog('open');\">";
|
||||
echo Ajax::createIframeModalWindow('add_dropdown'.$rand,
|
||||
User::getFormURL(),
|
||||
array('display' => false));
|
||||
// end of + sign
|
||||
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
@@ -201,17 +272,6 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
|
||||
echo "</td></tr>\n";
|
||||
|
||||
//echo "<tr class='tab_bg_1'>";
|
||||
//echo "<td >".$LANG['processmaker']['config']['comments']."";
|
||||
//echo "</td><td rowspan='5' >";
|
||||
//echo "<textarea cols='60' rows='5' name='comment' >".$config->fields['comment']."</textarea>";
|
||||
//echo "</td></tr>\n";
|
||||
|
||||
//echo "<tr></tr>";
|
||||
//echo "<tr></tr>";
|
||||
//echo "<tr></tr>";
|
||||
//echo "<tr></tr>";
|
||||
|
||||
echo "<tr><td colspan='4' class='center b'>".__('Maintenance')."</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
|
||||
$this->pmAdminSession = false ;
|
||||
unset($_SESSION["pluginprocessmaker"]["session"]) ;
|
||||
Toolbox::logDebug( "Processmaker Plugin: Soap problem: ". print_r( $locSession, true ) );
|
||||
Toolbox::logDebug( "Processmaker Plugin: $admin_or_user - Soap problem: ". print_r( $locSession, true ) );
|
||||
$this->lasterror = $locSession ;
|
||||
return false ;
|
||||
}
|
||||
@@ -957,7 +957,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
* 0 : nothing to do
|
||||
*/
|
||||
static function cronPMTaskActions($task) {
|
||||
global $DB, $CFG_GLPI;
|
||||
global $DB, $CFG_GLPI, $PM_DB;
|
||||
|
||||
if (!isset($PM_DB)) {
|
||||
$PM_DB = new PluginProcessmakerDB ;
|
||||
}
|
||||
|
||||
$actionCode = 0; // by default
|
||||
$error = false ;
|
||||
@@ -1678,6 +1682,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$input['is_private'] = 0 ;
|
||||
$input['actiontime'] = 0 ;
|
||||
$input['state'] = 1 ; // == TO_DO
|
||||
$input['users_id_tech'] = 0; // by default as it can't be empty
|
||||
if( $techId ) {
|
||||
$input['users_id_tech'] = $techId;
|
||||
} elseif( $groups_id_tech ) {
|
||||
@@ -1847,6 +1852,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
public function solveTask( $caseId, $delIndex, $options=array() ) {
|
||||
global $DB, $CFG_GLPI ;
|
||||
|
||||
// change current glpi_currenttime to be sure that date_mode for solved task will not be identical than date_mode of the newly started task
|
||||
$start_date = new DateTime( $_SESSION["glpi_currenttime"] ) ;
|
||||
$official_date_time = $_SESSION["glpi_currenttime"] ;
|
||||
$_SESSION["glpi_currenttime"] = $start_date->sub(new DateInterval("PT1S"))->format("Y-m-d H:i:s") ;
|
||||
|
||||
$default_options = array(
|
||||
'txtToAppend' => '',
|
||||
'notif' => true,
|
||||
@@ -1889,6 +1899,10 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$glpi_task->update( $params ) ;
|
||||
$CFG_GLPI["use_mailing"]= $donotif;
|
||||
}
|
||||
|
||||
// restore current glpi time
|
||||
$_SESSION["glpi_currenttime"] = $official_date_time ;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2468,6 +2482,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
$locItem->fields['due_date'] = "";
|
||||
}
|
||||
|
||||
|
||||
$resultCase = $this->newCase( $processId,
|
||||
array('GLPI_ITEM_CAN_BE_SOLVED' => 0,
|
||||
'GLPI_TICKET_ID' => $itemId,
|
||||
@@ -2482,9 +2497,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
||||
'GLPI_ITEM_IMPACT' => $locItem->fields['impact'],
|
||||
'GLPI_ITEM_PRIORITY' => $locItem->fields['priority'],
|
||||
'GLPI_TICKET_GLOBAL_VALIDATION' => $locItem->fields['global_validation'] ,
|
||||
'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $userId, //$technicians[0]['glpi_id'],
|
||||
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc'],
|
||||
'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $userId ) //$technicians[0]['pm_id']
|
||||
'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $userId,
|
||||
'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $userId ),
|
||||
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']
|
||||
) ) ;
|
||||
|
||||
if ($resultCase->status_code === 0){
|
||||
|
||||
@@ -94,6 +94,11 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
$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 ;
|
||||
}
|
||||
$ret = CommonITILTask::genericPopulatePlanning( 'TicketTask', $params ) ;
|
||||
|
||||
foreach( $ret as $key => $event ) {
|
||||
|
||||
@@ -63,10 +63,10 @@ function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
|
||||
// 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';
|
||||
}
|
||||
//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]');
|
||||
|
||||
17
js/domain.js.php
Normal file
17
js/domain.js.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
define('GLPI_ROOT','../../..');
|
||||
include (GLPI_ROOT."/inc/includes.php");
|
||||
header("Content-type: application/javascript");
|
||||
|
||||
$config = PluginProcessmakerConfig::getInstance() ;
|
||||
if( isset($config->fields['domain']) && $config->fields['domain'] != '' ) {
|
||||
echo "
|
||||
//debugger;
|
||||
var d = document,
|
||||
g = d.createElement('script'),
|
||||
s = d.getElementsByTagName('script')[0];
|
||||
g.type = 'text/javascript';
|
||||
g.text = 'document.domain = \'".$config->fields['domain']."\';';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
" ;
|
||||
}
|
||||
@@ -30,12 +30,7 @@ $LANG['processmaker']['process']['profile']="Delete permanently";
|
||||
$LANG['processmaker']['config']['name']="Name";
|
||||
$LANG['processmaker']['config']['setup']="ProcessMaker setup";
|
||||
$LANG['processmaker']['config']['mysql']="SQL server setup";
|
||||
$LANG['processmaker']['config']['URL']="Server URL";
|
||||
//$LANG['processmaker']['config']['db_server']="mySQL server";
|
||||
//$LANG['processmaker']['config']['db_user']="mySQL user";
|
||||
//$LANG['processmaker']['config']['db_password']="mySQL password (leave blank if unchanged)";
|
||||
//$LANG['processmaker']['config']['admin_user']="PM administrator user";
|
||||
//$LANG['processmaker']['config']['admin_password']="PM administrator password (leave blank if unchanged)";
|
||||
$LANG['processmaker']['config']['URL']="Server URL (must be in same domain than GLPI)";
|
||||
$LANG['processmaker']['config']['workspace']="Workspace Name";
|
||||
$LANG['processmaker']['config']['admin']['user']="Server administrator name";
|
||||
$LANG['processmaker']['config']['admin']['password']="Server administrator password";
|
||||
@@ -51,6 +46,8 @@ $LANG['processmaker']['config']['undermaintenance']="Under maintenance, please t
|
||||
$LANG['processmaker']['config']['empty_pm_group_name']="To select group, input ProcessMaker config first!";
|
||||
$LANG['processmaker']['config']['test']="Test";
|
||||
$LANG['processmaker']['config']['connectionstatus']="Connection status";
|
||||
$LANG['processmaker']['config']['domain']="Common domain with GLPI";
|
||||
$LANG['processmaker']['config']['domain-error']="None!";
|
||||
|
||||
$LANG['processmaker']['item']['tab']="Process - Case";
|
||||
$LANG['processmaker']['item']['cancelledcase']="Status: Cancelled";
|
||||
@@ -90,6 +87,7 @@ $LANG['processmaker']['item']['case']['casechangeloghistory']='Change log histor
|
||||
|
||||
$LANG['processmaker']['item']['error'][11]="Error creating case!";
|
||||
$LANG['processmaker']['item']['error'][14]="Can't create case: no rights for it!";
|
||||
$LANG['processmaker']['item']['error'][100]=$LANG['processmaker']['item']['error'][11];
|
||||
|
||||
$LANG['processmaker']['item']['preventsolution'][1]="A 'Case' is running!";
|
||||
$LANG['processmaker']['item']['preventsolution'][2]="You must manage it first (see 'Process - Case' tab)!";
|
||||
|
||||
@@ -30,12 +30,7 @@ $LANG['processmaker']['process']['profile']="Effacer définitivement";
|
||||
$LANG['processmaker']['config']['name']="Nom";
|
||||
$LANG['processmaker']['config']['setup']="Configuration du serveur ProcessMaker";
|
||||
$LANG['processmaker']['config']['mysql']="Configuration du serveur SQL";
|
||||
$LANG['processmaker']['config']['URL']="URL du serveur";
|
||||
//$LANG['processmaker']['config']['db_server']="Serveur mySQL";
|
||||
//$LANG['processmaker']['config']['db_user']="Utilisateur mySQL";
|
||||
//$LANG['processmaker']['config']['db_password']="Mot de passe mySQL (vide si inchangé)";
|
||||
//$LANG['processmaker']['config']['admin_user']="Administrateur de PM";
|
||||
//$LANG['processmaker']['config']['admin_password']="Mot de passed de l'administrateur de PM (vide si inchangé)";
|
||||
$LANG['processmaker']['config']['URL']="URL du serveur (doit être dans le même domaine que GLPI)";
|
||||
$LANG['processmaker']['config']['workspace']="Nom du Workspace";
|
||||
$LANG['processmaker']['config']['admin']['user']="Non de l'administreur du server ProcessMaker";
|
||||
$LANG['processmaker']['config']['admin']['password']="Mot de passe de l'administrateur du serveur ProcessMaker";
|
||||
@@ -51,6 +46,8 @@ $LANG['processmaker']['config']['undermaintenance']="En maintenance, veuillez r
|
||||
$LANG['processmaker']['config']['empty_pm_group_name']="Pour sélectionner un groupe, renseigner d'abord la config de ProcessMaker !";
|
||||
$LANG['processmaker']['config']['test']="Test";
|
||||
$LANG['processmaker']['config']['connectionstatus']="Status de la connexion";
|
||||
$LANG['processmaker']['config']['domain']="Domaine utilisé";
|
||||
$LANG['processmaker']['config']['domain-error']="Aucun !";
|
||||
|
||||
$LANG['processmaker']['item']['tab']="Processus - Cas";
|
||||
$LANG['processmaker']['item']['cancelledcase']="Statut : Annulé";
|
||||
@@ -90,6 +87,7 @@ $LANG['processmaker']['item']['case']['casechangeloghistory']='Historique évolu
|
||||
|
||||
$LANG['processmaker']['item']['error'][11]="Erreur à la création du cas !";
|
||||
$LANG['processmaker']['item']['error'][14]="Impossible de créer le cas : pas de droits pour cela !";
|
||||
$LANG['processmaker']['item']['error'][100]=$LANG['processmaker']['item']['error'][11];
|
||||
|
||||
$LANG['processmaker']['item']['preventsolution'][1]="Un 'Cas' est en cours !";
|
||||
$LANG['processmaker']['item']['preventsolution'][2]="Vous devez d'abord le terminer (voir onglet 'Processus - Cas') !";
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</authors>
|
||||
<versions>
|
||||
<version>
|
||||
<num>3.1.0</num>
|
||||
<num>3.1.1</num>
|
||||
<compatibility>9.1</compatibility>
|
||||
</version>
|
||||
</versions>
|
||||
|
||||
@@ -72,7 +72,6 @@ function plugin_init_processmaker() {
|
||||
$PLUGIN_HOOKS['pre_item_update']['processmaker'] = array(
|
||||
'Ticket' => 'plugin_pre_item_update_processmaker'
|
||||
);
|
||||
// , 'TicketFollowup' => 'plugin_pre_item_update_processmaker_followup'
|
||||
|
||||
$PLUGIN_HOOKS['item_update']['processmaker'] = array(
|
||||
'TicketSatisfaction' => 'plugin_item_update_processmaker_satisfaction',
|
||||
@@ -99,6 +98,7 @@ function plugin_init_processmaker() {
|
||||
'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]) {
|
||||
@@ -106,9 +106,8 @@ function plugin_init_processmaker() {
|
||||
case "helpdesk.public.php":
|
||||
//$plug = new Plugin;
|
||||
//if( !$plug->isActivated('rayusermanagementticket') )
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'] = "js/helpdesk.public.js.php";
|
||||
$PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/helpdesk.public.js.php";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS['use_massive_action']['processmaker'] = 1;
|
||||
@@ -124,7 +123,7 @@ function plugin_version_processmaker(){
|
||||
global $LANG;
|
||||
|
||||
return array ('name' => 'Process Maker',
|
||||
'version' => '3.1.0',
|
||||
'version' => '3.1.1',
|
||||
'author' => 'Olivier Moron',
|
||||
'homepage' => '',
|
||||
'minGlpiVersion' => '9.1');
|
||||
|
||||
Reference in New Issue
Block a user