File: //opt/alt/php54/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/OutSuggestionDao.php
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// WebSite: http://www.rvglobalsoft.com
// Unauthorized copying is strictly forbidden and may result in severe legal action.
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
//
// =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
// This Agreement is a legal contract, which specifies the terms of the license
// and warranty limitation between you and RV Global Soft Co.,Ltd. and RV Site Builder.
// You should carefully read the following terms and conditions before
// installing or using this software. Unless you have a different license
// agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
// indicates your acceptance of the license and warranty limitation terms
// contained in this Agreement. If you do not agree to the terms of this
// Agreement, promptly delete and destroy all copies of the Software.
//
// ===== Grant of License =======
// The Software may only be installed and used on a single host machine.
//
// ===== Disclaimer of Warranty =======
// THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
// WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
// WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE
// AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
// FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE
// ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
// LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
// IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
// CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
// OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
// BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
// NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
// RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
// RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
// BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
// +---------------------------------------------------------------------------+
// $Id$
// +---------------------------------------------------------------------------+
/**
* Data access methods for the out suggestion of RVSiteBuilder
*
* @package sitebuilder
* @author Pairote Manunphol <pairote@rvglobalsoft.com>
* @author Parinya <parinya@rvglobalsoft.com>
* @version $Revision$
* @since PHP 5.1
*/
class OutSuggestionDao extends DbWrapper implements SitebuilderInf
{
function OutSuggestionDao()
{
parent::DbWrapper();
}
/**
* Returns a singleton OutSuggestionDao instance.
*
* @param bool $autoload
* @return obj
*/
public static function singleton($autoload=false)
{
static $instance;
// If the instance is not there, create one
if (!isset($instance) || $autoload) {
$class = __CLASS__;
$instance = new $class();
}
return $instance;
}
/**
* Find out suggestion id by project page id
* @author Parinya Chaipetch
*
* @param string $projectPageId
* @param string $fetchMode
* @access public
* @return string|array
*/
function findOutSuggestionIdByProjectPageId($projectPageId=null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel();
$oProjectPageOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_project_page_out_seggestion']);
if (!is_null($projectPageId)) {
$query = sprintf('
SELECT
pos.out_suggestion_id
FROM
%s as pos
, %s as slt
WHERE
pos.project_page_id = %s
AND pos.out_suggestion_id = slt.out_suggestion_id
'
, $this->aConf['table']['rvs_project_page_out_seggestion']
, $this->aConf['table']['rvs_out_seggestion_layout_template']
, RvsLibs_String::quoteSmart($projectPageId)
);
$oProjectPageOutSuggestion->query($query);
}
$aCloneData = array();
while ($oProjectPageOutSuggestion->fetch()) {
$aCloneData[]= clone($oProjectPageOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oProjectPageOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
/**
* Find all out suggestion data by group id
* @param string $listPageId = "'1', '2', '3', '4', '5', '9', '15', '6', '19', '8'"
* @access public
* @return array
*/
public function findAllOutSuggestionDataByGroupName($listPageId = null, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_out_suggestion']);
$condi = '';
if ($listPageId != null && $listPageId !='') {
$condi = ' WHERE out_suggestion_id in ( ' . $listPageId .')';
$query = sprintf('
SELECT
*
FROM
%s
%s
'
, $this->aConf['table']['rvs_out_suggestion']
, $condi
);
$oOutSuggestion->query($query);
}
$aCloneData = array();
while ($oOutSuggestion->fetch()) {
$aCloneData[]= clone($oOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
/**
* Find all out suggestion data
* @author Parinya Chaipetch
* @tutorial SQL Command
* SELECT
* *
* FROM
* rvs_out_suggestion
*
* @param string $fetchMode
* @access public
* @return array
*/
public function findAllOutSuggestionData($fetchMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_out_suggestion']);
$oOutSuggestion->find();
$aCloneData = array();
while ($oOutSuggestion->fetch()) {
$aCloneData[]= clone($oOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
/**
* find new layout by templateid
* @othor pharadol
* @param <string> $projectpageId
* @param <string> $fetchMode
* @return array
*/
public function findNewLayoutByTemplateId($projectpageId = null, $fetchMode = 'getassoc')
{
//SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oProjectPageOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_out_suggestion']);
if (!is_null($projectpageId)) {
$query = sprintf('
SELECT
ly.layout_template_id
FROM
%s as os
, %s as pos
, %s as osl
, %s as ly
WHERE
pos.project_page_id = %s
AND os.out_suggestion_id = pos.out_suggestion_id
AND pos.out_suggestion_id = osl.out_suggestion_id
AND osl.layout_template_id = ly.layout_template_id
'
, $this->aConf['table']['rvs_out_suggestion']
, $this->aConf['table']['rvs_project_page_out_seggestion']
, $this->aConf['table']['rvs_out_seggestion_layout_template']
, $this->aConf['table']['rvs_layout_template']
, RvsLibs_String::quoteSmart($projectpageId)
);
$oProjectPageOutSuggestion->query($query);
}
$aCloneData = array();
while ($oProjectPageOutSuggestion->fetch()) {
$aCloneData[]= clone($oProjectPageOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oProjectPageOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
/**
* find new layout out suggestion by out_suggestion_id
* @othor darawan
* @param <string> $outSuggestionId
* @param <string> $fetchMode
* @return array
*/
public function findoutSuggestionLayout($outSuggestionId = null, $menustyleId = null, $fetchMode = 'getassoc')
{
DB_DataObject::debugLevel();
$oProjectPageOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_out_suggestion_layout']);
if (!is_null($outSuggestionId)) {
$query = sprintf('
SELECT
out_suggestion_id
, rvs_layout_id
, zone_block_id_1
, zone_block_id_2
, zone_block_id_3
, zone_block_id_4
, out_suggestion_image
, menustyle_id
FROM
%s
WHERE
out_suggestion_id = %s
AND menustyle_id = %s
'
, $this->aConf['table']['rvs_out_suggestion_layout']
, RvsLibs_String::quoteSmart($outSuggestionId)
, RvsLibs_String::quoteSmart($menustyleId)
);
$oProjectPageOutSuggestion->query($query);
}
$aCloneData = array();
while ($oProjectPageOutSuggestion->fetch()) {
$aCloneData[]= clone($oProjectPageOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oProjectPageOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
public function findOutSuggestionByProjectPageId($projectPageId, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_project_page_out_seggestion']);
if (!is_null($projectPageId)) {
$oOutSuggestion->project_page_id = $projectPageId;
}
$oOutSuggestion->find();
$aCloneData = array();
while ($oOutSuggestion->fetch()) {
$aCloneData[]= clone($oOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
public function findOutSuggestionByOutSuggestionId($outSuggestionId, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_out_suggestion']);
if (!is_null($outSuggestionId)) {
$oOutSuggestion->out_suggestion_id = $outSuggestionId;
}
$oOutSuggestion->find();
$aCloneData = array();
while ($oOutSuggestion->fetch()) {
$aCloneData[]= clone($oOutSuggestion);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oOutSuggestion->_resultFields, $aCloneData, $fetchMode);
}
//***************************************** DELETE ***********************************
/**
* deleteLayout Page Out Seggestion by usrId and ProjectId
* @author Pharadol
* @param <string> $usrId
* @param <string> $projectPageId
* @return bool
* form file PageStructureMgr.php
*/
public function deleteLayoutPageOutSeggestionByusrIdAndProjectId($projectPageId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$res = false;
$oOutSuggestion = DB_DataObject::factory($this->aConf['table']['rvs_project_page_out_seggestion']);
if (!is_null($projectPageId) && $oOutSuggestion->get('project_page_id', $projectPageId)) {
$res = $oOutSuggestion->delete();
}
return $res;
}
public function backupsql($projectId, $usrId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$aSQLData = array();
/// Get $aProjectPageId From rvs_project_layout_page by project_id
$aProjectPageId = DaoFactory::ProjectLayoutPage()->findProjectLayoutPage($projectId, 'getassoc');
/// Get $aProjectPageId From internal page
$aInternalPage = DaoFactory::InternalPage()->findInternalProjectPageIdByProjectId($projectId, 'getassoc', $aResultFields = array('project_page_id'));
$aProjectPageId = array_merge($aProjectPageId, $aInternalPage);
/// Backup table rvs_project_page_out_seggestion
$aOutSuggestion = array();
foreach ($aProjectPageId as $key => $val) {
$oProjectPageOutSuggestion = DaoFactory::OutSuggestion()->findOutSuggestionByProjectPageId($key, 'getDataObject');
foreach ($oProjectPageOutSuggestion as $k => $v) {
$aOutSuggestion[] = $v->out_suggestion_id;
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
/// Backup rvs_out_seggestion
foreach ($aOutSuggestion as $outSuggestionId) {
$oOutSuggestion = DaoFactory::OutSuggestion()->findOutSuggestionByOutSuggestionId($outSuggestionId, 'getDataObject');
foreach ($oOutSuggestion as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
return $aSQLData;
}
public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array())
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
/// delete rvs_project_page_out_seggestion
if (count($aProjectPageId)) {
foreach ($aProjectPageId as $key => $val) {
DaoFactory::OutSuggestion()->deleteLayoutPageOutSeggestionByusrIdAndProjectId($key);
}
}
}
}
?>