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/JotformDao.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 Jotform of RVSiteBuilder
 *
 * @package sitebuilder
 * @author  Pairote Manunphol <pairote@rvglobalsoft.com>
 * @author  
 * @version $Revision$
 * @since   PHP 5.1
 */
class JotformDao extends DbWrapper implements SitebuilderInf
{

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

    /**
     * Returns a singleton JotformDao 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 Data List Jot Form by username :: project id
     * @othor darawan 25/02/53
     * @param <string> $projectId
     * @param <string> $fetchMode
     * @return array
     * not unit test
     */
    public function findListJotFormById($formId, $fetchMode = 'getassoc')
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel(0);
        $oJotForm = DB_DataObject::factory($this->aConf['table']['forms']);
        if (is_array($formId) == false) {
            $oJotForm->id  = $formId;
        } else {
        	$oJotForm->whereAdd('id IN (\'' . trim(implode('\',\'', $formId), ',') . '\')');
        }
        $oJotForm->find();
        $aCloneData = array();
        while ($oJotForm->fetch()) {
            $aCloneData[] = clone($oJotForm);
        }
        DB_DataObject::debugLevel();
        return DbWrapper::fetchDatas($oJotForm->_resultFields, $aCloneData,  $fetchMode);
    }
    
    
      /**
      * find value prop By form id
       * @author darawan
       * @param <string> $formId
       * @param <string> $prop
       * @return array
       */
    public function findJotFormQuestionPropertiesByFormIdAndProp($formId, $prop, $fetchMode = 'getassoc')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	DB_DataObject::debugLevel(0);
    	$oJotForm = DB_DataObject::factory($this->aConf['table']['question_properties']);
    	$query = sprintf('
                        				SELECT 
                             			 *
                        				FROM 
                                    		%s
                        				WHERE 
                                    		form_id = %s
                                    	AND 
                                    		prop = %s
                              		'
                              	,	$this->aConf['table']['question_properties']
                              	, RvsLibs_String::quoteSmart($formId)
                              	, RvsLibs_String::quoteSmart($prop)
                              	);
                              
      	$oJotForm->query($query);

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

    
    public function insertForms($jotFormId, $userId, $title, $height, $status)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oOnlineForm = DB_DataObject::factory($this->aConf['table']['forms']);
        $query = sprintf('INSERT INTO %s
                                        ( 
                                            id
                                            , username
                                            , title
                                            , height
                                            , status
                                         )
                    				VALUES 
                    					(
                                         	%s
                                         	, %s
                                         	, %s
                                         	, %s
                                         	, %s
                                    	)
                                    	'
                                , $this->aConf['table']['forms']
                                , RvsLibs_String::quoteSmart($jotFormId)
								, RvsLibs_String::quoteSmart($userId)
								, RvsLibs_String::quoteSmart($title)
								, RvsLibs_String::quoteSmart($height)
								, RvsLibs_String::quoteSmart($status)
                                );
    	$oOnlineForm->query($query);
    }
    
    public function insertQuestions($jotFormId, $formId)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oOnlineForm = DB_DataObject::factory($this->aConf['table']['questions']);
        $query = sprintf('INSERT INTO %s
        							 SELECT
                                            %s
                                            , id
                                            , %s
                                            , type
                    				FROM %s 
                    				WHERE
                                         	form_id = %s
                                    	'
                                , $this->aConf['table']['questions']
                                , RvsLibs_String::quoteSmart($jotFormId)
								, $this->aConf['table']['questions'] . '.order'
								, $this->aConf['table']['questions']
								, RvsLibs_String::quoteSmart($formId)
                                );
    	$oOnlineForm->query($query);
    }
    
    function insertQuestionsProperties($jotFormId, $formId)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
        DB_DataObject::debugLevel();
        $oOnlineForm = DB_DataObject::factory($this->aConf['table']['question_properties']);
        $query = sprintf('INSERT INTO %s
        							 SELECT
                                            %s
                                            , question_id
                                            , %s
                                            , value
                    				FROM %s 
                    				WHERE
                                         	form_id = %s
                                    	'
                                , $this->aConf['table']['question_properties']
                                , RvsLibs_String::quoteSmart($jotFormId)
								, $this->aConf['table']['question_properties'] . '.prop'
								, $this->aConf['table']['question_properties']
								, RvsLibs_String::quoteSmart($formId)
                                );
    	$oOnlineForm->query($query);
    }
    
    public function backupsql($projectId, $usrId, $aJotformId=array())
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $aSQLData = array();
            // backup jotform
        if (count($aJotformId) <= 0) {
        	$oJotform = DaoFactory::OnlineForm()->findListJotFormByProjectId($projectId, 'getDataObject');
        } else {
        	if (count($aJotformId) > 1) {
        		$oJotform = DaoFactory::Jotform()->findListJotFormById($aJotformId, 'getDataObject');
        	} else {
        		$oJotform = DaoFactory::Jotform()->findListJotFormById($aJotformId[0], 'getDataObject');
        	}
        }
        foreach ($oJotform as $key => $value) {
            $aSQLData[] =  DbWrapper::buildSQLFormat($value);
            $oSqlQuestions = DaoFactory::OnlineForm()->findJotFormQuestionsByFormId($value->id, 'getDataObject');
            foreach ($oSqlQuestions as $keyQuestions => $valQuestions) {
                $aSQLData[] =  DbWrapper::buildSQLFormat($valQuestions);
            }
            $oSqlQuestionProperties = DaoFactory::OnlineForm()->findJotFormQuestionPropertiesByFormId($value->id, 'getDataObject');
            foreach ($oSqlQuestionProperties as $keyProperties => $valProperties) {
                $aSQLData[] =  DbWrapper::buildSQLFormat($valProperties);
            }
            $oSqlQuestionUtf8 = DaoFactory::OnlineForm()->findJotFormQuestionUtf8ByFormId($value->id, 'getDataObject');
            foreach ($oSqlQuestionUtf8 as $key => $val) {
                $aSQLData[] =  DbWrapper::buildSQLFormat($val);
            }
        }
        return $aSQLData;
    }
    
    public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId = array()) 
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        //TODO delete
    }

}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez