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

class CategoryDao extends DbWrapper implements SitebuilderInf
{

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

	/**
	 * Returns a singleton CategoryDao 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 all category data
     * @author Parinya Chaipetch
     *
     * @param string $fecthMode
     * @access public
     * @return array
     */
    public function findAllCategoryData($fecthMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_category']);
        $oCategory->selectAdd();
        $oCategory->selectAdd('rvs_category_id, category_name');
        $oCategory->orderBy('category_name');
        $oCategory->find();
        $aCloneData = array();
        while ($oCategory->fetch()) {
            $aCloneData[]= clone($oCategory);
        }
        return DbWrapper::fetchDatas($oCategory->_resultFields, $aCloneData, $fecthMode);
    }

    /**
     * Find category name by category id
     * @tutorial SQL Command
     *      SELECT
     *           category_name
     *      FROM
     *           rvs_category
     *      WHERE
     *           rvs_category_id = xxx
     *
     * @author Parinya Chaipetch
     * @param string $categoryId
     * @param string $fecthMode
     * @access public
     * @return array
     */
    public function findCategoryNameByCategoryId($categoryId=null, $fecthMode='getassoc', $aResultFields = array('category_name'))
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_category']);

        if (!is_null($categoryId)) {
            $oCategory->rvs_category_id = $categoryId;
        }
        $oCategory->find();
        $aCloneData = array();
        while ($oCategory->fetch()) {
            $aCloneData[]= clone($oCategory);
        }
        $aResultFields = DbWrapper::buildResultFields($oCategory, $aResultFields);
        return DbWrapper::fetchDatas($aResultFields, $aCloneData, $fecthMode);
    }

    public function findCategoryIdByCategoryShName($fecthMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_category']);
        $query = sprintf('
                        SELECT
                                  category_sh_name,rvs_category_id
                        FROM
                                    %s
                            '
                            , $this->aConf['table']['rvs_category']
                            );
        $oCategory->query($query);
        $aCloneData = array();
        while ($oCategory->fetch()) {
            $aCloneData[]= clone($oCategory);
        }
        return DbWrapper::fetchDatas($oCategory->_resultFields, $aCloneData, $fecthMode);
    }

    /**
     * find Associated Category
     * @author Pharadol
     * @param <string> $fecthMode
     * @return array
     * form file ImportTemplateMgr.php
     *        /*
        $query = "
                        SELECT
                                    rvs_category_id
                                    , category_name
                        FROM
                                    {$this->conf['table']['rvs_category']}
                        ORDER BY
                                    rvs_category_id
                        ";
        $aSubCategory2 = $this->dbh->getAssoc($query);
        */

    public function findCategoryOrderByCategoryId($fecthMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_category']);
        $oCategory->selectAdd();
        $oCategory->selectAdd('rvs_category_id, category_name');
        $oCategory->orderBy('rvs_category_id');
        $oCategory->find();
        $query = sprintf('
                        SELECT
                                  rvs_category_id
                                    , category_name
                        FROM
                                    %s
                        ORDER BY
                                    rvs_category_id
                            '
                            , $this->aConf['table']['rvs_category']
                            );

        $oCategory->query($query);

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

    public function findCustomCategoryOrderByCategoryId($fecthMode='getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_custom_category']);
        $query = sprintf('
                        SELECT
                                  *
                        FROM
                                    %s
                        ORDER BY
                                    custom_category_id
                        DESC
                            '
                            , $this->aConf['table']['rvs_custom_category']
                            );
        $oCategory->query($query);
        $aCloneData = array();
        while ($oCategory->fetch()) {
            $aCloneData[]= clone($oCategory);
        }
        return DbWrapper::fetchDatas($oCategory->_resultFields, $aCloneData, $fecthMode);
    }

    public function findCustomCategoryByCateId($cateId, $ownerId, $fecthMode='getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel();
    	$oCategory = DB_DataObject::factory($this->aConf['table']['rvs_custom_category']);
    	$query = sprintf('
                        SELECT
                                  custom_category_id
    							  , custom_category_name
                        FROM
                                    %s
    					WHERE
    						custom_category_user = %s
    						AND custom_category_id = %s
                        ORDER BY
                                  custom_category_id
                            '
    			, $this->aConf['table']['rvs_custom_category']
    			, RvsLibs_String::quoteSmart($ownerId)
    			, RvsLibs_String::quoteSmart($cateId)
    			);
    	$oCategory->query($query);
    	$aCloneData = array();
    	while ($oCategory->fetch()) {
    		$aCloneData[]= clone($oCategory);
    	}
    	return DbWrapper::fetchDatas($oCategory->_resultFields, $aCloneData, $fecthMode);
    }

    public function findCategoryNameByCustomCategoryId($categoryId=null, $fecthMode='getassoc', $aResultFields = array('category_name'))
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oCategory = DB_DataObject::factory($this->aConf['table']['rvs_custom_category']);

        if (!is_null($categoryId)) {
            $oCategory->rvs_category_id = $categoryId;
        }
        $oCategory->find();
        $aCloneData = array();
        while ($oCategory->fetch()) {
            $aCloneData[]= clone($oCategory);
        }
        $aResultFields = DbWrapper::buildResultFields($oCategory, $aResultFields);
        return DbWrapper::fetchDatas($aResultFields, $aCloneData, $fecthMode);
    }

    //-----------------------------------------INSERT-----------------------------------------
    public function insertTemplateCustomCategory($customCategoryId, $categoryName, $categorySh, $userStatus)
    {
            SGL::logMessage(null, PEAR_LOG_DEBUG);
            DB_DataObject::debugLevel(0);
            $oCategory =  DB_DataObject::factory($this->aConf['table']['rvs_custom_category']);
            $query = sprintf(" INSERT INTO
                                    %s
                                    (
                                    custom_category_id
                                    , custom_category_name
                                    , custom_category_sh
                                    , custom_category_user
                                    )
                                    VALUE
                                    (
                                    %s
                                    , %s
                                    , %s
                                    , %s
                                    )
                                  "
                                  , $this->aConf['table']['rvs_custom_category']
                                  , RvsLibs_String::quoteSmart($customCategoryId)
                                  , RvsLibs_String::quoteSmart($categoryName)
                                  , RvsLibs_String::quoteSmart($categorySh)
                                  , RvsLibs_String::quoteSmart($userStatus)
                                  );
            $res = $oCategory->query($query);
            DB_DataObject::debugLevel();
            return (isset($res) && $res) ? true : false;
    }

    public function deleteTemplateCategoryAdmin($categoryId, $usrStatus)
    {
            SGL::logMessage(null, PEAR_LOG_DEBUG);
            DB_DataObject::debugLevel(0);
            $oCategory =  DB_DataObject::factory($this->aConf['table']['rvs_custom_category']);
            $query = sprintf(" DELETE  FROM
                                                               %s
                                                     WHERE
                                                              custom_category_user = %s
                                                              AND custom_category_id = %s
                                    "
                                    , $this->aConf['table']['rvs_custom_category']
                                    , RvsLibs_String::quoteSmart($usrStatus)
                                    , RvsLibs_String::quoteSmart($categoryId)
                                    );
            $res = $oCategory->query($query);
	        return (isset($res) && $res) ? true : false;
    }

   public function backupsql($projectId, $usrId)
   {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       $aSQLData = array();
       /// Get Project info id By project_id
       $oProjectInfoId = DaoFactory::Project()->findProjectInfoDataByProjectId($projectId, 'getDataObject');
       foreach ($oProjectInfoId as $key => $val) {
           /// Backup table rvs_category
           if (!empty($val->rvs_category_id)) {
           		$oCategory = $this->findCategoryNameByCategoryId($val->rvs_category_id, 'getDataObject', $aResultFields = array());
           		foreach ($oCategory as $k => $v) {
           			$aSQLData[] = DbWrapper::buildSQLFormat($v);
           		}
           }
       }
       return $aSQLData;
   }

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