HOR-2114
This commit is contained in:
@@ -43,27 +43,6 @@
|
||||
class AppDocument extends BaseAppDocument
|
||||
{
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_title = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_comment = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_filename = '';
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
protected $driveDownload = array();
|
||||
protected $syncWithDrive = '';
|
||||
@@ -85,12 +64,6 @@ class AppDocument extends BaseAppDocument
|
||||
$oAppDocument = AppDocumentPeer::retrieveByPK( $sAppDocUid, $iVersion );
|
||||
if (! is_null( $oAppDocument )) {
|
||||
$aFields = $oAppDocument->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
//optimized for speed
|
||||
$aContentFields = $oAppDocument->getContentFields();
|
||||
$aFields['APP_DOC_TITLE'] = $aContentFields['APP_DOC_TITLE'];
|
||||
$aFields['APP_DOC_COMMENT'] = $aContentFields['APP_DOC_COMMENT'];
|
||||
$aFields['APP_DOC_FILENAME'] = $aContentFields['APP_DOC_FILENAME'];
|
||||
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$driveDownload = @unserialize($aFields['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
@@ -232,13 +205,13 @@ class AppDocument extends BaseAppDocument
|
||||
if ($oAppDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset( $aData['APP_DOC_TITLE'] )) {
|
||||
$oAppDocument->setAppDocTitle( $aData['APP_DOC_TITLE'] );
|
||||
$oAppDocument->setAppDocTitleContent( $aData['APP_DOC_TITLE'] );
|
||||
}
|
||||
if (isset( $aData['APP_DOC_COMMENT'] )) {
|
||||
$oAppDocument->setAppDocComment( $aData['APP_DOC_COMMENT'] );
|
||||
$oAppDocument->setAppDocCommentContent( $aData['APP_DOC_COMMENT'] );
|
||||
}
|
||||
if (isset( $aData['APP_DOC_FILENAME'] )) {
|
||||
$oAppDocument->setAppDocFilename( $aData['APP_DOC_FILENAME'] );
|
||||
$oAppDocument->setAppDocFilenameContent( $aData['APP_DOC_FILENAME'] );
|
||||
}
|
||||
$iResult = $oAppDocument->save();
|
||||
$oConnection->commit();
|
||||
@@ -288,13 +261,13 @@ class AppDocument extends BaseAppDocument
|
||||
if ($oAppDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset( $aData['APP_DOC_TITLE'] )) {
|
||||
$oAppDocument->setAppDocTitle( $aData['APP_DOC_TITLE'] );
|
||||
$oAppDocument->setAppDocTitleContent( $aData['APP_DOC_TITLE'] );
|
||||
}
|
||||
if (isset( $aData['APP_DOC_COMMENT'] )) {
|
||||
$oAppDocument->setAppDocComment( $aData['APP_DOC_COMMENT'] );
|
||||
$oAppDocument->setAppDocCommentContent( $aData['APP_DOC_COMMENT'] );
|
||||
}
|
||||
if (isset( $aData['APP_DOC_FILENAME'] )) {
|
||||
$oAppDocument->setAppDocFilename( $aData['APP_DOC_FILENAME'] );
|
||||
$oAppDocument->setAppDocFilenameContent( $aData['APP_DOC_FILENAME'] );
|
||||
}
|
||||
$iResult = $oAppDocument->save();
|
||||
$oConnection->commit();
|
||||
@@ -370,7 +343,7 @@ class AppDocument extends BaseAppDocument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocTitle ()
|
||||
public function getAppDocTitleContent ()
|
||||
{
|
||||
if ($this->app_doc_title == '') {
|
||||
try {
|
||||
@@ -391,7 +364,7 @@ class AppDocument extends BaseAppDocument
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocTitle ($sValue)
|
||||
public function setAppDocTitleContent ($sValue)
|
||||
{
|
||||
if ($sValue !== null && ! is_string( $sValue )) {
|
||||
$sValue = (string) $sValue;
|
||||
@@ -412,7 +385,7 @@ class AppDocument extends BaseAppDocument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocComment ()
|
||||
public function getAppDocCommentContent ()
|
||||
{
|
||||
if ($this->app_doc_comment == '') {
|
||||
try {
|
||||
@@ -433,7 +406,7 @@ class AppDocument extends BaseAppDocument
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocComment ($sValue)
|
||||
public function setAppDocCommentContent ($sValue)
|
||||
{
|
||||
if ($sValue !== null && ! is_string( $sValue )) {
|
||||
$sValue = (string) $sValue;
|
||||
@@ -454,7 +427,7 @@ class AppDocument extends BaseAppDocument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocFilename ()
|
||||
public function getAppDocFilenameContent ()
|
||||
{
|
||||
if ($this->app_doc_filename == '') {
|
||||
try {
|
||||
@@ -475,7 +448,7 @@ class AppDocument extends BaseAppDocument
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocFilename ($sValue)
|
||||
public function setAppDocFilenameContent ($sValue)
|
||||
{
|
||||
if ($sValue !== null && ! is_string( $sValue )) {
|
||||
$sValue = (string) $sValue;
|
||||
@@ -516,136 +489,8 @@ class AppDocument extends BaseAppDocument
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
/*public function setSyncWithDrive ($key)
|
||||
{
|
||||
$data = array('SYNCHRONIZED', 'UNSYNCHRONIZED', 'NO_EXIST_FILE_PM');
|
||||
if (array_search($key, $data) === false) {
|
||||
$key = 'UNSYNCHRONIZED';
|
||||
}
|
||||
$this->syncWithDrive = $key;
|
||||
}*/
|
||||
|
||||
/*public function getSyncWithDrive ()
|
||||
{
|
||||
return $this->syncWithDrive;
|
||||
}*/
|
||||
|
||||
/*public function setSyncPermissions ($email)
|
||||
{
|
||||
$this->syncPermissions = empty($this->syncPermissions) ? $email : ','.$email;
|
||||
}
|
||||
|
||||
public function getSyncPermissions ()
|
||||
{
|
||||
return !empty($this->syncPermissions) ? explode(',', $this->syncPermissions) : '';
|
||||
}*/
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
public function updateInsertContent ($content, $field, $value)
|
||||
{
|
||||
if (isset( $content[$field]['en'] )) {
|
||||
//update
|
||||
$con = ContentPeer::retrieveByPK( $field, $this->getDocVersion(), $this->getAppDocUid(), 'en' );
|
||||
$con->setConValue( $value );
|
||||
if ($con->validate()) {
|
||||
$res = $con->save();
|
||||
}
|
||||
} else {
|
||||
//insert
|
||||
$con = new Content();
|
||||
$con->setConCategory( $field );
|
||||
$con->setConParent( $this->getDocVersion() );
|
||||
$con->setConId( $this->getAppDocUid() );
|
||||
$con->setConLang( 'en' );
|
||||
$con->setConValue( $value );
|
||||
if ($con->validate()) {
|
||||
$res = $con->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function normalizeContent ($content, $field, $lang)
|
||||
{
|
||||
$value = '';
|
||||
//if the lang row is not empty, update in 'en' row and continue
|
||||
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
|
||||
$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
|
||||
if (! $this->isEmptyInContent( $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 ($this->isEmptyInContent( $content, $field, 'en' )) {
|
||||
if (isset( $content[$field] ) && is_array( $content[$field] )) {
|
||||
foreach ($content[$field] as $lan => $val) {
|
||||
if (trim( $val ) != '') {
|
||||
$value = $val;
|
||||
if ($lan != 'en') {
|
||||
$this->updateInsertContent( $content, $field, $value );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->updateInsertContent( $content, $field, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_description] , [app_title] column values.
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getContentFields ()
|
||||
{
|
||||
if ($this->getAppDocUid() == '') {
|
||||
throw (new Exception( "Error in getContentFields, the APP_DOC_UID can't be blank" ));
|
||||
}
|
||||
$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_VALUE );
|
||||
$c->add( ContentPeer::CON_ID, $this->getAppDocUid() );
|
||||
$c->add( ContentPeer::CON_PARENT, $this->getDocVersion() );
|
||||
$c->addAscendingOrderByColumn( 'CON_CATEGORY' );
|
||||
$c->addAscendingOrderByColumn( 'CON_LANG' );
|
||||
$rs = ContentPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$content = array ();
|
||||
while ($row = $rs->getRow()) {
|
||||
$conCategory = $row['CON_CATEGORY'];
|
||||
$conLang = $row['CON_LANG'];
|
||||
if (! isset( $content[$conCategory] )) {
|
||||
$content[$conCategory] = array ();
|
||||
}
|
||||
if (! isset( $content[$conCategory][$conLang] )) {
|
||||
$content[$conCategory][$conLang] = array ();
|
||||
}
|
||||
$content[$conCategory][$conLang] = $row['CON_VALUE'];
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
$res['APP_DOC_TITLE'] = $this->normalizeContent( $content, 'APP_DOC_TITLE', $lang );
|
||||
$res['APP_DOC_COMMENT'] = $this->normalizeContent( $content, 'APP_DOC_COMMENT', $lang );
|
||||
$res['APP_DOC_FILENAME'] = $this->normalizeContent( $content, 'APP_DOC_FILENAME', $lang );
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getObject ($APP_UID, $DEL_INDEX, $STEP_UID_OBJ, $APP_DOC_TYPE)
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
@@ -684,5 +529,11 @@ class AppDocument extends BaseAppDocument
|
||||
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function exists ($sAppDocUid, $iVersion)
|
||||
{
|
||||
$oAppDocument = AppDocumentPeer::retrieveByPK( $sAppDocUid, $iVersion );
|
||||
return (is_object( $oAppDocument ) && get_class( $oAppDocument ) == 'AppDocument');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user