Your IP : 216.73.216.84


Current Path : /home/helpink/www/components/com_jbusinessdirectory/models/
Upload File :
Current File : /home/helpink/www/components/com_jbusinessdirectory/models/customer.php

<?php
/**
 * @package    J-BusinessDirectory
 *
 * @author     CMSJunkie http://www.cmsjunkie.com/
 * @copyright  Copyright (C) 2007 - 2022 CMSJunkie. All rights reserved.
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html
 */
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Factory;

class JBusinessDirectoryModelCustomer extends JModelLegacy {
	public function __construct() {
		parent::__construct();
	}

	/**
	 * Switch user from the admin(which will have access to this option) to any other user registered on the system
	 *
	 * @param $data array with all post data from form
	 * @return bool
	 *
	 * @since 4.9.0
	 */
	public function switchUser($data) {
		jimport('joomla.database.database.mysql');

		$db = JFactory::getDbo();
		$q = "SELECT * FROM `#__users` WHERE id = ".$data["user_id"] . " order by name";
		$newUser = $db->setQuery($q)->loadAssoc();

		PluginHelper::importPlugin('user');

		// Initiate log in
		$options = array('action' => 'core.login.site', 'remember' => false);
		if (Factory::getApplication()->triggerEvent('onUserLogin', array($newUser,$options))[0]) {
			return true;
		} else {
			return false;
		}
	}
}