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/InternalPageDao.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 internal page of RVSiteBuilder
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  Parinya <parinya@rvglobalsoft.com>
 * @version $Revision$
 * @since   PHP 5.1
 */

class InternalPageDao extends DbWrapper implements SitebuilderInf
{
	function InternalPageDao()
	{
		parent::DbWrapper();
	}

	/**
	 * Returns a singleton InternalPageDao instance.
	 *
	 * @param bool $autoload
	 * @return obj
	 */
	public static function singleton($autoload=false)
    {
        static $instance;
        // If the instance is not there, create one
        if (!isset($instance) || $autoload) {
            $class = __CLASS__;
            $instance = new $class();
        }
        return $instance;
    }

    /**
     * Find internel page data by project id
     * @author Parinya Chaipetch
     *
     * @param string $projectId
     * @param string $fetchMode
     * @access public
     * @return array
     */
    function findInternalPageDataByProjectId($projectId=null,$fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);

        if (!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
                ORDER BY
                    pp.page_name
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_internal_page']
                , RvsLibs_String::quoteSmart($projectId)
            );
            $oInternalPage->query($query);
        }
        $aCloneData = array();
        while ($oInternalPage->fetch()) {
            $aCloneData[] = clone($oInternalPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oInternalPage->_resultFields, $aCloneData, $fetchMode);
    }
    /**
     * Find InternalPageData By PageName And UserId And ProjectId
     * @author tanawat kunanuraknun
     * @param string $pageName
     * @param string $userId
     * @param string $projectId
     * @param string $fetchMode
     * listPageStructureMgr.php
     * @return array
     */
    function findInternalPageDataByPageNameAndUserIdAndProjectId($pageName=null,$userId=null,$projectId=null,$fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);

        if (!is_null($pageName) && !is_null($userId) && !is_null($projectId)) {
             $query = sprintf('
                SELECT
                    *
                FROM
                    %s as pp
                    ,%s as lp
                    ,%s as ip
                WHERE
                    pp.project_page_id = ip.project_page_id
                    AND ip.project_id  = lp.project_id
                    AND ip.project_id = %s
                    AND pp.page_name = %s
                    AND pp.rvs_usr_id = %s

                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_project_layout_page']
                , $this->aConf['table']['rvs_internal_page']
                , RvsLibs_String::quoteSmart($projectId)
                , RvsLibs_String::quoteSmart($pageName)
                , RvsLibs_String::quoteSmart($userId)
            );
            $oInternalPage->query($query);
        }
        $aCloneData = array();
        while ($oInternalPage->fetch()) {
            $aCloneData[] = clone($oInternalPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oInternalPage->_resultFields, $aCloneData, $fetchMode);
    }
    /**
     * find All InternalPage Data By ProjectPageId from rvs_internal_page table
     * @author Pornthip Phothong
     * @param  string $projectPageId
     * @param  string $fetchMode
     * @return array
      /*  $query = "
                        SELECT
                                    *
                        FROM
                                     {$this->conf['table']['rvs_internal_page']}
                        WHERE
                                    project_page_id = '$projectPageId'
                    ";

        $res = $this->dbh->getAll($query, DB_FETCHMODE_ASSOC);
       */
    public function findAllInternalPageDataByProjectPageId($projectPageId=null, $projectId = null, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        if (!is_null($projectPageId)) {
            $query = sprintf('
                        SELECT
                                    *
                        FROM
                                   %s
                        WHERE
                                    project_page_id = %s
                                     %s
                    '
                    , $this->aConf['table']['rvs_internal_page']
                    , RvsLibs_String::quoteSmart($projectPageId)
                    , is_null($projectId) ? '' : 'AND project_id = ' . RvsLibs_String::quoteSmart($projectId)
                    );
         $oInternalPage->query($query);
        }
       $aCloneData = array();
        while ($oInternalPage->fetch()) {
            $aCloneData[] = clone($oInternalPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oInternalPage->_resultFields, $aCloneData, $fetchMode);
    }

    public function findInternalProjectPageIdByProjectId($projectId=null, $fetchMode='getassoc', $aResultFields = array(), $projectPageId=null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);

        if (!is_null($projectId)) {
            $oInternalPage->project_id = $projectId;
        }
        if (!is_null($projectPageId)) {
        	$oInternalPage->project_page_id = $projectPageId;
        }
        $oInternalPage->find();
        $aCloneData = array();
        while ($oInternalPage->fetch()) {
            $aCloneData[] = clone($oInternalPage);
        }
        DB_DataObject::debugLevel();
        $_aResultFields = DbWrapper::buildResultFields($oInternalPage, $aResultFields);
        return DbWrapper::fetchDatas($_aResultFields, $aCloneData, $fetchMode);
    }

  public function findInternalPageIsComponent($projectID, $userID, $ownerID, $componentName, $fetchMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        $query = sprintf('
                        SELECT
                        DISTINCT (i.project_page_id)
                                , i.project_id
                                , p.page_name
                                , c.rvs_component_id
                                , c.component_name
                                , c.rvs_owner_usr_id
                        FROM
                            %s as i
                            , %s as p
                            , %s as c
                        WHERE
                            i.project_page_id = p.project_page_id
                            AND p.rvs_component_id = c.rvs_component_id
                            AND p.rvs_component_id != ""
                            AND i.project_id = %s
                            AND p.rvs_usr_id = %s
                            AND c.rvs_owner_usr_id = %s
                            AND c.component_name = %s
                        '
                        , $this->aConf['table']['rvs_internal_page']
                        , $this->aConf['table']['rvs_project_page']
                        , $this->aConf['table']['rvs_component']
                        , RvsLibs_String::quoteSmart($projectID)
                        , RvsLibs_String::quoteSmart($userID)
                        , RvsLibs_String::quoteSmart($ownerID)
                        , RvsLibs_String::quoteSmart($componentName)
                        );
                        $oInternalPage->query($query);
       $aCloneData = array();
        while ($oInternalPage->fetch()) {
            $aCloneData[] = clone($oInternalPage);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oInternalPage->_resultFields, $aCloneData, $fetchMode);
    }


