Merge pull request #146 from tomolimo/4.0/bugfixes

Fixed add solution that was not compliant with GLPI9.5
This commit is contained in:
tomolimo
2022-01-24 14:54:22 +01:00
committed by GitHub
9 changed files with 378 additions and 316 deletions

View File

@@ -10,6 +10,5 @@ version 3.6.x is compatible with GLPI 9.4 and needs ProcessMaker 3.3.0-RE-1.x (h
version 4.0.x is compatible with GLPI 9.5 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
This plugin can run classic (ProcessMaker server v2) and BPMN (ProcessMaker server v3 and later) processes
An IRC channel is available: #processmaker-glpi on https://webchat.freenode.net/

View File

@@ -127,7 +127,7 @@ function plugin_pre_item_update_processmaker(CommonITILObject $parm) {
//global $DB;//, $PM_SOAP;
// look at previous status
if (isset($parm->input['status'])
if (isset($parm->input['status'])
&& $parm->input['status'] == CommonITILObject::SOLVED
&& !in_array($parm->fields['status'], [CommonITILObject::SOLVED, CommonITILObject::CLOSED])
&& !PluginProcessmakerCase::canSolve(['item' => $parm])) {
@@ -194,7 +194,7 @@ function plugin_item_update_processmaker_satisfaction($parm) {
global $PM_SOAP;
if (Session::isCron()) { // Task cron log with user admin
$PM_SOAP->login(true);
}
}
$cases = PluginProcessmakerCase::getIDsFromItem('Ticket', $parm->fields['tickets_id']);
foreach ($cases as $cases_id) {
$locCase = new PluginProcessmakerCase;
@@ -282,7 +282,6 @@ function plugin_item_update_processmaker_tasks($parm) {
$locCase = new PluginProcessmakerCase;
$locCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']);
$srccase_guid = $locCase->fields['case_guid'];
//$msg = Toolbox::backtrace(false);
//$msg .= ' $locCase: '.str_replace("\n", "\n ", print_r($locCase, true))."\n";
//$msg .= ' $task: '.str_replace("\n", "\n ", print_r($parm, true))."\n";
@@ -320,6 +319,15 @@ function plugin_item_update_processmaker_tasks($parm) {
$casevariables = array_merge( $casevariables, $matches[1] );
}
}
if (preg_match_all( "/@@(\w+)/u", $externalapplication['url'], $matches )) {
$casevariables = array_merge( $casevariables, $matches[1] );
}
if(isset($externalapplication['headers']) && $externalapplication['headers'] != "") {
if (preg_match_all( "/@@(\w+)/u", $externalapplication['headers'], $matches )) {
$casevariables = array_merge( $casevariables, $matches[1] );
}
}
}
// ask for those case variables
@@ -327,8 +335,10 @@ function plugin_item_update_processmaker_tasks($parm) {
//$PM_SOAP->login( );
// now tries to get the variables to check condition
$infoForTasks = $locCase->getVariables($casevariables);
$infoForURL = [];
foreach ($infoForTasks as $casevar => $varval) {
$infoForTasks[ "@@$casevar" ] = "'$varval'";
$infoForURL[ "@@$casevar" ] = $varval;
unset( $infoForTasks[ $casevar ] );
}
@@ -336,9 +346,7 @@ function plugin_item_update_processmaker_tasks($parm) {
//$msg .= ' $targetTask: '.str_replace("\n", "\n ", print_r($targetTask, true))."\n";
$targetTask['sourcecondition'] = str_replace( array_keys($infoForTasks), $infoForTasks, $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";
@@ -366,7 +374,8 @@ function plugin_item_update_processmaker_tasks($parm) {
}
$externalapplicationparams['callback'] = $CFG_GLPI["url_base"]."/plugins/processmaker/ajax/asynchronousdatas.php";
$ch = curl_init();
$externalapplication['url'] = eval( "return '".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['url'])."' ;" ); // '???
$externalapplication['url'] = str_replace( array_keys($infoForURL), $infoForURL, $externalapplication['url']);
curl_setopt($ch, CURLOPT_URL, $externalapplication['url'] );
if (isset($externalapplication['method']) && $externalapplication['method'] == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
@@ -391,18 +400,17 @@ function plugin_item_update_processmaker_tasks($parm) {
$pmconfig = $PM_SOAP->config; //PluginProcessmakerConfig::getInstance();
$cronaction = new PluginProcessmakerCrontaskaction;
$cronaction->add( [ 'plugin_processmaker_caselinks_id' => $targetTask['id'],
'plugin_processmaker_cases_id' => $locCase->getID(),
//'itemtype' => $itemtype,
//'items_id' => $parm->fields['tickets_id'],
'users_id' => $pmconfig->fields['users_id'],
'is_targettoclaim' => $targetTask['is_targettoclaim'],
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATA : PluginProcessmakerCrontaskaction::DATA_READY),
'postdata' => json_encode( $postdata, JSON_HEX_APOS | JSON_HEX_QUOT),
'logs_out' => json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT)
],
null,
false);
$cronaction->add([
'plugin_processmaker_caselinks_id' => $targetTask['id'],
'plugin_processmaker_cases_id' => $locCase->getID(),
//'itemtype' => $itemtype,
//'items_id' => $parm->fields['tickets_id'],
'users_id' => $pmconfig->fields['users_id'],
'is_targettoclaim' => $targetTask['is_targettoclaim'],
'state' => ($targetTask['is_externaldata'] ? PluginProcessmakerCrontaskaction::WAITING_DATA : PluginProcessmakerCrontaskaction::DATA_READY),
'postdata' => json_encode( $postdata, JSON_HEX_APOS | JSON_HEX_QUOT),
'logs_out' => json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT)
], [], false);
if ($externalapplication) {
// must call external application in order to get the needed data asynchroneously
@@ -415,12 +423,26 @@ function plugin_item_update_processmaker_tasks($parm) {
$externalapplicationparams = json_encode( $externalapplicationparams, JSON_HEX_APOS | JSON_HEX_QUOT);
curl_setopt($ch, CURLOPT_POSTFIELDS, $externalapplicationparams);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($externalapplicationparams), 'Expect:']);
$headers = [
'Content-Type: application/json',
'Content-Length: ' . strlen($externalapplicationparams),
'Expect:'];
if(isset($externalapplication['headers']) && $externalapplication['headers'] != "") {
$externalapplication['headers'] = eval( "return ".str_replace( array_keys($infoForTasks), $infoForTasks, $externalapplication['headers'])." ;" ); // '???
//Can't add an assoicative array in curlopt_httpheader
foreach($externalapplication['headers'] as $key => $h) {
array_push($headers, $key.": ".$h);
}
}
//$headers = array_merge($headers, $externalapplication['headers']);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_VERBOSE, 1);
if (isset($externalapplication['ssl_verify'])) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $externalapplication['ssl_verify']);
if (isset($externalapplication['ssl_verify']) && $externalapplication['ssl_verify'] > 0) {
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $externalapplication['ssl_verify']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $externalapplication['ssl_verify']);
}
@@ -432,7 +454,9 @@ function plugin_item_update_processmaker_tasks($parm) {
$response = curl_exec ($ch);
if ($response === false) {
//throw new Exception(curl_error($ch), curl_errno($ch));
Toolbox::logDebug( curl_error($ch).":".curl_errno($ch) );
Toolbox::logDebug(curl_error($ch) . ":" . curl_errno($ch));
// Set 0 to the crontask action status
$cronaction->update(['id ' => $cronaction->getID(), 'state' => PluginProcessmakerCrontaskaction::CURL_ERROR]);
}
curl_close ($ch);

View File

@@ -1,23 +1,23 @@
<?php
/**
* PluginProcessmakerCrontaskaction is used to manage actions between cases
*
* Allows actions: routing cases (called slaves) from another case (called master)
*
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCrontaskaction extends CommonDBTM {
// postdata are of the form:
// {"form":{"RELEASE_DONE":"0","btnGLPISendRequest":"submit"},"UID":"28421020557bffc5b374850018853291","__DynaformName__":"51126098657bd96b286ded7016691792_28421020557bffc5b374850018853291","__notValidateThisFields__":"[]","DynaformRequiredFields":"[]","APP_UID":"6077575685836f7d89cabe6013770123","DEL_INDEX":"4"}
const WAITING_DATA = 1;
const DATA_READY = 2;
const DONE = 3;
const NOT_DONE = 4;
}
<?php
/**
* PluginProcessmakerCrontaskaction is used to manage actions between cases
*
* Allows actions: routing cases (called slaves) from another case (called master)
*
*
* @version 1.0
* @author MoronO
*/
class PluginProcessmakerCrontaskaction extends CommonDBTM {
// postdata are of the form:
// {"form":{"RELEASE_DONE":"0","btnGLPISendRequest":"submit"},"UID":"28421020557bffc5b374850018853291","__DynaformName__":"51126098657bd96b286ded7016691792_28421020557bffc5b374850018853291","__notValidateThisFields__":"[]","DynaformRequiredFields":"[]","APP_UID":"6077575685836f7d89cabe6013770123","DEL_INDEX":"4"}
const CURL_ERROR = 0;
const WAITING_DATA = 1;
const DATA_READY = 2;
const DONE = 3;
const NOT_DONE = 4;
}

View File

@@ -45,10 +45,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
}
// static function getIcon() {
//// return "fas fa-code-branch fa-rotate-90";
// return "fas fa-blog fa-flip-vertical";
//// return "fas fa-cogs fa-flip-vertical";
// static function getIcon() {
//// return "fas fa-code-branch fa-rotate-90";
// return "fas fa-blog fa-flip-vertical";
//// return "fas fa-cogs fa-flip-vertical";
// }
@@ -151,16 +151,16 @@ class PluginProcessmakerProcess extends CommonDBTM {
$countElt += $dbu->countElementsInTable( $dbu->getTableForItemType($obj), "taskcategories_id = ".$task['taskcategories_id'] );
if ($countElt != 0) {
// just set 'is_active' to 0
$pmtask->Update( [ 'id' => $task['id'], 'is_start' => 0, 'is_active' => 0 ] );
$pmtask->Update(['id' => $task['id'], 'is_start' => 0, 'is_active' => 0]);
break;
}
}
if ($countElt == 0) {
// purge this category as it is not used anywhere
$taskCat = new TaskCategory;
$taskCat->delete([ 'id' => $task['taskcategories_id'] ], 1);
$taskCat->delete(['id' => $task['taskcategories_id']], 1);
$pmTaskCat = new PluginProcessmakerTaskCategory;
$pmTaskCat->delete([ 'id' => $task['id'] ], 1);
$pmTaskCat->delete(['id' => $task['id']], 1);
}
}
@@ -169,32 +169,52 @@ class PluginProcessmakerProcess extends CommonDBTM {
$taskCat = new TaskCategory;
if ($pmTaskCat->getFromGUID( $taskGUID )) {
// got it then check names, and if != update
if ($taskCat->getFromDB( $pmTaskCat->fields['taskcategories_id'] )) {
if ($taskCat->getFromDB($pmTaskCat->fields['taskcategories_id'])) {
// found it must test if should be updated
if ($taskCat->fields['name'] != $task['TAS_TITLE'] || $taskCat->fields['comment'] != $task['TAS_DESCRIPTION']) {
$taskCat->update( [ 'id' => $taskCat->getID(), 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ] );
if ($taskCat->fields['name'] != $task['TAS_TITLE']
|| $taskCat->fields['comment'] != $task['TAS_DESCRIPTION']) {
$taskCat->update([
'id' => $taskCat->getID(),
'name' => $PM_DB->escape($task['TAS_TITLE']),
'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']),
'taskcategories_id' => $this->fields['taskcategories_id'],
'is_active' => 0 // to prevent use of this task cat in manual tasks
] );
}
if ($pmTaskCat->fields['is_start'] != $task['is_start']) {
$pmTaskCat->update( [ 'id' => $pmTaskCat->getID(), 'is_start' => $task['is_start'] ] );
$pmTaskCat->update(['id' => $pmTaskCat->getID(), 'is_start' => $task['is_start']]);
}
} else {
// taskcat must be created
$taskCat->add( [ 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ] );
$taskCat->add([
'is_recursive' => true,
'name' => $PM_DB->escape($task['TAS_TITLE']),
'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']),
'taskcategories_id' => $this->fields['taskcategories_id'],
'is_active' => 0 // to prevent use of this task cat in manual tasks
] );
// update pmTaskCat
$pmTaskCat->update( [ 'id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'is_start' => $task['is_start'] ] );
$pmTaskCat->update(['id' => $pmTaskCat->getID(), 'taskcategories_id' => $taskCat->getID(), 'is_start' => $task['is_start']]);
}
} else {
// should create a new one
// taskcat must be created
$taskCat->add( [ 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ] );
$taskCat->add([
'is_recursive' => true,
'name' => $PM_DB->escape($task['TAS_TITLE']),
'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']),
'taskcategories_id' => $this->fields['taskcategories_id'],
'is_active' => 0 // to prevent use of this task cat in manual tasks
] );
// pmTaskCat must be created too
$pmTaskCat->add( ['plugin_processmaker_processes_id' => $this->getID(),
'pm_task_guid' => $taskGUID,
'taskcategories_id' => $taskCat->getID(),
'is_start' => $task['is_start'],
'is_active' => 1,
'is_subprocess' => $task['is_subprocess']
] );
$pmTaskCat->add([
'plugin_processmaker_processes_id' => $this->getID(),
'pm_task_guid' => $taskGUID,
'taskcategories_id' => $taskCat->getID(),
'is_start' => $task['is_start'],
'is_active' => 1,
'is_subprocess' => $task['is_subprocess']
]);
}
// here we should take into account translations if any
if (isset($taskArray[ $taskGUID ])) {
@@ -371,7 +391,12 @@ class PluginProcessmakerProcess extends CommonDBTM {
global $PM_DB;
$taskCat = new TaskCategory;
if ($taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name']) {
return $taskCat->update( [ 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])] );
return $taskCat->update([
'id' => $taskCat->getID(),
'taskcategories_id' => $pmMainTaskCat,
'name' => $PM_DB->escape($this->fields['name']),
'is_active' => 0 // to prevent use of this task cat in a manual task
] );
}
return false;
}
@@ -385,7 +410,12 @@ class PluginProcessmakerProcess extends CommonDBTM {
function addTaskCategory($pmMainTaskCat) {
global $PM_DB;
$taskCat = new TaskCategory;
if ($taskCat->add( [ 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])] )) {
if ($taskCat->add([
'is_recursive' => true,
'taskcategories_id' => $pmMainTaskCat,
'name' => $PM_DB->escape($this->fields['name']),
'is_active' => 0 // to prevent use of this task cat in a manual task
])) {
return $this->update( [ 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ] );
}
return false;

View File

@@ -1569,7 +1569,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
'itemtype' => $itemtype,
'items_id' => $items_id,
'entities_id' => $parm->fields['entities_id'],
'name' => $caseInfo->caseName,
'name' => $DB->escape($caseInfo->caseName),
'case_guid' => $case_guid,
'case_status' => $caseInfo->caseStatus,
'plugin_processmaker_processes_id' => $parm->input['processmaker_processes_id']
@@ -1831,7 +1831,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* Summary of getGLPIGroupId
* returns GLPI group id from pm group name
* returns false when not found
* @param string $pmGroupName
* @param string $pmGroupName
* @return bool|integer
*/
static function getGLPIGroupId(string $pmGroupName) {
@@ -1840,7 +1840,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$query = "SELECT id AS glpi_group_id FROM glpi_groups WHERE name LIKE '$pmGroupName';";
$res = $DB->query($query);
if ($DB->numrows($res) > 0) {
$row = $DB->fetch_array($res);
$row = $DB->fetchArray($res);
return $row['glpi_group_id'];
}
}
@@ -1950,13 +1950,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
global $DB;
$dbu = new DbUtils;
$item = $dbu->getItemForItemtype( $itemType );
if ($item->getFromDB( $itemId )) {
$item = $dbu->getItemForItemtype($itemType);
if ($item->getFromDB($itemId)) {
// default values
$solutiontemplates_id = 0;
$solutiontypes_id = 0;
$solution = '';
$to_update = false;
$solution_content = '';
$to_add = false;
// check solution template
if (array_key_exists( 'GLPI_ITEM_SET_SOLUTION_TEMPLATE_ID', $casevariablevalues )
@@ -1968,10 +1967,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$entities = $template->isRecursive() ? $dbu->getSonsOf(Entity::getTable(), $template->getEntityID()) : [$template->getEntityID()];
// and check entities
if (in_array($item->getEntityID(), $entities)) {
$solutiontemplates_id = $template->getID();
$solutiontypes_id = $template->fields['solutiontypes_id'];
$solution = $template->fields['content'];
$to_update = true;
$solution_content = $template->fields['content'];
$to_add = true;
}
}
@@ -1986,22 +1984,28 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// and check entities
if (in_array($item->getEntityID(), $entities)) {
$solutiontypes_id = $type->getID();
$to_update = true;
$to_add = true;
}
}
// Check solution description
if (array_key_exists( 'GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION', $casevariablevalues )
&& $casevariablevalues[ 'GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION' ] != '') {
if ($solution != '') {
$solution .= "\n";
if ($solution_content != '') {
$solution_content .= "\n";
}
$solution .= $DB->escape($casevariablevalues[ 'GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION' ]);
$to_update = true;
$solution_content .= $DB->escape($casevariablevalues[ 'GLPI_ITEM_APPEND_TO_SOLUTION_DESCRIPTION' ]);
$to_add = true;
}
if ($to_update) {
$item->update( ['id' => $itemId, 'solutiontemplates_id' => $solutiontemplates_id, 'solutiontypes_id' => $solutiontypes_id, 'solution' => $solution] );
if ($to_add) {
$solution = new ITILSolution();
$solution->add([
'itemtype' => $itemType,
'items_id' => $itemId,
'solutiontypes_id' => $solutiontypes_id,
'content' => $solution_content
]);
}
}
}
@@ -2335,8 +2339,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
//global $pmHideSolution;
$plugin = new Plugin();
$itemtype = $params['item']->getType();
if (in_array($itemtype, ['Ticket', 'Problem', 'Change'])
&& $params['options']['id']
if (in_array($itemtype, ['Ticket', 'Problem', 'Change'])
&& $params['options']['id']
&& $params['options']['itemtype'] == $itemtype
&& $params['options']['tabnum'] == 1
&& !PluginProcessmakerCase::canSolve($params)
@@ -2347,7 +2351,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// don't display message if arbehaviours is install and activated
$itemtype = strtolower($itemtype);
if ((!$plugin->isInstalled('arbehaviours') || !$plugin->isActivated('arbehaviours'))
if ((!$plugin->isInstalled('arbehaviours') || !$plugin->isActivated('arbehaviours'))
&& isset($_SESSION['glpiactiveprofile'][$itemtype.'_status'])) {
echo Html::scriptBlock("
@@ -2452,10 +2456,10 @@ debugger;
fflush($curl_log);
curl_setopt($ch, CURLOPT_STDERR, $curl_log);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Expect:"]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->config->fields['ssl_verify']);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->config->fields['ssl_verify']);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, ($this->config->fields['ssl_verify'] > 0 ? 2 : 0));
//curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine");
// to store cookies in memory
@@ -3039,7 +3043,7 @@ debugger;
}
if ($itemSetStatus != '') {
$this->setItemStatus($itemtype, $items_id, $itemSetStatus );
$this->setItemStatus($itemtype, $items_id, $itemSetStatus);
}
// get the new case info
@@ -3053,7 +3057,7 @@ debugger;
$taskCat = new TaskCategory;
$taskCat->getFromDB($glpi_task->fields['taskcategories_id']);
// we may replace ##casename## by the name of the case, and ##taskname## by the task name
$search = ['##casename##',
$search = ['##casename##',
'##taskname##'
];
$replace = [$caseInfo->caseName." (".$myCase->getID().")",
@@ -3347,7 +3351,7 @@ debugger;
$class = 'warn_msg';
break;
case INFO:
$title = _sn('Information', 'Information', 1);
$title = _sn('Information', 'Information', 1);
$class = 'info_msg';
break;
}
@@ -3465,7 +3469,7 @@ debugger;
// we must differentiate if rule assignement is self-service or self-service value based
//$query = "SELECT TAS_GROUP_VARIABLE
// FROM TASK
// FROM TASK
// WHERE TAS_UID='$pmTaskId'
// AND TAS_ASSIGN_TYPE='SELF_SERVICE';";
$query = ['SELECT' => 'TAS_GROUP_VARIABLE',
@@ -3483,8 +3487,8 @@ debugger;
// TU_RELATION=2 is groups and TU_TYPE=1 means normal (= not adhoc)
$queryname = "SELECT GROUPWF.GRP_TITLE AS 'GRP_TITLE', GROUPWF.GRP_UID AS 'GRP_UID' FROM TASK_USER
JOIN GROUPWF ON GROUPWF.GRP_UID = TASK_USER.USR_UID
WHERE TASK_USER.TAS_UID = '$pmTaskId'
AND TASK_USER.TU_RELATION = 2
WHERE TASK_USER.TAS_UID = '$pmTaskId'
AND TASK_USER.TU_RELATION = 2
AND TASK_USER.TU_TYPE = 1
LIMIT 1;";
} else {
@@ -3507,13 +3511,15 @@ debugger;
// or
// as there is only one group per guid
// then we should have at maximun 1 record
foreach ($PM_DB->request($queryname) as $onlyrec) {
$groupname = $onlyrec;
if (isset($queryname)) {
foreach ($PM_DB->request($queryname) as $onlyrec) {
$groupname = $onlyrec;
}
}
if (isset($groupname)) {
return ['name' => $groupname['GRP_TITLE'],
'id' => self::getGLPIGroupId($groupname['GRP_TITLE']),
return ['name' => $groupname['GRP_TITLE'],
'id' => self::getGLPIGroupId($groupname['GRP_TITLE']),
'uid' => $groupname['GRP_UID']
];
}

View File

@@ -23,13 +23,13 @@ class PluginProcessmakerUser extends CommonDBTM {
* @param integer $value default value
* @param integer[] $used array: Already used items ID: not to display in dropdown
* @param string $search pattern
* @param integer $start start LIMIT value (default 0)
* @param integer $limit limit LIMIT value (default -1 no limit)
* @param integer $start start LIMIT value (default 0)
* @param integer $limit limit LIMIT value (default -1 no limit)
* @param boolean $inactive_deleted true to retreive also inactive or deleted users
* @return DBmysqlIterator
**/
static function getSqlSearchResult (array $tags, $count = true, $right = "all", $entity_restrict = -1, $value = 0,
array $used = [], $search = '',$start = 0, $limit = -1,
array $used = [], $search = '',$start = 0, $limit = -1,
$inactive_deleted = 0) {
global $DB, $PM_DB, $CFG_GLPI;
@@ -83,7 +83,7 @@ class PluginProcessmakerUser extends CommonDBTM {
'WHERE' => ['GROUP_USER.GRP_UID' => $tags['grpGuid']]
]);
$subqueries[] = $res3;
}
@@ -110,6 +110,9 @@ class PluginProcessmakerUser extends CommonDBTM {
break;
}
if (count($pmUsers) == 0) { // to prevent add of empty array in where clause
$pmUsers = 0;
}
$query['WHERE']['AND']['glpi_plugin_processmaker_users.pm_users_id'] = $pmUsers;
$query['WHERE']['AND']['glpi_users.is_deleted'] = 0;
$query['WHERE']['AND']['glpi_users.is_active'] = 1;
@@ -132,7 +135,7 @@ class PluginProcessmakerUser extends CommonDBTM {
$query['DISTINCT'] = true;
}
$query['FROM'] = 'glpi_plugin_processmaker_users';
$query['FROM'] = 'glpi_plugin_processmaker_users';
$query['INNER JOIN'] = [
'glpi_users' => [
@@ -177,16 +180,16 @@ class PluginProcessmakerUser extends CommonDBTM {
$query['WHERE']['AND']['NOT']['glpi_users.id'] = $used;
} else {
if (strlen($search)>0 && $search!=$CFG_GLPI["ajax_wildcard"]) {
$txt_search = Search::makeTextSearchValue($search);
$firstname_field = $DB->quoteName(User::getTableField('firstname'));
$realname_field = $DB->quoteName(User::getTableField('realname'));
$fields = $_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE
? [$firstname_field, $realname_field]
: [$realname_field, $firstname_field];
$concat = new \QueryExpression(
'CONCAT(' . implode(',' . $DB->quoteValue(' ') . ',', $fields) . ')'
. ' LIKE ' . $DB->quoteValue($txt_search)
$txt_search = Search::makeTextSearchValue($search);
$firstname_field = $DB->quoteName(User::getTableField('firstname'));
$realname_field = $DB->quoteName(User::getTableField('realname'));
$fields = $_SESSION["glpinames_format"] == User::FIRSTNAME_BEFORE
? [$firstname_field, $realname_field]
: [$realname_field, $firstname_field];
$concat = new \QueryExpression(
'CONCAT(' . implode(',' . $DB->quoteValue(' ') . ',', $fields) . ')'
. ' LIKE ' . $DB->quoteValue($txt_search)
);
$query['WHERE']['AND'] = [
'glpi_users.name' => ['LIKE', $txt_search],
@@ -296,7 +299,7 @@ class PluginProcessmakerUser extends CommonDBTM {
* Summary of getGlpiIdFromAny
* Returns the GLPI id of the user or false if not found
* Accept either PM GUID, GLPI logon, or GLPI ID
* @param $any
* @param $any
* @return mixed GLPI ID of the user or false if not found
*/
public static function getGlpiIdFromAny($any) {

View File

@@ -1,194 +1,194 @@
<?php
function update_to_3_2_8() {
global $DB;
if ($DB->tableExists("glpi_plugin_processmaker_config")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_config`
ADD COLUMN `date_mod` DATETIME NULL DEFAULT NULL AFTER `pm_theme`,
ADD COLUMN `comment` TEXT NULL AFTER `date_mod`;
RENAME TABLE `glpi_plugin_processmaker_config` TO `glpi_plugin_processmaker_configs`;";
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbserver_name" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_group_guid`,
ADD COLUMN `pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_name`,
ADD COLUMN `pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_user`;";
$DB->query($query) or die("error adding fields pm_dbserver_name, pm_dbserver_user, pm_dbserver_passwd to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "domain" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `domain` VARCHAR(50) NULL DEFAULT '' AFTER `pm_dbserver_passwd`;
";
$DB->query($query) or die("error adding field domain to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "maintenance" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `domain`;
;";
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbname" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
;";
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
$DB->query("UPDATE glpi_plugin_processmaker_configs SET `pm_dbname` = CONCAT('wf_', `pm_workspace`) WHERE `id` = 1");
}
if ($DB->tableExists("glpi_plugin_processmaker_profiles")) {
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_cases", "processes_id")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
ADD COLUMN `processes_id` INT(11) NULL DEFAULT NULL;
";
$DB->query($query) or die("error adding column processes_id into glpi_plugin_processmaker_cases" . $DB->error());
} else {
$flds = $DB->list_fields('glpi_plugin_processmaker_cases');
if (strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0) {
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/process.class.php");
include_once(GLPI_ROOT."/plugins/processmaker/inc/case.class.php");
$proc = new PluginProcessmakerProcess;
$case = new PluginProcessmakerCase;
foreach ($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
$proc->getFromGUID( $row['processes_id'] );
$case->update([ 'id' => $row['id'], 'processes_id' => $proc->getID() ] );
}
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
CHANGE COLUMN `processes_id` `processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`;
";
$DB->query($query) or die("error converting column processes_id into INT(11) in glpi_plugin_processmaker_cases" . $DB->error());
}
}
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`,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error adding column 'password' to glpi_plugin_processmaker_users" . $DB->error());
// also need to change text of tasks for tasks linked to cases
$query = "UPDATE glpi_tickettasks SET content=REPLACE(content,'##_PluginProcessmakerCases\$processmakercases','##_PluginProcessmakerCase\$processmakercases')
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'";
$DB->query($query) or die("error updating TicketTask" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_users', 'glpi_users_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ALTER `glpi_users_id` DROP DEFAULT,
DROP PRIMARY KEY,
DROP COLUMN `id`,
DROP INDEX `glpi_users_id`;
";
$DB->query($query) or die("error droping 'defaults' from 'glpi_users_id' to glpi_plugin_processmaker_users" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
CHANGE COLUMN `glpi_users_id` `id` INT(11) NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error renaming 'glpi_users_id' into 'id' to glpi_plugin_processmaker_users" . $DB->error());
}
if ($DB->fieldExists( 'glpi_plugin_processmaker_processes', 'is_helpdeskvisible')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
CHANGE COLUMN `is_helpdeskvisible` `is_helpdeskvisible_notusedanymore` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Not used any more since version 2.2' AFTER `name`;";
$DB->query($query);
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'itilcategories_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `itilcategories_id` INT(11) NOT NULL DEFAULT '0',
ADD COLUMN `type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets';";
$DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'project_type')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';";
$DB->query($query) or die("error adding columns 'project_type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_taskcategories', 'is_active')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_taskcategories`
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `start`;";
$DB->query($query) or die("error adding field is_active to glpi_plugin_processmaker_taskcategories table" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'postdatas')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `postdatas` `postdata` MEDIUMTEXT NULL DEFAULT NULL AFTER `toclaim`;";
$DB->query($query) or die("error changing 'postdatas' from glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'logs_out')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
ADD COLUMN `logs_out` MEDIUMTEXT NULL AFTER `postdata`;";
$DB->query($query) or die("error adding 'logs_out' field into glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_crontaskactions", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `toclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `users_id`;";
$DB->query($query) or die("error renaming toclaim in glpi_plugin_processmaker_crontaskactions" . $DB->error());
}
//if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "plugin_processmaker_taskcategories_id_source")) {
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// ADD COLUMN `plugin_processmaker_taskcategories_id_source` INT(11) NULL DEFAULT NULL AFTER `sourcetask_guid`,
// ADD COLUMN `plugin_processmaker_taskcategories_id_target` INT(11) NULL DEFAULT NULL AFTER `targettask_guid`,
// ADD COLUMN `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL AFTER `targetprocess_guid`;";
// $DB->query($query) or die("error adding col plugin_processmaker_taskcategories_id_source to glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "UPDATE glpi_plugin_processmaker_caselinks AS pm_cl
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tcsource ON pm_tcsource.pm_task_guid=pm_cl.sourcetask_guid
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tctarget ON pm_tctarget.pm_task_guid=pm_cl.targettask_guid
// LEFT JOIN glpi_plugin_processmaker_processes AS pm_pr ON pm_pr.process_guid=pm_cl.targetprocess_guid
// SET pm_cl.plugin_processmaker_taskcategories_id_source = pm_tcsource.id,
// pm_cl.plugin_processmaker_taskcategories_id_target = pm_tctarget.id,
// pm_cl.plugin_processmaker_processes_id = pm_pr.id;";
// $DB->query($query) or die("error migrating data into col plugin_processmaker_taskcategories_id_source in glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// DROP COLUMN `sourcetask_guid`,
// DROP COLUMN `targettask_guid`,
// DROP COLUMN `targetprocess_guid`;";
// $DB->query($query) or die("error dropping col plugin_processmaker_taskcategories_id_source from glpi_plugin_processmaker_caselinks" . $DB->error());
//}
if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
CHANGE COLUMN `targettoclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `sourcecondition`;";
$DB->query($query) or die("error renaming targettoclaim in glpi_plugin_processmaker_caselinks" . $DB->error());
}
//if( !$DB->tableExists('glpi_plugin_processmaker_selfservicedrafts')){
// $query = "CREATE TABLE `glpi_plugin_processmaker_selfservicedrafts` (
// `id` INT(11) NOT NULL AUTO_INCREMENT,
// `users_id` INT(11) NOT NULL,
// `plugin_processmaker_processes_id` INT(11) NOT NULL,
// `url` TEXT NOT NULL,
// PRIMARY KEY (`id`),
// INDEX `users_id` (`users_id`)
// )
// COLLATE='utf8_general_ci'
// ENGINE=InnoDB
// ;" ;
// $DB->query($query) or die("error creating glpi_plugin_processmaker_selfservicedrafts" . $DB->error());
//}
return '3.2.8';
}
<?php
function update_to_3_2_8() {
global $DB;
if ($DB->tableExists("glpi_plugin_processmaker_config")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_config`
ADD COLUMN `date_mod` DATETIME NULL DEFAULT NULL AFTER `pm_theme`,
ADD COLUMN `comment` TEXT NULL AFTER `date_mod`;
RENAME TABLE `glpi_plugin_processmaker_config` TO `glpi_plugin_processmaker_configs`;";
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbserver_name" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_group_guid`,
ADD COLUMN `pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_name`,
ADD COLUMN `pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_user`;";
$DB->query($query) or die("error adding fields pm_dbserver_name, pm_dbserver_user, pm_dbserver_passwd to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "domain" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `domain` VARCHAR(50) NULL DEFAULT '' AFTER `pm_dbserver_passwd`;
";
$DB->query($query) or die("error adding field domain to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "maintenance" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `domain`;
;";
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbname" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
;";
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
$DB->query("UPDATE glpi_plugin_processmaker_configs SET `pm_dbname` = CONCAT('wf_', `pm_workspace`) WHERE `id` = 1");
}
if ($DB->tableExists("glpi_plugin_processmaker_profiles")) {
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_cases", "processes_id")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
ADD COLUMN `processes_id` INT(11) NULL DEFAULT NULL;
";
$DB->query($query) or die("error adding column processes_id into glpi_plugin_processmaker_cases" . $DB->error());
} else {
$flds = $DB->listFields('glpi_plugin_processmaker_cases');
if (strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0) {
// required because autoload doesn't work for unactive plugin'
include_once(GLPI_ROOT."/plugins/processmaker/inc/process.class.php");
include_once(GLPI_ROOT."/plugins/processmaker/inc/case.class.php");
$proc = new PluginProcessmakerProcess;
$case = new PluginProcessmakerCase;
foreach ($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
$proc->getFromGUID( $row['processes_id'] );
$case->update([ 'id' => $row['id'], 'processes_id' => $proc->getID() ] );
}
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
CHANGE COLUMN `processes_id` `processes_id` INT(11) NULL DEFAULT NULL AFTER `case_status`;
";
$DB->query($query) or die("error converting column processes_id into INT(11) in glpi_plugin_processmaker_cases" . $DB->error());
}
}
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`,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error adding column 'password' to glpi_plugin_processmaker_users" . $DB->error());
// also need to change text of tasks for tasks linked to cases
$query = "UPDATE glpi_tickettasks SET content=REPLACE(content,'##_PluginProcessmakerCases\$processmakercases','##_PluginProcessmakerCase\$processmakercases')
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'";
$DB->query($query) or die("error updating TicketTask" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_users', 'glpi_users_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ALTER `glpi_users_id` DROP DEFAULT,
DROP PRIMARY KEY,
DROP COLUMN `id`,
DROP INDEX `glpi_users_id`;
";
$DB->query($query) or die("error droping 'defaults' from 'glpi_users_id' to glpi_plugin_processmaker_users" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
CHANGE COLUMN `glpi_users_id` `id` INT(11) NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error renaming 'glpi_users_id' into 'id' to glpi_plugin_processmaker_users" . $DB->error());
}
if ($DB->fieldExists( 'glpi_plugin_processmaker_processes', 'is_helpdeskvisible')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
CHANGE COLUMN `is_helpdeskvisible` `is_helpdeskvisible_notusedanymore` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Not used any more since version 2.2' AFTER `name`;";
$DB->query($query);
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'itilcategories_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `itilcategories_id` INT(11) NOT NULL DEFAULT '0',
ADD COLUMN `type` INT(11) NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets';";
$DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'project_type')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';";
$DB->query($query) or die("error adding columns 'project_type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_taskcategories', 'is_active')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_taskcategories`
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `start`;";
$DB->query($query) or die("error adding field is_active to glpi_plugin_processmaker_taskcategories table" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'postdatas')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `postdatas` `postdata` MEDIUMTEXT NULL DEFAULT NULL AFTER `toclaim`;";
$DB->query($query) or die("error changing 'postdatas' from glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'logs_out')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
ADD COLUMN `logs_out` MEDIUMTEXT NULL AFTER `postdata`;";
$DB->query($query) or die("error adding 'logs_out' field into glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_crontaskactions", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `toclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `users_id`;";
$DB->query($query) or die("error renaming toclaim in glpi_plugin_processmaker_crontaskactions" . $DB->error());
}
//if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "plugin_processmaker_taskcategories_id_source")) {
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// ADD COLUMN `plugin_processmaker_taskcategories_id_source` INT(11) NULL DEFAULT NULL AFTER `sourcetask_guid`,
// ADD COLUMN `plugin_processmaker_taskcategories_id_target` INT(11) NULL DEFAULT NULL AFTER `targettask_guid`,
// ADD COLUMN `plugin_processmaker_processes_id` INT(11) NULL DEFAULT NULL AFTER `targetprocess_guid`;";
// $DB->query($query) or die("error adding col plugin_processmaker_taskcategories_id_source to glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "UPDATE glpi_plugin_processmaker_caselinks AS pm_cl
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tcsource ON pm_tcsource.pm_task_guid=pm_cl.sourcetask_guid
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tctarget ON pm_tctarget.pm_task_guid=pm_cl.targettask_guid
// LEFT JOIN glpi_plugin_processmaker_processes AS pm_pr ON pm_pr.process_guid=pm_cl.targetprocess_guid
// SET pm_cl.plugin_processmaker_taskcategories_id_source = pm_tcsource.id,
// pm_cl.plugin_processmaker_taskcategories_id_target = pm_tctarget.id,
// pm_cl.plugin_processmaker_processes_id = pm_pr.id;";
// $DB->query($query) or die("error migrating data into col plugin_processmaker_taskcategories_id_source in glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// DROP COLUMN `sourcetask_guid`,
// DROP COLUMN `targettask_guid`,
// DROP COLUMN `targetprocess_guid`;";
// $DB->query($query) or die("error dropping col plugin_processmaker_taskcategories_id_source from glpi_plugin_processmaker_caselinks" . $DB->error());
//}
if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
CHANGE COLUMN `targettoclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `sourcecondition`;";
$DB->query($query) or die("error renaming targettoclaim in glpi_plugin_processmaker_caselinks" . $DB->error());
}
//if( !$DB->tableExists('glpi_plugin_processmaker_selfservicedrafts')){
// $query = "CREATE TABLE `glpi_plugin_processmaker_selfservicedrafts` (
// `id` INT(11) NOT NULL AUTO_INCREMENT,
// `users_id` INT(11) NOT NULL,
// `plugin_processmaker_processes_id` INT(11) NOT NULL,
// `url` TEXT NOT NULL,
// PRIMARY KEY (`id`),
// INDEX `users_id` (`users_id`)
// )
// COLLATE='utf8_general_ci'
// ENGINE=InnoDB
// ;" ;
// $DB->query($query) or die("error creating glpi_plugin_processmaker_selfservicedrafts" . $DB->error());
//}
return '3.2.8';
}

View File

@@ -41,7 +41,7 @@
<compatibility>9.4</compatibility>
</version>
<version>
<num>4.0.8</num>
<num>4.0.11</num>
<compatibility>9.5</compatibility>
</version>
</versions>

View File

@@ -1,6 +1,6 @@
<?php
define('PROCESSMAKER_VERSION', '4.0.8');
define('PROCESSMAKER_VERSION', '4.0.11');
// used for case cancellation
define("CANCEL", 256);
@@ -130,7 +130,7 @@ function plugin_init_processmaker() {
// in order to manage the password encryption
$pmglpikey = new PluginProcessmakerGlpikey;
foreach ($pmglpikey->getFields() as $fld) {
$PLUGIN_HOOKS['secured_fields'][] = $fld;
$PLUGIN_HOOKS['secured_fields'][] = [$fld];
}
//}
}