#!/usr/bin/perl
package RVL::Manager;
# WebSite: http://www.rvglobalsoft.com
# Unauthorized copying is strictly forbidden and may result in severe legal action.
# Copyright (c) 2013 RV Global Soft Co.,Ltd. All rights reserved.
#
# =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
# Copyright (c) 2013 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 RV2Factor Product for RV Global Soft.
# 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.
# ===============================
use strict;
use warnings;
use RVL::DB;
#use RVL::ServiceLocator;
use Class::Std::Utils;
{
sub new {
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($class, $opt) = @_;
my (%hash);
my ($this) = bless( \%hash, $class);
my ($c) = RVL::Config::singleton();
$this->{conf} = $c->getAll();
if (!defined($this->{conf}->{'db'}->{'enabled'}) || $this->{conf}->{'db'}->{'enabled'} eq '1') {
RVL::logMessage('DB Connection', __CONSTANT__::RVL_LOG_DEBUG);
$this->{dbh} = $this->_getDb();
}
if (defined $this->{conf}->{'site'}->{'masterTemplate'}) {
$this->{masterTemplate} = $this->{conf}->{'site'}->{'masterTemplate'};
}
return $this;
}
sub _getDb {
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($this) = @_;
my ($locator) = new RVL::ServiceLocator;
my $dbh = $locator->get('DB');
if (!$dbh) {
$dbh = RVL::DB::singleton();
$locator->register('DB', $dbh);
}
return $dbh;
}
sub process {
my ($this, $input, $output) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($mgrName) = ref $this;
my ($defaultMgrLoaded) = 0;
${$input}->{action} = 'view' if (!defined ${$input}->{action});
if (!defined $this->{_aActionsMapping}->{ ${$input}->{action} }) {
return RVL::raiseError('The specified method, ' . ${$input}->{action} .
' does not exist', __CONSTANT__::RVL_ERROR_NOMETHOD);
}
if (!defined $this->{conf}) {
return RVL::raiseError('It appears you forgot to fire RVL::Manager\'s '.
'constructor - please add "use base qw(RVL::Manager);" and my ($this) = $class->SUPER::new($opt); in your '.
'new\'s constructor.', __CONSTANT__::RVL_ERROR_NOCLASS);
}
if ( defined $this->{conf}->{$mgrName}->{'requiresAuth'}
&& $this->{conf}->{$mgrName}->{'requiresAuth'} == 1 )
{
}
my ($actionPrefix) = defined ($this->{actionPrefix}) ? $this->{actionPrefix} : '_cmd_';
if (RVL::Error::count() > 0) {
my ($oLastError) = RVL::Error::pop();
$defaultMgrLoaded = 1;
$this->handleError($oLastError, $output);
}
if (!$defaultMgrLoaded) {
# all tests passed, execute relevant method
foreach my $methodName (@{ $this->{ _aActionsMapping }->{ ${$input}->{action} } } ) {
$methodName = $actionPrefix .$methodName;
RVL::logMessage("BEGIN Call: $methodName", __CONSTANT__::RVL_LOG_DEBUG);
$this->$methodName(${$input}, $output);
RVL::logMessage("END Call: $methodName", __CONSTANT__::RVL_LOG_DEBUG);
}
}
}
sub getConfig{
my ($this) = @_;
my ($c) = RVL::Config::singleton();
return $c;
}
sub display{
my ($output) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
# reinstate dynamically added css
if (!${${$output}->{manager}}->isValid()) {
if (defined(${$output}->{aCssFiles}) && @{ ${$output}->{aCssFiles} } > 0) {
# get action
my ($cssFile) = ${$output}->request->get('cssFile');
if (!$cssFile) {
${$output}->addCssFile($cssFile);
}
}
}
}
sub validate{
my ($this, $req, $input) = @_;
}
sub isValid {
my ($this) = @_;
return $this->{validated};
}
sub _cmd_redirectToDefault {
my ($this, $input, $output) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
if (RVL::Error::count() <= 0) {
my ($req) = RVL::Request::singleton();
my ($params) = '/' . $req->get('moduleName') . '/' . $req->get('managerName');
my ($direct) = "index.cgi?$params";
print RVL::Session::singleton()->header(-location => $direct);
exit;
} else {
${$output}->{template} = 'error.html';
}
}
sub handleError {
my ($this, $error, $output) = @_;
${$output}->{template} = 'error.html';
${$output}->{error} = $error;
}
}
1;
Copyright 2K16 - 2K18 Indonesian Hacker Rulez