CHips L MINI SHELL

CHips L pro

Current Path : /opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/
Upload File :
Current File : //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/ProjectPageDao.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 project page of RVSiteBuilder
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  Parinya <parinya@rvglobalsoft.com>
 * @version $Revision$
 * @since   PHP 5.1
 */

class ProjectPageDao extends DbWrapper implements SitebuilderInf
{

	function ProjectPageDao()
	{
		parent::DbWrapper();
	}

	/**
	 * Returns a singleton ProjectPageDao 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;
    }

    function findProjectPageDataByComponentName($projectId, $componentName, $fetchMode='getassoc')
    {
    	DB_DataObject::debugLevel();
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
    	$query = sprintf('SELECT * FROM
    				%s As pl
    				, %s As pp
    				, %s As rc
    			WHERE
    				pl.project_id = %s
    				AND rc.component_name = %s
    				AND pl.project_page_id = pp.project_page_id
    				AND pp.rvs_component_id = rc.rvs_component_id
	    	'
	    	, $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($componentName)
    	);
    	$oProjectLayoutPage->query($query);
    	$aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find project page data by project id and usr id in main page or sub page
     * @author Parinya Chaipetch
     *
     * @param string $projectId
     * @param string $usrId
     * @param bool $isMainPage
     * @param string $fetchMode
     * @access public
     * @return array
     */
    public function findProjectPageDataByProjectIdAndUsrId($projectId=null, $usrId=null, $isMainPage=true, $fetchMode = 'getassoc')
    {
        DB_DataObject::debugLevel();
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
        if (!is_null($projectId) && !is_null($usrId)) {
             $query = sprintf('
                SELECT
                    DISTINCT lp.project_page_id
                    , lp.project_id
                    , pp.rvs_usr_id
                    , lp.parent_project_page_id
                    , lp.priority
                    , lp.is_home
                    , pp.set_draft
                    , pp.page_name
                    , pp.custom_page_name
                    , pp.page_title
                    , pp.meta_keyword
                    , pp.meta_description
                    , pp.rvs_component_id
                    , pp.rvs_link_id
                    , pp.target
                    , pp.effect_page_enter
                    , pp.duration_page_enter
                    , pp.meta_page_effect
                    , pp.last_modifier
                    , pp.link_active
                    , pp.page_type
                    , pp.is_member_page
                FROM
                    %s lp
                    , %s pp
                WHERE
                    lp.project_id = %s
                    AND pp.rvs_usr_id = %s
                    AND (
						lp.parent_project_page_id %s %s
							OR
						lp.parent_project_page_id %s %s
						)
                    AND lp.project_page_id = pp.project_page_id
                ORDER BY
                    priority
                '
                , $this->aConf['table']['rvs_project_layout_page']
                , $this->aConf['table']['rvs_project_page']
                , RvsLibs_String::quoteSmart($projectId)
                , RvsLibs_String::quoteSmart($usrId)
                , ($isMainPage == true) ? '=' : '!='
                , RvsLibs_String::quoteSmart('0')
             	, ($isMainPage == true) ? '=' : '!='
             	, RvsLibs_String::quoteSmart('undefined')
            );

            //exit;
            //SGL::logMessage($query, PEAR_LOG_DEBUG);
            $oProjectLayoutPage->query($query);

        }
        $aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find custom page data by project id and usr id in main page or sub page
     * @author Parinya Chaipetch
     *
     * @param string $projectId
     * @param string $usrId
     * @param string $fetchMode
     * @access public
     * @return array
     */

    public function findCustomPageNameByProject($projectId=null, $usrId=null, $fetchMode = 'getassoc')
    {
        DB_DataObject::debugLevel();
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
        if (!is_null($projectId) && !is_null($usrId)) {
        	$projectId = RvsLibs_String::quoteSmart($projectId);
            $query = sprintf('
                SELECT
                    DISTINCT lp.project_page_id
                    , pp.custom_page_name
                FROM
                    %s lp
                    , %s pp
                WHERE
                    lp.project_id = %s
                    AND pp.rvs_usr_id = %s
                    AND pp.custom_page_name <> ""
                    AND lp.project_page_id = pp.project_page_id
                ORDER BY
                    priority
                '
                , $this->aConf['table']['rvs_project_layout_page']
                , $this->aConf['table']['rvs_project_page']
                , $projectId
                , RvsLibs_String::quoteSmart($usrId)
            );
            $oProjectLayoutPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find project page data by project id and usr id in internal page
     * @author Parinya Chaipetch
     *
     * @param string $projectId
     * @param string $usrId
     * @param string $fetchMode
     * @access public
     * @return array
     */
    public function findCustomPageNameOfInternalPageByProject($projectId=null, $usrId=null, $fetchMode = 'getassoc')
    {
        DB_DataObject::debugLevel();
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        if (!is_null($projectId) && !is_null($usrId)) {
        	$projectId = RvsLibs_String::quoteSmart($projectId);
            $query = sprintf('
                SELECT
                    DISTINCT ip.project_page_id
                    , pp.custom_page_name
                FROM
                    %s ip
                    , %s pp
                WHERE
                    ip.project_id = %s
                    AND pp.rvs_usr_id = %s
                    AND pp.custom_page_name <> ""
                    AND ip.project_page_id = pp.project_page_id
                '
                , $this->aConf['table']['rvs_internal_page']
                , $this->aConf['table']['rvs_project_page']
                , $projectId
                , RvsLibs_String::quoteSmart($usrId)
            );
            $oProjectLayoutPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    public function findProjectPageDataByProjectIdAndUsrIdAndImgOnlineForm($formId, $projectId=null, $usrId=null, $fetchMode = 'getarray')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
        if (!is_null($projectId) && !is_null($usrId)) {
             $query = sprintf('

           				SELECT
            				DISTINCT
           						 pp.page_name
                        FROM
                                %s lp,
                                %s pp
                        WHERE
                               lp.project_id = %s
                               AND pp.rvs_usr_id = %s
                               AND lp.project_page_id = pp.project_page_id
                               AND (
                               			pp.page_data REGEXP %s
                       				OR
                       					pp.page_data_zone_2 REGEXP %s
                       				OR
                       					pp.page_data_zone_3 REGEXP %s
                       				OR
                       					pp.page_data_zone_4 REGEXP %s
                       			)


                     '
                     , $this->aConf['table']['rvs_project_layout_page']
                     , $this->aConf['table']['rvs_project_page']
                     , RvsLibs_String::quoteSmart($projectId)
                     , RvsLibs_String::quoteSmart($usrId)
                     ,RvsLibs_String::quoteSmart('<img[^>].*onlineform_' . $formId . '.*>')
                     ,RvsLibs_String::quoteSmart('<img[^>].*onlineform_' . $formId . '.*>')
                     ,RvsLibs_String::quoteSmart('<img[^>].*onlineform_' . $formId . '.*>')
                     ,RvsLibs_String::quoteSmart('<img[^>].*onlineform_' . $formId . '.*>')
                     );
                   $oProjectLayoutPage->query($query);
        }
          $aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find project page priority from table 'rvs_project_layout_page' where project_id and usr_id
     * @author Witoon
     *
     * @param string $projectId
     * @param string $usrId (is_null($usrId) === false) ? sprintf('AND pp.rvs_usr_id = %s', RvsLibs_String::quoteSmart($usrId)) : ''
     * @access public
     * @return array or object (depend on fetch mode)
     */
    public function findProjectPagePriorityByProjectId($projectId=null,$usrId=null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (!is_null($projectId)) {
        $query = sprintf("
                        SELECT
                                    pp.project_page_id
                                    , lp.priority
                        FROM
                                    %s as lp
                                    , %s as pp
                        WHERE
                                    lp.project_id = %s
                                    AND lp.priority != '0'
                                    AND (lp.parent_project_page_id = '0' OR lp.parent_project_page_id = 'undefined')
                                    AND lp.project_page_id = pp.project_page_id
                                    %s
                                    ORDER BY lp.priority ASC
                    "
                    , $this->aConf['table']['rvs_project_layout_page']
                    , $this->aConf['table']['rvs_project_page']
                    , RvsLibs_String::quoteSmart($projectId)
                    , (is_null($usrId) === false) ? sprintf('AND pp.rvs_usr_id = %s', RvsLibs_String::quoteSmart($usrId)) : ''
                    );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find page last_modifier from table 'rvs_project_page' where project_id and usr_id
     * @author Witoon
     *
     * @param string $projectId
     * @param string $usrId (is_null($usrId) === false) ? sprintf('AND pp.rvs_usr_id = %s', RvsLibs_String::quoteSmart($usrId)) : ''
     * @access public
     * @return array or object (depend on fetch mode)
     */
    public function findProjectPageIdLastModifyByProjectId($projectId=null,$usrId=null, $fetchMode='getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel();
    	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
    	if (!is_null($projectId)) {
    		$query = sprintf("
                        SELECT
                                    pp.project_page_id
                                    , pp.last_modifier
                        FROM
                                    %s as lp
                                    , %s as pp
                        WHERE
                                    lp.project_id = %s
                                    AND lp.project_page_id = pp.project_page_id
                                    %s
                                    ORDER BY pp.last_modifier DESC
                    "
    				, $this->aConf['table']['rvs_project_layout_page']
    				, $this->aConf['table']['rvs_project_page']
    				, RvsLibs_String::quoteSmart($projectId)
    				, (is_null($usrId) === false) ? sprintf('AND pp.rvs_usr_id = %s', RvsLibs_String::quoteSmart($usrId)) : ''
    				);
    		$oProjectPage->query($query);
    	}
    	$aCloneData = array();
    	while ($oProjectPage->fetch()) {
    		$aCloneData[] = clone($oProjectPage);
    	}
    	DB_DataObject::debugLevel();
    	return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find project page from table 'rvs_project_layout_page'
     * Resulting SQL
     * 	SELECT
     * 		*
     *  FROM
     * 		rvs_project_layout_page lp
     * 		, rvs_project_page pp
     *  WHERE
     * 		lp.project_id = {$projectId}
     * 		AND pp.rvs_usr_id = '$input->rvs_usr_id'
     * 		AND lp.parent_project_page_id = '$input->project_page_id'
     * 		AND lp.project_page_id = pp.project_page_id
     *  ORDER BY
     *      priority
     * $this->dbh->getAssoc($query);
     *
     * @author Darawan Taorong
     *
     * @param string $projectId
     * @param string $usrId
     * @param string $projectPageId
     * @access public
     * @return array or object (depend on fetch mode)
     */
    public function findProjectPageDataByProjectIdAndUsrIdAndProjectPageId( $projectId = null, $usrId = null, $projectPageId = null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if ( !is_null($projectId) && !is_null($usrId) && !is_null($projectPageId)) {
        $query = sprintf('
        	SELECT
        		*
         	FROM
      			%s as lp
      			, %s as pp
    		WHERE
          		lp.project_id = %s
      			AND pp.rvs_usr_id = %s
         		AND lp.parent_project_page_id = %s
         		AND lp.project_page_id = pp.project_page_id
          	ORDER BY
          		lp.priority
          	'
            , $this->aConf['table']['rvs_project_layout_page']
         	, $this->aConf['table']['rvs_project_page']
            , RvsLibs_String::quoteSmart($projectId)
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($projectPageId)
            );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * get page name check to internel page step 5
     * @othor pharadol
     * @param <string> $usrId
     * @param <string> $projectId
     * @param <string> $fetchMode
     * @return array
     */

    public function findProjectPageDataByProjectIdAndUsrIdAndProjectPageName($usrId = null,  $projectId = null, $pageName = null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if ( !is_null($projectId) && !is_null($usrId)) {
            $query = sprintf('
        	SELECT
        		*
         	FROM
      			%s as lp
      			, %s as pp
    		WHERE
          		lp.project_id = %s
      			AND pp.rvs_usr_id = %s
         		AND lp.project_page_id = pp.project_page_id
         		%s
          	ORDER BY
          		lp.priority
          	'
          	, $this->aConf['table']['rvs_project_layout_page']
          	, $this->aConf['table']['rvs_project_page']
          	, RvsLibs_String::quoteSmart($projectId)
          	, RvsLibs_String::quoteSmart($usrId)
            , (is_null($pageName) === false) ? 'AND pp.page_name=' . RvsLibs_String::quoteSmart($pageName) : ''
          	);
          	$oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    /**
     * Find project_page_id , page_name , meta_keyword, meta_description from table rvs_project_page where project_page_id
     *
     * Resulting SQL
     * 		SELECT
     * 			project_page_id
     * 			, page_name
     * 			, meta_keyword
     * 			, meta_description
     * 		FROM
     * 			rvs_project_page
     * 		WHERE
     * 			project_page_id = {$projectPageId}
     *
     * @author duangdao.k
     * @param string $projectPageId
     * @param string $fetchMode
     * @return array
     */
    public function findProjectPageDataByProjectPageId($projectPageId = null, $fetchMode = 'getassoc', $aResultFields=array('project_page_id', 'page_name', 'meta_keyword', 'meta_description'))
    {
        //SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (!is_null($projectPageId)) {
            $query =sprintf('
				SELECT
                     *
				FROM
                      %s
				WHERE
                      project_page_id = %s
                 '
                 , $this->aConf['table']['rvs_project_page']
                 , RvsLibs_String::quoteSmart($projectPageId)
              );
                $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        $_aResultFields = DbWrapper::buildResultFields($oProjectPage, $aResultFields);
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
     }

     /**
      * Find All Data from table rvs_project_page
      *  $query = sprintf('
               SELECT
                     *
                FROM
                  	%s
                '
                , $this->aConf['table']['rvs_project_page']
            );
      *
      * @author duangdao.k
      * @param string $fetchMode
      * @param string $aResultFields
      * @return arrayobj
      */
     public function findAllDataProjectPage($fetchMode = 'getassoc', $aResultFields=array())
     {
         SGL::logMessage(null, PEAR_LOG_DEBUG);
         DB_DataObject::debugLevel();
         $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
         $query = sprintf('
               SELECT
                     *
                FROM
                  	%s
                '
                , $this->aConf['table']['rvs_project_page']
            );
             $oProjectPage->query($query);
             $aCloneData = array();

        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        $_aResultFields = DbWrapper::buildResultFields($oProjectPage, $aResultFields);
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
     }

     /**
     * Find project page and project layout page from table 'rvs_project_page' and 'rvs_project_layout_page'
     * @author Witoon
     *
     * @param string $projectId
     * @param string $projectPageId
     * @param string $rvsUsrId
     * @param string $fetchMode
     * @access public
     * @return array or object (depend on fetch mode)
     */
     public function findProjectPageAndProjectLayoutPageByProjectIdProjectPageIdAndUsrId($projectId, $rvsUsrId, $fetchMode = 'getassoc', $projectPageId = null)
     {
         SGL::logMessage(null, PEAR_LOG_DEBUG);
         DB_DataObject::debugLevel();
         $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
         if (!is_null($projectId) && !is_null($rvsUsrId)) {
             $query = sprintf("
                            SELECT
                                        *
                            FROM
                                        %s lp
                                        , %s pp
                            WHERE
                                        %s
                                        AND lp.project_id = %s
                                        AND pp.rvs_usr_id = %s
                        "
                         , $this->aConf['table']['rvs_project_layout_page']
                         , $this->aConf['table']['rvs_project_page']
                         , (!is_null($projectPageId) && $projectPageId != '')
                                             ? ' lp.project_page_id = ' . RvsLibs_String::quoteSmart($projectPageId) . ' AND pp.project_page_id = lp.project_page_id'
                                             : ' pp.project_page_id = lp.project_page_id'
                         , RvsLibs_String::quoteSmart($projectId)
                         , RvsLibs_String::quoteSmart($rvsUsrId)
                         );

             $oProjectPage->query($query) ;
         }
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
             $aCloneData[] = clone($oProjectPage);
         }
         DB_DataObject::debugLevel();
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
     }

      /**
     * Find project page and project layout page from table 'rvs_project_page' and 'rvs_project_layout_page ORDER BY priority'
     * @author Witoon
     *
     * @param string $projectId
     * @param string $projectPageId
     * @param string $rvsUsrId
     * @param string $fetchMode
     * @access public
     * @return array or object (depend on fetch mode)
     */
     public function findProjectPageAndProjectLayoutPageByProjectIdProjectPageIdAndUsrIdOrderByPriority($projectId, $rvsUsrId, $fetchMode = 'getassoc', $projectPageId = null)
     {
         /*
         $query = "
                        SELECT
                                    *
                         FROM
                                     {$this->conf['table']['rvs_project_page']} pp
                                     , {$this->conf['table']['rvs_project_layout_page']} lp ";
        if ($projectPageId) {
            $query .= "
                        WHERE
                                    pp.project_page_id = '$projectPageId'
                                     AND lp.project_id = '$projectId' ";
        } else {
            $query .= "
                        WHERE
                                    lp.project_id = '$projectId' ";
        }
        $query .= "             AND pp.rvs_usr_id = '$rvsUsrId'
                                     AND pp.project_page_id = lp.project_page_id
                         ORDER BY
                                     lp.priority
                    ";
        $aPageData = $this->dbh->getAll($query);
        */
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
        if (!is_null($projectId) && !is_null($rvsUsrId)) {
             $query = sprintf("
                            SELECT
                                        (pp.project_page_id), pp.*, lp.project_id, lp.parent_project_page_id
                            FROM
                                        %s lp
                                        , %s pp
                            WHERE
                            			pp.project_page_id = lp.project_page_id
                                        AND lp.project_id = %s
                                        AND pp.rvs_usr_id = %s
                                        %s
                            GROUP BY
                                        pp.project_page_id
                            ORDER BY
                            			lp.priority
                        "
                         , $this->aConf['table']['rvs_project_layout_page']
                         , $this->aConf['table']['rvs_project_page']
                         , RvsLibs_String::quoteSmart($projectId)
                         , RvsLibs_String::quoteSmart($rvsUsrId)
                         , (!is_null($projectPageId) && $projectPageId != '')
                            ? ' AND lp.project_page_id = ' . RvsLibs_String::quoteSmart($projectPageId)
                            : ''
                         );
             $oProjectPage->query($query);
         }
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
             $aCloneData[] = clone($oProjectPage);
         }
         DB_DataObject::debugLevel();
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
     }

      /**
     * find ProjectPageId By UsrId from rvs_project_page table
     *  SELECT
     *        project_page_id
     *  FROM
     *       {$this->conf['table']['rvs_project_page']} pp
     *    WHERE
     *        rvs_usr_id = '$rvs_usr_id'
     *        AND rvs_component_id = ''
     *
     * @author Pornthip Phothong
     * @param string $usrId
     * @param string $fetchMode
     * @return array object
      */

     public function findProjectPageIdByUsrId($usrId=null,  $fetchMode = 'getassoc')
     {
         SGL::logMessage(null, PEAR_LOG_DEBUG);
         DB_DataObject::debugLevel();
         $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
         if (!is_null($usrId)) {
             $query = sprintf('
                        SELECT
                                    project_page_id
                        FROM
                                    %s as pp
                        WHERE
                                    rvs_usr_id = %s
                                    AND (rvs_component_id = "" OR rvs_component_id = 0)
                    '
                    , $this->aConf['table']['rvs_project_page']
                    , RvsLibs_String::quoteSmart($usrId)
                    );
                    $oProjectPage->query($query) ;
         }
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
             $aCloneData[] = clone($oProjectPage);
         }
         DB_DataObject::debugLevel();
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
     }
      /**
     * find ProjectPageId By UsrId And ProjectPageId from rvs_project_page and rvs_project_layout_page
     *
     *  SELECT DISTINCT
     *            pp.project_page_id
     *  FROM
     *            {$this->conf['table']['rvs_project_page']} pp
     *            , {$this->conf['table']['rvs_project_layout_page']} lp
     *  WHERE
     *            pp.rvs_usr_id = '$rvsUsrId'
     *            AND pp.project_page_id = lp.project_page_id
     *
     * @author Pornthip Phothong
     * @param string $usrId
     * @param string $fetchMode
     * @return array object
      */
     public function findProjectPageIdByUsrIdAndProjectPageId($usrId=null, $fetchMode = 'getassoc')
     {
         SGL::logMessage(null, PEAR_LOG_DEBUG);
         DB_DataObject::debugLevel();
         $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
         if (!is_null($usrId)) {
              $query = sprintf('
                        SELECT DISTINCT
                                    pp.project_page_id
                         FROM
                                     %s as pp
                                     , %s as lp
                        WHERE
                                pp.rvs_usr_id = %s
                                AND pp.project_page_id = lp.project_page_id

                    '
                    , $this->aConf['table']['rvs_project_page']
                    , $this->aConf['table']['rvs_project_layout_page']
                    , RvsLibs_String::quoteSmart($usrId)
                    );
               $oProjectPage->query($query) ;
         }
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
             $aCloneData[] = clone($oProjectPage);
         }
         DB_DataObject::debugLevel();
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
     }


     public function findProjectPageIdByUsrIdAndProjectId($usrId=null, $projectId=null, $fetchMode = 'getassoc')
     {
     	SGL::logMessage(null, PEAR_LOG_DEBUG);
     	DB_DataObject::debugLevel();
     	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
     	if (!is_null($usrId)) {
     		$query = sprintf('
                        SELECT
                                    pp.project_page_id
     				                ,pp.rvs_layout_id
                         FROM
                                     %s as pp
                                     , %s as lp
                        WHERE
                                pp.rvs_usr_id = %s
     				            AND lp.project_id = %s
                                AND pp.project_page_id = lp.project_page_id
     				            AND pp.rvs_layout_id BETWEEN 10 AND 16
                    '
     				, $this->aConf['table']['rvs_project_page']
     				, $this->aConf['table']['rvs_project_layout_page']
     				, RvsLibs_String::quoteSmart($usrId)
     				, RvsLibs_String::quoteSmart($projectId)
     		);
     		$oProjectPage->query($query) ;
     	}
     	$aCloneData = array();
     	while ($oProjectPage->fetch()) {
     		$aCloneData[] = clone($oProjectPage);
     	}
     	DB_DataObject::debugLevel();
     	return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
     }


     /**
      * find Page Data by Page Name
      * @author Pharadol
      * @param <string> $dname
      * @param <string> $fetchMode
      * @return <array>
      * form file PageStructureMgr.php
        /*
        $query = "
                        SELECT
                                    data
                                    , head
                          FROM
                                      {$this->conf['table']['rvs_admin_page']}
                          WHERE
                                      admin_page_name = " . RvsLibs_String::quoteSmart($input->dname) . "
                      ";
        $res[] = $this->dbh->getRow($query,DB_FETCHMODE_ASSOC);
        */
   public function findPageDataByPageName($dname = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_admin_page']);
      if (!is_null($dname)) {
           $query = sprintf('
                        SELECT
                                    data
                                    , head
                          FROM
                                      %s
                          WHERE
                                      admin_page_name = %s
                             '
                             , $this->aConf['table']['rvs_admin_page']
                             , RvsLibs_String::quoteSmart($dname)
                             );
           $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find Check New Page By ProjectPageId
    * @author Pharadol
    * @param <string> $dname
    * @param <string> $fetchMode
    * @return <array>
    * form file PageStructureMgr.php
        /*
        $query = "
                        SELECT
                                    project_page_id
                        FROM
                                    {$this->conf['table']['rvs_project_page']}
                        WHERE
                                    project_page_id LIKE " . RvsLibs_String::quoteSmart($dname) . "
                    ";
        $res = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
        */
   public function findCheckNewPageByProjectPageId($dname = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      //SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_admin_page']);
      if (!is_null($dname)) {
           $query = sprintf('
                        SELECT
                                    project_page_id
                        FROM
                                    %s
                        WHERE
                                    project_page_id LIKE %s
                               '
                               , $this->aConf['table']['rvs_project_page']
                               ,  RvsLibs_String::quoteSmart($dname)
                               );
       $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find page structrue by admin layout id
    * @author Pharadol
    * @param <string> $adminLayoutId
    * @param <string> $fetchMode
    * @return <arrray>
    * PageStructureMgr.php
            /*
            $query = "
                            SELECT
                                        ap.admin_page_name
                                        , ap.component_name
                                        , alp.parent_admin_page_id
                                         , ap. admin_page_id
                                         , alp.priority

                            FROM
                                        {$this->aConf['table']['rvs_admin_page']} ap
                                        , {$this->aConf['table']['rvs_admin_layout_page']} alp
                            WHERE
                                        alp.admin_layout_id = '" . $res[$i]['admin_layout_id'] . "'
                                        AND ap.admin_page_id = alp.admin_page_id
                            ORDER BY
                                        alp.priority
                        ";
            $ans = $this->dbh->getAll($query,DB_FETCHMODE_ASSOC);
            */
   public function findPageStructureByAdminLayoutId($adminLayoutId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_admin_page']);
      if (!is_null($adminLayoutId)) {
           $query = sprintf('
                            SELECT
                                        ap.admin_page_name
                                        , ap.component_name
                                        , alp.parent_admin_page_id
                                         , ap. admin_page_id
                                         , alp.priority

                            FROM
                                       %s  ap
                                        , %s  alp
                            WHERE
                                        alp.admin_layout_id = %s
                                        AND ap.admin_page_id = alp.admin_page_id
                            ORDER BY
                                        alp.priority
                             '
                             ,  $this->aConf['table']['rvs_admin_page']
                             , $this->aConf['table']['rvs_admin_layout_page']
                             , RvsLibs_String::quoteSmart($adminLayoutId)
                             );
           $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

/**
 * find page data by porjectpageid and projectid and userid
 * @author Pharadol
 * @param <string> $rvsUsrId
 * @param <string> $projectId
 * @param <string> $projectPageId
 * @param <string> $fetchMode
 * @return array
 * form file Common.php
 */
   public function findPageDataByProjectPageIdAndProjectIdAndusrId($rvsUsrId = null, $projectId = null, $projectPageId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
      if (!is_null($rvsUsrId) && !is_null($projectId)) {
           $query = sprintf('
                        SELECT
                        		*
                        FROM
                        		%s pp
                        		, %s lp
                         WHERE
                         		pp.project_page_id = lp.project_page_id
                         		AND pp.rvs_usr_id = %s
                         		AND lp.project_id = %s
                         		%s
                         ORDER BY
                         		lp.priority
                              '
                              , $this->aConf['table']['rvs_project_page']
                              , $this->aConf['table']['rvs_project_layout_page']
                              , RvsLibs_String::quoteSmart($rvsUsrId)
                              , RvsLibs_String::quoteSmart($projectId)
                              , !is_null($projectPageId) || $projectPageId != '' ?
                                  sprintf(' AND pp.project_page_id = %s', RvsLibs_String::quoteSmart($projectPageId)) : ''
                              );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find internal page data by projectid and projectpageid
    * @author Pharadol
    * @param <string> $rvsUsrId
    * @param <string> $projectId
    * @param <string> $projectPageId
    * @param <string> $fetchMode
    * @return array
    *  form file Common.php
    */
   public function findInternalPageDataByProjectIdAndProjectPageId($rvsUsrId = null, $projectId = null, $projectPageId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
      if (!is_null($rvsUsrId) && !is_null($projectId)) {
           $query = sprintf('
                        SELECT
                        		*
                        FROM
                        		%s  pp
                                , %s ip
                        WHERE
                         		pp.project_page_id = ip.project_page_id
                         		AND ip.project_id = %s
                         		AND pp.rvs_usr_id = %s
                         		%s
                        ORDER BY
                                pp.page_name
                               '
                               , $this->aConf['table']['rvs_project_page']
                               , $this->aConf['table']['rvs_internal_page']
                               , RvsLibs_String::quoteSmart($projectId)
                               , RvsLibs_String::quoteSmart($rvsUsrId)
                               , !is_null($projectPageId) && $projectPageId != ''
                                       ? sprintf(' AND pp.project_page_id = %s', RvsLibs_String::quoteSmart($projectPageId))
                                       : ''
                               );
           $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find pagelink option data by projectpageid and linkid
    * @othor pharadol
    * @param <string> $pageId
    * @param <string> $rvsLinkId
    * @return array
    */
   public function findPageLinkOptionDataByProjectPageIdAndLinkId($pageId = null, $rvsLinkId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
      if (!is_null($pageId) && !is_null($rvsLinkId)) {
           $query =sprintf('
                        SELECT
                                    *
                        FROM
                                    %s pp
                                    , %s  ln
                        WHERE
                                    pp.rvs_link_id = ln.rvs_link_id
                                    AND ln.rvs_link_id = %s
                                    AND pp.project_page_id = %s
                             '
                             , $this->aConf['table']['rvs_project_page']
                             , $this->aConf['table']['rvs_link']
                             , RvsLibs_String::quoteSmart($rvsLinkId)
                             , RvsLibs_String::quoteSmart($pageId)
                             );
          $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

    /**
    * find check data in table rvs_project_page_metatag by project_page_id, custom_metatag_id
    * Resulting
    * 	SELECT
    * 		 rvs_custom_metatag_id
    * 	FROM
    * 		rvs_project_page_metatag
    * 	WHERE
    * 		rvs_project_page_id = {$projectPageId}
    * 		AND rvs_custom_metatag_id = {$customMetaId}
    *
    * @author Darawan Taorong
    * @param <sting> $projectPageId
    * @param <string> $metatagId
    * @param <sting> $fetchMode
    * @return array
    * form file Extras_MetatagMgr.php
    */
   public function  findChkCustomMetatagIdByProjectPageIdAndCustomMetatagId($projectPageId = null, $metatagId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
      if (!is_null($projectPageId) && !is_null($metatagId)) {
           $query = sprintf('
                       SELECT
                           rvs_custom_metatag_id
                       FROM
                           %s
                       WHERE
                           rvs_project_page_id = %s
                           AND rvs_custom_metatag_id = %s
                        '
                        , $this->aConf['table']['rvs_project_page_metatag']
                        , RvsLibs_String::quoteSmart($projectPageId)
                        , RvsLibs_String::quoteSmart($metatagId)
                        );
           $oProjectPage->query($query);
      }
      $aCloneData = array();
      while ($oProjectPage->fetch()) {
      	$aCloneData[] = clone($oProjectPage);
      }
      DB_DataObject::debugLevel();
      return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find check data in table rvs_custom_metatag by project_info_id, user_id, metatag_type, metatag_name
    * Resulting
    * 	SELECT
    * 		 cm.rvs_custom_metatag_id
    * 	FROM
    * 		rvs_custom_metatag as cm
    * 		, rvs_project_info_metatag as pim
    * 		, rvs_project as p
    * 	WHERE
    * 		cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id
    * 		AND p.project_info_id = pim.rvs_project_info_id
    * 		AND pim.rvs_project_info_id = {$projectInfoId}
    * 	 	AND p.rvs_usr_id = {$usrId}
    * 		AND cm.metatag_type = {$metatagType}
    * 		AND cm.metatag_name= {$metatagName}
    *
    * @author Darawan Taorong
    * @param <sting> $projectInfoId
    * @param <string> $usrId
    * @param <string> $metatagType
    * @param <string> $metatagName
    * @param <sting> $fetchMode
    * @return array
    * form file Extras_MetatagMgr.php
    */
   public function  findChkCustomMetatagByProjectInfoIdAndUsrIdAndMetatagTypeAndMetatagName($projectInfoId = null, $usrId = null, $metatagType = null, $metatagName = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
      if (!is_null($projectInfoId) && !is_null($usrId) && !is_null($metatagType) && !is_null($metatagName)) {
      		$query = sprintf('
                       SELECT
                           cm.rvs_custom_metatag_id
                       FROM
                           %s as cm
                           , %s as pim
                           , %s as p
                       WHERE
                           cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id
                           AND p.project_info_id = pim.rvs_project_info_id
                           AND pim.rvs_project_info_id = %s
                           AND p.rvs_usr_id = %s
                           AND cm.metatag_type = %s
                           AND cm.metatag_Name = %s
                        '
                        , $this->aConf['table']['rvs_custom_metatag']
                        , $this->aConf['table']['rvs_project_info_metatag']
                        , $this->aConf['table']['rvs_project']
                        , RvsLibs_String::quoteSmart($projectInfoId)
                        , RvsLibs_String::quoteSmart($usrId)
                        , RvsLibs_String::quoteSmart($metatagType)
                        , RvsLibs_String::quoteSmart($metatagName)
                        );
      		$oProjectPage->query($query);
      }
      	$aCloneData = array();
     	while ($oProjectPage->fetch()) {
 			$aCloneData[] = clone($oProjectPage);
		}
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find Custom Metatag by project page id and usrid
    * Resulting
    * 	SELECT
    * 		cm.*, pp.project_page_id
    * 	FROM
    * 		rvs_project_page as pp
    * 		, rvs_project_layout_page as pl
    * 		, rvs_project_page_metatag as ppm
    *       , rvs_custom_metatag as cm
    * 	WHERE
    * 		pp.project_page_id = pl.project_page_id
    * 		AND pl.project_page_id = ppm.rvs_project_page_id
    * 		AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
    * 		AND pp.rvs_usr_id = {$usrId}
    *  		AND pp.project_page_id = {$projectPageId}
	*
    * @author pharadol
    * @param <string> $projectPageId
    * @param <string> $usrId
    * @param <string> $fetchMode
    * @return array
    * form file Extras_MetatagMgr.php
    */
   public function findCustomMetatagByProjectPageIdAndUsrId($projectPageId, $usrId, $fetchMode = 'gatassoc')
   {
      DB_DataObject::debugLevel(0);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
      if (!is_null($projectPageId) && !is_null($usrId)) {
           $query = sprintf('
                           SELECT
                               pp.project_page_id
                               , cm.metatag_name
                               , cm.metatag_type
                               , cm.metatag_content
                               , cm.rvs_custom_metatag_id
                               , cm.rvs_custom_metatag_oldid
                           FROM
                               %s as pp
                               , %s as ppm
                               , %s as cm
                           WHERE
                               pp.project_page_id =  ppm.rvs_project_page_id
                               AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
                               AND pp.project_page_id = %s
                               AND pp.rvs_usr_id = %s
                            '
                            , $this->aConf['table']['rvs_project_page']
                            , $this->aConf['table']['rvs_project_page_metatag']
                            , $this->aConf['table']['rvs_custom_metatag']
                            , RvsLibs_String::quoteSmart($projectPageId)
                            , RvsLibs_String::quoteSmart($usrId)
                            );

             $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel(0);
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }
   /**
    * find Custom Metatag by project page id and usrid
    * Resulting
    * 	SELECT
    * 		cm.*, pp.project_page_id
    * 	FROM
    * 		rvs_project_page as pp
    * 		, rvs_project_page_metatag as ppm
    *       , rvs_custom_metatag as cm
    * 	WHERE
    * 		pp.project_page_id = ppm.rvs_project_page_id
    * 		AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
    * 		AND pp.rvs_usr_id = {$usrId}
    *  		AND pp.project_page_id = {$projectPageId}
	*
    * @author Darawan Taorong
    * @param <string> $projectPageId
    * @param <string> $usrId
    * @param <string> $fetchMode
    * @return array
    * form file Extras_MetatagMgr.php
    */
   public function findCustomMetatagListByProjectPageIdAndUsrId($projectPageId, $usrId, $fetchMode = 'gatassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
      if (!is_null($projectPageId) && !is_null($usrId)) {
           $query = sprintf('
                           SELECT
                               cm.metatag_name
                               , cm.metatag_type
                               , cm.metatag_content
                               , cm.rvs_custom_metatag_id
                           FROM
                               %s as pp
                               , %s as ppm
                               , %s as cm
                           WHERE
                               pp.project_page_id = ppm.rvs_project_page_id
                               AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
                               AND pp.project_page_id = %s
                               AND pp.rvs_usr_id = %s
                            '
                            , $this->aConf['table']['rvs_project_page']
                            , $this->aConf['table']['rvs_project_page_metatag']
                            , $this->aConf['table']['rvs_custom_metatag']
                            , RvsLibs_String::quoteSmart($projectPageId)
                            , RvsLibs_String::quoteSmart($usrId)
                            );

             $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find custom metatag by projectinfo and usrid
    * Resulting
    * 	SELECT
    * 		cm.metatag_name
    *        , cm.metatag_type
    *        , cm.metatag_content
    * 	FROM
    * 		rvs_custom_metatag as cm
    * 		, rvs_project_info_metatag as pim
    * 		, rvs_project as p
    * 	WHERE
    * 		cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id
    * 		AND p.project_info_id = pim.rvs_project_info_id
    * 		AND pim.rvs_project_info_id = {$projectInfoId}
    * 	 	AND p.rvs_usr_id = {$usrId}
    *
    * @author pharadol
    * @param <sting> $projectInfoId
    * @param <string> $usrId
    * @param <sting> $fetchMode
    * @return array
    * form file Extras_MetatagMgr.php
    */
   public function  findCustomMetatagByProjectInfoIdAndUsrId($projectInfoId = null, $usrId = null, $fetchMode = 'getassoc')
   {
   DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
      if (!is_null($projectInfoId) && !is_null($usrId)) {
          $query = sprintf('
                       SELECT
                           cm.metatag_name
                           , cm.metatag_type
                           , cm.metatag_content
                           , cm.rvs_custom_metatag_id
                           , cm.rvs_custom_metatag_oldid
                       FROM
                           %s as cm
                           , %s as pim
                           , %s as p
                       WHERE
                           cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id
                           AND p.project_info_id = pim.rvs_project_info_id
                           AND pim.rvs_project_info_id = %s
                           AND p.rvs_usr_id = %s
                        '
                        , $this->aConf['table']['rvs_custom_metatag']
                        , $this->aConf['table']['rvs_project_info_metatag']
                        , $this->aConf['table']['rvs_project']
                        , RvsLibs_String::quoteSmart($projectInfoId)
                        , RvsLibs_String::quoteSmart($usrId)
                        );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   /**
    * find link_update By ProjectPageId
    *
    * @param int $pageAct
    * @param string $projectPageId
    * @param string $fetchMode
    * @author duangdao.k
    * @return array
    */
   public  function findLinkActiveByProjectPageId($pageAct, $projectPageId, $fetchMode = 'getassoc')
   {
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
      if (!is_null($projectPageId)) {
           $query = sprintf('
                       SELECT
                                link_active
                       FROM
                             %s
                       WHERE
                           link_active = %s
                           AND project_page_id = %s
                        '
                        , $this->aConf['table']['rvs_project_page']
                        , RvsLibs_String::quoteSmart($pageAct)
                        , RvsLibs_String::quoteSmart($projectPageId)
                        );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }
   //old function is findCustomMetatagByProjectInfoIdAndUsrId chang by Witoon
    public function  findAllCustomMetatagInfoByProjectInfoIdAndUsrId($projectInfoId = null, $usrId = null, $fetchMode = 'getassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
      if (!is_null($projectInfoId) && !is_null($usrId)) {
           $query = sprintf('
                       SELECT
                           cm.*
                       FROM
                           %s as cm
                           , %s as pim
                           , %s as p
                       WHERE
                           cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id
                           AND p.project_info_id = pim.rvs_project_info_id
                           AND pim.rvs_project_info_id = %s
                           AND p.rvs_usr_id = %s
                        '
                        , $this->aConf['table']['rvs_custom_metatag']
                        , $this->aConf['table']['rvs_project_info_metatag']
                        , $this->aConf['table']['rvs_project']
                        , RvsLibs_String::quoteSmart($projectInfoId)
                        , RvsLibs_String::quoteSmart($usrId)
                        );
            $oProjectPage->query($query);
      }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }
   //old function is findCustomMetatagByProjectPageIdAndUsrId chang by Witoon
    public function findAllCustomMetatagByProjectPageIdAndUsrId($projectPageId = null, $usrId = null, $fetchMode = 'gatassoc')
   {
      DB_DataObject::debugLevel();
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
      if (!is_null($projectPageId) && !is_null($usrId)) {
           $query = sprintf('
                       SELECT
                           cm.*
                           , pp.project_page_id
                       FROM
                           %s as pp
                           , %s as pl
                           , %s as ppm
                           , %s as cm
                       WHERE
                           pp.project_page_id = pl.project_page_id
                           AND pl.project_page_id = ppm.rvs_project_page_id
                           AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
                           AND pp.project_page_id = %s
                           AND pp.rvs_usr_id = %s
                        '
                        , $this->aConf['table']['rvs_project_page']
                        , $this->aConf['table']['rvs_project_layout_page']
                        , $this->aConf['table']['rvs_project_page_metatag']
                        , $this->aConf['table']['rvs_custom_metatag']
                        , RvsLibs_String::quoteSmart($projectPageId)
                        , RvsLibs_String::quoteSmart($usrId)
                        );

            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
   }

   ///End chang by Witoon
    public function findProjectPageIdFromProjectLayoutPageByProjectId($projectId = null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
        $oProjectLayoutPage->selectAdd();
        $oProjectLayoutPage->selectAdd('project_page_id');
        if (!is_null($projectId)) {
        $oProjectLayoutPage->project_id = $projectId;
        }
        $oProjectLayoutPage->find();
        $aCloneData = array();
        while ($oProjectLayoutPage->fetch()) {
            $aCloneData[] = clone($oProjectLayoutPage);
        }
        return DbWrapper::fetchDatas($oProjectLayoutPage->_resultFields, $aCloneData, $fetchMode);
    }

    public function findProjectPageMetatagByProjectPageId($projectPageId = null, $fetchMode = 'getassoc', $aResultFields = array())
    {
        $oProjectPageMetatag = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
        if (!is_null($projectPageId)) {
             $oProjectPageMetatag->rvs_project_page_id = $projectPageId;
        }
             $oProjectPageMetatag->find();
             $aCloneData = array();
        while ($oProjectPageMetatag->fetch()) {
            $aCloneData[] = clone($oProjectPageMetatag);
        }
        $_resultFields = DbWrapper::buildResultFields($oProjectPageMetatag, $aResultFields);
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($_resultFields, $aCloneData, $fetchMode);
    }

    public function findPageByPageName($projectId, $pageName, $fetchMode = 'getassoc')
    {
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                       SELECT
                           *
                       FROM
                           %s as pp
                           , %s as pl
                       WHERE
                           pp.project_page_id = pl.project_page_id
                           AND pl.project_id = %s
                           AND pp.page_name = %s
                        '
                        , $this->aConf['table']['rvs_project_page']
                        , $this->aConf['table']['rvs_project_layout_page']
                        , RvsLibs_String::quoteSmart($projectId)
                        , RvsLibs_String::quoteSmart($pageName)
        );

        $oProjectPage->query($query);
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    public function findComponentAndUserFrameworkPageByProjectId($projectId, $fetchMode = 'getassoc')
    {
    	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
    	$query = sprintf('
                       SELECT
    						pp.project_page_id
                       FROM
                           %s as pp
                           , %s as pl
                       WHERE
                           pp.project_page_id = pl.project_page_id
                           AND pl.project_id = %s
                           AND pp.page_name = %s
                        '
    			, $this->aConf['table']['rvs_project_page']
    			, $this->aConf['table']['rvs_project_layout_page']
    			, RvsLibs_String::quoteSmart($projectId)
    			, RvsLibs_String::quoteSmart('ComponentAndUserFramework')
    	);

    	$oProjectPage->query($query);
    	$aCloneData = array();
    	while ($oProjectPage->fetch()) {
    		$aCloneData[] = clone($oProjectPage);
    	}
    	DB_DataObject::debugLevel();
    	return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    //fix get is home page v5 pharadol
    public function findHomePageByProjectId($projectId, $fetchMode = 'getone')
    {
      SGL::logMessage(null, PEAR_LOG_DEBUG);
      $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
      if (!is_null($projectId)) {
           $query = sprintf('
                       SELECT
                                project_page_id
                       FROM
                             %s
                       WHERE
                           project_id = %s
                           AND is_home = %s
                        '
                        , $this->aConf['table']['rvs_project_layout_page']
                        , RvsLibs_String::quoteSmart($projectId)
                        , RvsLibs_String::quoteSmart(1)
                        );
            $oProjectPage->query($query);
        }
        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        DB_DataObject::debugLevel();
        return  DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

	public function findMainPageOptionByProject($projectId = null, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);

            $query = sprintf('
    			SELECT
    				pp.project_page_id
    				, pp.target
    				, pp.link_active
    				, pp.page_type
    				, pp.blank_page
    			FROM
                         %s pp
                         , %s pl
                WHERE
                    pp.project_page_id = pl.project_page_id
                    AND pl.project_id = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_project_layout_page']
                , RvsLibs_String::quoteSmart($projectId)
            );
            $oProjectPage->query($query);


        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

    public function findInternalPageOptionByProject($projectId = null, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);

            $query = sprintf('
    			SELECT
    				pp.project_page_id
    				, pp.target
    				, pp.link_active
    				, pp.page_type
    				, pp.blank_page
    			FROM
                         %s pp
                         , %s ip
                WHERE
                    pp.project_page_id = ip.project_page_id
                    AND ip.project_id = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_internal_page']
                , RvsLibs_String::quoteSmart($projectId)
            );
            $oProjectPage->query($query);


        $aCloneData = array();
        while ($oProjectPage->fetch()) {
            $aCloneData[] = clone($oProjectPage);
        }
        return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

/**
 * findProjectPageIsmemberByProjectPageId
 * @param unknown_type $projectPageId
 * @param unknown_type $ismember
 * @param unknown_type $fetchMode
 * @author duangdao
 * @return unknown_type
 */
    public function findProjectPageIsmemberByProjectPageId($projectPageId = null, $ismember = 0, $fetchMode = 'getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);

    	$query = sprintf('
                SELECT
                    project_page_id
                    , is_member_page
                FROM
                         %s
                WHERE
                    project_page_id = %s
                    AND is_member_page = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , RvsLibs_String::quoteSmart($projectPageId)
                , $ismember
                );
         $oProjectPage->query($query);
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
               $aCloneData[] = clone($oProjectPage);
          }
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

/**
 * find ismember by internalpage
 * @param $projectId
 * @param $ismember
 * @param $fetchMode
 * @author duangdao.k
 * @return unknown_type
 */
    public function findInternalPageIsmemberByProject($projectId = null, $ismember = 0, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);

        $query = sprintf('
                SELECT
                    pp.project_page_id
                    , pp.is_member_page
                FROM
                         %s pp
                         , %s ip
                WHERE
                    pp.project_page_id = ip.project_page_id
                    AND ip.project_id = %s
                    AND pp.is_member_page = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_internal_page']
                , RvsLibs_String::quoteSmart($projectId)
                , $ismember
                );
         $oProjectPage->query($query);
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
               $aCloneData[] = clone($oProjectPage);
          }
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

  public function findProjectPageIdInternalPageDataByProjectId($projectId = null, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);

        $query = sprintf('
                SELECT
                    pp.project_page_id
                FROM
                         %s pp
                         , %s ip
                WHERE
                    pp.project_page_id = ip.project_page_id
                    AND ip.project_id = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_internal_page']
                , RvsLibs_String::quoteSmart($projectId)
                );
         $oProjectPage->query($query);
         $aCloneData = array();
         while ($oProjectPage->fetch()) {
               $aCloneData[] = clone($oProjectPage);
          }
         return DbWrapper::fetchDatas($oProjectPage->_resultFields, $aCloneData, $fetchMode);
    }

/***************************************************************
*              *****  INSERT *****                             *
****************************************************************/
/**
 * insert ProjectPage By PageId And UserId And PageName
 * @author Tanawat
 * @param string $projectPageId
 * @param string $rvsUsrId
 * @param string $pageName
 * @return bool
        /*
        $query = "
                        INSERT INTO
                        {$this->conf['table']['rvs_project_page']} (
                                                    project_page_id
                                                    , rvs_usr_id
                                                    , page_name
                                                    , rvs_component_id
                                                    , page_data
                                                    , head
                                                  )
                        VALUES (
                                        '$projectPageId'
                                        , '$input->rvs_usr_id'
                                        , " . RvsLibs_String::quoteSmart($input->uname) . "
                                        , '$input->rvs_component_id'
                                        , '$input->pagedata'
                                        , '$input->head'
                                      )
                     ";
       $res = $this->dbh->query($query);
       */
  public function insertProjectPageByPageIdAndUserIdAndPageName($projectPageId = null, $rvsUsrId = null, $pageName = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oProjectPage =  DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (!is_null($projectPageId) && !is_null($rvsUsrId) && !is_null($pageName)) {
        	///Fix PHP5.3 (use MDB2)
        	if (!empty($projectPageId)) {
        		$oProjectPage->project_page_id = $projectPageId;
        	}
        	if (!empty($rvsUsrId)) {
        		$oProjectPage->rvs_usr_id = $rvsUsrId;
        	}
        	if (!empty($pageName)) {
        		$oProjectPage->page_name = $pageName;
        	}
        	///Fix PHP5.3 (use MDB2)
            $res = $oProjectPage->insert();
        } else {
            $res = false;
        }
        DB_DataObject::debugLevel();
        return (isset($res) && $res) ? true : false;
    }

    /**
     * Insert project page
     * @author Pharadol
     * @param <string> $head
     * @param <string> $pagedata
     * @param <string> $componentId
     * @param <string> $pageName
     * @param <string> $usrId
     * @param <string> $projectPageId
     */
    public function insertProjectPage($head, $pagedata, $componentId, $pageName, $usrId, $projectPageId, $pageType = null, $rvsLayoutID = '0', $cutomPageName=null, $linkId=null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        if (is_null($cutomPageName) === true) {
        	$cutomPageName = '';
        }
        $oProjectPage =  DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                        INSERT INTO
                                             %s
                                              (
                                                    project_page_id
                                                    , rvs_usr_id
                                                    , page_name
                                                    , custom_page_name
                                                    , rvs_component_id
                                                    , page_data
                                                    , head
                                                    , page_type
                                                    , rvs_layout_id
                                                  )
                        VALUES  (
                                        %s
                                        , %s
                                        , %s
                                        , %s
                                        , %s
                                        , %s
                                        , %s
                                        , %s
                                        , %s
                                      )
                               '
                               , $this->aConf['table']['rvs_project_page']
                               , RvsLibs_String::quoteSmart($projectPageId)
                               , RvsLibs_String::quoteSmart($usrId)
                               , RvsLibs_String::quoteSmart($pageName)
                               , RvsLibs_String::quoteSmart($cutomPageName)
                               , RvsLibs_String::quoteSmart($componentId)
                               , RvsLibs_String::quoteSmart($pagedata)
                               , RvsLibs_String::quoteSmart($head)
                               , RvsLibs_String::quoteSmart($pageType)
                               , ( isset($rvsLayoutID) && $rvsLayoutID != '' ) ? RvsLibs_String::quoteSmart($rvsLayoutID) : 0
                               );
        $res = $oProjectPage->query($query);
    }

    public function insertProjectPage2($aProjectPage=array())
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel(0);
    	$oProjectPage =  DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
    	if (count($aProjectPage) > 0) {
    		foreach ($aProjectPage as $key => $val) {
    			$key = trim($key);
    			if (!empty($val)) {
    				$oProjectPage->$key = $val;
    			}
    		}
    		$oProjectPage->insert();
    	}
    	return $oProjectPage;
    }

    /**
     * insert project out seggestion
     * @author Pharadol
     * @param <string> $projectPageId
     * @param <string> $suggestionID
           /*$query1 = "
                        INSERT INTO
                        {$this->conf['table']['rvs_project_page_out_seggestion']} (
                                                    project_page_id
                                                    ,out_suggestion_id
                                                  )
                        VALUES (
                                        '$projectPageId'
                                        , '$input->suggestionID'
                                      )
                     ";
       $res1 = $this->dbh->query($query1);
       */
    public function  insertProjectPageOutSeggestion($projectPageId, $suggestionID)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oProjectPage =  DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                        INSERT INTO
                                            %s  (
                                                    project_page_id
                                                    ,out_suggestion_id
                                                  )
                        VALUES (
                                        %s
                                        , %s
                                      )
                                '
                                , $this->aConf['table']['rvs_project_page_out_seggestion']
                                , RvsLibs_String::quoteSmart($projectPageId)
                                , RvsLibs_String::quoteSmart($suggestionID)
                                );
        $res = $oProjectPage->query($query);
    }

 	/**
	* insert Custom Metatag
	* Resulting
	* 	INSERT INTO
	* 		rvs_custom_metatag (
	* 		rvs_custom_metatag_id
	* 		, metatag_type
	* 		, metatag_name
	* 		, metatag_content
	* 		) VALUES (
	* 		{$metatagId}
	*  		, {$metatagType}
	* 		, {$metatagName}
	* 		, {$metatagContent}
	* 		)
	*
 	* @author Darawan Taorong
 	* @param string $metatagId
	* @param string $metatagType
 	* @param string $metatagName
 	* @param string $metatagContent
 	* @return bool
 	*/
  	public function insertCustomMetatag($metatagId = null, $metatagType = null, $metatagName = null, $metatagContent = null, $metatagOldId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oCustomMeta = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
        if (!is_null($metatagId) && !is_null($metatagType) && !is_null($metatagName)) {
		$query = sprintf('
			INSERT INTO
				%s  (
				rvs_custom_metatag_id,
				metatag_type,
				metatag_name,
				metatag_content,
				rvs_custom_metatag_oldid
	            )VALUES (
				%s
				, %s
				, %s
				%s
				%s
				 )
			'
			, $this->aConf['table']['rvs_custom_metatag']
			, RvsLibs_String::quoteSmart($metatagId)
			, RvsLibs_String::quoteSmart($metatagType)
			, RvsLibs_String::quoteSmart($metatagName)
			, (!is_null($metatagContent))? sprintf(', %s ',RvsLibs_String::quoteSmart($metatagContent)) : ',""'
			, (!is_null($metatagOldId))? sprintf(', %s ',RvsLibs_String::quoteSmart($metatagOldId)) : sprintf(', %s ',RvsLibs_String::quoteSmart($metatagId))
			);
        }
        $res = $oCustomMeta->query($query);
        DB_DataObject::debugLevel(0);
        return (isset($res) && $res) ? true : false;
    }

    /**
	* insert Custom Metatag Project info
	* Resulting
	* 	INSERT INTO
	* 		rvs_project_info_metatag (
	* 		project_info_metatag_id
	* 		, rvs_project_info_id
	* 		, rvs_custom_metatag_id
	* 		) VALUES (
	* 		{$projectInfoMetatagId}
	*  		, {$projectInfoId}
	* 		, {$metatagId}
	* 		)
	*
 	* @author Darawan Taorong
 	* @param string $projectInfoMetatagId
	* @param string $projectInfoId
 	* @param string $metatagId
 	* @return bool
 	*/
  	public function insertProjectInfoCustomMetatag($projectInfoMetatagId = null, $projectInfoId = null, $metatagId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);

        DB_DataObject::debugLevel(0);
        $oProjectInfoCustomMeta = DB_DataObject::factory($this->aConf['table']['rvs_project_info_metatag']);
        if ( !is_null($projectInfoMetatagId) && !is_null($projectInfoId) && !is_null($metatagId) ) {
        	///Fix PHP5.3 (use MDB2)
        	if (!empty($projectInfoMetatagId)) {
        		$oProjectInfoCustomMeta->project_info_metatag_id = $projectInfoMetatagId;
        	}
        	if (!empty($projectInfoId)) {
        		$oProjectInfoCustomMeta->rvs_project_info_id = $projectInfoId;
        	}
        	if (!empty($metatagId)) {
        		$oProjectInfoCustomMeta->rvs_custom_metatag_id = $metatagId;
        	}
        	///Fix PHP5.3 (use MDB2)
        	$res = $oProjectInfoCustomMeta->insert();
        } else {
        	$res = false;
        }
        DB_DataObject::debugLevel(0);
        return (isset($res) && $res) ? true : false;
    }

   /**
	* insert Custom Metatag Project Page
	* Resulting
	* 	INSERT INTO
	* 		rvs_project_page_metatag (
	* 		project_page_metatag_id
	* 		, rvs_project_page_id
	* 		, rvs_custom_metatag_id
	* 		) VALUES (
	* 		{$projectPageMetatagId}
	*  		, {$projectPageId}
	* 		, {$metatagId}
	* 		)
	*
 	* @author Darawan Taorong
 	* @param string $projectPageMetatagId
	* @param string $projectPageId
 	* @param string $metatagId
 	* @return bool
 	*/
  	public function insertProjectPageCustomMetatag($projectPageMetatagId = null, $projectPageId = null, $metatagId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $res = false;
        $oProjectPageCustomMeta = DB_DataObject::factory($this->aConf['table']['rvs_project_page_metatag']);
        if (!is_null($projectPageMetatagId) && !is_null($projectPageId) && !is_null($metatagId)) {
        	///Fix PHP5.3 (use MDB2)
        	if (!empty($projectPageMetatagId)) {
        		$oProjectPageCustomMeta->project_page_metatag_id = $projectPageMetatagId;
        	}
        	if (!empty($projectPageId)) {
        		$oProjectPageCustomMeta->rvs_project_page_id = $projectPageId;
        	}
        	if (!empty($metatagId)) {
        		$oProjectPageCustomMeta->rvs_custom_metatag_id = $metatagId;
        	}
        	///Fix PHP5.3 (use MDB2)
        	$res = $oProjectPageCustomMeta->insert();
        }
        DB_DataObject::debugLevel(0);
        return $res;
    }


/**************************************************
*                  Update
**************************************************/
    function updateProjectPageDataByProjectPageId($projectPageId, $aUpdate)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (count($aUpdate)) {
        	foreach ($aUpdate as $key => $val) {
        		$key = trim($key);
        		if (!empty($key)) {
        			$oProjectPage->$key = $val;
        		}

        	}
        	$oProjectPage->whereAdd('project_page_id=' . RvsLibs_String::quoteSmart($projectPageId));
        	$oProjectPage->update();
        }

    }


    function updateProjectPageDataByrvsLayoutId($rvsLayoutId, $projectPageId)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel();
    	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
    	$query = sprintf('
    			UPDATE
    		      %s
    			SET
    	          rvs_layout_id = %s
			    WHERE
                  project_page_id = %s
            '
    		, $this->aConf['table']['rvs_project_page']
    		, RvsLibs_String::quoteSmart($rvsLayoutId)
    		, RvsLibs_String::quoteSmart($projectPageId)
    );
    $res = $oProjectPage->query($query);
    DB_DataObject::debugLevel();
    return $res;
    }




    /**
     * Update page data by project id and usr id and project id
     *
     * Resulting SQL
     *      UPDATE
     *          rvs_project_page as pa
     *          , rvs_project as pp
     *          , rvs_project_layout_page as  pl ** option if $linkWithProjectLayoutPage = true **
     *       SET
     *          pa.page_data = {$pageData}
     *      WHERE
     *          pp.project_id = {$projectId}
     *          AND pa.rvs_usr_id = {$usrId}
     *          AND pa.project_page_id = {$projectPageId}
     *          AND pa.project_page_id = pl.project_page_id ** option if $linkWithProjectLayoutPage = true **
     *          AND pl.project_id = pp.project_id  ** option if $linkWithProjectLayoutPage = true **
     *
     * @param strint $pageData
     * @param string $projectId
     * @param string $usrId
     * @param string $projectPageId
     *
     * @access public
     * @author Parinya Chaipetch
     *
     * @return bool
     */
    public function updatePageDataByProjectIdAndUsrIdAndProjectPageId($pageData, $projectId, $usrId, $projectPageId, $linkWithProjectLayoutPage=true)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
            UPDATE
                %s as pa
                , %s as pp
                %s
            SET
                pa.page_data = %s
            WHERE
                pp.project_id = %s
                AND pa.rvs_usr_id = %s
                AND pa.project_page_id = %s
                %s
                %s
            '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project']
            , ($linkWithProjectLayoutPage === true) ? sprintf(', %s as pl', $this->aConf['table']['rvs_project_layout_page']) : ''
            , RvsLibs_String::quoteSmart($pageData)
            , RvsLibs_String::quoteSmart($projectId)
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($projectPageId)
            , ($linkWithProjectLayoutPage === true) ? 'AND pa.project_page_id = pl.project_page_id' : ''
            , ($linkWithProjectLayoutPage === true) ? 'AND pl.project_id = pp.project_id' : ''
        );
        $res = $oProjectPage->query($query);
        DB_DataObject::debugLevel();
        return $res;
    }

    /**
     * Update table rvs_project_page set custom_page_name where project_page_id
     *
     * Resulting SQL
     * 		UPDATE
     * 			 rvs_project_page
     * 		SET
     * 			custom_page_name = {$customPageName}
     * 		WHERE
     * 			project_page_id = {$projectPageId}
     *
     * @param string $customPageName
     * @param string $projectPageId
     * @return bool
     */
    public function updateCustomPageNameByProjectPageId($customPageName, $projectPageId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
			 UPDATE
                      %s
             SET
                      custom_page_name = %s
              WHERE
                      project_page_id = %s
              '
               , $this->aConf['table']['rvs_project_page']
               , RvsLibs_String::quoteSmart($customPageName)
               , RvsLibs_String::quoteSmart($projectPageId)
           );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
    }

 public function updateLinkIdAndTargetByProjectPageId($rvsLlinkId, $projectPageId, $rvsUsrId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
		$query = sprintf('
        	UPDATE
				%s
			SET
				rvs_link_id = ""
               , target =""
			WHERE
			     rvs_link_id = %s
                AND project_page_id = %s
                AND rvs_usr_id =%s
            '
            , $this->aConf['table']['rvs_project_page']
            ,  RvsLibs_String::quoteSmart( $rvsLlinkId)
            ,  RvsLibs_String::quoteSmart($projectPageId)
            ,  RvsLibs_String::quoteSmart($rvsUsrId)
         );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
    }

    /**
     * Update PageData only in rvs_project_page table by ProjectPageId And UsrId
     * Resulting SQL
     * 		UPDATE
     * 			rvs_project_page as pa
     * 		SET
     * 			pa.page_data = {$pageData}
     * 		WHERE
     * 			pa.project_page_id = {$projectPageId}
     * 			AND pa.rvs_usr_id = {$usrId}

     * @author Pornthip Phothong
     * @param  $pageData
     * @param  $projectPageId
     * @param  $usrId
     * @from   cGuestBookUserMgr.php
     */
    public function updatePageDataOnlyByProjectPageIdAndUsrId($pageData, $projectPageId, $usrId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
            UPDATE
                 %s as pa
            SET
                pa.page_data = %s
            WHERE
                pa.project_page_id = %s
                AND pa.rvs_usr_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , RvsLibs_String::quoteSmart($pageData)
            , RvsLibs_String::quoteSmart($projectPageId)
            , RvsLibs_String::quoteSmart($usrId)
            );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;

    }
    /**
     * Update Icon ProjectPage By UsrId And ProjectId And projectPageI
     *
     * Resulting SQL
     * UPDATE
     * 		rvs_project_page as pa
     * 		rvs_project as pp
     * SET
     * 		pa.i_favorite = {$iconFavorite} *** (isset($iconFavorite) && $iconFavorite) ? $iconFavorite : 0
     * 		, pa.i_print = {$iconPrint} *** (isset($iconPrint) && $iconPrint) ? $iconPrint : 0
     * 		, pa.i_mail = {$iconMail} *** (isset($iconMail) && $iconMail) ? $iconMail : 0
     * 		, pa.i_pathway = {$iconPathway} ***(isset($iconPathway) && $iconPathway) ? $iconPathway : 0
     * WHERE
     * 		pa.rvs_usr_id = {$usrId}
     * 		AND pp.project_id ={$projectId}
     * 		AND pa.project_page_id ={$projectPageId}
     *
     *
     * @author duangdao.k
     * @param string $iconFavorite
     * @param string $iconPrint
     * @param string $iconMail
     * @param string $iconPathway
     * @param string $usrId
     * @param string $projectId
     * @param string $projectPageId
     * @return obj
     */
    public function updateIconProjectPageByUsrIdAndProjectId($iconFavorite, $iconPrint, $iconMail, $iconPathway, $usrId, $projectId, $projectPageId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
			UPDATE
					%s as  pa
					, %s as pp
			 SET
					 pa.i_favorite = %s
					 , pa.i_print =  %s
 					 , pa.i_mail = %s
				 	 , pa.i_pathway = %s
			WHERE
					pa.rvs_usr_id = %s
					AND pp.project_id = %s
					AND pa.project_page_id = %s
             '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project']
            , (isset($iconFavorite) && $iconFavorite) ? $iconFavorite : 0
            , (isset($iconPrint) && $iconPrint) ? $iconPrint : 0
            , (isset($iconMail) && $iconMail) ? $iconMail : 0
            , (isset($iconPathway) && $iconPathway) ? $iconPathway : 0
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($projectId)
            , RvsLibs_String::quoteSmart($projectPageId)
            );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
    }
        /**
     * Update table rvs_project_page and rvs_project set meta_keyword and meta_description where rvs_usr_id, project_id and project_page_id
     *
     * Resulting SQL
     * 		UPDATE
     * 		 	rvs_project_page as  pa
     * 			, rvs_project as pp
     * 		SET
     * 			pa.meta_keyword = {$metaKeyword}
     * 			 , pa.meta_description = {$metaDescription}
     * 		WHERE
     * 			 pa.rvs_usr_id = {$usrId}
     * 			AND pp.project_id = {$projectId}
     * 			AND pa.project_page_id = {$projectPageId}
     *
     * @author duangdao.k
     * @param string $metaKeyword
     * @param string $metaDescription
     * @param string $usrId
     * @param string $projectId
     * @param string $projectPageId
     * @return bool
     */
   public function updateMetaKeywordAndMetaDescriptionByUsrIdAndProjectId($metaKeyword = null, $metaDescription = null, $usrId = null, $projectId = null, $projectPageId = null, $pageTitle = null)
   {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
			UPDATE
                  %s as  pa
                  , %s as pp
			SET
                 pa.meta_keyword = %s
                , pa.meta_description = %s
                 %s
			WHERE
                 pa.rvs_usr_id = %s
                 AND pp.project_id = %s
                 AND pa.project_page_id = %s
           '
           , $this->aConf['table']['rvs_project_page']
           , $this->aConf['table']['rvs_project']
           , RvsLibs_String::quoteSmart($metaKeyword)
           , RvsLibs_String::quoteSmart($metaDescription)
           , (is_null($pageTitle) == true) ? '' : ',pa.page_title =' . RvsLibs_String::quoteSmart($pageTitle)
           , RvsLibs_String::quoteSmart($usrId)
           , RvsLibs_String::quoteSmart($projectId)
           , RvsLibs_String::quoteSmart($projectPageId)
           );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
   }
    /**
     * Update table rvs_project_page, rvs_project_layout_page, rvs_project set custom_page_name where project_page_id, project_id
     *
     * Resulting SQL
     * 		UPDATE
     * 		 	rvs_project_page as  pa
     * 			, rvs_project_layout_page as pl
     * 			, rvs_project as pp
     * 		SET
     * 			pa.custom_page_name = {$customPageName}
     * 		WHERE
     * 			pa.project_page_id = pl.project_page_id
     * 			AND pl.project_id = pp.project_id
     * 			AND pa.project_page_id = {$projectPageId}
     * 			AND pp.project_id = {$projectId}
     * $res = $this->dbh->query($query);
     *
     * @author Darawan Taorong
     * @param string $customPageName
     * @param string $projectPageId
     * @param string $projectId
     * @return bool
     */
   public function updatecustomPageNameByprojectPageIdAndProjectId($customPageName = null, $projectPageId = null, $projectId = null)
   {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if ($projectPageId != '' && $projectId != '') {
            $query = sprintf('
			UPDATE
                 %s as  pa
                 , %s as pl
                 , %s as pp
			SET
				pa.custom_page_name = %s
			WHERE
            	pa.project_page_id = pl.project_page_id
      			AND pl.project_id = pp.project_id
  	 			AND pa.project_page_id = %s
     	 		AND pp.project_id = %s
     	 	'
  	 		, $this->aConf['table']['rvs_project_page']
	  		, $this->aConf['table']['rvs_project_layout_page']
         	, $this->aConf['table']['rvs_project']
     		, RvsLibs_String::quoteSmart($customPageName)
         	, RvsLibs_String::quoteSmart($projectPageId)
      		, RvsLibs_String::quoteSmart($projectId)
           );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
        }
   }

   public function updateIsMemberPageByprojectPageIdAndProjectId($projectId = null, $isMemberPage)
   {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
            $query = sprintf('
            UPDATE
                 %s as  pa
                 , %s as pl
                 , %s as pp
            SET
                pa.is_member_page = %s
            WHERE
                pa.project_page_id = pl.project_page_id
                AND pl.project_id = pp.project_id
                AND pp.project_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project_layout_page']
            , $this->aConf['table']['rvs_project']
            , RvsLibs_String::quoteSmart($isMemberPage)
            , RvsLibs_String::quoteSmart($projectId)
           );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return (isset($res) && $res)? true : false;
   }

   public function updateIsMemberPageInternalpageByProjectId($projectId = null, $isMemberPage)
   {
   	SGL::logMessage(null, PEAR_LOG_DEBUG);
   	DB_DataObject::debugLevel();
   	$oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
   	$query = sprintf('
            UPDATE
                 %s as  pa
                 , %s as np
                 , %s as pp
            SET
                pa.is_member_page = %s
            WHERE
                pa.project_page_id = np.project_page_id
                AND np.project_id = pp.project_id
                AND pp.project_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_internal_page']
            , $this->aConf['table']['rvs_project']
            , RvsLibs_String::quoteSmart($isMemberPage)
            , RvsLibs_String::quoteSmart($projectId)
            );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return (isset($res) && $res)? true : false;
   }

    /**
     * Update PageTitle in rvs_project_page table by ProjectPageId
     * @author Pornthip Phothong
     * @param  $newPageTitle
     * @param  $projectPageId
     * @from   Extras_PagetitleMgr.php
     */
    public function updatePageTitleByProjectPageId($newPageTitle, $projectPageId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
              UPDATE
                  %s
              SET
                  page_title = %s
              WHERE
                 project_page_id = %s
              '
            , $this->aConf['table']['rvs_project_page']
            , RvsLibs_String::quoteSmart($newPageTitle)
            , RvsLibs_String::quoteSmart($projectPageId)
            );
            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
    }

    public function updateIconProjectPageByProjectPageId($iconFavorite, $iconPrint, $iconMail, $iconPathway, $aProjectPageId=array())
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        if (is_array($aProjectPageId) === false || count($aProjectPageId) <= 0) {
        	return;
        }
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
			UPDATE
					%s as  pa
			 SET
					 pa.i_favorite = %s
					 , pa.i_print =  %s
 					 , pa.i_mail = %s
				 	 , pa.i_pathway = %s
			WHERE
					pa.project_page_id IN (\'%s\')
             '
            , $this->aConf['table']['rvs_project_page']
            , (isset($iconFavorite) && $iconFavorite) ? $iconFavorite : 0
            , (isset($iconPrint) && $iconPrint) ? $iconPrint : 0
            , (isset($iconMail) && $iconMail) ? $iconMail : 0
            , (isset($iconPathway) && $iconPathway) ? $iconPathway : 0
            , implode($aProjectPageId, ' \', \'')
            );

            $res = $oProjectPage->query($query);
            DB_DataObject::debugLevel();
            return $res;
    }
    /**
     * Update Head And PageData in rvs_project_page And rvs_project By projectPageId And ProjectId And UsrId
     * @author Pornthip Phothong
     * @param  $projectPageId
     * @param  $aPageBody
     * @param  $aPageHead
     * @param  $projectId
     * @param  $rvsUsrId
     * @from   WysiwygMgr.php
     /*$query = " UPDATE
                                       {$this->conf['table']['rvs_project_page']} as pp
                                     , {$this->conf['table']['rvs_project']} as p
                            SET
                                     pp.head ='$aPageHead',
                                     pp.page_data ='$aPageBody'
                            WHERE
                                     pp.project_page_id = '$projectPageId'
                                     AND p.project_id = '$projectId'
                                     AND pp.rvs_usr_id = '$rvsUsrId'
                            ";
     $result = $this->dbh->query($query);
*/
    public function updateHeadAndPageDataByprojectPageIdAndProjectIdAndUsrId($projectPageId, $aPageBody, $aPageHead, $projectId, $rvsUsrId, $lastUpdate = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                            UPDATE
                                       %s as pp
                                     , %s as p
                            SET
                                     pp.head = %s
                                     , pp.page_data = %s
                                     , pp.last_modifier = %s
                            WHERE
                                     pp.project_page_id = %s
                                     AND p.project_id = %s
                                     AND pp.rvs_usr_id = %s
                            '
                            , $this->aConf['table']['rvs_project_page']
                            , $this->aConf['table']['rvs_project']
                            , RvsLibs_String::quoteSmart($aPageHead)
                            , RvsLibs_String::quoteSmart($aPageBody)
                            , RvsLibs_String::quoteSmart($lastUpdate)
                            , RvsLibs_String::quoteSmart($projectPageId)
                            , RvsLibs_String::quoteSmart($projectId)
                            , RvsLibs_String::quoteSmart($rvsUsrId)
                            );
                            $res = $oProjectPage->query($query);
                            DB_DataObject::debugLevel();
                            return $res;
    }
    /**
     * Update Data Zone in rvs_project_page And rvs_project By projectPageId And ProjectId And UsrId
     * @author Darawan
     *
     * ///OPTIMIZE VARIABLE PASSING
     * @param  $aParams = array(
						                                        'projectPageId' => $input->project_page_id,
						                                        'dataZone1' => email_encode($htmlcode1),
						                                        'dataZone2' => email_encode($htmlcode2),
						                                        'dataZone3' => email_encode($htmlcode3),
						                                        'dataZone4' => email_encode($htmlcode4),
						                                        'widthCol1' => '',
						                                        'widthCol2' => '',
						                                        'widthCol3' => '',
						                                        'layoutIndex' => '',
						                                        'projectId' => $input->project_id,
						                                        'rvsUsrId' => $input->rvs_usr_id,
						                                        'lastUpdate' => time()
                                                            );
     * @from   WysiwygMgr.php
     **/
    public function updateDataZoneAndPageDataByprojectPageIdAndProjectIdAndUsrId($aParams)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                            UPDATE
                                       %s as pp
                                     , %s as p
                            SET
                                     pp.page_data = %s
                                     %s
                                     %s
                                     %s
                                     %s
                                     %s
                                     %s
                                     %s
                                     , pp.last_modifier = %s
                            WHERE
                                     pp.project_page_id = %s
                                     AND p.project_id = %s
                                     AND pp.rvs_usr_id = %s
                            '
                            , $this->aConf['table']['rvs_project_page']
                            , $this->aConf['table']['rvs_project']
                            , (isset($aParams['dataZone1']) && $aParams['dataZone1']) ? RvsLibs_String::quoteSmart($aParams['dataZone1']) : RvsLibs_String::quoteSmart('')
                            , (isset($aParams['dataZone2']) && $aParams['dataZone2']) ? sprintf(' ,pp.page_data_zone_2 = %s',RvsLibs_String::quoteSmart($aParams['dataZone2'])) : ''
                            , (isset($aParams['dataZone3']) && $aParams['dataZone3']) ? sprintf(' ,pp.page_data_zone_3 = %s',RvsLibs_String::quoteSmart($aParams['dataZone3'])) : ''
                            , (isset($aParams['dataZone4']) && $aParams['dataZone4']) ? sprintf(' ,pp.page_data_zone_4 = %s',RvsLibs_String::quoteSmart($aParams['dataZone4'])) : ''
                            , (isset($aParams['widthCol1']) && $aParams['widthCol1']) ? sprintf(' ,pp.colume_width_1 = %s',RvsLibs_String::quoteSmart($aParams['widthCol1'])) : ''
                            , (isset($aParams['widthCol2']) && $aParams['widthCol2']) ? sprintf(' ,pp.colume_width_2 = %s',RvsLibs_String::quoteSmart($aParams['widthCol2'])) : ''
                            , (isset($aParams['widthCol3']) && $aParams['widthCol3']) ? sprintf(' ,pp.colume_width_3 = %s',RvsLibs_String::quoteSmart($aParams['widthCol3'])) : ''
                            , (isset($aParams['layoutIndex']) && $aParams['layoutIndex'] != '' && $aParams['layoutIndex'] != '0') ? sprintf(' ,pp.rvs_layout_id = %s',RvsLibs_String::quoteSmart($aParams['layoutIndex'])) : ''
                            , RvsLibs_String::quoteSmart($aParams['lastUpdate'])
                            , RvsLibs_String::quoteSmart($aParams['projectPageId'])
                            , RvsLibs_String::quoteSmart($aParams['projectId'])
                            , RvsLibs_String::quoteSmart($aParams['rvsUsrId'])
                            );
        $res = $oProjectPage->query($query);
        DB_DataObject::debugLevel();
        return $res;
    }

    /**
     * Update table rvs_project_page, rvs_project set effect_page_enter and duration_page_enter where rvs_usr_id, project_id,  project_page_id
     *
     * Resulting SQL
     * 		UPDATE
     * 			rvs_project_page as  pa
     * 			 ,rvs_project as pp
     * 		SET
     * 			pa.effect_page_enter = {$effectPageEnter}
     * 			pa.duration_page_enter = {$durationPageEnter}
     * 		 WHERE
     * 			pa.rvs_usr_id ={$usrId}
     * 			AND pp.project_id = {$projectId}
     * 			AND pa.project_page_id = {$pageId}
     *
     * @author duangdao.k
     * @param string $effectPageEnter
     * @param string $durationPageEnter
     * @param string $usrId
     * @param string $projectId
     * @param string $pageId
     * @return bool
     */
     public function updateProjectDataByUsrIdProjectIdAndPageId($effectPageEnter = null, $durationPageEnter = null, $usrId = null, $projectId = null, $pageId = null)
    {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
       $query = sprintf('
        	UPDATE
                   %s as  pa
                  ,%s as pp
			 SET
                   pa.effect_page_enter = %s
                    , pa.duration_page_enter = %s
			WHERE
                   pa.rvs_usr_id = %s
                   AND pp.project_id =%s
                   AND pa.project_page_id =%s
             '
             , $this->aConf['table']['rvs_project_page']
             , $this->aConf['table']['rvs_project']
             , $effectPageEnter
             , $durationPageEnter
             , RvsLibs_String::quoteSmart($usrId)
             , RvsLibs_String::quoteSmart($projectId)
             , RvsLibs_String::quoteSmart($pageId)
          );
          $res = $oProjectPage->query($query);
          DB_DataObject::debugLevel();
          return $res;
    }

    /**
     * update table rvs_project_page and rvs_project set meta_page_effect where rvs_usr_id, project_id and project_page_id
     *
     *   $query = sprintf('
        	UPDATE
                  %s as  pa
                  ,%s as pp
            SET
                  pa.meta_page_effect = %s
            WHERE
                  pa.rvs_usr_id = %s
                  AND pp.project_id = %s
                  AND pa.project_page_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project']
            , RvsLibs_String::quoteSmart($metaEffect)
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($projectId)
            , RvsLibs_String::quoteSmart($pageId)
         );
     * @author duangdao.k
     * @param string $metaEffect
     * @param string $usrId
     * @param string $projectId
     * @param string $pageId
     * @return bool
     */
    public function updateMetaPageEffectByUsrIdAndProjectId($metaEffect = null, $usrId = null, $projectId = null, $pageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
        	UPDATE
                  %s as  pa
                  ,%s as pp
            SET
                  pa.meta_page_effect = %s
            WHERE
                  pa.rvs_usr_id = %s
                  AND pp.project_id = %s
                  AND pa.project_page_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project']
            , RvsLibs_String::quoteSmart($metaEffect)
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($projectId)
            , RvsLibs_String::quoteSmart($pageId)
         );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return $res;
    }

     /*
     * @author darawan
     * @param string $iconPathway
     * @param string $projectPageId
     * @return obj
     * from : wysiwygMgr (update pathway by project_page_id)
     */
    public function updateIconPathwayProjectPageByProjectPageId($iconPathway, $projectPageId=null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        if ($projectPageId == null || $projectPageId == '') {
            return;
        }
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
            UPDATE
                %s as  pa
            SET
                pa.i_pathway = %s
            WHERE
                pa.project_page_id = %s
            '
            , $this->aConf['table']['rvs_project_page']
            , (isset($iconPathway) && $iconPathway) ? $iconPathway : 0
            , RvsLibs_String::quoteSmart($projectPageId)
            );
		$res = $oProjectPage->query($query);
		return $res;
    }

    /**
     * update Target By ProjectPageId And ProjectId And UsrId in table rvs_project_page and rvs_project_layout_page and rvs_project
     *
     *  UPDATE
     *        rvs_project_page as pp
     *       , rvs_project_layout_page as pl
     *       , rvs_project as p
     *   SET
     *       pp.target = {'$input->frmTarget'}
     *   WHERE
     *      pp.project_page_id = pl.project_page_id
     *      AND pl.project_id = p.project_id
     *      AND pp.project_page_id = {'$input->project_page_id'}
     *      AND p.project_id = {'$input->project_id'}
     *      AND pp.rvs_usr_id = {'$input->rvs_usr_id'}
     *
     * @author Pornthip Phothong
     * @param  $target
     * @param  $projectPageId
     * @param  $projectId
     * @param  $usrId
     * @from   TargetMgr.php
     */
    public function updateTargetByProjectPageIdAndProjectIdAndUsrId($target, $projectPageId, $projectId, $usrId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                            UPDATE
                                      %s as pp
                                     , %s as pl
                                     , %s as p
                            SET
                                      pp.target = %s
                            WHERE
                                     pp.project_page_id = %s
                                     AND p.project_id = %s
                                     AND pp.rvs_usr_id = %s
                                     AND pp.project_page_id = pl.project_page_id
                                     AND pl.project_id = p.project_id
                            '
                            , $this->aConf['table']['rvs_project_page']
                            , $this->aConf['table']['rvs_project_layout_page']
                            , $this->aConf['table']['rvs_project']
                            , RvsLibs_String::quoteSmart($target)
                            , RvsLibs_String::quoteSmart($projectPageId)
                            , RvsLibs_String::quoteSmart($projectId)
                            , RvsLibs_String::quoteSmart($usrId)
                            );
                            $res = $oProjectPage->query($query);
                            DB_DataObject::debugLevel();
                            return $res;
    }

    /**
     *  update post step 4 by project page id
     * @author Pharadol
     * @return Bool
     * form file cForumsUserMgr.php
     */
    public function updatatepostStep4ByProjectPageId($pageData, $projectPageId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                              UPDATE
                                    %s
                           SET
                                        page_data = %s
                            WHERE
                                project_page_id = %s
                              '
                              , $this->aConf['table']['rvs_project_page']
                              , RvsLibs_String::quoteSmart($pageData)
                              , RvsLibs_String::quoteSmart($projectPageId)
                              );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
    }

    /**
     * Update LinkId And TarGetByUsrId And ProjectId And ProjectPageId
     *
     *  Resulting SQ
     * 			UPDATE
     * 				rvs_project_page as  pa
     * 				 , rvs_project_layout_page as  pl
     * 				 , rvs_project as pp
     * 		  SET
     * 				pa.rvs_link_id = {$rvsLinkId}
     * 				, pa.target = {$target}
     * 		WHERE
     * 				pa.project_page_id = pl.project_page_id
     * 				AND pl.project_id = pp.project_id
     * 				AND pa.rvs_usr_id = {$usrId}
     * 				AND pp.project_id = {$projectId}
     * 				AND pa.project_page_id = {$projectPageId}
     *
     * @author duangdao.k
     * @param string $rvsLinkId
     * @param string $target
     * @param string $usrId
     * @param string $projectId
     * @param string $projectPageId
     * @return boll
     */
    public function updateLinkIdAndTarGetByUsrIdAndProjectIdAndProjectPageId($rvsLinkId, $target, $usrId, $projectId, $projectPageId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
			UPDATE
				%s as  pa
				 , %s as  pl
				 ,%s as pp
            SET
				pa.rvs_link_id = %s
				, pa.target = %s
            WHERE
				pa.project_page_id = pl.project_page_id
				AND pl.project_id = pp.project_id
				AND pa.rvs_usr_id = %s
				AND pp.project_id = %s
				AND pa.project_page_id = %s
          '
          , $this->aConf['table']['rvs_project_page']
          , $this->aConf['table']['rvs_project_layout_page']
          , $this->aConf['table']['rvs_project']
          , RvsLibs_String::quoteSmart($rvsLinkId)
          , RvsLibs_String::quoteSmart($target)
          , RvsLibs_String::quoteSmart($usrId)
          , RvsLibs_String::quoteSmart($projectId)
          , RvsLibs_String::quoteSmart($projectPageId)
          );
          $res = $oProjectPage->query($query);
          DB_DataObject::debugLevel();
          return (isset($res) && $res)? true : false;
    }

    /**
     *updateTargetAndLinkIdByusrIdAndProjectIdAndLnkId
     *
     * Resulting SQ
     *  	UPDATE
     * 			rvs_link as ln
     * 			 , rvs_project_page as pa
     * 			 , rvs_project_layout_page as pl
     * 	 if (!$input->external_url  || $input->rvs_link_enable == 0 || $input->rvs_link_enable == '0') {
     *        SET
     * 				 pa.target = ''
     * 				 , pa.rvs_link_id = '0' ";
     * 	} else {
     * 			SET
     * 				 pa.target = {target}
     * 				, pa.rvs_link_id = {$linkId}
     * }
     *  		WHERE
     * 				 ln.rvs_link_id = pa.rvs_link_id
     * 				AND pa.project_page_id = pl.project_page_id
     * 				AND pa.rvs_usr_id ={$usrId}
     * 				AND pl.project_id = {$projectId}
     * 				AND ln.rvs_link_id = {$linkId}
     *
     * @author duangdao.k
     * @param string $externalUrl
     * @param string $linkEnable
     * @param string $target
     * @param string $linkId
     * @param string $usrId
     * @param string $projectId
     * @return bool
     */
    public function updateTargetAndLinkIdByusrIdAndProjectIdAndLnkId($externalUrl, $linkEnable, $target, $linkId, $usrId, $projectId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
        	UPDATE
				%s as ln
				, %s as pa
				, %s as pl
			SET
                %s
			WHERE
			     ln.rvs_link_id = pa.rvs_link_id
                AND pa.project_page_id = pl.project_page_id
                AND pa.rvs_usr_id =%s
                AND pl.project_id = %s
                AND ln.rvs_link_id = %s
            '
            , $this->aConf['table']['rvs_link']
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project_layout_page']
            , (!$externalUrl  || $linkEnable == 0 || $linkEnable == '0') ? sprintf(" pa.target = '', pa.rvs_link_id = %s", RvsLibs_String::quoteSmart('0'))
                : sprintf('pa.target = %s, pa.rvs_link_id = %s', RvsLibs_String::quoteSmart($target), RvsLibs_String::quoteSmart($linkId))
            ,  RvsLibs_String::quoteSmart($usrId)
            ,  RvsLibs_String::quoteSmart($projectId)
            ,  RvsLibs_String::quoteSmart($linkId)
         );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
 }
      /**
       * update rvs component id by porjectid and usrid and project pageid
       * if mainpage update where table rvs_project_layout_page
       * if internal page update where table rvs_internal_page
       * @othor phparaol
       * @param <string> $pageId
       * @param <string> $rvsUsrId
       * @param <string> $projectId
       * @param <string> $currentComponentId
       * @return bool
       * form file common.php
       */
      public function updateRvsComponentIdByProjectIdAndUsrIdAndProjectPageId($pageId, $rvsUsrId, $projectId, $currentComponentId, $internalPageId = false)
      {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
       $query = sprintf(' UPDATE
                                   %s as pp
                                   , %s
                          SET
                                pp.rvs_component_id = %s
                          WHERE
                                   %s
                                  AND pp.rvs_usr_id = %s
                                  AND %s
                                '
                                  , $this->aConf['table']['rvs_project_page']
                                  , ($internalPageId === true && $internalPageId != '' )
                                    ? $this->aConf['table']['rvs_internal_page'] . ' as ip'
                                    : $this->aConf['table']['rvs_project_layout_page'] . ' as pl'
                                  , RvsLibs_String::quoteSmart($currentComponentId)

                                  , ($internalPageId === true && $internalPageId != '' )
                                    ? 'pp.project_page_id = ip.project_page_id AND  ip.project_id = ' . RvsLibs_String::quoteSmart($projectId)
                                    : 'pp.project_page_id = pl.project_page_id AND  pl.project_id = ' . RvsLibs_String::quoteSmart($projectId)
                                  , RvsLibs_String::quoteSmart($rvsUsrId)
                                  , ($internalPageId === true && $internalPageId != '' )
                                    ?  'ip.project_page_id = '. RvsLibs_String::quoteSmart($pageId)
                                    :  'pp.project_page_id = '. RvsLibs_String::quoteSmart($pageId)
                                );
          $res = $oProjectPage->query($query);
          DB_DataObject::debugLevel();
          return (isset($res) && $res)? true : false;
      }

      /**
       * update rvs_component_id from mainpage or internalpage
       * if mainpage update where table rvs_project_layout_page
       * if internal page update where table rvs_internal_page
       * @param $pageId
       * @param $rvsUsrId
       * @param $projectId
       * @param $currentComponentId
       * @param $internalPageId
       * @return unknown_type
       */
      function updateRvsuserComponent($pageId, $rvsUsrId, $projectId, $currentComponentId, $internalPageId = false)
      {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_user_component_config']);
       $query = sprintf(' UPDATE
	                              %s as uc
	                              , %s as pp
	                              , %s
                          SET
                                  uc.rvs_component_id = %s
                          WHERE

                                  uc.rvs_project_page_id = pp.project_page_id
                                  AND pp.rvs_usr_id = %s
                                  AND %s
                                  AND %s
                                '
                                  , $this->aConf['table']['rvs_user_component_config']
                                  , $this->aConf['table']['rvs_project_page']
                                  , ($internalPageId === true && $internalPageId != '' )
                                    ? $this->aConf['table']['rvs_internal_page'] . ' as ip'
                                    : $this->aConf['table']['rvs_project_layout_page'] . ' as pl'

                                  , RvsLibs_String::quoteSmart($currentComponentId)

                                  , RvsLibs_String::quoteSmart($rvsUsrId)
                                  , ($internalPageId === true && $internalPageId != '' )
                                    ? 'pp.project_page_id = ip.project_page_id AND  ip.project_id = ' . RvsLibs_String::quoteSmart($projectId)
                                    : 'pp.project_page_id = pl.project_page_id AND  pl.project_id = ' . RvsLibs_String::quoteSmart($projectId)
                                  , ($internalPageId === true && $internalPageId != '' )
                                    ?  'ip.project_page_id = '. RvsLibs_String::quoteSmart($pageId)
                                    :  'pp.project_page_id = '. RvsLibs_String::quoteSmart($pageId)

                                );

          $res = $oProjectPage->query($query);
          DB_DataObject::debugLevel();
          return (isset($res) && $res)? true : false;
      }
      /**
       * update set form template byo usrid and projectpageid and projectid
       * @othor pharadol
       * @param <string> $rvsUsrId
       * @param <string> $projectPageId
       * @param <string> $projectId
       * @param <string> $onlineFormId
       * @return bool
       * form file common.php
       */
      public function  updateSetFormTemplateIdByusrIdAndProjectIdAndProjectId($rvsUsrId, $projectPageId, $projectId, $onlineFormId)
      {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
       $query = sprintf('
                            UPDATE
                                           %s  as pa
                                           , %s as pp
                            SET
                                           pa.form_template_id = %s
                            WHERE
                                           pp.project_id = %s
                                           AND pa.project_page_id = %s
                                           AND pa.rvs_usr_id = %s
                                '
                                , $this->aConf['table']['rvs_project_page']
                                , $this->aConf['table']['rvs_project']
                                , RvsLibs_String::quoteSmart($onlineFormId)
                                , RvsLibs_String::quoteSmart($projectId)
                                , RvsLibs_String::quoteSmart($projectPageId)
                                , RvsLibs_String::quoteSmart($rvsUsrId)
                                );
          $oProjectPage->query($query);
          $res = $oProjectPage->query($query);
          DB_DataObject::debugLevel();
          return (isset($res) && $res)? true : false;
      }
       /**
        *   updateAllCustomMetatagDataByCustomMetatagId
        *   Resulting SQL
        *
        *    UPDATE
        *              rvs_custom_metatag
        *     SET
        *               metatag_type = {$aMetatagType}
        *              , metatag_name = {$aMetatagName}
        *              , metatag_content ={$aMetatagContent}
        *     WHERE
        *              rvs_custom_metatag_id = {$aCustomMetatagId}
        *
        * @author Pornthip Phothong
        * @param string $aMetatagType
        * @param string $aMetatagName
        * @param string $aMetatagContent
        * @param string $aCustomMetatagId
        * @return  bool
        * @from Extras_MetatagMgr.php
        */
      public function updateAllCustomMetatagDataByCustomMetatagId($aMetatagType, $aMetatagName, $aMetatagContent, $aCustomMetatagId)
      {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       DB_DataObject::debugLevel();
       $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
       $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    metatag_type = %s
                                    , metatag_name = %s
                                    , metatag_content = %s
                       WHERE
                                    rvs_custom_metatag_id = %s

                               '
                               , $this->aConf['table']['rvs_custom_metatag']
                               , RvsLibs_String::quoteSmart($aMetatagType)
                               , RvsLibs_String::quoteSmart($aMetatagName)
                               , RvsLibs_String::quoteSmart($aMetatagContent)
                               , RvsLibs_String::quoteSmart($aCustomMetatagId)
                               );
          $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }

      /**
       * update PageLinkActive ByProjectPageId
       *
       * @param int $pageAct
       * @param string $projectPageId
       * @return bool
       */
      public function updatePageLinkActiveByProjectPageId($pageAct, $projectPageId)
      {
          SGL::logMessage(null, PEAR_LOG_DEBUG);
          DB_DataObject::debugLevel();
          $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
          $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    link_active = %s
                       WHERE
                                    project_page_id = %s
                               '
                       , $this->aConf['table']['rvs_project_page']
                       , $pageAct
                       , RvsLibs_String::quoteSmart($projectPageId)
                       );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }

     /**
      *   updateMetatagContentByCustomMetatagId
      *   Resulting SQL
      *
      *  UPDATE
      *          rvs_custom_metatag
      *    SET
      *          metatag_content = {$aDescription}
      *    WHERE
      *          rvs_custom_metatag_id = {$aCustomMetatagId}
      *
      * @author Pornthip Phothong
      * @param string $aDescription
      * @param string $aCustomMetatagId
      * @return  bool
      * @from Extras_MetatagMgr.php
      */
      public function updateMetatagContentByCustomMetatagId($aDescription, $aCustomMetatagId)
      {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCustomMetatag = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
		$oCustomMetatag->get('rvs_custom_metatag_id', $aCustomMetatagId);
		$oCustomMetatag->metatag_content = $aDescription;
		 $res = $oCustomMetatag->update();
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }

      //fix update is home page 0 v5 pharadol
      public function unsetHomePageByProjectId($projectId)
      {
      	SGL::logMessage(null, PEAR_LOG_DEBUG);
          DB_DataObject::debugLevel();
          $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
          $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    is_home = 0
                       WHERE
                                    project_id = %s
                                    AND is_home = %s
                       '
                       , $this->aConf['table']['rvs_project_layout_page']
                       , RvsLibs_String::quoteSmart($projectId)
                       , RvsLibs_String::quoteSmart(1)
                       );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }

