<?php
/**
 * @package    VP Advanced User
 * @author     Abhishek Das <info@virtueplanet.com>
 * @copyright  Copyright (C) 2012-2019 VirtuePlanet Services LLP. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 * @link       https://www.virtueplanet.com
 */

defined('_JEXEC') or die;

// Get current user
$user = JFactory::getUser();

// Access check
if(!$user->authorise('core.manage', 'com_users') || !$user->authorise('core.manage', 'com_vpadvanceduser'))
{
	throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
}

// Load definitions
require_once JPATH_SITE . '/components/com_vpadvanceduser/define.php';

// Register helper class
JLoader::register('VPAdvancedUserHelper', __DIR__ . '/helpers/vpadvanceduser.php');

// Register mailer helper
JLoader::register('VPAdvancedUserHelperMailer', JPATH_SITE . '/components/com_vpadvanceduser/helpers/mailer.php');

// Register avatar helper
JLoader::register('VPAdvancedUserHelperAvatar', JPATH_SITE . '/components/com_vpadvanceduser/helpers/avatar.php');

// Register utility helper
JLoader::register('VPAdvancedUserHelperUtility', JPATH_SITE . '/components/com_vpadvanceduser/helpers/utility.php');

// Load com_users langauge
JFactory::getLanguage()->load('com_users');

// Check system
VPAdvancedUserHelper::checkSystem();

// Execute task
$controller = JControllerLegacy::getInstance('VPAdvancedUser');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();