&$val) { // $item=false; // if( isset( $val['tickettasks_id'] ) ) // $item = new TicketTask ; // if( $item ) { // $item->getFromDB( $val['id'] ) ; // PluginProcessmakerProcessmaker::canedit_item_processmakertickettask( $item ) ; // $val['content']=$item->fields['content']; // } // } // } // return $param; //} function plugin_processmaker_MassiveActions($type) { global $LANG; switch ($type) { case 'PluginProcessmakerProcess' : if( plugin_processmaker_haveRight('process_config', 'w' ) ) return array('plugin_processmaker_taskrefresh' => 'Synchronize Task List'); } return array(); } function plugin_processmaker_MassiveActionsDisplay($options) { global $LANG; switch ($options['itemtype']) { case 'PluginProcessmakerProcess' : switch ($options['action']) { // No case for add_document : use GLPI core one case "plugin_processmaker_taskrefresh" : echo ""; break; } break; } return ""; } function plugin_processmaker_MassiveActionsProcess($data) { global $LANG,$DB; switch ($data['action']) { case "plugin_processmaker_taskrefresh" : if ($data['itemtype'] == 'PluginProcessmakerProcess') { foreach ($data["item"] as $key => $val) { if ($val == 1) { $process = new PluginProcessmakerProcess; //$process->getFromDB($key); $process->refreshTasks( array( 'id' => $key ) ) ; } } } break; } } /** * Summary of plugin_processmaker_install * Creates tables and initializes tasks, "GLPI Requesters" group * and so on * @return true or die! */ function plugin_processmaker_install() { 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`;" ; $DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error()); } 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, `pm_server_URL` VARCHAR(250) NOT NULL DEFAULT 'http://localhost/', `pm_workspace` VARCHAR(50) NOT NULL DEFAULT 'workflow', `pm_theme` VARCHAR(50) NOT NULL DEFAULT 'classic', `date_mod` DATETIME NULL DEFAULT NULL, `taskcategories_id` INT(11) NULL , `users_id` INT(11) NULL DEFAULT NULL, `pm_group_guid` VARCHAR(32) NULL DEFAULT NULL, `comment` TEXT NULL, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB; "; $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()); } 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_cases")) { $query = "CREATE TABLE `glpi_plugin_processmaker_cases` ( `id` VARCHAR(32) NOT NULL, `items_id` INT(11) NOT NULL, `itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket', `case_num` INT(11) NOT NULL, `case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT', UNIQUE INDEX `items` (`itemtype`, `items_id`), INDEX `case_status` (`case_status`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB; "; $DB->query($query) or die("error creating glpi_plugin_processmaker_cases" . $DB->error()); } if (!TableExists("glpi_plugin_processmaker_tasks")) { $query = "CREATE TABLE `glpi_plugin_processmaker_tasks` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `items_id` INT(11) NOT NULL, `itemtype` VARCHAR(32) NOT NULL, `case_id` VARCHAR(32) NOT NULL, `del_index` INT(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `case_id` (`case_id`, `del_index`), UNIQUE INDEX `items` (`itemtype`, `items_id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB; "; $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` ( `glpi_users_id` INT(11) NOT NULL , `pm_users_id` VARCHAR(32) NOT NULL , UNIQUE INDEX `glpi_users_id` (`glpi_users_id`), UNIQUE INDEX `pm_users_id` (`pm_users_id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB; "; $DB->query($query) or die("error creating 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, `process_guid` VARCHAR(32) NOT NULL, `name` VARCHAR(255) NOT NULL, `is_active` TINYINT(1) NOT NULL DEFAULT '0', `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 , `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, PRIMARY KEY (`id`), UNIQUE INDEX `process_guid` (`process_guid`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB; "; $DB->query($query) or die("error creating glpi_plugin_processmaker_processes" . $DB->error()); } 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) ; } 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';" ; $DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error()); } 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', 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 AUTO_INCREMENT=57 ; "; $DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error()); } // 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 ) ) ; } $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 Requesters" ) ; if( $pmres->status_code == 0 ) $config->update( array( 'id' => $config->getID(), 'pm_group_guid' => $pmres->groupUID ) ) ; } // 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)); // required cause autoload doesn't work for unactive plugin' include_once(GLPI_ROOT."/plugins/processmaker/inc/profile.class.php"); PluginProcessmakerProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']); return true; } function plugin_processmaker_uninstall() { global $DB; // Current version tables //if (TableExists("glpi_plugin_processmaker_ticketcase")) { // $query = "DROP TABLE `glpi_plugin_processmaker_ticketcase`"; // $DB->query($query) or die("error deleting glpi_plugin_processmaker_ticketcase"); //} CronTask::Unregister('PluginProcessmakerProcessmaker'); //if (TableExists("glpi_plugin_processmaker_processes")) { // $query = "DROP TABLE `glpi_plugin_processmaker_processes`"; // $DB->query($query) or die("error deleting glpi_plugin_processmaker_processes"); //} // now uninstall triggers from PM tables //$DB->close(); //$DB->dbdefault='wf_workflow'; //$DB->connect( ) ; //$DB->runFile(GLPI_ROOT.'/plugins/processmaker/config/pm_db_uninstall.sql') or die("error creating triggers on wf_workflow database!" . $DB->error()); //$DB->close(); //$DB->dbdefault='glpi'; //$DB->connect( ) ; // return true; } //// Define headings added by the plugin //function plugin_get_headings_processmaker($item, $withtemplate) { // global $LANG ; // switch (get_class($item)) { // case 'Ticket' : // return array(1 => $LANG['processmaker']['ticket']['tab']); // //case 'Profile' : // // $prof = new Profile(); // // if ($item->fields['interface'] == 'central') { // // return array(1 => "Test PLugin"); // // } // // return array(); // //case 'Computer' : // // // new object / template case // // if ($withtemplate) { // // return array(); // // // Non template case / editing an existing object // // } // // return array(1 => "Test PLugin"); // //case 'ComputerDisk' : // //case 'Supplier' : // // if ($item->getField('id')) { // Not in create mode // // return array(1 => "Test PLugin", // // 2 => "Test PLugin 2"); // // } // // break; // //case 'Central' : // //case 'Preference': // //case 'Notification': // // return array(1 => "Test PLugin"); // } // return false; //} //// Define headings actions added by the plugin //function plugin_headings_actions_processmaker($item) { // switch (get_class($item)) { // //case 'Profile' : // //case 'Computer' : // // return array(1 => "plugin_headings_processmaker"); // //case 'ComputerDisk' : // //case 'Supplier' : // // return array(1 => "plugin_headings_processmaker", // // 2 => "plugin_headings_processmaker"); // //case 'Central' : // //case 'Preference' : // //case 'Notification' : // case 'Ticket' : // return array(1 => "plugin_headings_processmaker"); // } // return false; //} //// Example of an action heading //function plugin_headings_processmaker($item, $withtemplate=0) { // global $LANG, $DB, $GLOBALS ; // if (!$withtemplate) { // echo "