      //fix update is home page 1 v5 pharadol
      public function updateSetHomePageByProjectPageId($projectPageId, $isHome)
      {
		  SGL::logMessage(null, PEAR_LOG_DEBUG);
          DB_DataObject::debugLevel();
          $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_layout_page']);
          $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    is_home = %s
                       WHERE
                                    project_page_id = %s
                               '
                       , $this->aConf['table']['rvs_project_layout_page']
                       , $isHome
                       , RvsLibs_String::quoteSmart($projectPageId)
                       );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return $res;
      }

      public function updatePagedataByProjectIdAndUserId($projectPageId, $usrId, $pagedata, $pageZone2, $pageZone3, $pageZone4)
      {
      	   SGL::logMessage(null, PEAR_LOG_DEBUG);
	       DB_DataObject::debugLevel();
	       $oProjectLayoutPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
	       $query = sprintf('
	            UPDATE
	                %s
	            SET
	                 page_data = %s
	                 , page_data_zone_2 = %s
	                 , page_data_zone_3 = %s
	                 , page_data_zone_4 = %s
	            WHERE
	                project_page_id = %s
	                AND rvs_usr_id = %s
	            '
	            , $this->aConf['table']['rvs_project_page']
	            , RvsLibs_String::quoteSmart($pagedata)
	            , RvsLibs_String::quoteSmart($pageZone2)
	            , RvsLibs_String::quoteSmart($pageZone3)
	            , RvsLibs_String::quoteSmart($pageZone4)
	            , RvsLibs_String::quoteSmart($projectPageId)
	            , RvsLibs_String::quoteSmart($usrId)
	      );
	      $res = $oProjectLayoutPage->query($query);
	      DB_DataObject::debugLevel();
	      return $res;
      }


      /**
       * updateSetDraftPageByProjectPageId
       * @param unknown_type $projectPageId
       * @param unknown_type $draft
       * @author pharadol
       * @return string
       */
    public function updateSetDraftPageByProjectPageId($projectPageId, $draft)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    set_draft = %s
                       WHERE
                                    project_page_id = %s
                               '
                               , $this->aConf['table']['rvs_project_page']
                               , $draft
                               , RvsLibs_String::quoteSmart($projectPageId)
                   );
       $res = $oProjectPage->query($query);
       DB_DataObject::debugLevel();
       return (isset($res) && $res)? true : false;
    }

    /**
     * Update IsMemberPage By ProjectPageId
     * @param $isMemberPage
     * @param $projectPageId
     * @author duangdao.k
     * @return bool
     */
      public function updateIsMemberPageByProjectPageId($isMemberPage, $projectPageId)
      {
          SGL::logMessage(null, PEAR_LOG_DEBUG);
          DB_DataObject::debugLevel();
          $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
          $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    is_member_page = %s
                       WHERE
                                    project_page_id = %s
                               '
                       , $this->aConf['table']['rvs_project_page']
                       , $isMemberPage
                       , RvsLibs_String::quoteSmart($projectPageId)
                       );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }

      /**
       * update Is MemberAllPage By ProjectPageId
       * @param string $isMemberPage
       * @param string $projectInfoId
       * @return bool
       */
      public function updateIsMemberAllPageByProjectInfo($isMemberPage, $projectInfoId)
      {
          SGL::logMessage(null, PEAR_LOG_DEBUG);
          DB_DataObject::debugLevel();
          $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_info']);
          $query = sprintf('
                       UPDATE
                                    %s
                       SET
                                    is_member_page = %s
                       WHERE
                                    project_info_id = %s
                               '
                       , $this->aConf['table']['rvs_project_info']
                       , $isMemberPage
                       , RvsLibs_String::quoteSmart($projectInfoId)
                       );
         $res = $oProjectPage->query($query);
         DB_DataObject::debugLevel();
         return (isset($res) && $res)? true : false;
      }



 //************************************ DELETE *********************************************
    /**
     * delete rename Page by project page id nam usrid
     * @author pharadol
     * @param <string> $usrId
     * @param <string> $projectPageId
     * @param <string> $pageName
     * @return bool
     * form fle PageStructureMgr.php
     /*
        $query = "
                        UPDATE
                                         {$this->conf['table']['rvs_project_page']} as  pa
                        SET
                                         pa.page_name = " . RvsLibs_String::quoteSmart($input->uname) . "

                        WHERE
                                          pa.rvs_usr_id = '$input->rvs_usr_id'
                                          AND pa.project_page_id = '$input->project_page_id'
                        ";
        $res = $this->dbh->query($query);
        */
    public function deleteRenamePageByProjectPageIdAndUsrId($usrId = null, $projectPageId = null, $pageName = null)
    {
        //SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (!is_null($usrId) && !is_null($projectPageId) && !is_null($pageName)) {
        $query = sprintf('
                        UPDATE
                                         %s  as  pa
                        SET
                                         pa.page_name = %s

                        WHERE
                                          pa.rvs_usr_id = %s
                                          AND pa.project_page_id = %s
                                 '
                                 , $this->aConf['table']['rvs_project_page']
                                 , RvsLibs_String::quoteSmart($pageName)
                                 , RvsLibs_String::quoteSmart($usrId)
                                 , RvsLibs_String::quoteSmart($projectPageId)
                                 );
          $res = $oProjectPage->query($query);
        }
          DB_DataObject::debugLevel();
          return (isset($res) && $res)? true : false;
    }


    /**
     * delete project page by projectid and usrid
     * $query = "
                        DELETE
                                    {$this->conf['table']['rvs_project_page']} as pa
                        FROM
                                    {$this->conf['table']['rvs_project_page']} as pa
                                    , {$this->conf['table']['rvs_project_layout_page']} as pl
                                    , {$this->conf['table']['rvs_project']} as pp
                        WHERE
                                    pa.project_page_id = pl.project_page_id
                                    AND pl.project_id = pp.project_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
     * form file RemoveProjectMgr.php
     */
    public function deleteProjectPageByProjectIdAndUsrId($pageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $res = false;
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
         if (!is_null($pageId) && $oProjectPage->get('project_page_id', $pageId)) {
              $res = $oProjectPage->delete();
        }
		return $res;
    }

    /**
     * delete ProjectPage Form InternalPage By ProjectId And UsrId
     * @author Tanawat
     * @param string $usrId
     * @param string $ProjectId
     * @param string $ProjectPageId
     * @return bool
     */
    public function deleteProjectPageFormInternalPageByProjectIdAndUsrId($usrId = null, $ProjectId=null, $ProjectPageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
         if (!is_null($ProjectPageId)) {
            /*
         	$query = sprintf('
            DELETE
                %s as pa
            FROM
                %s as pa
                , %s  as ip
            WHERE
                pa.project_page_id = ip.project_page_id
                AND pa.project_page_id = %s
                AND pa.rvs_usr_id = %s
                AND ip.project_id = %s'
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_internal_page']
            , RvsLibs_String::quoteSmart($ProjectPageId)
            , RvsLibs_String::quoteSmart($usrId)
            , RvsLibs_String::quoteSmart($ProjectId)
            );
            */

         	$query = sprintf('
            DELETE

            FROM
                %s
            WHERE
                project_page_id = %s'
            , $this->aConf['table']['rvs_project_page']
            , RvsLibs_String::quoteSmart($ProjectPageId)
            );
              $res = $oProjectPage->query($query);
        }
        return (isset($res) && $res) ? true : false;
    }

    /**
     * delete Project Page by Project pageid and projectid and usrid
     * @author pharadol
     * @param <string> $projectId
     * @param <string> $usrId
     * @param <string> $projectPageId
     * @return bool
     * form file PageStructureMgr.php
                 /*
                  $query1 = "
                                    DELETE
                                                 {$this->conf['table']['rvs_project_page']} as pa
                                    FROM
                                                {$this->conf['table']['rvs_project_page']} as pa
                                                , {$this->conf['table']['rvs_project_layout_page']} as  pl

                                    WHERE
                                                pl.project_page_id = pa.project_page_id
                                                AND pa.project_page_id = '$projectPageId'
                                                AND pa.rvs_usr_id = '$input->rvs_usr_id'
                                                AND pl.project_id = '$input->project_id'
                            ";
                  $result1 = $this->dbh->query($query1)
                  */
    public function deleteProjectPageByprojectIpageIdAndProjectIdAndUsrId($projectId = null, $usrId = null, $projectPageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oProjectPage = DB_DataObject::factory($this->aConf['table']['rvs_project_page']);
        if (!is_null($projectPageId)) {
         /*
        $query = sprintf('
                                    DELETE
                                                 %s  as pa
                                    FROM
                                               %s  as pa
                                                , %s  as  pl

                                    WHERE
                                                pl.project_page_id = pa.project_page_id
                                                AND pa.project_page_id = %s
                                                AND pa.rvs_usr_id = %s
                                                AND pl.project_id = %s
                                  '
                                  , $this->aConf['table']['rvs_project_page']
                                  , $this->aConf['table']['rvs_project_page']
                                  , $this->aConf['table']['rvs_project_layout_page']
                                  , RvsLibs_String::quoteSmart($projectPageId)
                                  , RvsLibs_String::quoteSmart($usrId)
                                  , RvsLibs_String::quoteSmart($projectId)
                                  );
          */
                $query = sprintf('
                                    DELETE

                                    FROM
                                               %s
                                    WHERE
                                               project_page_id = %s
                                  '
                                  , $this->aConf['table']['rvs_project_page']
                                  , RvsLibs_String::quoteSmart($projectPageId)
                                  );
                $res = $oProjectPage->query($query);
        }
        SGL::logMessage('**********Query :' . $query, PEAR_LOG_DEBUG);
        SGL::logMessage('**********Res:' . $res, PEAR_LOG_DEBUG);
        return (isset($res) && $res) ? true : false;
    }

    /**
     * delete project info metatag And custom metatag by user_id, project id,  Page by Project pageid and projectid and usrid
     * Resulting
     * 	DELETE
     * 		rvs_custom_metatag as cm
     * 		, rvs_project_info_metatag as pim
     * 		, rvs_project_page_metatag as ppm
     * 	FROM
     * 		rvs_custom_metatag AS cm LEFT OUTER JOIN
     * 		rvs_project_info_metatag AS pim ON cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id LEFT OUTER JOIN
     * 		rvs_project_page_metatag AS ppm ON cm.rvs_custom_metatag_id = ppm.rvs_custom_metatag_id LEFT OUTER JOIN
     * 		rvs_project_info AS pi ON pim.rvs_project_info_id = pi.project_info_id
     * 	WHERE
     * 		(cm.metatag_type = {$metatagType} and cm.metatag_name = {metatagName})
     * 		AND (pim.rvs_project_info_id ={$projectInfoId}
     * 		OR  pim.rvs_project_info_id is null )
     *
     * @author Darawan Taorong 02/06/2552 09:39 AM
     * @param <string> $metatagType
     * @param <string> $metatagName
     * @param <string> $projectInfoId
     * @return bool
     * form file Extras_MetatagMgr.php
     */
    public function deleteCustomMetatagInfoAndCustomMetatagByUsrIdAndProjectIdAndProjectInfoIdAndCustomMetatagId($metatagType = null, $metatagName = null, $projectInfoId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCustomMetatag = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
        if (!is_null($metatagType) && !is_null($metatagName) && !is_null($projectInfoId)) {
	        /*
        	$query = sprintf('
				DELETE
					%s  as cm
					, %s as pim
					, %s as ppm
	    		FROM
	      			%s  as cm LEFT OUTER JOIN
					%s AS pim ON cm.rvs_custom_metatag_id = pim.rvs_custom_metatag_id LEFT OUTER JOIN
	        		%s AS ppm ON cm.rvs_custom_metatag_id = ppm.rvs_custom_metatag_id LEFT OUTER JOIN
	       			%s AS pi ON pim.rvs_project_info_id = pi.project_info_id
				WHERE
					( cm.metatag_type = %s
					AND cm.metatag_name = %s )
					AND ( pim.rvs_project_info_id = %s
					OR  pim.rvs_project_info_id is null )        '
			, $this->aConf['table']['rvs_custom_metatag']
			, $this->aConf['table']['rvs_project_info_metatag']
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_custom_metatag']
			, $this->aConf['table']['rvs_project_info_metatag']
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_project_info']
			, RvsLibs_String::quoteSmart($metatagType)
			, RvsLibs_String::quoteSmart($metatagName)
			, RvsLibs_String::quoteSmart($projectInfoId)
			);
			*/
            $query = sprintf('
                DELETE

                FROM
                    %s
                WHERE
                    metatag_name = %s
            '
            , $this->aConf['table']['rvs_custom_metatag']
            , RvsLibs_String::quoteSmart($metatagName)
            );
            $res = $oCustomMetatag->query($query);
        }
         DB_DataObject::debugLevel(0);
        return (isset($res) && $res) ? true : false;
    }

    /**
     * delete project page metatag And custom metatag by user_id, project_page_id, custom_metatag_id
     * Resulting
     * 	DELETE
     * 		rvs_project_page_metatag as ppm
     * 		, rvs_custom_metatag as cm
     * 	FROM
     * 		rvs_project_page as pp
     * 		, rvs_project_layout_page as pl
     * 		, rvs_project_page_metatag as ppm
     * 		, rvs_custom_metatag as cm
     * 	WHERE
     * 		pp.project_page_id = ppm.rvs_project_page_id
     * 		AND pp.project_page_id = pl.project_page_id
     * 		AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
     * 		AND pp.rvs_usr_id = {$usrId}
     * 		AND pp.project_page_id = {$projectPageId}
     * 		AND cm.rvs_custom_metatag_id = {$customMetatagId}
     *
     * @author Darawan Taorong 02/06/2552 09:39 AM
     * @param <string> $usrId
     * @param <string> $projectPageId
     * @param <string> $customMetatagId
     * @return bool
     * form file Extras_MetatagMgr.php
     */
    public function deleteCustomMetatagPageAndCustomMetatagByUsrIdAndProjectPageIdAndCustomMetatagId($usrId = null, $projectPageId = null, $customMetatagId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCustomMetatag = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
        if (!is_null($customMetatagId)) {
/*
        	$query = sprintf('
				DELETE
					%s  as ppm
					, %s as cm
	    		FROM
	      			%s  as pp
					, %s  as  pl
	        		, %s as ppm
	       			, %s as cm
				WHERE
					pp.project_page_id = ppm.rvs_project_page_id
					AND pp.project_page_id = pl.project_page_id
					AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
					AND pp.rvs_usr_id =  %s
					AND pp.project_page_id =  %s
					%s
			'
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_custom_metatag']
			, $this->aConf['table']['rvs_project_page']
			, $this->aConf['table']['rvs_project_layout_page']
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_custom_metatag']
			, RvsLibs_String::quoteSmart($usrId)
			, RvsLibs_String::quoteSmart($projectPageId)
			, ( !is_null($customMetatagId) && $customMetatagId != '' ) ? ' AND cm.rvs_custom_metatag_id = ' . RvsLibs_String::quoteSmart($customMetatagId) : ''
			);
			*/

        	    $query = sprintf('
                DELETE

                FROM
                    %s
                WHERE
                    rvs_custom_metatag_id = %s
            '
            , $this->aConf['table']['rvs_custom_metatag']
            , RvsLibs_String::quoteSmart($customMetatagId)
            );
			$res = $oCustomMetatag->query($query);
        }
        return (isset($res) && $res) ? true : false;
    }
