BUG 9377 "Formatting files to PSR2" SOLVED

Formatting files to PSR2
This commit is contained in:
Victor Saisa Lopez
2012-07-09 16:26:17 -04:00
parent df8cfae446
commit e030e259e1
2 changed files with 2969 additions and 2615 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -24,8 +24,8 @@
* *
*/ */
require_once 'classes/model/om/BaseApplication.php'; require_once ('classes/model/om/BaseApplication.php');
require_once 'classes/model/Content.php'; require_once ('classes/model/Content.php');
/** /**
@@ -39,7 +39,8 @@ require_once 'classes/model/Content.php';
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Application extends BaseApplication { class Application extends BaseApplication
{
/** /**
* This value goes in the content table * This value goes in the content table
@@ -55,11 +56,13 @@ class Application extends BaseApplication {
*/ */
public function getAppTitle() public function getAppTitle()
{ {
if ( $this->getAppUid() == '' ) { if ($this->getAppUid() == '') {
throw ( new Exception( "Error in getAppTitle, the APP_UID can't be blank") ); throw (new Exception( "Error in getAppTitle, the APP_UID can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->app_title = Content::load ( 'APP_TITLE', '', $this->getAppUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->app_title = Content::load('APP_TITLE', '', $this->getAppUid(), $lang);
return $this->app_title; return $this->app_title;
} }
@@ -71,21 +74,21 @@ class Application extends BaseApplication {
*/ */
public function setAppTitle($v) public function setAppTitle($v)
{ {
if ( $this->getAppUid() == '' ) { if ($this->getAppUid() == '') {
throw ( new Exception( "Error in setAppTitle, the APP_UID can't be blank") ); throw (new Exception( "Error in setAppTitle, the APP_UID can't be blank"));
} }
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not). //Since the native PHP type for this column is string,
//we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) { if ($v !== null && !is_string($v)) {
$v = (string) $v; $v = (string) $v;
} }
if ($this->app_title !== $v || $v === '') { if ($this->app_title !== $v || $v === '') {
$this->app_title = $v; $this->app_title = $v;
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$res = Content::addContent( 'APP_TITLE', '', $this->getAppUid(), $lang, $this->app_title ); $res = Content::addContent('APP_TITLE', '', $this->getAppUid(), $lang, $this->app_title);
} }
} // set() } // set()
/** /**
@@ -94,78 +97,89 @@ class Application extends BaseApplication {
*/ */
public function getAppDescription() public function getAppDescription()
{ {
if ( $this->getAppUid() == '' ) { if ($this->getAppUid() == '') {
throw ( new Exception( "Error in getAppDescription, the APP_UID can't be blank") ); throw (new Exception( "Error in getAppDescription, the APP_UID can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->app_description = Content::load ( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->app_description = Content::load('APP_DESCRIPTION', '', $this->getAppUid(), $lang);
return $this->app_description; return $this->app_description;
} }
public function isEmptyInContent ( $content, $field, $lang ) { public function isEmptyInContent($content, $field, $lang)
if ( isset ( $content[$field][ $lang ] ) ) { {
if ( trim( $content[$field][ $lang ] ) != '' ) if (isset($content[$field][$lang])) {
if (trim($content[$field][$lang]) != '') {
return false; return false;
}; }
}
return true; return true;
} }
public function updateInsertContent ( $content, $field, $value ) { public function updateInsertContent($content, $field, $value)
if ( isset ( $content[$field][ 'en' ] ) ) { {
if (isset($content[$field]['en'])) {
//update //update
$con = ContentPeer::retrieveByPK ( $field, '', $this->getAppUid(), 'en' ); $con = ContentPeer::retrieveByPK($field, '', $this->getAppUid(), 'en');
$con->setConValue ( $value ); $con->setConValue($value);
if ($con->validate ()) { if ($con->validate()) {
$res = $con->save (); $res = $con->save();
} }
} } else {
else {//insert //insert
$con = new Content ( ); $con = new Content();
$con->setConCategory ( $field ); $con->setConCategory($field);
$con->setConParent ( '' ); $con->setConParent('');
$con->setConId ( $this->getAppUid()); $con->setConId($this->getAppUid());
$con->setConLang ( 'en' ); $con->setConLang('en');
$con->setConValue ( $value ); $con->setConValue($value);
if ($con->validate ()) {
$res = $con->save (); if ($con->validate()) {
$res = $con->save();
} }
} }
} }
public function normalizeContent( $content, $field , $lang ) { public function normalizeContent($content, $field, $lang)
{
$value = ''; $value = '';
//if the lang row is not empty, update in 'en' row and continue //if the lang row is not empty, update in 'en' row and continue
if ( !$this->isEmptyInContent ( $content, $field , $lang ) ) { if (!$this->isEmptyInContent($content, $field, $lang)) {
//update/insert only if this lang is != 'en', with this always we will have an en row with last value //update/insert only if this lang is != 'en', with this always we will have an en row with last value
$value = $content [ $field ][ $lang ]; $value = $content[$field][$lang];
if ( $lang != 'en' ) {
$this->updateInsertContent ( $content, $field , $value ); if ($lang != 'en') {
$this->updateInsertContent($content, $field, $value);
} }
} } else {
else {
//if the lang row is empty, and 'en' row is not empty return 'en' value //if the lang row is empty, and 'en' row is not empty return 'en' value
if ( !$this->isEmptyInContent ( $content, $field , 'en' ) ) { if (!$this->isEmptyInContent($content, $field, 'en')) {
$value = $content [ $field ][ 'en' ]; $value = $content[$field]['en'];
} }
//if the lang row is empty, and 'en' row is empty get value for 'other' row and update in 'en' row and continue //if the lang row is empty, and 'en' row is empty get value for 'other' row and update in 'en'
if ( $this->isEmptyInContent ( $content, $field , 'en' ) ) { //row and continue
if ( isset($content[$field]) && is_array ($content[$field] ) ) { if ($this->isEmptyInContent($content, $field, 'en')) {
foreach ( $content [ $field ] as $lan => $val ) { if (isset($content[$field]) && is_array($content[$field])) {
if ( trim ( $val ) != '' ) { foreach ($content[$field] as $lan => $val) {
if (trim($val) != '') {
$value = $val; $value = $val;
if ( $lan != 'en' ) {
$this->updateInsertContent ( $content, $field , $value ); if ($lan != 'en') {
$this->updateInsertContent($content, $field , $value);
continue; continue;
} }
} }
} }
} } else {
else { $this->updateInsertContent($content, $field, '');
$this->updateInsertContent ( $content, $field , '' );
} }
} }
} }
return $value; return $value;
} }
@@ -175,38 +189,48 @@ class Application extends BaseApplication {
*/ */
public function getContentFields() public function getContentFields()
{ {
if ( $this->getAppUid() == '' ) { if ($this->getAppUid() == '') {
throw ( new Exception( "Error in getContentFields, the APP_UID can't be blank") ); throw (new Exception("Error in getContentFields, the APP_UID can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$lang = defined('SYS_LANG')? SYS_LANG : 'en';
$c = new Criteria(); $c = new Criteria();
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn( ContentPeer::CON_CATEGORY ); $c->addSelectColumn(ContentPeer::CON_CATEGORY);
$c->addSelectColumn( ContentPeer::CON_LANG ); $c->addSelectColumn(ContentPeer::CON_LANG);
$c->addSelectColumn( ContentPeer::CON_VALUE ); $c->addSelectColumn(ContentPeer::CON_VALUE);
$c->add( ContentPeer::CON_ID, $this->getAppUid() ); $c->add(ContentPeer::CON_ID, $this->getAppUid());
//$c->add( ContentPeer::CON_LANG, $lang ); //$c->add(ContentPeer::CON_LANG, $lang);
$c->addAscendingOrderByColumn('CON_CATEGORY'); $c->addAscendingOrderByColumn('CON_CATEGORY');
$c->addAscendingOrderByColumn('CON_LANG'); $c->addAscendingOrderByColumn('CON_LANG');
$rs = ContentPeer::doSelectRS( $c ); $rs = ContentPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next(); $rs->next();
$content = array(); $content = array();
while ($row = $rs->getRow()) { while ($row = $rs->getRow()) {
$conCategory = $row['CON_CATEGORY']; $conCategory = $row['CON_CATEGORY'];
$conLang = $row['CON_LANG']; $conLang = $row['CON_LANG'];
if ( !isset( $content[$conCategory] ) ) $content[$conCategory] = array();
if ( !isset( $content[$conCategory][$conLang] ) ) $content[$conCategory][$conLang] = array(); if (!isset($content[$conCategory])) {
$content[$conCategory] = array();
}
if (!isset($content[$conCategory][$conLang])) {
$content[$conCategory][$conLang] = array();
}
$content[$conCategory][$conLang] = $row['CON_VALUE']; $content[$conCategory][$conLang] = $row['CON_VALUE'];
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();
} }
$appTitle = $this->normalizeContent( $content, 'APP_TITLE', $lang ); $appTitle = $this->normalizeContent($content, 'APP_TITLE', $lang);
$appDescription = $this->normalizeContent( $content, 'APP_DESCRIPTION', $lang ); $appDescription = $this->normalizeContent($content, 'APP_DESCRIPTION', $lang);
$res['APP_TITLE'] = $appTitle; $res['APP_TITLE'] = $appTitle;
$res['APP_DESCRIPTION'] = $appDescription; $res['APP_DESCRIPTION'] = $appDescription;
return $res; return $res;
} }
@@ -218,9 +242,10 @@ class Application extends BaseApplication {
*/ */
public function setAppDescription($v) public function setAppDescription($v)
{ {
if ( $this->getAppUid() == '' ) { if ($this->getAppUid() == '') {
throw ( new Exception( "Error in setAppTitle, the APP_UID can't be blank") ); throw ( new Exception( "Error in setAppTitle, the APP_UID can't be blank") );
} }
// Since the native PHP type for this column is string, // Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not). // we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) { if ($v !== null && !is_string($v)) {
@@ -229,12 +254,11 @@ class Application extends BaseApplication {
if ($this->app_description !== $v || $v === '') { if ($this->app_description !== $v || $v === '') {
$this->app_description = $v; $this->app_description = $v;
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$res = Content::addContent( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang, $this->app_description ); $res = Content::addContent('APP_DESCRIPTION', '', $this->getAppUid(), $lang, $this->app_description);
} }
} // set() } // set()
/** /**
* Get the [app_proc_code] column value. * Get the [app_proc_code] column value.
* @return string * @return string
@@ -281,13 +305,16 @@ class Application extends BaseApplication {
* @return array $Fields the fields * @return array $Fields the fields
*/ */
function Load ( $AppUid ) { public function Load($AppUid)
{
$con = Propel::getConnection(ApplicationPeer::DATABASE_NAME); $con = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
try { try {
$oApplication = ApplicationPeer::retrieveByPk( $AppUid ); $oApplication = ApplicationPeer::retrieveByPk( $AppUid );
if (is_object($oApplication) && get_class ($oApplication) == 'Application' ) { if (is_object($oApplication) && get_class ($oApplication) == 'Application' ) {
$aFields = $oApplication->toArray(BasePeer::TYPE_FIELDNAME); $aFields = $oApplication->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME ); $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
//this is the new function to optimize content queries //this is the new function to optimize content queries
$aContentFields = $oApplication->getContentFields(); $aContentFields = $oApplication->getContentFields();
@@ -299,15 +326,14 @@ class Application extends BaseApplication {
$this->app_description = $aFields['APP_DESCRIPTION']; $this->app_description = $aFields['APP_DESCRIPTION'];
//$aFields['APP_PROC_CODE'] = $oApplication->getAppProcCode(); //$aFields['APP_PROC_CODE'] = $oApplication->getAppProcCode();
//$this->setAppProcCode ( $oApplication->getAppProcCode() ); //$this->setAppProcCode($oApplication->getAppProcCode());
return $aFields; return $aFields;
} else {
throw (new Exception("The Application row '$AppUid' doesn't exist!"));
} }
else { } catch (Exception $oError) {
throw( new Exception( "The Application row '$AppUid' doesn't exist!" )); throw ($oError);
}
}
catch (Exception $oError) {
throw($oError);
} }
} }
@@ -319,63 +345,67 @@ class Application extends BaseApplication {
* $sUsrUid the userid * $sUsrUid the userid
* @return void * @return void
*/ */
public function create($sProUid, $sUsrUid)
{
$con = Propel::getConnection('workflow');
function create ($sProUid, $sUsrUid ) {
$con = Propel::getConnection( 'workflow' );
try { try {
//fill the default values for new application row //fill the default values for new application row
$this->setAppUid ( G::generateUniqueID() ); $this->setAppUid(G::generateUniqueID());
$this->setAppParent ( '' ); $this->setAppParent('');
$this->setAppStatus ( 'DRAFT' ); $this->setAppStatus('DRAFT');
$this->setProUid ( $sProUid ); $this->setProUid( $sProUid);
$this->setAppProcStatus('' ); $this->setAppProcStatus('');
$this->setAppProcCode ( '' ); $this->setAppProcCode('');
$this->setAppParallel ( 'N' ); $this->setAppParallel('N');
$this->setAppInitUser ( $sUsrUid ); $this->setAppInitUser($sUsrUid);
$this->setAppCurUser ( $sUsrUid ); $this->setAppCurUser($sUsrUid);
$this->setAppCreateDate( 'now' ); $this->setAppCreateDate('now');
$this->setAppInitDate ( 'now' ); $this->setAppInitDate('now');
$this->setAppUpdateDate( 'now' ); $this->setAppUpdateDate('now');
$pin = G::generateCode( 4, 'ALPHANUMERIC'); $pin = G::generateCode(4, 'ALPHANUMERIC');
$this->setAppData ( serialize ( array('PIN'=>$pin) ) ); $this->setAppData(serialize(array('PIN' => $pin)));
$this->setAppPin ( md5($pin) ); $this->setAppPin(md5($pin));
$c = new Criteria(); $c = new Criteria();
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn( 'MAX(' . ApplicationPeer::APP_NUMBER . ')' ); //the appnumber is based in all processes active, not only in the specified process guid
$result = ApplicationPeer::doSelectRS( $c ); $c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')'); //the appnumber is based in all processes
//active, not only in the specified
//process guid
$result = ApplicationPeer::doSelectRS($c);
$result->next(); $result->next();
$row = $result->getRow(); $row = $result->getRow();
$maxNumber = $row[0] + 1; $maxNumber = $row[0] + 1;
$this->setAppNumber ( $maxNumber ); $this->setAppNumber($maxNumber);
if ( $this->validate() ) { if ($this->validate()) {
$con->begin(); $con->begin();
$res = $this->save(); $res = $this->save();
$con->commit(); $con->commit();
//to do: ID_CASE in translation $this->setAppTitle ( G::LoadTranslation ( 'ID_CASE') . $maxNumber ); //to do: ID_CASE in translation $this->setAppTitle(G::LoadTranslation('ID_CASE') . $maxNumber);
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $lang = defined('SYS_LANG')? SYS_LANG : 'en';
Content::insertContent( 'APP_TITLE', '', $this->getAppUid(), $lang, '#' . $maxNumber ); Content::insertContent('APP_TITLE', '', $this->getAppUid(), $lang, '#' . $maxNumber);
Content::insertContent( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang, '' ); Content::insertContent('APP_DESCRIPTION', '', $this->getAppUid(), $lang, '');
//Content::insertContent( 'APP_PROC_CODE', '', $this->getAppUid(), $lang, '' ); //Content::insertContent('APP_PROC_CODE', '', $this->getAppUid(), $lang, '');
$con->commit(); $con->commit();
return $this->getAppUid(); return $this->getAppUid();
} } else {
else {
$msg = ''; $msg = '';
foreach($this->getValidationFailures() as $objValidationFailure)
foreach ($this->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new PropelException ( 'The APPLICATION row cannot be created!', new PropelException ( $msg ) ) );
} }
throw (new PropelException('The APPLICATION row cannot be created!', new PropelException($msg)));
} }
catch (Exception $e) { } catch (Exception $e) {
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
@@ -386,40 +416,48 @@ class Application extends BaseApplication {
* @param array $aData * @param array $aData
* @return variant * @return variant
**/ **/
public function update($aData) public function update($aData)
{ {
$con = Propel::getConnection( ApplicationPeer::DATABASE_NAME ); $con = Propel::getConnection( ApplicationPeer::DATABASE_NAME );
try { try {
$con->begin(); $con->begin();
$oApp = ApplicationPeer::retrieveByPK( $aData['APP_UID'] ); $oApp = ApplicationPeer::retrieveByPK($aData['APP_UID']);
if (is_object($oApp) && get_class ($oApp) == 'Application' ) {
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); if (is_object($oApp) && get_class($oApp) == 'Application') {
$oApp->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oApp->validate()) { if ($oApp->validate()) {
if ( isset ( $aData['APP_TITLE'] ) ) if (isset($aData['APP_TITLE'])) {
$oApp->setAppTitle( $aData['APP_TITLE'] ); $oApp->setAppTitle($aData['APP_TITLE']);
if ( isset ( $aData['APP_DESCRIPTION'] ) ) }
$oApp->setAppDescription( $aData['APP_DESCRIPTION'] ); if (isset($aData['APP_DESCRIPTION'])) {
$oApp->setAppDescription($aData['APP_DESCRIPTION']);
}
//if ( isset ( $aData['APP_PROC_CODE'] ) ) //if ( isset ( $aData['APP_PROC_CODE'] ) )
//$oApp->setAppProcCode( $aData['APP_PROC_CODE'] ); //$oApp->setAppProcCode( $aData['APP_PROC_CODE'] );
$res = $oApp->save(); $res = $oApp->save();
$con->commit(); $con->commit();
return $res; return $res;
} } else {
else {
$msg = ''; $msg = '';
foreach($this->getValidationFailures() as $objValidationFailure)
foreach ($this->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new PropelException ( 'The row cannot be updated!', new PropelException ( $msg ) ) );
} }
throw (new PropelException('The row cannot be updated!', new PropelException($msg)));
} }
else { } else {
$con->rollback(); $con->rollback();
throw(new Exception( "The row '" . $aData['APP_UID'] . "' in table APPLICATION doesn't exist!" ));
throw (new Exception("The row '" . $aData['APP_UID'] . "' in table APPLICATION doesn't exist!"));
} }
} } catch (Exception $oError) {
catch (Exception $oError) { throw ($oError);
throw($oError);
} }
} }
@@ -430,103 +468,110 @@ class Application extends BaseApplication {
**/ **/
public function remove($appUid) public function remove($appUid)
{ {
if ( is_array ( $appUid ) ) { if (is_array($appUid)) {
$appUid = ( isset ( $appUid['APP_UID'] ) ? $appUid['APP_UID'] : '' ); $appUid = (isset($appUid['APP_UID'])? $appUid['APP_UID'] : '');
} }
try { try {
$oApp = ApplicationPeer::retrieveByPK( $appUid ); $oApp = ApplicationPeer::retrieveByPK($appUid);
if (!is_null($oApp))
{ if (!is_null($oApp)) {
Content::removeContent('APP_TITLE', '', $oApp->getAppUid()); Content::removeContent('APP_TITLE', '', $oApp->getAppUid());
Content::removeContent('APP_DESCRIPTION', '', $oApp->getAppUid()); Content::removeContent('APP_DESCRIPTION', '', $oApp->getAppUid());
//Content::removeContent('APP_PROC_CODE', '', $oApp->getAppUid()); //Content::removeContent('APP_PROC_CODE', '', $oApp->getAppUid());
return $oApp->delete(); return $oApp->delete();
} else {
throw (new Exception("The row '$appUid' in table Application doesn't exist!"));
} }
else { } catch (Exception $oError) {
throw(new Exception( "The row '$appUid' in table Application doesn't exist!" )); throw ($oError);
}
}
catch (Exception $oError) {
throw($oError);
} }
} }
function exists( $sAppUid ) public function exists($sAppUid)
{ {
$oApplicaton = ApplicationPeer::retrieveByPK( $sAppUid ); $oApplicaton = ApplicationPeer::retrieveByPK($sAppUid);
return (!is_null($oApplicaton)); return (!is_null($oApplicaton));
} }
function createApplication ($aData ) {
public function createApplication($aData)
{
$c = new Criteria(); $c = new Criteria();
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn( 'MAX(' . ApplicationPeer::APP_NUMBER . ')' ); $c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')');
$c->add( ApplicationPeer::PRO_UID, $aData['PRO_UID'] ); $c->add(ApplicationPeer::PRO_UID, $aData['PRO_UID']);
$result = ApplicationPeer::doSelectRS( $c ); $result = ApplicationPeer::doSelectRS($c);
$result->next(); $result->next();
$row = $result->getRow(); $row = $result->getRow();
$maxNumber = $row[0] + 1; $maxNumber = $row[0] + 1;
$this->setAppUid ( G::generateUniqueID() ); $this->setAppUid(G::generateUniqueID());
$this->setAppNumber ( $maxNumber ); $this->setAppNumber($maxNumber);
$this->setAppParent (isset($aData['APP_PARENT']) ? $aData['APP_PARENT'] : 0 ); $this->setAppParent(isset($aData['APP_PARENT'])? $aData['APP_PARENT'] : 0);
$this->setAppStatus (isset($aData['APP_STATUS']) ? $aData['APP_STATUS'] : 'DRAFT' ); $this->setAppStatus(isset($aData['APP_STATUS'])? $aData['APP_STATUS'] : 'DRAFT');
$this->setProUid ( $aData['PRO_UID'] ); $this->setProUid($aData['PRO_UID']);
$this->setAppProcStatus(isset($aData['APP_PROC_STATUS'])? $aData['APP_PROC_STATUS'] : '' ); $this->setAppProcStatus(isset($aData['APP_PROC_STATUS'])? $aData['APP_PROC_STATUS'] : '');
$this->setAppProcCode (isset($aData['APP_PROC_CODE']) ? $aData['APP_PROC_CODE'] : '' ); $this->setAppProcCode(isset($aData['APP_PROC_CODE'])? $aData['APP_PROC_CODE'] : '');
$this->setAppParallel (isset($aData['APP_PARALLEL']) ? $aData['APP_PARALLEL'] : 'N' ); $this->setAppParallel(isset($aData['APP_PARALLEL'])? $aData['APP_PARALLEL'] : 'N');
$this->setAppInitUser ( $aData['USR_UID'] ); $this->setAppInitUser($aData['USR_UID']);
$this->setAppCurUser ( $aData['USR_UID'] ); $this->setAppCurUser($aData['USR_UID']);
$this->setAppCreateDate(isset($aData['APP_CREATE_DATE'])? $aData['APP_CREATE_DATE'] : 'now' ); $this->setAppCreateDate(isset($aData['APP_CREATE_DATE'])? $aData['APP_CREATE_DATE'] : 'now');
$this->setAppInitDate (isset($aData['APP_INIT_DATE']) ? $aData['APP_INIT_DATE'] : 'now' ); $this->setAppInitDate(isset($aData['APP_INIT_DATE'])? $aData['APP_INIT_DATE'] : 'now');
$this->setAppUpdateDate(isset($aData['APP_UPDATE_DATE'])? $aData['APP_UPDATE_DATE'] : 'now' ); $this->setAppUpdateDate(isset($aData['APP_UPDATE_DATE'])? $aData['APP_UPDATE_DATE'] : 'now');
//$this->setAppData ( serialize ( array() ) ); //$this->setAppData(serialize(array()));
/** Start Comment : Sets the $this->Fields['APP_DATA'] /** Start Comment : Sets the $this->Fields['APP_DATA']
Merge between stored APP_DATA with new APP_DATA. **/ Merge between stored APP_DATA with new APP_DATA. **/
if (!$this->getAppData()) if (!$this->getAppData()) {
{ // if (!$this->is_new)
// if (!$this->is_new) // {
// { // $this->load($fields['APP_UID']);
// $this->load($fields['APP_UID']); // }
// }
} }
$this->Fields['APP_DATA']=isset($this->Fields['APP_DATA'])?$this->Fields['APP_DATA']:array();
if (isset($fields['APP_DATA']) && is_array($fields['APP_DATA'])) $this->Fields['APP_DATA'] = isset($this->Fields['APP_DATA'])? $this->Fields['APP_DATA'] : array();
{
foreach($fields['APP_DATA'] as $k=>$v) if (isset($fields['APP_DATA']) && is_array($fields['APP_DATA'])) {
{ foreach ($fields['APP_DATA'] as $k => $v) {
$this->Fields['APP_DATA'][$k]=$v; $this->Fields['APP_DATA'][$k] = $v;
} }
} }
/** End Comment **/ /** End Comment **/
/** Begin Comment : Replace APP_DATA in APP_TITLE (before to serialize) /*
Begin Comment : Replace APP_DATA in APP_TITLE (before to serialize)
$pro = new process( $this->_dbc ); $pro = new process( $this->_dbc );
$pro->load((isset($fields['PRO_UID']) ? $fields['PRO_UID'] : $this->Fields['PRO_UID'])); $pro->load((isset($fields['PRO_UID']) ? $fields['PRO_UID'] : $this->Fields['PRO_UID']));
$fields['APP_TITLE'] = G::replaceDataField( $pro->Fields['PRO_TITLE'], $this->Fields['APP_DATA']); $fields['APP_TITLE'] = G::replaceDataField( $pro->Fields['PRO_TITLE'], $this->Fields['APP_DATA']);
/** End Comment **/ End Comment
*/
// parent::save(); // parent::save();
// $this->Fields['APP_DATA'] = unserialize($this->Fields['APP_DATA']); // $this->Fields['APP_DATA'] = unserialize($this->Fields['APP_DATA']);
// /** Start Comment: Save in the table CONTENT */ // /** Start Comment: Save in the table CONTENT */
// $this->content->saveContent('APP_TITLE',$fields); // $this->content->saveContent('APP_TITLE',$fields);
// /** End Comment */ // /** End Comment */
if ($this->validate() ) {
if ($this->validate()) {
$res = $this->save(); $res = $this->save();
$this->setAppTitle (''); $this->setAppTitle('');
$this->setAppDescription (''); $this->setAppDescription('');
$this->setAppProcCode (''); $this->setAppProcCode('');
} } else {
else {
// Something went wrong. We can now get the validationFailures and handle them. // Something went wrong. We can now get the validationFailures and handle them.
$msg = ''; $msg = '';
$validationFailuresArray = $this->getValidationFailures(); $validationFailuresArray = $this->getValidationFailures();
foreach($validationFailuresArray as $objValidationFailure) {
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
} }
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
} }
return $this->getAppUid(); return $this->getAppUid();
} }
} // Application }