diff --git a/README.md b/README.md index b7d1bad..d5b74f4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ GLPI plugin that provides an interface with a customized ProcessMaker server (https://github.com/tomolimo/processmaker-server). -version 3.4.5 is compatible with GLPI 9.2 and needs ProcessMaker either 3.0.1.8-RE-1.12 (https://github.com/tomolimo/processmaker-server/releases/tag/3.0.1.8-RE-1.12) or 3.3.0-RE-1.0 (https://github.com/tomolimo/processmaker-server/releases/tag/3.3.0-RE-1.0) +version 3.4.x is compatible with GLPI 9.2 and needs ProcessMaker either 3.0.1.8-RE-1.12 (https://github.com/tomolimo/processmaker-server/releases/tag/3.0.1.8-RE-1.12) or 3.3.0-RE-1.0 (https://github.com/tomolimo/processmaker-server/releases/tag/3.3.0-RE-1.0) + +version 3.5.x is compatible with GLPI 9.3 and needs ProcessMaker 3.3.0-RE-1.x (https://github.com/tomolimo/processmaker-server/releases/latest) This plugin can run classic and bpmn processes diff --git a/ajax/dropdownProcesses.php b/ajax/dropdownProcesses.php index af506a7..ba543e3 100644 --- a/ajax/dropdownProcesses.php +++ b/ajax/dropdownProcesses.php @@ -61,15 +61,22 @@ if (empty($_REQUEST['searchText'])) { } $processall = (isset($_REQUEST['specific_tags']['process_restrict']) && !$_REQUEST['specific_tags']['process_restrict']); +$count_cases_per_item = isset($_REQUEST['specific_tags']['count_cases_per_item']) ? $_REQUEST['specific_tags']['count_cases_per_item'] : []; $result = PluginProcessmakerProcess::getSqlSearchResult(false, $search); if ($DB->numrows($result)) { while ($data = $DB->fetch_array($result)) { $process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true); - if ($processall || in_array( $_REQUEST["entity_restrict"], $process_entities)) { - array_push( $processes, [ 'id' => $data["id"], - 'text' => $data["name"] ]); + $can_add = $data['max_cases_per_item'] == 0 || !isset($count_cases_per_item[$data["id"]]) || $count_cases_per_item[$data["id"]] < $data['max_cases_per_item']; + if ($processall + || ($data['maintenance'] != 1 + && in_array( $_REQUEST["entity_restrict"], $process_entities) + && $can_add) ) { + + array_push( $processes, ['id' => $data["id"], + 'text' => $data["name"] + ]); $count++; } } diff --git a/ajax/dropdownUsers.php b/ajax/dropdownUsers.php index 2ad0286..16785f1 100644 --- a/ajax/dropdownUsers.php +++ b/ajax/dropdownUsers.php @@ -57,8 +57,9 @@ if (!isset($_REQUEST['page'])) { if ($one_item < 0) { $start = ($_REQUEST['page']-1)*$_REQUEST['page_limit']; $LIMIT = "LIMIT $start,".$_REQUEST['page_limit']; + $searchText = isset($_REQUEST['searchText']) ? $_REQUEST['searchText'] : ""; $result = PluginProcessmakerUser::getSqlSearchResult( $_REQUEST['specific_tags']['taskGuid'], false, $_REQUEST['right'], $_REQUEST["entity_restrict"], - $_REQUEST['value'], $used, $_REQUEST['searchText'], $LIMIT); + $_REQUEST['value'], $used, $searchText, $LIMIT); } else { $query = "SELECT DISTINCT `glpi_users`.* FROM `glpi_users` diff --git a/front/case.form.php b/front/case.form.php index 6ed607f..f3f63ac 100644 --- a/front/case.form.php +++ b/front/case.form.php @@ -22,16 +22,13 @@ function glpi_processmaker_case_reload_page() { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'route' && isset( $_REQUEST['UID'] ) && isset( $_REQUEST['APP_UID'] ) && isset( $_REQUEST['__DynaformName__'] )) { // then get item id from DB if ($locCase->getFromGUID($_REQUEST['APP_UID'])) { - - if (isset( $_REQUEST['form'] )) { - $PM_SOAP->derivateCase($locCase, $_REQUEST); - } + $PM_SOAP->derivateCase($locCase, $_REQUEST); } glpi_processmaker_case_reload_page(); -} else if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { +} else if (isset($_REQUEST['purge'])) { // delete case from case table, this will also delete the tasks - if ($locCase->getFromDB($_POST['cases_id']) && $locCase->deleteCase()) { + if ($locCase->getFromDB($_REQUEST['id']) && $locCase->deleteCase()) { Session::addMessageAfterRedirect(__('Case has been deleted!', 'processmaker'), true, INFO); } else { Session::addMessageAfterRedirect(__('Unable to delete case!', 'processmaker'), true, ERROR); diff --git a/front/case.php b/front/case.php index 8cb05e5..45bb2ac 100644 --- a/front/case.php +++ b/front/case.php @@ -5,19 +5,8 @@ include_once ("../../../inc/includes.php"); Html::header(__('ProcessMaker', 'processmaker'), $_SERVER['PHP_SELF'], "helpdesk", "PluginProcessmakerCase", "cases"); if (!$PM_SOAP->config->fields['maintenance']) { - if (Session::haveRightsOr("plugin_processmaker_config", [READ, UPDATE])) { + if (Session::haveRightsOr("plugin_processmaker_case", [READ, UPDATE])) { - // force default sort to column id / DESC - if (empty($_SESSION['glpisearch']['PluginProcessmakerCase']) - || isset($_GET["reset"]) - || !isset($_GET["sort"]) - ) { - $_SESSION['glpisearch']['PluginProcessmakerCase']['order'] = 'DESC'; - $_SESSION['glpisearch']['PluginProcessmakerCase']['sort'] = '1'; - if (isset($_GET["reset"])) { - unset($_GET['reset']); - } - } Search::show('PluginProcessmakerCase'); } else { Html::displayRightError(); diff --git a/front/process_profile.form.php b/front/process_profile.form.php index c273793..18d0460 100644 --- a/front/process_profile.form.php +++ b/front/process_profile.form.php @@ -4,14 +4,13 @@ include_once ("../../../inc/includes.php"); Session::checkCentralAccess(); -$right = new PluginProcessmakerProcess_Profile(); +$right = new PluginProcessmakerProcess_Profile(); if (isset($_POST["add"])) { $right->check(-1, UPDATE, $_POST); - if ($right->add($_POST)) { - } + $right->add($_POST); Html::back(); -} +} Html::displayErrorAndDie("lost"); diff --git a/front/processmaker.form.php b/front/processmaker.form.php index a2a0b2f..d70ab35 100644 --- a/front/processmaker.form.php +++ b/front/processmaker.form.php @@ -3,12 +3,9 @@ include_once ("../../../inc/includes.php"); switch ($_POST["action"]) { case 'newcase': - if (isset($_POST['items_id']) && $_POST['items_id'] > 0) { // then this case will be bound to an item - // TODO: we must check if a case is not already existing - // to manage the problem of F5 (Refresh) + if (isset($_POST['items_id']) && $_POST['items_id'] > 0) { - //$hasCase = PluginProcessmakerCase::getIDFromItem($_POST['itemtype'], $_POST['items_id']); - //if ($hasCase === false && $_POST['plugin_processmaker_processes_id'] > 0) { + // then this case will be bound to an item if ($_POST['plugin_processmaker_processes_id'] > 0) { $resultCase = $PM_SOAP->startNewCase($_POST['plugin_processmaker_processes_id'], $_POST['itemtype'], $_POST['items_id'], Session::getLoginUserID()); @@ -18,9 +15,18 @@ switch ($_POST["action"]) { if ($case->getFromGUID($resultCase->caseId)) { $link = $case->getLinkURL(); $task = new PluginProcessmakerTask(); - $task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task + + $task->getFromDBByRequest([ + 'WHERE' => [ + 'plugin_processmaker_cases_id' => $case->getID() + ], + ]); + + + //$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task //$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID(); - Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->getID()); + + Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']); $item = new $_POST['itemtype']; $item->getFromDB($_POST['items_id']); unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList @@ -39,11 +45,18 @@ switch ($_POST["action"]) { Html::back(); } } else { // the case is created before the ticket (used for post-only case creation before ticket creation) + $pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ); $resultCase = $PM_SOAP->newCase( $_POST['plugin_processmaker_processes_id'], - [ 'GLPI_ITEM_CAN_BE_SOLVED' => 0, - 'GLPI_SELFSERVICE_CREATED' => '1', - 'GLPI_ITEM_TYPE' => 'Ticket', - 'GLPI_URL' => $CFG_GLPI['url_base']] ); + ['GLPI_ITEM_CAN_BE_SOLVED' => 0, + 'GLPI_SELFSERVICE_CREATED' => '1', + 'GLPI_ITEM_TYPE' => 'Ticket', + 'GLPI_URL' => $CFG_GLPI['url_base'], + // Specific to Tickets + // GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request) + 'GLPI_TICKET_TYPE' => $_POST['type'], + 'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(), + 'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid + ] ); if ($resultCase->status_code == 0) { // case is created // Must show it... diff --git a/front/processmaker.helpdesk.form.php b/front/processmaker.helpdesk.form.php index 212a910..5a7175a 100644 --- a/front/processmaker.helpdesk.form.php +++ b/front/processmaker.helpdesk.form.php @@ -54,6 +54,7 @@ function processMakerShowCase($ID, $from_helpdesk) { $rand = rand(); + $PM_SOAP->echoDomain(); echo ""; $tkt = new Ticket; diff --git a/hook.php b/hook.php index 130e12b..85cad3f 100644 --- a/hook.php +++ b/hook.php @@ -24,66 +24,6 @@ function plugin_processmaker_MassiveActions($type) { } -//function plugin_processmaker_MassiveActionsDisplay($options) { - -// switch ($options['itemtype']) { -// case 'PluginProcessmakerProcess' : -// //case 'PluginProcessmakerCase' : -// switch ($options['action']) { -// case "plugin_processmaker_taskrefresh" : -// //case "plugin_processmaker_purgecase" : -// echo ""; -// break; - -// } -// break; -// } -// return ""; -//} - - -//function plugin_processmaker_MassiveActionsProcess($data) { - -// switch ($data['action']) { - -// case "plugin_processmaker_taskrefresh" : -// if ($data['itemtype'] == 'PluginProcessmakerProcess') { -// foreach ($data["item"] as $key => $val) { -// if ($val == 1) { -// $process = new PluginProcessmakerProcess; -// $process->refreshTasks( array( 'id' => $key ) ); - -// } -// } -// } -// break; -// //case "plugin_processmaker_purgecase": -// // if ($data['itemtype'] == 'PluginProcessmakerCase') { -// // foreach ($data["item"] as $key => $val) { -// // if ($val == 1) { -// // $locCase= new PluginProcessmakerCase; -// // //$locCase->( array( 'id' => $key ) ); - -// // } -// // } -// // } -// // break; -// //case 'plugin_processmaker_process_profile_delete' : -// // if ($data['itemtype'] == 'PluginProcessmakerProcess_Profile') { -// // foreach ($data["item"] as $key => $val) { -// // if ($val == 1) { -// // $process_profile = new PluginProcessmakerProcess_Profile; -// // $process_profile->delete( array( 'id' => $key ), true ); - -// // } -// // } -// // } -// // break; - -// } -//} - /** * Summary of plugin_processmaker_install * Creates tables and initializes tasks, "GLPI Requesters" group @@ -192,6 +132,7 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) { switch ($key) { case 'global_validation' : $locVar[ 'GLPI_TICKET_GLOBAL_VALIDATION' ] = $val; + $locVar[ 'GLPI_ITEM_GLOBAL_VALIDATION' ] = $val; break; case 'itilcategories_id' : $locVar[ 'GLPI_ITEM_ITIL_CATEGORY_ID' ] = $val; @@ -250,73 +191,6 @@ function plugin_item_update_processmaker_satisfaction($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 (PluginProcessmakerCase::getIDFromItem($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, $PM_SOAP; - -// //$objects = ['Ticket', 'Change', 'Problem']; -// $object_users = ['Ticket_User', 'Change_User', 'Problem_User']; - -// if (in_array($parm->getType(), $object_users) && 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 !!!! - -// $itemType = strtolower(explode('_', $parm->getType())[0]); // $parm->getType() returns 'Ticket_User'; -// $itemId = $parm->fields[$itemType.'s_id']; -// $cases = PluginProcessmakerCase::getIDsFromItem($itemType, $itemId); -// foreach ($cases as $cases_id) { -// // cases are existing for this item -// $locCase = new PluginProcessmakerCase; -// if ($locCase->getFromDB($cases_id)) { -// $technicians = PluginProcessmakerProcessmaker::getItemUsers($itemType, $itemId, CommonITILActor::ASSIGN); - -// $locVars = array( 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'], -// 'GLPI_ITEM_TECHNICIAN_GLPI_ID' => $technicians[0]['glpi_id'], -// 'GLPI_TICKET_TECHNICIAN_PM_ID' => $technicians[0]['pm_id'], -// 'GLPI_ITEM_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 = $locCase->getCaseInfo( ); -// if ($caseInfo !== false) { -// $locCase->sendVariables( $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'] ); -// if (property_exists($caseInfo, 'currentUsers') && is_array( $caseInfo->currentUsers )) { -// foreach ($caseInfo->currentUsers as $caseUser) { -// if ($caseUser->userId == $GLPICurrentPMUserId && in_array( $caseUser->delThreadStatus, array('DRAFT', 'OPEN', 'PAUSE' ) )) { -// $locCase->reassignCase($caseUser->delIndex, $caseUser->taskId, $caseUser->delThread, $parm->fields['users_id'], $technicians[0]['pm_id'] ); -// } -// } -// } -// } - -// } -// } -// } -//} function plugin_processmaker_post_init() { global $PM_DB, $PM_SOAP; @@ -352,22 +226,26 @@ function plugin_processmaker_change_profile() { function plugin_item_update_processmaker_tasks($parm) { global $DB, $CFG_GLPI, $PM_SOAP; - // 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'] ) && in_array( 'state', $parm->updates ) - && $parm->input['state'] == 2) { // the task has just been set to DONE state + && $parm->input['state'] == Planning::DONE + && $parm->oldvalues['state'] == Planning::TODO) { // the task has just been set to DONE state - $itemtype = str_replace( 'Task', '', $parm->getType() ); + //$itemtype = str_replace( 'Task', '', $parm->getType() ); $pmTask = new PluginProcessmakerTask($parm->getType()); $pmTask->getFromDB($parm->fields['id']); $locCase = new PluginProcessmakerCase; - $locCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']); //Item($itemtype, $parm->fields['tickets_id']); + $locCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']); $srccase_guid = $locCase->fields['case_guid']; + $msg = ' $locCase: '.str_replace("\n", "\n ", print_r($locCase, true))."\n"; + $msg .= ' $task: '.str_replace("\n", "\n ", print_r($parm, true))."\n"; + $msg .= ' $pmTask: '.str_replace("\n", "\n ", print_r($pmTask, true))."\n"; + $msg .= "\n"; + foreach ($DB->request( 'glpi_plugin_processmaker_caselinks', "is_active = 1 AND sourcetask_guid='".$pmTaskCat->fields['pm_task_guid']."'") as $targetTask) { // Must check the condition @@ -390,7 +268,7 @@ function plugin_item_update_processmaker_tasks($parm) { // must read some values $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"}} + // {"method":"POST","url":"urloftheservice","params":json_object} // 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 @@ -410,9 +288,20 @@ function plugin_item_update_processmaker_tasks($parm) { $infoForTasks[ "@@$casevar" ] = "'$varval'"; unset( $infoForTasks[ $casevar ] ); } + + $msg .= " ***********\n"; + $msg .= ' $targetTask: '.str_replace("\n", "\n ", print_r($targetTask, true))."\n"; + $targetTask['sourcecondition'] = str_replace( array_keys($infoForTasks), $infoForTasks, $targetTask['sourcecondition'] ); - if (eval( "return ".$targetTask['sourcecondition'].";" )) { + $eval = eval( "return (".$targetTask['sourcecondition']." ? 1 : 0);" ); + + $msg .= ' $infoForTasks: '.str_replace("\n", "\n ", print_r($infoForTasks, true))."\n"; + $msg .= ' $targetTask[\'sourcecondition\']: '.str_replace("\n", "\n ", print_r($targetTask['sourcecondition'], true))."\n"; + $msg .= ' $result: '."$eval\n"; + $msg .= "\n"; + + if ($eval) { // 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 @@ -436,9 +325,13 @@ function plugin_item_update_processmaker_tasks($parm) { $ch = curl_init(); $externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ); // '??? curl_setopt($ch, CURLOPT_URL, $externalapplication['url'] ); + if (isset($externalapplication['method']) && $externalapplication['method'] == 'POST') { + curl_setopt($ch, CURLOPT_POST, 1); + } } if ($targetTask['is_self']) { + $PM_SOAP->login(true); $taskCase = $PM_SOAP->taskCase( $srccase_guid ); foreach ($taskCase as $task) { // search for target task guid @@ -446,6 +339,7 @@ function plugin_item_update_processmaker_tasks($parm) { break; } } + $PM_SOAP->login(); $postdata['APP_UID'] = $srccase_guid; $postdata['DEL_INDEX'] = $task->delegate; @@ -470,20 +364,22 @@ function plugin_item_update_processmaker_tasks($parm) { 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":"urloftheservice","params":{"user":"@@USER_ID","system":"GPP","list":"@@ROLE_LIST"}} // url is the URL to be called $externalapplicationparams['id'] = $cronaction->getID(); $externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT); - curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($externalapplicationparams), 'Expect:']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt($ch, CURLOPT_VERBOSE, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $pmconfig->fields['ssl_verify']); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $pmconfig->fields['ssl_verify']); - //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ; - //curl_setopt($ch, CURLOPT_PROXY, "localhost:8889"); + //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ; + //curl_setopt($ch, CURLOPT_PROXY, "localhost:8889"); $response = curl_exec ($ch); @@ -493,6 +389,7 @@ function plugin_item_update_processmaker_tasks($parm) { } // } } else { + // TODO to review this part of code as it is no longer usable like this !!! 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 @@ -531,5 +428,9 @@ function plugin_item_update_processmaker_tasks($parm) { } } + + $msg .= "================\n"; + Toolbox::logInFile("processmaker", $msg); + } } diff --git a/inc/case.class.php b/inc/case.class.php index 3dbfe2e..907507a 100644 --- a/inc/case.class.php +++ b/inc/case.class.php @@ -28,13 +28,13 @@ class PluginProcessmakerCase extends CommonDBTM { //} - //static function canView() { - // return Session::haveRightsOr('plugin_processmaker_case', [READ, UPDATE]); - //} + static function canView() { + return Session::haveRightsOr('plugin_processmaker_case', [READ, UPDATE]); + } - //function canViewItem() { - // return Session::haveRightsOr('plugin_processmaker_case', READ); - //} + function canViewItem() { + return Session::haveRight('plugin_processmaker_case', READ); + } //static function canUpdate( ) { // return Session::haveRight('plugin_processmaker_config', UPDATE); @@ -44,25 +44,31 @@ class PluginProcessmakerCase extends CommonDBTM { // return Session::haveRight('plugin_processmaker_config', UPDATE); //} + //function canEdit($ID) { + // return parent::canDelete(); + //} function maybeDeleted() { return false; } - static function canDelete() { - return parent::canDelete(); - } + //static function canDelete() { + // return parent::canDelete(); + //} - function canDeleteItem() { - return parent::canDeleteItem(); - } + //function canDeleteItem() { + // return parent::canDeleteItem(); + //} static function canPurge() { - return self::canDelete(); + return true; //self::canDelete(); } function canPurgeItem() { - return $this->canDeleteItem(); + return $_SESSION['glpiactiveprofile']['interface'] == 'central' + && $this->fields['plugin_processmaker_cases_id'] == 0 + && $this->canDeleteItem() + && (self::canDelete() || $this->fields['case_status'] == PluginProcessmakerCase::DRAFT); } static function canCancel() { @@ -83,7 +89,7 @@ class PluginProcessmakerCase extends CommonDBTM { // case is a sub-case $tabname = __('Sub-case', 'processmaker'); } - return [ __CLASS__ => $tabname." ".self::getStatus($item->fields['case_status']).""]; + return [ 'main' => $tabname." ".self::getStatus($item->fields['case_status']).""]; } else { $items_id = $item->getID(); $itemtype = $item->getType(); @@ -114,13 +120,13 @@ class PluginProcessmakerCase extends CommonDBTM { * @param integer $items_id is the item id * @return integer cases_id */ - static function getIDFromItem($itemtype, $items_id) { - $tmp = New self; - if ($tmp->getFromDBByQuery(" WHERE items_id=$items_id and itemtype='$itemtype'")) { - return $tmp->getID(); - } - return false; - } + //static function getIDFromItem($itemtype, $items_id) { + // $tmp = New self; + // if ($tmp->getFromDBByQuery(" WHERE items_id=$items_id and itemtype='$itemtype'")) { + // return $tmp->getID(); + // } + // return false; + //} /** @@ -133,7 +139,12 @@ class PluginProcessmakerCase extends CommonDBTM { static function getIDsFromItem($itemtype, $items_id) { $ret = []; $dbu = new DbUtils; - foreach ($dbu->getAllDataFromTable( self::getTable(), "items_id=$items_id AND itemtype='$itemtype'") as $case) { + $restrict = [ + "items_id" => $items_id, + "itemtype" => $itemtype,]; + + //foreach ($dbu->getAllDataFromTable( self::getTable(), "items_id=$items_id AND itemtype='$itemtype'") as $case) + foreach ($dbu->getAllDataFromTable( self::getTable(), $restrict) as $case) { $ret[] = $case['id']; } return $ret; @@ -156,7 +167,12 @@ class PluginProcessmakerCase extends CommonDBTM { * @return boolean */ function getFromGUID($case_guid) { - return $this->getFromDBByQuery(" WHERE case_guid='$case_guid'"); + $restrict=[ + 'WHERE' => [ + 'case_guid' => $case_guid, + ], + ]; + return $this->getFromDBByRequest($restrict); } @@ -477,9 +493,6 @@ class PluginProcessmakerCase extends CommonDBTM { */ static function showCaseInfoTab(CommonGLPI $case, $tabnum = 1, $withtemplate = 0) { // echo 'The idea is to show here the GLPI ITIL item to which it is linked, and to give a resume of the current case status, and to give possibility to delete or cancel the case.'; - - echo ""; - $itemtype = $case->fields['itemtype']; $maintitle = __('Case is linked to a %1s', 'processmaker'); @@ -487,7 +500,7 @@ class PluginProcessmakerCase extends CommonDBTM { $maintitle = __('Sub-case is linked to a %1s', 'processmaker'); } - echo ""; + echo ""; Ticket::commonListHeader(Search::HTML_OUTPUT); @@ -502,12 +515,8 @@ class PluginProcessmakerCase extends CommonDBTM { // it's a main case, not a sub-case // and we have the rights to cancel cases - // show a form to be able to cancel the case - $rand = rand(); echo "

"; - echo ""; - echo "
"; echo "
".sprintf($maintitle, $itemtype::getTypeName(1))."
".sprintf($maintitle, $itemtype::getTypeName(1))."
"; echo ""; echo ""; @@ -517,33 +526,27 @@ class PluginProcessmakerCase extends CommonDBTM { echo ""; echo "
".__('Case cancellation', 'processmaker')."
".__('Cancel case', 'processmaker')."
"; - Html::closeForm(); - } // will not show delete button if case is a sub-process // and will show it only if it is a draft or if current glpi user has the right to delete cases and session is central - if ($case->fields['plugin_processmaker_cases_id'] == 0 - && ($case->fields['case_status'] == self::DRAFT - || (plugin_processmaker_haveRight("case", DELETE) - && $_SESSION['glpiactiveprofile']['interface'] == 'central'))) { + if ($case->canPurgeItem($case->getID())) { // then propose a button to delete case - $rand = rand(); + // the button will be effectively shown by the showFormButtons() echo "

"; - echo ""; - echo "
"; echo ""; - echo ""; - echo ""; - echo "
".__('Case deletion', 'processmaker')."
".__('Delete case', 'processmaker').""; - echo ""; - echo ""; - echo ""; - echo "
"; + echo "".__('Case deletion', 'processmaker').""; + // echo "".__('Delete case', 'processmaker').""; + // echo ""; + // echo ""; + // echo ""; + // echo ""; + // echo ""; + echo ""; + echo "

"; - Html::closeForm(); } return; @@ -556,7 +559,7 @@ class PluginProcessmakerCase extends CommonDBTM { * @param CommonITILObject $item */ static function showForItem(CommonITILObject $item) { - global $DB, $CFG_GLPI; + global $DB, $CFG_GLPI, $PM_SOAP; $items_id = $item->getField('id'); $itemtype = $item->getType(); @@ -570,7 +573,7 @@ class PluginProcessmakerCase extends CommonDBTM { $rand = mt_rand(); - $query = "SELECT gppc.`id` AS assocID, gppc.`id` as id, gppp.name as pname, gppc.`case_status`, gppc.`plugin_processmaker_cases_id` + $query = "SELECT gppc.`id` AS assocID, gppc.`id` as id, gppp.id as pid, gppp.name as pname, gppc.`case_status`, gppc.`plugin_processmaker_cases_id` FROM `glpi_plugin_processmaker_cases` as gppc LEFT JOIN `glpi_plugin_processmaker_processes` AS gppp ON gppp.`id`=gppc.`plugin_processmaker_processes_id` WHERE gppc.`itemtype` = '$itemtype' @@ -579,25 +582,33 @@ class PluginProcessmakerCase extends CommonDBTM { $result = $DB->query($query); $cases = []; - $used = []; + $used = []; + $pid = []; if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $cases[$data['id']] = $data; - $used[$data['id']] = $data['id']; + $used[$data['id']] = $data['id']; + if (isset($pid[$data['pid']])) { + $pid[$data['pid']] += 1; + } else { + $pid[$data['pid']] = 1; + } } } $columns = ['pname' => __('Process', 'processmaker'), - 'name' => __('Title', 'processmaker'), - 'status' => __('Status', 'processmaker'), - 'sub' => __('Sub-case of', 'processmaker') + 'name' => __('Title', 'processmaker'), + 'status' => __('Status', 'processmaker'), + 'sub' => __('Sub-case of', 'processmaker') ]; // check if item is not solved nor closed if ($canupdate && $item->fields['status'] != CommonITILObject::SOLVED && $item->fields['status'] != CommonITILObject::CLOSED - && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') { + && $_SESSION['glpiactiveprofile']['interface'] != 'helpdesk' + && ($numrows < $PM_SOAP->config->fields['max_cases_per_item'] + || $PM_SOAP->config->fields['max_cases_per_item'] == 0)) { echo "
"; echo ""; echo ""; @@ -621,7 +632,8 @@ class PluginProcessmakerCase extends CommonDBTM { PluginProcessmakerProcess::dropdown(['value' => 0, 'entity' => $item->fields['entities_id'], 'name' => 'plugin_processmaker_processes_id', - 'condition' => "is_active=1 $is_itemtype" + 'condition' => "is_active=1 $is_itemtype", + 'specific_tags' => ['count_cases_per_item' => $pid] ]); echo ""; echo ""; @@ -728,7 +740,7 @@ class PluginProcessmakerCase extends CommonDBTM { if ($item->getType() == __CLASS__) { // we are in a case viewing the main tab // the 'Case infos' tab - self::showCaseInfoTab($item, $tabnum, $withtemplate); + //self::showCaseInfoTab($item, $tabnum, $withtemplate); } else { @@ -1099,168 +1111,172 @@ class PluginProcessmakerCase extends CommonDBTM { /** - * Summary of getSearchOptions + * Get default values to search engine to override + **/ + static function getDefaultSearchRequest() { + + $search = ['sort' => 1, + 'order' => 'DESC']; + + return $search; + } + + + /** + * Summary of rawSearchOptions * @return mixed */ - function getSearchOptions() { + function rawSearchOptions() { $tab = []; - $tab['common'] = __('Process cases', 'processmaker'); + $tab[] = [ + 'id' => 'common', + 'name' => __('Process cases', 'processmaker') + ]; - $tab[1]['table'] = self::getTable(); - $tab[1]['field'] = 'id'; - $tab[1]['name'] = __('ID', 'processmaker'); - $tab[1]['datatype'] = 'number'; - $tab[1]['searchtype'] = 'contains'; - $tab[1]['massiveaction'] = false; + $tab[] = [ + 'id' => '1', + 'table' => $this->getTable(), + 'field' => 'id', + 'name' => __('ID'), + 'datatype' => 'number', + 'searchtype' => 'contains', + 'massiveaction' => false + ]; - $tab[2]['table'] = self::getTable(); - $tab[2]['field'] = 'name'; - $tab[2]['name'] = __('Title', 'processmaker'); - $tab[2]['datatype'] = 'itemlink'; - $tab[2]['searchtype'] = 'contains'; - $tab[2]['massiveaction'] = false; + $tab[] = [ + 'id' => '2', + 'table' => $this->getTable(), + 'field' => 'name', + 'name' => __('Title'), + 'datatype' => 'itemlink', + 'searchtype' => 'contains', + 'massiveaction' => false + ]; - $tab[3]['table'] = self::getTable(); - $tab[3]['field'] = 'plugin_processmaker_processes_id'; - $tab[3]['name'] = __('Process', 'processmaker'); - $tab[3]['datatype'] = 'specific'; - $tab[3]['searchtype'] = ['contains', 'equals', 'notequals']; - $tab[3]['massiveaction'] = false; + $tab[] = [ + 'id' => '3', + 'table' => $this->getTable(), + 'field' => 'plugin_processmaker_processes_id', + 'name' => __('Process', 'processmaker'), + 'datatype' => 'specific', + 'searchtype' => [ + '0' => 'contains', + '1' => 'equals', + '2' => 'notequals' + ], + 'massiveaction' => false + ]; - $tab[7]['table'] = self::getTable(); - $tab[7]['field'] = 'itemtype'; - $tab[7]['name'] = __('Item type', 'processmaker'); - $tab[7]['massiveaction'] = false; - $tab[7]['datatype'] = 'specific'; - $tab[7]['searchtype'] = ['contains', 'equals', 'notequals']; + $tab[] = [ + 'id' => '7', + 'table' => $this->getTable(), + 'field' => 'itemtype', + 'name' => __('Item type'), + 'massiveaction' => false, + 'datatype' => 'specific', + 'searchtype' => [ + '0' => 'contains', + '1' => 'equals', + '2' => 'notequals' + ] + ]; - $tab[8]['table'] = self::getTable(); - $tab[8]['field'] = 'items_id'; - $tab[8]['name'] = __('Item', 'processmaker'); - $tab[8]['massiveaction'] = false; - $tab[8]['datatype'] = 'specific'; - $tab[8]['additionalfields'] = ['itemtype']; + $tab[] = [ + 'id' => '8', + 'table' => $this->getTable(), + 'field' => 'items_id', + 'name' => __('Item'), + 'massiveaction' => false, + 'datatype' => 'specific', + 'additionalfields' => [ + '0' => 'itemtype' + ] + ]; - $tab[9]['table'] = Entity::getTable(); - $tab[9]['field'] = 'name'; - $tab[9]['name'] = __('Item entity', 'processmaker'); - $tab[9]['massiveaction'] = false; - $tab[9]['datatype'] = 'itemlink'; + $tab[] = [ + 'id' => '9', + 'table' => 'glpi_entities', + 'field' => 'name', + 'name' => __('Item entity', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'itemlink' + ]; - $tab[10]['table'] = self::getTable(); - $tab[10]['field'] = 'case_status'; - $tab[10]['name'] = __('Status', 'processmaker'); - $tab[10]['datatype'] = 'specific'; - $tab[10]['searchtype'] = ['contains', 'equals', 'notequals']; - $tab[10]['massiveaction'] = false; + $tab[] = [ + 'id' => '10', + 'table' => $this->getTable(), + 'field' => 'case_status', + 'name' => __('Status'), + 'datatype' => 'specific', + 'searchtype' => [ + '0' => 'contains', + '1' => 'equals', + '2' => 'notequals' + ], + 'massiveaction' => false + ]; - $tab[14]['table'] = self::getTable(); - $tab[14]['field'] = 'plugin_processmaker_cases_id'; - $tab[14]['name'] = __('Sub-case of', 'processmaker'); - $tab[14]['datatype'] = 'specific'; - //$tab[14]['searchtype'] = ['contains', 'equals', 'notequals']; - $tab[14]['massiveaction'] = false; - $tab[14]['nosearch'] = true; + $tab[] = [ + 'id' => '14', + 'table' => $this->getTable(), + 'field' => 'plugin_processmaker_cases_id', + 'name' => __('Sub-case of', 'processmaker'), + 'datatype' => 'specific', + 'massiveaction' => false, + 'nosearch' => true + ]; - $tab[16]['table'] = self::getTable(); - $tab[16]['field'] = 'id'; - $tab[16]['name'] = __('Creation date', 'processmaker'); - $tab[16]['datatype'] = 'specific'; - //$tab[16]['searchtype'] = ['contains', 'equals', 'notequals']; - $tab[16]['massiveaction'] = false; - $tab[16]['nosearch'] = true; - $tab[16]['processmaker_cases'] = 'creation_date'; + $tab[] = [ + 'id' => '16', + 'table' => $this->getTable(), + 'field' => 'id', + 'name' => __('Creation date'), + 'datatype' => 'specific', + 'massiveaction' => false, + 'nosearch' => true, + 'processmaker_cases' => 'creation_date' + ]; - $tab[18]['table'] = self::getTable(); - $tab[18]['field'] = 'id'; - $tab[18]['name'] = __('Last update date', 'processmaker'); - $tab[18]['datatype'] = 'specific'; - // $tab[18]['searchtype'] = ['contains', 'equals', 'notequals']; - $tab[18]['massiveaction'] = false; - $tab[18]['nosearch'] = true; - $tab[18]['processmaker_cases'] = 'update_date'; + $tab[] = [ + 'id' => '18', + 'table' => $this->getTable(), + 'field' => 'id', + 'name' => __('Last update'), + 'datatype' => 'specific', + 'massiveaction' => false, + 'nosearch' => true, + 'processmaker_cases' => 'update_date' + ]; return $tab; } function showForm ($ID, $options = ['candel'=>false]) { - //global $DB, $CFG_GLPI, $LANG; + $options['colspan'] = 6; + $options['formtitle'] = sprintf( __('Case status is \'%s\'', 'processmaker'), self::getStatus($this->fields['case_status'])); - $options['candel'] = true; - - $this->initForm($ID, $options); $this->showFormHeader($options); - //echo ""; - //echo "".__("Name").""; - //echo ""; - //echo ""; + $process = new PluginProcessmakerProcess; + $process->getFromDB($this->fields['plugin_processmaker_processes_id']); - //echo ""; - //echo "".__("Active").""; - //Dropdown::showYesNo("is_active", $this->fields["is_active"]); - //echo ""; + if ($process->fields['maintenance']) { + PluginProcessmakerProcess::showUnderMaintenance($process->fields['name'], 'small'); + } + self::showCaseInfoTab($this); - //echo ""; - //echo "".__("External data").""; - //Dropdown::showYesNo("is_externaldata", $this->fields["is_externaldata"]); - //echo ""; + //echo '
' ; - //echo ""; - //echo "".__("Self").""; - //Dropdown::showYesNo("is_self", $this->fields["is_self"]); - //echo ""; - - //echo ""; - //echo "".__("Source task GUID").""; - ////PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_source', - //// 'display_emptychoice' => false, - //// 'value' => $this->fields['plugin_processmaker_taskcategories_id_source'])); - //echo ""; - //echo ""; - - //echo ""; - //echo "".__("Target task GUID").""; - ////PluginProcessmakerTaskCategory::dropdown(array('name' => 'plugin_processmaker_taskcategories_id_target', - //// 'display_emptychoice' => false, - //// 'value' => $this->fields['plugin_processmaker_taskcategories_id_target'])); - //echo ""; - //echo ""; - - //echo ""; - //echo "".__("Target process GUID").""; - ////Dropdown::show( 'PluginProcessmakerProcess', array('name' => 'plugin_processmaker_processes_id', - //// 'display_emptychoice' => true, - //// 'value' => $this->fields['plugin_processmaker_processes_id'], - //// 'condition' => 'is_active = 1')); - //echo ""; - //echo ""; - - //echo ""; - //echo "".__("Target dynaform GUID").""; - //echo ""; - //echo ""; - - //echo ""; - //echo "".__("Source condition").""; - ////echo ""; - //echo ""; - //echo ""; - - //echo ""; - //echo "".__("Claim target task").""; - //Dropdown::showYesNo("is_targettoclaim", $this->fields["is_targettoclaim"]); - //echo ""; - - //echo ""; - //echo "".__("External application JSON config").""; - //echo ""; - //echo ""; - - $this->showFormButtons($options ); + Html::closeForm(); + $options['candel'] = true; + $this->showFormButtons($options); + echo Html::scriptBlock(" + $('#tabsbody th').css('text-align', 'center'); + $('#tabsbody td').css('text-align', 'center'); + "); } @@ -1271,21 +1287,31 @@ class PluginProcessmakerCase extends CommonDBTM { */ function defineTabs($options = []) { - // $ong = array('empty' => $this->getTypeName(1)); + $process = new PluginProcessmakerProcess; + $process->getFromDB($this->fields['plugin_processmaker_processes_id']); + $ong = []; - //$this->addDefaultFormTab($ong); + if (self::isLayoutWithMain()) { + $this->addDefaultFormTab($ong); + } - $this->addStandardTab('PluginProcessmakerTask', $ong, $options); + if (!$process->fields['maintenance']) { + $this->addStandardTab('PluginProcessmakerTask', $ong, $options); + } - $this->addStandardTab(__CLASS__, $ong, $options); + if (!self::isLayoutWithMain()) { + $this->addStandardTab(__CLASS__, $ong, $options); + } - $this->addStandardTab('PluginProcessmakerCasemap', $ong, $options); + if (!$process->fields['maintenance']) { + $this->addStandardTab('PluginProcessmakerCasemap', $ong, $options); - $this->addStandardTab('PluginProcessmakerCasehistory', $ong, $options); + $this->addStandardTab('PluginProcessmakerCasehistory', $ong, $options); - $this->addStandardTab('PluginProcessmakerCasechangelog', $ong, $options); + $this->addStandardTab('PluginProcessmakerCasechangelog', $ong, $options); - $this->addStandardTab('PluginProcessmakerCasedynaform', $ong, $options); + $this->addStandardTab('PluginProcessmakerCasedynaform', $ong, $options); + } return $ong; } @@ -1311,7 +1337,9 @@ class PluginProcessmakerCase extends CommonDBTM { $ret = true; $dbu = new DbUtils; // then must delete any sub-processes (sub-cases) - foreach ($dbu->getAllDataFromTable(self::getTable(), "`plugin_processmaker_cases_id` = ".$this->getID()) as $row) { + $restrict = ["plugin_processmaker_cases_id" => $this->getID()]; + //foreach ($dbu->getAllDataFromTable(self::getTable(), "`plugin_processmaker_cases_id` = ".$this->getID()) as $row) { + foreach ($dbu->getAllDataFromTable(self::getTable(), $restrict) as $row) { $tmp = new self; $tmp->fields = $row; $ret &= $tmp->delete(['id' => $row['id']]); @@ -1332,4 +1360,5 @@ class PluginProcessmakerCase extends CommonDBTM { return $DB->query($query); } + } diff --git a/inc/casechangelog.class.php b/inc/casechangelog.class.php index 9d10ce7..34c73e9 100644 --- a/inc/casechangelog.class.php +++ b/inc/casechangelog.class.php @@ -10,13 +10,14 @@ */ class PluginProcessmakerCasechangelog extends CommonDBTM { - static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) { + static function displayTabContentForItem(CommonGLPI $case, $tabnum = 1, $withtemplate = 0) { global $CFG_GLPI, $PM_SOAP; $rand = rand(); $caseHistoryURL = $PM_SOAP->serverURL."/cases/ajaxListener?action=changeLogHistory&rand=$rand"; + $PM_SOAP->echoDomain(); echo ""; //?rand=$rand' $iframe = ""; - $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ; + $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); } - function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ + function getTabNameForItem(CommonGLPI $case, $withtemplate = 0) { return __('Change log', 'processmaker'); } -} \ No newline at end of file +} diff --git a/inc/casedynaform.class.php b/inc/casedynaform.class.php index e6d85f7..29d5a24 100644 --- a/inc/casedynaform.class.php +++ b/inc/casedynaform.class.php @@ -19,6 +19,7 @@ class PluginProcessmakerCasedynaform extends CommonDBTM { $proj = new PluginProcessmakerProcess; $proj->getFromDB($case->fields['plugin_processmaker_processes_id']); + $PM_SOAP->echoDomain(); echo ""; //?rand=$rand' echo ""; $iframe = ""; - $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ; + $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); } - function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ + function getTabNameForItem(CommonGLPI $case, $withtemplate = 0) { return __('History', 'processmaker'); } -} \ No newline at end of file +} diff --git a/inc/caselink.class.php b/inc/caselink.class.php index 00b341c..a7e011a 100644 --- a/inc/caselink.class.php +++ b/inc/caselink.class.php @@ -148,136 +148,127 @@ class PluginProcessmakerCaselink extends CommonDBTM { /** - * Summary of getSearchOptions + * Summary of rawSearchOptions * @return mixed */ - function getSearchOptions() { + function rawSearchOptions() { $tab = []; - $tab['common'] = __('ProcessMaker', 'processmaker'); + $tab[] = [ + 'id' => 'common', + 'name' => __('ProcessMaker', 'processmaker') + ]; - $tab[1]['table'] = $this->getTable(); - $tab[1]['field'] = 'name'; - $tab[1]['name'] = __('Name'); - $tab[1]['datatype'] = 'itemlink'; - $tab[1]['itemlink_type'] = $this->getType(); + $tab[] = [ + 'id' => '1', + 'table' => $this->getTable(), + 'field' => 'name', + 'name' => __('Name'), + 'datatype' => 'itemlink', + 'itemlink_type' => 'PluginProcessmakerCaselink', + 'massiveaction' => false + ]; - $tab[8]['table'] = $this->getTable(); - $tab[8]['field'] = 'is_active'; - $tab[8]['name'] = __('Active'); - $tab[8]['massiveaction'] = true; - $tab[8]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '8', + 'table' => $this->getTable(), + 'field' => 'is_active', + 'name' => __('Active'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[9]['table'] = $this->getTable(); - $tab[9]['field'] = 'date_mod'; - $tab[9]['name'] = __('Last update'); - $tab[9]['massiveaction'] = false; - $tab[9]['datatype'] = 'datetime'; + $tab[] = [ + 'id' => '9', + 'table' => $this->getTable(), + 'field' => 'date_mod', + 'name' => __('Last update'), + 'massiveaction' => false, + 'datatype' => 'datetime' + ]; - $tab[10]['table'] = $this->getTable(); - $tab[10]['field'] = 'is_externaldata'; - $tab[10]['name'] = __('External data', 'processmaker'); - $tab[10]['massiveaction'] = false; - $tab[10]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '10', + 'table' => $this->getTable(), + 'field' => 'is_externaldata', + 'name' => __('External data', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'bool' + ]; - $tab[11]['table'] = $this->getTable(); - $tab[11]['field'] = 'is_self'; - $tab[11]['name'] = __('Self', 'processmaker'); - $tab[11]['massiveaction'] = false; - $tab[11]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '11', + 'table' => $this->getTable(), + 'field' => 'is_self', + 'name' => __('Self', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'bool' + ]; - $tab[12]['table'] = $this->getTable(); - $tab[12]['field'] = 'is_targettoclaim'; - $tab[12]['name'] = __('Claim target task', 'processmaker'); - $tab[12]['massiveaction'] = false; - $tab[12]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '12', + 'table' => $this->getTable(), + 'field' => 'is_targettoclaim', + 'name' => __('Claim target task', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'bool' + ]; - $tab[13]['table'] = $this->getTable(); - $tab[13]['field'] = 'externalapplication'; - $tab[13]['name'] = __('External application JSON config', 'processmaker'); - $tab[13]['massiveaction'] = false; - $tab[13]['datatype'] = 'text'; + $tab[] = [ + 'id' => '13', + 'table' => $this->getTable(), + 'field' => 'externalapplication', + 'name' => __('External application JSON config', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[14]['table'] = $this->getTable(); - $tab[14]['field'] = 'sourcetask_guid'; - $tab[14]['name'] = __('Source task GUID', 'processmaker'); - $tab[14]['massiveaction'] = false; - $tab[14]['datatype'] = 'text'; + $tab[] = [ + 'id' => '14', + 'table' => $this->getTable(), + 'field' => 'sourcetask_guid', + 'name' => __('Source task GUID', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[15]['table'] = $this->getTable(); - $tab[15]['field'] = 'targettask_guid'; - $tab[15]['name'] = __('Target task GUID', 'processmaker'); - $tab[15]['massiveaction'] = false; - $tab[15]['datatype'] = 'text'; + $tab[] = [ + 'id' => '15', + 'table' => $this->getTable(), + 'field' => 'targettask_guid', + 'name' => __('Target task GUID', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[16]['table'] = $this->getTable(); - $tab[16]['field'] = 'targetdynaform_guid'; - $tab[16]['name'] = __('Target dynaform GUID', 'processmaker'); - $tab[16]['massiveaction'] = false; - $tab[16]['datatype'] = 'text'; + $tab[] = [ + 'id' => '16', + 'table' => $this->getTable(), + 'field' => 'targetdynaform_guid', + 'name' => __('Target dynaform GUID', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[17]['table'] = $this->getTable(); - $tab[17]['field'] = 'targetprocess_guid'; - $tab[17]['name'] = __('Target process GUID', 'processmaker'); - $tab[17]['massiveaction'] = false; - $tab[17]['datatype'] = 'text'; + $tab[] = [ + 'id' => '17', + 'table' => $this->getTable(), + 'field' => 'targetprocess_guid', + 'name' => __('Target process GUID', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[18]['table'] = $this->getTable(); - $tab[18]['field'] = 'sourcecondition'; - $tab[18]['name'] = __('Source condition', 'processmaker'); - $tab[18]['massiveaction'] = false; - $tab[18]['datatype'] = 'text'; - - //$tab[14]['table'] = 'glpi_taskcategories'; - //$tab[14]['field'] = 'completename'; //'plugin_processmaker_taskcategories_id_source'; - //$tab[14]['name'] = __('Source task'); - //$tab[14]['massiveaction'] = false; - //$tab[14]['datatype'] = 'dropdown'; - //$tab[14]['forcegroupby'] = true; - //$tab[14]['joinparams'] = - // [ - // 'beforejoin' => [ - // 'table' => 'glpi_plugin_processmaker_taskcategories', - // 'joinparams' => [ - // 'beforejoin' => [ - // 'table' => 'glpi_plugin_processmaker_caselinks' - // ] - // ] - // ] - // ]; + $tab[] = [ + 'id' => '18', + 'table' => $this->getTable(), + 'field' => 'sourcecondition', + 'name' => __('Source condition', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; return $tab; } - //static function getMenuContent() { - - // if (!Session::haveRight('entity', READ)) { - // return; - // } - - // $front_page = "/plugins/processmaker/front"; - // $menu = array(); - // //$menu['title'] = self::getMenuName(); - // //$menu['page'] = "$front_page/caselink.php"; - - // $itemtypes = array('PluginProcessmakerCaselink' => 'processmakercaselinks'); - - // foreach ($itemtypes as $itemtype => $option) { - // $menu['options'][$option]['title'] = $itemtype::getTypeName(Session::getPluralNumber()); - // switch( $itemtype ) { - // case 'PluginProcessmakerCaselink': - // $menu['options'][$option]['page'] = $itemtype::getSearchURL(false); - // $menu['options'][$option]['links']['search'] = $itemtype::getSearchURL(false); - // if ($itemtype::canCreate()) { - // $menu['options'][$option]['links']['add'] = $itemtype::getFormURL(false); - // } - // break ; - // default : - // $menu['options'][$option]['page'] = PluginProcessmakerCaselink::getSearchURL(false); - // break ; - // } - - // } - // return $menu; - //} } diff --git a/inc/caselinkaction.class.php b/inc/caselinkaction.class.php index bce380d..60f0eb8 100644 --- a/inc/caselinkaction.class.php +++ b/inc/caselinkaction.class.php @@ -9,4 +9,4 @@ * @author MoronO */ class PluginProcessmakerCaselinkaction extends CommonDBTM { -} \ No newline at end of file +} diff --git a/inc/casemap.class.php b/inc/casemap.class.php index 2b2c53a..4c268c0 100644 --- a/inc/casemap.class.php +++ b/inc/casemap.class.php @@ -10,7 +10,7 @@ */ class PluginProcessmakerCasemap extends CommonDBTM { - static function displayTabContentForItem(CommonGLPI $case, $tabnum=1, $withtemplate=0) { + static function displayTabContentForItem(CommonGLPI $case, $tabnum = 1, $withtemplate = 0) { global $CFG_GLPI, $PM_SOAP; $rand = rand(); @@ -26,6 +26,7 @@ class PluginProcessmakerCasemap extends CommonDBTM { "/cases/ajaxListener?action=processMap" )."&rand=$rand"; + $PM_SOAP->echoDomain(); echo ""; //?rand=$rand' $iframe = ""; - $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand) ; + $PM_SOAP->initCaseAndShowTab(['APP_UID' => $case->fields['case_guid'], 'DEL_INDEX' => 1], $iframe, $rand); } - function getTabNameForItem(CommonGLPI $case, $withtemplate = 0){ + function getTabNameForItem(CommonGLPI $case, $withtemplate = 0) { return __('Map', 'processmaker'); } -} \ No newline at end of file +} diff --git a/inc/config.class.php b/inc/config.class.php index 9520523..3ad759e 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -158,8 +158,9 @@ class PluginProcessmakerConfig extends CommonDBTM { echo ""; echo "".__('Server URL (must be in same domain than GLPI)', 'processmaker').""; echo ""; - echo ""; + echo "\n"; + echo ""; echo "".__('Common domain with GLPI', 'processmaker').""; echo "
".$config->fields['domain']."
"; @@ -315,24 +316,29 @@ class PluginProcessmakerConfig extends CommonDBTM { } else { echo "".__('Not connected'); } - echo "\n"; + + echo ""; + echo "" . __('Max cases per item (0=unlimited)', 'processmaker') . ""; + echo ""; + echo "\n"; + } else { echo ""; PluginProcessmakerProcessmaker::showUnderMaintenance(); echo ""; } - echo "".__('Maintenance').""; + echo "".__('Maintenance').""; - echo ""; - echo "".__('Maintenance mode').""; - Dropdown::showYesNo("maintenance", $config->fields['maintenance']); - echo ""; + echo ""; + echo "".__('Maintenance mode').""; + Dropdown::showYesNo("maintenance", $config->fields['maintenance']); + echo ""; - echo ""; + echo ""; - echo "".__('Processmaker system information', 'processmaker').""; + echo "".__('Processmaker system information', 'processmaker').""; if ($setup_ok) { $info = $PM_SOAP->systemInformation( ); echo ''.__('Version', 'processmaker').''.$info->version.''; @@ -347,7 +353,7 @@ class PluginProcessmakerConfig extends CommonDBTM { } else { echo ''.__('Version', 'processmaker').''.__('Not yet!', 'processmaker').''; } - $config->showFormButtons(['candel'=>false]); + $config->showFormButtons(['candel' => false]); return false; } diff --git a/inc/process.class.php b/inc/process.class.php index 8d8d3c6..ea2cbe3 100644 --- a/inc/process.class.php +++ b/inc/process.class.php @@ -44,6 +44,19 @@ class PluginProcessmakerProcess extends CommonDBTM { return false; } + + /** + * Get default values to search engine to override + **/ + static function getDefaultSearchRequest() { + + $search = ['sort' => 1, + 'order' => 'ASC']; + + return $search; + } + + /** * Summary of refreshTasks * will refresh (re-synch) all process task list @@ -93,7 +106,9 @@ class PluginProcessmakerProcess extends CommonDBTM { } $pmtask = new PluginProcessmakerTaskCategory; - $currentasksinprocess = $dbu->getAllDataFromTable($pmtask->getTable(), '`is_active` = 1 AND `plugin_processmaker_processes_id` = '.$this->getID()); + $restrict = ["is_active" => '1', 'plugin_processmaker_processes_id' => $this->getID()]; + //$currentasksinprocess = $dbu->getAllDataFromTable($pmtask->getTable(), '`is_active` = 1 AND `plugin_processmaker_processes_id` = '.$this->getID()); + $currentasksinprocess = $dbu->getAllDataFromTable($pmtask->getTable(), $restrict); $tasks=[]; foreach ($currentasksinprocess as $task) { $tasks[$task['pm_task_guid']] = $task; @@ -288,7 +303,9 @@ class PluginProcessmakerProcess extends CommonDBTM { $tmp->deleteByCriteria(['plugin_processmaker_processes_id' => $key]); // must delete any taskcategory and translations - $pmtaskcategories = $dbu->getAllDataFromTable( PluginProcessmakerTaskCategory::getTable(), "plugin_processmaker_processes_id = $key"); + $restrict = ["plugin_processmaker_processes_id" => $key]; + //$pmtaskcategories = $dbu->getAllDataFromTable( PluginProcessmakerTaskCategory::getTable(), "plugin_processmaker_processes_id = $key"); + $pmtaskcategories = $dbu->getAllDataFromTable( PluginProcessmakerTaskCategory::getTable(), $restrict ); foreach ($pmtaskcategories as $pmcat) { // delete taskcat $tmp = new TaskCategory; @@ -387,104 +404,162 @@ class PluginProcessmakerProcess extends CommonDBTM { /** - * Summary of getSearchOptions + * Summary of rawSearchOptions * @return mixed */ - function getSearchOptions() { + function rawSearchOptions() { $tab = []; - $tab['common'] = __('ProcessMaker', 'processmaker'); + $tab[] = [ + 'id' => 'common', + 'name' => __('ProcessMaker', 'processmaker') + ]; - $tab[1]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[1]['field'] = 'name'; - $tab[1]['name'] = __('Name'); - $tab[1]['datatype'] = 'itemlink'; - $tab[1]['itemlink_type'] = $this->getType(); + $tab[] = [ + 'id' => '1', + 'table' => $this->getTable(), + 'field' => 'name', + 'name' => __('Name'), + 'datatype' => 'itemlink', + 'itemlink_type' => 'PluginProcessmakerProcess', + 'massiveaction' => false + ]; - //$tab[7]['table'] = 'glpi_plugin_processmaker_processes'; - //$tab[7]['field'] = 'is_helpdeskvisible'; - //$tab[7]['name'] = $LANG['tracking'][39]; - //$tab[7]['massiveaction'] = true; - //$tab[7]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '8', + 'table' => $this->getTable(), + 'field' => 'is_active', + 'name' => __('Active'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[8]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[8]['field'] = 'is_active'; - $tab[8]['name'] = __('Active'); - $tab[8]['massiveaction'] = true; - $tab[8]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '4', + 'table' => $this->getTable(), + 'field' => 'comment', + 'name' => __('Comments'), + 'massiveaction' => true, + 'datatype' => 'text' + ]; - $tab[4]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[4]['field'] = 'comment'; - $tab[4]['name'] = __('Comments'); - $tab[4]['massiveaction'] = true; - $tab[4]['datatype'] = 'text'; + $tab[] = [ + 'id' => '9', + 'table' => $this->getTable(), + 'field' => 'date_mod', + 'name' => __('Last update'), + 'massiveaction' => false, + 'datatype' => 'datetime' + ]; - $tab[9]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[9]['field'] = 'date_mod'; - $tab[9]['name'] = __('Last update'); - $tab[9]['massiveaction'] = false; - $tab[9]['datatype'] = 'datetime'; + $tab[] = [ + 'id' => '10', + 'table' => $this->getTable(), + 'field' => 'process_guid', + 'name' => __('Process GUID', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'text' + ]; - $tab[10]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[10]['field'] = 'process_guid'; - $tab[10]['name'] = __('Process GUID', 'processmaker'); - $tab[10]['massiveaction'] = false; - $tab[10]['datatype'] = 'text'; + $tab[] = [ + 'id' => '11', + 'table' => $this->getTable(), + 'field' => 'project_type', + 'name' => __('Process type', 'processmaker'), + 'massiveaction' => false, + 'datatype' => 'specific' + ]; - $tab[11]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[11]['field'] = 'project_type'; - $tab[11]['name'] = __('Process type', 'processmaker'); - $tab[11]['massiveaction'] = false; - $tab[11]['datatype'] = 'specific'; + $tab[] = [ + 'id' => '12', + 'table' => $this->getTable(), + 'field' => 'hide_case_num_title', + 'name' => __('Hide case num. & title', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[12]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[12]['field'] = 'hide_case_num_title'; - $tab[12]['name'] = __('Hide case num. & title', 'processmaker'); - $tab[12]['massiveaction'] = true; - $tab[12]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '13', + 'table' => $this->getTable(), + 'field' => 'insert_task_comment', + 'name' => __('Insert Task Category', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[13]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[13]['field'] = 'insert_task_comment'; - $tab[13]['name'] = __('Insert Task Category', 'processmaker'); - $tab[13]['massiveaction'] = true; - $tab[13]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '14', + 'table' => 'glpi_itilcategories', + 'field' => 'completename', + 'name' => __('Category'), + 'datatype' => 'dropdown', + 'massiveaction' => false + ]; - $tab[14]['table'] = 'glpi_itilcategories'; - $tab[14]['field'] = 'completename'; - $tab[14]['name'] = __('Category'); - $tab[14]['datatype'] = 'dropdown'; - $tab[14]['massiveaction'] = false; + $tab[] = [ + 'id' => '15', + 'table' => $this->getTable(), + 'field' => 'type', + 'name' => __('Ticket type (self-service)', 'processmaker'), + 'searchtype' => 'equals', + 'datatype' => 'specific', + 'massiveaction' => false + ]; - $tab[15]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[15]['field'] = 'type'; - $tab[15]['name'] = __('Ticket type (self-service)', 'processmaker'); - $tab[15]['searchtype'] = 'equals'; - $tab[15]['datatype'] = 'specific'; - $tab[15]['massiveaction'] = false; + $tab[] = [ + 'id' => '16', + 'table' => $this->getTable(), + 'field' => 'is_incident', + 'name' => __('Visible in Incident for Central interface', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[16]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[16]['field'] = 'is_incident'; - $tab[16]['name'] = __('Visible in Incident for Central interface', 'processmaker'); - $tab[16]['massiveaction'] = true; - $tab[16]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '17', + 'table' => $this->getTable(), + 'field' => 'is_request', + 'name' => __('Visible in Request for Central interface', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[17]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[17]['field'] = 'is_request'; - $tab[17]['name'] = __('Visible in Request for Central interface', 'processmaker'); - $tab[17]['massiveaction'] = true; - $tab[17]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '18', + 'table' => $this->getTable(), + 'field' => 'is_change', + 'name' => __('Visible in Change', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[18]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[18]['field'] = 'is_change'; - $tab[18]['name'] = __('Visible in Change', 'processmaker'); - $tab[18]['massiveaction'] = true; - $tab[18]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '19', + 'table' => $this->getTable(), + 'field' => 'is_problem', + 'name' => __('Visible in Problem', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; - $tab[19]['table'] = 'glpi_plugin_processmaker_processes'; - $tab[19]['field'] = 'is_problem'; - $tab[19]['name'] = __('Visible in Problem', 'processmaker'); - $tab[19]['massiveaction'] = true; - $tab[19]['datatype'] = 'bool'; + $tab[] = [ + 'id' => '20', + 'table' => 'glpi_plugin_processmaker_processes', + 'field' => 'maintenance', + 'name' => __('Maintenance'), + 'massiveaction' => true, + 'datatype' => 'bool' + ]; + + $tab[] = [ + 'id' => '21', + 'table' => 'glpi_plugin_processmaker_processes', + 'field' => 'max_cases_per_item', + 'name' => __('Max cases per item (0=unlimited)', 'processmaker'), + 'massiveaction' => true, + 'datatype' => 'number' + ]; return $tab; } @@ -594,7 +669,7 @@ class PluginProcessmakerProcess extends CommonDBTM { echo ""; echo ""; - echo "".__("Active").""; + echo "".__('Active').""; Dropdown::showYesNo("is_active", $this->fields["is_active"]); echo ""; @@ -608,6 +683,11 @@ class PluginProcessmakerProcess extends CommonDBTM { Dropdown::showYesNo("insert_task_comment", $this->fields["insert_task_comment"]); echo ""; + echo ""; + echo "" . __('Max cases per item (0=unlimited)', 'processmaker') . ""; + echo ""; + echo "\n"; + echo ""; echo "".__('Visible in Incident for Central interface', 'processmaker').""; Dropdown::showYesNo("is_incident", $this->fields["is_incident"]); @@ -680,6 +760,15 @@ class PluginProcessmakerProcess extends CommonDBTM { Dropdown::showFromArray( 'project_type', self::getAllTypeArray(), [ 'value' => $this->fields["project_type"] ] ); echo ""; + echo ""; + echo "".__('Maintenance mode').""; + Dropdown::showYesNo("maintenance", $this->fields["maintenance"]); + if ($this->fields["maintenance"]) { + echo ""; + echo "Synchronize Task List"; + } + echo ""; + $this->showFormButtons($options); } @@ -801,5 +890,24 @@ class PluginProcessmakerProcess extends CommonDBTM { } + + /** + * Summary of underMaintenance + * Shows a nice(?) under maintenance message + */ + static function showUnderMaintenance($ptitle, $size = '') { + global $CFG_GLPI; + if ($size != '') { + $size .= '-'; + } + echo "
"; + + echo Html::image($CFG_GLPI['root_doc']."/plugins/processmaker/pics/{$size}under_maintenance.png"); + echo "

"; + echo sprintf(__('Process \'%s\' is under maintenance, please retry later, thank you.', 'processmaker'), $ptitle); + echo "

"; + echo "
"; + } + } diff --git a/inc/process_profile.class.php b/inc/process_profile.class.php index 25a4433..20990aa 100644 --- a/inc/process_profile.class.php +++ b/inc/process_profile.class.php @@ -170,9 +170,14 @@ class PluginProcessmakerProcess_Profile extends CommonDBTM */ function prepareInputForAdd($input) { $tmp = new self; - if ($tmp->getFromDBByQuery(" WHERE `plugin_processmaker_processes_id` = ".$input['plugin_processmaker_processes_id']." - AND `entities_id` = ".$input['entities_id']." - AND `profiles_id` = ".$input['profiles_id'])) { + $restrict=[ + 'WHERE' => [ + 'plugin_processmaker_processes_id' => $input['plugin_processmaker_processes_id'], + 'entities_id' => $input['entities_id'], + 'profiles_id' => $input['profiles_id'] + ], + ]; + if ($tmp->getFromDBByRequest($restrict)) { //// then update existing //$tmp->update(['id' => $tmp->getID(), // 'is_recursive' => $input['is_recursive']]); diff --git a/inc/processmaker.class.php b/inc/processmaker.class.php index 8777b24..732bb22 100644 --- a/inc/processmaker.class.php +++ b/inc/processmaker.class.php @@ -180,16 +180,22 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $this->taskWriter = $this->config->fields['users_id']; $this->pm_group_guid = $this->config->fields['pm_group_guid']; + //$cipher_list = openssl_get_cipher_methods(true); + $wsdl = $this->serverURL."/services/wsdl2"; $context['ssl'] = ['verify_peer_name' => $this->config->fields['ssl_verify'], // Verification of peer name 'verify_peer' => $this->config->fields['ssl_verify'], // Verification of SSL certificate used + //'ciphers' => 'RSA', ]; - $options = [ 'stream_context' => stream_context_create($context), - 'soap_version' => SOAP_1_2, - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, - //'proxy_host' => 'localhost', - //'proxy_port' => 8888 + $options = ['stream_context' => stream_context_create($context), + 'soap_version' => SOAP_1_2, + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, + 'keep_alive' => false, + //'trace' => true, + //'exceptions' => false, + //'proxy_host' => 'localhost', + //'proxy_port' => 8889 ]; $this->pmSoapClient = new SoapClient($wsdl, $options); @@ -246,7 +252,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $gusr = new User; if (is_numeric($admin_or_user)) { $gusr->getFromDB($admin_or_user); - } elseif ($admin_or_user !== false) { + } else if ($admin_or_user !== false) { $gusr->getFromDBbyName($admin_or_user); } else { $gusr->getFromDB(Session::getLoginUserID()); @@ -1440,18 +1446,35 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $caseInfo = $myProcessMaker->getCaseInfo( $parm->input['processmaker_caseguid'], $parm->input['processmaker_delindex']); $parm->input['name'] = $PM_DB->escape($caseInfo->caseName ); - $caseInitialDueDate = $myProcessMaker->getVariables( $parm->input['processmaker_caseguid'], [ 'GLPI_ITEM_TITLE', 'GLPI_ITEM_INITIAL_DUE_DATE' ]); - if (array_key_exists( 'GLPI_ITEM_INITIAL_DUE_DATE', $caseInitialDueDate )) { - $parm->input['time_to_resolve'] = $caseInitialDueDate[ 'GLPI_ITEM_INITIAL_DUE_DATE' ]." 23:59:59"; + $casegetvariables = ['GLPI_ITEM_TITLE', 'GLPI_ITEM_INITIAL_DUE_DATE', 'GLPI_ITEM_DUE_DATE']; + $caseresetvariables = []; + + $caseDueDate = $myProcessMaker->getVariables( $parm->input['processmaker_caseguid'], $casegetvariables); + if (array_key_exists('GLPI_ITEM_INITIAL_DUE_DATE', $caseDueDate)) { + $parm->input['time_to_resolve'] = $caseDueDate['GLPI_ITEM_INITIAL_DUE_DATE']; + $caseresetvariables['GLPI_ITEM_INITIAL_DUE_DATE'] = ''; } + if (array_key_exists( 'GLPI_ITEM_DUE_DATE', $caseDueDate )) { + $parm->input['time_to_resolve'] = $caseDueDate['GLPI_ITEM_DUE_DATE']; + $caseresetvariables['GLPI_ITEM_DUE_DATE'] = ''; + } + $re = '/^(?\'date\'[0-9]{4}-[0-1][0-9]-[0-3][0-9])( (?\'time\'[0-2][0-9]:[0-5][0-9]:[0-5][0-9]))*$/'; + if (preg_match($re, $parm->input['time_to_resolve'], $matches) && !array_key_exists('time', $matches)) { + $parm->input['time_to_resolve'] .= " 23:59:59"; + } + $txtItemTitle = $caseInfo->caseName; - if (array_key_exists( 'GLPI_ITEM_TITLE', $caseInitialDueDate )) { - $txtItemTitle = $caseInitialDueDate[ 'GLPI_ITEM_TITLE' ]; - // reset those variables - $resultSave = $myProcessMaker->sendVariables( $parm->input['processmaker_caseguid'], [ "GLPI_ITEM_TITLE" => ''] ); + if (array_key_exists( 'GLPI_ITEM_TITLE', $caseDueDate )) { + $txtItemTitle = $caseDueDate['GLPI_ITEM_TITLE']; + // reset item title case variable + $caseresetvariables['GLPI_ITEM_TITLE'] = ''; } $parm->input['name'] = $PM_DB->escape($txtItemTitle ); + if (count($caseresetvariables)) { + $resultSave = $myProcessMaker->sendVariables( $parm->input['processmaker_caseguid'], $caseresetvariables ); + } + $procDef = new PluginProcessmakerProcess; $procDef->getFromGUID( $caseInfo->processId ); if (isset($parm->input['type'])) { @@ -1465,6 +1488,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } } + + /** + * Summary of plugin_item_add_processmaker + * @param mixed $parm + * @return void + */ public static function plugin_item_add_processmaker($parm) { global $DB, $GLOBALS, $PM_SOAP; @@ -1493,74 +1522,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { // before routing, send items_id and itemtype // as this information was not available at case creation - $myCase->sendVariables( [ "GLPI_TICKET_ID" => $items_id ] ); + $myCase->sendVariables( [ "GLPI_TICKET_ID" => $items_id, + "GLPI_ITEM_ID" => $items_id, + "GLPI_ITEM_TYPE" => $itemtype, + ] ); - // route case - $pmRouteCaseResponse = $PM_SOAP->routeCase($case_guid, $parm->input['processmaker_delindex'] ); - - // gets new case status - $caseInfo = $myCase->getCaseInfo();//$parm->input['processmaker_delindex']); - // now manage tasks associated with item - // create new tasks - if (property_exists( $pmRouteCaseResponse, 'routing' )) { - // now tries to get some variables to setup content for new task and to append text to solved task - $txtForTasks = $myCase->getVariables( [ "GLPI_ITEM_APPEND_TO_TASK", - "GLPI_ITEM_SET_STATUS", - "GLPI_TICKET_FOLLOWUP_CONTENT", - "GLPI_TICKET_FOLLOWUP_IS_PRIVATE", - "GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" ] ); - $itemSetStatus = ''; - if (array_key_exists( 'GLPI_ITEM_SET_STATUS', $txtForTasks )) { - $itemSetStatus = $txtForTasks[ 'GLPI_ITEM_SET_STATUS' ]; - } - if (array_key_exists( 'GLPI_ITEM_APPEND_TO_TASK', $txtForTasks )) { - $txtToAppendToTask = $txtForTasks[ 'GLPI_ITEM_APPEND_TO_TASK' ]; - } else { - $txtToAppendToTask = ''; - } - $createFollowup = false; // by default - if (array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $txtForTasks ) && $txtForTasks[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') { - $createFollowup = true; - } - - // reset those variables - $resultSave = $myCase->sendVariables( [ "GLPI_ITEM_APPEND_TO_TASK" => '', - "GLPI_ITEM_SET_STATUS" => '', - "GLPI_TICKET_FOLLOWUP_CONTENT" => '', - "GLPI_TICKET_FOLLOWUP_IS_PRIVATE" => '', - "GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" => '' ] ); - - // routing has been done, then solve 1st task - $PM_SOAP->solveTask($myCase->getID(), $parm->input['processmaker_delindex'], [ 'txtToAppend' => $txtToAppendToTask, 'notif' => false] ); - - // create a followup if requested - if ($createFollowup && $itemtype == 'Ticket') { - $PM_SOAP->addTicketFollowup( $items_id, $txtForTasks ); - } - - // and create GLPI tasks for the newly created PM tasks. - foreach ($pmRouteCaseResponse->routing as $route) { - $PM_SOAP->addTask( $myCase->getID(), - $myCase->fields['itemtype'], - $myCase->fields['items_id'], - $caseInfo, - $route->delIndex, - PluginProcessmakerUser::getGLPIUserId( $route->userId ), - 0, - $route->taskId, - $route->delThread ); - } - - if ($itemSetStatus != '') { - $PM_SOAP->setItemStatus($myCase->fields['itemtype'], $myCase->fields['items_id'], $itemSetStatus ); - } - } - - // evolution of case status: DRAFT, TO_DO, COMPLETED, CANCELLED - $myCase->update( ['id' => $myCase->getID(), - 'case_status' => $caseInfo->caseStatus, - 'name' => $caseInfo->caseName - ]); + $PM_SOAP->derivateCase($myCase, ['DEL_INDEX' => $parm->input['processmaker_delindex']]); } else {//if( array_key_exists('_head', $parm->input) ) { // this ticket have been created via email receiver. $ptnProcessToStart = "/##TicketProcess:\s*#([0-9a-f]{32})\s*##/i"; @@ -1657,13 +1624,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { */ public function addTask($cases_id, $itemtype, $items_id, $caseInfo, $delIndex, $techId, $groupId, $pmTaskId, $delThread, $options = []) { global $DB, $PM_DB, $_SESSION; + $dbu = new DbUtils; + $default_options = [ 'txtTaskContent' => '', 'start_date' => '', 'end_date' => '', + 'reminder' => '', 'notif' => true ]; + foreach ($default_options as $key => $opt) { if (!isset($options[$key])) { $options[$key] = $opt; @@ -1710,7 +1681,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $input['users_id'] = $this->taskWriter; // manage groups - if ($techId == 0) { // then we must look-up DB to get the pseudo-group that will be assigned to the task + if ($techId == 0) { // then we must look-up DB to get the group that will be assigned to the task $groupname=''; if ($groupId == 0) { $query = "SELECT CONTENT.CON_VALUE FROM TASK_USER @@ -1766,13 +1737,21 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $input['groups_id_tech'] = $groups_id_tech; } + if ($options['reminder'] != '' && $techId) { + $input['_planningrecall'] = ['before_time' => $options['reminder'], + 'itemtype' => get_class($glpi_task), + 'items_id' => '', + 'users_id' => $techId, + 'field' => 'begin']; + } + $donotif = self::saveNotification(false); // do not send notification yet as the PluginProcessmakerTask is not yet added to DB $glpi_task->add( Toolbox::addslashes_deep( $input ) ); self::restoreNotification($donotif); // to prevent error message for overlapping planning - if (isset($_SESSION["MESSAGE_AFTER_REDIRECT"][ERROR])) { - unset($_SESSION["MESSAGE_AFTER_REDIRECT"][ERROR]); + if (isset($_SESSION["MESSAGE_AFTER_REDIRECT"][WARNING])) { + unset($_SESSION["MESSAGE_AFTER_REDIRECT"][WARNING]); } if ($glpi_task->getId() > 0) { @@ -1892,6 +1871,21 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } + /** + * Summary of setItemDuedate + * @param mixed $itemtype + * @param mixed $itemId + * @param mixed $duedate + */ + public function setItemDuedate($itemtype, $itemId, $duedate) { + $dbu = new DbUtils; + $item = $dbu->getItemForItemtype( $itemtype ); + if ($item->getFromDB( $itemId )) { + $item->update( ['id' => $itemId, 'time_to_resolve' => $duedate] ); + } + } + + /** * Summary of setItemSolution * @param mixed $itemType @@ -2384,25 +2378,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { /** * Summary of saveForm * This function posts dynaform variables to PM, using the CURL module. - * @param mixed $request: is the $_REQUEST server array + * @param array $request: is the $_REQUEST server array * //@param string $cookie: is the $_SERVER['HTTP_COOKIE'] string * @return mixed: returns false if request failed, otherwise, returns true */ public function saveForm($request) { - //, $cookie ) { - //if (!function_exists( 'HandleHeaderLine' )) { - // function HandleHeaderLine( $curl, $header_line ) { - // //global $cookies; - // $temp = explode( ": ", $header_line ); - // if (is_array( $temp ) && $temp[0] == 'Set-Cookie') { - // $temp2 = explode( "; ", $temp[1]); - // //$cookies .= $temp2[0].'; ' ; - // curl_setopt($curl, CURLOPT_COOKIE, $temp2[0]."; " ); - // } - // return strlen($header_line); - // } - //} $loggable = false; $request = stripcslashes_deep( $request ); @@ -2411,7 +2392,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { //to be able to trace network traffic with a local proxy // curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ); // curl_setopt($ch, CURLOPT_PROXY, "localhost:8888"); - // curl_setopt($ch, CURLOPT_PROXY, "fry07689.fr.ray.group:8889"); //curl_setopt($ch, CURLINFO_HEADER_OUT, 1); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); @@ -2423,7 +2403,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->config->fields['ssl_verify']); //curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine"); - // to stock cookies in memory + // to store cookies in memory // ( replace HandleHeaderLine function ) curl_setopt($ch, CURLOPT_COOKIEFILE, ""); @@ -2441,24 +2421,24 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { // check if any files are in the $_FILES global array // and add them to the curl POST $fileForm = $_FILES['form']['name']; - if( !empty($fileForm[array_keys($fileForm)[0]][1][array_keys($fileForm[array_keys($fileForm)[0]][1])[0]]) ){ + if (!empty($fileForm[array_keys($fileForm)[0]][1][array_keys($fileForm[array_keys($fileForm)[0]][1])[0]])) { foreach ($_FILES['form']['name'] as $key => $file) { if (is_array($file)) { // it's a grid which contains documents foreach ($file as $row => $col) { - foreach($col as $control => $filename) { - $cfile = new CURLFile($_FILES['form']['tmp_name'][$key][$row][$control], $_FILES['form']['type'][$key][$row][$control],$_FILES['form']['name'][$key][$row][$control]); + foreach ($col as $control => $filename) { + $cfile = new CURLFile($_FILES['form']['tmp_name'][$key][$row][$control], $_FILES['form']['type'][$key][$row][$control], $_FILES['form']['name'][$key][$row][$control]); $data["form[$key][$row][$control]"] = $cfile; } } } else { - $cfile = new CURLFile($_FILES['form']['tmp_name'][$key], $_FILES['form']['type'][$key],$_FILES['form']['name'][$key]); + $cfile = new CURLFile($_FILES['form']['tmp_name'][$key], $_FILES['form']['type'][$key], $_FILES['form']['name'][$key]); $data["form[$key]"] = $cfile; } } } // to get all cookies in one variable - $cookies = curl_getinfo($ch, CURLINFO_COOKIELIST); + //$cookies = curl_getinfo($ch, CURLINFO_COOKIELIST); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Expect:"]); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // inject POST values // add agent and referer params @@ -2477,10 +2457,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } return ($response ? true : false); - - //$n = preg_match("/HTTP\/1.1 302 /", $response, $matches); - - //return ($n < 1 ? false : true) ; } /** @@ -2548,14 +2524,21 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { public static function plugin_item_get_data_processmaker($item) { global $_SESSION, $CFG_GLPI; if (isset( $item->data ) && isset( $item->data['tasks'] )) { + $pmtask = new PluginProcessmakerTask($pmtask_itemtype); foreach ($item->data['tasks'] as &$task) { $pmtask_itemtype = $item->obj->getType().'Task'; $pmtask_items_id = $task['##task.id##']; // for each task, we must check if it is in our task table // and if yes, then process the content - $pmtask = new PluginProcessmakerTask($pmtask_itemtype); - if ($pmtask->getFromDBByQuery("WHERE itemtype = '$pmtask_itemtype' AND items_id = $pmtask_items_id")) { + $restrict=[ + 'WHERE' => [ + 'itemtype' => $pmtask_itemtype, + 'items_id' => $pmtask_items_id + ], + ]; + //if ($pmtask->getFromDBByQuery("WHERE itemtype = '$pmtask_itemtype' AND items_id = $pmtask_items_id")) { + if ($pmtask->getFromDBByRequest($restrict)) { if (!in_array("tasks", $item->html_tags)) { $item->html_tags[] = "tasks"; // to force GLPI to keep the below HTML tags, otherwise it will apply a Html::entities_deep() to the task.description @@ -2564,7 +2547,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $task['##task.description##'] = str_replace( '##processmaker.taskcomment##', $task['##task.categorycomment##'], $task['##task.description##'] ); $task['##task.description##'] = Html::nl2br_deep($task['##task.description##']); - $pmtask->getFromDBByQuery("WHERE itemtype = '$pmtask_itemtype' AND items_id = $pmtask_items_id"); + //$restrict=[ + // 'WHERE' => [ + // 'itemtype' => $pmtask_itemtype, + // 'items_id' => $pmtask_items_id + // ], + // ]; + //$pmtask->getFromDBByRequest($restrict); //$caseurl = urldecode($CFG_GLPI["url_base"]."/index.php?redirect=PluginProcessmakerCase_".$pmtask->fields['plugin_processmaker_cases_id']); $caseurl = $CFG_GLPI["url_base"]."/index.php?redirect=".urlencode("/plugins/processmaker/front/case.form.php?id=".$pmtask->fields['plugin_processmaker_cases_id']); @@ -2598,7 +2587,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { if (in_array( $config->fields['taskcategories_id'], $ancestors)) { $loc_completename = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'completename', $_SESSION['glpilanguage'], $taskCat->fields['completename'] ); $loc_comment = DropdownTranslation::getTranslatedValue( $taskCat->getID(), 'TaskCategory', 'comment', $_SESSION['glpilanguage'], $taskCat->fields['comment'] ); - $item->datas['content'] = $loc_completename."\n\n".str_replace( "##processmaker.taskcomment##\n##processmakercase.url##", $loc_comment, $item->datas['content']); + $item->datas['content'] = $loc_completename."\n\n".str_replace( "##processmaker.taskcomment##", $loc_comment, $item->datas['content']); + $item->datas['content'] = str_replace( "##processmakercase.url##", '', $item->datas['content']); } // restore default translations if (isset( $trans )) { @@ -2642,15 +2632,15 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { /** * Summary of startNewCase * @param mixed $processes_id integer: GLPI process id - * @param mixed $itemType string: item type 'Ticket', 'Change' or 'Problem' + * @param mixed $itemtype string: item type 'Ticket', 'Change' or 'Problem' * @param mixed $items_id integer: id to thte item * @param mixed $users_id integer: GLPI user id * @return mixed */ - public function startNewCase($processes_id, $itemType, $items_id, $users_id = null) { + public function startNewCase($processes_id, $itemtype, $items_id, $users_id = null) { global $DB, $CFG_GLPI; - $requesters = PluginProcessmakerProcessmaker::getItemUsers( $itemType, $items_id, CommonITILActor::REQUESTER); // 1 for requesters + $requesters = PluginProcessmakerProcessmaker::getItemUsers( $itemtype, $items_id, CommonITILActor::REQUESTER); // 1 for requesters if (!key_exists( 0, $requesters )) { $requesters[0]['glpi_id'] = 0; $requesters[0]['pm_id'] = 0; @@ -2664,67 +2654,72 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { //} // get item info to retreive title, description and duedate - $locItem = new $itemType; // $_POST['itemtype'] ; //Ticket(); - $locItem->getFromDB( $items_id ); // $_POST['id'] ) ; + $item = new $itemtype; + $item->getFromDB( $items_id ); - if ($locItem->countUsers(CommonITILActor::ASSIGN) == 0 - || !$locItem->isUser(CommonITILActor::ASSIGN, $users_id) ) { - $locItem->update( [ 'id' => $items_id, '_itil_assign' => [ '_type' => 'user', 'users_id' => $users_id ] ] ); + if ($item->countUsers(CommonITILActor::ASSIGN) == 0 + || !$item->isUser(CommonITILActor::ASSIGN, $users_id) ) { + $item->update( [ 'id' => $items_id, '_itil_assign' => [ '_type' => 'user', 'users_id' => $users_id ] ] ); } - if (!isset($locItem->fields['time_to_resolve']) || $locItem->fields['time_to_resolve'] == null) { - $locItem->fields['time_to_resolve'] = ""; + if (!isset($item->fields['time_to_resolve']) || $item->fields['time_to_resolve'] == null) { + $item->fields['time_to_resolve'] = ""; } $resultCase = $this->newCase( $processes_id, - ['GLPI_ITEM_CAN_BE_SOLVED' => 0, - 'GLPI_TICKET_ID' => $items_id, - 'GLPI_ITEM_ID' => $items_id, - 'GLPI_ITEM_TYPE' => $itemType, - 'GLPI_TICKET_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], - 'GLPI_ITEM_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], - 'GLPI_TICKET_REQUESTER_PM_ID' => $requesters[0]['pm_id'], - 'GLPI_ITEM_REQUESTER_PM_ID' => $requesters[0]['pm_id'], - 'GLPI_TICKET_TITLE' => $locItem->fields['name'], - 'GLPI_ITEM_TITLE' => $locItem->fields['name'], - 'GLPI_TICKET_DESCRIPTION' => $locItem->fields['content'], - 'GLPI_ITEM_DESCRIPTION' => $locItem->fields['content'], - 'GLPI_TICKET_DUE_DATE' => $locItem->fields['time_to_resolve'], - 'GLPI_ITEM_OPENING_DATE' => $locItem->fields['date'], - 'GLPI_ITEM_DUE_DATE' => $locItem->fields['time_to_resolve'], - 'GLPI_ITEM_ITIL_CATEGORY_ID' => $locItem->fields['itilcategories_id'], - 'GLPI_TICKET_URGENCY' => $locItem->fields['urgency'], - 'GLPI_ITEM_URGENCY' => $locItem->fields['urgency'], - 'GLPI_ITEM_IMPACT' => $locItem->fields['impact'], - 'GLPI_ITEM_PRIORITY' => $locItem->fields['priority'], - 'GLPI_TICKET_GLOBAL_VALIDATION' => $locItem->fields['global_validation'] , - 'GLPI_Ticket_TYPE' => $locItem->fields['type'] , - 'GLPI_TICKET_STATUS' => $locItem->fields['status'] , - 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $users_id, - 'GLPI_ITEM_TECHNICIAN_GLPI_ID' => $users_id, - 'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), - 'GLPI_ITEM_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), - 'GLPI_URL' => $CFG_GLPI['url_base'] - ] ); + ['GLPI_ITEM_CAN_BE_SOLVED' => 0, + 'GLPI_TICKET_ID' => $items_id, + 'GLPI_ITEM_ID' => $items_id, + 'GLPI_ITEM_TYPE' => $itemtype, + 'GLPI_ITEM_STATUS' => $item->fields['status'], + 'GLPI_TICKET_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], + 'GLPI_ITEM_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], + 'GLPI_TICKET_REQUESTER_PM_ID' => $requesters[0]['pm_id'], + 'GLPI_ITEM_REQUESTER_PM_ID' => $requesters[0]['pm_id'], + 'GLPI_TICKET_TITLE' => $item->fields['name'], + 'GLPI_ITEM_TITLE' => $item->fields['name'], + 'GLPI_TICKET_DESCRIPTION' => $item->fields['content'], + 'GLPI_ITEM_DESCRIPTION' => $item->fields['content'], + 'GLPI_ITEM_OPENING_DATE' => $item->fields['date'], + 'GLPI_TICKET_DUE_DATE' => $item->fields['time_to_resolve'], + 'GLPI_ITEM_DUE_DATE' => $item->fields['time_to_resolve'], + 'GLPI_ITEM_ITIL_CATEGORY_ID' => $item->fields['itilcategories_id'], + 'GLPI_TICKET_URGENCY' => $item->fields['urgency'], + 'GLPI_ITEM_URGENCY' => $item->fields['urgency'], + 'GLPI_ITEM_IMPACT' => $item->fields['impact'], + 'GLPI_ITEM_PRIORITY' => $item->fields['priority'], + // Specific to Tickets and Changes + // GLPI_ITEM_GLOBAL_VALIDATION will be '' when Problem, else it will be the global_validation field + 'GLPI_TICKET_GLOBAL_VALIDATION' => $itemtype == 'Problem' ? '' : $item->fields['global_validation'], + 'GLPI_ITEM_GLOBAL_VALIDATION' => $itemtype == 'Problem' ? '' : $item->fields['global_validation'], + 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $users_id, + 'GLPI_ITEM_TECHNICIAN_GLPI_ID' => $users_id, + 'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), + 'GLPI_ITEM_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), + 'GLPI_URL' => $CFG_GLPI['url_base'], + // Specific to Tickets + // GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request), or '' if itemtype is not Ticket + 'GLPI_TICKET_TYPE' => $itemtype == 'Ticket' ? $item->fields['type'] : '' + ]); if ($resultCase->status_code === 0) { $caseInfo = $this->getCaseInfo( $resultCase->caseId ); // save info to DB $locCase = new PluginProcessmakerCase; - $locCase->add( ['id' => $resultCase->caseNumber, - 'itemtype' => $itemType, - 'items_id' => $items_id, - 'case_guid' => $resultCase->caseId, - 'case_status' => $caseInfo->caseStatus, - 'name' => $caseInfo->caseName, - 'entities_id' => $locItem->fields['entities_id'], + $locCase->add( ['id' => $resultCase->caseNumber, + 'itemtype' => $itemtype, + 'items_id' => $items_id, + 'case_guid' => $resultCase->caseId, + 'case_status' => $caseInfo->caseStatus, + 'name' => $caseInfo->caseName, + 'entities_id' => $item->fields['entities_id'], 'plugin_processmaker_processes_id' => $processes_id, - 'plugin_processmaker_cases_id' => 0 + 'plugin_processmaker_cases_id' => 0 ], [], true ); - $this->add1stTask($locCase->getID(), $itemType, $items_id, $caseInfo, ['userId' => $users_id] ); + $this->add1stTask($locCase->getID(), $itemtype, $items_id, $caseInfo, ['userId' => $users_id] ); } return $resultCase; @@ -2750,64 +2745,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $item->getFromDB($items_id); // save the dynaform variables into the current case - $resultSave = $this->saveForm( $request ); + if (isset($request['UID']) && isset($request['APP_UID']) && isset($request['__DynaformName__'])) { + $resultSave = $this->saveForm( $request ); + } // now derivate the case !!! $pmRouteCaseResponse = $this->routeCase($myCase->fields['case_guid'], $request['DEL_INDEX']); - //if (property_exists($pmRouteCaseResponse, 'routing')) { - // // must check if case has started a sub-process - // // we may have several new cases for this case - // // must check if all child cases are existing in GLPI - // $locTaskCat = new PluginProcessmakerTaskCategory; - // foreach($pmRouteCaseResponse->routing as $route) { - // if ($locTaskCat->getFromGUID($route->taskId) && $locTaskCat->fields['is_subprocess']) { - // // look for APP_UID - // foreach($PM_DB->request("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$myCase->fields['case_guid']}' AND DEL_INDEX_PARENT={$route->delIndex} AND DEL_THREAD_PARENT={$route->delThread} AND SA_STATUS='ACTIVE'") as $subCase) { - // // normally only one case for this delIndex and delThread - // // now need to get the PRO_UID - // $sub_caseInfo = self::getCaseInfo($subCase['APP_UID']); - - // $locProc = new PluginProcessmakerProcess; - // $locProc->getFromGUID($sub_caseInfo->processId); - // $locCase = new PluginProcessmakerCase; - // $locCase->add(['id' => $sub_caseInfo->caseNumber, - // 'case_guid'=> $sub_caseInfo->caseId, - // 'itemtype' => $itemtype, - // 'items_id' => $items_id, - // 'name' => $sub_caseInfo->caseName, - // 'entities_id' => $item->fields['entities_id'], - // 'case_status' => $sub_caseInfo->caseStatus, - // 'plugin_processmaker_processes_id' => $locProc->getID(), - // 'plugin_processmaker_cases_id' => $myCase->getID()]); - - // // then create associated task - // if (property_exists( $sub_caseInfo, 'currentUsers' )) { - // foreach ($sub_caseInfo->currentUsers as $sub_route) { - // $this->addTask($locCase->getID(), $itemtype, - // $items_id, - // $sub_caseInfo, - // $sub_route->delIndex, - // PluginProcessmakerUser::getGLPIUserId($sub_route->userId), - // 0, - // $sub_route->taskId, - // $sub_route->delThread, - // [] - // //array( 'txtTaskContent' => $txtTaskContent, - // // 'start_date' => $taskStartDate, - // // 'end_date' => $taskEndDate) - // ); - - // } - // } - - // } - - // } - // } - - //} - $casevariables = ["GLPI_ITEM_TASK_CONTENT", "GLPI_ITEM_APPEND_TO_TASK", "GLPI_NEXT_GROUP_TO_BE_ASSIGNED", @@ -2817,13 +2761,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { "GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID", "GLPI_ITEM_TASK_ENDDATE", "GLPI_ITEM_TASK_STARTDATE", + "GLPI_ITEM_TASK_REMINDER", "GLPI_ITEM_SOLVED_TASK_ENDDATE", "GLPI_ITEM_SOLVED_TASK_STARTDATE", "GLPI_ITEM_SOLVED_TASK_SETINFO", "GLPI_ITEM_SET_STATUS", + "GLPI_ITEM_STATUS", "GLPI_ITEM_SET_SOLUTION_TEMPLATE_ID", "GLPI_ITEM_SET_SOLUTION_TYPE_ID", - "GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION" + "GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION", + "GLPI_ITEM_INITIAL_DUE_DATE", + "GLPI_ITEM_DUE_DATE" ]; // now tries to get some variables to setup content for new task and to append text to solved task @@ -2833,6 +2781,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { if (array_key_exists( 'GLPI_ITEM_SET_STATUS', $casevariablevalues )) { $itemSetStatus = $casevariablevalues[ 'GLPI_ITEM_SET_STATUS' ]; } + if (array_key_exists( 'GLPI_ITEM_STATUS', $casevariablevalues )) { + $itemSetStatus = $casevariablevalues[ 'GLPI_ITEM_STATUS' ]; + } $txtItemTitle = ''; if (array_key_exists( 'GLPI_ITEM_TITLE', $casevariablevalues )) { @@ -2867,6 +2818,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } } + $taskReminder = ''; + if (array_key_exists( 'GLPI_ITEM_TASK_REMINDER', $casevariablevalues )) { + $taskReminder = $casevariablevalues[ 'GLPI_ITEM_TASK_REMINDER' ]; + } + $solvedTaskStartDate = ''; $solvedTaskEndDate = ''; if (array_key_exists( 'GLPI_ITEM_SOLVED_TASK_ENDDATE', $casevariablevalues )) { @@ -2892,6 +2848,18 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $createFollowup = true; } + $item_duedate = ''; + if (array_key_exists('GLPI_ITEM_INITIAL_DUE_DATE', $casevariablevalues)) { + $item_duedate = $casevariablevalues['GLPI_ITEM_INITIAL_DUE_DATE']; + } + if (array_key_exists( 'GLPI_ITEM_DUE_DATE', $casevariablevalues )) { + $item_duedate = $casevariablevalues['GLPI_ITEM_DUE_DATE']; + } + $re = '/^(?\'date\'[0-9]{4}-[0-1][0-9]-[0-3][0-9])( (?\'time\'[0-2][0-9]:[0-5][0-9]:[0-5][0-9]))*$/'; + if (preg_match($re, $item_duedate, $matches) && !array_key_exists('time', $matches)) { + $item_duedate .= " 23:59:59"; + } + // reset those variables $resetcasevariables = []; foreach ($casevariables as $val) { @@ -2923,8 +2891,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $this->setItemTitle($itemtype, $items_id, $txtItemTitle); } - if ($itemSetStatus != '') { - $this->setItemStatus($itemtype, $items_id, $itemSetStatus ); + if ($item_duedate != '') { + // we are going to change the due date (time to resolve) of current GLPI Item + $this->setItemDuedate($itemtype, $items_id, $item_duedate); } if (array_key_exists( 'GLPI_ITEM_SET_SOLUTION_TEMPLATE_ID', $casevariablevalues ) @@ -2934,6 +2903,10 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $this->setItemSolution($itemtype, $items_id, $casevariablevalues); } + if ($itemSetStatus != '') { + $this->setItemStatus($itemtype, $items_id, $itemSetStatus ); + } + // get the new case info $caseInfo = $myCase->getCaseInfo($request['DEL_INDEX']); // not sure that it should passed this @@ -2981,8 +2954,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $sub_route->taskId, $sub_route->delThread, [ 'txtTaskContent' => $txtTaskContent, - 'start_date' => $taskStartDate, - 'end_date' => $taskEndDate] + 'start_date' => $taskStartDate, + 'end_date' => $taskEndDate, + 'reminder' => $taskReminder] ); // if end date was specified, then must change due date of the PM task @@ -3005,6 +2979,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { 'GLPI_TICKET_ID' => $items_id, 'GLPI_ITEM_ID' => $items_id, 'GLPI_ITEM_TYPE' => $itemtype, + 'GLPI_ITEM_STATUS' => $item->fields['status'], 'GLPI_TICKET_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], 'GLPI_ITEM_REQUESTER_GLPI_ID' => $requesters[0]['glpi_id'], 'GLPI_TICKET_REQUESTER_PM_ID' => $requesters[0]['pm_id'], @@ -3013,22 +2988,26 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { 'GLPI_ITEM_TITLE' => $item->fields['name'], 'GLPI_TICKET_DESCRIPTION' => $item->fields['content'], 'GLPI_ITEM_DESCRIPTION' => $item->fields['content'], - 'GLPI_TICKET_DUE_DATE' => $item->fields['time_to_resolve'], 'GLPI_ITEM_OPENING_DATE' => $item->fields['date'], + 'GLPI_TICKET_DUE_DATE' => $item->fields['time_to_resolve'], 'GLPI_ITEM_DUE_DATE' => $item->fields['time_to_resolve'], 'GLPI_ITEM_ITIL_CATEGORY_ID' => $item->fields['itilcategories_id'], 'GLPI_TICKET_URGENCY' => $item->fields['urgency'], 'GLPI_ITEM_URGENCY' => $item->fields['urgency'], 'GLPI_ITEM_IMPACT' => $item->fields['impact'], 'GLPI_ITEM_PRIORITY' => $item->fields['priority'], - 'GLPI_TICKET_GLOBAL_VALIDATION' => $item->fields['global_validation'] , - 'GLPI_Ticket_TYPE' => $locItem->fields['type'] , - 'GLPI_TICKET_STATUS' => $locItem->fields['status'] , + // Specific to Tickets and Changes + // GLPI_ITEM_GLOBAL_VALIDATION will be '' when Problem, else it will be the global_validation field + 'GLPI_TICKET_GLOBAL_VALIDATION' => $itemtype == 'Problem' ? '' : $item->fields['global_validation'], + 'GLPI_ITEM_GLOBAL_VALIDATION' => $itemtype == 'Problem' ? '' : $item->fields['global_validation'], 'GLPI_TICKET_TECHNICIAN_GLPI_ID' => $users_id, 'GLPI_ITEM_TECHNICIAN_GLPI_ID' => $users_id, 'GLPI_TICKET_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), 'GLPI_ITEM_TECHNICIAN_PM_ID' => PluginProcessmakerUser::getPMUserId( $users_id ), - 'GLPI_URL' => $CFG_GLPI['url_base'] + 'GLPI_URL' => $CFG_GLPI['url_base'], + // Specific to Tickets + // GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request) + 'GLPI_TICKET_TYPE' => $itemtype == 'Ticket' ? $item->fields['type'] : '' ]; $subCase->sendVariables($glpi_variables); @@ -3047,8 +3026,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $route->taskId, $route->delThread, [ 'txtTaskContent' => $txtTaskContent, - 'start_date' => $taskStartDate, - 'end_date' => $taskEndDate] + 'start_date' => $taskStartDate, + 'end_date' => $taskEndDate, + 'reminder' => $taskReminder] ); // if end date was specified, then must change due date of the PM task if ($taskEndDate != '') { @@ -3072,9 +3052,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { // must check if $open_task is not is_subprocess and is not already existing in the item $locTaskCat = new PluginProcessmakerTaskCategory; $locTask = new PluginProcessmakerTask(); + + $locTaskRestrict=[ + 'WHERE' => [ + 'plugin_processmaker_cases_id' => $parentCase->getID(), + 'plugin_processmaker_taskcategories_id' => $locTaskCat->getID(), + 'del_index' => $open_task->delIndex + ], + ]; if ($locTaskCat->getFromGUID($open_task->taskId) && !$locTaskCat->fields['is_subprocess'] - && !$locTask->getFromDBByQuery("WHERE `plugin_processmaker_cases_id`={$parentCase->getID()} AND `plugin_processmaker_taskcategories_id`={$locTaskCat->getID()} AND `del_index`={$open_task->delIndex}")) { + && !$locTask->getFromDBByRequest($locTaskRestrict)) { $this->addTask($parentCase->getID(), $itemtype, $items_id, $parentCaseInfo, @@ -3084,8 +3072,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $open_task->taskId, $open_task->delThread, [ 'txtTaskContent' => $txtTaskContent, - 'start_date' => $taskStartDate, - 'end_date' => $taskEndDate] + 'start_date' => $taskStartDate, + 'end_date' => $taskEndDate, + 'reminder' => $taskReminder] ); // if end date was specified, then must change due date of the PM task @@ -3215,8 +3204,32 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { echo "
"; echo Html::image($CFG_GLPI['root_doc'].'/plugins/processmaker/pics/under_maintenance.png'); echo "

"; - __('ProcessMaker plugin is under maintenance, please retry later, thank you.', 'processmaker'); + echo __('ProcessMaker plugin is under maintenance, please retry later, thank you.', 'processmaker'); echo "

"; echo "
"; } + + + /** + * Summary of echoDomain + */ + function echoDomain() { + if (isset($this->config->fields['domain']) && $this->config->fields['domain'] != '') { + $script = " + (function() { + var id = 'commonDomainGlpiPmScript_Wjd4uWisWHLt9I'; + //debugger; + if ($('#' + id).length == 0) { + //debugger; + var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; + g.type = 'text/javascript'; + g.id = id; + g.text = 'try { document.domain = \'".$this->config->fields['domain']."\'; } catch(ev) { /*console.log(ev);*/ }'; + s.parentNode.insertBefore(g, s); + } + })();"; + + echo Html::scriptBlock($script); + } + } } diff --git a/inc/selfservicedraft.class.php b/inc/selfservicedraft.class.php index 705d4bc..df45378 100644 --- a/inc/selfservicedraft.class.php +++ b/inc/selfservicedraft.class.php @@ -10,4 +10,4 @@ */ class PluginProcessmakerSelfservicedraft extends CommonDBTM { -} \ No newline at end of file +} diff --git a/inc/task.class.php b/inc/task.class.php index c6e02d6..fe843f8 100644 --- a/inc/task.class.php +++ b/inc/task.class.php @@ -41,7 +41,13 @@ class PluginProcessmakerTask extends CommonITILTask function getFromDB($items_id) { global $DB; - if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) { + //if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) { + if ($this->getFromDBByRequest([ + 'WHERE' => [ + 'itemtype' => $this->itemtype, + 'items_id' => $items_id + ], + ])) { $task = new $this->itemtype; if ($task->getFromDB( $items_id )) { // then we should add our own fields @@ -306,7 +312,11 @@ class PluginProcessmakerTask extends CommonITILTask $rand = rand(); // get infos for the current task - $task = $dbu->getAllDataFromTable('glpi_plugin_processmaker_tasks', "id = $tabnum"); + $restrict = [ + "id" => $tabnum + ]; + //$task = $dbu->getAllDataFromTable('glpi_plugin_processmaker_tasks', "id = $tabnum"); + $task = $dbu->getAllDataFromTable('glpi_plugin_processmaker_tasks', $restrict); // shows the re-assign form $caseInfo = $case->getCaseInfo(); @@ -347,6 +357,7 @@ class PluginProcessmakerTask extends CommonITILTask } } + $PM_SOAP->echoDomain(); echo ""; $csrf = Session::getNewCSRFToken(); diff --git a/inc/taskcategory.class.php b/inc/taskcategory.class.php index d0952e1..d915b52 100644 --- a/inc/taskcategory.class.php +++ b/inc/taskcategory.class.php @@ -86,11 +86,11 @@ class PluginProcessmakerTaskCategory extends CommonDBTM 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) - **/ + /** + * 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 $CFG_GLPI; @@ -99,26 +99,22 @@ class PluginProcessmakerTaskCategory extends CommonDBTM if (Session::haveRight('plugin_processmaker_config', UPDATE)) { $buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $title; - Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png", $title, "", - $buttons); + $pic = $CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png"; + if ($item->fields['maintenance']) { + $pic = $CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/verysmall-under_maintenance.png"; + } + Html::displayTitle($pic, $title, "", $buttons); } } - //function getLinkItemFromExternalID($extId) { - // if( $this->getFromDBbyExternalID( $extId ) ) { - // $taskcat = new TaskCategory ; - // return $taskcat->getFromDB( $this->fields['items_id'] ) ; - // } - //} - - /** - * Retrieve a TaskCat from the database using its external id (unique index): pm_task_guid - * - * @param $task_guid string externalid - * - * @return true if succeed else false - **/ + /** + * Retrieve a TaskCat from the database using its external id (unique index): pm_task_guid + * + * @param $task_guid string externalid + * + * @return true if succeed else false + **/ function getFromGUID($task_guid) { global $DB; diff --git a/inc/user.class.php b/inc/user.class.php index 9d3a007..72bee97 100644 --- a/inc/user.class.php +++ b/inc/user.class.php @@ -178,9 +178,14 @@ class PluginProcessmakerUser extends CommonDBTM { */ public static function getGLPIUserId($pmUserId) { $obj = new self; - if ($obj->getFromDBByQuery("WHERE `pm_users_id` = '$pmUserId'")) { + if ($obj->getFromDBByRequest([ + 'WHERE' => [ + 'pm_users_id' => $pmUserId + ], + ])) { return $obj->fields['id']; } + return 0; } diff --git a/install/install.php b/install/install.php index ec0b43d..b1e9143 100644 --- a/install/install.php +++ b/install/install.php @@ -4,27 +4,7 @@ function processmaker_install() { global $DB; // installation from scratch - include_once(GLPI_ROOT."/plugins/processmaker/setup.php"); - $info = plugin_version_processmaker(); - switch ($info['version']) { - case '3.3.0' : - $version = '3.3.0'; - break; - case '3.3.1' : - case '3.3.2' : - case '3.3.3' : - case '3.3.4' : - case '3.3.5' : - case '3.3.6' : - case '3.3.7' : - $version = '3.3.1'; - break; - case '3.3.8' : - default : - $version = '3.3.8'; - break; - } - $DB->runFile(GLPI_ROOT . "/plugins/processmaker/install/mysql/$version-empty.sql"); + $DB->runFile(GLPI_ROOT . "/plugins/processmaker/install/mysql/processmaker-empty.sql"); // add configuration singleton $query = "INSERT INTO `glpi_plugin_processmaker_configs` (`id`) VALUES (1);"; diff --git a/install/mysql/3.2.8-empty.sql b/install/mysql/3.2.8-empty.sql deleted file mode 100644 index 6a217a1..0000000 --- a/install/mysql/3.2.8-empty.sql +++ /dev/null @@ -1,167 +0,0 @@ -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET NAMES utf8 */; -/*!50503 SET NAMES utf8mb4 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinkactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinkactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `name` varchar(255) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY `caselinks_id_name` (`plugin_processmaker_caselinks_id`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `is_active` tinyint(1) NOT NULL DEFAULT '0', - `is_externaldata` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:insert data from case,1:wait for external application to set datas', - `is_self` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:use linked tickets, 1:use self', - `sourcetask_guid` varchar(32) DEFAULT NULL, - `targettask_guid` varchar(32) DEFAULT NULL, - `targetprocess_guid` varchar(32) DEFAULT NULL, - `targetdynaform_guid` varchar(32) DEFAULT NULL, - `sourcecondition` text, - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `externalapplication` text, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `is_active` (`is_active`), - KEY `is_externaldata` (`is_externaldata`), - KEY `is_self` (`is_self`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_cases -CREATE TABLE IF NOT EXISTS `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', - `processes_id` int(11) DEFAULT NULL, - UNIQUE KEY `items` (`itemtype`,`items_id`), - KEY `case_status` (`case_status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_configs -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `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) DEFAULT NULL, - `pm_admin_passwd` varchar(255) DEFAULT NULL, - `pm_theme` varchar(50) NOT NULL DEFAULT 'glpi_classic', - `date_mod` timestamp NULL DEFAULT NULL, - `taskcategories_id` int(11) DEFAULT NULL, - `users_id` int(11) DEFAULT NULL, - `pm_group_guid` varchar(32) DEFAULT NULL, - `comment` text, - `pm_dbserver_name` varchar(255) DEFAULT 'localhost', - `pm_dbname` varchar(50) DEFAULT 'wf_workflow', - `pm_dbserver_user` varchar(255) DEFAULT NULL, - `pm_dbserver_passwd` varchar(255) DEFAULT NULL, - `domain` varchar(50) DEFAULT '', - `maintenance` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_crontaskactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_crontaskactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `itemtype` varchar(100) NOT NULL, - `items_id` int(11) NOT NULL DEFAULT '0', - `users_id` int(11) NOT NULL DEFAULT '0', - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `postdata` mediumtext, - `logs_out` mediumtext, - `state` int(11) NOT NULL, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes -CREATE TABLE IF NOT EXISTS `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, - `taskcategories_id` int(11) DEFAULT NULL, - `itilcategories_id` int(11) NOT NULL DEFAULT '0', - `type` int(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets', - `date_mod` timestamp NULL DEFAULT NULL, - `project_type` varchar(50) NOT NULL DEFAULT 'classic', - PRIMARY KEY (`id`), - UNIQUE KEY `process_guid` (`process_guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes_profiles -CREATE TABLE IF NOT EXISTS `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`), - KEY `entities_id` (`entities_id`), - KEY `profiles_id` (`profiles_id`), - KEY `processes_id` (`processes_id`), - KEY `is_recursive` (`is_recursive`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_taskcategories -CREATE TABLE IF NOT EXISTS `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', - `is_active` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `pm_task_guid` (`pm_task_guid`), - UNIQUE KEY `items` (`taskcategories_id`), - KEY `processes_id` (`processes_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_tasks -CREATE TABLE IF NOT EXISTS `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 KEY `case_id` (`case_id`,`del_index`), - UNIQUE KEY `items` (`itemtype`,`items_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_users -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pm_users_id` varchar(32) NOT NULL, - `password` varchar(32) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `pm_users_id` (`pm_users_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/install/mysql/3.2.9-empty.sql b/install/mysql/3.2.9-empty.sql deleted file mode 100644 index 3ee30cd..0000000 --- a/install/mysql/3.2.9-empty.sql +++ /dev/null @@ -1,168 +0,0 @@ -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET NAMES utf8 */; -/*!50503 SET NAMES utf8mb4 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinkactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinkactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `name` varchar(255) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY `caselinks_id_name` (`plugin_processmaker_caselinks_id`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `is_active` tinyint(1) NOT NULL DEFAULT '0', - `is_externaldata` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:insert data from case,1:wait for external application to set datas', - `is_self` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:use linked tickets, 1:use self', - `sourcetask_guid` varchar(32) DEFAULT NULL, - `targettask_guid` varchar(32) DEFAULT NULL, - `targetprocess_guid` varchar(32) DEFAULT NULL, - `targetdynaform_guid` varchar(32) DEFAULT NULL, - `sourcecondition` text, - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `externalapplication` text, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `is_active` (`is_active`), - KEY `is_externaldata` (`is_externaldata`), - KEY `is_self` (`is_self`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_cases -CREATE TABLE IF NOT EXISTS `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', - `processes_id` int(11) DEFAULT NULL, - UNIQUE KEY `items` (`itemtype`,`items_id`), - KEY `case_status` (`case_status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_configs -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `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) DEFAULT NULL, - `pm_admin_passwd` varchar(255) DEFAULT NULL, - `pm_theme` varchar(50) NOT NULL DEFAULT 'glpi_classic', - `date_mod` timestamp NULL DEFAULT NULL, - `taskcategories_id` int(11) DEFAULT NULL, - `users_id` int(11) DEFAULT NULL, - `pm_group_guid` varchar(32) DEFAULT NULL, - `comment` text, - `pm_dbserver_name` varchar(255) DEFAULT 'localhost', - `pm_dbname` varchar(50) DEFAULT 'wf_workflow', - `pm_dbserver_user` varchar(255) DEFAULT NULL, - `pm_dbserver_passwd` varchar(255) DEFAULT NULL, - `domain` varchar(50) DEFAULT '', - `maintenance` tinyint(1) NOT NULL DEFAULT '0', - `db_version` varchar(10) NOT NULL DEFAULT '3.2.9', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_crontaskactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_crontaskactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `itemtype` varchar(100) NOT NULL, - `items_id` int(11) NOT NULL DEFAULT '0', - `users_id` int(11) NOT NULL DEFAULT '0', - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `postdata` mediumtext, - `logs_out` mediumtext, - `state` int(11) NOT NULL, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes -CREATE TABLE IF NOT EXISTS `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, - `taskcategories_id` int(11) DEFAULT NULL, - `itilcategories_id` int(11) NOT NULL DEFAULT '0', - `type` int(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets', - `date_mod` timestamp NULL DEFAULT NULL, - `project_type` varchar(50) NOT NULL DEFAULT 'classic', - PRIMARY KEY (`id`), - UNIQUE KEY `process_guid` (`process_guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes_profiles -CREATE TABLE IF NOT EXISTS `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`), - KEY `entities_id` (`entities_id`), - KEY `profiles_id` (`profiles_id`), - KEY `processes_id` (`processes_id`), - KEY `is_recursive` (`is_recursive`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_taskcategories -CREATE TABLE IF NOT EXISTS `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', - `is_active` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `pm_task_guid` (`pm_task_guid`), - UNIQUE KEY `items` (`taskcategories_id`), - KEY `processes_id` (`processes_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_tasks -CREATE TABLE IF NOT EXISTS `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 KEY `case_id` (`case_id`,`del_index`), - UNIQUE KEY `items` (`itemtype`,`items_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_users -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pm_users_id` varchar(32) NOT NULL, - `password` varchar(32) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `pm_users_id` (`pm_users_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/install/mysql/3.3.0-empty.sql b/install/mysql/3.3.0-empty.sql deleted file mode 100644 index 3049ca9..0000000 --- a/install/mysql/3.3.0-empty.sql +++ /dev/null @@ -1,179 +0,0 @@ -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET NAMES utf8 */; -/*!50503 SET NAMES utf8mb4 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinkactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinkactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `name` varchar(255) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY `caselinks_id_name` (`plugin_processmaker_caselinks_id`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `is_active` tinyint(1) NOT NULL DEFAULT '0', - `is_externaldata` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:insert data from case,1:wait for external application to set datas', - `is_self` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:use linked tickets, 1:use self', - `sourcetask_guid` varchar(32) DEFAULT NULL, - `targettask_guid` varchar(32) DEFAULT NULL, - `targetprocess_guid` varchar(32) DEFAULT NULL, - `targetdynaform_guid` varchar(32) DEFAULT NULL, - `sourcecondition` text, - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `externalapplication` text, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `is_active` (`is_active`), - KEY `is_externaldata` (`is_externaldata`), - KEY `is_self` (`is_self`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_cases -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_cases` ( - `id` INT(11) NOT NULL, - `itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket', - `items_id` INT(11) NOT NULL, - `entities_id` INT(11) NOT NULL DEFAULT '0', - `name` MEDIUMTEXT NOT NULL DEFAULT '', - `case_guid` VARCHAR(32) NOT NULL, - `case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT', - `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL, - `plugin_processmaker_cases_id` INT(11) NULL DEFAULT NULL, - INDEX `items` (`itemtype`, `items_id`), - INDEX `case_status` (`case_status`), - PRIMARY KEY (`id`), - UNIQUE INDEX `case_guid` (`case_guid`), - INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`), - INDEX `plugin_processmaker_cases_id` (`plugin_processmaker_cases_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_configs -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `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) DEFAULT NULL, - `pm_admin_passwd` varchar(255) DEFAULT NULL, - `pm_theme` varchar(50) NOT NULL DEFAULT 'glpi_classic', - `date_mod` timestamp NULL DEFAULT NULL, - `taskcategories_id` int(11) DEFAULT NULL, - `users_id` int(11) DEFAULT NULL, - `pm_group_guid` varchar(32) DEFAULT NULL, - `comment` text, - `pm_dbserver_name` varchar(255) DEFAULT 'localhost', - `pm_dbname` varchar(50) DEFAULT 'wf_workflow', - `pm_dbserver_user` varchar(255) DEFAULT NULL, - `pm_dbserver_passwd` varchar(255) DEFAULT NULL, - `domain` varchar(50) DEFAULT '', - `maintenance` tinyint(1) NOT NULL DEFAULT '0', - `db_version` varchar(10) NOT NULL DEFAULT '3.3.0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_crontaskactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_crontaskactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `plugin_processmaker_cases_id` int(11) DEFAULT '0', - `users_id` int(11) NOT NULL DEFAULT '0', - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `postdata` mediumtext, - `logs_out` mediumtext, - `state` int(11) NOT NULL, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes -CREATE TABLE IF NOT EXISTS `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, - `taskcategories_id` int(11) DEFAULT NULL, - `itilcategories_id` int(11) NOT NULL DEFAULT '0', - `type` int(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets', - `date_mod` timestamp NULL DEFAULT NULL, - `project_type` varchar(50) NOT NULL DEFAULT 'classic', - PRIMARY KEY (`id`), - UNIQUE KEY `process_guid` (`process_guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes_profiles -CREATE TABLE `glpi_plugin_processmaker_processes_profiles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_processes_id` int(11) NOT NULL, - `profiles_id` int(11) NOT NULL, - `entities_id` int(11) NOT NULL, - `is_recursive` tinyint(1) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE INDEX `plugin_processmaker_processes_id_profiles_id_entities_id` (`plugin_processmaker_processes_id`, `profiles_id`, `entities_id`), - KEY `entities_id` (`entities_id`), - KEY `profiles_id` (`profiles_id`), - KEY `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`), - KEY `is_recursive` (`is_recursive`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_taskcategories -CREATE TABLE `glpi_plugin_processmaker_taskcategories` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_processes_id` INT(11) NOT NULL, - `pm_task_guid` VARCHAR(32) NOT NULL, - `taskcategories_id` INT(11) NOT NULL, - `is_start` TINYINT(1) NOT NULL DEFAULT '0', - `is_active` TINYINT(1) NOT NULL DEFAULT '1', - `is_subprocess` TINYINT(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE INDEX `pm_task_guid` (`pm_task_guid`), - UNIQUE INDEX `items` (`taskcategories_id`), - INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_tasks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_tasks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `items_id` int(11) NOT NULL, - `itemtype` varchar(32) NOT NULL, - `plugin_processmaker_cases_id` int(11) NOT NULL, - `plugin_processmaker_taskcategories_id` int(11) NOT NULL, - `del_index` int(11) NOT NULL, - `del_thread` INT(11) NOT NULL, - `del_thread_status` varchar(32) NOT NULL DEFAULT 'OPEN', - PRIMARY KEY (`id`), - UNIQUE KEY `tasks` (`plugin_processmaker_cases_id`,`del_index`), - UNIQUE KEY `items` (`itemtype`,`items_id`), - KEY `del_thread_status` (`del_thread_status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_users -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pm_users_id` varchar(32) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `pm_users_id` (`pm_users_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/install/mysql/3.3.1-empty.sql b/install/mysql/3.3.1-empty.sql deleted file mode 100644 index cb7d897..0000000 --- a/install/mysql/3.3.1-empty.sql +++ /dev/null @@ -1,186 +0,0 @@ -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET NAMES utf8 */; -/*!50503 SET NAMES utf8mb4 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinkactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinkactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `name` varchar(255) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY `caselinks_id_name` (`plugin_processmaker_caselinks_id`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_caselinks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_caselinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `is_active` tinyint(1) NOT NULL DEFAULT '0', - `is_externaldata` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:insert data from case,1:wait for external application to set datas', - `is_self` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:use linked tickets, 1:use self', - `sourcetask_guid` varchar(32) DEFAULT NULL, - `targettask_guid` varchar(32) DEFAULT NULL, - `targetprocess_guid` varchar(32) DEFAULT NULL, - `targetdynaform_guid` varchar(32) DEFAULT NULL, - `sourcecondition` text, - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `is_targettoreassign` TINYINT(1) NOT NULL DEFAULT '0', - `is_targettoimpersonate` TINYINT(1) NOT NULL DEFAULT '0', - `externalapplication` TEXT NULL, - `is_synchronous` TINYINT(1) NOT NULL DEFAULT '0', - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `is_active` (`is_active`), - KEY `is_externaldata` (`is_externaldata`), - KEY `is_self` (`is_self`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_cases -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_cases` ( - `id` INT(11) NOT NULL, - `itemtype` VARCHAR(10) NOT NULL DEFAULT 'Ticket', - `items_id` INT(11) NOT NULL, - `entities_id` INT(11) NOT NULL DEFAULT '0', - `name` MEDIUMTEXT NOT NULL DEFAULT '', - `case_guid` VARCHAR(32) NOT NULL, - `case_status` VARCHAR(20) NOT NULL DEFAULT 'DRAFT', - `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL, - `plugin_processmaker_cases_id` INT(11) NULL DEFAULT NULL, - INDEX `items` (`itemtype`, `items_id`), - INDEX `case_status` (`case_status`), - PRIMARY KEY (`id`), - UNIQUE INDEX `case_guid` (`case_guid`), - INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`), - INDEX `plugin_processmaker_cases_id` (`plugin_processmaker_cases_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_configs -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `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) DEFAULT NULL, - `pm_admin_passwd` varchar(255) DEFAULT NULL, - `pm_theme` varchar(50) NOT NULL DEFAULT 'glpi_classic', - `date_mod` timestamp NULL DEFAULT NULL, - `taskcategories_id` int(11) DEFAULT NULL, - `users_id` int(11) DEFAULT NULL, - `pm_group_guid` varchar(32) DEFAULT NULL, - `comment` text, - `pm_dbserver_name` varchar(255) DEFAULT 'localhost', - `pm_dbname` varchar(50) DEFAULT 'wf_workflow', - `pm_dbserver_user` varchar(255) DEFAULT NULL, - `pm_dbserver_passwd` varchar(255) DEFAULT NULL, - `domain` varchar(50) DEFAULT '', - `maintenance` tinyint(1) NOT NULL DEFAULT '0', - `db_version` varchar(10) NOT NULL DEFAULT '3.3.0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_crontaskactions -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_crontaskactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_caselinks_id` int(11) DEFAULT NULL, - `plugin_processmaker_cases_id` int(11) DEFAULT '0', - `users_id` int(11) NOT NULL DEFAULT '0', - `is_targettoclaim` tinyint(1) NOT NULL DEFAULT '0', - `postdata` mediumtext, - `logs_out` mediumtext, - `state` int(11) NOT NULL, - `date_mod` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes -CREATE TABLE IF NOT EXISTS `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, - `taskcategories_id` int(11) DEFAULT NULL, - `itilcategories_id` int(11) NOT NULL DEFAULT '0', - `type` int(11) NOT NULL DEFAULT '1' COMMENT 'Only used for self-service Tickets', - `date_mod` timestamp NULL DEFAULT NULL, - `project_type` varchar(50) NOT NULL DEFAULT 'classic', - `is_change` tinyint(1) NOT NULL DEFAULT '0', - `is_problem` tinyint(1) NOT NULL DEFAULT '0', - `is_incident` tinyint(1) NOT NULL DEFAULT '0', - `is_request` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE KEY `process_guid` (`process_guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_processes_profiles -CREATE TABLE `glpi_plugin_processmaker_processes_profiles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_processes_id` int(11) NOT NULL, - `profiles_id` int(11) NOT NULL, - `entities_id` int(11) NOT NULL, - `is_recursive` tinyint(1) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE INDEX `plugin_processmaker_processes_id_profiles_id_entities_id` (`plugin_processmaker_processes_id`, `profiles_id`, `entities_id`), - KEY `entities_id` (`entities_id`), - KEY `profiles_id` (`profiles_id`), - KEY `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`), - KEY `is_recursive` (`is_recursive`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_taskcategories -CREATE TABLE `glpi_plugin_processmaker_taskcategories` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `plugin_processmaker_processes_id` INT(11) NOT NULL, - `pm_task_guid` VARCHAR(32) NOT NULL, - `taskcategories_id` INT(11) NOT NULL, - `is_start` TINYINT(1) NOT NULL DEFAULT '0', - `is_active` TINYINT(1) NOT NULL DEFAULT '1', - `is_subprocess` TINYINT(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE INDEX `pm_task_guid` (`pm_task_guid`), - UNIQUE INDEX `items` (`taskcategories_id`), - INDEX `plugin_processmaker_processes_id` (`plugin_processmaker_processes_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_tasks -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_tasks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `items_id` int(11) NOT NULL, - `itemtype` varchar(32) NOT NULL, - `plugin_processmaker_cases_id` int(11) NOT NULL, - `plugin_processmaker_taskcategories_id` int(11) NOT NULL, - `del_index` int(11) NOT NULL, - `del_thread` INT(11) NOT NULL, - `del_thread_status` varchar(32) NOT NULL DEFAULT 'OPEN', - PRIMARY KEY (`id`), - UNIQUE KEY `tasks` (`plugin_processmaker_cases_id`,`del_index`), - UNIQUE KEY `items` (`itemtype`,`items_id`), - KEY `del_thread_status` (`del_thread_status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- Dumping structure for table glpi.glpi_plugin_processmaker_users -CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pm_users_id` varchar(32) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `pm_users_id` (`pm_users_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/install/mysql/3.3.8-empty.sql b/install/mysql/processmaker-empty.sql similarity index 96% rename from install/mysql/3.3.8-empty.sql rename to install/mysql/processmaker-empty.sql index a5be338..3ad90bb 100644 --- a/install/mysql/3.3.8-empty.sql +++ b/install/mysql/processmaker-empty.sql @@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_cases` ( CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT 'ProcessMaker', - `pm_server_URL` varchar(250) NOT NULL DEFAULT 'http://localhost/', + `pm_server_URL` varchar(250) NOT NULL DEFAULT 'http://itsm-pm.acme.com/', `pm_workspace` varchar(50) NOT NULL DEFAULT 'workflow', `pm_admin_user` varchar(255) DEFAULT NULL, `pm_admin_passwd` varchar(255) DEFAULT NULL, @@ -81,7 +81,8 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_configs` ( `domain` varchar(50) DEFAULT '', `maintenance` tinyint(1) NOT NULL DEFAULT '0', `ssl_verify` tinyint(1) NOT NULL DEFAULT '0', - `db_version` varchar(10) NOT NULL DEFAULT '3.3.8', + `db_version` varchar(10) NOT NULL DEFAULT '3.4.9', + `max_cases_per_item` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -119,6 +120,8 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_processmaker_processes` ( `is_problem` tinyint(1) NOT NULL DEFAULT '0', `is_incident` tinyint(1) NOT NULL DEFAULT '0', `is_request` tinyint(1) NOT NULL DEFAULT '0', + `maintenance` TINYINT(1) NOT NULL DEFAULT '0', + `max_cases_per_item` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `process_guid` (`process_guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/install/update.php b/install/update.php index 06f713a..febe0e5 100644 --- a/install/update.php +++ b/install/update.php @@ -11,6 +11,9 @@ function processmaker_update() { include_once(GLPI_ROOT."/plugins/processmaker/inc/config.class.php"); $config = PluginProcessmakerConfig::getInstance(); $current_version = $config->fields['db_version']; + if (empty($current_version)) { + $current_version = '2.4.1'; + } } switch ($current_version) { @@ -37,6 +40,10 @@ function processmaker_update() { // will upgrade 3.3.1 to 3.3.8 include_once(GLPI_ROOT."/plugins/processmaker/install/update_3_3_1_to_3_3_8.php"); $new_version = update_3_3_1_to_3_3_8(); + case '3.3.8' : + // will upgrade 3.3.8 to 3.4.9 + include_once(GLPI_ROOT."/plugins/processmaker/install/update_3_3_8_to_3_4_9.php"); + $new_version = update_3_3_8_to_3_4_9(); } if (isset($new_version)) { diff --git a/install/update_3_3_1_to_3_3_8.php b/install/update_3_3_1_to_3_3_8.php index ebac746..1a4e4f7 100644 --- a/install/update_3_3_1_to_3_3_8.php +++ b/install/update_3_3_1_to_3_3_8.php @@ -1,6 +1,6 @@ fieldExists("glpi_plugin_processmaker_configs", "max_cases_per_item" )) { + $query = "ALTER TABLE `glpi_plugin_processmaker_configs` + ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `db_version`;"; + + $DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_configs table" . $DB->error()); + } + + // Alter table glpi_plugin_processmaker_processes + if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "maintenance" )) { + $query = "ALTER TABLE `glpi_plugin_processmaker_processes` + ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_request`;"; + + $DB->query($query) or die("error adding maintenance to glpi_plugin_processmaker_processes table" . $DB->error()); + } + // Alter table glpi_plugin_processmaker_processes + if (!$DB->fieldExists("glpi_plugin_processmaker_processes", "max_cases_per_item" )) { + $query = "ALTER TABLE `glpi_plugin_processmaker_processes` + ADD COLUMN `max_cases_per_item` INT(11) NOT NULL DEFAULT '0' AFTER `maintenance`;"; + + $DB->query($query) or die("error adding max_cases_per_item to glpi_plugin_processmaker_processes table" . $DB->error()); + } + + return '3.4.9'; +} \ No newline at end of file diff --git a/install/update_to_3_2_8.php b/install/update_to_3_2_8.php index 47f48df..d9784b3 100644 --- a/install/update_to_3_2_8.php +++ b/install/update_to_3_2_8.php @@ -71,7 +71,7 @@ function update_to_3_2_8() { } } - if (!$DB->fieldExists('glpi_plugin_processmaker_users', 'password')) { + if (!$DB->fieldExists('glpi_plugin_processmaker_users', 'password') && !$DB->fieldExists('glpi_plugin_processmaker_users', 'id')) { $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`, diff --git a/js/cases.helpdesk.js b/js/cases.helpdesk.js index b846e59..fb1c062 100644 --- a/js/cases.helpdesk.js +++ b/js/cases.helpdesk.js @@ -21,7 +21,7 @@ function onClickContinue(obj) { // hide the iFrame caseIFrame.style.visibility = 'hidden'; - // trigger a click on the 'add' button of the ticket + // trigger a click on the 'add' button of the ticket submitButton.click(); } @@ -59,17 +59,17 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { if (caseIFrame != undefined && contentDocument) { var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]'); var linkList = contentDocument.getElementsByTagName('a'); - + 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'); - + oldHandler = buttonContinue.onclick; buttonContinue.onclick = onClickContinue; - + submitButton = $("input[name='add'][type=submit]")[0]; submitButton.insertAdjacentHTML('beforebegin', ""); submitButton.insertAdjacentHTML('beforebegin', ""); @@ -116,4 +116,4 @@ function redimTaskFrame(taskFrame) { taskFrame.height = newHeight; } catch (e) { } -} \ No newline at end of file +} diff --git a/js/central.js b/js/central.js index 593e425..c907753 100644 --- a/js/central.js +++ b/js/central.js @@ -2,18 +2,17 @@ $(document).ajaxComplete(function (event, jqXHR, ajaxOptions) { //debugger; var pattern = /##processmaker.*(##|...)/g; - + $('tr.tab_bg_2 td a').each(function (index) { - + var textToChange = $(this).text(); var matches = textToChange.match(pattern); if (matches) { textToChange = textToChange.replace(pattern, ''); - if (!textToChange.trim().length>0) - { + if (!textToChange.trim().length>0) { var title = $(this).parent().prev().text(); textToChange = title; - } + } $(this).text(textToChange); } }); diff --git a/js/domain.js.php b/js/domain.js.php deleted file mode 100644 index 3d10868..0000000 --- a/js/domain.js.php +++ /dev/null @@ -1,19 +0,0 @@ -isActivated('processmaker')) { - $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 = 'try { document.domain = \'".$config->fields['domain']."\'; } catch(ev) { /*console.log(ev);*/ }'; - s.parentNode.insertBefore(g, s); - "; - } -} \ No newline at end of file diff --git a/js/helpdesk.public.js.php b/js/helpdesk.public.js.php index c93b8d4..6d2bd5d 100644 --- a/js/helpdesk.public.js.php +++ b/js/helpdesk.public.js.php @@ -14,7 +14,7 @@ if (!defined('GLPI_ROOT')) { $config = PluginProcessmakerConfig::getInstance(); if (!$config->fields['maintenance']) { - echo "$(function () { + echo "$(function () { // 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]; diff --git a/js/planning.js b/js/planning.js index a0c8be9..b82153a 100644 --- a/js/planning.js +++ b/js/planning.js @@ -6,4 +6,4 @@ } $('input[type="checkbox"][value="PluginProcessmakerTask"]').parents('li').first().hide(); }); -}); \ No newline at end of file +}); diff --git a/pics/small-under_maintenance.png b/pics/small-under_maintenance.png new file mode 100644 index 0000000..0f4749a Binary files /dev/null and b/pics/small-under_maintenance.png differ diff --git a/pics/verysmall-under_maintenance.png b/pics/verysmall-under_maintenance.png new file mode 100644 index 0000000..b659749 Binary files /dev/null and b/pics/verysmall-under_maintenance.png differ diff --git a/processmaker.xml b/processmaker.xml index 8f4d30c..898d1eb 100644 --- a/processmaker.xml +++ b/processmaker.xml @@ -6,15 +6,15 @@ https://raw.githubusercontent.com/tomolimo/processmaker/master/processmaker.png - Ce plugin fournit la possibilité d'intégrer un processus (workflow) aux objets ITIL (Tickets, Changements et Problèmes). + Ce plugin fournit la possibilité d'intégrer un processus (workflow) aux objets ITIL (Tickets, Changements et Problèmes). This plugin provides a process (workflow) management linked to ITIL objects (Tickets, Changes and Problems). - Tento zásuvný modul poskytuje správu procesů (pracovní postup) napojený na požadavky. - + Tento zásuvný modul poskytuje správu procesů (pracovní postup) napojený na požadavky. + This plugin is dedicated to provide process (workflows) management linked to ITIL objects (Tickets, Changes and Problems). This goal is achieved using a customized ProcessMaker server (URL: https://github.com/tomolimo/processmaker-server). ProcessMaker provides BPMN Process design and execution. This plugin is the glue between GLPI and ProcessMaker. - Ce plugin est dédié à la gestion de processus (workflows) liés aux objets ITIL (Tickets, Changements et Problèmes). Ce but est atteint par l'utilisation d'un serveur ProcessMaker customisé (URL: https://github.com/tomolimo/processmaker-server). ProcessMaker fournit un outil graphique de création de processus BPMN et permet l'exécution de ceux-ci. Ce plugin sert de glue entre GLPI et ProcessMaker. - Tento zásuvný modul je věnován poskytnutí správy procesu (pracovní postup), napojeného na požadavky. Tohoto cíle je dosaženo použitím ProcessMaker (URL: https://github.com/tomolimo/processmaker-server). ProcessMaker poskytne návrh procesu a vykonání pracovního postupu. Tento zásuvný modul je můstkem mezi GLPI a ProcessMaker. - + Ce plugin est dédié à la gestion de processus (workflows) liés aux objets ITIL (Tickets, Changements et Problèmes). Ce but est atteint par l'utilisation d'un serveur ProcessMaker customisé (URL: https://github.com/tomolimo/processmaker-server). ProcessMaker fournit un outil graphique de création de processus BPMN et permet l'exécution de ceux-ci. Ce plugin sert de glue entre GLPI et ProcessMaker. + Tento zásuvný modul je věnován poskytnutí správy procesu (pracovní postup), napojeného na požadavky. Tohoto cíle je dosaženo použitím ProcessMaker (URL: https://github.com/tomolimo/processmaker-server). ProcessMaker poskytne návrh procesu a vykonání pracovního postupu. Tento zásuvný modul je můstkem mezi GLPI a ProcessMaker. + https://github.com/tomolimo/processmaker https://github.com/tomolimo/processmaker/releases @@ -28,10 +28,14 @@ 3.3.8 9.1 - - 3.4.5 - 9.2 - + + 3.4.9 + 9.2 + + + 3.5.1 + 9.3 + en_gb @@ -44,22 +48,15 @@ Processus BPMN 2.0 Workflow - Helpdesk - Ticket + Helpdesk + Ticket Processes BPMN 2.0 Helpdesk - Workflows - Ticket + Workflows + Ticket - - Procesy - BPMN 2.0 - Službapodpory - Pracovnípostupy - Požadavek - - + \ No newline at end of file diff --git a/setup.php b/setup.php index f894ae2..16f2a77 100644 --- a/setup.php +++ b/setup.php @@ -2,7 +2,7 @@ // used for case cancellation define("CANCEL", 256); -define('PROCESSMAKER_VERSION', '3.4.5'); +define('PROCESSMAKER_VERSION', '3.5.1'); // Init the hooks of the plugins -Needed function plugin_init_processmaker() { @@ -11,7 +11,6 @@ function plugin_init_processmaker() { $PLUGIN_HOOKS['csrf_compliant']['processmaker'] = true; $objects = ['Ticket', 'Change', 'Problem']; - // $objects = ['Ticket']; Plugin::registerClass('PluginProcessmakerProcessmaker'); @@ -33,11 +32,6 @@ function plugin_init_processmaker() { $PLUGIN_HOOKS['pre_show_item']['processmaker'] = ['PluginProcessmakerProcessmaker', 'pre_show_item_processmaker']; - //$PLUGIN_HOOKS['pre_item_form']['processmaker'] - // = array('PluginProcessmakerProcessmaker', 'pre_item_form_processmakerticket'); - //$PLUGIN_HOOKS['post_item_form']['processmaker'] - // = array('PluginProcessmakerProcessmaker', 'post_item_form_processmakerticket'); - $PLUGIN_HOOKS['pre_show_tab']['processmaker'] = ['PluginProcessmakerProcessmaker', 'pre_show_tab_processmaker']; $PLUGIN_HOOKS['post_show_tab']['processmaker'] @@ -45,8 +39,13 @@ function plugin_init_processmaker() { // Display a menu entry ? if (Session::haveRightsOr('plugin_processmaker_config', [READ, UPDATE])) { - // tools and helpdesk - $PLUGIN_HOOKS['menu_toadd']['processmaker'] = ['tools' => 'PluginProcessmakerMenu', 'helpdesk' => 'PluginProcessmakerCase']; + // tools + $PLUGIN_HOOKS['menu_toadd']['processmaker']['tools'] = 'PluginProcessmakerMenu'; + } + + if (Session::haveRightsOr('plugin_processmaker_case', [READ, UPDATE])) { + // helpdesk + $PLUGIN_HOOKS['menu_toadd']['processmaker']['helpdesk'] = 'PluginProcessmakerCase'; } Plugin::registerClass('PluginProcessmakerProcess', [ 'massiveaction_nodelete_types' => true] ); @@ -83,43 +82,27 @@ function plugin_init_processmaker() { $hooks = []; foreach ($objects as $obj) { - $hooks["PluginPdf'.$obj.'Task"] = ['PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdata_processmaker']; + $hooks["PluginPdf".$obj."Task"] = ['PluginProcessmakerProcessmaker', 'plugin_item_get_pdfdata_processmaker']; } $PLUGIN_HOOKS['item_get_pdfdatas']['processmaker'] = $hooks; - //$hooks = []; - //foreach($objects as $obj){ - // $hooks[$obj.'_User'] = 'plugin_pre_item_purge_processmaker'; - //} - //$PLUGIN_HOOKS['pre_item_purge']['processmaker'] = $hooks; - - //$hooks = []; - //foreach($objects as $obj){ - // $hooks[$obj.'_User'] = 'plugin_item_purge_processmaker'; - //} - //$PLUGIN_HOOKS['item_purge']['processmaker'] = $hooks; - $plugin = new Plugin(); if ($plugin->isActivated('processmaker') && Session::getLoginUserID() ) { - + $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"; + $PLUGIN_HOOKS['add_javascript']['processmaker'] = ["js/helpdesk.public.js.php"]; break; case "planning.php": - $PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/planning.js"; + $PLUGIN_HOOKS['add_javascript']['processmaker'] = ["js/planning.js"]; break; case "central.php": - $PLUGIN_HOOKS['add_javascript']['processmaker'][] = "js/central.js"; - break; - case "case.form.php": - case "processmaker.helpdesk.form.php" : - $PLUGIN_HOOKS['add_javascript']['processmaker'] = ["js/domain.js.php"]; - break; + $PLUGIN_HOOKS['add_javascript']['processmaker'] = ["js/central.js"]; + break; } } @@ -145,17 +128,17 @@ function plugin_version_processmaker() { 'homepage' => 'https://github.com/tomolimo/processmaker', 'requirements' => [ 'glpi' => [ - 'min' => '9.2', - 'max' => '9.2.99' + 'min' => '9.3', + 'max' => '9.4' ], - ] + ] ]; } // 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.2', 'lt') || version_compare(GLPI_VERSION, '9.3', 'ge')) { - echo "This plugin requires GLPI >= 9.2 and < 9.3"; + if (version_compare(GLPI_VERSION, '9.3', 'lt') || version_compare(GLPI_VERSION, '9.4', 'ge')) { + echo "This plugin requires GLPI >= 9.3 and < 9.4"; return false; }