HOR-4482
This commit is contained in:
@@ -3379,7 +3379,6 @@ class Cases
|
|||||||
public function executeTriggers($sTasUid, $sStepType, $sStepUidObj, $sTriggerType, $aFields = array())
|
public function executeTriggers($sTasUid, $sStepType, $sStepUidObj, $sTriggerType, $aFields = array())
|
||||||
{
|
{
|
||||||
ChangeLog::getChangeLog()
|
ChangeLog::getChangeLog()
|
||||||
->setStepTypeObject($sStepType)
|
|
||||||
->setObjectUid($sStepUidObj)
|
->setObjectUid($sStepUidObj)
|
||||||
->getExecutedAtIdByTriggerType($sTriggerType);
|
->getExecutedAtIdByTriggerType($sTriggerType);
|
||||||
|
|
||||||
|
|||||||
@@ -2249,7 +2249,7 @@ class WsBase
|
|||||||
unset($appFields['APP_PROC_STATUS']);
|
unset($appFields['APP_PROC_STATUS']);
|
||||||
unset($appFields['APP_PROC_CODE']);
|
unset($appFields['APP_PROC_CODE']);
|
||||||
unset($appFields['APP_PIN']);
|
unset($appFields['APP_PIN']);
|
||||||
$fieldsUpdated = $oCase->updateCase($caseId, $appFields);
|
$oCase->updateCase($caseId, $appFields);
|
||||||
|
|
||||||
//We need to update the variable $appData for use the new variables in the next trigger
|
//We need to update the variable $appData for use the new variables in the next trigger
|
||||||
$appData = array_merge($appData, $appFields['APP_DATA']);
|
$appData = array_merge($appData, $appFields['APP_DATA']);
|
||||||
@@ -2258,15 +2258,14 @@ class WsBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChangeLog::getChangeLog()
|
ChangeLog::getChangeLog()
|
||||||
->setDate($fieldsUpdated['APP_UPDATE_DATE'])
|
->setDate('now')
|
||||||
->setAppNumber($fieldsUpdated['APP_NUMBER'])
|
->setAppNumber($appData['APP_NUMBER'])
|
||||||
->setDelIndex($fieldsUpdated['DEL_INDEX'])
|
->setDelIndex($appData['INDEX'])
|
||||||
->getProIdByProUid($appData['PROCESS'])
|
->getProIdByProUid($appData['PROCESS'])
|
||||||
->getTasIdByTasUid($appData['TASK'])
|
->getTasIdByTasUid($appData['TASK'])
|
||||||
->setStepTypeObject($stepType)
|
->setData(serialize($appData))
|
||||||
->setObjectUid($stepUidObj)
|
->getExecutedAtIdByTriggerType($triggerType)
|
||||||
->setData($fieldsUpdated['APP_DATA'])
|
->getObjectIdByUidAndObjType($stepUidObj, $stepType);
|
||||||
->getExecutedAtIdByTriggerType($triggerType);
|
|
||||||
|
|
||||||
return $varTriggers;
|
return $varTriggers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use ProcessMaker\BusinessModel\Cases as BmCases;
|
use ProcessMaker\BusinessModel\Cases as BmCases;
|
||||||
|
use ProcessMaker\ChangeLog\ChangeLogResult;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
if (!isset($_SESSION['USER_LOGGED'])) {
|
if (!isset($_SESSION['USER_LOGGED'])) {
|
||||||
@@ -770,15 +771,19 @@ class Ajax
|
|||||||
|
|
||||||
public function changeLogAjax()
|
public function changeLogAjax()
|
||||||
{
|
{
|
||||||
$changeLog = new ProcessMaker\BusinessModel\Cases\ChangeLog();
|
|
||||||
$idHistory = $_REQUEST["idHistory"];
|
$idHistory = $_REQUEST["idHistory"];
|
||||||
$idHistoryArray = explode("_", $idHistory);
|
$idHistoryArray = explode("_", $idHistory);
|
||||||
$proUid = $idHistoryArray[0];
|
$proUid = $idHistoryArray[0];
|
||||||
$appUid = $idHistoryArray[1];
|
$appUid = $idHistoryArray[1];
|
||||||
$tasUid = $idHistoryArray[2];
|
$tasUid = $idHistoryArray[2];
|
||||||
$start = isset($_REQUEST['start']) ? (int) $_REQUEST['start']: 0;
|
|
||||||
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']: 15;
|
$changeLog = new ChangeLogResult();
|
||||||
echo G::json_encode($changeLog->getChangeLog($appUid, $proUid, $tasUid, $start, $limit));
|
$result = $changeLog->setAppUid($appUid)
|
||||||
|
->setUserLogged($_SESSION['USER_LOGGED'])
|
||||||
|
->setProUid($proUid)
|
||||||
|
->setTasUid($tasUid)
|
||||||
|
->getLogs();
|
||||||
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeLogTab()
|
public function changeLogTab()
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $applications = ['unknow', 'web', 'ABE', 'mobile'];
|
protected static $applications = ['Unknow', 'Web', 'Actions by Email', 'Mobile'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifier for unknow object.
|
* Identifier for unknow object.
|
||||||
@@ -195,7 +195,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $objectUid = '';
|
protected $objectUid = '0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the executedAt field.
|
* The value for the executedAt field.
|
||||||
@@ -232,13 +232,6 @@ class ChangeLog
|
|||||||
*/
|
*/
|
||||||
protected $language = '';
|
protected $language = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* The value for the stepTypeObject field.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $stepTypeObject = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of de class.
|
* Constructor of de class.
|
||||||
*/
|
*/
|
||||||
@@ -252,7 +245,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return datetime
|
* @return datetime
|
||||||
*/
|
*/
|
||||||
function getDate()
|
public function getDate()
|
||||||
{
|
{
|
||||||
return $this->date;
|
return $this->date;
|
||||||
}
|
}
|
||||||
@@ -262,7 +255,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getAppNumber()
|
public function getAppNumber()
|
||||||
{
|
{
|
||||||
return $this->appNumber;
|
return $this->appNumber;
|
||||||
}
|
}
|
||||||
@@ -272,7 +265,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getDelIndex()
|
public function getDelIndex()
|
||||||
{
|
{
|
||||||
return $this->delIndex;
|
return $this->delIndex;
|
||||||
}
|
}
|
||||||
@@ -282,7 +275,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getProId()
|
public function getProId()
|
||||||
{
|
{
|
||||||
return $this->proId;
|
return $this->proId;
|
||||||
}
|
}
|
||||||
@@ -292,7 +285,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getTasId()
|
public function getTasId()
|
||||||
{
|
{
|
||||||
return $this->tasId;
|
return $this->tasId;
|
||||||
}
|
}
|
||||||
@@ -302,7 +295,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getUsrId()
|
public function getUsrId()
|
||||||
{
|
{
|
||||||
return $this->usrId;
|
return $this->usrId;
|
||||||
}
|
}
|
||||||
@@ -312,7 +305,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getObjectType()
|
public function getObjectType()
|
||||||
{
|
{
|
||||||
return $this->objectType;
|
return $this->objectType;
|
||||||
}
|
}
|
||||||
@@ -322,7 +315,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getObjectId()
|
public function getObjectId()
|
||||||
{
|
{
|
||||||
return $this->objectId;
|
return $this->objectId;
|
||||||
}
|
}
|
||||||
@@ -332,7 +325,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
function getObjectUid()
|
public function getObjectUid()
|
||||||
{
|
{
|
||||||
return $this->objectUid;
|
return $this->objectUid;
|
||||||
}
|
}
|
||||||
@@ -342,7 +335,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getExecutedAt()
|
public function getExecutedAt()
|
||||||
{
|
{
|
||||||
return $this->executedAt;
|
return $this->executedAt;
|
||||||
}
|
}
|
||||||
@@ -352,7 +345,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getSourceId()
|
public function getSourceId()
|
||||||
{
|
{
|
||||||
return $this->sourceId;
|
return $this->sourceId;
|
||||||
}
|
}
|
||||||
@@ -362,7 +355,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getData()
|
public function getData()
|
||||||
{
|
{
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
@@ -372,7 +365,7 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getSkin()
|
public function getSkin()
|
||||||
{
|
{
|
||||||
return $this->skin;
|
return $this->skin;
|
||||||
}
|
}
|
||||||
@@ -382,27 +375,18 @@ class ChangeLog
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getLanguage()
|
public function getLanguage()
|
||||||
{
|
{
|
||||||
return $this->language;
|
return $this->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get stepTypeObject.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function getStepTypeObject()
|
|
||||||
{
|
|
||||||
return $this->stepTypeObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set date.
|
* Set date.
|
||||||
*
|
*
|
||||||
* @param datetime $date
|
* @param datetime $date
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setDate($date)
|
public function setDate($date)
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -414,7 +398,7 @@ class ChangeLog
|
|||||||
* @param int $appNumber
|
* @param int $appNumber
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setAppNumber($appNumber)
|
public function setAppNumber($appNumber)
|
||||||
{
|
{
|
||||||
$this->appNumber = $appNumber;
|
$this->appNumber = $appNumber;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -426,7 +410,7 @@ class ChangeLog
|
|||||||
* @param int $delIndex
|
* @param int $delIndex
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setDelIndex($delIndex)
|
public function setDelIndex($delIndex)
|
||||||
{
|
{
|
||||||
$this->delIndex = $delIndex;
|
$this->delIndex = $delIndex;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -438,7 +422,7 @@ class ChangeLog
|
|||||||
* @param int $proId
|
* @param int $proId
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setProId($proId)
|
public function setProId($proId)
|
||||||
{
|
{
|
||||||
$this->proId = $proId;
|
$this->proId = $proId;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -450,7 +434,7 @@ class ChangeLog
|
|||||||
* @param int $tasId
|
* @param int $tasId
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setTasId($tasId)
|
public function setTasId($tasId)
|
||||||
{
|
{
|
||||||
$this->tasId = $tasId;
|
$this->tasId = $tasId;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -462,7 +446,7 @@ class ChangeLog
|
|||||||
* @param int $usrId
|
* @param int $usrId
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setUsrId($usrId)
|
public function setUsrId($usrId)
|
||||||
{
|
{
|
||||||
$this->usrId = $usrId;
|
$this->usrId = $usrId;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -474,7 +458,7 @@ class ChangeLog
|
|||||||
* @param int $objectType
|
* @param int $objectType
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setObjectType($objectType)
|
public function setObjectType($objectType)
|
||||||
{
|
{
|
||||||
$this->objectType = $objectType;
|
$this->objectType = $objectType;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -486,7 +470,7 @@ class ChangeLog
|
|||||||
* @param int $objectId
|
* @param int $objectId
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setObjectId($objectId)
|
public function setObjectId($objectId)
|
||||||
{
|
{
|
||||||
$this->objectId = $objectId;
|
$this->objectId = $objectId;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -498,7 +482,7 @@ class ChangeLog
|
|||||||
* @param string $objectUid
|
* @param string $objectUid
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setObjectUid($objectUid)
|
public function setObjectUid($objectUid)
|
||||||
{
|
{
|
||||||
$this->objectUid = $objectUid;
|
$this->objectUid = $objectUid;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -510,7 +494,7 @@ class ChangeLog
|
|||||||
* @param int $executedAt
|
* @param int $executedAt
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setExecutedAt($executedAt)
|
public function setExecutedAt($executedAt)
|
||||||
{
|
{
|
||||||
$this->executedAt = $executedAt;
|
$this->executedAt = $executedAt;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -522,7 +506,7 @@ class ChangeLog
|
|||||||
* @param string $sourceId
|
* @param string $sourceId
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setSourceId($sourceId)
|
public function setSourceId($sourceId)
|
||||||
{
|
{
|
||||||
$this->sourceId = $sourceId;
|
$this->sourceId = $sourceId;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -534,7 +518,7 @@ class ChangeLog
|
|||||||
* @param string $data
|
* @param string $data
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setData($data)
|
public function setData($data)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -546,7 +530,7 @@ class ChangeLog
|
|||||||
* @param string $skin
|
* @param string $skin
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setSkin($skin)
|
public function setSkin($skin)
|
||||||
{
|
{
|
||||||
$this->skin = $skin;
|
$this->skin = $skin;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -558,24 +542,12 @@ class ChangeLog
|
|||||||
* @param string $language
|
* @param string $language
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setLanguage($language)
|
public function setLanguage($language)
|
||||||
{
|
{
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set stepTypeObject.
|
|
||||||
*
|
|
||||||
* @param string $stepTypeObject
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
function setStepTypeObject($stepTypeObject)
|
|
||||||
{
|
|
||||||
$this->stepTypeObject = $stepTypeObject;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an entry in the database with all the data established in the
|
* Registers an entry in the database with all the data established in the
|
||||||
* object at that moment.
|
* object at that moment.
|
||||||
@@ -744,6 +716,9 @@ class ChangeLog
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch ($uid) {
|
switch ($uid) {
|
||||||
|
case "":
|
||||||
|
$this->setObjectUid(0);
|
||||||
|
break;
|
||||||
case "-1":
|
case "-1":
|
||||||
$this->setObjectUid(0);
|
$this->setObjectUid(0);
|
||||||
$this->setExecutedAt(self::BEFORE_ASSIGNMENT);
|
$this->setExecutedAt(self::BEFORE_ASSIGNMENT);
|
||||||
|
|||||||
294
workflow/engine/src/ProcessMaker/ChangeLog/ChangeLogResult.php
Normal file
294
workflow/engine/src/ProcessMaker/ChangeLog/ChangeLogResult.php
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\ChangeLog;
|
||||||
|
|
||||||
|
use Cases;
|
||||||
|
use G;
|
||||||
|
use ProcessMaker\ChangeLog\LogStruct;
|
||||||
|
use Propel;
|
||||||
|
|
||||||
|
class ChangeLogResult
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Reserved steps.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $reservedSteps = [
|
||||||
|
-1,
|
||||||
|
-2,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Variables to exclude.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $excludeVariables = [
|
||||||
|
'SYS_LANG',
|
||||||
|
'SYS_SKIN',
|
||||||
|
'SYS_SYS',
|
||||||
|
'APPLICATION',
|
||||||
|
'PROCESS',
|
||||||
|
'TASK',
|
||||||
|
'INDEX',
|
||||||
|
'USER_LOGGED',
|
||||||
|
'USR_USERNAME',
|
||||||
|
'APP_NUMBER',
|
||||||
|
'PIN',
|
||||||
|
'DYN_CONTENT_HISTORY',
|
||||||
|
'__VAR_CHANGED__',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permissions.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $permissions = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier of the application.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $appUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier of the process.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $proUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier of the task.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $tasUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User logged.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $userLogged;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set appUid.
|
||||||
|
*
|
||||||
|
* @param string $appUid
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function setAppUid($appUid)
|
||||||
|
{
|
||||||
|
$this->appUid = $appUid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set proUid.
|
||||||
|
*
|
||||||
|
* @param string $proUid
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function setProUid($proUid)
|
||||||
|
{
|
||||||
|
$this->proUid = $proUid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tasUid.
|
||||||
|
*
|
||||||
|
* @param string $tasUid
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function setTasUid($tasUid)
|
||||||
|
{
|
||||||
|
$this->tasUid = $tasUid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set userLogged.
|
||||||
|
*
|
||||||
|
* @param string $userLogged
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function setUserLogged($userLogged)
|
||||||
|
{
|
||||||
|
$this->userLogged = $userLogged;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get logs.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLogs()
|
||||||
|
{
|
||||||
|
$cases = new Cases();
|
||||||
|
$this->permissions = $cases->getAllObjects($this->proUid, $this->appUid, $this->tasUid, $this->userLogged);
|
||||||
|
|
||||||
|
$logs = [];
|
||||||
|
$totalCount = 0;
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
$this->getLogsFromDataBase($this->appUid, function($row) use(&$logs, &$totalCount, &$values) {
|
||||||
|
$appData = $this->getAppData($row['DATA']);
|
||||||
|
$this->removeVariables($appData);
|
||||||
|
|
||||||
|
$hasPermission = $this->hasPermission($row['DYN_UID']);
|
||||||
|
if ((int) $row['SOURCE_ID'] === ChangeLog::FromABE) {
|
||||||
|
$hasPermission = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($appData as $key => $value) {
|
||||||
|
if ($hasPermission && (!isset($values[$key]) || $values[$key] !== $value)) {
|
||||||
|
|
||||||
|
$previousValue = !isset($values[$key]) ? null : $values[$key];
|
||||||
|
$record = ''
|
||||||
|
. G::LoadTranslation('ID_TASK') . ': ' . $row['TAS_TITLE'] . ' / '
|
||||||
|
. G::LoadTranslation('ID_DYNAFORM') . ': ' . $row['DYN_TITLE'] . ' / '
|
||||||
|
. G::LoadTranslation('ID_LAN_UPDATE_DATE') . ': ' . $row['DATE'] . ' / '
|
||||||
|
. G::LoadTranslation('ID_USER') . ': ' . $row['USR_USERNAME'] . ' / '
|
||||||
|
. G::LoadTranslation('ID_FROM') . ': ' . ChangeLog::getChangeLog()->getApplicationNameById($row['SOURCE_ID']);
|
||||||
|
|
||||||
|
$struct = new LogStruct();
|
||||||
|
$struct->setField($key)
|
||||||
|
->setPreviousValue($this->toString($previousValue))
|
||||||
|
->setCurrentValue($this->toString($value))
|
||||||
|
->setPreviousValueType(gettype($previousValue))
|
||||||
|
->setCurrentValueType(gettype($value))
|
||||||
|
->setRecord($record);
|
||||||
|
|
||||||
|
$logs[] = $struct->getValues();
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
$values[$key] = $value;
|
||||||
|
}
|
||||||
|
$totalCount = $totalCount + $count;
|
||||||
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
'data' => $logs,
|
||||||
|
'totalCount' => $totalCount
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get logs from Database.
|
||||||
|
*
|
||||||
|
* @param type $appUid
|
||||||
|
* @param type $callback
|
||||||
|
*/
|
||||||
|
public function getLogsFromDataBase($appUid, $callback = null)
|
||||||
|
{
|
||||||
|
$conn = Propel::getConnection('workflow');
|
||||||
|
$sql = ""
|
||||||
|
. "SELECT "
|
||||||
|
. "A.CHANGE_LOG_ID, "
|
||||||
|
. "D.TAS_TITLE, "
|
||||||
|
. "C.PRO_TITLE, "
|
||||||
|
. "IF(F.DYN_UID IS NULL,'N/A',F.DYN_TITLE) AS 'DYN_TITLE', "
|
||||||
|
. "F.DYN_UID, "
|
||||||
|
. "A.DATE, "
|
||||||
|
. "E.USR_USERNAME, "
|
||||||
|
. "A.APP_NUMBER, "
|
||||||
|
. "A.DEL_INDEX, "
|
||||||
|
. "A.PRO_ID, "
|
||||||
|
. "A.TAS_ID, "
|
||||||
|
. "A.USR_ID, "
|
||||||
|
. "A.OBJECT_ID, "
|
||||||
|
. "A.OBJECT_UID, "
|
||||||
|
. "A.EXECUTED_AT, "
|
||||||
|
. "A.SOURCE_ID, "
|
||||||
|
. "A.DATA, "
|
||||||
|
. "A.SKIN, "
|
||||||
|
. "A.LANGUAGE "
|
||||||
|
. "FROM APP_DATA_CHANGE_LOG AS A "
|
||||||
|
. "INNER JOIN APPLICATION AS B ON (B.APP_NUMBER=A.APP_NUMBER AND B.APP_UID=? ) "
|
||||||
|
. "LEFT JOIN PROCESS AS C ON (C.PRO_ID=A.PRO_ID) "
|
||||||
|
. "LEFT JOIN TASK AS D ON (D.TAS_ID=A.TAS_ID) "
|
||||||
|
. "LEFT JOIN USERS AS E ON (E.USR_ID=A.USR_ID) "
|
||||||
|
. "LEFT JOIN DYNAFORM AS F ON (F.DYN_ID=A.OBJECT_ID AND A.OBJECT_TYPE=" . ChangeLog::DYNAFORM . ") "
|
||||||
|
. "ORDER BY A.DATE ASC ";
|
||||||
|
|
||||||
|
$stmt = $conn->prepareStatement($sql);
|
||||||
|
$stmt->set(1, $appUid);
|
||||||
|
$stmt->executeQuery();
|
||||||
|
$result = $stmt->getResultSet();
|
||||||
|
while ($result->next()) {
|
||||||
|
$row = $result->getRow();
|
||||||
|
if (!empty($callback) && is_callable($callback)) {
|
||||||
|
$callback($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get appData from value serialized.
|
||||||
|
*
|
||||||
|
* @param string $appDataString
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getAppData($appDataString)
|
||||||
|
{
|
||||||
|
$case = new Cases();
|
||||||
|
$appData = $case->unserializeData($appDataString);
|
||||||
|
if (!is_array($appData)) {
|
||||||
|
$appData = [];
|
||||||
|
}
|
||||||
|
return $appData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all values from the array that are in the excludeVariables property.
|
||||||
|
*
|
||||||
|
* @param array $appData
|
||||||
|
*/
|
||||||
|
private function removeVariables(&$appData)
|
||||||
|
{
|
||||||
|
foreach ($this->excludeVariables as $value) {
|
||||||
|
unset($appData[$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has permission.
|
||||||
|
*
|
||||||
|
* @param string $uid
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function hasPermission($uid)
|
||||||
|
{
|
||||||
|
if (array_search($uid, $this->reservedSteps) !== false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($this->permissions as $ids) {
|
||||||
|
if (is_array($ids) && array_search($uid, $ids) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the print string from the value.
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function toString($value)
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
return nl2br(print_r($value, true));
|
||||||
|
} else {
|
||||||
|
return (string) $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
130
workflow/engine/src/ProcessMaker/ChangeLog/LogStruct.php
Normal file
130
workflow/engine/src/ProcessMaker/ChangeLog/LogStruct.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\ChangeLog;
|
||||||
|
|
||||||
|
class LogStruct
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name of the variable.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $field = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous value of the variable.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $previousValue = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current value.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $currentValue = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous type of variable.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $previousValueType = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the variable.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $currentValueType = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group of changes.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $record = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the field.
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setField($field)
|
||||||
|
{
|
||||||
|
$this->field = $field;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the previousValue.
|
||||||
|
*
|
||||||
|
* @param string $previousValue
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPreviousValue($previousValue)
|
||||||
|
{
|
||||||
|
$this->previousValue = $previousValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currentValue.
|
||||||
|
*
|
||||||
|
* @param string $currentValue
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCurrentValue($currentValue)
|
||||||
|
{
|
||||||
|
$this->currentValue = $currentValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the previousValueType.
|
||||||
|
*
|
||||||
|
* @param string $previousValueType
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPreviousValueType($previousValueType)
|
||||||
|
{
|
||||||
|
$this->previousValueType = $previousValueType;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currentValueType.
|
||||||
|
*
|
||||||
|
* @param string $currentValueType
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCurrentValueType($currentValueType)
|
||||||
|
{
|
||||||
|
$this->currentValueType = $currentValueType;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the record.
|
||||||
|
*
|
||||||
|
* @param string $record
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setRecord($record)
|
||||||
|
{
|
||||||
|
$this->record = $record;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get values.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getValues()
|
||||||
|
{
|
||||||
|
return get_object_vars($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user