Skip to content

Commit

Permalink
Fixed issue that prevents script tasks to be executed and synchronize…
Browse files Browse the repository at this point in the history
…d with GLPI items

Set version to RE-2.4
  • Loading branch information
tomolimo committed Jan 9, 2024
1 parent 369b9f6 commit 658e93a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
65 changes: 43 additions & 22 deletions workflow/engine/classes/WsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function login($userid, $password)

$sessionId = G::generateUniqueID();
$wsResponse = new WsResponse('0', $sessionId);
$timelife = explode( ':', gmdate("H:i:s", ini_get('session.cookie_lifetime')));
$timelife = explode( ':', gmdate("H:i:s", ini_get('session.cookie_lifetime')));
$session = new Session();
$session->setSesUid($sessionId);
$session->setSesStatus('ACTIVE');
Expand All @@ -81,7 +81,7 @@ public function login($userid, $password)
$session->setSesInitDate(date('Y-m-d H:i:s'));
$session->setSesDueDate(date(
'Y-m-d H:i:s',
mktime(date('H') + $timelife[0], date('i') + $timelife[1], date('s') + $timelife[2], date('m'), date('d'), date('Y'))
mktime(date('H') + $timelife[0], date('i') + $timelife[1], date('s') + $timelife[2], date('m'), date('d'), date('Y'))
));
$session->setSesEndDate('');
$session->Save();
Expand All @@ -106,18 +106,18 @@ public function login($userid, $password)
public function processList()
{
try {
// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
$ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro') );
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = [];

while ($ds->next()) {
$row = $ds->getRow();
$bpmnProjects[] = $row['PRJ_UID'];
}

// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
$ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro') );
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = [];

while ($ds->next()) {
$row = $ds->getRow();
$bpmnProjects[] = $row['PRJ_UID'];
}

$result = [];
$oCriteria = new Criteria('workflow');
$oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
Expand All @@ -130,8 +130,8 @@ public function processList()
$arrayProcess = $oProcess->load($aRow['PRO_UID']);
$result[] = array(
'guid' => $aRow['PRO_UID'],
'name' => $arrayProcess['PRO_TITLE'],
'project_type' => in_array($aRow['PRO_UID'], $bpmnProjects) ? 'bpmn' : 'classic'
'name' => $arrayProcess['PRO_TITLE'],
'project_type' => in_array($aRow['PRO_UID'], $bpmnProjects) ? 'bpmn' : 'classic'
);
$oDataset->next();
}
Expand Down Expand Up @@ -549,14 +549,14 @@ public function userList()
try {
$result = [];
$criteria = new Criteria('workflow');
//$criteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
//$criteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
$criteria->add(UsersPeer::USR_UID, [RBAC::GUEST_USER_UID], Criteria::NOT_IN);
$dataset = UsersPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();

while ($row = $dataset->getRow()) {
$result[] = ['guid' => $row['USR_UID'], 'name' => $row['USR_USERNAME'], 'status' => $row['USR_STATUS']];
$result[] = ['guid' => $row['USR_UID'], 'name' => $row['USR_USERNAME'], 'status' => $row['USR_STATUS']];
$dataset->next();
}

Expand Down Expand Up @@ -1788,7 +1788,7 @@ public function getVariables($caseId, $variables)
$resFields = [];

foreach ($variables as $key => $val) {
//$a .= $val->name . ', ';
//$a .= $val->name . ', ';

if (isset($oldFields[$val->name])) {
if (!is_array($oldFields[$val->name])) {
Expand Down Expand Up @@ -2487,21 +2487,42 @@ public function derivateCase($userId, $caseId, $delIndex, $bExecuteTriggersBefor
//Now fill the array of AppDelegationPeer
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_THREAD);
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_THREAD_STATUS);
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
$oCriteria->add(AppDelegationPeer::APP_UID, $caseId);
$oCriteria->add(AppDelegationPeer::DEL_PREVIOUS, $delIndex);
$oCriteria->addAscendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

$aCurrentUsers = [];


// all tasks
$allTasks = [];
while ($oDataset->next()) {
$aAppDel = $oDataset->getRow();
$allTasks[$aAppDel['DEL_INDEX']] = $aAppDel;
}

function searchNewlyActivatedTasks($tasks, $prev_index) {
$ret = [];
foreach(array_filter($tasks, function($rw) use($prev_index) {
return $rw['DEL_PREVIOUS'] == $prev_index;
}) as $task) {
if ($task['DEL_THREAD_STATUS'] == 'CLOSED') {
$ret = array_merge($ret, searchNewlyActivatedTasks($tasks, $task['DEL_INDEX']));
} else {
$ret[] = $tasks[$task['DEL_INDEX']];
}
}
return $ret;
}

// search the tasks with matching previous_index to be able to get the newly created tasks
foreach (searchNewlyActivatedTasks($allTasks, $delIndex) as $aAppDel) {
$oUser = new Users();

try {
Expand Down Expand Up @@ -2930,7 +2951,7 @@ public function systemInformation()
define('SKIP_RENDER_SYSTEM_INFORMATION', true);

require_once(PATH_METHODS . 'login' . PATH_SEP . 'dbInfo.php');
$result = new stdClass;
$result = new stdClass;
$result->status_code = 0;
$result->message = G::loadTranslation('ID_SUCESSFUL');
$result->timestamp = date('Y-m-d H:i:s');
Expand Down
4 changes: 2 additions & 2 deletions workflow/engine/methods/login/version-pmos.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if (!defined('PM_VERSION')) {
define("PM_VERSION", "3.3.0-community-RE-2.3");
define("PM_BUILD_VERSION", "3.3.0-community-RE-2.3");
define("PM_VERSION", "3.3.0-community-RE-2.4");
define("PM_BUILD_VERSION", "3.3.0-community-RE-2.4");
}

0 comments on commit 658e93a

Please sign in to comment.