/***************************************************************
*              *****  INSERT *****                             *
****************************************************************/

    /**
     * insert InternalPage by internal_page_id project_id project_page_id
     *
     * @param string $internalPageId
     * @param string $projectId
     * @param string $projectPageId
     * @return bool
    /* $query = "
                        INSERT INTO
                        {$this->conf['table']['rvs_internal_page']}
                                    (
                                    internal_page_id
                                    , project_id
                                    , project_page_id
                                    )
                        VALUES (
                                        '$internalPageId'
                                        , '$projectId'
                                        , '$projectPageId'
                                      )
                        ";

                $this->dbh->query($query);
                 */
                // Call insert InternalPage in rvs_internal_page table :Pornthip Phothong
public function insertInternalPage($internalPageId = null, $projectId = null, $projectPageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oInternalPage =  DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        if (!is_null($internalPageId) && !is_null($projectId) && !is_null($projectPageId)) {
        	///Fix PHP5.3 (use MDB2)
        	if (!empty($internalPageId)) {
        		$oInternalPage->internal_page_id = $internalPageId;
        	}
        	if (!empty($projectId)) {
        		$oInternalPage->project_id = $projectId;
        	}
        	if (!empty($projectPageId)) {
        		$oInternalPage->project_page_id = $projectPageId;
        	}
        	///Fix PHP5.3 (use MDB2)
            $res = $oInternalPage->insert();
        } else {
            $res = false;
        }
        DB_DataObject::debugLevel();
        return (isset($res) && $res) ? true : false;
    }

/***************************************************************
*              *****  DELETE *****                             *
****************************************************************/
    /**
     * delate internal page by usrid and projectid
     * $query = "
                        DELETE
                                    {$this->conf['table']['rvs_internal_page']} as ip
                        FROM
                                    {$this->conf['table']['rvs_internal_page']} as ip
                        WHERE
                                    ip.project_page_id = '$input->project_page_id'
                                    AND ip.project_id = '$input->project_id'
                    ";
     * @author pharadol
     * @param <string> $usrId
     * @param <string> $projectId
     * @return array
     */
    public function deleteInternalPageByProjectIdAndProjectPageId($projectId, $usrId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        /*
        $query = sprintf('
            DELETE
                %s as ip
                , %s as pp
            FROM
                %s as ip
                , %s as pp
            WHERE
                ip.project_id = %s
                AND ip.project_page_id = pp.project_page_id
            '
            , $this->aConf['table']['rvs_internal_page']
            , $this->aConf['table']['rvs_project_page']
            , $this->aConf['table']['rvs_internal_page']
            , $this->aConf['table']['rvs_project_page']
            , RvsLibs_String::quoteSmart($projectId)
            , !is_null($projectPageId) ? sprintf(' AND  ip.project_page_id = %s', RvsLibs_String::quoteSmart($projectPageId))
                                : ''
             );
             */

            $query = sprintf('
            DELETE

            FROM
                %s
            WHERE
                project_id = %s
            '
            , $this->aConf['table']['rvs_internal_page']
            , RvsLibs_String::quoteSmart($projectId)
             );
          $res = $oInternalPage->query($query);
          return ($res) ? true : false;
    }

    /**
     * delate internal page by usrid and projectid : used movePage Step 5
     * $query = "
                        DELETE
                                    {$this->conf['table']['rvs_internal_page']} as ip
                        FROM
                                    {$this->conf['table']['rvs_internal_page']} as ip
                        WHERE
                                    ip.project_page_id = '$input->project_page_id'
                                    AND ip.project_id = '$input->project_id'
                    ";
     * @author duangdao.k
     * @param <string> $usrId
     * @param <string> $projectId
     * @return array
    */
  public function deleteInternalPageByProjectIdAndProjectPageId2($projectId, $projectPageId = null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oInternalPage = DB_DataObject::factory($this->aConf['table']['rvs_internal_page']);
        /*
        $query = sprintf('
            DELETE
                %s as ip
            FROM
                %s as ip
            WHERE
                ip.project_id = %s
                %s
            '
            , $this->aConf['table']['rvs_internal_page']
            , $this->aConf['table']['rvs_internal_page']
            , RvsLibs_String::quoteSmart($projectId)
            , !is_null($projectPageId) ? sprintf(' AND  ip.project_page_id = %s', RvsLibs_String::quoteSmart($projectPageId))                : ''
             );
             */
         $query = sprintf('
            DELETE

            FROM
                %s
            WHERE
                project_page_id = %s

            '
            , $this->aConf['table']['rvs_internal_page']
            , RvsLibs_String::quoteSmart($projectPageId)

             );
          $res = $oInternalPage->query($query);
          return ($res) ? true : false;
    }

    public function backupsql($projectId, $usrId, $projectPageId=null)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $aSQLData = array();
        /// Backup table rvs_internal_page
        $oInternalPage = DaoFactory::InternalPage()->findInternalProjectPageIdByProjectId($projectId, 'getDataObject', array(), $projectPageId);
        foreach ($oInternalPage as $k => $v) {
            $aSQLData[] = DbWrapper::buildSQLFormat($v);
        }
        return $aSQLData;
    }

    public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array())
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $result = DaoFactory::InternalPage()->deleteInternalPageByProjectIdAndProjectPageId($projectId, $usrId);
    }
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez