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

View File

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

View File

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