This commit is contained in:
Paula Quispe
2018-08-29 12:53:04 -04:00
parent 123078d1b3
commit 7306967cd5
3 changed files with 70 additions and 70 deletions

View File

@@ -1,6 +1,7 @@
<?php <?php
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\Util\DateTime;
/** /**
* class.bootstrap.php * class.bootstrap.php
@@ -2658,7 +2659,7 @@ class Bootstrap
* @param int $level The logging level * @param int $level The logging level
* @param string $message The log message * @param string $message The log message
* @param array $context The log context * @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 string $file name file
* @param boolean $readLoggingLevel * @param boolean $readLoggingLevel
* *
@@ -2669,8 +2670,8 @@ class Bootstrap
$level, $level,
$message, $message,
$context, $context,
$workspace, $workspace = '',
$file = 'cron.log', $file = 'processmaker.log',
$readLoggingLevel = true $readLoggingLevel = true
) )
{ {
@@ -2681,17 +2682,34 @@ class Bootstrap
/** /**
* Get the default information from the context * Get the default information from the context
* *
* @return array $aContext void * @return array
*/ */
public static function getDefaultContextLog(){ 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( global $RBAC;
'ip' => \G::getIpAddress() $info = [
,'timeZone' => $date 'ip' => G::getIpAddress(),
,'workspace' => $sysSys 'workspace' => !empty(config('system.workspace')) ? config('system.workspace') : 'Undefined Workspace',
); 'timeZone' => DateTime::convertUtcToTimeZone(date('Y-m-d H:m:s'))
return $aContext; ];
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;
} }
/** /**

View File

@@ -26,7 +26,7 @@ class MonologProvider
private $registerLogger; private $registerLogger;
//the default format "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; //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'; private $dateFormat = 'M d H:i:s';
/** /**
* The maximal amount of files to keep (0 means unlimited) * The maximal amount of files to keep (0 means unlimited)

View File

@@ -900,7 +900,7 @@ class Cases
$appDataWithoutDynContentHistory = serialize($FieldsDifference); $appDataWithoutDynContentHistory = serialize($FieldsDifference);
$aFieldsHistory['APP_DATA'] = serialize($FieldsDifference); $aFieldsHistory['APP_DATA'] = serialize($FieldsDifference);
$appHistory->insertHistory($aFieldsHistory); $appHistory->insertHistory($aFieldsHistory);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$type = isset($Fields['OBJECT_TYPE']) ? $type = isset($Fields['OBJECT_TYPE']) ?
$Fields['OBJECT_TYPE'] : ChangeLog::getChangeLog()->getObjectNameById(ChangeLog::DYNAFORM); $Fields['OBJECT_TYPE'] : ChangeLog::getChangeLog()->getObjectNameById(ChangeLog::DYNAFORM);
@@ -1140,12 +1140,13 @@ class Cases
$nameFiles .= $node['file'] . ":" . $node['function'] . "(" . $node['line'] . ")\n"; $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'); /** ProcessMaker log*/
$dataLog['appUid'] = $sAppUid; $context = Bootstrap::getDefaultContextLog();
$dataLog['request'] = $nameFiles; $context['appUid'] = $sAppUid;
$dataLog['action'] = 'DeleteCases'; $context['request'] = $nameFiles;
Bootstrap::registerMonolog('DeleteCases', 200, 'Delete Case', $dataLog, $dataLog['workspace'], 'processmaker.log'); Bootstrap::registerMonolog('DeleteCases', 200, 'Delete Case', $context);
return $result; return $result;
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
@@ -7128,57 +7129,38 @@ class Cases
return false; 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) public function reportTableDeleteRecord($applicationUid)
{ {
$criteria1 = new Criteria("workflow"); $app = new Application();
$applicationFields = $app->Load($applicationUid);
//SELECT if (!empty($applicationFields["PRO_UID"])) {
$criteria1->addSelectColumn(ApplicationPeer::PRO_UID); $additionalTables = new AdditionalTables();
$listTables = $additionalTables->getReportTables($applicationFields["PRO_UID"]);
//FROM $pmTable = new PmTable();
//WHERE foreach ($listTables as $row) {
$criteria1->add(ApplicationPeer::APP_UID, $applicationUid); try {
$tableName = $row["ADD_TAB_NAME"];
//QUERY $pmTableName = $pmTable->toCamelCase($tableName);
$rsCriteria1 = ApplicationPeer::doSelectRS($criteria1); require_once(PATH_WORKSPACE . 'classes' . PATH_SEP . $pmTableName . '.php');
$rsCriteria1->setFetchmode(ResultSet::FETCHMODE_ASSOC); $criteria = new Criteria("workflow");
$pmTablePeer = $pmTableName . 'Peer';
$rsCriteria1->next(); $criteria->add($pmTablePeer::APP_UID, $applicationUid);
$row1 = $rsCriteria1->getRow(); $pmTablePeer::doDelete($criteria);
} catch (Exception $e) {
$processUid = $row1["PRO_UID"]; $context = Bootstrap::getDefaultContextLog();
$context['appUid'] = $applicationUid;
$criteria2 = new Criteria("workflow"); $context['proUid'] = $applicationFields["PRO_UID"];
$context['reportTable'] = $tableName;
//SELECT Bootstrap::registerMonolog('DeleteCases', 400, $e->getMessage(), $context);
$criteria2->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); }
//FROM
//WHERE
$criteria2->add(AdditionalTablesPeer::PRO_UID, $processUid);
//QUERY
$rsCriteria2 = AdditionalTablesPeer::doSelectRS($criteria2);
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$pmTable = new PmTable();
while ($rsCriteria2->next()) {
try {
$row2 = $rsCriteria2->getRow();
$tableName = $row2["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);");
} catch (Exception $e) {
throw $e;
} }
} }
} }