solved conflict composer.lock, config/app.php, workflow/engine/classes/SpoolRun.php
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use OutputDocument as ClassesOutputDocument;
|
||||
use PEAR;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
@@ -595,31 +592,21 @@ class OutputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Generate the output document
|
||||
*
|
||||
* @param string $outDocUid
|
||||
* @param array $caseFields
|
||||
* @param string $path
|
||||
* @param string $filename
|
||||
* @param string $content
|
||||
* @param bool $landscape
|
||||
* @param string $typeDocsToGen
|
||||
* @param array $properties
|
||||
* @param string $application
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @see this->addCasesOutputDocument()
|
||||
* @param string $sUID
|
||||
* @param array $aFields
|
||||
* @param string $sPath
|
||||
* @return variant
|
||||
*/
|
||||
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [], $application = '')
|
||||
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication)
|
||||
{
|
||||
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
|
||||
$content = G::replaceDataGridField($content, $caseFields, true, true);
|
||||
G::verifyPath($path, true);
|
||||
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
|
||||
$sContent = \G::replaceDataGridField($sContent, $aFields);
|
||||
\G::verifyPath($sPath, true);
|
||||
//Start - Create .doc
|
||||
$fp = fopen($path . $filename . '.doc', 'wb');
|
||||
$size = [];
|
||||
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
|
||||
$size = array();
|
||||
$size["Letter"] = "216mm 279mm";
|
||||
$size["Legal"] = "216mm 357mm";
|
||||
$size["Executive"] = "184mm 267mm";
|
||||
@@ -640,7 +627,6 @@ class OutputDocument
|
||||
$size["Screenshot640"] = "640mm 480mm";
|
||||
$size["Screenshot800"] = "800mm 600mm";
|
||||
$size["Screenshot1024"] = "1024mm 768mm";
|
||||
$sizeLandscape = [];
|
||||
$sizeLandscape["Letter"] = "279mm 216mm";
|
||||
$sizeLandscape["Legal"] = "357mm 216mm";
|
||||
$sizeLandscape["Executive"] = "267mm 184mm";
|
||||
@@ -661,31 +647,31 @@ class OutputDocument
|
||||
$sizeLandscape["Screenshot640"] = "480mm 640mm";
|
||||
$sizeLandscape["Screenshot800"] = "600mm 800mm";
|
||||
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
|
||||
if (!isset($properties['media'])) {
|
||||
$properties['media'] = 'Letter';
|
||||
if (!isset($aProperties['media'])) {
|
||||
$aProperties['media'] = 'Letter';
|
||||
}
|
||||
if ($landscape) {
|
||||
$media = $sizeLandscape[$properties['media']];
|
||||
if ($sLandscape) {
|
||||
$media = $sizeLandscape[$aProperties['media']];
|
||||
} else {
|
||||
$media = $size[$properties['media']];
|
||||
$media = $size[$aProperties['media']];
|
||||
}
|
||||
$marginLeft = '15';
|
||||
if (isset($properties['margins']['left'])) {
|
||||
$marginLeft = $properties['margins']['left'];
|
||||
if (isset($aProperties['margins']['left'])) {
|
||||
$marginLeft = $aProperties['margins']['left'];
|
||||
}
|
||||
$marginRight = '15';
|
||||
if (isset($properties['margins']['right'])) {
|
||||
$marginRight = $properties['margins']['right'];
|
||||
if (isset($aProperties['margins']['right'])) {
|
||||
$marginRight = $aProperties['margins']['right'];
|
||||
}
|
||||
$marginTop = '15';
|
||||
if (isset($properties['margins']['top'])) {
|
||||
$marginTop = $properties['margins']['top'];
|
||||
if (isset($aProperties['margins']['top'])) {
|
||||
$marginTop = $aProperties['margins']['top'];
|
||||
}
|
||||
$marginBottom = '15';
|
||||
if (isset($properties['margins']['bottom'])) {
|
||||
$marginBottom = $properties['margins']['bottom'];
|
||||
if (isset($aProperties['margins']['bottom'])) {
|
||||
$marginBottom = $aProperties['margins']['bottom'];
|
||||
}
|
||||
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
@@ -730,40 +716,40 @@ class OutputDocument
|
||||
</head>
|
||||
<body>
|
||||
<div class=WordSection1>');
|
||||
fwrite($fp, $content);
|
||||
fwrite($fp, "\n</div></body></html>\n\n");
|
||||
fclose($fp);
|
||||
fwrite($oFile, $sContent);
|
||||
fwrite($oFile, "\n</div></body></html>\n\n");
|
||||
fclose($oFile);
|
||||
/* End - Create .doc */
|
||||
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
|
||||
$fp = fopen($path . $filename . '.html', 'wb');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
|
||||
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
/* Start - Create .pdf */
|
||||
if (isset($properties['report_generator'])) {
|
||||
switch ($properties['report_generator']) {
|
||||
if (isset($aProperties['report_generator'])) {
|
||||
switch ($aProperties['report_generator']) {
|
||||
case 'TCPDF':
|
||||
$o = new ClassesOutputDocument();
|
||||
if (strlen($content) == 0) {
|
||||
$o = new \OutputDocument();
|
||||
if (strlen($sContent) == 0) {
|
||||
libxml_use_internal_errors(true);
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, ' ', $landscape, $properties);
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, ' ', $sLandscape, $aProperties);
|
||||
libxml_use_internal_errors(false);
|
||||
} else {
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
}
|
||||
break;
|
||||
case 'HTML2PDF':
|
||||
default:
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties, $application);
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
}
|
||||
}
|
||||
//end if $typeDocsToGen
|
||||
//end if $sTypeDocToGener
|
||||
/* End - Create .pdf */
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
return \PEAR::raiseError(
|
||||
null,
|
||||
G_ERROR_USER_UID,
|
||||
null,
|
||||
|
||||
@@ -1108,7 +1108,7 @@ class Consolidated
|
||||
foreach ($G_FORM->fields as $key => $val) {
|
||||
if ($fieldName == $val->name) {
|
||||
if ($G_FORM->fields[$key]->sql != "") {
|
||||
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"]);
|
||||
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"], 'mysql', false);
|
||||
}
|
||||
if ((is_array($val->options)) && (!empty($val->options))) {
|
||||
foreach ($val->options as $key1 => $val1) {
|
||||
|
||||
@@ -522,7 +522,7 @@ class EmailEvent
|
||||
$emailTo,
|
||||
'',
|
||||
'',
|
||||
G::replaceDataField($arrayData[5], $arrayApplicationData['APP_DATA']),
|
||||
G::replaceDataField($arrayData[5], $arrayApplicationData['APP_DATA'], 'mysql', false),
|
||||
$contentFile['prf_filename'],
|
||||
[],
|
||||
[],
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
use \Criteria;
|
||||
use \UsersPeer;
|
||||
use \PMLicensedFeatures;
|
||||
use G;
|
||||
use Criteria;
|
||||
use PMLicensedFeatures;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use UsersPeer;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Lists
|
||||
@@ -258,6 +258,7 @@ class Lists
|
||||
|
||||
/**
|
||||
* Get counters for lists
|
||||
*
|
||||
* @param $userId
|
||||
* @return array
|
||||
*/
|
||||
@@ -271,6 +272,13 @@ class Lists
|
||||
$total = $this->$listObject->getCountList($userId, array('action' => 'draft'));
|
||||
array_push($response, (array('count' => $total, 'item' => $item)));
|
||||
break;
|
||||
case 'ListSelfService':
|
||||
$total = Delegation::countSelfService($userId);
|
||||
array_push($response, ([
|
||||
'count' => $total,
|
||||
'item' => $item
|
||||
]));
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
case 'ListConsolidated':
|
||||
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
||||
|
||||
@@ -9,6 +9,7 @@ use Faker;
|
||||
use G;
|
||||
use GzipFile;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Foundation\Http\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use InputFilter;
|
||||
use InstallerModule;
|
||||
@@ -1023,7 +1024,7 @@ class System
|
||||
*
|
||||
* @return array $skinListArray
|
||||
*/
|
||||
public function getSkingList()
|
||||
public static function getSkingList()
|
||||
{
|
||||
//Create Skins custom folder if it doesn't exists
|
||||
if (!is_dir(PATH_CUSTOM_SKINS)) {
|
||||
@@ -1629,5 +1630,21 @@ class System
|
||||
{
|
||||
return !empty(self::getServerHostname()) ? self::getServerHostname() : 'processmaker.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize laravel database configuration
|
||||
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
|
||||
*/
|
||||
public static function initLaravel()
|
||||
{
|
||||
config(['database.connections.workflow.host' => DB_HOST]);
|
||||
config(['database.connections.workflow.database' => DB_NAME]);
|
||||
config(['database.connections.workflow.username' => DB_USER]);
|
||||
config(['database.connections.workflow.password' => DB_PASS]);
|
||||
|
||||
app()->useStoragePath(realpath(PATH_DATA));
|
||||
app()->make(Kernel::class)->bootstrap();
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
// end System class
|
||||
|
||||
@@ -300,6 +300,24 @@ abstract class Importer
|
||||
$this->preserveEmailEventConfiguration($emailEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->importData["tables"]["workflow"]["dynaforms"])) {
|
||||
foreach ($this->importData["tables"]["workflow"]["dynaforms"] as &$dynaform) {
|
||||
$this->preserveDynaformId($dynaform);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->importData["tables"]["workflow"]["inputs"])) {
|
||||
foreach ($this->importData["tables"]["workflow"]["inputs"] as &$input) {
|
||||
$this->preserveInputDocumentId($input);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->importData["tables"]["workflow"]["outputs"])) {
|
||||
foreach ($this->importData["tables"]["workflow"]["outputs"] as &$output) {
|
||||
$this->preserveOutputDocumentId($output);
|
||||
}
|
||||
}
|
||||
|
||||
$objectList = $granularObj->loadObjectsListSelected($this->importData, $newObjectArray);
|
||||
if (sizeof($objectList) > 0 && $processGranulate) {
|
||||
@@ -602,6 +620,18 @@ abstract class Importer
|
||||
foreach ($arrayWorkflowTables["emailEvent"] as &$emailEvent) {
|
||||
$this->preserveEmailEventConfiguration($emailEvent);
|
||||
}
|
||||
|
||||
foreach ($arrayWorkflowTables["dynaforms"] as &$dynaform) {
|
||||
$this->preserveDynaformId($dynaform);
|
||||
}
|
||||
|
||||
foreach ($arrayWorkflowTables["inputs"] as &$input) {
|
||||
$this->preserveInputDocumentId($input);
|
||||
}
|
||||
|
||||
foreach ($arrayWorkflowTables["outputs"] as &$output) {
|
||||
$this->preserveOutputDocumentId($output);
|
||||
}
|
||||
|
||||
$this->importWfTables($arrayWorkflowTables);
|
||||
|
||||
@@ -862,6 +892,8 @@ abstract class Importer
|
||||
* Saves the current objects before import.
|
||||
*
|
||||
* @param string $proUid
|
||||
*
|
||||
* @see ProcessMaker\Importer\Importer::import()
|
||||
*/
|
||||
public function saveCurrentProcess($proUid)
|
||||
{
|
||||
@@ -873,9 +905,9 @@ abstract class Importer
|
||||
$result->tasks = $processes->getTaskRows($proUid);
|
||||
$result->abeConfigurations = $processes->getActionsByEmail($proUid);
|
||||
$result->emailEvents = $processes->getEmailEvent($proUid);
|
||||
$result->dynaforms = $processes->getDynaformRows($proUid);
|
||||
$result->inputs = $processes->getInputRows($proUid);
|
||||
$result->outputs = $processes->getOutputRows($proUid);
|
||||
$result->dynaforms = $processes->getDynaformRows($proUid, false);
|
||||
$result->inputs = $processes->getInputRows($proUid, false);
|
||||
$result->outputs = $processes->getOutputRows($proUid, false);
|
||||
|
||||
$this->setCurrentProcess($result);
|
||||
}
|
||||
@@ -948,4 +980,87 @@ abstract class Importer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore DYN_ID value for specific dynaform.
|
||||
* The value of __DYN_ID_UPDATE__ only used like a reference.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @see ProcessMaker\Importer\Importer::import()
|
||||
* @see ProcessMaker\Importer\Importer::doImport()
|
||||
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
|
||||
*/
|
||||
public function preserveDynaformId(&$data)
|
||||
{
|
||||
$currentProccess = $this->getCurrentProcess();
|
||||
if (!is_object($currentProccess)) {
|
||||
return;
|
||||
}
|
||||
if (!is_array($currentProccess->dynaforms)) {
|
||||
return;
|
||||
}
|
||||
foreach ($currentProccess->dynaforms as $dynaform) {
|
||||
if ($data["DYN_UID"] === $dynaform["DYN_UID"]) {
|
||||
$data["DYN_ID"] = $dynaform["DYN_ID"];
|
||||
$data["__DYN_ID_UPDATE__"] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore INP_DOC_ID value for specific input document.
|
||||
* The value of __INP_DOC_ID_UPDATE__ only used like a reference.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @see ProcessMaker\Importer\Importer::import()
|
||||
* @see ProcessMaker\Importer\Importer::doImport()
|
||||
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
|
||||
*/
|
||||
public function preserveInputDocumentId(&$data)
|
||||
{
|
||||
$currentProccess = $this->getCurrentProcess();
|
||||
if (!is_object($currentProccess)) {
|
||||
return;
|
||||
}
|
||||
if (!is_array($currentProccess->inputs)) {
|
||||
return;
|
||||
}
|
||||
foreach ($currentProccess->inputs as $inputDocument) {
|
||||
if ($data["INP_DOC_UID"] === $inputDocument["INP_DOC_UID"]) {
|
||||
$data["INP_DOC_ID"] = $inputDocument["INP_DOC_ID"];
|
||||
$data["__INP_DOC_ID_UPDATE__"] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore OUT_DOC_ID value for specific output document.
|
||||
* The value of __OUT_DOC_ID_UPDATE__ only used like a reference.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @see ProcessMaker\Importer\Importer::import()
|
||||
* @see ProcessMaker\Importer\Importer::doImport()
|
||||
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
|
||||
*/
|
||||
public function preserveOutputDocumentId(&$data)
|
||||
{
|
||||
$currentProccess = $this->getCurrentProcess();
|
||||
if (!is_object($currentProccess)) {
|
||||
return;
|
||||
}
|
||||
if (!is_array($currentProccess->outputs)) {
|
||||
return;
|
||||
}
|
||||
foreach ($currentProccess->outputs as $outputDocument) {
|
||||
if ($data["OUT_DOC_UID"] === $outputDocument["OUT_DOC_UID"]) {
|
||||
$data["OUT_DOC_ID"] = $outputDocument["OUT_DOC_ID"];
|
||||
$data["__OUT_DOC_ID_UPDATE__"] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,63 @@ class AppAssignSelfServiceValue extends Model
|
||||
protected $primaryKey = 'ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return the case number this belongs to
|
||||
*/
|
||||
public function appNumber()
|
||||
{
|
||||
return $this->belongsTo(Delegation::class, 'APP_NUMBER', 'APP_NUMBER');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index this belongs to
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->belongsTo(Delegation::class, 'DEL_INDEX', 'DEL_INDEX');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the task this belongs to
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_ID', 'TAS_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases with assignment Self-Service Value Based
|
||||
*
|
||||
* @param string $usrUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSelfServiceCasesByEvaluatePerUser($usrUid)
|
||||
{
|
||||
//Get the groups related to the user
|
||||
$groups = GroupUser::getGroups($usrUid);
|
||||
|
||||
// Build query
|
||||
$query = AppAssignSelfServiceValue::query()->select();
|
||||
$query->join('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP', function ($join) {
|
||||
$join->on('APP_ASSIGN_SELF_SERVICE_VALUE.ID', '=', 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ID');
|
||||
});
|
||||
$query->where(function ($query) use ($usrUid, $groups) {
|
||||
//Filtering the user assigned in the task
|
||||
$query->where('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.GRP_UID', '=', $usrUid);
|
||||
if (!empty($groups)) {
|
||||
//Consider the group related to the user
|
||||
$query->orWhere(function ($query) use ($groups) {
|
||||
$query->whereIn('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ASSIGNEE_ID', $groups);
|
||||
$query->where('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ASSIGNEE_TYPE', '=', 2);
|
||||
});
|
||||
}
|
||||
});
|
||||
$query->distinct();
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,13 @@ class AppAssignSelfServiceValueGroup extends Model
|
||||
protected $table = 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return the appSelfServiceValue this belongs to
|
||||
*/
|
||||
public function appSelfService()
|
||||
{
|
||||
return $this->belongsTo(AppAssignSelfServiceValue::class, 'ID', 'ID');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,79 @@ class Delegation extends Model
|
||||
return $query->where('APP_UID', '=', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include open threads
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIsThreadOpen($query)
|
||||
{
|
||||
return $query->where('DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include threads without user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeNoUserInThread($query)
|
||||
{
|
||||
return $query->where('USR_ID', '=', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include specific tasks
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $tasks
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTasksIn($query, array $tasks)
|
||||
{
|
||||
return $query->whereIn('APP_DELEGATION.TAS_ID', $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific case
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $appNumber
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCase($query, $appNumber)
|
||||
{
|
||||
return $query->where('APP_NUMBER', '=', $appNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific index
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $index
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIndex($query, $index)
|
||||
{
|
||||
return $query->where('DEL_INDEX', '=', $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific task
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $task
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTask($query, $task)
|
||||
{
|
||||
return $query->where('APP_DELEGATION.TAS_ID', '=', $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for delegations which match certain criteria
|
||||
*
|
||||
@@ -389,4 +462,47 @@ class Delegation extends Model
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the self-services cases by user
|
||||
*
|
||||
* @param string $usrUid
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function countSelfService($usrUid)
|
||||
{
|
||||
//Get the task self services related to the user
|
||||
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);
|
||||
//Get the task self services value based related to the user
|
||||
$selfServiceValueBased = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($usrUid);
|
||||
|
||||
//Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select('APP_NUMBER');
|
||||
//Add Join with task filtering only the type self-service
|
||||
$query->join('TASK', function ($join) {
|
||||
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID')
|
||||
->where('TASK.TAS_ASSIGN_TYPE', '=', 'SELF_SERVICE');
|
||||
});
|
||||
//Filtering the open threads and without users
|
||||
$query->isThreadOpen()->noUserInThread();
|
||||
|
||||
//Get the cases unassigned
|
||||
if (!empty($selfServiceValueBased)) {
|
||||
$query->where(function ($query) use ($selfServiceValueBased, $taskSelfService) {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
foreach ($selfServiceValueBased as $case) {
|
||||
//Get the cases related to the task self service value based
|
||||
$query->orWhere(function ($query) use ($case) {
|
||||
$query->case($case['APP_NUMBER'])->index($case['DEL_INDEX'])->task($case['TAS_ID']);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,13 @@ use Illuminate\Support\Facades\DB;
|
||||
class Dynaform extends Model
|
||||
{
|
||||
protected $table = 'DYNAFORM';
|
||||
protected $primaryKey = "DYN_ID";
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return relation process.
|
||||
* @return object
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
@@ -61,4 +66,16 @@ class Dynaform extends Model
|
||||
->where('DYNAFORM.DYN_UID', '!=', $dynUid)
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $columns
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, string $proUID)
|
||||
{
|
||||
return $query->where('PRO_UID', $proUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,53 @@ class GroupUser extends Model
|
||||
protected $table = 'GROUP_USER';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return the user this belongs to
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'USR_UID', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the group user this belongs to
|
||||
*/
|
||||
public function groupsWf()
|
||||
{
|
||||
return $this->belongsTo(Groupwf::class, 'GRP_ID', 'GRP_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to specific user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $user
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeUser($query, $user)
|
||||
{
|
||||
return $query->where('USR_UID', '=', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the groups from a user
|
||||
*
|
||||
* @param string $usrUid
|
||||
* @param string $column
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroups($usrUid, $column = 'GRP_ID')
|
||||
{
|
||||
$groups = GroupUser::query()->select(['GROUP_USER.' . $column])
|
||||
->join('GROUPWF', function ($join) use ($usrUid) {
|
||||
$join->on('GROUPWF.GRP_ID', '=', 'GROUP_USER.GRP_ID')
|
||||
->where('GROUPWF.GRP_STATUS', 'ACTIVE')
|
||||
->where('GROUP_USER.USR_UID', $usrUid);
|
||||
})->get()->values()->toArray();
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,24 @@ class Groupwf extends Model
|
||||
protected $primaryKey = 'GRP_ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Scope a query to active groups
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('GRP_STATUS', '=', 'ACTIVE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user this belongs to
|
||||
*/
|
||||
public function groupUsers()
|
||||
{
|
||||
return $this->belongsTo(GroupUser::class, 'GRP_ID', 'GRP_ID');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
workflow/engine/src/ProcessMaker/Model/InputDocument.php
Normal file
45
workflow/engine/src/ProcessMaker/Model/InputDocument.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Represents a input document object in the system.
|
||||
*/
|
||||
class InputDocument extends Model
|
||||
{
|
||||
protected $table = 'INPUT_DOCUMENT';
|
||||
protected $primaryKey = 'INP_DOC_ID';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return relation process.
|
||||
* @return object
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input documents by PRO_UID
|
||||
* @param string $proUid
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
{
|
||||
return InputDocument::where('PRO_UID', '=', $proUid)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input document by INP_DOC_UID
|
||||
* @param type $inpDocUid
|
||||
* @return Model
|
||||
*/
|
||||
public static function getByInpDocUid($inpDocUid)
|
||||
{
|
||||
return InputDocument::where('INP_DOC_UID', '=', $inpDocUid)->first();
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,65 @@ class ListUnassigned extends Model
|
||||
return $this->belongsTo(Process::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user this belongs to
|
||||
*/
|
||||
public function previousUser()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'DEL_PREVIOUS_USR_UID', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include specific tasks
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $tasks
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTasksIn($query, array $tasks)
|
||||
{
|
||||
return $query->whereIn('TAS_ID', $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific case
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $appNumber
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCase($query, $appNumber)
|
||||
{
|
||||
return $query->where('APP_NUMBER', '=', $appNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific index
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $index
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIndex($query, $index)
|
||||
{
|
||||
return $query->where('DEL_INDEX', '=', $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific task
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $task
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTask($query, $task)
|
||||
{
|
||||
return $query->where('TAS_ID', '=', $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
@@ -42,7 +101,7 @@ class ListUnassigned extends Model
|
||||
* @param array $filters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
*/
|
||||
public static function doCount($userUid, $filters = [])
|
||||
{
|
||||
$list = new PropelListUnassigned();
|
||||
@@ -51,6 +110,43 @@ class ListUnassigned extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the self-services cases by user
|
||||
*
|
||||
* @param string $usrUid
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function countSelfService($usrUid)
|
||||
{
|
||||
//Get the task self services related to the user
|
||||
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);
|
||||
//Get the task self services value based related to the user
|
||||
$selfServiceValueBased = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($usrUid);
|
||||
|
||||
//Start the query for get the cases related to the user
|
||||
$query = ListUnassigned::query()->select('APP_NUMBER');
|
||||
|
||||
//Get the cases unassigned
|
||||
if (!empty($selfServiceValueBased)) {
|
||||
$query->where(function ($query) use ($selfServiceValueBased, $taskSelfService) {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
foreach ($selfServiceValueBased as $case) {
|
||||
//Get the cases related to the task self service value based
|
||||
$query->orWhere(function ($query) use ($case) {
|
||||
$query->case($case['APP_NUMBER'])->index($case['DEL_INDEX'])->task($case['TAS_ID']);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//Get the cases related to the task self service
|
||||
$query->tasksIn($taskSelfService);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search data
|
||||
*
|
||||
@@ -67,4 +163,3 @@ class ListUnassigned extends Model
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
workflow/engine/src/ProcessMaker/Model/OutputDocument.php
Normal file
45
workflow/engine/src/ProcessMaker/Model/OutputDocument.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Represents a output document object in the system.
|
||||
*/
|
||||
class OutputDocument extends Model
|
||||
{
|
||||
protected $table = 'OUTPUT_DOCUMENT';
|
||||
protected $primaryKey = 'OUT_DOC_ID';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return relation process.
|
||||
* @return object
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output documents by PRO_UID.
|
||||
* @param string $proUid
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
{
|
||||
return OutputDocument::where('PRO_UID', '=', $proUid)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output document by OUT_DOC_UID.
|
||||
* @param string $outDocUid
|
||||
* @return Model
|
||||
*/
|
||||
public static function getByOutDocUid($outDocUid)
|
||||
{
|
||||
return OutputDocument::where('OUT_DOC_UID', '=', $outDocUid)->first();
|
||||
}
|
||||
}
|
||||
27
workflow/engine/src/ProcessMaker/Model/ProcessVariables.php
Normal file
27
workflow/engine/src/ProcessMaker/Model/ProcessVariables.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProcessVariables extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'PROCESS_VARIABLES';
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
//primary key
|
||||
protected $primaryKey = 'VAR_UID';
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $columns
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, string $proUID)
|
||||
{
|
||||
return $query->where('PRJ_UID', $proUID);
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,16 @@ class Task extends Model
|
||||
{
|
||||
return $this->hasMany(Delegation::class, 'TAS_ID', 'TAS_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include self-service
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIsSelfService($query)
|
||||
{
|
||||
return $query->where('TAS_ASSIGN_TYPE', '=', 'SELF_SERVICE')
|
||||
->where('TAS_GROUP_VARIABLE', '=', '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,64 @@ class TaskUser extends Model
|
||||
protected $table = 'TASK_USER';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Return the task this belongs to
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_UID', 'TAS_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user this belongs to
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'USR_UID', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the task self services related to the user
|
||||
*
|
||||
* @param string $usrUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSelfServicePerUser($usrUid)
|
||||
{
|
||||
//Get the groups related to the user
|
||||
$groups = GroupUser::getGroups($usrUid, 'GRP_UID');
|
||||
|
||||
// Build query
|
||||
$query = Task::query()->select('TAS_ID');
|
||||
//Add Join with process filtering only the active process
|
||||
$query->join('PROCESS', function ($join) {
|
||||
$join->on('PROCESS.PRO_UID', '=', 'TASK.PRO_UID')
|
||||
->where('PROCESS.PRO_STATUS', 'ACTIVE');
|
||||
});
|
||||
//Add join with with the task users
|
||||
$query->join('TASK_USER', function ($join) {
|
||||
$join->on('TASK.TAS_UID', '=', 'TASK_USER.TAS_UID')
|
||||
//We not considered the Ad-hoc
|
||||
->where('TASK_USER.TU_TYPE', '=', 1);
|
||||
});
|
||||
//Filtering only the task self-service
|
||||
$query->isSelfService();
|
||||
//Filtering the task related to the user
|
||||
$query->where(function ($query) use ($usrUid, $groups) {
|
||||
//Filtering the user assigned in the task
|
||||
$query->where('TASK_USER.USR_UID', '=', $usrUid);
|
||||
if (!empty($groups)) {
|
||||
//Consider the group related to the user
|
||||
$query->orWhere(function ($query) use ($groups) {
|
||||
$query->whereIn('TASK_USER.USR_UID', $groups);
|
||||
});
|
||||
}
|
||||
});
|
||||
$query->distinct();
|
||||
$tasks = $query->get()->values()->toArray();
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
27
workflow/engine/src/ProcessMaker/Model/Triggers.php
Normal file
27
workflow/engine/src/ProcessMaker/Model/Triggers.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Triggers extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'TRIGGERS';
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
//primary key
|
||||
protected $primaryKey = 'TRI_UID';
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $columns
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, string $proUID)
|
||||
{
|
||||
return $query->where('PRO_UID', $proUID);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = "USERS";
|
||||
protected $primaryKey = 'USR_ID';
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'USR_CREATE_DATE';
|
||||
const UPDATED_AT = 'USR_UPDATE_DATE';
|
||||
@@ -18,4 +19,24 @@ class User extends Model
|
||||
{
|
||||
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user this belongs to
|
||||
*/
|
||||
public function groups()
|
||||
{
|
||||
return $this->belongsTo(GroupUser::class, 'USR_UID', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the groups from a user
|
||||
*
|
||||
* @param boolean $usrUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroups($usrUid)
|
||||
{
|
||||
return User::find($usrUid)->groups()->get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,10 +652,11 @@ class Light extends Api
|
||||
if (preg_match($this->regexNull, $newerThan)) {
|
||||
return [];
|
||||
}
|
||||
$paged = ($start === 0 && $limit === 0) ? false : true;
|
||||
|
||||
$dataList['userId'] = $this->getUserId();
|
||||
$dataList['action'] = 'unassigned';
|
||||
$dataList['paged'] = false;
|
||||
$dataList['paged'] = $paged;
|
||||
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
@@ -682,6 +683,9 @@ class Light extends Api
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if ($paged === true) {
|
||||
$response = $response['data'];
|
||||
}
|
||||
$result = $this->parserDataUnassigned($response);
|
||||
|
||||
return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601);
|
||||
|
||||
@@ -409,7 +409,7 @@ class Server implements iAuthenticate
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
public function getUserId()
|
||||
public static function getUserId()
|
||||
{
|
||||
return self::$userId;
|
||||
}
|
||||
|
||||
@@ -485,33 +485,6 @@ function csrfToken()
|
||||
return isset($_SESSION['USR_CSRF_TOKEN']) ? $_SESSION['USR_CSRF_TOKEN'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid HTML code
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see G::replaceDataField()
|
||||
*/
|
||||
function stringIsValidHtml($string)
|
||||
{
|
||||
// To validate we use the DOMDocument class
|
||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
// Clean previous errors
|
||||
libxml_clear_errors();
|
||||
|
||||
// This line have to be silenced because if the string is not an HTML a Warning is displayed
|
||||
@$doc->loadHTML($string);
|
||||
|
||||
// Get last error parsing the HTML
|
||||
$libXmlError = libxml_get_last_error();
|
||||
|
||||
// If the attribute "textContent" is empty or exists libxml errors, is not a valid HTML
|
||||
return $doc->textContent !== '' && empty($libXmlError);
|
||||
}
|
||||
|
||||
// Methods deleted in PHP 7.x, added in this file in order to keep compatibility with old libraries included/used in ProcessMaker
|
||||
if (!function_exists('set_magic_quotes_runtime')) {
|
||||
function set_magic_quotes_runtime($value) {
|
||||
|
||||
110
workflow/engine/src/ProcessMaker/Validation/MySQL57.php
Normal file
110
workflow/engine/src/ProcessMaker/Validation/MySQL57.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Validation;
|
||||
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
|
||||
class MySQL57
|
||||
{
|
||||
const REGEX = '/(?i)(select|\$).*?UNION.*?(select|\$).*?/ms';
|
||||
|
||||
/**
|
||||
* Checks the queries inside triggers that could have possible incompatibilities with MySQL 5.7
|
||||
*
|
||||
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
|
||||
* @param array $processes
|
||||
* @return array
|
||||
*/
|
||||
public function checkIncompatibilityTriggers($processes)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($processes as $process) {
|
||||
$triggerQuery = Triggers::query()->select();
|
||||
//Call the scope method to filter by process
|
||||
$triggerQuery->process($process['PRO_UID']);
|
||||
$triggers = $triggerQuery->get()->values()->toArray();
|
||||
foreach ($triggers as $trigger) {
|
||||
$resultIncompatibility = $this->analyzeQuery($trigger['TRI_WEBBOT']);
|
||||
if ($resultIncompatibility) {
|
||||
$aux = array_merge($process, $trigger);
|
||||
array_push($result, $aux);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the queries inside dynaforms that could have possible incompatibilities with MySQL 5.7
|
||||
*
|
||||
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
|
||||
* @param array $processes
|
||||
* @return array
|
||||
*/
|
||||
public function checkIncompatibilityDynaforms($processes)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($processes as $process) {
|
||||
$dynaformQuery = Dynaform::query()->select();
|
||||
//Call the scope method to filter by process
|
||||
$dynaformQuery->process($process['PRO_UID']);
|
||||
$dynaforms = $dynaformQuery->get()->values()->toArray();
|
||||
foreach ($dynaforms as $dynaform) {
|
||||
$resultIncompatibility = $this->analyzeQuery($dynaform['DYN_CONTENT']);
|
||||
if ($resultIncompatibility) {
|
||||
$aux = array_merge($process, $dynaform);
|
||||
array_push($result, $aux);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the queries inside variables that could have possible incompatibilities with MySQL 5.7
|
||||
*
|
||||
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
|
||||
* @param array $processes
|
||||
* @return array
|
||||
*/
|
||||
public function checkIncompatibilityVariables($processes)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($processes as $process) {
|
||||
$variablesQuery = ProcessVariables::query()->select();
|
||||
//Call the scope method to filter by process
|
||||
$variablesQuery->process($process['PRO_UID']);
|
||||
$variables = $variablesQuery->get()->values()->toArray();
|
||||
foreach ($variables as $variable) {
|
||||
$resultIncompatibility = $this->analyzeQuery($variable['VAR_SQL']);
|
||||
if ($resultIncompatibility) {
|
||||
$aux = array_merge($process, $variable);
|
||||
array_push($result, $aux);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze the query using the regular expression
|
||||
*
|
||||
* @param string $query
|
||||
* @return bool
|
||||
*/
|
||||
public function analyzeQuery($query)
|
||||
{
|
||||
preg_match_all($this::REGEX, $query, $matches, PREG_SET_ORDER, 0);
|
||||
|
||||
return !empty($matches);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user