Merged in bugfix/HOR-4789-A (pull request #6608)
HOR-4789 Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Util\DateTime;
|
||||
|
||||
/**
|
||||
* class.bootstrap.php
|
||||
@@ -2658,7 +2659,7 @@ class Bootstrap
|
||||
* @param int $level The logging level
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @param string $workspace name workspace
|
||||
* @param string $workspace @todo we need to remove this parameter this is not necessary
|
||||
* @param string $file name file
|
||||
* @param boolean $readLoggingLevel
|
||||
*
|
||||
@@ -2669,8 +2670,8 @@ class Bootstrap
|
||||
$level,
|
||||
$message,
|
||||
$context,
|
||||
$workspace,
|
||||
$file = 'cron.log',
|
||||
$workspace = '',
|
||||
$file = 'processmaker.log',
|
||||
$readLoggingLevel = true
|
||||
)
|
||||
{
|
||||
@@ -2681,17 +2682,34 @@ class Bootstrap
|
||||
/**
|
||||
* Get the default information from the context
|
||||
*
|
||||
* @return array $aContext void
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaultContextLog(){
|
||||
$sysSys = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined";
|
||||
$date = \ProcessMaker\Util\DateTime::convertUtcToTimeZone(date('Y-m-d H:m:s'));
|
||||
$aContext = array(
|
||||
'ip' => \G::getIpAddress()
|
||||
,'timeZone' => $date
|
||||
,'workspace' => $sysSys
|
||||
);
|
||||
return $aContext;
|
||||
public static function getDefaultContextLog()
|
||||
{
|
||||
|
||||
global $RBAC;
|
||||
$info = [
|
||||
'ip' => G::getIpAddress(),
|
||||
'workspace' => !empty(config('system.workspace')) ? config('system.workspace') : 'Undefined Workspace',
|
||||
'timeZone' => DateTime::convertUtcToTimeZone(date('Y-m-d H:m:s'))
|
||||
];
|
||||
|
||||
if ($RBAC !== null) {
|
||||
$userInfo = [
|
||||
'usrUid' => $RBAC->aUserInfo['USER_INFO']['USR_UID']
|
||||
];
|
||||
$info = array_merge($info, $userInfo);
|
||||
}
|
||||
//Some endpoints can defined the USER_LOGGED
|
||||
if (empty($info['usrUid'])) {
|
||||
$user = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : G::LoadTranslation('UID_UNDEFINED_USER');
|
||||
$userInfo = [
|
||||
'usrUid' => $user
|
||||
];
|
||||
$info = array_merge($info, $userInfo);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ class MonologProvider
|
||||
private $registerLogger;
|
||||
|
||||
//the default format "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
|
||||
private $output = "<%level%> %datetime% %channel% %level_name%: %message% %context% %extra%\n";
|
||||
private $output = "<%level%> %datetime% %channel% %level_name%: %message% %context%\n";
|
||||
private $dateFormat = 'M d H:i:s';
|
||||
/**
|
||||
* The maximal amount of files to keep (0 means unlimited)
|
||||
|
||||
@@ -1140,12 +1140,13 @@ class Cases
|
||||
$nameFiles .= $node['file'] . ":" . $node['function'] . "(" . $node['line'] . ")\n";
|
||||
}
|
||||
}
|
||||
$dataLog = \Bootstrap::getDefaultContextLog();
|
||||
$dataLog['usrUid'] = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : G::LoadTranslation('UID_UNDEFINED_USER');
|
||||
$dataLog['appUid'] = $sAppUid;
|
||||
$dataLog['request'] = $nameFiles;
|
||||
$dataLog['action'] = 'DeleteCases';
|
||||
Bootstrap::registerMonolog('DeleteCases', 200, 'Delete Case', $dataLog, $dataLog['workspace'], 'processmaker.log');
|
||||
|
||||
/** ProcessMaker log*/
|
||||
$context = Bootstrap::getDefaultContextLog();
|
||||
$context['appUid'] = $sAppUid;
|
||||
$context['request'] = $nameFiles;
|
||||
Bootstrap::registerMonolog('DeleteCases', 200, 'Delete Case', $context);
|
||||
|
||||
return $result;
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
@@ -7128,57 +7129,38 @@ class Cases
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the case is deleted will be removed the case from the report tables related
|
||||
*
|
||||
* @param string $applicationUid
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function reportTableDeleteRecord($applicationUid)
|
||||
{
|
||||
$criteria1 = new Criteria("workflow");
|
||||
|
||||
//SELECT
|
||||
$criteria1->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
|
||||
//FROM
|
||||
//WHERE
|
||||
$criteria1->add(ApplicationPeer::APP_UID, $applicationUid);
|
||||
|
||||
//QUERY
|
||||
$rsCriteria1 = ApplicationPeer::doSelectRS($criteria1);
|
||||
$rsCriteria1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rsCriteria1->next();
|
||||
$row1 = $rsCriteria1->getRow();
|
||||
|
||||
$processUid = $row1["PRO_UID"];
|
||||
|
||||
$criteria2 = new Criteria("workflow");
|
||||
|
||||
//SELECT
|
||||
$criteria2->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME);
|
||||
|
||||
//FROM
|
||||
//WHERE
|
||||
|
||||
$criteria2->add(AdditionalTablesPeer::PRO_UID, $processUid);
|
||||
|
||||
//QUERY
|
||||
$rsCriteria2 = AdditionalTablesPeer::doSelectRS($criteria2);
|
||||
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$app = new Application();
|
||||
$applicationFields = $app->Load($applicationUid);
|
||||
if (!empty($applicationFields["PRO_UID"])) {
|
||||
$additionalTables = new AdditionalTables();
|
||||
$listTables = $additionalTables->getReportTables($applicationFields["PRO_UID"]);
|
||||
$pmTable = new PmTable();
|
||||
|
||||
while ($rsCriteria2->next()) {
|
||||
foreach ($listTables as $row) {
|
||||
try {
|
||||
$row2 = $rsCriteria2->getRow();
|
||||
$tableName = $row2["ADD_TAB_NAME"];
|
||||
$tableName = $row["ADD_TAB_NAME"];
|
||||
$pmTableName = $pmTable->toCamelCase($tableName);
|
||||
|
||||
//DELETE
|
||||
require_once(PATH_WORKSPACE . "classes" . PATH_SEP . "$pmTableName.php");
|
||||
|
||||
$criteria3 = new Criteria("workflow");
|
||||
|
||||
eval("\$criteria3->add(" . $pmTableName . "Peer::APP_UID, \$applicationUid);");
|
||||
eval($pmTableName . "Peer::doDelete(\$criteria3);");
|
||||
require_once(PATH_WORKSPACE . 'classes' . PATH_SEP . $pmTableName . '.php');
|
||||
$criteria = new Criteria("workflow");
|
||||
$pmTablePeer = $pmTableName . 'Peer';
|
||||
$criteria->add($pmTablePeer::APP_UID, $applicationUid);
|
||||
$pmTablePeer::doDelete($criteria);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
$context = Bootstrap::getDefaultContextLog();
|
||||
$context['appUid'] = $applicationUid;
|
||||
$context['proUid'] = $applicationFields["PRO_UID"];
|
||||
$context['reportTable'] = $tableName;
|
||||
Bootstrap::registerMonolog('DeleteCases', 400, $e->getMessage(), $context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user