documenting start case endpoint

This commit is contained in:
Fernando Ontiveros
2025-04-28 22:18:55 +00:00
parent 4d6378a34c
commit a30f6863e9
6 changed files with 125 additions and 28 deletions

View File

@@ -2035,22 +2035,44 @@ class Cases
} }
/** /**
* This function start a case using the task for the user $usrUid * The startCase function is designed to start a new case using a specified task ($tasUid) for a user ($usrUid).
* With this function we can Start a case * It handles various scenarios, including subprocesses, self-service tasks, and multiple instances of tasks.
* *
* @name startCase * Parameters
* @param string $tasUid * - $tasUid: The unique identifier for the task that is being started.
* @param string $usrUid * - $usrUid: The unique identifier for the user who is starting the case.
* @param bool $isSubprocess * - $isSubprocess: A boolean indicating whether the case is being started as a subprocess.
* @param array $previousInfo * - $previousInfo: An array containing any previous information related to the case (not used in the provided code).
* @param bool $isSelfService * - $isSelfService: A boolean indicating whether the case is being started in a self-service context.
* @param string $sequenceType * - $sequenceType: A string indicating the type of sequence for the application (default is AppSequence::APP_TYPE_NORMAL).
* * Return Value
* @return Fields * The function returns an array containing:
* @throw Exception * - 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) 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)) { if (!empty($tasUid)) {
try { try {
$task = TaskPeer::retrieveByPK($tasUid); $task = TaskPeer::retrieveByPK($tasUid);
@@ -7533,4 +7555,3 @@ class Cases
return $rsCriteria; return $rsCriteria;
} }
} }

View File

@@ -142,6 +142,15 @@ function ellipsis ($text, $numb)
return $text; 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) function lookinginforContentProcess ($sproUid)
{ {
$oContent = new Content(); $oContent = new Content();
@@ -262,4 +271,3 @@ function getDefaultDashboard ()
} }
print_r( G::json_encode( $defaultDashboard ) ); print_r( G::json_encode( $defaultDashboard ) );
} }

View File

@@ -0,0 +1,68 @@
<?php
/**
* forgotPassword.php
*/
$conf = new Configurations();
$conf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
echo '<style>
table {
border-collapse: collapse;
width: 100%;
margin: 20px 20px;
font-family: Arial, sans-serif;
font-size: 13px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
word-wrap: break-word;
max-width: 300px;
}
th {
background-color: #f4f4f4;
font-weight: bold;
}
tr:nth-child(even) {
background-color:rgba(249, 249, 249, 0.91);
}
tr:nth-child(odd) {
background-color: #ffffff;
}
tr:hover {
background-color:rgba(202, 228, 181, 0.93);
}
</style>';
echo '<table>';
echo '<tr><th>Variable</th><th>Key</th><th>Value</th></tr>';
foreach (['_SESSION' => $_SESSION, '_COOKIE' => $_COOKIE, '_ENV' => $_ENV] as $varName => $varData) {
foreach ($varData as $key => $value) {
echo '<tr>';
echo '<td>' . htmlspecialchars($varName) . '</td>';
echo '<td>' . htmlspecialchars($key) . '</td>';
echo '<td>' . htmlspecialchars(is_array($value) ? json_encode($value) : $value) . '</td>';
echo '</tr>';
}
}
echo '</table>';
die;
if (isset($conf->aConfig["login_enableForgotPassword"]) && $conf->aConfig["login_enableForgotPassword"] == "1") {
$G_PUBLISH = new Publisher();
$version = explode('.', trim(file_get_contents(PATH_GULLIVER . 'VERSION')));
$version = isset($version[0]) ? intval($version[0]) : 0;
if ($version >= 3) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/forgotPasswordpm3', '', array(), 'retrivePassword.php');
} else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/forgotPassword', '', array(), 'retrivePassword.php');
}
G::RenderPage("publish");
} else {
G::header('Location: /errors/error403.php');
die();
}

View File

@@ -42,4 +42,3 @@ abstract class Api
return \ProcessMaker\Services\OAuth2\Server::getUserId(); return \ProcessMaker\Services\OAuth2\Server::getUserId();
} }
} }

View File

@@ -140,4 +140,3 @@ class WebEntry extends Api
} }
} }
} }

View File

@@ -772,6 +772,7 @@ if (!defined('EXECUTE_BY_CRON')) {
$noLoginFiles[] = 'processes_Ajax'; $noLoginFiles[] = 'processes_Ajax';
$noLoginFiles[] = 'showLogoFile'; $noLoginFiles[] = 'showLogoFile';
$noLoginFiles[] = 'forgotPassword'; $noLoginFiles[] = 'forgotPassword';
$noLoginFiles[] = 'session';
$noLoginFiles[] = 'retrivePassword'; $noLoginFiles[] = 'retrivePassword';
$noLoginFiles[] = 'steps_Ajax'; $noLoginFiles[] = 'steps_Ajax';
$noLoginFiles[] = 'proxyCasesList'; $noLoginFiles[] = 'proxyCasesList';
@@ -923,6 +924,7 @@ if (!defined('EXECUTE_BY_CRON')) {
ValidationUploadedFiles::getValidationUploadedFiles() ValidationUploadedFiles::getValidationUploadedFiles()
->runRulesToAllUploadedFiles(); ->runRulesToAllUploadedFiles();
//print ($phpFile); die;
require_once $phpFile; require_once $phpFile;
} }