File: //opt/cloudlinux/alt-php53/root/usr/share/pear/RVSeagullMod/lib/RVSGL/SitebuilderDao/PublishDao.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 publish projects of RVSiteBuilder
*
* @package sitebuilder
* @author Pairote Manunphol <pairote@rvglobalsoft.com>
* @author Parinya <parinya@rvglobalsoft.com>
* @version $Revision$
* @since PHP 5.1
*/
class PublishDao extends DbWrapper implements SitebuilderInf
{
function PublishDao()
{
parent::DbWrapper();
}
/**
* Returns a singleton PublishDao 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 getDomain($domain = null) {
$oPublish = DB_DataObject::factory($this->aConf['table']['rvs_publish']);
$query = sprintf('
SELECT
rvs_publish_domain
FROM
%s
WHERE
rvs_publish_domain = %s'
, $this->aConf['table']['rvs_publish']
, RvsLibs_String::quoteSmart($domain)
);
SGL::logMessage('url ' . $domain, PEAR_LOG_DEBUG);
$res = $oPublish->query($query);
return $res;
}
// SELECT //
/**
* find AllPublish Data By ProjectId And UserFolder And PublishDomain Or ProjectId in rvs_publish
* @author Pornthip Phothong
* @param $projectId
* @param $userFolder
* @param $publishDomain
* @return array obj
* from file PublishSiteMgr.php
/* $query = sprintf('
SELECT
*
FROM
%s
WHERE
project_id = %s
'
, $this->conf['table']['rvs_publish']
, RvsLibs_String::quoteSmart($input->project_id)
);
$aPublish = $this->dbh->getAssoc($query);
*/
public function findAllPublishDataByProjectIdAndUserFolderAndPublishDomainOrProjectId($projectId=null, $userFolder=null, $publishDomain=null, $fetchMode='getassoc')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oPublish = DB_DataObject::factory($this->aConf['table']['rvs_publish']);
if (!is_null($projectId)) {
$query = sprintf('
SELECT
*
FROM
%s
'
, $this->aConf['table']['rvs_publish']
);
if ($userFolder) {
$query .= sprintf('
WHERE
project_id = %s
AND rvs_publish_path = %s
AND rvs_publish_domain = %s
'
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($userFolder)
, RvsLibs_String::quoteSmart($publishDomain)
);
} else {
$query .= sprintf('
WHERE
project_id = %s
'
, RvsLibs_String::quoteSmart($projectId)
);
}
$oPublish->query($query);
}
$aCloneData = array();
while ($oPublish->fetch()) {
$aCloneData[] = clone($oPublish);
}
DB_DataObject::debugLevel();
return DbWrapper::fetchDatas($oPublish->_resultFields, $aCloneData, $fetchMode);
}
// INSERT //
/**
* insert Publish Data in rvs_publish table
* @author Pornthip Phothong
* @param $projectId
* @param $publishDomain
* @param $publishPath
* @return bool
* from file PublishSiteMgr.php
/* $query = "
INSERT INTO
{$this->conf['table']['rvs_publish']}
(
project_id
, rvs_publish_protocal
, rvs_publish_domain
, rvs_publish_path
)
VALUES (
'$input->project_id'
, '$input->rvsPublishProtocal'
, '$input->rvs_publish_domain'
, '$input->UserFolder'
)";
$aPublish = $this->dbh->query($query);
*/
public function insertPublishData($projectId, $publishDomain, $publishPath, $publishProtocal = 'http')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oPublish = DB_DataObject::factory($this->aConf['table']['rvs_publish']);
$query = sprintf('
INSERT INTO
%s
(
project_id
, rvs_publish_protocal
, rvs_publish_domain
, rvs_publish_path
)
VALUES (
%s
, %s
, %s
, %s
);
'
, $this->aConf['table']['rvs_publish']
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($publishProtocal)
, RvsLibs_String::quoteSmart($publishDomain)
, RvsLibs_String::quoteSmart($publishPath)
);
$res = $oPublish->query($query);
return (isset($res)&& $res)? true : false;
}
// UPDATE //
/**
* update Publish Data By ProjectId And PublishDomain And UserFolder And UsrId in rvs_publish and rvs_project table
*
* UPDATE
* {$this->conf['table']['rvs_publish']} as pb
* ,{$this->conf['table']['rvs_project']} as pp
* SET
* pb.rvs_publish_domain = '$input->rvs_publish_domain'
* , pb.rvs_publish_path = '$input->UserFolder'
* WHERE
* pb.project_id = pp.project_id
* AND pb.project_id = '$input->project_id'
* AND pb.rvs_publish_domain = '$input->rvs_publish_domain'
* AND pb.rvs_publish_path = '$input->UserFolder'
* AND pp.rvs_usr_id = '$input->rvs_usr_id'
*
* @author Pornthip Phothong
* @param $projectId
* @param $publishDomain
* @param $userFolder
* @param $usrId
* from file PublishSiteMgr.php
*/
public function updatePublishDataByProjectIdAndPublishDomainAndUserFolderAndUsrId($projectId, $publishDomain, $userFolder, $publishPath, $usrId, $publishProtocal = 'http')
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel(0);
$oPublish = DB_DataObject::factory($this->aConf['table']['rvs_publish']);
$query = sprintf('
UPDATE
%s as pb
, %s as pp
SET
pb.rvs_publish_protocal = %s
, pb.rvs_publish_domain = %s
, pb.rvs_publish_path = %s
, pb.rvs_domain_path = %s
WHERE
pb.project_id = %s
AND pp.rvs_usr_id = %s
And pb.project_id = pp.project_id
'
, $this->aConf['table']['rvs_publish']
, $this->aConf['table']['rvs_project']
, RvsLibs_String::quoteSmart($publishProtocal)
, RvsLibs_String::quoteSmart($publishDomain)
, RvsLibs_String::quoteSmart($userFolder)
, RvsLibs_String::quoteSmart($publishPath)
, RvsLibs_String::quoteSmart($projectId)
, RvsLibs_String::quoteSmart($usrId)
);
$res = $oPublish->query($query);
DB_DataObject::debugLevel();
return $res;
}
// DELETE //
/**
* delete publish user by userid and projectid
$query = "
DELETE
{$this->conf['table']['rvs_publish']} as pb
FROM
{$this->conf['table']['rvs_publish']} as pb
, {$this->conf['table']['rvs_project']} as p
WHERE
pb.project_id = p.project_id
AND p.rvs_usr_id = '$input->rvs_usr_id'
AND p.project_id = '$input->project_id'
";
* @author Pharadol
* @param <string> $projectId
* @param <string> $usrId
* @return bool
*
* @see form file RemoveProjectMgr.php
*/
public function deletePublishByUsrIdAndProjectId($projectId, $usrId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
DB_DataObject::debugLevel();
$oPublish = DB_DataObject::factory($this->aConf['table']['rvs_publish']);
$res = false;
if (!empty($projectId) && $oPublish->get('project_id', $projectId)) {
$oPublish->project_id = $projectId;
$res = $oPublish->delete();
}
return $res;
}
public function backupsql($projectId, $usrId)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$aSQLData = array();
/// Backup table rvs_publish
$oPublish = $this->findAllPublishDataByProjectIdAndUserFolderAndPublishDomainOrProjectId($projectId, null, null, 'getDataObject');
foreach ($oPublish as $k => $v) {
$aSQLData[] = DbWrapper::buildSQLFormat($v);
}
return $aSQLData;
}
public function deleteProjectOfUserId($projectId, $usrId, $aProjectPageId=array())
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$result = DaoFactory::Publish()->deletePublishByUsrIdAndProjectId($projectId, $usrId);
}
}
?>