HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/PictureDao.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 pictures of RVSiteBuilder  
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  Parinya <parinya@rvglobalsoft.com>
 * @version $Revision$
 * @since   PHP 5.1
 */

class PictureDao extends DbWrapper implements SitebuilderInf
{
	
	function PictureDao()
	{
		parent::DbWrapper();
	}
	
	/**
	 * Returns a singleton PictureDao instance.
	 *
	 * @param bool $autoload
	 * @return obj
	 */
	public static function singleton($autoload=false)
    {
        static $instance;
        // If the instance is not there, create one
        if (!isset($instance) || $autoload) {
            $class = __CLASS__;
            $instance = new $class();
        }
        return $instance;
    }
    
	public function  findPicturesByTemplateID($templateId=null, $fetchMode='getassoc')
	{
	    $oTemplateItem = DB_DataObject::factory($this->aConf['table']['rvs_template_item']);
        $oPicture = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
        $oTemplateItem->joinAdd($oPicture);

            $oTemplateItem->selectAdd(); 
            $oTemplateItem->selectAdd("
            DISTINCT({$this->aConf['table']['rvs_picture']}.picture_id), 
                     {$this->aConf['table']['rvs_picture']}.picture_name");
            $oTemplateItem->orderBy("{$this->aConf['table']['rvs_picture']}.picture_name");
                     if (!is_null($templateId)) {
                         $oTemplateItem->template_id = $templateId;
                          $oTemplateItem->find();
                     }
                     $aCloneData = array();
        while ($oTemplateItem->fetch()) {
           // echo $oTemplateItem->picture_name;
            $aCloneData[]= clone($oTemplateItem);
        }
        return DbWrapper::fetchDatas($oTemplateItem->_resultFields, $aCloneData, $fetchMode);
	}
	
	/**
	 * Find picture_id and picture_name by template_item_id and picture_id from table rvs_picture and rvs_template_item
	 *
	 * @author duangdao.k
	 * @param $string $templateItemId
	 * @param $string $fetchMode
	 * @return  obj
	 */
	public function findPictureNameAndPictureIdByTemplateItemId($templateItemId = null, $fetchMode='getassoc')
	{
	    SGL::logMessage(null, PEAR_LOG_DEBUG);	
		$oProject = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
		if (!is_null($templateItemId)) {
			$query = sprintf('    
			   SELECT DISTINCT
                     (p.picture_id), p.picture_name
                FROM 
                      %s p
                       , %s it
                WHERE 
                         it.template_item_id = %s
                 AND 
                       p.picture_id = it.picture_id
                 '
                 , $this->aConf['table']['rvs_picture']
                 , $this->aConf['table']['rvs_template_item']
                 , RvsLibs_String::quoteSmart($templateItemId)
                 );
                 $oProject->query($query);    
		}
		$aCloneData = array();
        while ($oProject->fetch()) {
            $aCloneData[] = clone($oProject);
        }
        return DbWrapper::fetchDatas($oProject->_resultFields, $aCloneData, $fetchMode);
	}
	
	/**
	 * find picture by picture name
	 * @author pharadol
	 * @param <string> $pictureName
	 * @param <string> $fetchMode
	 * @return <string>
	 * form flle ImportTemplateMgr.php
     /*
        $query = "
                        SELECT
                                    *
                           FROM 
                                       {$this->conf['table']['rvs_picture']}
                           WHERE 
                                       picture_name LIKE '" . RvsLibs_String::trim($input->picture_name) . "'
                    ";
        $aPictureId = $this->dbh->getRow($query);
       */
	public function findPictureIdByPictureName($pictureName = null, $fetchMode = 'getassoc')
	{
	    SGL::logMessage(null, PEAR_LOG_DEBUG);	
		$oProject = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
		if (!is_null($pictureName)) {
	    $query = sprintf('
                        SELECT
                                    *
                           FROM 
                                      %s
                           WHERE 
                                       picture_name LIKE %s
                               '
	                           ,  $this->aConf['table']['rvs_picture']
	                           , RvsLibs_String::quoteSmart($pictureName)
	                           );
	                              $oProject->query($query);    
		}
		
		$aCloneData = array();
        while ($oProject->fetch()) {
            $aCloneData[] = clone($oProject);
        }
        return DbWrapper::fetchDatas($oProject->_resultFields, $aCloneData, $fetchMode);
	}
	
    public function findPictureByPictureId($pictureId = null, $fetchMode = 'getassoc')
	{
	    SGL::logMessage(null, PEAR_LOG_DEBUG);	
		$oProject = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
		if (!is_null($pictureId)) {
		    $oProject->picture_id = $pictureId;	    
		}
		$oProject->find();
		$aCloneData = array();
        while ($oProject->fetch()) {
            $aCloneData[] = clone($oProject);
        }
        return DbWrapper::fetchDatas($oProject->_resultFields, $aCloneData, $fetchMode);
	}
	
	/**
	 * find rvs_picture By picture_id <array>
	 * @author maythapon.p
	 * @param <array> $aPictureId
	 * @param <string> $fetchMode
	 * @return <array>
	 */
	public function findPictureIdByArrayPictureId($aPictureId, $fetchMode = 'getassoc') 
	{
		SGL::logMessage(null, PEAR_LOG_DEBUG);
		$strId = (count($aPictureId) > 1) ? implode("','", $aPictureId) : implode('', $aPictureId);
		$oProject = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
		if ( !is_null($aPictureId) && is_array($aPictureId) ) {
			$query = sprintf ('
						SELECT 
							* 
						FROM 
							%s 
						WHERE 
							picture_id IN (\'%s\');', 
					$this->aConf['table']['rvs_picture'], 
					$strId );
			$oProject->query($query);
		}
		
		$aCloneData = array();
		while ( $oProject->fetch() ) {
			$aCloneData[] = clone($oProject);
		}
		return DbWrapper::fetchDatas($oProject->_resultFields, $aCloneData, $fetchMode);
	}
	
	/**
	 * Insert New picture Name
	 * @author pharadol
	 * @param <string> $uniqueId
	 * @param <string> $pictureName
	 * form file ImportTemplateMgr.php
	 *      
      $query = " 
                        INSERT INTO
                        {$this->conf['table']['rvs_picture']} ( 
                                            picture_id
                                            , picture_name
                                         )
                        VALUES(
                                        '" . RvsLibs_String::trim($input->uniqueId) . "'
                                        ,'" . RvsLibs_String::trim($input->picture_name) . "'
                                     )
                    ";
      $res =  $this->dbh->query($query);    
	 */
	public function insertNewPictureName($uniqueId, $pictureName)
	{
	    SGL::logMessage(null, PEAR_LOG_DEBUG);	
		$oProject = DB_DataObject::factory($this->aConf['table']['rvs_picture']);
	     $query = sprintf(' 
                        INSERT INTO
                                               %s
                                        ( 
                                            picture_id
                                            , picture_name
                                         )
                        VALUES(
                                        %s
                                        , %s
                                        )
                                '
                                , $this->aConf['table']['rvs_picture']
                                , RvsLibs_String::quoteSmart($uniqueId)
                                , RvsLibs_String::quoteSmart($pictureName)
	                            );
	     $oProject->query($query);
	     return  $oProject;
	 }

	 public function backupsql($projectId, $usrId)
	 {
	     SGL::logMessage(null, PEAR_LOG_DEBUG);
	     $aSQLData = array();
	     $aPicture = array();
	     $aTemplateItem = array();
	     $aProjectInfoId = array();
	     /// Get Project info id By project_id
	     $aProjectInfoId = DaoFactory::Project()->findProjectInfoDataByProjectId($projectId, 'getDataObject');
	     if (count($aProjectInfoId) > 0 && !empty($aProjectInfoId[0]->template_item_id)) {
	         $aTemplateItem = DaoFactory::Template()->findTemplateItemByTemplateItemId($aProjectInfoId[0]->template_item_id, 'getDataObject');
	     }
	     /// Backup table rvs_Picture
	     if (count($aTemplateItem) > 0) {
	         $aPicture = $this->findPictureByPictureId($aTemplateItem[0]->picture_id, 'getDataObject');
	         foreach ($aPicture as $oPictureVal) {
	             $aSQLData[] = DbWrapper::buildSQLFormat($oPictureVal);
	         }
	     }
	     return $aSQLData;
   }
    
   public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId=array()) {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
   }
   
   /**
    * find rvs_picture By picture_id
    * @author maythapon
    * @param <array> $aPictureId
    * @return <array> $aSQLData
    */
    public function backupsqlByPictureId($aPictureId)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	$aSQLData = array();
    	
    	$aSQLData[] = '-- rvs_picture by picture_id --' . "\n\n";
    	$aPicture = $this->findPictureIdByArrayPictureId($aPictureId, 'getDataObject');
    	foreach ($aPicture as $oPictureVal) {
    		$aSQLData[] = DbWrapper::buildSQLFormat($oPictureVal);
    	}
    	return $aSQLData;
    }
}
?>