diff --git a/workflow/engine/classes/Cases.php b/workflow/engine/classes/Cases.php index 705f6c0ae..c22ab96b6 100644 --- a/workflow/engine/classes/Cases.php +++ b/workflow/engine/classes/Cases.php @@ -2035,22 +2035,44 @@ class Cases } /** - * This function start a case using the task for the user $usrUid - * With this function we can Start a case - * - * @name startCase - * @param string $tasUid - * @param string $usrUid - * @param bool $isSubprocess - * @param array $previousInfo - * @param bool $isSelfService - * @param string $sequenceType - * - * @return Fields - * @throw Exception + * The startCase function is designed to start a new case using a specified task ($tasUid) for a user ($usrUid). + * It handles various scenarios, including subprocesses, self-service tasks, and multiple instances of tasks. + * + * Parameters + * - $tasUid: The unique identifier for the task that is being started. + * - $usrUid: The unique identifier for the user who is starting the case. + * - $isSubprocess: A boolean indicating whether the case is being started as a subprocess. + * - $previousInfo: An array containing any previous information related to the case (not used in the provided code). + * - $isSelfService: A boolean indicating whether the case is being started in a self-service context. + * - $sequenceType: A string indicating the type of sequence for the application (default is AppSequence::APP_TYPE_NORMAL). + * Return Value + * The function returns an array containing: + * - APPLICATION: The unique identifier of the created application. + * - INDEX: The delegation index. + * - PROCESS: The unique identifier of the process. + * - CASE_NUMBER: The case number of the created application. + * Exception Handling + * The function throws exceptions in various scenarios, such as when the task does not exist or when required parameters are missing. */ public function startCase(string $tasUid, string $usrUid, $isSubprocess = false, $previousInfo = [], $isSelfService = false, $sequenceType = AppSequence::APP_TYPE_NORMAL) { + /* + 1. checks if $tasUid is not empty. If it is, an exception is thrown user or task UID is missing. + 2. retrieves the task using TaskPeer::retrieveByPK($tasUid) and the user using UsersPeer::retrieveByPK($usrUid). + 3. checks if the task type is not allowed for self-service and if the user UID is empty. eod throws an exception + 4. loads the process associated with the task using $task->getProUid() and creates a new Process object. + 5. creates a new application using the Application class, which is associated with the process and user. + 6. creates a new application delegation using the newAppDelegation method. + 7. An application thread is created for the new application. + 8. If the task is of type "MULTIPLE_INSTANCE", it retrieves all users and creates delegations for each user, excluding the current user. + 9. The application is updated with the delegation index and other relevant fields. + 10. An event is created to log the application creation. + 11. The function adds a new row to the inbox for the user and for each user in the multiple instance scenario. + 12. A log entry is created to record the case creation, including relevant context information. + 13. If a specific plugin class exists, it executes triggers related to the case creation. + 14. The function executes any configured triggers for the case creation process. + 15. Finally, the function returns an array containing the application UID, delegation index, process UID, and case number. + */ if (!empty($tasUid)) { try { $task = TaskPeer::retrieveByPK($tasUid); @@ -7371,12 +7393,12 @@ class Cases { $conn = Propel::getConnection('workflow'); - $sql = 'SELECT TASK.TAS_UID, TASK.TAS_TITLE, TASK.TAS_DESCRIPTION, TASK.TAS_START, - TASK.TAS_TYPE, TASK.TAS_DERIVATION, TASK.TAS_ASSIGN_TYPE, APP.USR_UID, USERS.USR_USERNAME, - USERS.USR_FIRSTNAME, USERS.USR_LASTNAME - FROM TASK LEFT JOIN (SELECT * FROM APP_DELEGATION WHERE APP_DELEGATION.APP_UID = ?) AS APP - ON TASK.TAS_UID = APP.TAS_UID LEFT JOIN USERS - ON (SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID = ? AND TAS_UID = TASK.TAS_UID ORDER BY DEL_INDEX DESC LIMIT 1) = USERS.USR_UID + $sql = 'SELECT TASK.TAS_UID, TASK.TAS_TITLE, TASK.TAS_DESCRIPTION, TASK.TAS_START, + TASK.TAS_TYPE, TASK.TAS_DERIVATION, TASK.TAS_ASSIGN_TYPE, APP.USR_UID, USERS.USR_USERNAME, + USERS.USR_FIRSTNAME, USERS.USR_LASTNAME + FROM TASK LEFT JOIN (SELECT * FROM APP_DELEGATION WHERE APP_DELEGATION.APP_UID = ?) AS APP + ON TASK.TAS_UID = APP.TAS_UID LEFT JOIN USERS + ON (SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID = ? AND TAS_UID = TASK.TAS_UID ORDER BY DEL_INDEX DESC LIMIT 1) = USERS.USR_UID WHERE TASK.PRO_UID = ?'; $stmt = $conn->prepareStatement($sql); @@ -7533,4 +7555,3 @@ class Cases return $rsCriteria; } } - diff --git a/workflow/engine/methods/cases/casesStartPage_Ajax.php b/workflow/engine/methods/cases/casesStartPage_Ajax.php index 7caf8fc1d..585a46b4d 100644 --- a/workflow/engine/methods/cases/casesStartPage_Ajax.php +++ b/workflow/engine/methods/cases/casesStartPage_Ajax.php @@ -142,6 +142,15 @@ function ellipsis ($text, $numb) return $text; } +/* Looking for Content Process (seems to be a function semi deprecated: + + The lookinginfor_content_process function takes a spro_uid as an argument. + It queries the Process table to check if a process with the given pro_uid exists. (This happens 99% of the time) + If a process is found, it does nothing. 99% of the time, this is the case. + If no process is found, it queries the Task table for tasks associated with the spro_uid and inserts their titles into the Content table. + It then queries the Process table again to get the process title and inserts it into the Content table. + Example Usage: The example at the bottom shows how to call the lookinginfor_content_process function. +*/ function lookinginforContentProcess ($sproUid) { $oContent = new Content(); @@ -238,7 +247,7 @@ function startCase() // Print JSON response ob_end_clean(); - header('Content-Type: application/json'); + header('Content-Type: application/json'); print (json_encode($newCase)); } catch (Exception $e) { $newCase['status'] = 'failure'; @@ -262,4 +271,3 @@ function getDefaultDashboard () } print_r( G::json_encode( $defaultDashboard ) ); } - diff --git a/workflow/engine/methods/login/session.php b/workflow/engine/methods/login/session.php new file mode 100644 index 000000000..08304ae6e --- /dev/null +++ b/workflow/engine/methods/login/session.php @@ -0,0 +1,68 @@ +loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); + +echo ''; + +echo '
| Variable | Key | Value |
|---|---|---|
| ' . htmlspecialchars($varName) . ' | '; + echo '' . htmlspecialchars($key) . ' | '; + echo '' . htmlspecialchars(is_array($value) ? json_encode($value) : $value) . ' | '; + echo '