BUG 6688 KT issues

Part of the solution was to fix some issues in core that failed to
update uploaded files to a plugin in local DB

Change-Id: I60d18b0fa8416923780df802110ad81473a43b86
This commit is contained in:
Hugo Loza
2011-04-14 15:59:26 -04:00
parent cb17c58262
commit f19eadf2d4
3 changed files with 34 additions and 28 deletions

View File

@@ -466,33 +466,33 @@ class AppDocument extends BaseAppDocument {
public function isEmptyInContent ( $content, $field, $lang ) { public function isEmptyInContent ( $content, $field, $lang ) {
if ( isset ( $content[$field][ $lang ] ) ) { if ( isset ( $content[$field][ $lang ] ) ) {
if ( trim( $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->getDocVersion(), $this->getAppDocUid(), 'en' ); $con = ContentPeer::retrieveByPK ( $field, $this->getDocVersion(), $this->getAppDocUid(), 'en' );
$con->setConValue ( $value ); $con->setConValue ( $value );
if ($con->validate ()) { if ($con->validate ()) {
$res = $con->save (); $res = $con->save ();
} }
} }
else {//insert else {//insert
$con = new Content ( ); $con = new Content ( );
$con->setConCategory ( $field ); $con->setConCategory ( $field );
$con->setConParent ($this->getDocVersion() ); $con->setConParent ($this->getDocVersion() );
$con->setConId ( $this->getAppDocUid() ); $con->setConId ( $this->getAppDocUid() );
$con->setConLang ( 'en' ); $con->setConLang ( 'en' );
$con->setConValue ( $value ); $con->setConValue ( $value );
if ($con->validate ()) { if ($con->validate ()) {
$res = $con->save (); $res = $con->save ();
} }
} }
} }
public function normalizeContent( $content, $field , $lang ) { public function normalizeContent( $content, $field , $lang ) {
$value = ''; $value = '';
@@ -502,7 +502,7 @@ class AppDocument extends BaseAppDocument {
$value = $content [ $field ][ $lang ]; $value = $content [ $field ][ $lang ];
if ( $lang != 'en' ) { if ( $lang != 'en' ) {
$this->updateInsertContent ( $content, $field , $value ); $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
@@ -514,13 +514,13 @@ class AppDocument extends BaseAppDocument {
if ( $this->isEmptyInContent ( $content, $field , 'en' ) ) { if ( $this->isEmptyInContent ( $content, $field , 'en' ) ) {
if ( isset($content[$field]) && is_array ($content[$field] ) ) { if ( isset($content[$field]) && is_array ($content[$field] ) ) {
foreach ( $content [ $field ] as $lan => $val ) { foreach ( $content [ $field ] as $lan => $val ) {
if ( trim ( $val ) != '' ) { if ( trim ( $val ) != '' ) {
$value = $val; $value = $val;
if ( $lan != 'en' ) { if ( $lan != 'en' ) {
$this->updateInsertContent ( $content, $field , $value ); $this->updateInsertContent ( $content, $field , $value );
continue; continue;
} }
} }
} }
} }
else { else {
@@ -529,7 +529,7 @@ class AppDocument extends BaseAppDocument {
} }
} }
return $value; return $value;
} }
/** /**
* Get the [app_description] , [app_title] column values. * Get the [app_description] , [app_title] column values.
@@ -543,12 +543,12 @@ class AppDocument extends BaseAppDocument {
$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_PARENT ); $c->addSelectColumn( ContentPeer::CON_PARENT );
$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->getAppDocUid() ); $c->add( ContentPeer::CON_ID, $this->getAppDocUid() );
$c->add( ContentPeer::CON_PARENT, $this->getDocVersion() ); $c->add( ContentPeer::CON_PARENT, $this->getDocVersion() );
$c->addAscendingOrderByColumn('CON_CATEGORY'); $c->addAscendingOrderByColumn('CON_CATEGORY');
$c->addAscendingOrderByColumn('CON_LANG'); $c->addAscendingOrderByColumn('CON_LANG');
$rs = ContentPeer::doSelectRS( $c ); $rs = ContentPeer::doSelectRS( $c );

View File

@@ -22,7 +22,7 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
try { //try {
//First review if there is no error with the uploaded document //First review if there is no error with the uploaded document
if ((isset($_FILES['form']))&&($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) { if ((isset($_FILES['form']))&&($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) {
@@ -152,7 +152,6 @@
$aFields = array('APP_DOC_UID' => $appDocUid, $aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $_SESSION['APPLICATION'], 'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'], 'DEL_INDEX' => $_SESSION['INDEX'],
'USR_UID' => $_SESSION['USER_LOGGED'], 'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid, 'DOC_UID' => $docUid,
@@ -167,7 +166,8 @@
$oAppDocument->create($aFields); $oAppDocument->create($aFields);
break; break;
default: //New default: //New
$aFields = array('APP_UID' => $_SESSION['APPLICATION'], $aFields = array(
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'], 'DEL_INDEX' => $_SESSION['INDEX'],
'USR_UID' => $_SESSION['USER_LOGGED'], 'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid, 'DOC_UID' => $docUid,
@@ -200,7 +200,7 @@
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton(); $oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) { if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$oData['APP_UID'] = $_SESSION['APPLICATION']; $oData['APP_UID'] = $_SESSION['APPLICATION'];
$documentData = new uploadDocumentData ( $documentData = new uploadDocumentData (
$_SESSION['APPLICATION'], $_SESSION['APPLICATION'],
@@ -214,8 +214,15 @@
$uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
if($uploadReturn){ if($uploadReturn){
$aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace; $aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace;
$oAppDocument1 = new AppDocument(); if(!isset($aFields['APP_DOC_UID'])){
$oAppDocument1->update($aFields); $aFields['APP_DOC_UID']=$sAppDocUid;
}
if(!isset($aFields['DOC_VERSION'])){
$aFields['DOC_VERSION']=$iDocVersion;
}
//$oAppDocument1 = new AppDocument();
//G::pr($aFields);die;
$oAppDocument->update($aFields);
unlink ( $sPathName . $sFileName ); unlink ( $sPathName . $sFileName );
} }
} }
@@ -280,11 +287,11 @@
} }
} }
$_SESSION['BREAKSTEP']['NEXT_STEP'] = $aNextStep; $_SESSION['BREAKSTEP']['NEXT_STEP'] = $aNextStep;
/*
} catch ( Exception $e ) { } catch ( Exception $e ) {
/* Render Error page */
$aMessage['MESSAGE'] = $e->getMessage(); $aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish' ); G::RenderPage( 'publish' );
} }*/

View File

@@ -610,7 +610,6 @@
$listing=$oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData); $listing=$oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
} }
require_once 'classes/model/OutputDocument.php'; require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new OutputDocument(); $oOutputDocument = new OutputDocument();
$aGields = $oOutputDocument->load($aFields['DOC_UID']); $aGields = $oOutputDocument->load($aFields['DOC_UID']);