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/LinkDao.php

<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// WebSite:  http://www.rvglobalsoft.com
// Unauthorized copying is strictly forbidden and may result in severe legal action.
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
//
// =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
// This Agreement is a legal contract, which specifies the terms of the license
// and warranty limitation between you and RV Global Soft Co.,Ltd. and RV Site Builder.
// You should carefully read the following terms and conditions before
// installing or using this software.  Unless you have a different license
// agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
// indicates your acceptance of the license and warranty limitation terms
// contained in this Agreement. If you do not agree to the terms of this
// Agreement, promptly delete and destroy all copies of the Software.
//
// =====  Grant of License =======
// The Software may only be installed and used on a single host machine.
//
// =====  Disclaimer of Warranty =======
// THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
// WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
// WARRANTIES WHETHER EXPRESSED OR IMPLIED.   BECAUSE OF THE VARIOUS HARDWARE
// AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
// FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.  THE USER MUST ASSUME THE
// ENTIRE RISK OF USING THIS PROGRAM.  ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
// LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
// IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
// CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
// OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
// BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
// NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
// RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
// RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
// BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
// +---------------------------------------------------------------------------+
// $Id$
// +---------------------------------------------------------------------------+

/**
 *  Data access methods for the component of RVSiteBuilder
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  Parinya <parinya@rvglobalsoft.com>
 * @version $Revision$
 * @since   PHP 5.1
 */

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

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

    // Select //

    /**
     * find AllData By LinkId from rvs_link table
     * SELECT
     *      *
     *  FROM
     *     {$this->conf['table']['rvs_link']}
     *  WHERE
     *     rvs_link_id = '$rvsLinkId'
     *
     * @author Pornthip Phothong
     * @param <string> $rvsLinkId
     * @param <string> $fetchMode
     * @return array
     * form file SitebilderFixMgr.php
     */
    public function findAllDataByLinkId($rvsLinkId=null, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
        if (!is_null($rvsLinkId)) {
           $query = sprintf('
                        SELECT
                                    *
                        FROM
                                   %s
                        WHERE
                                    rvs_link_id = %s
                    '
                    , $this->aConf['table']['rvs_link']
                    , RvsLibs_String::quoteSmart($rvsLinkId)
                    );
                    $oLink->query($query);
        }
         $aCloneData = array();
         while ($oLink->fetch()) {
             $aCloneData[] = clone($oLink);
         }
         DB_DataObject::debugLevel();
         return DbWrapper::fetchDatas($oLink->_resultFields, $aCloneData, $fetchMode);
    }

 /**
     * Find LinkData And ProjectPageData
     *
     * Resulting SQL
     * 		SELECT
     * 			*
     * 		FROM
     * 			 rvs_project_page pp
     * 			 , rvs_link ln
     * 		 WHERE
     * 				 pp.rvs_link_id = ln.rvs_link_id
     * 				AND ln.rvs_link_id = {$inkId}
     * 				AND pp.project_page_id = {$projectPageId}
     *
     * @author duangdao.k
     * @param string $inkId
     * @param string $projectPageId
     * @param string $fetchMode
     * @return arrayobj
     */
    public function findLinkDataAndProjectPageData($inkId = null, $projectPageId = null, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
        if (!is_null($inkId) && !is_null($projectPageId)) {
            $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($inkId)
                  , RvsLibs_String::quoteSmart($projectPageId)
             );
              $oLink->query($query);
        }

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

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

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


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

    public function findLinkOptionDialogByProject($projectId = null, $fetchMode = 'getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);

    	DB_DataObject::debugLevel(0);
    	$oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);

    	$query = sprintf('
                SELECT
                    ln.rvs_link_id
                FROM
                    %s pp
                    , %s ln
                    , %s pl
                WHERE
                    pp.rvs_link_id = ln.rvs_link_id
                    AND pp.project_page_id = pl.project_page_id
                    AND ln.dialog_option != ""
                    AND pl.project_id = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_link']
                , $this->aConf['table']['rvs_project_layout_page']
                , RvsLibs_String::quoteSmart($projectId)
                );
        $oLink->query($query);
        $aCloneData = array();
        while ($oLink->fetch()) {
            $aCloneData[] = clone($oLink);
        }
        return DbWrapper::fetchDatas($oLink->_resultFields, $aCloneData, $fetchMode);
    }

    public function findLinkByProjectProjectPage($projectPage=null, $fetchMode='getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel(0);
    	$oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
    	$query = sprintf('
                SELECT
                    ln.*
                FROM
                    %s pp
                    , %s ln
                WHERE
                    pp.rvs_link_id = ln.rvs_link_id
                    AND pp.project_page_id = %s
                '
                , $this->aConf['table']['rvs_project_page']
                , $this->aConf['table']['rvs_link']
                , RvsLibs_String::quoteSmart($projectPage)
                );
        $oLink->query($query);
        $aCloneData = array();
        while ($oLink->fetch()) {
        	$aCloneData[] = clone($oLink);
        }
        return DbWrapper::fetchDatas($oLink->_resultFields, $aCloneData, $fetchMode);
    }

 //------------------------------------ Insert -----------------------------//

    /**
     * insert Link Data
     *
     * Resulting SQL
     *  		INSERT INTO
     * 			  rvs_link
     * 				(
     * 				 rvs_link_id
     * 				 , fullscreen
     * 				 , external_url
     * 				 , toolbar
     * 				 , location
     * 				 , status_bar
     * 				 , menubar
     * 				 , resizeable
     * 				 , scrollbars
     * 				, size_width
     * 				 , size_height
     * 				 )
     * 			VALUES
     * 				 (
     * 				  {$rvsLinkId}
     * 			 	 , {$fullscreen}
     * 				  ,{$externalUrl}
     * 				 , {$toolbar}
     * 				 , {$location}
     * 				 , {$statusBar}
     * 				 , {$menubar}
     * 			 	 , {$resizeable}
     * 				 , {$scrollbars}
     * 				 , {$sizeWidth}
     * 				 , {$sizeHeight}
     * 				 )
     *
     * @author duangdao.k
     * @param array $aLinkOption
     *          $aLinkOption = array(
                    'rvsLinkId' => $rvsLinkId,
                    'fullscreen' => 1,
                    'externalUrl' => 'http://rvglobalsoft',
                    'toolbar' => 1,
                    'location' => 1,
                    'statusBar' => 1,
                    'menubar' => 1,
                    'resizeable' => 1,
                    'scrollbars' => 1,
                    'sizeWidth' => 0,
                    'sizeHeight' => 0,
        );

     * @return bool
     */
    public function insertLinkData($aLinkOption)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);

        DB_DataObject::debugLevel(0);
        $oLnk =  DB_DataObject::factory($this->aConf['table']['rvs_link']);
        $query = sprintf('
			 INSERT INTO
                        %s
                        (
						 rvs_link_id
						 , dialog_option
						 , fullscreen
						 , external_url
						 , toolbar
						 , location
						 , status_bar
						 , menubar
						 , resizeable
						 , scrollbars
						 , size_width
						 , size_height
						 )
				 VALUES
				 		 (
							%s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
							 , %s
                             )
                    '
                    , $this->aConf['table']['rvs_link']
                    , RvsLibs_String::quoteSmart($aLinkOption['rvsLinkId'])
                    , RvsLibs_String::quoteSmart($aLinkOption['dialog_option'])
                    , RvsLibs_String::quoteSmart($aLinkOption['fullscreen'])
                    , RvsLibs_String::quoteSmart($aLinkOption['externalUrl'])
                    , RvsLibs_String::quoteSmart($aLinkOption['toolbar'])
                    , RvsLibs_String::quoteSmart($aLinkOption['location'])
                    , RvsLibs_String::quoteSmart($aLinkOption['statusBar'])
                    , RvsLibs_String::quoteSmart($aLinkOption['menubar'])
                    , RvsLibs_String::quoteSmart($aLinkOption['resizeable'])
                    , RvsLibs_String::quoteSmart($aLinkOption['scrollbars'])
                    , RvsLibs_String::quoteSmart($aLinkOption['sizeWidth'])
                    , RvsLibs_String::quoteSmart($aLinkOption['sizeHeight'])
            );
            $res = $oLnk->query($query);
            DB_DataObject::debugLevel();
            return (isset($res) && $res) ? true : false;
    }

    /**
     * can combine the data into a single database query
     * @param $aValue
     * 					$aValue = array(
     * 						'("value1-of-row1", "value2-of-row1")'
     * 						, '("value1-of-row2", "value2-of-row2")'
     * 					);
     * @return unknown_type
     */
    public function insertLinkData2($aValue, $aField)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);

       $query = RvsLibs_DB::genInsertSqlCommand(
            $this->aConf['table']['rvs_link']
            , $aValue
            , $aField
        );
		if ($query != '') {
			$oLnk =  DB_DataObject::factory($this->aConf['table']['rvs_link']);
	        $res = $oLnk->query($query);
	        DB_DataObject::debugLevel();
	        return (isset($res) && $res) ? true : false;
		} else {
			return false;
		}
    }

 // ------------------------------------ Update ----------------------------//
 /**
  *Update LinkData By UsrId And rojectId And lnkId
  *
  *  Resulting SQL
  * 		UPDATE
  * 			rvs_link as ln
  * 			, rvs_project_page as pa
  *  			, rvs_project_layout_page as pl
  * 		 SET
  * 			 ln.fullscreen = {$fullscreen}
  * 			, ln.external_url ={$externalUrl}
  *            , ln.toolbar ={$toolbar}
  *            , ln.location ={$location}
  *            , ln.status_bar = {$statusBar}
  *            , ln.menubar = {$menubar}
  *            , ln.resizeable = {$resizeable}
  *            , ln.scrollbars= {$scrollbars}
  *             , ln.size_width = {$sizeWidth}
  *             , ln.size_height = {$sizeHeight}
  * 		  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 array $aLinkOption
           $aLinkOption = array(
                    'rvsLinkId' => $rvsLinkId,
                    'fullscreen' => 1,
                    'externalUrl' => 'http://rvglobalsoft',
                    'toolbar' => 1,
                    'location' => 1,
                    'statusBar' => 1,
                    'menubar' => 1,
                    'resizeable' => 1,
                    'scrollbars' => 1,
                    'sizeWidth' => 0,
                    'sizeHeight' => 0,
        );
  * @param string $usrId
  * @param string $projectId
  * @return bool
  */
 public function updateLinkDataByUsrIdAndrojectIdAndlnkId($aLinkOption, $usrId, $projectId)
 {
     SGL::logMessage(null, PEAR_LOG_DEBUG);

     DB_DataObject::debugLevel();
     $oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
     $query = sprintf('
     	UPDATE
         		%s as ln
                 , %s as pa
                  , %s as pl

           SET
                ln.dialog_option = %s
                 ,ln.fullscreen = %s
                 , ln.external_url = %s
                 , ln.toolbar = %s
                 , ln.location = %s
                 , ln.status_bar = %s
                 , ln.menubar = %s
                 , ln.resizeable = %s
                 , ln.scrollbars = %s
                  , ln.size_width = %s
                  , ln.size_height = %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']
          , RvsLibs_String::quoteSmart($aLinkOption['dialog_option'])
          , RvsLibs_String::quoteSmart($aLinkOption['fullscreen'])
          , RvsLibs_String::quoteSmart($aLinkOption['externalUrl'])
          , RvsLibs_String::quoteSmart($aLinkOption['toolbar'])
          , RvsLibs_String::quoteSmart($aLinkOption['location'])
          , RvsLibs_String::quoteSmart($aLinkOption['statusBar'])
          , RvsLibs_String::quoteSmart($aLinkOption['menubar'])
          , RvsLibs_String::quoteSmart($aLinkOption['resizeable'])
          , RvsLibs_String::quoteSmart($aLinkOption['scrollbars'])
          , RvsLibs_String::quoteSmart($aLinkOption['sizeWidth'])
          , RvsLibs_String::quoteSmart($aLinkOption['sizeHeight'])
          , RvsLibs_String::quoteSmart($usrId)
          , RvsLibs_String::quoteSmart($projectId)
          , RvsLibs_String::quoteSmart($aLinkOption['rvsLinkId'])
       );
       //SGL::logMessage($query, PEAR_LOG_DEBUG);
       $res = $oLink->query($query);
       DB_DataObject::debugLevel();
       return $res;
 }

 //--------------------------------------Delete------------------------------//

 /*delete link by rvs_link_id
  * @param <string> $usrId
  * @return Bool
  */
 public function deleteLinkById($linkId)
 {
 	SGL::logMessage(null, PEAR_LOG_DEBUG);
 	DB_DataObject::debugLevel();
 	$oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
 	$res = false;
 	if (!empty($linkId)) {
 		$oLink->get('rvs_link_id', $linkId);
 		$res = $oLink->delete();
 	}
 	return $res;

 }

 public function deleteLinkByProjectPage($projectPage)
 {
 	$res = DaoFactory::Link()->findLinkByProjectProjectPage($projectPage, 'getrowobj');
 	if (isset($res->rvs_link_id) && !empty($res->rvs_link_id)) {
 		DaoFactory::Link()->deleteLinkById($res->rvs_link_id);
 		return true;
 	}
 	return false;
 }

 public function backupsql($projectId, $usrId, $aLinkId=array())
 {
 	SGL::logMessage(null, PEAR_LOG_DEBUG);
 	$aSQLData = array();
 	/*
 	 /// Get $aProjectPageId From rvs_project_layout_page by project_id
 	 $aProjectPageId = DaoFactory::ProjectLayoutPage()->findProjectLayoutPage($projectId, 'getassoc');
 	 /// Get $aProjectPageId From internal page
 	 $aInternalPage = DaoFactory::InternalPage()->findInternalProjectPageIdByProjectId($projectId, 'getassoc', $aResultFields = array('project_page_id'));
 	 $aProjectPageId = array_merge($aProjectPageId, $aInternalPage);
 	 */
 	if (count($aLinkId) <= 0) {
 		$aLinkId = DbWrapper::getLinkId($projectId, $usrId);
 	}
 	foreach ($aLinkId as $linkId) {
 		$oLink = DaoFactory::Link()->findAllDataByLinkId($linkId, 'getDataObject');
 		foreach ($oLink as $k => $v) {
 			$aSQLData[] = DbWrapper::buildSQLFormat($v);
 		}
 	}
 	return $aSQLData;
 }

 public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array())
 {
 	SGL::logMessage(null, PEAR_LOG_DEBUG);
 	$aLinkId = DbWrapper::getLinkId($projectId, $usrId);
 	if (count($aLinkId)) {
 		$oLink = DB_DataObject::factory($this->aConf['table']['rvs_link']);
 		foreach ($aLinkId as $linkId) {
 			if (!empty($linkId)) {
 				$oLink->get('rvs_link_id', $linkId);
 				$oLink->delete();
 			}
 		}
 	}
 }
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez