CHips L MINI SHELL

CHips L pro

Current Path : /proc/3/root/usr/local/rvglobalsoft/rvglobalsoft/modules/rvglobalsoft/classes/
Upload File :
Current File : //proc/3/root/usr/local/rvglobalsoft/rvglobalsoft/modules/rvglobalsoft/classes/ResellerctrlMgr.pm

#!/usr/bin/perl
package ResellerctrlMgr;

#@LICENSE@#
use strict;
use warnings;
use base qw(RVL::Manager);
use Class::Std::Utils;
{

	sub new {
		my ( $class, $opt ) = @_;
		my ($this) = $class->SUPER::new($opt);
		$this->{pageTitle} = 'Home';
		$this->{template}  = 'resellerctrl.html';

		$this->{_aActionsMapping} = {
			'view' => ['view'],
			'add'  => [ 'add'],
		};

		return $this;
	}

	sub validate {
		my ( $this, $req, $input ) = @_;
		RVL::logMessage( '', __CONSTANT__::RVL_LOG_DEBUG );

		${$input}->{masterTemplate} = $this->{masterTemplate};
		${$input}->{template}       = $this->{template};
		${$input}->{pageTitle}      = $this->{pageTitle};
		$this->{validated} = 1;

		${$input}->{action} =
		  $req->get('action') ? $req->get('action') : 'view';

		my ($obj) = RVL::Output::singleton();
		if ( !Libs::Rvglobalsoft::singleton()->isAcceptLicense() ) {
			$obj->redirect( 'rvglobalsoft', 'licenseagreement', '' );
			$this->{validated} = 0;
		}
		elsif (!Libs::Rvglobalsoft::singleton()->isSetupApiKey()
			|| !Libs::Rvglobalsoft::singleton()->oAuthOnReady() )
		{
			RVL::raiseMsg( 'This is your first time visit. You need to set up API key before proceeding. <br />You have to insert your Registered Email and API Key',
				0, __CONSTANT__::RVL_MESSAGE_ERROR );
			$obj->redirect( 'rvglobalsoft', 'apikeysetup', '' );
			$this->{validated} = 0;
		}
		elsif ( ${$input}->{action} eq 'add' ) {
			${$input}->{res_accres} =
			  $req->get('res_accres') ? $req->get('res_accres') : '0';
		}
	}

	sub _cmd_view {
		my ( $this, $input, $output ) = @_;
		RVL::logMessage( '', __CONSTANT__::RVL_LOG_DEBUG );
		my ($oAuth) = Libs::Rvglobalsoft::oAuthConnect();
		if ( Libs::Rvglobalsoft::getAllowReseller() ) {
			${$output}->{'res_accres_1_checked'} = ' checked="checked"';
			${$output}->{'allowReseller'}        = '1';
		}
		else {
			${$output}->{'res_accres_0_checked'} = ' checked="checked"';
			${$output}->{'allowReseller'}        = '0';
		}

		if ( ref $oAuth ne 'RVL::oAuth' ) {
			my ($errorMsg) = RVL::Error::pop()->{message};
			RVL::raiseMsg($errorMsg);
		}
		else {
			my ($resellerList) = {};
			foreach my $reseller (
				@{ RVL::CpHandle::singleton()->getResellerList() } )
			{
				$resellerList->{$reseller} =
				  Libs::Rvglobalsoft::getResellerEnableRVGS($reseller);
			}

			${$output}->{'resellerList'} = $resellerList;
			my ($data) = $oAuth->request( 'get', 'commission' );
			if ( $oAuth->isError() ) {
				my ($errorMsg) = RVL::Error::pop()->{message};
				RVL::raiseMsg($errorMsg);
			}
			else {
				${$output}->{'commission'} = $data->{commission};
			}
		}
	}

	sub _cmd_add {
		my ( $this, $input, $output ) = @_;
		RVL::logMessage( '', __CONSTANT__::RVL_LOG_DEBUG );
		if ( $input->{res_accres} ) {
			Libs::Rvglobalsoft::setAllowReseller(1);
		}
		else {
			Libs::Rvglobalsoft::setAllowReseller(0);
		}
		RVL::raiseMsg( 'Restrict Reseller successfully updated',
			0, __CONSTANT__::RVL_MESSAGE_SUCCESS );
			
		RVL::Output::singleton()->redirect('rvglobalsoft', 'resellerctrl' , 'view');
	}

	sub display {
		my ( $this, $output ) = @_;
		RVL::logMessage( '', __CONSTANT__::RVL_LOG_DEBUG );

	}

}
1;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez