I completed the issue PM-1588 [Audit log by Forms]
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.dynaformEditor.php
|
||||
@@ -816,12 +816,60 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
||||
$answer = 0;
|
||||
$file = G::decrypt($A, URL_KEY);
|
||||
$tmp = self::_getTmpData();
|
||||
if (isset($tmp['Properties'])){
|
||||
$fileFirst = $tmp['Properties']['PRO_UID'].'/'.$tmp['Properties']['DYN_UID'];
|
||||
}
|
||||
if (isset($tmp['useTmpCopy'])) {
|
||||
/* Save Register */
|
||||
$dynaform = new dynaform();
|
||||
$dynaform->update($tmp['Properties']);
|
||||
/* Save file */
|
||||
$copyFirst = implode('', file(PATH_DYNAFORM . $fileFirst . '.xml'));
|
||||
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
|
||||
/*Check differences between XML*/
|
||||
$elementFirst = new SimpleXMLElement($copyFirst);
|
||||
$elementCopy = new SimpleXMLElement($copy);
|
||||
$desAdd = '';
|
||||
$desDel = '';
|
||||
//Check the new fields
|
||||
foreach ($elementCopy as $key1 => $row1){
|
||||
$swAll = true;
|
||||
foreach ($elementFirst as $key2 => $row2){
|
||||
if ($key1 == $key2){
|
||||
$swAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($swAll){
|
||||
$desAdd .= $key1." ";
|
||||
}
|
||||
}
|
||||
//Check the delete fields
|
||||
foreach ($elementFirst as $key1 => $row1){
|
||||
$swAll = true;
|
||||
foreach ($elementCopy as $key2 => $row2){
|
||||
if ($key1 == $key2){
|
||||
$swAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($swAll){
|
||||
$desDel .= $key1." ";
|
||||
}
|
||||
}
|
||||
|
||||
$mode = empty($tmp['Properties']['MODE'])? 'Determined by Fields' : $tmp['Properties']['MODE'];
|
||||
$auditDescription = "Dynaform Title: ".$tmp['Properties']['DYN_TITLE'].", Type: ".$tmp['Properties']['DYN_TYPE'].", Description: ".$tmp['Properties']['DYN_DESCRIPTION'].", Mode: ".$mode;
|
||||
if($desAdd != ''){
|
||||
$auditDescription .= ", Field(s) Add: ".$desAdd;
|
||||
}
|
||||
if($desDel != ''){
|
||||
$auditDescription .= ", Field(s) Delete: ".$desDel;
|
||||
}
|
||||
//Add Audit Log
|
||||
G::auditLog("UpdateDynaform", $auditDescription);
|
||||
|
||||
|
||||
/*
|
||||
* added by krlos carlos/a/colosa.com
|
||||
* in here we are validation if a xmlform has a submit action
|
||||
@@ -947,4 +995,18 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
||||
return (array) $e;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Functionality: Funcion que convierte objecto en array
|
||||
Parameters : Object $object que queremos convertir
|
||||
Return: Array
|
||||
*/
|
||||
public function convertObjectToArray($object){
|
||||
if( !is_object( $object ) && !is_array( $object ) ){
|
||||
return $object;
|
||||
}
|
||||
if( is_object( $object ) ){
|
||||
$object = get_object_vars( $object );
|
||||
}
|
||||
return array_map( 'objectToArray', $object );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class Dynaform extends BaseDynaform
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function create ($aData)
|
||||
public function create ($aData, $pmTableUid='')
|
||||
{
|
||||
if (! isset( $aData['PRO_UID'] )) {
|
||||
throw (new PropelException( 'The dynaform cannot be created. The PRO_UID is empty.' ));
|
||||
@@ -194,6 +194,17 @@ class Dynaform extends BaseDynaform
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
|
||||
//Add Audit Log
|
||||
$mode = isset($aData['MODE'])? $aData['MODE'] : 'Determined by Fields';
|
||||
$description = "";
|
||||
if($pmTableUid!=''){
|
||||
$pmTable = AdditionalTablesPeer::retrieveByPK( $pmTableUid );
|
||||
$addTabName = $pmTable->getAddTabName();
|
||||
$description = "Create from a PM Table: ".$addTabName.", ";
|
||||
}
|
||||
G::auditLog("CreateDynaform", $description."Dynaform Title: ".$aData['DYN_TITLE'].", Type: ".$aData['DYN_TYPE'].", Description: ".$aData['DYN_DESCRIPTION'].", Mode: ".$mode);
|
||||
|
||||
$sXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">' . "\n";
|
||||
$sXml .= '</dynaForm>';
|
||||
@@ -232,7 +243,7 @@ class Dynaform extends BaseDynaform
|
||||
|
||||
public function createFromPMTable ($aData, $pmTableUid)
|
||||
{
|
||||
$this->create( $aData );
|
||||
$this->create( $aData , $pmTableUid);
|
||||
$aData['DYN_UID'] = $this->getDynUid();
|
||||
//krumo(BasePeer::getFieldnames('Content'));
|
||||
$fields = array ();
|
||||
@@ -560,6 +571,9 @@ class Dynaform extends BaseDynaform
|
||||
}
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
//Add Audit Log
|
||||
//G::auditLog("UpdateDynaform", "Dynaform Title: ".$aData['DYN_TITLE'].", Type: ".$aData['DYN_TYPE'].", Modified Fields ");
|
||||
|
||||
return $res;
|
||||
} else {
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
@@ -591,9 +605,18 @@ class Dynaform extends BaseDynaform
|
||||
try {
|
||||
$oPro = DynaformPeer::retrieveByPK( $ProUid );
|
||||
if (! is_null( $oPro )) {
|
||||
$title = $oPro->getDynTitle();
|
||||
$type = $oPro->getDynType();
|
||||
$description = $oPro->getDynDescription();
|
||||
|
||||
Content::removeContent( 'DYN_TITLE', '', $oPro->getDynUid() );
|
||||
Content::removeContent( 'DYN_DESCRIPTION', '', $oPro->getDynUid() );
|
||||
$iResult = $oPro->delete();
|
||||
|
||||
//Add Audit Log
|
||||
//$mode = isset($ProUid['MODE'])? $ProUid['MODE'] : 'Determined by Fields';
|
||||
G::auditLog("DeleteDynaform", "Dynaform Title: ".$title.", Type: ".$type.", Description: ".$description);
|
||||
|
||||
if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' )) {
|
||||
unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user