File: //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/ComponentDao.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 component of RVSiteBuilder
*
* @package sitebuilder
* @author Pairote Manunphol <pairote@rvglobalsoft.com>
* @author Parinya <parinya@rvglobalsoft.com>
* @version $Revision$
* @since PHP 5.1
*/
class ComponentDao extends DbWrapper implements SitebuilderInf
{
function ComponentDao()
{
parent::DbWrapper();
}
/**
* Returns a singleton ComponentDao 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;
}
/***************************************************************
* ***** SELECT ***** *
****************************************************************/
/**
* find Data from table rvs_component by condition where
* Resulting SQL
* SELECT
* rvs_component_id
* FROM
* rvs_component
* WHERE
* component_name = {$aSelectFiled}
* AND rvs_owner_usr_id = {$usrId}
* @author Darawan Taorong crate date 22/04/2552
* @param array $aSelectFiled ex. $aSelectFiled = array('component_id');
* @param array $aCondi ex. $aCondi = array('component_id'=>'1');
* @param $fetchMode
* @return Object
**/
public function findDataComponentByCondition($aSelectFiled = null, $aCondi = null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel(0);
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (is_array($aSelectFiled)) {
$oComponent->selectadd();
foreach( $aSelectFiled as $v){
$oComponent->selectadd($v);
}
}else $oComponent->selectadd();
if (is_array($aCondi)) {
foreach( $aCondi as $k => $v ){
$oComponent->whereadd("`" . $k . "` = '" . $v . "'");
}
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel(0);
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find Data from table rvs_component_config by condition where
* Resulting SQL
* SELECT
* rvs_component_id
* FROM
* rvs_component_config
* WHERE
* rvs_component_id = {$rvsComponentId}
* AND component_config = {$config}
* $res = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
*
* @author Darawan Taorong crate date 23/04/2552 11:31PM
* @param array $aSelectFiled ex. $aSelectFiled = array('component_id');
* @param array $aCondi ex. $aCondi = array('component_id'=>'1');
* @param $fetchMode
* @return Object
**/
public function findConfigComponentByCondition($aSelectFiled = null, $aCondi = null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel(0);
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (is_array($aSelectFiled) || $aSelectFiled !='' ) {
$oComponent->selectadd();
foreach( $aSelectFiled as $v) {
$oComponent->selectadd($v);
}
}
if (is_array($aCondi)) {
foreach( $aCondi as $k => $v ){
$oComponent->whereadd("`" . $k . "` = '" . $v . "'");
}
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel(0);
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* Selete all component data from table 'rvs_component' and 'rvs_component_config' by rvs_component_id and owner_id
*
* Resulting SQL
* SELECT
* *
* FROM
* rvs_component c
* , rvs_component_config cf
* WHERE
* c.rvs_component_id = {$componentID}
* AND c.rvs_owner_usr_id = {$ownerID}
* AND c.rvs_component_id = cf.rvs_component_id
*
* @access public
* @author tanawat kunanuraknun
* @param string $componentID
* @param string $ownerID
*
* @return <array obj>
*/
public function fineAllComponentByComponentID($componentID=null, $ownerID=null, $fetchMode='getassoc')
{
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
$oComponentConfig = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
$oComponentConfig->joinAdd($oComponent);
if (!is_null($componentID)) {
$oComponentConfig->rvs_component_id = $componentID;
}
$oComponentConfig->rvs_owner_usr_id = $ownerID;
$oComponentConfig->component_config = 'active';
$oComponentConfig->find();
$aCloneData = array();
//$oComponent->query("SELECT * FROM rvs_component c, rvs_component_config cf WHERE c.rvs_component_id = 'd947acc2fae15a67b3735606940f0dcb' AND c.rvs_owner_usr_id = '08c98e0974178020b0d4ce5d0e9e8cce' AND c.rvs_component_id = cf.rvs_component_id");
while ($oComponentConfig->fetch()) {
$aCloneData[]= clone($oComponentConfig);
}
return DbWrapper::fetchDatas($oComponentConfig->_resultFields, $aCloneData, $fetchMode);
}
/**
* find user component config from table 'rvs_user_component_config' by project_page_id and component_id
* Resulting SQL
* SELECT
* *
* FROM
* rvs_user_component_config
* WHERE
* rvs_project_page_id = {$project_page_id}
* AND rvs_component_id = {$rvs_component_id}
* $res = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
*
* @access public
* @author Witoon Jansri
* @param string $project_page_id
* @param string $rvs_component_id
* @param string $fetchmode; getassoc, getall, getrow, getarray
*
* @return <array obj>
*/
public function findUserComponentConfigByProjectpageIdAndComponentId($project_page_id=null, $rvs_component_id=null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($project_page_id)) {
$oComponent->rvs_project_page_id = $project_page_id;
$oComponent->rvs_component_id = $rvs_component_id;
$oComponent->find();
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
public function findComponentByConponentName($componentName = null, $userId, $fetchMode='getassoc')
{
DB_DataObject::debugLevel(0);
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
if (!is_null($componentName)&& !is_null($userId)) {
$query = sprintf("
SELECT
p.project_page_id
, p.page_name
FROM
%s p
, %s c
WHERE
c.rvs_component_id = p.rvs_component_id
AND p.rvs_component_id != ''
AND p.rvs_component_id != '0'
AND c.component_name = %s
AND p.rvs_usr_id = %s
"
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($componentName)
, RvsLibs_String::quoteSmart($userId)
);
$oComponent->query($query);
}
//echo $query;
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find component from table 'rvs_project_page,rvs_component' by project_page_id and rvs_usr_id
* Resulting SQL
* SELECT
* c.rvs_component_id
* , c.component_name
* FROM
* %s p
* , %s c
* WHERE
* p.project_page_id = %s
* AND p.rvs_usr_id = %s
* AND c.rvs_component_id = p.rvs_component_id
* "
* , $this->conf['table']['rvs_project_page']
* , $this->conf['table']['rvs_component']
* , RvsLibs_String::quoteSmart($input->project_page_id)
* , RvsLibs_String::quoteSmart($input->rvs_usr_id)
* $res = $this->dbh->getRow($query,DB_FETCHMODE_ASSOC);
*
* @access public
* @author Darawan Taorong create date 24/04/2552 09:52AM
* @param string $project_page_id
* @param string $UsrId
* @param string $fetchmode; getassoc, getall, getrow, getarray
*
* @return <array obj>
*/
public function findGetComponentByProjectPageIdAndUsrId($projectPageId = null, $UsrId = null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel(0);
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
if (!is_null($projectPageId) && !is_null($UsrId)) {
$query = sprintf("
SELECT
c.rvs_component_id
, c.component_name
FROM
%s p
, %s c
WHERE
p.project_page_id = %s
AND p.rvs_usr_id = %s
AND c.rvs_component_id = p.rvs_component_id
"
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($projectPageId)
, RvsLibs_String::quoteSmart($UsrId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find rvs_component_id, component_name and component_value by rvs_component_id and rvs_component_config
* $query = sprintf('
SELECT
c.rvs_component_id
, c.component_name
, cf.component_value
FROM
%s c
, %s cf
WHERE
c.rvs_component_id = %s
AND c.rvs_owner_usr_id = %s
AND c.rvs_component_id = cf.rvs_component_id
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($rvsComponentID)
, RvsLibs_String::quoteSmart($ownerID)
);
*
* @author duangdao.k
* @param string $rvsComponentID
* @param string $ownerID
* @param string $fecthMode
* @return object
*/
public function findComponentDataByComponentIDAndOwnerID($rvsComponentID = null, $ownerID = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($rvsComponentID) && !is_null($ownerID)) {
$query = sprintf('
SELECT
c.rvs_component_id
, c.component_name
, cf.component_value
FROM
%s c
, %s cf
WHERE
c.rvs_component_id = %s
AND c.rvs_owner_usr_id = %s
AND c.rvs_component_id = cf.rvs_component_id
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($rvsComponentID)
, RvsLibs_String::quoteSmart($ownerID)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find rvs_component_id, component_name and component_value by rvs_component_id and rvs_component_config
* Resulting SQL
* SELECT
* *
* if($ownerID){
* FROM
* rvs_component c
* , rvs_component_config cf
* WHERE
* c.rvs_owner_usr_id = {$ownerID}
* AND c.rvs_component_id = cf.rvs_component_id
* AND (cf.component_config = 'active'
* OR cf.component_config = 'isAdminActiveKey')
* if($componentID){
* AND c.rvs_component_id = {$componentId}
* }
* }else{
* FROM
* rvs_component
* WHERE
* rvs_component_id = {$componentId}
* }
*
* $this->dbh->getAssoc($query);
*
* @author Darawan Taorong
* @param string $componentId
* @param string $ownerID
* @param string $fecthMode
* @return object edit in getcomponentData From file common.php
*/
public function findComponentDataByComponentIdOrOwnerId($componentId = null, $ownerId = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
/*
if (!is_null($ownerId)) {
$query = sprintf('
SELECT
*
FROM
%s c
, %s cf
WHERE
c.rvs_owner_usr_id = %s
AND c.rvs_component_id = cf.rvs_component_id
AND (cf.component_config = %s
OR cf.component_config = %s )
%s
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($ownerId)
, RvsLibs_String::quoteSmart('active')
, RvsLibs_String::quoteSmart('isAdminActiveKey')
, (!is_null($componentId) && $componentId != '') ? ' AND c.rvs_component_id = ' . RvsLibs_String::quoteSmart($componentId) : ''
);
$oComponent->query($query);
} else {
$query = sprintf('
SELECT
*
FROM
%s
WHERE
rvs_component_id = %s
'
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($componentId)
);
$oComponent->query($query);
}
*/
if (!is_null($ownerId)) {
return $this->findComponentByOwnerIdAndComponentId($ownerId, $componentId, $fecthMode);
} else {
return $this->findComponentByComponentId($componentId, $fecthMode);
}
}
public function findComponentByOwnerIdAndComponentId($ownerId = null, $componentId = null, $fecthMode = 'getassoc', $aResultFields = array())
{
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
//rvs_component_id component_name rvs_owner_usr_id use_wysiwyg rvs_component_id component_config component_value
if (!is_null($ownerId)) {
$query = sprintf('
SELECT
DISTINCT (c.rvs_component_id)
, c.component_name
, c.rvs_owner_usr_id
, c.use_wysiwyg
, cf.component_config
, cf.component_value
FROM
%s c
, %s cf
WHERE
c.rvs_component_id = cf.rvs_component_id
AND c.rvs_owner_usr_id = %s
AND (cf.component_config = %s
OR cf.component_config = %s )
%s
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($ownerId)
, RvsLibs_String::quoteSmart('active')
, RvsLibs_String::quoteSmart('isAdminActiveKey')
, (!is_null($componentId) && $componentId != '') ? ' AND c.rvs_component_id = ' . RvsLibs_String::quoteSmart($componentId) : ''
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
$_resultFields = DbWrapper::buildResultFields($oComponent, $aResultFields);
return DbWrapper::fetchDatas($_resultFields, $aCloneData, $fecthMode);
}
public function findgetComponentIdByComponentName($componentName, $ownerId, $fecthMode ='getone', $aResultFields = array())
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
//$oMgr = SGL_Manager::singleton();
if (!is_null($ownerId)) {
$query = sprintf('
SELECT
c.rvs_component_id
FROM
%s as c
,%s as cc
WHERE
c.rvs_component_id = cc.rvs_component_id
AND c.component_name = %s
AND c.rvs_owner_usr_id = %s
AND cc.component_config = %s
AND cc.component_value = %s
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($componentName)
, RvsLibs_String::quoteSmart($ownerId)
, RvsLibs_String::quoteSmart('active')
, RvsLibs_String::quoteSmart('1')
);
$oComponent->getOne($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
$_resultFields = DbWrapper::buildResultFields($oComponent, $aResultFields);
return DbWrapper::fetchDatas($_resultFields, $aCloneData, $fecthMode);
}
public function findComponentByComponentId($componentId = null, $fecthMode = 'getassoc', $aResultFields = array())
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($componentId)) {
$oComponent->rvs_component_id = $componentId;
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
$_resultFields = DbWrapper::buildResultFields($oComponent, $aResultFields);
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($_resultFields, $aCloneData, $fecthMode);
}
/**
* find component config from table 'rvs_component_config' and 'rvs_component' by component_name and rvs_owner_usr_id
* $query = "
* SELECT
* cf.component_config
* , cf.component_value
* FROM
* rvs_component_config cf
* , rvs_component cp
* WHERE
* cp.rvs_owner_usr_id = {$rvs_owner_usr_id}
* AND cp.component_name = '{$component_name}
* AND cf.rvs_component_id = cp.rvs_component_id
*
* $res = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
*
* @access public
* @author Witoon Jansri
* @param string $component_name
* @param string $rvs_owner_usr_id
* @param string $fetchmode; getassoc, getall, getrow, getarray
*
* @return <array obj>
*/
public function findComponentConfigByComponentNameAndOwnerUsrID($component_name=null, $owner_usr_id=null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (!is_null($component_name) && !is_null($owner_usr_id)) {
$query = sprintf('
SELECT
cf.component_config
, cf.component_value
FROM
%s cf
, %s cc
WHERE
cc.rvs_owner_usr_id = %s
AND cc.component_name = %s
AND cf.rvs_component_id = cc.rvs_component_id
'
, $this->aConf['table']['rvs_component_config']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($owner_usr_id)
, RvsLibs_String::quoteSmart($component_name)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find Footer data from table 'rvs_component_header' by project_page_id
*
* Resulting SQL
* SELECT
* footer
* FROM
* rvs_component_header
* WHERE
* project_page_id = {$project_page_id}
*
* @author Pornthip
* @param $project_page_id
* @param $fetchMode
* @return String
*/
public function findFooterDataByProjectpageId($project_page_id=null,$fetchMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponentHeader = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
$oComponentHeader->selectAdd();
$oComponentHeader->selectAdd('footer');
if (!is_null($project_page_id)){
$oComponentHeader->project_page_id = $project_page_id;
}
$oComponentHeader->find();
$aCloneData = array();
while ($oComponentHeader->fetch()) {
$aCloneData[]= clone($oComponentHeader);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponentHeader->_resultFields, $aCloneData, $fetchMode);
}
/**
* find rvs_component_id from table rvs_component by $componentName
*
* Resulting SQL
* SELECT
* rvs_component_id
* FROM
* rvs_component
* WHERE
* component_name = {$componentName}
*
* @author Pornthip
* @param $componentName
* @param $fetchMode
* @return Object
*/
public function findComponentIdByComponentName($componentName=null, $fetchMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
$oComponent->selectAdd();
$oComponent->selectAdd('rvs_component_id');
if (!is_null($componentName)) {
$oComponent->component_name = $componentName;
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find AllData from table rvs_component by $componentId
*
* Resulting SQL
* SELECT
* *
* FROM
* rvs_component
* WHERE
* rvs_component_id = {$componentId}
*
* @author Pornthip
* @param $componentId
* @param $fetchMode
* @return Object
*/
public function findAllDataByComponentId($componentId = null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($componentId)) {
$oComponent->rvs_component_id = $componentId;
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find config block from table 'rvs_block'
* Resulting SQL
* SELECT
* block_id
* , name
* , title
* , blk_order
* , position
* , is_enabled
* FROM
* block
* $aParentMenu = $conn->getAll($query);
*
* @access public
* @author Darawan Taorong
* @param string $fetchmode; getassoc, getall, getrow, getarray
* @param array $aCondi; ex. array('block_id'=> 4); //where block_id = 4
* @return <array obj>
**/
public function findConfigBlock($aCondi = null, $fetchMode='getassoc')
{
DB_DataObject::debugLevel(0);
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['block']);
$oComponent->selectadd();
$oComponent->selectadd('block_id, name, title, blk_order, position, is_enabled');
if (is_array($aCondi)) {
foreach($aCondi as $k => $v){
$oComponent->$k = $v;
}
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel(0);
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find config menu by root id from table 'section'
* Resulting SQL
* SELECT
* section_id
* , title
* #, is_enabled
* FROM
* section
* WHERE
* parent_id = 0
* # parent_id !=0
* # AND root_id = {IrootId}
* $aParentMenu = $conn->getAll($query);
*
* @access public
* @author Darawan Taorong create date: 17/04/2550 13:42PM
* @param string $rootId;
* @param bool $getParentMenu;
* @param string $getField;
* @param string $fetchmode; getassoc, getall, getrow, getarray
* @return <array obj>
*/
public function findGetSGLConfigMenuByRootId($fetchMode='getassoc', $getParentMenu = false, $getField = null, $rootId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG); ;
$oSection = DB_DataObject::factory($this->aConf['table']['section']);
$oSection->selectadd();
if (!is_null($getField)) {
$oSection->selectadd($getField);
}
if (is_null($getParentMenu) || $rootId == 0) {
$oSection->parent_id = 0;
$oSection->find();
} else {
$oSection->whereAdd(" 'parent_id' != '0'");
if (!is_null($rootId))
{
$oSection->root_id = $rootId;
}
$oSection->find();
}
$aCloneData = array();
while ($oSection->fetch()) {
$aCloneData[]= clone($oSection);
}
return DbWrapper::fetchDatas($oSection->_resultFields, $aCloneData, $fetchMode);
}
/**
* Find project and component data by project id and usr id and owner id
*
* Resulting SQL
* SELECT
* DISTINCT (p.project_id)
* , l.project_page_id
* , j.page_name
* , cp.rvs_component_id
* ,cp.component_name
* , cp.rvs_owner_usr_id
* FROM
* rvs_project p
* , rvs_project_layout_page l
* , rvs_project_page j
* , rvs_component cp
* WHERE
* p.project_id = {$projectId}
* AND p.rvs_usr_id = {$userId}
* AND cp.rvs_owner_usr_id = {$ownerId}
* AND p.project_id = l.project_id
* AND l.project_page_id = j.project_page_id
* AND j.rvs_component_id = cp.rvs_component_id
*
* @param string $projectId
* @param string $userId
* @param string $ownerId
* @param string $fetchMode
* @author Parinya Chaipetch
* @access public
* @return array
*/
public function findComponentAndProjectDataByProjectIdAndUsrIdAndOwnerId($projectId = null, $userId = null, $ownerId = null, $fetchMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
DB_DataObject::debugLevel(0);
$query = sprintf('
SELECT
DISTINCT (p.project_id)
, l.project_page_id
, j.page_name
, cp.rvs_component_id
,cp.component_name
, cp.rvs_owner_usr_id
FROM
%s p
, %s l
, %s j
, %s cp
WHERE
p.project_id = %s
AND p.rvs_usr_id = %s
AND cp.rvs_owner_usr_id = %s
AND p.project_id = l.project_id
AND l.project_page_id = j.project_page_id
AND j.rvs_component_id = cp.rvs_component_id
AND cp.rvs_component_id != ""
'
, $this->aConf['table']['rvs_project']
, $this->aConf['table']['rvs_project_layout_page']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($userId)
, RvsLibs_String::quoteSmart($ownerId)
);
//SGL::logMessage('Find component : ' . $query, PEAR_LOG_DEBUG);
$oComponent->query($query);
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel(0);
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
public function findComponentOnInternalPage($projectId = null, $userId = null, $ownerId = null, $fetchMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
DB_DataObject::debugLevel(0);
//fix fine component ใน internal page
$query = sprintf('
SELECT
DISTINCT (p.project_id)
, I.project_page_id
, j.page_name
, cp.rvs_component_id
,cp.component_name
, cp.rvs_owner_usr_id
FROM
%s p
, %s I
, %s j
, %s cp
WHERE
p.project_id = %s
AND p.rvs_usr_id = %s
AND cp.rvs_owner_usr_id = %s
AND p.project_id = I.project_id
AND I.project_page_id = j.project_page_id
AND j.rvs_component_id = cp.rvs_component_id
AND cp.rvs_component_id != ""
'
, $this->aConf['table']['rvs_project']
, $this->aConf['table']['rvs_internal_page']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($userId)
, RvsLibs_String::quoteSmart($ownerId)
);
// SGL::logMessage('Find component : ' . $query, PEAR_LOG_DEBUG);
$oComponent->query($query);
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel(0);
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/**
* find Header data from table 'rvs_component_header' by project_page_id
*
* Resulting SQL
* SELECT
* header
* FROM
* rvs_component_header
* WHERE
* project_page_id = {$projectPageId}
*
* @author Pornthip Phothong
* @param $project_page_id
* @param $fetchMode
* @return String
*/
public function findHeaderDataByProjectpageId($projectPageId=null,$fetchMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponentHeader = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
$oComponentHeader->selectAdd();
$oComponentHeader->selectAdd('header');
if (!is_null($projectPageId)){
$oComponentHeader->project_page_id = $projectPageId;
}
$oComponentHeader->find();
$aCloneData = array();
while ($oComponentHeader->fetch()) {
$aCloneData[]= clone($oComponentHeader);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponentHeader->_resultFields, $aCloneData, $fetchMode);
}
/**
* find component data from table 'rvs_component' and 'rvs_project_page' by project_page_id and rvs_usr_id
*
* Resulting SQL
* SELECT
* c.rvs_component_id
* , c.component_name
* FROM
* rvs_project_page p
* , rvs_component c
* WHERE
* p.project_page_id = {$roject_page_id}
* AND p.rvs_usr_id = {$rvs_usr_id}
* AND c.rvs_component_id = p.rvs_component_id
*
* @access public
* @author Witoon Jansri
* @param string $project_page_id
* @param string $rvs_usr_id
* @param string $fetchmode; getassoc, getall, getrow, getarray
*
* @return <array obj>
*/
public function findComponentByProjectpageIdAndUsrId($projectPageId=null, $usrId=null, $fecthMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
/*
$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
$oComponent->joinAdd($oProjectPage);
$oComponent->selectAdd();
$oComponent->selectAdd('rvs_component_id, component_name');
//$oComponent->orderBy('project_name');
if (!is_null($project_page_id)) {
$oProjectPage->project_page_id = $project_page_id;
$oProjectPage->rvs_usr_id = $rvs_usr_id;
$oComponent->find();
}
*/
if (!is_null($projectPageId)) {
$query = sprintf('
SELECT
c.rvs_component_id
, c.component_name
FROM
%s p
, %s c
WHERE
p.project_page_id = %s
AND p.rvs_usr_id = %s
AND c.rvs_component_id = p.rvs_component_id
AND c.rvs_component_id != ""
'
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($projectPageId)
, RvsLibs_String::quoteSmart($usrId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find All Data By ProjectPageId from table rvs_component_header and rvs_project_page
* @author Pornthip Phothong
* @param $projectPageId
* @param $fetchMode
* @return array obj
/* $query = "
SELECT
*
FROM
{$this->conf['table']['rvs_component_header']} ch
, {$this->conf['table']['rvs_project_page']} pp
WHERE
ch.project_page_id = pp.project_page_id
AND pp.project_page_id = '$projectPageId'
";
$res = $this->dbh->getRow($query,DB_FETCHMODE_ASSOC);
*/
public function findAllDataInComponentHeaderByProjectPageId($projectPageId=null, $fecthMode='getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
if (!is_null($projectPageId)) {
$query = sprintf('
SELECT
*
FROM
%s as ch
, %s as pp
WHERE
pp.project_page_id = %s
AND ch.project_page_id = pp.project_page_id
'
, $this->aConf['table']['rvs_component_header']
, $this->aConf['table']['rvs_project_page']
, RvsLibs_String::quoteSmart($projectPageId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find Compent by owner_usr_id
* @author Pharadol
* @param <string> $uid
* @param <string> $fecthMode
* @return array
* form filej PageStrctrueMgr.php
/*
$query = "
SELECT
cf.component_value
, cp.component_name
FROM
{$this->conf['table']['rvs_component']} cp
, {$this->conf['table']['rvs_component_config']} cf
WHERE
cp.rvs_owner_usr_id = '$uid'
AND cf.rvs_component_id = cp.rvs_component_id
AND cf.component_config = 'active'
";
$res = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
*/
public function findComponentConfigByOwnerUsrId($uid = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($uid)) {
$query = sprintf('
SELECT
cf.component_value
, cp.component_name
FROM
%s as cp
, %s as cf
WHERE
cp.rvs_owner_usr_id = %s
AND cf.rvs_component_id = cp.rvs_component_id
AND cf.component_config = "active"
AND cp.rvs_component_id != ""
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($uid)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find component by owner id and component name
* @author Pharadol
* @param <string> $ownerId
* @param <string> $componentName
* @param <string> $fecthMode
* @return <array>
/*
$query = "
SELECT
cp.rvs_component_id
FROM
{$this->conf['table']['rvs_component']} as cp
, {$this->conf['table']['rvs_component_config']} as cc
WHERE
cp.rvs_component_id = cc.rvs_component_id
AND cp.component_name = '" . $component[1] . "'
AND cp.rvs_owner_usr_id = '$input->owner_id'
";
$res = $this->dbh->getRow($query,DB_FETCHMODE_ASSOC);
*/
public function findComponentByOwnerIdAndComponantName($ownerId = null, $componentName = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($ownerId) && !is_null($componentName)) {
$query = sprintf('
SELECT
cp.rvs_component_id
FROM
%s as cp
, %s as cc
WHERE
cp.rvs_component_id = cc.rvs_component_id
AND cp.component_name = %s
AND cp.rvs_owner_usr_id = %s
AND cp.rvs_component_id != ""
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($componentName)
, RvsLibs_String::quoteSmart($ownerId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find owner component data
* @author Pharadol
* @param <string> $ownerId
* @return <array>
*/
public function findOwnerComponentData($ownerId = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($ownerId)) {
$query = sprintf(' SELECT
DISTINCT
cp.rvs_component_id
, cp.component_name
, cp.rvs_owner_usr_id
FROM
%s cp
, %s cc
WHERE
cp.rvs_component_id = cc.rvs_component_id
AND cp.rvs_owner_usr_id = %s
AND cp.rvs_component_id != ""
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($ownerId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
}
/**
* find component data by ownerid and componentid
* @author Pharadol
* @param <string> $ownerId
* @param <string> $componentId
* @param <string> $fecthMode
* @return array
*/
public function findComponentDataByOwnerIdAndComponentId($ownerId = null, $componentId = null, $fecthMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
/*
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
$active = 'active';
$isAdminActiveKey = 'isAdminActiveKey';
if (!is_null($ownerId)) {
$query = sprintf('
SELECT
*
FROM
%s c
, %s cf
WHERE
c.rvs_owner_usr_id = %s
AND c.rvs_component_id = cf.rvs_component_id
AND (cf.component_config = %s
OR cf.component_config = %s)
%s
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($ownerId)
, RvsLibs_String::quoteSmart($active)
, RvsLibs_String::quoteSmart($isAdminActiveKey)
, !is_null($componentId) ? sprintf(' AND c.rvs_component_id = %s', RvsLibs_String::quoteSmart($componentId)) : ''
);
} else {
$query = sprintf('
SELECT
*
FROM
%s
WHERE
rvs_component_id = %s
'
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($componentId)
);
}
$oComponent->query($query);
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fecthMode);
*/
/// query is exist in function findComponentDataByComponentIdOrOwnerId
if (!is_null($ownerId)) {
return $this->findComponentByOwnerIdAndComponentId($ownerId, $componentId, $fecthMode);
} else {
return $this->findComponentByComponentId($componentId, $fecthMode);
}
}
/**
* find componet header footer by projectpageid
* @othor pharadol
* @param <string> $projectPageId
* @param <string> $fecthMode
* @return array
*/
public function findComponentHeaderFooterByProjectPageId($projectPageId = null, $fecthMode = 'getassoc')
{
DB_DataObject::debugLevel();
//SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponentHeaderFooter = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
if (!is_null($projectPageId)) {
$oComponentHeaderFooter->project_page_id = $projectPageId;
}
$oComponentHeaderFooter->find();
$aCloneData = array();
while ($oComponentHeaderFooter->fetch()) {
$aCloneData[]= clone($oComponentHeaderFooter);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponentHeaderFooter->_resultFields, $aCloneData, $fecthMode);
}
public function findComponentIdFromProjectPageByProjectPageId($projectPageId, $fetchMode = 'getassoc')
{
//SGL::logMessage(null, PEAR_LOG_DEBUG);
$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
$oProjectPage->selectAdd();
$oProjectPage->selectAdd('rvs_component_id');
if (!is_null($projectPageId)) {
$oProjectPage->project_page_id = $projectPageId;
}
$oProjectPage->find();
$aCloneData = array();
while ($oProjectPage->fetch()) {
$aCloneData[] = clone($oProjectPage);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
}
public function findComponentConfigByComponentId($componentId, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (!is_null($componentId)) {
$oComponent->rvs_component_id = $componentId;
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[] = clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
public function findUserComponentConfigByProjectPageId($projectPageId, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oUserComponentConfig = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($projectPageId)) {
$oUserComponentConfig->rvs_project_page_id = $projectPageId;
}
$oUserComponentConfig->find();
$aCloneData = array();
while ($oUserComponentConfig->fetch()) {
$aCloneData[] = clone($oUserComponentConfig);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oUserComponentConfig->_resultFields, $aCloneData, $fetchMode);
}
public function findComponentByOwnerUsrId($ownerUsrId, $fetchMode, $aResultFields = array())
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($ownerUsrId)) {
$oComponent->rvs_owner_usr_id = $ownerUsrId;
}
$oComponent->find();
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[] = clone($oComponent);
}
DB_DataObject::debugLevel();
$_resultFields = DbWrapper::buildResultFields($oComponent, $aResultFields);
return DbWrapper::fetchDatas($_resultFields, $aCloneData, $fetchMode);
}
function findComponentDataByProjectId($proId = null, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($proId)) {
$query = sprintf('
SELECT
c.rvs_component_id
, c.component_name
FROM
%s c
, %s pp
, %s pl
WHERE
pl.project_id = %s
AND pl.project_page_id = pp.project_page_id
AND c.rvs_component_id = pp.rvs_component_id
AND c.rvs_component_id != ""
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($proId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
function findComponentAllDataByComponentIdAndOwnerId($componentId, $ownerId, $fetchMode = 'getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($componentId) && !is_null($ownerId)) {
$query = sprintf('
SELECT
*
FROM
%s c
, %s cf
WHERE
c.rvs_component_id = %s
AND c.rvs_owner_usr_id = %s
AND c.rvs_component_id = cf.rvs_component_id
AND c.rvs_component_id != ""
'
, $this->aConf['table']['rvs_component']
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($componentId)
, RvsLibs_String::quoteSmart($ownerId)
);
$oComponent->query($query);
}
$aCloneData = array();
while ($oComponent->fetch()) {
$aCloneData[]= clone($oComponent);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oComponent->_resultFields, $aCloneData, $fetchMode);
}
/***************************************************************
* ***** INSERT ***** *
****************************************************************/
/**
* Insert rvs_Component
*
* Resulting SQL
* INSERT INTO
* rvs_component
* (
* rvs_component_id
* , component_name
* , rvs_owner_usr_id
* )
* VALUES
* (
* $rvsComponentId
* , $input->component_name
* , $input->rvs_usr_id
* )
* @author Darawan Taorong
* @param string $componentId
* @param string $componentName
* @param string $usrId
* @access public
* @return bool
**/
public function insertComponent($componentId = null, $componentName = null, $usrId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if (!is_null($componentId) && !is_null($componentName) && !is_null($usrId)){
///Fix PHP5.3 (use MDB2)
if (!empty($componentId)) {
$oComponent->rvs_component_id = $componentId;
}
if (!empty($componentName)) {
$oComponent->component_name = $componentName;
}
if (!empty($usrId)) {
$oComponent->rvs_owner_usr_id = $usrId;
}
///Fix PHP5.3 (use MDB2)
$res = $oComponent->insert();
}
DB_DataObject::debugLevel(0);
return (isset($res) && $res) ? true : false;
}
/**
* Insert rvs_Component
*
* Resulting SQL
* INSERT INTO
* rvs_component_config(
* rvs_component_id
* , component_config
* , component_value
* ) VALUES (
* $rvsComponentId
* , $key
* , RvsLibs_String::quoteSmart($val)
* )
*
* @param array $afield ex. $afield = array('rvs_component_id'=>'1234565');
* @author Darawan Taorong crate date 23/04/2552
* @access public
* @return bool
**/
public function insertComponentConfig($afield = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (is_array($afield)) {
foreach($afield as $k => $v){
///Fix PHP5.3 (use MDB2)
if (is_null($v) === false && !empty($v)) {
$oComponent->$k = $v;
}
//$oComponent->$k = $v;
///Fix PHP5.3 (use MDB2)
}
$oComponent->insert();
}
DB_DataObject::debugLevel(0);
return 0;
}
/**
* Insert User Component Config data
*
* Resulting SQL
* INSERT INTO
* rvs_user_component_config(
* rvs_project_page_id
* , rvs_component_id
* , component_config
* , component_value
* ) VALUES (
* $input->project_page_id
* , $input->component_id
* , $key
* , $val
* )
*
* @param array $field
* @author Darawan Taorong
* @access public
* @return bool
**/
public function insertUserComponentConfig($field = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
///Fix PHP5.3 (use MDB2)
if (!is_null($field)) {
foreach($field as $k => $v){
//$oComponent->$k = $v;
if (is_null($v) === false && !empty($v)) {
$oComponent->$k = $v;
}
}
$oComponent->insert();
}
///Fix PHP5.3 (use MDB2)
DB_DataObject::debugLevel(0);
return 0;
}
/**
* insert Component Footer Data
*
* Resulting SQL
* INSERT INTO
* rvs_component_header
* ( project_page_id, footer)
* VALUES
* ( {$projectPageId}, {$pageFooter} )
*
* @author Pornthip Phothong
* @param $projectPageId
* @param $pageFooter
* @return bool
* from file ComponentFooterMgr.php
*/
public function insertComponentFooter($projectPageId, $pageFooter)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponentHeader = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
///Fix PHP5.3 (use MDB2)
if (is_null($projectPageId) === false && !empty($projectPageId)) {
$oComponentHeader->project_page_id = $projectPageId;
}
if (is_null($pageFooter) === false && !empty($pageFooter)) {
$oComponentHeader->footer = $pageFooter;
}
///Fix PHP5.3 (use MDB2)
$res = $oComponentHeader->insert();
DB_DataObject::debugLevel();
return (isset($res) && $res) ? true : false;
}
/**
* insert Component Header Data
* Resulting SQL
* INSERT INTO
* rvs_component_header (
* project_page_id
* , header
* )
* VALUES (
* {$projectPageId}
* , {$pageHeader}
* )
*
* @author Pornthip Phothong
* @param $projectPageId
* @param $pageHeader
* from file ComponentHeaderMgr.php
*/
public function insertComponentHeader($projectPageId, $pageHeader)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponentHeader = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
///Fix PHP5.3 (use MDB2)
if (is_null($projectPageId) === false && !empty($projectPageId)) {
$oComponentHeader->project_page_id = $projectPageId;
}
if (is_null($pageHeader) === false && !empty($pageHeader)) {
$oComponentHeader->header = $pageHeader;
}
///Fix PHP5.3 (use MDB2)
$res = $oComponentHeader->insert();
DB_DataObject::debugLevel();
return (isset($res) && $res) ? true : false;
}
/**
* Insert component usr
* @author Pharadol
* @param <string> $usewysiwyg
* @param <string> $wonerUsrId
* @param <string> $cName
* @param <string> $rvsComponentId
* form file StructureMgr.php
/*
$query1 = "
INSERT INTO
{$this->conf['table']['rvs_component']} (
rvs_component_id
, component_name
, rvs_owner_usr_id
, use_wysiwyg
)
VALUES (
'$rvsComponentId'
, '$cName'
, '$uid'
, '" . $aIniComponent[$cName]['use_wysiwyg'] . "'
)
";
$res1 = $this->dbh->query($query1);
*/
public function insertComponentUser1($usewysiwyg, $wonerUsrId, $cName, $rvsComponentId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component']);
if ($rvsComponentId != '') {
$query = sprintf('
INSERT INTO
%s
(
rvs_component_id
, component_name
, rvs_owner_usr_id
, use_wysiwyg
)
VALUES (
%s
, %s
, %s
, %s
)
'
, $this->aConf['table']['rvs_component']
, RvsLibs_String::quoteSmart($rvsComponentId)
, RvsLibs_String::quoteSmart($cName)
, RvsLibs_String::quoteSmart($wonerUsrId)
, ($usewysiwyg == '1' || $usewysiwyg == 1 || $usewysiwyg == 'true' || $usewysiwyg == true) ? 1 : 0
);
$res = $oComponent->query($query);
}
}
/**
* insert component fied compoponent value
* @author Pharadol
* @param <string> $componentValue
* @param <string> $rvsComponentId
/*
$query1 = "
INSERT INTO
{$this->conf['table']['rvs_component_config']} (
rvs_component_id
, component_config
, component_value
)
VALUES (
'$rvsComponentId'
, 'active'
, '" . $aIniComponent[$cName]['active'] . "'
)";
$res1 = $this->dbh->query($query1);
*/
public function insertComponentUser2($componentValue, $rvsComponentId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
$active = 'active';
if ($rvsComponentId != '') {
$query = sprintf('
INSERT INTO
%s
(
rvs_component_id
, component_config
, component_value
)
VALUES (
%s
, %s
, %s
)
'
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($rvsComponentId)
, RvsLibs_String::quoteSmart($active)
, RvsLibs_String::quoteSmart($componentValue)
);
$res = $oComponent->query($query);
}
}
/**
* insert component fild reseller
* @author Pharadol
* @param <string> $componentValue
* @param <string> $rvsComponentId
/*
$query2 = "
INSERT INTO
{$this->conf['table']['rvs_component_config']} (
rvs_component_id
, component_config
, component_value
)
VALUES (
'$rvsComponentId'
, 'isResellerConfig'
, '" . $aIniComponent[$cName]['isResellerConfig'] . "'
)";
$res2 = $this->dbh->query($query2);
*/
public function insertComponentUsers($isResellerConfig, $rvsComponentId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
$isReseller = 'isResellerConfig';
if ($rvsComponentId != '') {
$query = sprintf('
INSERT INTO
%s
(
rvs_component_id
, component_config
, component_value
)
VALUES (
%s
, %s
, %s
)
'
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($rvsComponentId)
, RvsLibs_String::quoteSmart($isReseller)
, RvsLibs_String::quoteSmart($isResellerConfig)
);
$res = $oComponent->query($query);
}
}
/***************************************************************
* ***** UPDATE *****
*
* If you want to update a field to null in the database
* set the field in your DO to the string 'null'.
*
* For string fields, setting it to '' or 'null' issues null in the update statement.
* Example:
* Set the contractNumber to null.
*
* //INCORRECT
* $contract->get(123);
* $contract->contractNumber = null;
* $contract->update();
*
* //CORRECT
* $contract->get(123);
* $contract->contractNumber = 'null';
* $contract->update();
****************************************************************/
/**
* Update rvs_component_config
*
* Resulting SQL
* UPDATE
* rvs_component_config
* SET
* component_value = {$companentValue}
* WHERE
* rvs_component_id = {$componentId}
* AND component_config = {$componentConfig}
*
* Modify last update section enabled By sectionId in database
* @access public
* @author Darawan Taorong crate date 23/04/52
* @param string $componentId
* @param string $componentConfig
* @param string $companentValue
* @return boolean
**/
public function updateConfigComponentByComponentIdAndConponentConfig($componentId = null, $componentConfig = null, $companentValue = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (!is_null($componentId) && !is_null($componentConfig) && !is_null($componentConfig)) {
$query = sprintf('
UPDATE
%s
SET
component_value = %s
WHERE
rvs_component_id = %s
AND component_config = %s
'
, $this->aConf['table']['rvs_component_config']
, RvsLibs_String::quoteSmart($companentValue)
, RvsLibs_String::quoteSmart($componentId)
, RvsLibs_String::quoteSmart($componentConfig)
);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
}
return $res;
}
/**
* Update rvs_component_config
*
* Resulting SQL
* UPDATE
* rvs_user_component_config uc
* , rvs_project_page pp
* , rvs_project_layout_page pl
* SET
* uc.rvs_component_id = {$componentId}
* WHERE
* uc.rvs_project_page_id = pp.project_page_id
* AND pp.project_page_id = pl.project_page_id
* AND pl.project_id = {$projectId}
* AND pp.rvs_usr_id = {$rvsUsrId}
* AND uc.rvs_project_page_id = {$pageId}
*
* Modify last update component id By project id, user id, page id in database
* @access public
* @author Darawan Taorong crate date 11/05/52
* @param string $componentId
* @param string $projectId
* @param string $rvsUsrId
* @param string $pageId
* @return boolean
**/
public function updateComponentIdByProjectIdAndUsrIdAndPageId($componentId = null, $projectId = null, $rvsUsrId = null, $pageId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_config']);
if (!is_null($componentId) && !is_null($projectId) && !is_null($rvsUsrId) && !is_null($pageId)) {
$query = sprintf('
UPDATE
%s uc
, %s pp
, %s pl
SET
uc.rvs_component_id = %s
WHERE
uc.rvs_project_page_id = pp.project_page_id
AND pp.project_page_id = pl.project_page_id
AND pl.project_id = %s
AND pp.rvs_usr_id = %s
AND uc.rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($componentId)
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($rvsUsrId)
, RvsLibs_String::quoteSmart($pageId)
);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
}
return $res;
}
/**
* Modify last update section enabled By sectionId in database
* Resulting SQL
* UPDATE
* section
* SET
* is_enabled = {$isEnabled}
* WHERE
* section_id = {$sectionId}
*
* @access public
* @author Darawan Taorong
* @param string $sectionId
* @param string $isEnabled
*
* @return boolean
*/
public function updateSGLConfigMenuEnableBySectionId($sectionId=null, $isEnabled=null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oProject = DB_DataObject::factory($this->aConf['table']['section']);
if (!is_null($sectionId) && !is_null($isEnabled)) {
$oProject->get('section_id', $sectionId);
///Fix PHP5.3 (use MDB2) is_enabled มีค่า Default เป็น null
if (is_null($isEnabled) || empty($isEnabled)) {
$oProject->is_enabled = 'null';
} else {
$oProject->is_enabled = $isEnabled;
}
///Fix PHP5.3 (use MDB2) is_enabled มีค่า Default เป็น null
$oProject->update();
}
return 0;
}
/**
* Modify blk_order position is_enabled By block_id in database
* Resulting SQL
* UPDATE
* block
* SET
* blk_order = {$blkOrder}
* , position = {$position}
* , is_enabled = {$isEnabled}
* WHERE
* block_id = {$blockId}
*
* @access public
* @author Darawan Taorong
* @param string $blkOrder
* @param string $position
* @param string $isEnabled
* @param string $blockId
*
* @return boolean
*/
public function updateBlkOrderPositionIsEnabledByBlockId($blkOrder = null, $position = null, $isEnabled = null, $blockId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$oBlock = DB_DataObject::factory($this->aConf['table']['block']);
if (!is_null($blkOrder) && !is_null($position) && !is_null($isEnabled) && !is_null($blockId)) {
$oBlock->get('block_id', $blockId);
$oBlock->blk_order = $blkOrder;
$oBlock->position = $position;
$oBlock->is_enabled = $isEnabled;
$oBlock->update();
}
return 0;
}
/**
* update footer By ProjectId and UsrId and ProjectPageId in rvs_component_header table
* Resulting SQL
* UPDATE
* rvs_component_header ch
* , rvs_project_layout_page pl
* , rvs_project pp
* SET
* ch.footer = {$pageFooter}
* WHERE
* ch.project_page_id = pl.project_page_id
* AND pl.project_id = pp.project_id
* AND pp.rvs_usr_id = {$usrId}
* AND pp.project_id = {$projectId}
* AND ch.project_page_id = {$projectPageId}
*
* @author Pornthip Phothong
* @param $pageFooter,$projectId,$usrId,$projectPageId,$linkWithProjectLayoutPage
* @from ComponentFooterMgr.php
*/
public function updateFooterByProjectIdAndUsrIdAndProjectPageId($pageFooter, $projectId, $usrId, $projectPageId, $linkWithProjectLayoutPage=true )
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
$query = sprintf('
UPDATE
%s as ch
, %s as pp
%s
SET
ch.footer = %s
WHERE
ch.project_page_id = pl.project_page_id
AND pl.project_id = pp.project_id
AND pp.rvs_usr_id = %s
AND pp.project_id = %s
AND ch.project_page_id = %s
'
, $this->aConf['table']['rvs_component_header']
, $this->aConf['table']['rvs_project']
, ($linkWithProjectLayoutPage === true) ? sprintf(', %s as pl', $this->aConf['table']['rvs_project_layout_page']) : ''
, RvsLibs_String::quoteSmart($pageFooter)
, RvsLibs_String::quoteSmart($usrId)
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($projectPageId)
, ($linkWithProjectLayoutPage === true) ? 'AND ch.project_page_id = pl.project_page_id' : ''
, ($linkWithProjectLayoutPage === true) ? 'AND pl.project_id = pp.project_id' : ''
);
$oComponent->query($query);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
return $res;
}
/**
* Modify last update ConfigBlock By title in database
*
* Resulting SQL
* UPDATE
* block
* SET
* blk_order = {$blk_order}
* , position = {$position}
* , is_enabled = {$isEnabled}
* WHERE
* title = {$title}//Subscribe
*
* @access public
* @author Darawan Taorong crateDate: 22/04/2552 10:51AM
* @param array $aFieldSet
* @param string $title
*
* @return boolean
*/
public function updateConfigBlockByTitle($aFieldSet = null, $title = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oBlock = DB_DataObject::factory($this->aConf['table']['block']);
if (is_array($aFieldSet) && !is_null($title)) {
$oBlock->get('title', $title );
foreach ($aFieldSet as $fk => $fv) {
$oBlock->$fk = $fv;
}
$oBlock->update();
}
DB_DataObject::debugLevel();
return 0;
}
/**
* Update header By UsrId and ProjectId and ProjectPageId in rvs_component_header table
* Resulting SQL
* UPDATE
* rvs_component_header ch
* rvs_project_layout_page pl
* rvs_project pp
* SET
* ch.header = {$pageHeader}
* AND pl.project_id = pp.project_id
* AND pp.rvs_usr_id = {$usrId}
* AND pp.project_id = {$projectId}
* AND ch.project_page_id = {$projectPageId}
*
* @author Pornthip Phothong
* @param $pageHeader,$usrId,$projectId,$projectPageId,$linkWithProjectLayoutPage
* @from ComponentHeaderMgr.php
*/
public function updateHeaderByUsrIdAndProjectIdAndProjectPageId($pageHeader, $usrId, $projectId, $projectPageId, $linkWithProjectLayoutPage=true)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
$query = sprintf('
UPDATE
%s as ch
, %s
, %s as pp
SET
ch.header = %s
WHERE
ch.project_page_id = pl.project_page_id
AND pl.project_id = pp.project_id
AND pp.rvs_usr_id = %s
AND pp.project_id = %s
AND ch.project_page_id = %s
'
, $this->aConf['table']['rvs_component_header']
, ($linkWithProjectLayoutPage === true) ? sprintf('%s as pl', $this->aConf['table']['rvs_project_layout_page']) : ''
, $this->aConf['table']['rvs_project']
, RvsLibs_String::quoteSmart($pageHeader)
, RvsLibs_String::quoteSmart($usrId)
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($projectPageId)
, ($linkWithProjectLayoutPage === true) ? 'AND ch.project_page_id = pl.project_page_id' : ''
, ($linkWithProjectLayoutPage === true) ? 'AND pl.project_id = pp.project_id' : ''
);
$oComponent->query($query);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
return $res;
}
/**
* update edit confgi to db by user name
*
* @param <string> $tableName
* @param <string> $adminUserName
* @param <string> $adminPassword
* @param <string> $adminFirstName
* @param <string> $adminLastName
* @param <string> $adminEmail
* @param <string> $adminUserNameOld
* @return bool
* form file cComponentAndUserframeworkmgr.php
*/
public function updateeditConfigToDbByUserName($tableName, $adminUserName, $adminPassword, $adminFirstName, $adminLastName, $adminEmail, $adminUserNameOld)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($tableName);
$query = sprintf('
UPDATE
%s
SET
username = %s
, passwd = %s
, first_name = %s
, last_name = %s
, email = %s
WHERE
username = %s
'
, $tableName
, RvsLibs_String::quoteSmart($adminUserName)
, RvsLibs_String::quoteSmart($adminPassword)
, RvsLibs_String::quoteSmart($adminFirstName)
, RvsLibs_String::quoteSmart($adminLastName)
, RvsLibs_String::quoteSmart($adminEmail)
, RvsLibs_String::quoteSmart($adminUserNameOld)
);
$oComponent->query($query);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
return (isset($res) && $res)? true : false;
}
public function updateRvsComponentIdByProjectIdAndUsrIdAndPageId($pageId, $rvsUsrId, $projectId, $currentComponentId)
{
/* cannot test
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
$query = sprintf(' UPDATE
%s as uc
, %s as pp
, %s as pl
SET
uc.rvs_component_id = %s
WHERE
uc.rvs_project_page_id = pp.project_page_id
AND pp.project_page_id = pl.project_page_id
AND pl.project_id = %s
AND pp.rvs_usr_id = %s
AND uc.rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($currentComponentId)
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($rvsUsrId)
, RvsLibs_String::quoteSmart($pageId)
);
$oComponent->query($query);
$res = $oComponent->query($query);
DB_DataObject::debugLevel();
return (isset($res) && $res)? true : false; */
}
/***************************************************************
* ***** DELETE ***** *
****************************************************************/
/**
* Modify last delete UserComponentConfigByProjectPageId in database
* Resulting SQL
* DELETE
* rvs_user_component_config
* FROM
* rvs_user_component_config uc
* rvs_project_page pa
* rvs_project_layout_page pl
* rvs_project pp
* WHERE
* uc.rvs_project_page_id = pa.project_page_id
* AND pa.project_page_id = pl.project_page_id
* AND pp.project_id = pl.project_id
* AND pp.project_id = {$projectId}
* AND pa.rvs_usr_id = {$rvsUsrId}
* AND uc.rvs_project_page_id = {$projectPageId}
* AND uc.rvs_component_id = {$ComponentId}
* @access public
* @author Darawan Taorong crate date 21/04/2552
* @param string $projectId
* @param string $rvsUsrId
* @param string $projectPageId
* @param string $ComponentId
*
* @return boolean
*/
public function deleteUserComponentConfigByProjectPageId ($projectId = null, $rvsUsrId = null, $projectPageId = null, $ComponentId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($projectId) && !is_null($rvsUsrId) && !is_null($projectPageId) && !is_null($ComponentId)) {
/*
$query = sprintf('
DELETE
%s uc
FROM
%s uc
, %s pa
, %s pl
, %s pp
WHERE
uc.rvs_project_page_id = pa.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pp.project_id = pl.project_id
AND pp.project_id = %s
AND pa.rvs_usr_id = %s
AND uc.rvs_project_page_id = %s
AND uc.rvs_component_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, $this->aConf['table']['rvs_project']
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($rvsUsrId)
, RvsLibs_String::quoteSmart($projectPageId)
, RvsLibs_String::quoteSmart($ComponentId)
);
*/
$query = sprintf('
DELETE
FROM
%s
WHERE
rvs_project_page_id = %s
AND rvs_component_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, RvsLibs_String::quoteSmart($projectPageId)
, RvsLibs_String::quoteSmart($ComponentId)
);
$res = $oComponent->query($query);
}
return (isset($res) && $res) ? true : false;
}
/**
* Delete Component header By projectid and usrid
* $query = "
DELETE
{$this->conf['table']['rvs_component_header']} as ph
FROM
{$this->conf['table']['rvs_component_header']} as ph
, {$this->conf['table']['rvs_project_page']} as pa
, {$this->conf['table']['rvs_project_layout_page']} as pl
WHERE
pa.project_page_id = ph.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = '$input->rvs_usr_id'
AND pl.project_id = '$input->project_id'
";
* @author Pharadol
* @param <string> $usrId
* @param <string> $projectId
* @return <array>
*
*/
public function deleteComponentHeaderByprojcectIdAndUsrId($projectPageId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_component_header']);
if (!is_null($projectPageId)) {
/*
$query = sprintf('
DELETE
%s as ph
FROM
%s as ph
, %s as pa
, %s as pl
WHERE
pa.project_page_id = ph.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = %s
AND pl.project_id = %s
'
, $this->aConf['table']['rvs_component_header']
, $this->aConf['table']['rvs_component_header']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($usrId)
, RvsLibs_String::quoteSmart($projectId)
);
*/
$query = sprintf('
DELETE
FROM
%s
WHERE
project_page_id = %s
'
, $this->aConf['table']['rvs_component_header']
, RvsLibs_String::quoteSmart($projectPageId)
);
$res = $oComponent->query($query);
}
return (isset($res) && $res) ? true : false;
}
/**
* delete Component config by userid and projectid
* $cQuery = "
DELETE
{$this->conf['table']['rvs_user_component_config']} as uc
FROM
{$this->conf['table']['rvs_user_component_config']} as uc
, {$this->conf['table']['rvs_project_page']} as pa
, {$this->conf['table']['rvs_project_layout_page']} as pl
WHERE
uc.rvs_project_page_id = pa.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = '$input->rvs_usr_id'
AND pl.project_id = '$input->project_id'
";
* @author Pharadol
* @param <string> $usrId
* @param <string> $projectId
* @return Bool
*/
public function deleteComponentConfigByUsridAndProjectId($projectPageId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($projectPageId)) {
/*
$query = sprintf('
DELETE
%s as uc
FROM
%s as uc
, %s as pa
, %s as pl
WHERE
uc.rvs_project_page_id = pa.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = %s
AND pl.project_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($usrId)
, RvsLibs_String::quoteSmart($projectId)
);
*/
$query = sprintf('
DELETE
FROM
%s
WHERE
rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, RvsLibs_String::quoteSmart($projectPageId)
);
$res = $oComponent->query($query);
}
return (isset($res) && $res) ? true : false;
}
/**
* delete component config by usrid and projectpage id
* @author Pharadol
* @param <string> $projectPageId
* @param <string> $usrId
* @return bool
* form file pagestructerMgr.php
/*
$cQuery = "
DELETE
{$this->conf['table']['rvs_user_component_config']} as uc
FROM
{$this->conf['table']['rvs_user_component_config']} as uc
, {$this->conf['table']['rvs_project_page']} as pa
, {$this->conf['table']['rvs_project_layout_page']} as pl
WHERE
uc.rvs_project_page_id = pa.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = '$input->rvs_usr_id'
AND uc.rvs_project_page_id = '$projectPageId'
";
$cResult = $this->dbh->query($cQuery);
*/
public function deleteComponentConfigByUsridAndProjectPageId($projectPageId = null, $usrId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($projectPageId) && !is_null($usrId)) {
/*
$query = sprintf('
DELETE
%s as uc
FROM
%s as uc
, %s as pa
, %s as pl
WHERE
uc.rvs_project_page_id = pa.project_page_id
AND pa.project_page_id = pl.project_page_id
AND pa.rvs_usr_id = %s
AND uc.rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_project_page']
, $this->aConf['table']['rvs_project_layout_page']
, RvsLibs_String::quoteSmart($usrId)
, RvsLibs_String::quoteSmart($projectPageId)
);
*/
$query = sprintf('
DELETE
FROM
%s
WHERE
rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, RvsLibs_String::quoteSmart($projectPageId)
);
$res = $oComponent->query($query);
}
return (isset($res) && $res) ? true : false;
}
/**
* delete component config by projectpage id
* Resulting SQL
* DELETE
* rvs_user_component_config
* FROM
* rvs_user_component_config
* WHERE
* rvs_project_page_id = {$projectPageId}
*
* @author Darawan Taorong
* @param <string> $projectPageId
* @return bool
* form file ListPageStructure.php
*/
public function deleteComponentConfigByProjectPageId($projectPageId = null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oComponent = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
if (!is_null($projectPageId)) {
/*
$query = sprintf('
DELETE
%s
FROM
%s
WHERE
rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, $this->aConf['table']['rvs_user_component_config']
, RvsLibs_String::quoteSmart($projectPageId)
);
*/
$query = sprintf('
DELETE
FROM
%s
WHERE
rvs_project_page_id = %s
'
, $this->aConf['table']['rvs_user_component_config']
, RvsLibs_String::quoteSmart($projectPageId)
);
$res = $oComponent->query($query);
}
return (isset($res) && $res) ? true : false;
}
public function backupsql($projectId, $usrId, $projectPageId=null)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$aSQLData = array();
$aComponentId = array();
if (is_null($projectPageId)) {
/// 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);
} else {
/// Backup table rvs_component_header
$oComponentHeader = DaoFactory::Component()->findComponentHeaderFooterByProjectPageId($projectPageId, 'getDataObject');
foreach ($oComponentHeader as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
/// Backup table rvs_user_component_config by $projectPageId
$oUserComponentConfig = DaoFactory::Component()->findUserComponentConfigByProjectPageId($projectPageId, 'getDataObject');
foreach ($oUserComponentConfig as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
return $aSQLData;
}
/// Backup table rvs_component by component_id
foreach ($aProjectPageId as $projectPageId => $val) {
$componentId = DaoFactory::Component()->findComponentIdFromProjectPageByProjectPageId($projectPageId, 'getone');
if (!empty($componentId)) {
$aComponentId[] = $componentId;
$oComponent = DaoFactory::Component()->findAllDataByComponentId($componentId, 'getDataObject');
if (count($oComponent) > 0) {
foreach ($oComponent as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
}
}
/// Backup table rvs_component_header
foreach ($aProjectPageId as $projectPageId => $val) {
$oComponentHeader = DaoFactory::Component()->findComponentHeaderFooterByProjectPageId($projectPageId, 'getDataObject');
foreach ($oComponentHeader as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
/// Backup table rvs_user_component_config by $projectPageId
foreach ($aProjectPageId as $projectPageId => $val) {
$oUserComponentConfig = DaoFactory::Component()->findUserComponentConfigByProjectPageId($projectPageId, 'getDataObject');
foreach ($oUserComponentConfig as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
/// Backup table rvs_component_config by component_id
foreach ($aComponentId as $componentId) {
$oComponentConfig = DaoFactory::Component()->findComponentConfigByComponentId($componentId, 'getDataObject');
foreach ($oComponentConfig as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
}
return $aSQLData;
}
public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array())
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
if (count($aProjectPageId)) {
/// Backup table rvs_component by component_id
foreach ($aProjectPageId as $projectPageId => $val) {
$result = DaoFactory::Component()->deleteComponentHeaderByprojcectIdAndUsrId($projectPageId);
$cResult = DaoFactory::Component()->deleteComponentConfigByUsridAndProjectId($projectPageId);
}
}
}
}
?>