/**
     * delete project page metatag  by user_id, project_page_id, custom_metatag_id
     * Resulting
     * 	DELETE
     * 		rvs_project_page_metatag as ppm
     * 		, rvs_custom_metatag as cm
     * 	FROM
     * 		rvs_project_page as pp
     * 		, rvs_project_page_metatag as ppm
     * 		, rvs_custom_metatag as cm
     * 	WHERE
     * 		pp.project_page_id = ppm.rvs_project_page_id
     * 		AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
     * 		AND pp.rvs_usr_id = {$usrId}
     * 		AND pp.project_page_id = {$projectPageId}
     * 		AND cm.rvs_custom_metatag_id = {$customMetatagId}
     *
     * @author Darawan Taorong 02/06/2552 09:39 AM
     * @param <string> $usrId
     * @param <string> $projectPageId
     * @param <string> $customMetatagId
     * @return bool
     * form file Extras_MetatagMgr.php
     */
    public function deleteCustomMetatagPageListByUsrIdAndProjectPageIdAndCustomMetatagId($usrId = null, $projectPageId = null, $customMetatagId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCustomMetatag = DB_DataObject::factory($this->aConf['table']['rvs_custom_metatag']);
        if (!is_null($usrId) && !is_null($projectPageId)) {
	        $query = sprintf('
				DELETE
					%s  as ppm
					, %s as cm
	    		FROM
	      			%s  as pp
	        		, %s as ppm
	       			, %s as cm
				WHERE
					pp.project_page_id = ppm.rvs_project_page_id
					AND ppm.rvs_custom_metatag_id = cm.rvs_custom_metatag_id
					AND pp.rvs_usr_id =  %s
					AND pp.project_page_id =  %s
					%s
			'
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_custom_metatag']
			, $this->aConf['table']['rvs_project_page']
			, $this->aConf['table']['rvs_project_page_metatag']
			, $this->aConf['table']['rvs_custom_metatag']
			, RvsLibs_String::quoteSmart($usrId)
			, RvsLibs_String::quoteSmart($projectPageId)
			, ( !is_null($customMetatagId) && $customMetatagId != '' ) ? ' AND cm.rvs_custom_metatag_id = ' . RvsLibs_String::quoteSmart($customMetatagId) : ''
			);
			$res = $oCustomMetatag->query($query);
        }
        return (isset($res) && $res) ? true : false;
    }
    public function backupsql($projectId, $usrId, $aProjectPageId=array())
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $aSQLData = array();
        $aCustomMetatagId = array();
        if (count($aProjectPageId) <= 0) {
        	/// 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 teble rvs_project_page
        foreach ($aProjectPageId as $key => $val) {
            $oProjectPage = $this->findProjectPageDataByProjectPageId($key, 'getDataObject', $aResultFields = array());
            foreach ($oProjectPage as $k => $v) {
                $aSQLData[] = DbWrapper::buildSQLFormat($v);
            }
            /// Backup table rvs_project_page_metatag
            $oProjectPageMetatag = DaoFactory::ProjectPage()->findProjectPageMetatagByProjectPageId($key, 'getDataObject');
            foreach ($oProjectPageMetatag as $k => $v) {
                $aCustomMetatagId[] = $v->rvs_custom_metatag_id;
                $aSQLData[] = DbWrapper::buildSQLFormat($v);
            }
        }
        /*
        /// Backup table rvs_project_page_metatag
        foreach ($aProjectPageId as $key => $val) {
            $oProjectPageMetatag = DaoFactory::ProjectPage()->findProjectPageMetatagByProjectPageId($key, 'getDataObject');
            foreach ($oProjectPageMetatag as $k => $v) {
				$aCustomMetatagId[] = $v->rvs_custom_metatag_id;
                $aSQLData[] = DbWrapper::buildSQLFormat($v);
            }

        }
        */
        /// Backup Table rvs_custom_metatag
        foreach ($aCustomMetatagId as $customMetatagId) {
            $oCustomMetatagId = DaoFactory::Project()->findCustomMetatagByCustomMetatagId($customMetatagId, $fetchMode = 'getDataObject');
            foreach ($oCustomMetatagId as $k => $v) {
                $aSQLData[] = DbWrapper::buildSQLFormat($v);
            }
        }
        /// Write file sql
        //$rvsDbBackup = DbWrapper::writeSqlFile($projectId, $aSQLData, 'projectpage');
        return $aSQLData;
    }

    public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array())
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        if (count($aProjectPageId)) {
        	foreach ($aProjectPageId as $pageId => $val) {
        		$result = DaoFactory::ProjectPage()->deleteProjectPageByProjectIdAndUsrId($pageId);
        	}
        }
    }
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez