<?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 category of RVSiteBuilder
*
* @package sitebuilder
* @author Pairote Manunphol <pairote@rvglobalsoft.com>
* @version $Revision$
* @since PHP 5.1
*/
class BlockDao extends DbWrapper implements SitebuilderInf
{
function BlockDao()
{
parent::DbWrapper();
}
/**
* Returns a singleton CategoryDao 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;
}
public function findBlockDataByBlockId($blockId, $fecthMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
$query = sprintf('
SELECT
*
FROM
%s as bk
, %s as bt
WHERE
bk.block_id = bt.block_id
%s
ORDER BY bt.section
'
, $this->aConf['table']['rvs_block_user']
, $this->aConf['table']['rvs_block_to_layout_template']
, ($blockId) ? 'AND bk.block_id = ' . RvsLibs_String::quoteSmart($blockId) : ''
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
public function findBlockDataByProjectId($projectId, $fecthMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
$query = sprintf('
SELECT
*
FROM
%s as bk
, %s as bt
WHERE
bk.block_id = bt.block_id
AND bk.project_id = %s
GROUP BY bk.block_id
ORDER BY bt.section,bt.priority
'
, $this->aConf['table']['rvs_block_user']
, $this->aConf['table']['rvs_block_to_layout_template']
, RvsLibs_String::quoteSmart($projectId)
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[$oBlock->block_id]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
public function findBlockUsing($projectId, $blockId, $fecthMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
$query = sprintf('
SELECT
*
FROM
%s as bk
, %s as bt
WHERE
bk.block_id = bt.block_id
AND bt.section <> 0
AND bk.project_id = %s
AND bk.block_id = %s
ORDER BY bt.section
'
, $this->aConf['table']['rvs_block_user']
, $this->aConf['table']['rvs_block_to_layout_template']
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($blockId)
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
public function findBlockToLayoutTemplateUserByLayoutTemplateUserId($layoutTemplateId, $blockId=null, $fecthMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_to_layout_template']);
$query = sprintf('
SELECT
block_id
, layout_template_user_id
, section
, priority
FROM
%s
WHERE
layout_template_user_id = %s
%s
ORDER BY section,priority
'
, $this->aConf['table']['rvs_block_to_layout_template']
, RvsLibs_String::quoteSmart($layoutTemplateId)
, !empty($blockId) ? 'AND block_id = ' . RvsLibs_String::quoteSmart($blockId) : ''
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
public function findBlockUserOfProject($projectId, $fecthMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
$query = sprintf('
SELECT
*
FROM
%s
WHERE
project_id = %s
;'
, $this->aConf['table']['rvs_block_user']
, RvsLibs_String::quoteSmart($projectId)
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[$oBlock->block_id]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
public function findMaxPriorityBlockOfLayoutTemplateUser($layoutTemplateId, $section, $fecthMode='getOne')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_to_layout_template']);
$query = sprintf('
SELECT
MAX(priority) as max_priority
FROM
%s
WHERE
layout_template_user_id = %s
AND section = %s
'
, $this->aConf['table']['rvs_block_to_layout_template']
, RvsLibs_String::quoteSmart($layoutTemplateId)
, RvsLibs_String::quoteSmart($section)
);
$oBlock->query($query);
$aCloneData = array();
while ($oBlock->fetch()) {
$aCloneData[]= clone($oBlock);
}
return DbWrapper::fetchDatas($oBlock->_resultFields, $aCloneData, $fecthMode);
}
//-----------------------------------------INSERT-----------------------------------------
public function insertBlockUser($blockId, $projectId, $userId, $blockName, $blockData, $useWysiwyg='1')
{
SGL::logMessage('Insert to project -->' . $projectId, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
$oBlock->block_id = $blockId;
$oBlock->project_id = $projectId;
$oBlock->rvs_user_id = $userId;
$oBlock->block_name = $blockName;
$oBlock->block_data = $blockData;
$oBlock->use_wysiwyg = $useWysiwyg;
$oBlock->insert();
if (SGL::isError($oBlock)) {
SGL_Error::pop();
return false;
} else {
return true;
}
DB_DataObject::debugLevel();
}
public function insertBlockToLayoutTemplate($layoutTemplateId, $blockId, $section, $priority)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_to_layout_template']);
$oBlock->layout_template_user_id = $layoutTemplateId;
$oBlock->block_id = $blockId;
$oBlock->section = $section;
$oBlock->priority = $priority;
$oBlock->insert();
if (SGL::isError($oBlock)) {
SGL_Error::pop();
return false;
} else {
return true;
}
}
//-----------------------------------------UPDATE-----------------------------------------
public function updateBlockUser($blockId, $blockName, $blockData)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
if ($oBlock->get('block_id', $blockId)) {
$oBlock->block_name = $blockName;
$oBlock->block_data = $blockData;
return $oBlock->update();
}
return false;
}
public function updateBlockToLayoutTemplate($layoutTemplateId, $blockId, $section, $priority)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_to_layout_template']);
$whereAdd = 'layout_template_user_id = ' . RvsLibs_String::quoteSmart($layoutTemplateId);
$whereAdd .= ' AND block_id = ' . RvsLibs_String::quoteSmart($blockId);
$oBlock->section = $section;
$oBlock->priority = $priority;
$oBlock->whereAdd($whereAdd);
return $oBlock->update();
}
//-----------------------------------------DELETE-----------------------------------------
public function deleteBlockUser($blockId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_user']);
if($oBlock->get('block_id', $blockId)) {
$oBlock->block_id = $blockId;
$oBlock->delete();
}
if (SGL::isError($oBlock)) {
SGL_Error::pop();
return false;
} else {
return true;
}
}
public function deleteBlockToLayoutTemplate($layoutTemplateId, $blockId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['rvs_block_to_layout_template']);
if($oBlock->get('block_id', $blockId)) {
$oBlock->layout_template_user_id = $layoutTemplateId;
$oBlock->block_id = $blockId;
$oBlock->delete();
}
if (SGL::isError($oBlock)) {
SGL_Error::pop();
return false;
} else {
return true;
}
if (SGL::isError($oBlock)) {
SGL_Error::pop();
return false;
} else {
return true;
}
}
public function backupsql($projectId, $usrId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$aSQLData = array();
//backup rvs_block_user
$oBlockUser = $this->findBlockUserOfProject($projectId, 'getDataObject');
foreach ($oBlockUser as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
return $aSQLData;
}
public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array()) {
SGL::logMessage(null, PEAR_LOG_DEBUG);
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez