Spade

Mini Shell

Directory:~$ /proc/self/root/home/lmsyaran/www/khademsharif/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/home/lmsyaran/www/khademsharif/com_helpdeskpro.zip

PK̑�[����Controller/Api.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Controller;

use Exception;
use Joomla\CMS\Language\Text;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;

defined('_JEXEC') or die;

class Api extends \OSL\Controller\Controller
{
	/**
	 * Add ticket
	 *
	 * @throws Exception
	 */
	public function add()
	{
		$this->validateAPIRequest();

		$errors = $this->validateTicketData($this->input);

		if (count($errors))
		{
			$success      = false;
			$responseData = $errors;
		}
		else
		{
			// Make sure id is not provided on a add request
			$this->input->remove('id');

			/* @var \OSSolution\HelpdeskPro\Admin\Model\Ticket $model */
			$model = $this->getModel('Ticket',
['ignore_request' => true]);
			$model->store($this->input);

			$success            = true;
			$responseData['id'] =
$this->input->getInt('id');
		}


		$this->sendResponse($success, $responseData);
	}


	/**
	 * Validate data which is passed to add new ticket
	 *
	 * @param   \OSL\Input\Input  $input
	 *
	 * @return array
	 */
	protected function validateTicketData($input)
	{
		$data = $input->getData();

		$errors = [];

		if (empty($data['user_id']) &&
empty($data['username']))
		{
			// If user id is not provided, name and email must be passed

			if (empty($data['name']))
			{
				$errors[] = Text::_('You need to provide Name of user for this
ticket');
			}

			if (empty($data['email']))
			{
				$errors[] = Text::_('You need to provide email of user for this
ticket');
			}
		}
		else
		{
			$db = $this->container->db;

			// Validate and make user exists
			if (!empty($data['user_id']))
			{
				$userId = (int) $data['user_id'];

				$query = $db->getQuery(true)
					->select('COUNT(*)')
					->from('#__users')
					->where('id = ' . $userId);
				$db->setQuery($query);

				if (!$db->loadResult())
				{
					$errors[] = Text::sprintf('There is no user with ID %s in the
system', $userId);
				}
			}
			else
			{
				$username = $data['username'];

				$query = $db->getQuery(true)
					->select('id')
					->from('#__users')
					->where('username = ' . $db->quote($username));
				$db->setQuery($query);

				$userId          = (int) $db->loadResult();
				$data['user_id'] = $userId;

				if (!$userId)
				{
					$errors[] = Text::sprintf('There is no user with username %s in
the system', $username);
				}
			}
		}

		if (empty(trim($data['subject'])))
		{
			$errors[] = Text::_('Please provide subject for the ticket');
		}

		if (empty(trim($data['message'])))
		{
			$errors[] = Text::_('Please provide message for the ticket');
		}

		// Validate Category ID
		if (empty($data['category_id']))
		{
			$errors[] = Text::_('Please provide Category ID for the
ticket');
		}

		return $errors;
	}

	/**
	 * Basic API validation, should be called before each request
	 *
	 * @throws \Exception
	 */
	protected function validateAPIRequest()
	{
		$config = HelpdeskproHelper::getConfig();

		// Check and make sure API is enabled
		if (!$config->enable_api)
		{
			throw new \Exception(Text::_('API is not enabled on this
site'));
		}

		// Check API Key
		$apiKey = $this->input->getString('api_key');

		if ($apiKey !== $config->api_key)
		{
			throw new Exception(sprintf('The provided API Key %s is
invalid', $apiKey));
		}
	}

	/**
	 * Send json response to the API call
	 *
	 * @param   bool   $success
	 * @param   array  $data
	 */
	protected function sendResponse($success, $data)
	{
		$response['success'] = $success;

		if ($success)
		{
			$response['data'] = $data;
		}
		else
		{
			$response['errors'] = $data;
		}

		echo json_encode($response);
		$this->app->close();
	}
}PK̑�[c���	�	Controller/Controller.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Controller;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Uri\Uri;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;

defined('_JEXEC') or die;

class Controller extends \OSL\Controller\Controller
{
	/**
	 * Display information
	 *
	 */
	public function display($cachable = false, array $urlparams = [])
	{
		$document = $this->container->document;
		$config   = HelpdeskproHelper::getConfig();
		$rootUri  = Uri::root(true);

		// Load part of twitter bootstrap
		if ($config->load_twttier_bootstrap_framework_in_frontend)
		{
			$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/bootstrap/css/bootstrap.css');
		}

		$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/css/style.css');
		$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/css/common.css');
		$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/dropzone/basic.min.css');
		$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/dropzone/dropzone.min.css');

		$customCssFile = JPATH_ROOT .
'/media/com_helpdeskpro/assets/css/custom.css';

		if (file_exists($customCssFile) && filesize($customCssFile))
		{
			$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/css/custom.css');
		}

		$viewName = $this->input->get('view',
$this->container->defaultView);

		if (in_array(strtolower($viewName), ['ticket',
'tickets']))
		{
			// Load bootstrap-framework
			HTMLHelper::_('bootstrap.framework');

			// Helpdesk Pro javascript lib
			HTMLHelper::_('script',
'media/com_helpdeskpro/assets/js/helpdeskpro.min.js', false,
false);

			// Dropzone JS
			HTMLHelper::_('script',
'media/com_helpdeskpro/assets/dropzone/dropzone.min.js', false,
false);
		}


		parent::display($cachable, $urlparams);
	}

	/**
	 * @throws \Exception
	 */
	public function get_reply()
	{
		@header('Content-Type: text/html; charset=utf-8');

		$replyId = $this->input->getInt('reply_id', 0);
		$db      = $this->container->db;
		$query   = $db->getQuery(true);
		$query->select('message')
			->from('#__helpdeskpro_replies')
			->where('id = ' . $replyId);
		$db->setQuery($query);

		echo $db->loadResult();

		$this->container->app->close();
	}
}PK̑�[�d(�((helpdeskpro.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

// no direct access
defined('_JEXEC') or die;

//echo '<pre>';
////var_dump(JFactory::getApplication()->input->get('task'));
//var_dump(JFactory::getApplication()->input);
//echo '</pre>';
//exit();

// Bootstrap the component
require_once JPATH_ADMINISTRATOR .
'/components/com_helpdeskpro/init.php';

// Get component config data
$config = require JPATH_ADMINISTRATOR .
'/components/com_helpdeskpro/config.php';

// Creating component container
$container =
OSL\Container\Container::getInstance('com_helpdeskpro',
$config);

// Create controller, execute the request and redirect to the requested
page if it is set
$controller = OSL\Controller\Controller::getInstance($container);
//echo '<pre>';
//var_dump($controller);
//echo '</pre>';
//exit();
$controller->execute()
	->redirect();

PK̑�[q�Helper/bootstrap.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

use Joomla\CMS\Factory;

class HelpdeskProHelperBootstrap
{
	/**
	 * Bootstrap Helper instance
	 *
	 * @var PMFormHelperBootstrap
	 */
	protected static $instance;

	/**
	 * Twitter bootstrap version, default 2
	 * @var string
	 */
	protected $bootstrapVersion;

	/**
	 * UI component
	 *
	 * @var MPFUiInterface
	 */
	protected $ui;

	/**
	 * The class mapping to map between twitter bootstrap 2 and twitter
bootstrap 3
	 * @var string
	 */
	protected static $classMaps;

	/**
	 * Get bootstrap helper object
	 *
	 * @return PMFormHelperBootstrap
	 */
	public static function getInstance()
	{
		if (self::$instance === null)
		{
			$config = HelpdeskproHelper::getConfig();

			if (Factory::getApplication()->isClient('administrator')
&& version_compare(JVERSION, '3.9.99',
'<'))
			{
				self::$instance = new self('2');
			}
			else
			{
				self::$instance = new self($config->twitter_bootstrap_version);
			}
		}

		return static::$instance;
	}

	/**
	 * Constructor, initialize the classmaps array
	 *
	 * @param   string  $ui
	 * @param   array   $classMaps
	 *
	 * @throws Exception
	 */
	public function __construct($ui, $classMaps = [])
	{
		if (empty($ui))
		{
			$ui = 2;
		}

		switch ($ui)
		{
			case 2:
			case 3:
			case 4:
			case 5:
				$uiClass = 'HDPUiBootstrap' . $ui;
				break;
			default:
				$uiClass = 'HDPUi' . ucfirst($ui);
				break;
		}

		$this->bootstrapVersion = $ui;

		if (!class_exists($uiClass))
		{
			throw new Exception(sprintf('UI class %s not found',
$uiClass));
		}

		$this->ui = new $uiClass($classMaps);
	}

	/**
	 * Get the mapping of a given class
	 *
	 * @param   string  $class  The input class
	 *
	 * @return string The mapped class
	 */
	public function getClassMapping($class)
	{
		return $this->ui->getClassMapping($class);
	}

	/**
	 * Get twitter bootstrap version
	 *
	 * @return int|string
	 */
	public function getBootstrapVersion()
	{
		return $this->bootstrapVersion;
	}

	/**
	 * Method to get input with prepend add-on
	 *
	 * @param   string  $input
	 * @param   string  $addOn
	 *
	 * @return string
	 */
	public function getPrependAddon($input, $addOn)
	{
		return $this->ui->getPrependAddon($input, $addOn);
	}

	/**
	 * Method to get input with append add-on
	 *
	 * @param   string  $input
	 * @param   string  $addOn
	 *
	 * @return string
	 */
	public function getAppendAddon($input, $addOn)
	{
		return $this->ui->getAppendAddon($input, $addOn);
	}

	/**
	 * Get framework own css class
	 *
	 * @param   string  $class
	 * @param   int     $behavior
	 *
	 * @return string
	 */
	public function getFrameworkClass($class, $behavior = 0)
	{
		return $this->ui->getFrameworkClass($class, $behavior);
	}
}PK̑�[��Q��Helper/Database.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Helper;

use OSL\Container\Container;
use OSL\Utils\Database as DatabaseUtils;

defined('_JEXEC') or die;

class Database
{
	/**
	 * Get all published categories
	 *
	 * @param   string  $order
	 * @param   array   $filters
	 * @param   string  $fieldSuffix
	 * @param   int     $categoryType
	 *
	 * @return array
	 */
	public static function getAllCategories($order = 'title',
$filters = array(), $fieldSuffix = '', $categoryType = 1)
	{
		$db    = Container::getInstance('com_helpdeskpro')->db;
		$query = $db->getQuery(true);
		$query->select('id, parent_id, managers')
			->select($db->quoteName('title' . $fieldSuffix,
'title'))
			->from('#__helpdeskpro_categories')
			->where('published=1')
			->where('category_type IN (0, ' . $categoryType .
')')
			->order($order);

		foreach ($filters as $filter)
		{
			$query->where($filter);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all published statuses
	 *
	 * @param   string  $order
	 * @param   string  $fieldSuffix
	 *
	 * @return array
	 */
	public static function getAllStatuses($order = 'ordering',
$fieldSuffix = '')
	{
		$db    = Container::getInstance('com_helpdeskpro')->db;
		$query = $db->getQuery(true);
		$query->select('id, title')
			->from('#__helpdeskpro_statuses')
			->where('published=1')
			->order($order);

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, array('title'),
$fieldSuffix);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all published priorities
	 *
	 * @param   string  $order
	 * @param   string  $fieldSuffix
	 *
	 * @return array
	 */
	public static function getAllPriorities($order = 'ordering',
$fieldSuffix = '')
	{
		$db    = Container::getInstance('com_helpdeskpro')->db;
		$query = $db->getQuery(true);
		$query->select('id, title')
			->from('#__helpdeskpro_priorities')
			->where('published=1')
			->order($order);

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, array('title'),
$fieldSuffix);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all published labels
	 *
	 * @param   string  $order
	 *
	 * @return array
	 */
	public static function getAllLabels($order = 'title')
	{
		$db    = Container::getInstance('com_helpdeskpro')->db;
		$query = $db->getQuery(true);
		$query->select('id, title')
			->from('#__helpdeskpro_labels')
			->where('published=1')
			->order($order);
		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all published labels
	 *
	 * @param   int  $staffGroupId
	 *
	 * @return array
	 */
	public static function getAllStaffs($staffGroupId)
	{
		$db           =
Container::getInstance('com_helpdeskpro')->db;
		$query        = $db->getQuery(true);
		$config       = Helper::getConfig();
		$displayField = $config->get('staff_display_field',
'username') ?: 'username';

		$query->select("a.id, a.username, a.name, a.email")
			->from("#__users AS a")
			->innerJoin("#__user_usergroup_map AS b ON a.id =
b.user_id")
			->where("group_id=" . (int) $staffGroupId)
			->order($displayField);
		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all custom fields which will be displayed in list view
	 *
	 * @param   string  $fieldSuffix
	 *
	 * @return array
	 */
	public static function getFieldsOnListView($fieldSuffix = null)
	{
		$db    = Container::getInstance('com_helpdeskpro')->db;
		$query = $db->getQuery(true);

		$query->select('*')
			->from('#__helpdeskpro_fields')
			->where('show_in_list_view=1')
			->where('published=1')
			->order('ordering');

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, array('title',
'description', 'values', 'default_values'),
$fieldSuffix);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}
}PK̑�[×J�ѼѼHelper/Helper.phpnu�[���<?php
/**
 * @version        3.5.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2019 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Helper;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Mail\MailHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserHelper;
use OSL\Utils\Database as DatabaseUtils;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

defined('_JEXEC') or die;

class Helper
{
	/**
	 * Get current installed version of Helpdesk Pro
	 *
	 * @return string
	 */
	public static function getInstalledVersion()
	{
		return '4.1.0';
	}

	/**
	 * Helper method to check if the extension is running on Joomla 4
	 *
	 * @return bool
	 */
	public static function isJoomla4()
	{
		return version_compare(JVERSION, '4.0.0-dev', 'ge');
	}

	/**
	 * Get configuration data and store in config object
	 *
	 * @return \OSL\Config\Config
	 */
	public static function getConfig()
	{
		static $config;

		if (!$config)
		{
			$db    = Factory::getDbo();
			$query = $db->getQuery(true);
			$query->select('*')->from('#__helpdeskpro_configs');
			$db->setQuery($query);
			$rows = $db->loadObjectList();
			$data = [];

			foreach ($rows as $row)
			{
				$data[$row->config_key] = $row->config_value;
			}

			$config = new \OSL\Config\Config($data);
		}

		return $config;
	}

	/**
	 * Get the email messages used for sending emails
	 *
	 * @return \OSL\Config\Config
	 */
	public static function getEmailMessages()
	{
		static $message;

		if (!$message)
		{
			$db    = Factory::getDbo();
			$query = $db->getQuery(true);
			$query->select('*')->from('#__helpdeskpro_emails');
			$db->setQuery($query);
			$rows = $db->loadObjectList();
			$data = [];

			foreach ($rows as $row)
			{
				$data[$row->email_key] = $row->email_message;
			}

			$message = new \OSL\Config\Config($data);
		}

		return $message;
	}

	/**
	 * Get all custom fields assigned to certain category
	 *
	 * @param   int    $categoryId
	 * @param   array  $filters
	 *
	 * @return mixed
	 */
	public static function getFields($categoryId, $filters = [])
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('id, name, fieldtype, title')
			->from('#__helpdeskpro_fields')
			->where('(category_id = -1 OR id IN (SELECT field_id FROM
#__helpdeskpro_field_categories WHERE category_id=' . (int)
$categoryId . '))')
			->where('published = 1');

		foreach ($filters as $filter)
		{
			$query->where($filter);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get all custom fields
	 *
	 * @return array
	 */
	public static function getAllFields()
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('*, extra AS extra_attributes, 0 AS max_length,
"" AS place_holder')
			->from('#__helpdeskpro_fields')
			->where('published = 1')
			->order('ordering');

		if ($fieldSuffix = Helper::getFieldSuffix())
		{
			\OSL\Utils\Database::getMultilingualFields($query, ['title',
'description', 'values', 'default_values'],
$fieldSuffix);
		}

		$db->setQuery($query);

		return $db->loadObjectList();
	}

	/**
	 * Get the association array contains the relationship between field and
categories
	 *
	 * @return array
	 */
	public static function getFieldCategoryRelation()
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('id')
			->from('#__helpdeskpro_fields')
			->where('published = 1')
			->where('category_id = -1');
		$db->setQuery($query);

		$relation[0] = $db->loadColumn();

		$query->clear()
			->select('*')
			->from('#__helpdeskpro_field_categories');
		$db->setQuery($query);
		$fieldCategories = $db->loadObjectList();

		foreach ($fieldCategories as $fieldCategory)
		{
			$relation[$fieldCategory->category_id][] =
$fieldCategory->field_id;
		}


		return $relation;
	}

	/**
	 * Get specify config value
	 *
	 * @param   string  $key
	 *
	 * @return string
	 */
	public static function getConfigValue($key)
	{
		$config = static::getConfig();

		return $config->get($key);
	}

	/**
	 * Get Itemid of Helpdesk Pro componnent
	 *
	 * @return int
	 */
	public static function getItemid()
	{
		$db    = Factory::getDbo();
		$user  = Factory::getUser();
		$query = $db->getQuery(true);
		$query->select('id')
			->from('#__menu AS a')
			->where('a.link LIKE
"%index.php?option=com_helpdeskpro&view=tickets%"')
			->where('a.published=1')
			->where('a.access IN (' . implode(',',
$user->getAuthorisedViewLevels()) . ')');

		if (Multilanguage::isEnabled())
		{
			$query->where('a.language IN (' .
$db->quote(Factory::getLanguage()->getTag()) . ',' .
$db->Quote('*') . ')');
		}

		$query->order('a.access');
		$db->setQuery($query);
		$itemId = $db->loadResult();

		if (!$itemId)
		{
			$Itemid =
Factory::getApplication()->input->getInt('Itemid');

			if ($Itemid == 1)
			{
				$itemId = 999999;
			}
			else
			{
				$itemId = $Itemid;
			}
		}

		return $itemId;
	}

	/**
	 * Get field suffix used in sql query
	 *
	 * @param   string  $activeLanguage
	 *
	 * @return string
	 */
	public static function getFieldSuffix($activeLanguage = null)
	{
		$prefix = '';

		if (Multilanguage::isEnabled())
		{
			if (!$activeLanguage)
			{
				$activeLanguage = Factory::getLanguage()->getTag();
			}

			if ($activeLanguage != self::getDefaultLanguage())
			{
				$db    = Factory::getDbo();
				$query = $db->getQuery(true);
				$query->select('`sef`')
					->from('#__languages')
					->where('lang_code = ' . $db->quote($activeLanguage))
					->where('published = 1');
				$db->setQuery($query);
				$sef = $db->loadResult();

				if ($sef)
				{
					$prefix = '_' . $sef;
				}
			}
		}

		return $prefix;
	}

	/**
	 * load editable
	 */
	public static function loadEditable($loadJs = true)
	{
		$document = Factory::getDocument();
		$rootUri  = Uri::root(true);
		$config   = static::getConfig();

		if ($config->twitter_bootstrap_version === '4' &&
Factory::getApplication()->isClient('site'))
		{
			return;
		}

		if ($config->twitter_bootstrap_version == '3' &&
Factory::getApplication()->isClient('site'))
		{
			$editable = 'bs3editable';
		}
		else
		{
			$editable = 'editable';
		}

		$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/js/' . $editable .
'/css/bootstrap-editable.css');

		if ($loadJs)
		{
			$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/' . $editable .
'/js/bootstrap-editable.min.js');
		}
	}

	/**
	 * Load highlighter script so that the code will be highlighted
	 */
	public static function loadHighlighter()
	{
		$config             = self::getConfig();
		$supportedLanguages = explode(',',
$config->programming_languages);
		$syntaxPath         = Uri::root(true) .
'/media/com_helpdeskpro/assets/js/syntaxhighlighter3/';
		$document           = Factory::getDocument();
		$document->addScript($syntaxPath . 'scripts/shCore.js');
		$languages = [
			'AS3',
			'Bash',
			'Cpp',
			'CSharp',
			'Css',
			'Delphi',
			'Diff',
			'Groovy',
			'Java',
			'JavaFX',
			'JScript',
			'Perl',
			'Php',
			'Plain',
			'PowerShell',
			'Python',
			'Ruby',
			'Scala',
			'Sql',
			'Vb',
			'Xml'];

		foreach ($languages as $language)
		{
			if (in_array($language, $supportedLanguages))
			{
				$document->addScript($syntaxPath . 'scripts/shBrush' .
$language . '.js');
			}
		}

		$theme = 'Default';
		$document->addStyleSheet($syntaxPath . 'styles/shCore' .
$theme . '.css');
		$document->addStyleSheet($syntaxPath . 'styles/shTheme' .
$theme . '.css');
		$document->addScriptDeclaration('
			  SyntaxHighlighter.all();
		 ');
	}

	/**
	 *
	 *
	 * @return string
	 */
	public static function validateEngine()
	{
		$dateNow    = HTMLHelper::_('date', Factory::getDate(),
'Y/m/d');
		$validClass = [
			"",
			"validate[custom[integer]]",
			"validate[custom[number]]",
			"validate[custom[email]]",
			"validate[custom[url]]",
			"validate[custom[phone]]",
			"validate[custom[date],past[$dateNow]]",
			"validate[custom[ipv4]]",
			"validate[minSize[6]]",
			"validate[maxSize[12]]",
			"validate[custom[integer],min[-5]]",
			"validate[custom[integer],max[50]]"];

		return json_encode($validClass);
	}

	/**
	 *
	 * Get role of the given user
	 *
	 * @param $userId
	 *
	 * @return mixed
	 */
	public static function getUserRole($userId = 0)
	{
		static $roles = [];

		if (!$userId)
		{
			$userId = Factory::getUser()->id;
		}

		if (!isset($roles[$userId]))
		{
			$role = 'user';

			if ($userId)
			{
				$user = Factory::getUser($userId);

				if ($user->authorise('core.admin',
'com_helpdeskpro'))
				{
					$role = 'admin';
				}
				else
				{
					$manageCategoryIds =
Helper::getTicketCategoryIds($user->username);

					if (count($manageCategoryIds) >= 1 && $manageCategoryIds[0]
!= 0)
					{
						$role = 'manager';
					}
					else
					{
						$config = self::getConfig();

						if ($config->staff_group_id)
						{
							$staffs = Database::getAllStaffs($config->staff_group_id);

							foreach ($staffs as $staff)
							{
								if ($staff->id == $userId)
								{
									$role = 'staff';
									break;
								}
							}
						}
					}
				}
			}

			$roles[$userId] = $role;
		}

		return $roles[$userId];
	}

	/**
	 * Get list of current online users
	 *
	 * @return array
	 */
	public static function getOnlineUsers()
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('DISTINCT u.id');
		$query->from('#__session AS s');
		$query->innerJoin('#__users AS u ON s.userid = u.id');
		$query->where('s.guest = 0');
		$db->setQuery($query);

		return $db->loadColumn();
	}

	/**
	 * Load language from main component
	 *
	 */
	public static function loadLanguage()
	{
		static $loaded;

		if (!$loaded)
		{
			$lang = Factory::getLanguage();
			$tag  = $lang->getTag();

			if (!$tag)
			{
				$tag = 'en-GB';
			}

			$lang->load('com_helpdeskpro', JPATH_ROOT, $tag);
			$loaded = true;
		}
	}

	/**
	 * Display copy right information
	 *
	 */
	public static function displayCopyRight()
	{
		echo '<div class="copyright clearfix row-fluid"
style="text-align:center;margin-top: 5px;"><a
href="http://joomdonation.com/components/helpdesk-pro.html"
target="_blank"><strong>Helpdesk
Pro</strong></a> version ' . self::getInstalledVersion() .
', Copyright (C) 2012 - ' . date('Y') . ' <a
href="http://joomdonation.com"
target="_blank"><strong>Ossolution
Team</strong></a></div>';
	}

	/**
	 * Get ticket categories managed by the given user
	 *
	 * @param   string  $username
	 *
	 * @return array
	 */
	public static function getTicketCategoryIds($username)
	{
		static $categories = [];

		if (!isset($categories[$username]))
		{
			$db    = Factory::getDbo();
			$query = $db->getQuery(true);
			$query->select('id')
				->from('#__helpdeskpro_categories')
				->where("managers='$username' OR managers LIKE
'$username,%' OR managers LIKE '%,$username,%' OR
managers LIKE '%,$username'");
			$db->setQuery($query);

			$categoryIds = $db->loadColumn();

			if (!count($categoryIds))
			{
				$categoryIds = [0];
			}

			$categories[$username] = $categoryIds;
		}

		return $categories[$username];
	}

	/**
	 * Method to check to see whether the user can edit the comment
	 *
	 * @param   \JUser  $user
	 * @param   int     $id
	 *
	 * @return bool
	 */
	public static function canUpdateComment($user, $id)
	{
		if (static::isJoomla4())
		{
			return false;
		}

		// User has edit permission in helpdesk pro will be able to edit the
comment
		if ($user->authorise('core.edit',
'com_helpdeskpro'))
		{
			return true;
		}

		// Owner of the ticket can edit the comment
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('user_id')
			->from('#__helpdeskpro_messages')
			->where('id = ' . $id);
		$db->setQuery($query);
		$message = $db->loadObject();

		if ($message && $user->id && ($message->user_id ==
$user->id) && $user->authorise('core.editown',
'com_helpdeskpro'))
		{
			return true;
		}

		// Otherwise, he could not edit the comment
		return false;
	}

	/**
	 * Helper methd to check to see whether the user can edit the comment
	 *
	 * @param   \JUser  $user
	 * @param           $id
	 *
	 * @return bool
	 */
	public static function canDeleteComment($user, $id)
	{
		// User has edit permission in helpdesk pro will be able to edit the
comment
		if ($user->authorise('core.delete',
'com_helpdeskpro'))
		{
			return true;
		}

		// Owner of the ticket can edit the comment
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('user_id')
			->from('#__helpdeskpro_messages')
			->where('id = ' . $id);
		$db->setQuery($query);
		$message = $db->loadObject();

		if ($message && $user->id && ($message->user_id ==
$user->id))
		{
			return true;
		}

		// Otherwise, he could not edit the comment

		return false;
	}

	/**
	 * Check ticket access
	 *
	 * @param   \Ossolution\HelpdeskPro\Admin\Table\Ticket  $item
	 *
	 * @return bool
	 */
	public static function checkTicketAccess($item)
	{
		$user   = Factory::getUser();
		$config = Helper::getConfig();

		if (!$item->id)
		{
			return false;
		}

		if ($item->is_ticket_code &&
$config->allow_public_user_submit_ticket)
		{
			return true;
		}

		if (!$user->id)
		{
			return false;
		}

		if ($user->id == $item->user_id || $user->email ==
$item->email)
		{
			return true;
		}

		if ($user->id == $item->staff_id)
		{
			return true;
		}

		if ($user->authorise('core.admin',
'com_helpdeskpro'))
		{
			return true;
		}

		$managedCategoryIds =
Helper::getTicketCategoryIds($user->get('username'));

		if (in_array($item->category_id, $managedCategoryIds))
		{
			return true;
		}

		return false;
	}

	/**
	 * Get CB avatar of the given user to display on the ticket
	 *
	 * @param   int  $userId
	 *
	 * @return string relative path to the avatar
	 */
	public static function getCBAvatar($userId)
	{
		static $avatars;

		if (!isset($avatars[$userId]))
		{
			$db    = Factory::getDbo();
			$query = $db->getQuery(true);
			$query->select('avatar')
				->from('#__comprofiler')
				->where('user_id=' . $userId . ' AND
avatarapproved=1');
			$db->setQuery($query);
			$avatar = $db->loadResult();
			if (!$avatar)
				$avatar = '';
			$avatars[$userId] = $avatar;
		}

		return $avatars[$userId];
	}

	/**
	 * This function is used to check to see whether we need to update the
database to support multilingual or not
	 *
	 * @return boolean
	 */
	public static function isSyncronized()
	{
		$db             = Factory::getDbo();
		$fields         =
$db->getTableColumns('#__helpdeskpro_categories');
		$fields         = array_keys($fields);
		$extraLanguages = self::getLanguages(self::getDefaultLanguage());

		if (count($extraLanguages))
		{
			foreach ($extraLanguages as $extraLanguage)
			{
				$prefix = $extraLanguage->sef;

				if (!in_array('title_' . $prefix, $fields))
				{
					return false;
				}
			}
		}

		return true;
	}

	/**
	 * Syncronize Helpdesk Pro database to support multilingual
	 */
	public static function setupMultilingual()
	{
		$db        = Factory::getDbo();
		$languages = self::getLanguages();

		if (count($languages))
		{
			foreach ($languages as $language)
			{
				#Process for #__helpdeskpro_categories table							
				$prefix = $language->sef;
				$fields =
array_keys($db->getTableColumns('#__helpdeskpro_categories'));

				if (!in_array('title_' . $prefix, $fields))
				{
					$fieldName = 'title_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_categories` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();

					$fieldName = 'description_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_categories` ADD 
`$fieldName` TEXT NULL;";
					$db->setQuery($sql);
					$db->execute();
				}

				if (!in_array('alias_' . $prefix, $fields))
				{
					$fieldName = 'alias_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_categories` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();
				}

				#Process for #__helpdeskpro_statuses table
				$fields =
array_keys($db->getTableColumns('#__helpdeskpro_statuses'));
				if (!in_array('title_' . $prefix, $fields))
				{
					$fieldName = 'title_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_statuses` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();
				}

				#Process for #__helpdeskpro_priorities table
				$fields =
array_keys($db->getTableColumns('#__helpdeskpro_priorities'));
				if (!in_array('title_' . $prefix, $fields))
				{
					$fieldName = 'title_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_priorities` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();
				}

				#Process for #__helpdeskpro_fields table
				$fields =
array_keys($db->getTableColumns('#__helpdeskpro_fields'));
				if (!in_array('title_' . $prefix, $fields))
				{
					$fieldName = 'title_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_fields` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();

					$fieldName = 'description_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_fields` ADD 
`$fieldName` TEXT NULL;";
					$db->setQuery($sql);
					$db->execute();

					$fieldName = 'values_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_fields` ADD 
`$fieldName` TEXT NULL;";
					$db->setQuery($sql);
					$db->execute();

					$fieldName = 'default_values_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_fields` ADD 
`$fieldName` TEXT NULL;";
					$db->setQuery($sql);
					$db->execute();
				}

				// Process for #__helpdeskpro_articles tabl
				$fields =
array_keys($db->getTableColumns('#__helpdeskpro_articles'));

				if (!in_array('title_' . $prefix, $fields))
				{
					$fieldName = 'title_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_articles` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();

					$fieldName = 'text_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_articles` ADD 
`$fieldName` TEXT NULL;";
					$db->setQuery($sql);
					$db->execute();
				}

				if (!in_array('alias_' . $prefix, $fields))
				{
					$fieldName = 'alias_' . $prefix;
					$sql       = "ALTER TABLE  `#__helpdeskpro_articles` ADD 
`$fieldName` VARCHAR( 255 );";
					$db->setQuery($sql);
					$db->execute();
				}
			}
		}
	}

	/**
	 * Process BB code for the given message
	 *
	 * @param   string  $message
	 *
	 * @return string
	 */
	public static function processBBCode($message)
	{
		require_once JPATH_ROOT .
'/administrator/components/com_helpdeskpro/libraries/bbcodeparser.php';

		$config = self::getConfig();

		if (!$config->use_html_editor)
		{
			$message = nl2br($message);
		}

		return \BBCodeParser::parse($message);
	}

	/**
	 *  Method to add ticket or comment attachments to mailer for sending
emails
	 *
	 * @param   \JMail  $mailer
	 * @param   object  $row
	 */
	protected static function addAttachmentsToMailer($mailer, $row)
	{
		$originalFileNames = explode('|',
$row->original_filenames);
		$attachments       = explode('|', $row->attachments);

		for ($i = 0, $n = count($attachments); $i < $n; $i++)
		{
			$attachment       = $attachments[$i];
			$originalFileName = $originalFileNames[$i];

			if (file_exists(JPATH_ROOT .
'/media/com_helpdeskpro/attachments/' . $attachment))
			{
				$mailer->addAttachment(JPATH_ROOT .
'/media/com_helpdeskpro/attachments/' . $attachment,
$originalFileName);
			}
		}
	}

	/**
	 * Send email to super administrator and user
	 *
	 * @param   object  $row     The message object
	 * @param   object  $ticket  The ticket object
	 * @param   object  $config
	 */
	public static function sendTicketUpdatedEmailToCustomer($row, $ticket,
$config)
	{
		$user        = Factory::getUser();
		$mailer      = static::getMailer();
		$db          = Factory::getDbo();
		$message     = self::getEmailMessages();
		$fieldSuffix = self::getFieldSuffix($ticket->language);

		$query = $db->getQuery(true)
			->select('name')
			->from('#__users')
			->where('id = ' . (int) $row->user_id);
		$db->setQuery($query);
		$manageName = $db->loadResult();

		$replaces = self::getCommonTicketTags($ticket, $config);

		if ($config->use_html_editor)
		{
			$replaces['ticket_comment'] = $row->message;
		}
		else
		{
			$replaces['ticket_comment'] = nl2br($row->message);
		}

		$replaces['manager_name'] = $manageName;

		if ($fieldSuffix &&
$message->{'ticket_updated_user_email_subject' .
$fieldSuffix})
		{
			$subject = $message->{'ticket_updated_user_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->ticket_updated_user_email_subject;
		}

		if ($fieldSuffix &&
strlen(strip_tags($message->{'ticket_updated_user_email_body'
. $fieldSuffix})))
		{
			$body = $message->{'ticket_updated_user_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->ticket_updated_user_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$key     = strtoupper($key);
			$body    = str_replace("[$key]", $value, $body);
			$subject = str_replace("[$key]", $value, $subject);
		}

		if ($config->notify_manager_when_staff_reply &&
($ticket->staff_id == $user->id))
		{
			// Staff reply to ticket
			$emails = static::getTicketNotificationEmails($ticket);
			$mailer->addBcc($emails);
		}
		elseif ($config->notify_other_managers_when_a_manager_reply &&
$ticket->staff_id != $user->id)
		{
			// Admin or manager reply to a ticket
			$emails = static::getTicketNotificationEmails($ticket);

			// Exclude email of the current manager from receiving notification
			$emails = array_diff($emails, [$user->email]);

			if (count($emails))
			{
				$mailer->addBcc($emails);
			}
		}

		// Add ticket attachments to email if configured
		if ($config->send_ticket_attachments_to_email &&
$row->attachments)
		{
			static::addAttachmentsToMailer($mailer, $row);
		}

		if ($ticket->user_id)
		{
			$userEmail = static::getUserEmail($ticket->user_id);

			if ($userEmail != $ticket->email)
			{
				$ticket->email = $userEmail;

				$query->clear()
					->update('#__helpdeskpro_tickets')
					->set('email = ' . $db->quote($userEmail))
					->where('user_id = ' . $ticket->user_id);
				$db->setQuery($query)
					->execute();
			}
		}


		static::send($mailer, [$ticket->email], $subject, $body);
	}

	/**
	 * Send email to super administrator and user
	 *
	 * @param   object  $row     The message object
	 * @param   object  $ticket  The ticket object
	 * @param   object  $config
	 */
	public static function sendTicketUpdatedEmailToManagers($row, $ticket,
$config)
	{
		$mailer      = static::getMailer();
		$message     = self::getEmailMessages();
		$fieldSuffix = self::getFieldSuffix($ticket->language);

		$replaces = self::getCommonTicketTags($ticket, $config);

		if ($config->use_html_editor)
		{
			$replaces['ticket_comment'] = $row->message;
		}
		else
		{
			$replaces['ticket_comment'] = nl2br($row->message);
		}

		$emails = static::getTicketNotificationEmails($ticket, true);

		if ($message->{'ticket_updated_admin_email_subject' .
$fieldSuffix})
		{
			$subject = $message->{'ticket_updated_admin_email_subject'
. $fieldSuffix};
		}
		else
		{
			$subject = $message->ticket_updated_admin_email_subject;
		}

		if
(strlen(strip_tags($message->{'ticket_updated_admin_email_body'
. $fieldSuffix})))
		{
			$body = $message->{'ticket_updated_admin_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->ticket_updated_admin_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$key     = strtoupper($key);
			$body    = str_replace("[$key]", $value, $body);
			$subject = str_replace("[$key]", $value, $subject);
		}

		// Add ticket attachments to email if configured
		if ($config->send_ticket_attachments_to_email &&
$row->attachments)
		{
			static::addAttachmentsToMailer($mailer, $row);
		}

		static::send($mailer, $emails, $subject, $body);
	}

	/**
	 * Send email to super administrator and user
	 *
	 * @param   object  $row     The message object
	 * @param   object  $ticket  The ticket object
	 * @param   object  $config
	 */
	public static function sendNewTicketNotificationEmails($row, $config)
	{
		$mailer      = static::getMailer();
		$message     = self::getEmailMessages();
		$fieldSuffix = self::getFieldSuffix($row->language);

		$replaces = self::getCommonTicketTags($row, $config);

		$emails = static::getTicketNotificationEmails($row);

		if ($message->{'new_ticket_admin_email_subject' .
$fieldSuffix})
		{
			$subject = $message->{'new_ticket_admin_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->new_ticket_admin_email_subject;
		}

		if
(strlen(strip_tags($message->{'new_ticket_admin_email_body' .
$fieldSuffix})))
		{
			$body = $message->{'new_ticket_admin_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->new_ticket_admin_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		// Add ticket attachments to email if configured
		if ($config->send_ticket_attachments_to_email &&
$row->attachments)
		{
			static::addAttachmentsToMailer($mailer, $row);
		}

		static::send($mailer, $emails, $subject, $body);

		$mailer->clearAllRecipients();
		$mailer->clearAttachments();

		if (!MailHelper::isEmailAddress($row->email))
		{
			return;
		}

		//Send email to user
		if ($message->{'new_ticket_user_email_subject' .
$fieldSuffix})
		{
			$subject = $message->{'new_ticket_user_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->new_ticket_user_email_subject;
		}

		if
(strlen(strip_tags($message->{'new_ticket_user_email_body' .
$fieldSuffix})))
		{
			$body = $message->{'new_ticket_user_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->new_ticket_user_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		if ($row->user_id)
		{
			$userEmail = static::getUserEmail($row->user_id);

			if ($userEmail != $row->email)
			{
				$row->email = $userEmail;

				$db    = Factory::getDbo();
				$query = $db->getQuery(true)
					->update('#__helpdeskpro_tickets')
					->set('email = ' . $db->quote($userEmail))
					->where('user_id = ' . $row->user_id);
				$db->setQuery($query)
					->execute();
			}
		}

		static::send($mailer, [$row->email], $subject, $body);
	}

	/**
	 * Send Ticket assigned email
	 *
	 * @param   object  $row
	 * @param   object  $config
	 */
	public static function sendTicketAssignedEmails($row, $config)
	{
		if (!$row->staff_id)
		{
			return;
		}

		$mailer                   = static::getMailer();
		$message                  = self::getEmailMessages();
		$fieldSuffix              = self::getFieldSuffix($row->language);
		$replaces                 = self::getCommonTicketTags($row, $config);
		$replaces['MANAGER_NAME'] = Factory::getUser()->name;

		if ($message->{'customer_ticket_assigned_email_subject' .
$fieldSuffix})
		{
			$subject =
$message->{'customer_ticket_assigned_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->customer_ticket_assigned_email_subject;
		}

		if
(strlen(strip_tags($message->{'customer_ticket_assigned_email_body'
. $fieldSuffix})))
		{
			$body = $message->{'customer_ticket_assigned_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->customer_ticket_assigned_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		static::send($mailer, [$row->email], $subject, $body);

		$mailer->clearAllRecipients();

		// Get staff email
		$db    = Factory::getDbo();
		$query = $db->getQuery(true)
			->select('email')
			->from('#__users')
			->where('id = ' . $row->staff_id);
		$db->setQuery($query);
		$staffEmail = $db->loadResult();

		if (!MailHelper::isEmailAddress($staffEmail))
		{
			return;
		}

		//Send email to staff
		if ($message->{'ticket_assiged_email_subject' .
$fieldSuffix})
		{
			$subject = $message->{'ticket_assiged_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->ticket_assiged_email_subject;
		}

		if (strlen(strip_tags($message->{'ticket_assiged_email_body'
. $fieldSuffix})))
		{
			$body = $message->{'ticket_assiged_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->ticket_assiged_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		static::send($mailer, [$staffEmail], $subject, $body);
	}


	/**
	 * Send ticket closed email to customer
	 *
	 * @param $row
	 * @param $config
	 */
	public static function sendTicketClosedEmail($row, $config)
	{
		$user = Factory::getUser();

		$mailer      = static::getMailer();
		$message     = self::getEmailMessages();
		$fieldSuffix = self::getFieldSuffix($row->language);
		$replaces    = self::getCommonTicketTags($row, $config);

		// Customer close ticket, sending email to managers
		if ($user->id == $row->user_id)
		{
			if ($message->{'manager_ticket_closed_email_subject' .
$fieldSuffix})
			{
				$subject =
$message->{'manager_ticket_closed_email_subject' .
$fieldSuffix};
			}
			else
			{
				$subject = $message->manager_ticket_closed_email_subject;
			}

			if
(strlen(strip_tags($message->{'manager_ticket_closed_email_body'
. $fieldSuffix})))
			{
				$body = $message->{'manager_ticket_closed_email_body' .
$fieldSuffix};
			}
			else
			{
				$body = $message->manager_ticket_closed_email_body;
			}

			foreach ($replaces as $key => $value)
			{
				$body    = str_ireplace("[$key]", $value, $body);
				$subject = str_ireplace("[$key]", $value, $subject);
			}

			// Get all managers + staff email
			$emails = static::getTicketNotificationEmails($row, true);

			static::send($mailer, $emails, $subject, $body);

			return;
		}

		// Manager or staff closes ticket, send notification email to customer
		$replaces['MANAGER_NAME'] = Factory::getUser()->name;

		if ($message->{'customer_ticket_closed_email_subject' .
$fieldSuffix})
		{
			$subject =
$message->{'customer_ticket_closed_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->customer_ticket_closed_email_subject;
		}

		if
(strlen(strip_tags($message->{'customer_ticket_closed_email_body'
. $fieldSuffix})))
		{
			$body = $message->{'customer_ticket_closed_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->customer_ticket_closed_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		static::send($mailer, [$row->email], $subject, $body);
	}

	/**
	 * Send ticket status change email to customer
	 *
	 * @param $row
	 * @param $config
	 */
	public static function sendTicketStatusChangeEmail($row, $oldStatus,
$newStatus, $config)
	{
		$user = Factory::getUser();

		$mailer      = static::getMailer();
		$db          = Factory::getDbo();
		$message     = self::getEmailMessages();
		$fieldSuffix = self::getFieldSuffix($row->language);
		$replaces    = self::getCommonTicketTags($row, $config);

		$query = $db->getQuery(true)
			->select('title')
			->from('#__helpdeskpro_statuses')
			->where('id = ' . (int) $oldStatus);

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, ['title'],
$fieldSuffix);
		}

		$db->setQuery($query);

		$replaces['old_status'] = $db->loadResult();

		$query->clear('where')
			->where('id = ' . (int) $newStatus);
		$db->setQuery($query);

		$replaces['new_status'] = $db->loadResult();

		// Customer close ticket, sending email to managers
		if ($user->id == $row->user_id)
		{
			if
($message->{'manager_ticket_status_changed_email_subject' .
$fieldSuffix})
			{
				$subject =
$message->{'manager_ticket_status_changed_email_subject' .
$fieldSuffix};
			}
			else
			{
				$subject = $message->manager_ticket_status_changed_email_subject;
			}

			if
(strlen(strip_tags($message->{'manager_ticket_status_changed_email_body'
. $fieldSuffix})))
			{
				$body =
$message->{'manager_ticket_status_changed_email_body' .
$fieldSuffix};
			}
			else
			{
				$body = $message->manager_ticket_status_changed_email_body;
			}

			foreach ($replaces as $key => $value)
			{
				$body    = str_ireplace("[$key]", $value, $body);
				$subject = str_ireplace("[$key]", $value, $subject);
			}

			// Get all managers + staff emails
			$emails = static::getTicketNotificationEmails($row, true);

			static::send($mailer, $emails, $subject, $body);

			return;
		}

		// Manager or staff change ticket status, send notification email to
customer
		$replaces['MANAGER_NAME'] = Factory::getUser()->name;

		if
($message->{'customer_ticket_status_changed_email_subject' .
$fieldSuffix})
		{
			$subject =
$message->{'customer_ticket_status_changed_email_subject' .
$fieldSuffix};
		}
		else
		{
			$subject = $message->customer_ticket_status_changed_email_subject;
		}

		if
(strlen(strip_tags($message->{'customer_ticket_status_changed_email_body'
. $fieldSuffix})))
		{
			$body =
$message->{'customer_ticket_status_changed_email_body' .
$fieldSuffix};
		}
		else
		{
			$body = $message->customer_ticket_status_changed_email_body;
		}

		foreach ($replaces as $key => $value)
		{
			$body    = str_ireplace("[$key]", $value, $body);
			$subject = str_ireplace("[$key]", $value, $subject);
		}

		static::send($mailer, [$row->email], $subject, $body);
	}

	/**
	 * Get common tags related to ticket and use it for sending emails
	 *
	 * @param   \OSSolution\HelpdeskPro\Admin\Table\Ticket  $row
	 * @param   \stdClass                                   $config
	 *
	 * @return array
	 */
	public static function getCommonTicketTags($row, $config)
	{
		$siteUrl     = Uri::root();
		$fieldSuffix = self::getFieldSuffix($row->language);
		$db          = Factory::getDbo();
		$query       = $db->getQuery(true);
		$replaces    = [];

		$replaces['ticket_id']      = $row->id;
		$replaces['ticket_subject'] = $row->subject;
		$replaces['name']           = $row->name;
		$replaces['email']          = $row->email;

		if ($row->staff_id)
		{
			$query->clear()
				->select('name')
				->from('#__users')
				->where('id = ' . (int) $row->staff_id);
			$db->setQuery($query);
			$replaces['staff_name'] = $db->loadResult();
		}
		else
		{
			$replaces['staff_name'] = '';
		}

		if ($config->use_html_editor)
		{
			$replaces['ticket_message'] = $row->message;
		}
		else
		{
			$replaces['ticket_message'] = nl2br($row->message);
		}

		$replaces['frontend_link']               = $siteUrl .
RouteHelper::getTicketRoute($row->id);
		$replaces['backend_link']                = $siteUrl .
'administrator/index.php?option=com_helpdeskpro&view=ticket&id='
. $row->id;
		$replaces['frontend_link_without_login'] = $siteUrl .
RouteHelper::getTicketRoute($row->ticket_code, false);

		$query->clear()
			->select('id, name, title')
			->from('#__helpdeskpro_fields')
			->where('published=1')
			->where('(category_id = -1 OR id IN (SELECT field_id FROM
#__helpdeskpro_field_categories WHERE category_id=' .
$row->category_id . '))')
			->order('ordering');
		$db->setQuery($query);
		$rowFields = $db->loadObjectList();
		$fields    = [];

		for ($i = 0, $n = count($rowFields); $i < $n; $i++)
		{
			$rowField              = $rowFields[$i];
			$fields[$rowField->id] = $rowField->name;
		}

		$query->clear()
			->select('*')
			->from('#__helpdeskpro_field_value')
			->where('ticket_id = ' . $row->id);
		$db->setQuery($query);
		$rowValues = $db->loadObjectList();

		for ($i = 0, $n = count($rowValues); $i < $n; $i++)
		{
			$rowValue                               = $rowValues[$i];
			$replaces[$fields[$rowValue->field_id]] = $rowValue->field_value;
		}

		$query->clear()
			->select('name')
			->from('#__helpdeskpro_fields');
		$db->setQuery($query);
		$fields = $db->loadColumn();

		foreach ($fields as $field)
		{
			if (!isset($replaces[$field]))
			{
				$replaces[$field] = '';
			}
		}

		$query->clear()
			->select($db->quoteName('title' . $fieldSuffix))
			->from('#__helpdeskpro_categories')
			->where('id = ' . $row->category_id);
		$db->setQuery($query);
		$replaces['ticket_category'] =
$replaces['category_title'] = $db->loadResult();

		// Ticket status
		$query->clear()
			->select($db->quoteName('title' . $fieldSuffix))
			->from('#__helpdeskpro_statuses')
			->where('id = ' . (int) $row->status_id);
		$db->setQuery($query);
		$replaces['ticket_status'] = $db->loadResult();

		// Ticket priority
		$query->clear()
			->select($db->quoteName('title' . $fieldSuffix))
			->from('#__helpdeskpro_priorities')
			->where('id = ' . (int) $row->priority_id);
		$db->setQuery($query);
		$replaces['ticket_priority'] = $db->loadResult();

		return $replaces;
	}

	/**
	 *
	 * Function to get all available languages except the default language
	 * @return array object list
	 */
	public static function getLanguages()
	{
		$db      = Factory::getDbo();
		$query   = $db->getQuery(true);
		$default = self::getDefaultLanguage();
		$query->select('lang_id, lang_code, title, `sef`')
			->from('#__languages')
			->where('published = 1')
			->where('lang_code != "' . $default .
'"')
			->order('ordering');
		$db->setQuery($query);
		$languages = $db->loadObjectList();

		return $languages;
	}

	/**
	 * Get front-end default language
	 * @return string
	 */
	public static function getDefaultLanguage()
	{
		$params = ComponentHelper::getParams('com_languages');

		return $params->get('site', 'en-GB');
	}

	/**
	 * Get formatted file size of a file
	 *
	 * @param   string  $filePath
	 *
	 * @return string
	 */
	public static function getSize($filePath)
	{
		$kb   = 1024;
		$mb   = 1024 * $kb;
		$gb   = 1024 * $mb;
		$tb   = 1024 * $gb;
		$size = @filesize($filePath);

		if ($size)
		{
			if ($size < $kb)
			{
				$final    = round($size, 2);
				$fileSize = $final . ' ' . 'Byte';
			}
			elseif ($size < $mb)
			{
				$final    = round($size / $kb, 2);
				$fileSize = $final . ' ' . 'KB';
			}
			elseif ($size < $gb)
			{
				$final    = round($size / $mb, 2);
				$fileSize = $final . ' ' . 'MB';
			}
			elseif ($size < $tb)
			{
				$final    = round($size / $gb, 2);
				$fileSize = $final . ' ' . 'GB';
			}
			else
			{
				$final    = round($size / $tb, 2);
				$fileSize = $final . ' ' . 'TB';
			}
		}
		else
		{
			if ($size == 0)
			{
				$fileSize = 'EMPTY';
			}
			else
			{
				$fileSize = 'ERROR';
			}
		}

		return $fileSize;
	}

	/**
	 * Store ticket from input data
	 *
	 * @param   array  $data
	 *
	 * @return bool
	 */
	public static function storeTicket($data)
	{
		jimport('joomla.user.helper');

		$container =
\OSL\Container\Container::getInstance('com_helpdeskpro');

		$db     = $container->db;
		$user   = $container->user;
		$config = Helper::getConfig();

		$row = $container->factory->createTable('Ticket', $db);
		$row->bind($data);

		if ($user->get('id'))
		{
			$row->user_id = $user->get('id');
		}
		else
		{
			$sql = 'SELECT id FROM #__users WHERE email=' .
$db->quote($data['email']);
			$db->setQuery($sql);
			$row->user_id = $db->loadResult();
		}

		$row->status_id = $config->new_ticket_status_id;

		while (true)
		{
			$ticketCode = strtolower(UserHelper::genRandomPassword(10));
			$sql        = 'SELECT COUNT(*) FROM #__helpdeskpro_tickets WHERE
ticket_code=' . $db->quote($ticketCode);
			$db->setQuery($sql);
			$total = $db->loadResult();

			if (!$total)
			{
				break;
			}
		}

		$row->ticket_code  = $ticketCode;
		$row->created_date = $row->modified_date = gmdate('Y-m-d
H:i:s');
		$row->store(); //Store custom fields information for this ticket	

		Helper::sendNewTicketNotificationEmails($row, $config);

		return true;
	}

	/**
	 * Get email of user
	 *
	 * @param   int  $userId
	 *
	 * @return string
	 */
	public static function getUserEmail($userId)
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true)
			->select('email')
			->from('#__users')
			->where('id = ' . (int) $userId);
		$db->setQuery($query);

		return $db->loadResult();
	}

	/**
	 * Get avatar of user
	 *
	 * @param   int  $userId
	 *
	 * @return string
	 */
	public static function getUserAvatar($userId)
	{
		static $avatars = [];

		if (!isset($avatars[$userId]))
		{
			// Default avatar
			$avatars[$userId] =
'media/com_helpdeskpro/assets/images/icons/icon-user.jpeg';

			$db    = Factory::getDbo();
			$query = $db->getQuery(true);

			if (ComponentHelper::isInstalled('com_comprofiler') &&
ComponentHelper::isEnabled('com_comprofiler'))
			{
				$query->select('avatar')
					->from('#__comprofiler')
					->where('user_id=' . $userId . ' AND avatarapproved
= 1');
				$db->setQuery($query);
				$avatar = $db->loadResult();

				if ($avatar && file_exists(JPATH_ROOT .
'/images/comprofiler/' . $avatar))
				{
					$avatars[$userId] = 'images/comprofiler/' . $avatar;
				}
			}
			elseif (ComponentHelper::isInstalled('com_kunena') &&
ComponentHelper::isEnabled('com_kunena'))
			{
				$query->select('avatar')
					->from('#__kunena_users')
					->where('userid=' . $userId);
				$db->setQuery($query);
				$avatar = $db->loadResult();

				if ($avatar && file_exists(JPATH_ROOT .
'/media/kunena/avatars/resized/size72/' . $avatar))
				{
					$avatars[$userId] = 'media/kunena/avatars/resized/size72/' .
$avatar;
				}
			}
		}

		return $avatars[$userId];
	}


	/**
	 * Get Notification Emails for a given ticket
	 *
	 * @param   \Joomla\CMS\Table\Table  $ticket
	 *
	 * @return array
	 */
	public static function getTicketNotificationEmails($ticket,
$includeStaffEmail = false)
	{
		$config = static::getConfig();
		$db     = Factory::getDbo();
		$query  = $db->getQuery(true)
			->select('managers')
			->from('#__helpdeskpro_categories')
			->where('id = ' . (int) $ticket->category_id);
		$db->setQuery($query);
		$managers = trim($db->loadResult());

		if ($managers)
		{
			$managers = explode(',', $managers);
			$managers = array_map('trim', $managers);
			$query->clear()
				->select('email')
				->from('#__users')
				->where('username IN ("' .
implode('","', $managers) . '")');
			$db->setQuery($query);
			$emails = $db->loadColumn();
		}
		else
		{
			$config = static::getConfig();
			$emails = array_map('trim', explode(',',
$config->notification_emails));
		}

		if ($includeStaffEmail &&
$config->notify_staff_when_customer_reply &&
$ticket->staff_id)
		{
			$db    = Factory::getDbo();
			$query = $db->getQuery(true)
				->select('email')
				->from('#__users')
				->where('id = ' . (int) $ticket->staff_id);
			$db->setQuery($query);
			$email = $db->loadResult();

			if (MailHelper::isEmailAddress($email))
			{
				$emails[] = $email;
			}
		}

		return $emails;
	}

	/**
	 * Create and initialize mailer object from configuration data
	 *
	 * @return \JMail
	 */
	public static function getMailer()
	{
		$mailer = Factory::getMailer();
		$config = static::getConfig();

		if ($config->reply_to_email)
		{
			$mailer->addReplyTo($config->reply_to_email);
		}

		if ($config->from_name)
		{
			$fromName = $config->from_name;
		}
		else
		{
			$fromName = Factory::getConfig()->get('fromname');
		}

		if ($config->from_email)
		{
			$fromEmail = $config->from_email;
		}
		else
		{
			$fromEmail = Factory::getConfig()->get('mailfrom');
		}

		$mailer->setSender([$fromEmail, $fromName]);

		$mailer->isHtml(true);

		return $mailer;
	}

	/**
	 * Process sending after all the data has been initialized
	 *
	 * @param   \JMail  $mailer
	 * @param   array   $emails
	 * @param   string  $subject
	 * @param   string  $body
	 *
	 */
	public static function send($mailer, $emails, $subject, $body)
	{
		if (empty($subject))
		{
			return;
		}

		$emails = (array) $emails;

		$emails = array_map('trim', $emails);

		for ($i = 0, $n = count($emails); $i < $n; $i++)
		{
			if (!MailHelper::isEmailAddress($emails[$i]))
			{
				unset($emails[$i]);
			}
		}

		$emails = array_unique($emails);

		if (count($emails) == 0)
		{
			return;
		}

		$email = $emails[0];
		$mailer->addRecipient($email);

		if (count($emails) > 1)
		{
			unset($emails[0]);
			$bccEmails = $emails;
			$mailer->addBcc($bccEmails);
		}

		$body = static::convertImgTags($body);

		try
		{
			$mailer->setSubject($subject)
				->setBody($body)
				->Send();
		}
		catch (\Exception $e)
		{
			Factory::getApplication()->enqueueMessage($e->getMessage(),
'warning');
		}
	}

	/**
	 * Convert all img tags to use absolute URL
	 *
	 * @param   string  $text
	 *
	 * @return string
	 */
	public static function convertImgTags($text)
	{
		$app = Factory::getApplication();

		$siteUrl    = Uri::root();
		$rootURL    = rtrim(Uri::root(), '/');
		$subpathURL = Uri::root(true);

		if (!empty($subpathURL) && ($subpathURL != '/'))
		{
			$rootURL = substr($rootURL, 0, -1 * strlen($subpathURL));
		}

		// Replace index.php URI by SEF URI.
		if (strpos($text, 'href="index.php?') !== false)
		{
			preg_match_all('#href="index.php\?([^"]+)"#m',
$text, $matches);

			foreach ($matches[1] as $urlQueryString)
			{

				if ($app->isClient('site'))
				{
					$text = str_replace(
						'href="index.php?' . $urlQueryString .
'"',
						'href="' . $rootURL . Route::_('index.php?'
. $urlQueryString) . '"',
						$text
					);
				}
				else
				{
					$text = str_replace(
						'href="index.php?' . $urlQueryString .
'"',
						'href="' . $siteUrl . 'index.php?' .
$urlQueryString . '"',
						$text
					);
				}
			}
		}

		$patterns     = [];
		$replacements = [];
		$i            = 0;
		$src_exp      = "/src=\"(.*?)\"/";
		$link_exp     =
"[^http:\/\/www\.|^www\.|^https:\/\/|^http:\/\/]";

		preg_match_all($src_exp, $text, $out, PREG_SET_ORDER);

		foreach ($out as $val)
		{
			$links = preg_match($link_exp, $val[1], $match, PREG_OFFSET_CAPTURE);

			if ($links == '0')
			{
				$patterns[$i]     = $val[1];
				$patterns[$i]     = "\"$val[1]";
				$replacements[$i] = $siteUrl . $val[1];
				$replacements[$i] = "\"$replacements[$i]";
			}

			$i++;
		}

		$text = str_replace($patterns, $replacements, $text);

		return $text;
	}
}PK̑�[a��800Helper/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Helper;

use Joomla\CMS\Filesystem\File;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Table\Table;
use Joomla\Registry\Registry;
use OSL\Container\Container;

defined('_JEXEC') or die;

class Html
{
	/**
	 * Render ShowOn string
	 *
	 * @param array $fields
	 *
	 * @return string
	 */
	public static function renderShowOn($fields)
	{
		$output = [];

		$i = 0;

		foreach ($fields as $name => $values)
		{
			$i++;

			$values = (array) $values;

			$data = [
				'field'  => $name,
				'values' => $values,
				'sign'   => '=',
			];

			$data['op'] = $i > 1 ? 'AND' : '';

			$output[] = json_encode($data);
		}

		return '[' . implode(',', $output) . ']';
	}

	public static function buildCategoryDropdown($selected, $name =
'parent_id', $attr = null, $rows = [])
	{
		if (empty($rows))
		{
			$db    = Container::getInstance('com_helpdeskpro')->db;
			$query = $db->getQuery(true);
			$query->select('id, parent_id, title')
				->from('#__helpdeskpro_categories')
				->where('category_type IN (0, 1)')
				->where('published=1');
			$db->setQuery($query);
			$rows = $db->loadObjectList();
		}

		$children = [];

		if ($rows)
		{
			// first pass - collect children
			foreach ($rows as $v)
			{
				$pt   = (int) $v->parent_id;
				$list = @$children[$pt] ? $children[$pt] : [];
				array_push($list, $v);
				$children[$pt] = $list;
			}
		}

		$list      = HTMLHelper::_('menu.treerecurse', 0, '',
[], $children, 9999, 0, 0);
		$options   = [];
		$options[] = HTMLHelper::_('select.option', '0',
Text::_('HDP_SELECT_CATEGORY'));

		foreach ($list as $item)
		{
			$options[] = HTMLHelper::_('select.option', $item->id,
'&nbsp;&nbsp;&nbsp;' . $item->treename);
		}

		return HTMLHelper::_('select.genericlist', $options, $name,
			[
				'option.text.toHtml' => false,
				'option.text'        => 'text',
				'option.value'       => 'value',
				'list.attr'          => $attr,
				'list.select'        => $selected]);
	}

	/**
	 * Function to render a common layout which is used in different views
	 *
	 * @param string $layout
	 * @param array  $data
	 *
	 * @return string
	 * @throws \Exception
	 */
	public static function loadCommonLayout($layout, $data = [])
	{
		$app       =
Container::getInstance('com_helpdeskpro')->app;
		$themeFile = str_replace('/tmpl', '', $layout);

		if (File::exists($layout))
		{
			$path = $layout;
		}
		elseif (File::exists(JPATH_THEMES . '/' .
$app->getTemplate() . '/html/com_helpdeskpro/' . $themeFile))
		{
			$path = JPATH_THEMES . '/' . $app->getTemplate() .
'/html/com_helpdeskpro/' . $themeFile;
		}
		elseif (File::exists(JPATH_ROOT .
'/components/com_helpdeskpro/View/' . $layout))
		{
			$path = JPATH_ROOT . '/components/com_helpdeskpro/View/' .
$layout;
		}
		else
		{
			throw new \RuntimeException(Text::_('The given shared template path
is not exist'));
		}

		// Start an output buffer.
		ob_start();
		extract($data);

		// Load the layout.
		include $path;

		// Get the layout contents.
		return ob_get_clean();
	}

	/**
	 * Get page params of the given view
	 *
	 * @param $active
	 * @param $views
	 *
	 * @return Registry
	 */
	public static function getViewParams($active, $views)
	{
		if ($active && isset($active->query['view'])
&& in_array($active->query['view'], $views))
		{
			return $active->getParams();
		}

		return new Registry();
	}

	/**
	 * Helper method to prepare meta data for the document
	 *
	 * @param Registry $params
	 *
	 * @param Table  $item
	 */
	public static function prepareDocument($params, $item = null)
	{
		$container = Container::getInstance('com_helpdeskpro');

		$document = $container->document;
		$config   = $container->appConfig;

		$siteNamePosition = $config->get('sitename_pagetitles');
		$pageTitle        = $params->get('page_title');

		if ($pageTitle)
		{
			if ($siteNamePosition == 0)
			{
				$document->setTitle($pageTitle);
			}
			elseif ($siteNamePosition == 1)
			{
				$document->setTitle($config->get('sitename') . ' -
' . $pageTitle);
			}
			else
			{
				$document->setTitle($pageTitle . ' - ' .
$config->get('sitename'));
			}
		}

		if (!empty($item->meta_keywords))
		{
			$document->setMetaData('keywords',
$item->meta_keywords);
		}
		elseif ($params->get('menu-meta_keywords'))
		{
			$document->setMetaData('keywords',
$params->get('menu-meta_keywords'));
		}

		if (!empty($item->meta_description))
		{
			$document->setMetaData('description',
$item->meta_description);
		}
		elseif ($params->get('menu-meta_description'))
		{
			$document->setDescription($params->get('menu-meta_description'));
		}

		if ($params->get('robots'))
		{
			$document->setMetaData('robots',
$params->get('robots'));
		}
	}
}PK̑�[E.����Helper/Jquery.phpnu�[���<?php
/**
 * @version            3.8
 * @package            Joomla
 * @subpackage         Joom Donation
 * @author             Tuan Pham Ngoc
 * @copyright          Copyright (C) 2009 - 2019 Ossolution Team
 * @license            GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Helper;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

class Jquery
{
	/**
	 * validate form
	 */
	public static function validateForm()
	{
		static $loaded = false;

		if (!$loaded)
		{
			$rootUri  = Uri::root(true);
			$document = Factory::getDocument();
			$document->addStyleSheet($rootUri .
'/media/com_helpdeskpro/assets/js/validate/css/validationEngine.jquery.css');

			// Add possible language files for jquery validation engine
			$tag   = Factory::getLanguage()->getTag();
			$tag   = substr($tag, 0, 2);
			$files = [
				"jquery.validationEngine-$tag.custom.js",
				"jquery.validationEngine-$tag.js",
				"jquery.validationEngine-en.js",
			];

			foreach ($files as $file)
			{
				if (file_exists(JPATH_ROOT .
'/media/com_helpdeskpro/assets/js/validate/js/languages/' .
$file))
				{
					$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/validate/js/languages/' .
$file);
					break;
				}
			}

			// Add validation engine
			$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/validate/js/jquery.validationEngine.js');

			$loaded = true;
		}
	}
}PK̑�[se�tXMXMHelper/mime.mapping.phpnu�[���<?php
return array(
	'__MAXPERIOD__' => '1',
	'3ds'           => 'image/x-3ds',
	'BLEND'         => 'application/x-blender',
	'C'             => 'text/x-c++src',
	'CSSL'          => 'text/css',
	'NSV'           => 'video/x-nsv',
	'XM'            => 'audio/x-mod',
	'Z'             => 'application/x-compress',
	'a'             => 'application/x-archive',
	'abw'           => 'application/x-abiword',
	'abw.gz'        => 'application/x-abiword',
	'ac3'           => 'audio/ac3',
	'adb'           => 'text/x-adasrc',
	'ads'           => 'text/x-adasrc',
	'afm'           => 'application/x-font-afm',
	'ag'            => 'image/x-applix-graphics',
	'ai'            => 'application/illustrator',
	'aif'           => 'audio/x-aiff',
	'aifc'          => 'audio/x-aiff',
	'aiff'          => 'audio/x-aiff',
	'al'            => 'application/x-perl',
	'arj'           => 'application/x-arj',
	'as'            =>
'application/x-applix-spreadsheet',
	'asc'           => 'text/plain',
	'asf'           => 'video/x-ms-asf',
	'asp'           => 'application/x-asp',
	'asx'           => 'video/x-ms-asf',
	'au'            => 'audio/basic',
	'avi'           => 'video/x-msvideo',
	'aw'            => 'application/x-applix-word',
	'bak'           => 'application/x-trash',
	'bcpio'         => 'application/x-bcpio',
	'bdf'           => 'application/x-font-bdf',
	'bib'           => 'text/x-bibtex',
	'bin'           => 'application/octet-stream',
	'blend'         => 'application/x-blender',
	'blender'       => 'application/x-blender',
	'bmp'           => 'image/bmp',
	'bz'            => 'application/x-bzip',
	'bz2'           => 'application/x-bzip',
	'c'             => 'text/x-csrc',
	'c++'           => 'text/x-c++src',
	'cc'            => 'text/x-c++src',
	'cdf'           => 'application/x-netcdf',
	'cdr'           => 'application/vnd.corel-draw',
	'cer'           => 'application/x-x509-ca-cert',
	'cert'          => 'application/x-x509-ca-cert',
	'cgi'           => 'application/x-cgi',
	'cgm'           => 'image/cgm',
	'chrt'          => 'application/x-kchart',
	'class'         => 'application/x-java',
	'cls'           => 'text/x-tex',
	'cpio'          => 'application/x-cpio',
	'cpio.gz'       =>
'application/x-cpio-compressed',
	'cpp'           => 'text/x-c++src',
	'cpt'           => 'application/mac-compactpro',
	'crt'           => 'application/x-x509-ca-cert',
	'cs'            => 'text/x-csharp',
	'csh'           => 'application/x-shellscript',
	'css'           => 'text/css',
	'csv'           =>
'text/x-comma-separated-values',
	'cur'           => 'image/x-win-bitmap',
	'cxx'           => 'text/x-c++src',
	'dat'           => 'video/mpeg',
	'dbf'           => 'application/x-dbase',
	'dc'            => 'application/x-dc-rom',
	'dcl'           => 'text/x-dcl',
	'dcm'           => 'image/x-dcm',
	'dcr'           => 'application/x-director',
	'deb'           => 'application/x-deb',
	'der'           => 'application/x-x509-ca-cert',
	'desktop'       => 'application/x-desktop',
	'dia'           => 'application/x-dia-diagram',
	'diff'          => 'text/x-patch',
	'dir'           => 'application/x-director',
	'djv'           => 'image/vnd.djvu',
	'djvu'          => 'image/vnd.djvu',
	'dll'           => 'application/octet-stream',
	'dms'           => 'application/octet-stream',
	'doc'           => 'application/msword',
	'dsl'           => 'text/x-dsl',
	'dtd'           => 'text/x-dtd',
	'dvi'           => 'application/x-dvi',
	'dwg'           => 'image/vnd.dwg',
	'dxf'           => 'image/vnd.dxf',
	'dxr'           => 'application/x-director',
	'egon'          => 'application/x-egon',
	'el'            => 'text/x-emacs-lisp',
	'eps'           => 'image/x-eps',
	'epsf'          => 'image/x-eps',
	'epsi'          => 'image/x-eps',
	'etheme'        => 'application/x-e-theme',
	'etx'           => 'text/x-setext',
	'exe'           => 'application/x-executable',
	'ez'            => 'application/andrew-inset',
	'f'             => 'text/x-fortran',
	'fig'           => 'image/x-xfig',
	'fits'          => 'image/x-fits',
	'flac'          => 'audio/x-flac',
	'flc'           => 'video/x-flic',
	'fli'           => 'video/x-flic',
	'flw'           => 'application/x-kivio',
	'fo'            => 'text/x-xslfo',
	'g3'            => 'image/fax-g3',
	'gb'            => 'application/x-gameboy-rom',
	'gcrd'          => 'text/x-vcard',
	'gen'           => 'application/x-genesis-rom',
	'gg'            => 'application/x-sms-rom',
	'gif'           => 'image/gif',
	'glade'         => 'application/x-glade',
	'gmo'           =>
'application/x-gettext-translation',
	'gnc'           => 'application/x-gnucash',
	'gnucash'       => 'application/x-gnucash',
	'gnumeric'      => 'application/x-gnumeric',
	'gra'           => 'application/x-graphite',
	'gsf'           => 'application/x-font-type1',
	'gtar'          => 'application/x-gtar',
	'gz'            => 'application/x-gzip',
	'h'             => 'text/x-chdr',
	'h++'           => 'text/x-chdr',
	'hdf'           => 'application/x-hdf',
	'hh'            => 'text/x-c++hdr',
	'hp'            => 'text/x-chdr',
	'hpgl'          => 'application/vnd.hp-hpgl',
	'hqx'           => 'application/mac-binhex40',
	'hs'            => 'text/x-haskell',
	'htm'           => 'text/html',
	'html'          => 'text/html',
	'icb'           => 'image/x-icb',
	'ice'           => 'x-conference/x-cooltalk',
	'ico'           => 'image/x-ico',
	'ics'           => 'text/calendar',
	'idl'           => 'text/x-idl',
	'ief'           => 'image/ief',
	'ifb'           => 'text/calendar',
	'iff'           => 'image/x-iff',
	'iges'          => 'model/iges',
	'igs'           => 'model/iges',
	'ilbm'          => 'image/x-ilbm',
	'iso'           => 'application/x-cd-image',
	'it'            => 'audio/x-it',
	'jar'           => 'application/x-jar',
	'java'          => 'text/x-java',
	'jng'           => 'image/x-jng',
	'jp2'           => 'image/jpeg2000',
	'jpg'           => 'image/jpeg',
	'jpe'           => 'image/jpeg',
	'jpeg'          => 'image/jpeg',
	'jpr'           =>
'application/x-jbuilder-project',
	'jpx'           =>
'application/x-jbuilder-project',
	'js'            => 'application/x-javascript',
	'kar'           => 'audio/midi',
	'karbon'        => 'application/x-karbon',
	'kdelnk'        => 'application/x-desktop',
	'kfo'           => 'application/x-kformula',
	'kil'           => 'application/x-killustrator',
	'kon'           => 'application/x-kontour',
	'kpm'           => 'application/x-kpovmodeler',
	'kpr'           => 'application/x-kpresenter',
	'kpt'           => 'application/x-kpresenter',
	'kra'           => 'application/x-krita',
	'ksp'           => 'application/x-kspread',
	'kud'           => 'application/x-kugar',
	'kwd'           => 'application/x-kword',
	'kwt'           => 'application/x-kword',
	'la'            =>
'application/x-shared-library-la',
	'latex'         => 'application/x-latex',
	'lha'           => 'application/x-lha',
	'lhs'           => 'text/x-literate-haskell',
	'lhz'           => 'application/x-lhz',
	'log'           => 'text/x-log',
	'ltx'           => 'text/x-tex',
	'lwo'           => 'image/x-lwo',
	'lwob'          => 'image/x-lwo',
	'lws'           => 'image/x-lws',
	'lyx'           => 'application/x-lyx',
	'lzh'           => 'application/x-lha',
	'lzo'           => 'application/x-lzop',
	'm'             => 'text/x-objcsrc',
	'm15'           => 'audio/x-mod',
	'm3u'           => 'audio/x-mpegurl',
	'man'           => 'application/x-troff-man',
	'md'            => 'application/x-genesis-rom',
	'me'            => 'text/x-troff-me',
	'mesh'          => 'model/mesh',
	'mgp'           => 'application/x-magicpoint',
	'mid'           => 'audio/midi',
	'midi'          => 'audio/midi',
	'mif'           => 'application/x-mif',
	'mkv'           => 'application/x-matroska',
	'mm'            => 'text/x-troff-mm',
	'mml'           => 'text/mathml',
	'mng'           => 'video/x-mng',
	'moc'           => 'text/x-moc',
	'mod'           => 'audio/x-mod',
	'moov'          => 'video/quicktime',
	'mov'           => 'video/quicktime',
	'movie'         => 'video/x-sgi-movie',
	'mp2'           => 'video/mpeg',
	'mp3'           => 'audio/x-mp3',
	'mpe'           => 'video/mpeg',
	'mpeg'          => 'video/mpeg',
	'mpg'           => 'video/mpeg',
	'mpga'          => 'audio/mpeg',
	'ms'            => 'text/x-troff-ms',
	'msh'           => 'model/mesh',
	'msod'          => 'image/x-msod',
	'msx'           => 'application/x-msx-rom',
	'mtm'           => 'audio/x-mod',
	'mxu'           => 'video/vnd.mpegurl',
	'n64'           => 'application/x-n64-rom',
	'nc'            => 'application/x-netcdf',
	'nes'           => 'application/x-nes-rom',
	'nsv'           => 'video/x-nsv',
	'o'             => 'application/x-object',
	'obj'           => 'application/x-tgif',
	'oda'           => 'application/oda',
	'odb'           =>
'application/vnd.oasis.opendocument.database',
	'odc'           =>
'application/vnd.oasis.opendocument.chart',
	'odf'           =>
'application/vnd.oasis.opendocument.formula',
	'odg'           =>
'application/vnd.oasis.opendocument.graphics',
	'odi'           =>
'application/vnd.oasis.opendocument.image',
	'odm'           =>
'application/vnd.oasis.opendocument.text-master',
	'odp'           =>
'application/vnd.oasis.opendocument.presentation',
	'ods'           =>
'application/vnd.oasis.opendocument.spreadsheet',
	'odt'           =>
'application/vnd.oasis.opendocument.text',
	'ogg'           => 'application/ogg',
	'old'           => 'application/x-trash',
	'oleo'          => 'application/x-oleo',
	'otg'           =>
'application/vnd.oasis.opendocument.graphics-template',
	'oth'           =>
'application/vnd.oasis.opendocument.text-web',
	'otp'           =>
'application/vnd.oasis.opendocument.presentation-template',
	'ots'           =>
'application/vnd.oasis.opendocument.spreadsheet-template',
	'ott'           =>
'application/vnd.oasis.opendocument.text-template',
	'p'             => 'text/x-pascal',
	'p12'           => 'application/x-pkcs12',
	'p7s'           => 'application/pkcs7-signature',
	'pas'           => 'text/x-pascal',
	'patch'         => 'text/x-patch',
	'pbm'           => 'image/x-portable-bitmap',
	'pcd'           => 'image/x-photo-cd',
	'pcf'           => 'application/x-font-pcf',
	'pcf.Z'         => 'application/x-font-type1',
	'pcl'           => 'application/vnd.hp-pcl',
	'pdb'           => 'application/vnd.palm',
	'pdf'           => 'application/pdf',
	'pem'           => 'application/x-x509-ca-cert',
	'perl'          => 'application/x-perl',
	'pfa'           => 'application/x-font-type1',
	'pfb'           => 'application/x-font-type1',
	'pfx'           => 'application/x-pkcs12',
	'pgm'           => 'image/x-portable-graymap',
	'pgn'           => 'application/x-chess-pgn',
	'pgp'           => 'application/pgp',
	'php'           => 'application/x-php',
	'php3'          => 'application/x-php',
	'php4'          => 'application/x-php',
	'pict'          => 'image/x-pict',
	'pict1'         => 'image/x-pict',
	'pict2'         => 'image/x-pict',
	'pl'            => 'application/x-perl',
	'pls'           => 'audio/x-scpls',
	'pm'            => 'application/x-perl',
	'png'           => 'image/png',
	'pnm'           => 'image/x-portable-anymap',
	'po'            => 'text/x-gettext-translation',
	'pot'           =>
'application/vnd.ms-powerpoint',
	'ppm'           => 'image/x-portable-pixmap',
	'pps'           =>
'application/vnd.ms-powerpoint',
	'ppt'           =>
'application/vnd.ms-powerpoint',
	'ppz'           =>
'application/vnd.ms-powerpoint',
	'ps'            => 'application/postscript',
	'ps.gz'         => 'application/x-gzpostscript',
	'psd'           => 'image/x-psd',
	'psf'           => 'application/x-font-linux-psf',
	'psid'          => 'audio/prs.sid',
	'pw'            => 'application/x-pw',
	'py'            => 'application/x-python',
	'pyc'           =>
'application/x-python-bytecode',
	'pyo'           =>
'application/x-python-bytecode',
	'qif'           => 'application/x-qw',
	'qt'            => 'video/quicktime',
	'qtvr'          => 'video/quicktime',
	'ra'            => 'audio/x-pn-realaudio',
	'ram'           => 'audio/x-pn-realaudio',
	'rar'           => 'application/x-rar',
	'ras'           => 'image/x-cmu-raster',
	'rdf'           => 'text/rdf',
	'rej'           => 'application/x-reject',
	'rgb'           => 'image/x-rgb',
	'rle'           => 'image/rle',
	'rm'            => 'audio/x-pn-realaudio',
	'roff'          => 'application/x-troff',
	'rpm'           => 'application/x-rpm',
	'rss'           => 'text/rss',
	'rtf'           => 'application/rtf',
	'rtx'           => 'text/richtext',
	's3m'           => 'audio/x-s3m',
	'sam'           => 'application/x-amipro',
	'scm'           => 'text/x-scheme',
	'sda'           =>
'application/vnd.stardivision.draw',
	'sdc'           =>
'application/vnd.stardivision.calc',
	'sdd'           =>
'application/vnd.stardivision.impress',
	'sdp'           =>
'application/vnd.stardivision.impress',
	'sds'           =>
'application/vnd.stardivision.chart',
	'sdw'           =>
'application/vnd.stardivision.writer',
	'sgi'           => 'image/x-sgi',
	'sgl'           =>
'application/vnd.stardivision.writer',
	'sgm'           => 'text/sgml',
	'sgml'          => 'text/sgml',
	'sh'            => 'application/x-shellscript',
	'shar'          => 'application/x-shar',
	'shtml'         => 'text/html',
	'siag'          => 'application/x-siag',
	'sid'           => 'audio/prs.sid',
	'sik'           => 'application/x-trash',
	'silo'          => 'model/mesh',
	'sit'           => 'application/x-stuffit',
	'skd'           => 'application/x-koan',
	'skm'           => 'application/x-koan',
	'skp'           => 'application/x-koan',
	'skt'           => 'application/x-koan',
	'slk'           => 'text/spreadsheet',
	'smd'           =>
'application/vnd.stardivision.mail',
	'smf'           =>
'application/vnd.stardivision.math',
	'smi'           => 'application/smil',
	'smil'          => 'application/smil',
	'sml'           => 'application/smil',
	'sms'           => 'application/x-sms-rom',
	'snd'           => 'audio/basic',
	'so'            => 'application/x-sharedlib',
	'spd'           => 'application/x-font-speedo',
	'spl'           => 'application/x-futuresplash',
	'sql'           => 'text/x-sql',
	'src'           => 'application/x-wais-source',
	'stc'           =>
'application/vnd.sun.xml.calc.template',
	'std'           =>
'application/vnd.sun.xml.draw.template',
	'sti'           =>
'application/vnd.sun.xml.impress.template',
	'stm'           => 'audio/x-stm',
	'stw'           =>
'application/vnd.sun.xml.writer.template',
	'sty'           => 'text/x-tex',
	'sun'           => 'image/x-sun-raster',
	'sv4cpio'       => 'application/x-sv4cpio',
	'sv4crc'        => 'application/x-sv4crc',
	'svg'           => 'image/svg+xml',
	'swf'           =>
'application/x-shockwave-flash',
	'sxc'           => 'application/vnd.sun.xml.calc',
	'sxd'           => 'application/vnd.sun.xml.draw',
	'sxg'           =>
'application/vnd.sun.xml.writer.global',
	'sxi'           =>
'application/vnd.sun.xml.impress',
	'sxm'           => 'application/vnd.sun.xml.math',
	'sxw'           =>
'application/vnd.sun.xml.writer',
	'sylk'          => 'text/spreadsheet',
	't'             => 'application/x-troff',
	'tar'           => 'application/x-tar',
	'tar.Z'         => 'application/x-tarz',
	'tar.bz'        =>
'application/x-bzip-compressed-tar',
	'tar.bz2'       =>
'application/x-bzip-compressed-tar',
	'tar.gz'        => 'application/x-compressed-tar',
	'tar.lzo'       => 'application/x-tzo',
	'tcl'           => 'text/x-tcl',
	'tex'           => 'text/x-tex',
	'texi'          => 'text/x-texinfo',
	'texinfo'       => 'text/x-texinfo',
	'tga'           => 'image/x-tga',
	'tgz'           => 'application/x-compressed-tar',
	'theme'         => 'application/x-theme',
	'tif'           => 'image/tiff',
	'tiff'          => 'image/tiff',
	'tk'            => 'text/x-tcl',
	'torrent'       => 'application/x-bittorrent',
	'tr'            => 'application/x-troff',
	'ts'            => 'application/x-linguist',
	'tsv'           => 'text/tab-separated-values',
	'ttf'           => 'application/x-font-ttf',
	'txt'           => 'text/plain',
	'tzo'           => 'application/x-tzo',
	'ui'            => 'application/x-designer',
	'uil'           => 'text/x-uil',
	'ult'           => 'audio/x-mod',
	'uni'           => 'audio/x-mod',
	'uri'           => 'text/x-uri',
	'url'           => 'text/x-uri',
	'ustar'         => 'application/x-ustar',
	'vcd'           => 'application/x-cdlink',
	'vcf'           => 'text/x-vcalendar',
	'vcs'           => 'text/x-vcalendar',
	'vct'           => 'text/x-vcard',
	'vfb'           => 'text/calendar',
	'vob'           => 'video/mpeg',
	'voc'           => 'audio/x-voc',
	'vor'           =>
'application/vnd.stardivision.writer',
	'vrml'          => 'model/vrml',
	'vsd'           => 'application/vnd.visio',
	'wav'           => 'audio/x-wav',
	'wax'           => 'audio/x-ms-wax',
	'wb1'           => 'application/x-quattropro',
	'wb2'           => 'application/x-quattropro',
	'wb3'           => 'application/x-quattropro',
	'wbmp'          => 'image/vnd.wap.wbmp',
	'wbxml'         => 'application/vnd.wap.wbxml',
	'wk1'           => 'application/vnd.lotus-1-2-3',
	'wk3'           => 'application/vnd.lotus-1-2-3',
	'wk4'           => 'application/vnd.lotus-1-2-3',
	'wks'           => 'application/vnd.lotus-1-2-3',
	'wm'            => 'video/x-ms-wm',
	'wma'           => 'audio/x-ms-wma',
	'wmd'           => 'application/x-ms-wmd',
	'wmf'           => 'image/x-wmf',
	'wml'           => 'text/vnd.wap.wml',
	'wmlc'          => 'application/vnd.wap.wmlc',
	'wmls'          => 'text/vnd.wap.wmlscript',
	'wmlsc'         =>
'application/vnd.wap.wmlscriptc',
	'wmv'           => 'video/x-ms-wmv',
	'wmx'           => 'video/x-ms-wmx',
	'wmz'           => 'application/x-ms-wmz',
	'wpd'           => 'application/wordperfect',
	'wpg'           => 'application/x-wpg',
	'wri'           => 'application/x-mswrite',
	'wrl'           => 'model/vrml',
	'wvx'           => 'video/x-ms-wvx',
	'xac'           => 'application/x-gnucash',
	'xbel'          => 'application/x-xbel',
	'xbm'           => 'image/x-xbitmap',
	'xcf'           => 'image/x-xcf',
	'xcf.bz2'       => 'image/x-compressed-xcf',
	'xcf.gz'        => 'image/x-compressed-xcf',
	'xht'           => 'application/xhtml+xml',
	'xhtml'         => 'application/xhtml+xml',
	'xi'            => 'audio/x-xi',
	'xls'           => 'application/vnd.ms-excel',
	'xla'           => 'application/vnd.ms-excel',
	'xlc'           => 'application/vnd.ms-excel',
	'xld'           => 'application/vnd.ms-excel',
	'xll'           => 'application/vnd.ms-excel',
	'xlm'           => 'application/vnd.ms-excel',
	'xlt'           => 'application/vnd.ms-excel',
	'xlw'           => 'application/vnd.ms-excel',
	'xm'            => 'audio/x-xm',
	'xml'           => 'text/xml',
	'xpm'           => 'image/x-xpixmap',
	'xsl'           => 'text/x-xslt',
	'xslfo'         => 'text/x-xslfo',
	'xslt'          => 'text/x-xslt',
	'xwd'           => 'image/x-xwindowdump',
	'xyz'           => 'chemical/x-xyz',
	'zabw'          => 'application/x-abiword',
	'zip'           => 'application/zip',
	'zoo'           => 'application/x-zoo',
	'123'           => 'application/vnd.lotus-1-2-3',
	'669'           => 'audio/x-mod'
);PK̑�[p#9#9#Helper/Route.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Helper;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;

defined('_JEXEC') or die;

class Route
{
	/**
	 * Cached categories
	 *
	 * @var array
	 */
	protected static $categories;

	/**
	 * Cached articles, which can be passed from outside to reduce number of
queries
	 *
	 * @var array
	 */
	protected static $articles = [];

	/**
	 * Store menu items created to link to the component
	 *
	 * @var array
	 */
	protected static $lookup;

	/**
	 * Function to get Tickets Route
	 *
	 * @param   string  $language
	 *
	 * @return string
	 */
	public static function getTicketsRoute($language = '*')
	{
		$link = 'index.php?option=com_helpdeskpro&view=tickets';

		$needles = [
			'tickets' => [0],
		];

		if ($language != "*" && Multilanguage::isEnabled())
		{
			$link                .= '&lang=' . $language;
			$needles['language'] = $language;
		}

		if ($item = self::findItem($needles))
		{
			$link .= '?Itemid=' . $item;
		}

		return $link;
	}

	/**
	 * Function to get Ticket Route
	 *
	 * @param   mixed   $id  Ticket ID or Ticket Code, depends on $isId
parameter
	 * @param   bool    $isId
	 * @param   string  $language
	 *
	 * @return string
	 */
	public static function getTicketRoute($id, $isId = true, $language =
'*')
	{
		$link = 'index.php?option=com_helpdeskpro&view=ticket';

		if ($isId)
		{
			$link .= '&id=' . $id;
		}
		else
		{
			$link .= '&ticket_code=' . $id;
		}

		if ($language != "*" && Multilanguage::isEnabled())
		{
			$link .= '&lang=' . $language;
		}

		if ($isId)
		{
			if ($item = self::findItem(['tickets' => [0],
'language' => $language]))
			{
				$link .= '&Itemid=' . $item;
			}
			elseif ($item = self::findItem(['ticket' => [0],
'language' => $language]))
			{
				$link .= '&layout=default&Itemid=' . $item;
			}
		}
		else
		{
			if ($item = self::findItem(['ticket' => [0],
'language' => $language]))
			{
				$link .= '&layout=default&Itemid=' . $item;
			}
		}

		return $link;
	}

	/**
	 * Method to get articles route (display articles from a category)
	 *
	 * @param           $id
	 * @param   int     $itemId
	 * @param   string  $language
	 */
	public static function getArticlesRoute($id, $itemId = 0, $language =
'*')
	{
		$link =
'index.php?option=com_helpdeskpro&view=articles&id=' .
$id;

		$needles = ['articles' => [$id]];

		if ($language != "*" && Multilanguage::isEnabled())
		{
			$needles['language'] = $language;
			$link                .= '&lang=' . $language;
		}

		if ($item = self::findItem($needles, $itemId))
		{
			$link .= '&Itemid=' . $item;
		}

		return $link;
	}

	/**
	 * @param   int     $id
	 * @param   int     $catId
	 * @param   int     $itemId
	 * @param   string  $language
	 */
	public static function getArticleRoute($id, $catId, $itemId = 0, $language
= '*')
	{
		$id      = (int) $id;
		$needles = ['article' => [$id]];
		$link    =
'index.php?option=com_helpdeskpro&view=article&id=' .
$id;

		if (!$catId)
		{
			//Find the main category of this event
			$db    = Factory::getDbo();
			$query = $db->getQuery(true)
				->select('category_id')
				->from('#__helpdeskpro_articles')
				->where('id = ' . $id);
			$db->setQuery($query);
			$catId = (int) $db->loadResult();
		}

		if ($catId)
		{
			$needles['articles'] = self::getCategoriesPath($catId,
'id', false);
			$link                .= '&catid=' . $catId;
		}

		$needles['categories'] = [0];

		if ($language != "*" && Multilanguage::isEnabled())
		{
			$link .= '&lang=' . $language;

			$needles['language'] = $language;
		}

		if ($item = self::findItem($needles, $itemId))
		{
			$link .= '&Itemid=' . $item;
		}

		return $link;
	}

	/**
	 * Get path to the category
	 *
	 * @param   int     $id
	 * @param   string  $type
	 * @param   bool    $reverse
	 *
	 * @return array
	 */
	public static function getCategoriesPath($id, $type = 'id',
$reverse = true)
	{
		self::getCategories();;

		$paths = [];

		if ($type == 'id')
		{
			do
			{
				$paths[] = self::$categories[$id]->{$type};
				$id      = self::$categories[$id]->parent_id;
			} while ($id != 0);

			if ($reverse)
			{
				$paths = array_reverse($paths);
			}
		}
		else
		{
			$paths[] = self::$categories[$id]->{$type};
		}

		return $paths;
	}

	/**
	 * Find item id variable corresponding to the view
	 *
	 * @param   string  $view
	 * @param   int     $itemId
	 * @param   string  $language
	 *
	 * @return int
	 */
	public static function findView($view, $itemId, $language =
'*')
	{
		$needles = [
			$view => [0],
		];

		if ($language != "*" && Multilanguage::isEnabled())
		{
			$needles['language'] = $language;
		}

		if ($item = self::findItem($needles, $itemId))
		{
			return $item;
		}

		return 0;
	}

	/**
	 *
	 * Function to find Itemid
	 *
	 * @param   string  $needles
	 * @param   int     $itemId
	 *
	 * @return int
	 */
	public static function findItem($needles = null, $itemId = 0)
	{
		$app      = Factory::getApplication();
		$menus    = $app->getMenu('site');
		$language = isset($needles['language']) ?
$needles['language'] : '*';

		// Prepare the reverse lookup array.
		if (!isset(self::$lookup[$language]))
		{
			self::$lookup[$language] = array();

			$component =
ComponentHelper::getComponent('com_helpdeskpro');

			$attributes = array('component_id');
			$values     = array($component->id);

			if ($language != '*')
			{
				$attributes[] = 'language';
				$values[]     = array($needles['language'], '*');
			}

			$items = $menus->getItems($attributes, $values);

			foreach ($items as $item)
			{
				if (isset($item->query) &&
isset($item->query['view']))
				{
					$view = $item->query['view'];

					if (!isset(self::$lookup[$language][$view]))
					{
						self::$lookup[$language][$view] = array();
					}

					if (isset($item->query['id']) ||
$item->query['filter_category_id'])
					{
						$id = isset($item->query['id']) ?
$item->query['id'] :
$item->query['filter_category_id'];

						/**
						 * Here it will become a bit tricky
						 * language != * can override existing entries
						 * language == * cannot override existing entries
						 */
						if (!isset(self::$lookup[$language][$view][$id]) ||
$item->language != '*')
						{
							self::$lookup[$language][$view][$id] = $item->id;
						}
					}
				}
			}
		}

		if ($needles)
		{
			foreach ($needles as $view => $ids)
			{
				if (isset(self::$lookup[$language][$view]))
				{
					foreach ($ids as $id)
					{
						if (isset(self::$lookup[$language][$view][(int) $id]))
						{
							return self::$lookup[$language][$view][(int) $id];
						}
					}
				}
			}
		}

		//Return default item id
		return $itemId;
	}

	/**
	 * Get categories
	 *
	 * @return void
	 */
	protected static function getCategories()
	{
		$db    = Factory::getDbo();
		$query = $db->getQuery(true)
			->select('id,
parent_id')->from('#__helpdeskpro_categories')
			->where('published = 1');

		if ($fieldSuffix = Helper::getFieldSuffix())
		{
			$aliasField = $db->quoteName('alias' . $fieldSuffix);
			$query->select("IF(CHAR_LENGTH($aliasField) > 0, $aliasField,
alias) AS alias");
		}
		else
		{
			$query->select('alias');
		}

		$db->setQuery($query);

		self::$categories = $db->loadObjectList('id');
	}

	/**
	 * Add articles to cached articles
	 *
	 * @param   array  $articles
	 */
	public static function addArticles($articles)
	{
		foreach ($articles as $article)
		{
			self::$articles[$article->id] = $article;
		}
	}

	/**
	 * Get alias of category
	 *
	 * @param   int  $id
	 *
	 * @return string
	 */
	public static function getCategoryAlias($id)
	{
		self::getCategories();

		return self::$categories[$id]->alias;
	}

	/**
	 * Method to get article alias
	 *
	 * @param   int  $id
	 *
	 * @return string
	 */
	public static function getArticleAlias($id)
	{
		if (isset(self::$articles[$id]))
		{
			$db = Factory::getDbo();

			$query = $db->getQuery(true)
				->select('id')->from('#__helpdeskpro_articles')
				->where('id = ' . $id);

			if ($fieldSuffix = Helper::getFieldSuffix())
			{
				$aliasField = $db->quoteName('alias' . $fieldSuffix);
				$query->select("IF(CHAR_LENGTH($aliasField) > 0,
$aliasField, alias) AS alias");
			}
			else
			{
				$query->select('alias');
			}

			$db->setQuery($query);

			self::$articles[$id] = $db->loadObject();
		}

		return self::$articles[$id]->alias;
	}
}PK̑�[ł
KKModel/Article.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Model;

use OSL\Model\Model;
use OSL\Utils\Database as DatabaseUtils;
use Ossolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;

defined('_JEXEC') or die;

class Article extends Model
{
	/**
	 * Initialize the model, add new states
	 */
	protected function initialize()
	{
		$this->state->insert('id', 'int', 0);
	}

	/**
	 *
	 */
	public function getData()
	{
		$db    = $this->getDbo();
		$query = $db->getQuery(true);
		$query->select('*')
			->from('#__helpdeskpro_articles')
			->where('id = ' . $this->state->id)
			->where('published = 1');

		if ($fieldSuffix = HelpdeskproHelper::getFieldSuffix())
		{
			DatabaseUtils::getMultilingualFields($query, array('title',
'text'), $fieldSuffix);
		}

		$db->setQuery($query);

		return $db->loadObject();
	}


	public function hits()
	{
		$db = $this->getDbo();

		$query = $db->getQuery(true);
		$query->update('#__helpdeskpro_articles')
			->set('hits = hits + 1')
			->where('id = ' . $this->state->id);
		$db->setQuery($query);

		$db->execute();
	}
}PK̑�[��7q��Model/Articles.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Model;

use OSL\Container\Container;
use OSL\Model\ListModel;
use OSL\Utils\Database as DatabaseUtils;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskProHelper;

defined('_JEXEC') or die;

class Articles extends ListModel
{
	protected $clearJoin = false;

	/**
	 * Constructor.
	 *
	 * @param   Container  $container
	 * @param   array      $options
	 */
	public function __construct(Container $container, $options = [])
	{

		$options['search_fields'] = ['tbl.id',
'tbl.title', 'tbl.text'];

		$options['remember_states'] = true;

		parent::__construct($container, $options);
	}

	/**
	 * Initialize the model, add new states
	 */
	protected function initialize()
	{
		$this->state->insert('id', 'int', 0);
	}

	/**
	 * Build the query object which is used to get list of records from
database
	 *
	 * @return \JDatabaseQuery
	 */
	protected function buildListQuery()
	{
		$query = parent::buildListQuery();

		if ($fieldSuffix = HelpdeskProHelper::getFieldSuffix())
		{
			DatabaseUtils::getMultilingualFields($query, ['tbl.title'],
$fieldSuffix);
		}

		$query->innerJoin('#__helpdeskpro_categories AS c ON
tbl.category_id = c.id')
			->where('tbl.published = 1')
			->where('c.published = 1')
			->where('c.access IN (' . implode(',',
$this->container->user->getAuthorisedViewLevels()) .
')');

		if ($this->state->id)
		{
			$query->where('tbl.category_id = ' .
$this->state->id);
		}

		return $query;
	}
}PK̑�[s'�Model/Categories.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\Model;

use OSL\Model\ListModel;
use OSL\Utils\Database as DatabaseUtils;
use Ossolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;

defined('_JEXEC') or die;

class Categories extends ListModel
{

	/**
	 * Clear join clause for getTotal method
	 *
	 * @var bool
	 */
	protected $clearJoin = false;

	/**
	 * Build the query object which is used to get list of records from
database
	 *
	 * @return \JDatabaseQuery
	 */
	protected function buildListQuery()
	{
		$query = parent::buildListQuery();
		$user  = $this->container->user;

		$query->select('COUNT(b.id) AS total_articles')
			->innerJoin('#__helpdeskpro_articles AS b ON tbl.id =
b.category_id')
			->where('tbl.published = 1')
			->where('tbl.access IN (' . implode(',',
$user->getAuthorisedViewLevels()) . ')')
			->where('b.published = 1')
			->group('tbl.id');


		if ($fieldSuffix = HelpdeskproHelper::getFieldSuffix())
		{
			DatabaseUtils::getMultilingualFields($query, ['tbl.title'],
$fieldSuffix);
		}

		return $query;
	}

	/**
	 * Get list of articles belong to each category, max 10 articles per
category
	 *
	 * @param array $rows
	 */
	protected function beforeReturnData($rows)
	{
		$db          = $this->getDbo();
		$query       = $db->getQuery(true);
		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();

		$query->select('id, title')
			->from('#__helpdeskpro_articles')
			->order('ordering');

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, ['title'],
$fieldSuffix);
		}

		foreach ($rows as $row)
		{
			$query->where('category_id = ' . $row->id)
				->where('published = 1');
			$db->setQuery($query, 0, 10);
			$row->articles = $db->loadObjectList();

			$query->clear('where');
		}
	}
}PK̑�[џ�j
router.phpnu�[���<?php
/**
 * @package            Joomla
 * @subpackage         Event Booking
 * @author             Tuan Pham Ngoc
 * @copyright          Copyright (C) 2010 - 2021 Ossolution Team
 * @license            GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

/** @var \Composer\Autoload\ClassLoader $autoLoader */
$autoLoader = include JPATH_LIBRARIES . '/vendor/autoload.php';
$autoLoader->setPsr4('OSSolution\\HelpdeskPro\\Site\\',
JPATH_ROOT . '/components/com_helpdeskpro');

/**
 * Routing class from com_eventbooking
 *
 * @since  2.8.1
 */
class HelpdeskproRouter extends JComponentRouterBase
{
	/**
	 * Build the route for the com_eventbooking component
	 *
	 * @param   array &$query  An array of URL arguments
	 *
	 * @return  array  The URL arguments to use to assemble the subsequent
URL.
	 *
	 * @since   2.8.1
	 */
	public function build(&$query)
	{
		$segments = [];

		//Store the query string to use in the parseRouter method
		$queryArr = $query;

		//We need a menu item.  Either the one specified in the query, or the
current active one if none specified
		if (empty($query['Itemid']))
		{
			$menuItem = $this->menu->getActive();
		}
		else
		{
			$menuItem = $this->menu->getItem($query['Itemid']);

			// If the given menu item doesn't belong to our component, unset
the Itemid from query array
			if ($menuItem && $menuItem->component !=
'com_helpdeskpro')
			{
				unset($query['Itemid']);
			}
		}

		if ($menuItem && empty($menuItem->query['view']))
		{
			$menuItem->query['view'] = '';
		}

		//Are we dealing with link to a article or articles view
		if ($menuItem
			&& isset($query['view'], $query['id'],
$menuItem->query['id'])
			&& $menuItem->query['view'] ==
$query['view']
			&& $menuItem->query['id'] ==
intval($query['id'])
		)
		{
			unset($query['view'], $query['id'],
$query['catid']);
		}

		$view  = isset($query['view']) ? $query['view'] :
'';
		$id    = isset($query['id']) ? (int) $query['id'] :
0;
		$catId = isset($query['catid']) ? (int)
$query['catid'] : 0;

		switch ($view)
		{
			case 'article':
				if ($id)
				{
					$segments[] = RouteHelper::getArticleAlias($id);
				}

				if ($catId)
				{
					$segments = array_merge(RouteHelper::getCategoriesPath($catId,
'alias'), $segments);
					unset($query['catid']);
				}

				unset($query['view'], $query['id']);
				break;
			case 'articles':
				if ($id)
				{
					$segments[] = RouteHelper::getCategoryAlias($id);
				}

				unset($query['view'], $query['id']);
				break;
		}

		if (count($segments))
		{
			$systemVariables = [
				'option',
				'Itemid',
				'search',
				'start',
				'limitstart',
				'limit',
				'format',
			];

			foreach ($systemVariables as $variable)
			{
				if (isset($queryArr[$variable]))
				{
					unset($queryArr[$variable]);
				}
			}

			$db      = Factory::getDbo();
			$dbQuery = $db->getQuery(true);

			$queryString   = $db->quote(http_build_query($queryArr));
			$segments      =
array_map('Joomla\CMS\Application\ApplicationHelper::stringURLSafe',
$segments);
			$segmentString = implode('/', $segments);
			$key           = $db->quote(md5($segmentString));
			$dbQuery->select('id')
				->from('#__helpdeskpro_urls')
				->where('md5_key = ' . $key);
			$db->setQuery($dbQuery);
			$urlId = (int) $db->loadResult();

			if (!$urlId)
			{
				$dbQuery->clear()
					->insert('#__helpdeskpro_urls')
					->columns($db->quoteName(['md5_key',
'query', 'segment']))
					->values(implode(',', [$key, $queryString,
$db->quote($segmentString)]));
				$db->setQuery($dbQuery);
				$db->execute();
			}
		}

		return $segments;
	}

	/**
	 * Parse the segments of a URL.
	 *
	 * @param   array &$segments  The segments of the URL to parse.
	 *
	 * @return  array  The URL attributes to be used by the application.
	 * @throws  Exception
	 *
	 * @since   2.8.1
	 */
	public function parse(&$segments)
	{
		$vars = [];

		if (count($segments))
		{
			$db    = Factory::getDbo();
			$key   = md5(str_replace(':', '-',
implode('/', $segments)));
			$query = $db->getQuery(true);
			$query->select('`query`')
				->from('#__helpdeskpro_urls')
				->where('md5_key = ' . $db->quote($key));
			$db->setQuery($query);
			$queryString = $db->loadResult();

			if ($queryString)
			{
				parse_str(html_entity_decode($queryString), $vars);
			}
			else
			{
				$method =
strtoupper(Factory::getApplication()->input->getMethod());

				if ($method == 'GET')
				{
					throw new Exception('Page not found', 404);
				}
			}

			if (version_compare(JVERSION, '4.0.0-dev', 'ge'))
			{
				$segments = [];
			}
		}

		return $vars;
	}
}

/**
 * Events Booking router functions
 *
 * These functions are proxies for the new router interface
 * for old SEF extensions.
 *
 * @param   array &$query  An array of URL arguments
 *
 * @return  array  The URL arguments to use to assemble the subsequent
URL.
 */
function HelpdeskproBuildRoute(&$query)
{
	$router = new HelpdeskproRouter();

	return $router->build($query);
}

function HelpdeskproParseRoute($segments)
{
	$router = new HelpdeskproRouter();

	return $router->parse($segments);
}
PK̑�[6c>Z��View/Article/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\View\Article;

use HelpdeskProHelperBootstrap;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use OSL\Utils\Database as DatabaseUtils;
use OSL\View\HtmlView;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;
use OSSolution\HelpdeskPro\Site\Helper\Html as HelpdeskproHelperHtml;

defined('_JEXEC') or die;

/**
 * Class Html
 *
 * @property \OSSolution\HelpdeskPro\Site\Model\Article $model
 */
class Html extends HtmlView
{
	protected function beforeRender()
	{
		$this->item = $this->model->getData();

		if (empty($this->item->id))
		{
			throw new \Exception(Text::_('HDP_ARTICLE_NOT_FOUND'), 404);
		}

		$config = HelpdeskproHelper::getConfig();

		// Update hits
		$this->model->hits();

		if ($config->highlight_code)
		{
			HelpdeskproHelper::loadHighlighter();
		}

		// Pathway
		$pathway = $this->container->app->getPathway();

		// Get category title
		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();

		$db    = $this->model->getDbo();
		$query = $db->getQuery(true);
		$query->select('title')
			->from('#__helpdeskpro_categories')
			->where('id = ' . $this->item->category_id);

		if ($fieldSuffix)
		{
			DatabaseUtils::getMultilingualFields($query, array('title'),
$fieldSuffix);
		}
		$db->setQuery($query);
		$categoryTitle = $db->loadResult();
		$pathway->addItem($categoryTitle,
Route::_('index.php?option=com_helpdeskpro&view=articles&filter_category_id='
. $this->item->category_id . '&Itemid=' .
$this->Itemid));
		$pathway->addItem($this->item->title);

		// Handle page title
		$active = $this->container->app->getMenu()->getActive();
		$params = HelpdeskproHelperHtml::getViewParams($active,
array('categories', 'articles', 'article'));

		if (!$params->get('page_title'))
		{
			$params->set('page_title', $this->item->title);
		}

		HelpdeskproHelperHtml::prepareDocument($params, $this->item);

		$this->bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
	}
}PK̑�[�he::View/Article/tmpl/default.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

// no direct access

defined( '_JEXEC' ) or die ;
?>
<div id="hdp_container" class="container-fluid">
	<h1 class="hdp_title"><?php echo
$this->item->title; ?></h1>
	<div class="hdp-article-detail <?php echo
$this->bootstrapHelper->getClassMapping('clearfix');
?>">
		<?php echo $this->item->text; ?>
	</div>
</div>PK̑�[�����View/Articles/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\View\Articles;

use HelpdeskProHelperBootstrap;
use OSL\Utils\Database as DatabaseUtils;
use OSL\View\ListView;
use OSSolution\HelpdeskPro\Site\Helper\Database as
HelpdeskproHelperDatabase;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;
use OSSolution\HelpdeskPro\Site\Helper\Html as HelpdeskproHelperHtml;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

defined('_JEXEC') or die;

class Html extends ListView
{
	protected function beforeRender()
	{
		parent::beforeRender();

		// Add articles to route
		RouteHelper::addArticles($this->items);

		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();

		$rows = HelpdeskproHelperDatabase::getAllCategories('title',
array(), $fieldSuffix, 2);

		$this->lists['id'] =
HelpdeskproHelperHtml::buildCategoryDropdown($this->state->id,
'id', 'class="input-large form-select"
onchange="submit();"', $rows);

		// Handle page title
		$active = $this->container->app->getMenu()->getActive();
		$params = HelpdeskproHelperHtml::getViewParams($active,
array('categories', 'articles'));

		$category = null;

		if ($this->state->filter_category_id)
		{
			$db    = $this->model->getDbo();
			$query = $db->getQuery(true);
			$query->select('title')
				->from('#__helpdeskpro_categories')
				->where('id = ' .
$this->state->filter_category_id);

			if ($fieldSuffix)
			{
				DatabaseUtils::getMultilingualFields($query, array('title'),
$fieldSuffix);
			}

			$db->setQuery($query);
			$categoryTitle = $db->loadResult();

			if (!$params->get('page_title') && $categoryTitle)
			{
				$params->set('page_title', $categoryTitle);
			}

			// Pathway
			$pathway = $this->container->app->getPathway();
			$pathway->addItem($categoryTitle);
		}

		HelpdeskproHelperHtml::prepareDocument($params);

		$this->bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
	}
}PK̑�[�
�q��View/Articles/tmpl/default.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined( '_JEXEC' ) or die ;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

$ordering = $this->state->filter_order == 'tbl.ordering';

HTMLHelper::_('bootstrap.tooltip', '.hasTooltip',
array('placement' => 'top'));
?>
<div id="hdp_container" class="container-fluid">
	<h1 class="hdp_title"><?php echo
Text::_('HDP_ARTICLES'); ?></h1>
	<form action="<?php echo
htmlspecialchars(Uri::getInstance()->toString()); ?>"
method="post" name="adminForm" id="adminForm"
class="form-inline">
		<fieldset class="filters btn-toolbar <?php echo
$this->bootstrapHelper->getClassMapping('clearfix');
?>">
			<div class="btn-group">
				<input type="text" name="filter_search"
id="filter_search" value="<?php echo
$this->escape($this->state->filter_search); ?>"
class="search-query input-xlarge"
onchange="document.adminForm.submit();"
placeholder="<?php echo
Text::_('HDP_ARTICLES_SEARCH_PLACEHOLDER'); ?>" />
			</div>
			<div class="btn-group pull-right">
				<?php echo $this->lists['id']; ?>
			</div>
		</fieldset>
	</form>
	<table class="table table-striped table-bordered
table-condensed">
		<thead>
			<tr>
				<th>
					<?php echo Text::_('HDP_TITLE'); ?>
				</th>
				<th>
					<?php echo Text::_('HDP_HITS'); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
			foreach($this->items as $item)
			{
			?>
				<tr>
					<td>
						<a href="<?php echo
Route::_('index.php?option=com_helpdeskpro&view=article&id='.$item->id.'&Itemid='.$this->Itemid);
?>"><?php echo $item->title;?></a>
					</td>
					<td>
						<spsn class="badge badge-info"><?php echo
$item->hits; ?></spsn>
					</td>
				</tr>
			<?php
			}
		?>
		</tbody>
		<?php
		if ($this->pagination->total > $this->pagination->limit)
		{
		?>
			<tfoot>
				<tr>
					<td colspan="2"><?php echo
$this->pagination->getPagesLinks();?></td>
				</tr>
			</tfoot>
		<?php
		}
		?>
	</table>
</div>PK̑�[�q{��View/Categories/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\View\Categories;

use HelpdeskProHelperBootstrap;
use OSL\View\ListView;
use OSSolution\HelpdeskPro\Site\Helper\Html as HelpdeskproHelperHtml;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

defined('_JEXEC') or die;

class Html extends ListView
{
	protected function beforeRender()
	{
		parent::beforeRender();

		foreach ($this->items as $item)
		{
			RouteHelper::addArticles($item->articles);
		}

		// Handle page title
		$active = $this->container->app->getMenu()->getActive();
		$params = HelpdeskproHelperHtml::getViewParams($active,
array('categories'));
		HelpdeskproHelperHtml::prepareDocument($params);

		$this->bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
	}
}PK̑�[A�V��
View/Categories/tmpl/default.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined( '_JEXEC' ) or die ;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

$params = Factory::getApplication()->getParams();
$numberColumns = $params->get('number_columns', 2);
$spanClass          = 'span' . intval(12 / $numberColumns);
?>
<div id="hdp_container" class="container-fluid">
	<h1 class="hdp_title"><?php echo
Text::_('HDP_ARTICLE_CATEGORIES'); ?></h1>
	<div class="hdp-categories-list clearfix">
		<div class="row-fluid">
			<?php
			$i = 0;
			$numberCategories = count($this->items);
			foreach ($this->items as $item)
			{
				$i++;
				$link = Route::_(RouteHelper::getArticlesRoute($item->id,
$this->Itemid, Factory::getLanguage()->getTag()));
			?>
				<div class="hpd-category-wrapper <?php echo $spanClass;
?>">
					<h3>
						<i class="icon-folder-open"></i><a
title="<?php echo
Text::sprintf('HDP_VIEW_ALL_ARTICLES_IN_CATEGORY',
$item->title);?>" href="<?php echo $link;
?>"><?php echo $item->title; ?></a><span
class="hdp-articles-count badge badge-info"><?php echo
$item->total_articles; ?></span>
					</h3>
					<?php 
						if ($item->description)
						{
						?>
							<div class="hdp-category-description
clearfix"><?php echo $item->description; ?></div>
						<?php			
						}
					?>
					<ul class="hp-category-posts">
						<?php
							foreach($item->articles as $article)
							{
							?>
								<li class="format-standard">
									<i class="icon-list-alt"></i><a
title="<?php echo $article->title; ?>"
href="<?php echo
Route::_(RouteHelper::getArticleRoute($article->id,
$article->category_id, $this->Itemid,
JFactory::getLanguage()->getTag()));?>"><?php echo
$article->title; ?></a>
								</li>
							<?php
							}
						?>
					</ul>
				</div>
				<?php
				if ($i % $numberColumns == 0 && $i < $numberCategories)
				{
				?>
					</div>
					<div class="clearfix row-fluid">
				<?php
				}
			}
			?>
		</div>
	</div>
</div>PK̑�[VJ�
�
'View/common/tmpl/ticket_add_comment.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

use Joomla\CMS\Language\Text;

defined('_JEXEC') or die;

if (!$canComment)
{
    return;
}

if ($captchaInvalid)
{
    $style = '';
}
else
{
    $style = ' style="display:none;"';
}

if ($config->enable_attachment)
{
	echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_upload_attachments.php');
}

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper     = HelpdeskProHelperBootstrap::getInstance();
$btnClass            =
$bootstrapHelper->getClassMapping('btn');
$btnPrimaryClass     = $bootstrapHelper->getClassMapping('btn
btn-primary');
?>
<tr id="tr_message_id" <?php echo $style; ?>>
    <td>
        <?php
        if ($config->use_html_editor)
        {
            echo $editor->display( 'message',  $message,
'100%', '250', '75', '10' );
        }
        else
        {
        ?>
            <textarea rows="10" class="hdp_fullwidth
form-control" cols="75" class="hdp_fullwidth"
name="message" id="message"><?php echo $message;
?></textarea>
        <?php
        }
        if ($config->enable_attachment)
        {
        ?>
            <div class="clearfix"></div>
            <table width="100%">
                <tr>
                    <th><?php echo
Text::_('HDP_ATTACHMENTS'); ?></th>
                </tr>
                <tr>
                    <td>
                        <div id="hdp_ticket_attachments"
class="dropzone needsclick dz-clickable">

                        </div>
                    </td>
                </tr>
            </table>
            <?php
        }
        if ($config->enable_captcha && !empty($captcha))
        {
        ?>
            <table>
                <tr>
                    <td class="title_cell">
                        <?php echo Text::_('HDP_CAPTCHA');
?><span class="required">*</span>
                    </td>
                    <td>
                        <?php echo $captcha; ?>
                    </td>
                </tr>
            </table>
            <?php
        }
        ?>
        <div class="clearfix"></div>
        <input type="button" name="btnSubmit"
class="<?php echo $btnPrimaryClass; ?>"
value="<?php echo Text::_('HDP_SUBMIT_COMMENT');
?>" onclick="addComment(this.form);" />
        <input type="button" name="btnSubmit"
class="<?php echo $btnPrimaryClass; ?>"
value="<?php echo Text::_('HDP_COMMENT_AND_CLOSE');
?>" onclick="addCommentAndClose(this.form);" />
    </td>
</tr>
PK̑�[�&�b��$View/common/tmpl/ticket_comments.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

defined('_JEXEC') or die;

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
$iconEdit        =
$bootstrapHelper->getClassMapping('icon-edit');
$iconTrash       =
$bootstrapHelper->getClassMapping('icon-trash');
$btn             = $bootstrapHelper->getClassMapping('btn');
$btnSmall        =
$bootstrapHelper->getClassMapping('btn-small');

if (count($messages))
{
	$imageFileTypes = array('gif', 'jpg',
'jpeg', 'png', 'csv', 'bmp',
'txt');
	$attachmentsPath = JPATH_ROOT .
'/media/com_helpdeskpro/attachments';
?>
	<tr>
		<td>
			<div class="hdp_ticket_comments">
				<ul>
					<?php
					foreach($messages as $message)
					{
					?>
						<li id="mesage-<?php echo $message->id;
?>">
							<table class="admintable <?php echo
$bootstrapHelper->getClassMapping('table table-striped
table-bordered'); ?> table-condensed">
								<tr>
									<td class="hdp_ticket_icon_user">
										<div class="hdp_ticket-images">
											<?php
											$avatarUrl = $rootUri .
'/media/com_helpdeskpro/assets/images/icons/icon-user.jpeg';

											if ($message->user_id)
											{
												$avatar =
HelpdeskproHelper::getUserAvatar($message->user_id);
												if ($avatar)
												{
													$avatarUrl = $rootUri . '/' . $avatar;
												}
											}
											?>
											<img width="60" height="60"
src="<?php echo $avatarUrl; ?>" title="<?php echo
$message->name; ?>">
										</div>
									</td>
									<td class="hdp_ticket_comments">
										<div class="hdp_ticket_comments_body">
											<div class="hdp_ticket_arrow"></div>
											<div class="hdp_ticket_commenter-name">
													<span class="hdp_ticket_name">
														<?php
														if ($message->user_id)
														{
															echo $message->name;
														}
														else
														{
															echo $item->name;
														}
														?>
                                                        - <a
href="#<?php echo $message->id; ?>">[#<?php echo
$message->id; ?>]</a>
													</span>
													<span class="hdp_ticket_date_time">
														<?php
														if ($message->user_id)
														{
															echo HTMLHelper::_('date',
$message->date_added, $config->date_format);
														}
														else
														{
															echo  HTMLHelper::_('date',
$message->date_added, $config->date_format);
														}
														if (HelpdeskproHelper::canUpdateComment($user,
$message->id))
														{
														?>
															<button type="button" class="<?php echo
$btn . ' ' . $btnSmall; ?>  edit_comment"
id="<?php echo $message->id; ?>" title="<?php
echo Text::_('HDP_EDIT_THIS_COMMENT'); ?>"><i
class="<?php echo $iconEdit;
?>"></i></button>
														<?php
														}

														if (HelpdeskproHelper::canDeleteComment($user,
$message->id))
														{
														?>
															<button type="button" class="<?php echo
$btn . ' ' . $btnSmall; ?> remove_comment"
id="<?php echo $message->id; ?>" title="<?php
echo Text::_('HDP_DELETE_THIS_COMMENT'); ?>"><i
class="<?php echo $iconTrash;
?>"></i></button>
														<?php
														}
														?>
													</span>
											</div>
											<div class="hdp_ticket_comment-text">
												<div data-title="Enter Your Comment"
class="hd-edit-table" id="hdp_ticket_edit-text-<?php echo
$message->id; ?>">
													<?php
													if ($config->process_bb_code)
													{
														echo HelpdeskproHelper::processBBCode($message->message);
													}
													else
													{
														if ($config->use_html_editor)
														{
															echo $message->message;
														}
														else
														{
															echo nl2br($message->message);
														}
													}
													?>
												</div>
												<?php
												if ($message->attachments)
												{
													$originalFileNames = explode('|',
$message->original_filenames);
													$attachments = explode('|',
$message->attachments);;
													?>
														<div class="hdp_ticket_comment-file">
															<ul>
																<?php
																	$i = 0 ;
																	foreach($originalFileNames as $fileName)
																	{
																		$actualFileName = $attachments[$i++];
																		if (!file_exists($attachmentsPath . '/' .
$actualFileName))
																		{
																			continue;
																		}

																		$icon = substr($fileName, strrpos($fileName,
'.') + 1);
																		$icon = strtolower($icon);
																		if (!file_exists(JPATH_SITE .
"/media/com_helpdeskpro/assets/images/icons/$icon.png"))
																		{
																			$icon = "default";
																		}
																		if (in_array($icon, $imageFileTypes))
																		{
																		?>
																			<li><a class="hdp-modal"
href="<?php echo
Route::_('index.php?option=com_helpdeskpro&task=ticket.download_attachment&filename='.$actualFileName.'&original_filename='.$fileName);
?>"><img height="16" width="16"
src="<?php echo $rootUri .
"/media/com_helpdeskpro/assets/images/icons/$icon.png"
?>" ><?php echo $fileName ?></a></li>
																		<?php
																		}
																		else
																		{
																		?>
																			<li><a href="<?php echo
Route::_('index.php?option=com_helpdeskpro&task=ticket.download_attachment&filename='.$actualFileName.'&original_filename='.$fileName);
?>"><img height="16" width="16"
src="<?php echo $rootUri .
"/media/com_helpdeskpro/assets/images/icons/$icon.png"
?>" ><?php echo $fileName ?></a></li>
																		<?php
																		}
																	}
																?>
															</ul>
														</div>
													<?php
												}
												?>
											</div>
										</div>
									</td>
								</tr>
							</table>
						</li>
					<?php
					}
					?>
				</ul>
			</div>
		</td>
	</tr>
	<?php
}PK̑�[*ځv�
�
)View/common/tmpl/ticket_customer_info.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

defined('_JEXEC') or die;

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper     = HelpdeskProHelperBootstrap::getInstance();
$config              = HelpdeskproHelper::getConfig();
?>
<table class="admintable <?php echo
$bootstrapHelper->getClassMapping('table table-striped
table-bordered'); ?> table-condensed">
	<tr>
		<th colspan="2"><?php echo
Text::_('HPD_TICKET_DETAIL'); ?></th>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_TICKET_ID'); ?>
		</td>
		<td>
			<?php echo $item->id; ?>
		</td>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_CATEGORY'); ?>
		</td>
		<td>
			<?php echo $item->category_title ; ?>
		</td>
	</tr>
	<?php
	if ($item->user_id > 0)
	{
	?>
		<tr>
			<td>
				<?php echo Text::_('HDP_USER'); ?>
			</td>
			<td>
				<?php echo $item->username; ?>[<?php echo
$item->user_id; ?>]
			</td>
		</tr>
	<?php
	}
	?>
	<tr>
		<td>
			<?php echo Text::_('HDP_NAME'); ?>
		</td>
		<td>
			<?php echo $item->name; ?>
		</td>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_EMAIl'); ?>
		</td>
		<td>
			<a href="mailto:<?php echo $item->email;
?>"><?php echo $item->email; ?></a>
		</td>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_TICKET_STATUS'); ?>
		</td>
		<td>
			<?php echo $item->status ; ?>
		</td>
	</tr>
	<?php
	if ($config->get('enable_rating', 1) &&
$item->rating)
	{
		switch ($item->rating)
		{
			case 1:
				$img = 'unsatisfactory.png';
				$title = Text::_('HDP_VERY_POOR');
				break ;
			case 2:
				$img = 'poor.png';
				$title = Text::_('HDP_FAIR');
				break ;
			case 3:
				$img = 'average.png';
				$title = Text::_('HDP_AVERAGE');
				break ;
			case 4:
				$img = 'good.png';
				$title = Text::_('HDP_GOOD');
				break ;
			case 5:
				$img = 'great.png';
				$title = Text::_('HDP_EXCELLENT');
				break ;
		}
		?>
			<tr>
				<td>
					<?php echo Text::_('HDP_RATING'); ?>
				</td>
				<td>
					<img src="<?php echo $rootUri .
'/media/com_helpdeskpro/feedback/' . $img; ?>"
title="<?php echo $title; ?>" />
				</td>
			</tr>
		<?php
	}
	?>
	<tr>
		<td>
			<?php echo Text::_('HDP_TICKET_PRIORITY'); ?>
		</td>
		<td>
			<?php echo $item->priority ; ?>
		</td>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_CREATED_DATE'); ?>
		</td>
		<td>
			<?php echo HTMLHelper::_('date', $item->created_date,
$config->date_format); ?>
		</td>
	</tr>
	<tr>
		<td>
			<?php echo Text::_('HDP_MODIFIED_DATE'); ?>
		</td>
		<td>
			<?php echo HTMLHelper::_('date', $item->modified_date,
$config->date_format); ?>
		</td>
	</tr>
	<?php
	if (count($fields))
	{
	?>
		<tr><th colspan="2"><?php echo
Text::_('HPD_EXTRA_INFORMATION'); ?></th></tr>
		<?php
		foreach($fields as $field)
		{
		    if (in_array($field->fieldtype, ['Heading',
'Message']))
            {
                continue;
		    }
		?>
			<tr>
				<td>
					<?php echo $field->title ; ?>
				</td>
				<td>
					<?php echo @$fieldValues[$field->id]; ?>
				</td>
			</tr>
		<?php
		}
	}

	if (!empty($results))
	{
		foreach($results as $result)
		{
			echo $result ;
		}
	}
	?>
</table>
PK̑�[v��`��"View/common/tmpl/ticket_detail.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Router\Route;

$imageFileTypes = array('gif', 'jpg', 'jpeg',
'png', 'csv', 'bmp', 'txt');
$attachmentsPath = JPATH_ROOT .
'/media/com_helpdeskpro/attachments';
?>
<div class="hdp_ticket_description-body">
	<?php
	if ($config->process_bb_code)
	{
		echo HelpdeskproHelper::processBBCode($item->message);
	}
	else
	{
		if ($config->use_html_editor)
		{
			echo $item->message;
		}
		else
		{
			echo nl2br($item->message);
		}
	}
	if ($item->attachments)
	{
		$originalFileNames = explode('|',
$item->original_filenames);
		$attachments = explode('|', $item->attachments);;
		?>
		<div class="hdp_ticket_description-file">
			<ul>
				<?php
				$i = 0 ;
				foreach($originalFileNames as $fileName)
				{
					$actualFileName = $attachments[$i++];

					if (!file_exists($attachmentsPath . '/' . $actualFileName))
					{
						continue;
					}

					$icon = substr($fileName, strrpos($fileName, '.') + 1);
					$icon = strtolower($icon);

					if
(!file_exists(JPATH_SITE."/media/com_helpdeskpro/assets/images/icons/$icon.png"))
					{
						$icon="default";
					}

					if (in_array($icon, $imageFileTypes))
					{
					?>
						<li><a class="hdp-modal" href="<?php echo
Route::_('index.php?option=com_helpdeskpro&task=ticket.download_attachment&filename='.$actualFileName.'&original_filename='.$fileName);
?>"><img height="16" width="16"
src="<?php echo $rootUri .
"/media/com_helpdeskpro/assets/images/icons/$icon.png";
?>" ><?php echo $fileName ?></a></li>
					<?php
					}
					else
					{
					?>
						<li><a href="<?php echo
Route::_('index.php?option=com_helpdeskpro&task=ticket.download_attachment&filename='.$actualFileName.'&original_filename='.$fileName);
?>"><img height="16" width="16"
src="<?php echo $rootUri .
"/media/com_helpdeskpro/assets/images/icons/$icon.png";
?>" ><?php echo $fileName ?></a></li>
					<?php
					}
				}
				?>
			</ul>
		</div>
		<?php
	}
	?>
</div>
PK̑�[2F��.View/common/tmpl/ticket_upload_attachments.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;

$config = HelpdeskproHelper::getConfig();

$allowedExtensions = $config->allowed_file_types;
$maxNumberOfFiles  = (int) $config->max_number_attachments ?: 1;

if (!$allowedExtensions)
{
	$allowedExtensions =
'doc|docx|ppt|pptx|pdf|zip|rar|bmp|gif|jpg|jepg|png|swf|zipx';
}

$allowedExtensions = explode('|', $allowedExtensions);

for ($i = 0, $n = count($allowedExtensions); $i < $n; $i++)
{
	$allowedExtensions[$i] = '.' .
strtolower(trim($allowedExtensions[$i]));
}

$token    = JSession::getFormToken() . '=' . 1;
$maxFileSize = 'null';

if ($config->max_file_size > 0)
{
	switch ($config->max_filesize_type)
	{
		case 1:
			$maxFileSize = (int) ($config->max_file_size / 1024 * 1024);
            break;
		case 2:
			$maxFileSize = (int) ($config->max_file_size / 1024);
	        break;
		case 3:
			$maxFileSize = (int) $config->max_file_size;
			break;
	}
}

$document = Factory::getDocument();
$rootUri  = Uri::root(true);
$document->addScript($rootUri .
'/media/com_helpdeskpro/js/ticket-upload-attachments.js');
$document->addScriptOptions('maxFiles', $maxNumberOfFiles);
$document->addScriptOptions('acceptedFiles',
implode(',', $allowedExtensions));
$document->addScriptOptions('maxFilesize', $maxFileSize);

Text::script('HDP_DROP_FILES_TO_UPLOAD', true);
$document->addScriptOptions('uploadProcessUrl',
Uri::base(true) .
'/index.php?option=com_helpdeskpro&task=ticket.upload&' .
$token);PK̑�[�#�View/common/tmpl/toolbar.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
$btnPrimary      = $bootstrapHelper->getClassMapping('btn
btn-primary');
$config          = HelpdeskproHelper::getConfig();
?>
<div class="btn-toolbar hdp_toolbar">
	<?php
	if ($user->authorise('helpdeskpro.changeticketcategory',
'com_helpdeskpro') && count($categories) > 1)
	{
	?>
		<div class="btn-group">
			<button class="<?php echo $btnPrimary; ?>
dropdown-toggle" data-toggle="dropdown"><?php echo
Text::_('HDP_CHANGE_TICKET_CATEGORY'); ?> <span
class="caret"></span></button>
			<ul class="dropdown-menu">
				<?php
				foreach ($categories as $category)
				{
				?>
					<li><a
href="javascript:HDP.changeTicketCategory(<?php echo
$category->id; ?>)"><?php echo $category->treename;
?></a></li>
				<?php
				}
				?>
			</ul>
		</div>
	<?php
	}
	if ($user->authorise('helpdeskpro.changeticketstatus',
'com_helpdeskpro') && count($rowStatuses) > 1)
	{
	?>
		<div class="btn-group">
			<button class="<?php echo $btnPrimary; ?>
dropdown-toggle" data-toggle="dropdown"><?php echo
Text::_('HDP_CHANGE_TICKET_STATUS'); ?> <span
class="caret"></span></button>
			<ul class="dropdown-menu">
				<?php
				foreach ($rowStatuses as $rowStatus)
				{
				?>
					<li><a href="javascript:HDP.changeTicketStatus(<?php
echo $rowStatus->id; ?>);"><?php echo
$rowStatus->title; ?></a></li>
				<?php
				}
				?>
			</ul>
		</div>
	<?php
	}
	if (count($rowPriorities) && count($rowPriorities) > 1)
	{
	?>
		<div class="btn-group">
			<button class="<?php echo $btnPrimary; ?>
dropdown-toggle" data-toggle="dropdown"><?php echo
Text::_('HDP_CHANGE_TICKET_PRIORITY'); ?> <span
class="caret"></span></button>
			<ul class="dropdown-menu">
				<?php
				foreach ($rowPriorities as $rowPriority)
				{
				?>
					<li><a
href="javascript:HDP.changeTicketPriority(<?php echo
$rowPriority->id; ?>)"><?php echo $rowPriority->title;
?></a></li>
				<?php
				}
				?>
			</ul>
		</div>
	<?php
	}

	if ($config->get('enable_rating', 1) && $isCustomer
&& !$item->rating)
	{
	?>
		<div class="btn-group">
			<button class="<?php echo $btnPrimary; ?>
dropdown-toggle" data-toggle="dropdown"><?php echo
Text::_('HDP_TICKET_RATING'); ?> <span
class="caret"></span></button>
			<ul class="dropdown-menu">
				<li><a
href="javascript:HDP.ticketRating(1)"><?php echo
Text::_('HDP_VERY_POOR'); ?></a></li>
				<li><a
href="javascript:HDP.ticketRating(2)"><?php echo
Text::_('HDP_FAIR'); ?></a></li>
				<li><a
href="javascript:HDP.ticketRating(3)"><?php echo
Text::_('HDP_AVERAGE'); ?></a></li>
				<li><a
href="javascript:HDP.ticketRating(4)"><?php echo
Text::_('HDP_GOOD'); ?></a></li>
				<li><a
href="javascript:HDP.ticketRating(5)"><?php echo
Text::_('HDP_EXCELLENT'); ?></a></li>
			</ul>
		</div>
	<?php
	}

	if (!empty($rowLabels))
	{
	?>
		<div class="btn-group">
			<button class="<?php echo $btnPrimary; ?>
dropdown-toggle" data-toggle="dropdown"><?php echo
Text::_('HDP_APPLY_LABEL'); ?><span
class="caret"></span></button>
			<ul class="dropdown-menu">
				<li><a
href="javascript:HDP.applyTicketLabel(0)"><?php echo
Text::_('HDP_NO_LABEL'); ?></a></li>
				<?php
				foreach ($rowLabels as $rowLabel)
				{
				?>
					<li><a href="javascript:HDP.applyTicketLabel(<?php
echo $rowLabel->id; ?>)"><?php echo $rowLabel->title;
?></a></li>
				<?php
				}
				?>
			</ul>
		</div>
	<?php
	}
	if (!empty($convertToKb))
	{
	?>
		<div class="btn-group">
			<input type="button" class="<?php echo
$bootstrapHelper->getClassMapping('btn'); ?>
btn-success" value="<?php echo
Text::_('HDP_CONVERT_TO_KB'); ?>"
onclick="convertToArticle(this.form)"
style="margin-left:20px;" />
		</div>
	<?php
	}
	?>
</div>
<?php
PK̑�[�s�XXView/fieldlayout/checkboxes.phpnu�[���<?php
/**
 * @package            Joomla
 * @subpackage         Event Booking
 * @author             Tuan Pham Ngoc
 * @copyright          Copyright (C) 2010 - 2018 Ossolution Team
 * @license            GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

$size          = (int) $row->size ?: 1;
$span          = intval(12 / $size);
$i             = 0;
$numberOptions = count($options);

$rowFluid        = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('row-fluid') :
'row-fluid';
$spanClass       = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('span' . $span) :
'span' . $span;
$clearFixClass   = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('clearfix') :
'clearfix';
$ukFieldsetClass = $bootstrapHelper ?
$bootstrapHelper->getFrameworkClass('uk-fieldset', 2) :
'';
?>
<fieldset id="<?php echo $name; ?>" class="<?php
echo $ukFieldsetClass . $clearFixClass; ?>
hdp-checkboxes-container">
    <div class="<?php echo $rowFluid . ' ' .
$clearFixClass; ?>">
		<?php
		foreach ($options as $option)
		{
		$i++;
		$checked = in_array($option, $selectedOptions) ? 'checked' :
'';
		?>
            <div class="<?php echo $spanClass ?>">
                <label class="checkbox">
                    <input type="checkbox" id="<?php
echo $name.$i; ?>"
                           name="<?php echo $name; ?>[]"
                           value="<?php echo
htmlspecialchars($option, ENT_COMPAT, 'UTF-8') ?>"
                        <?php echo $checked.$attributes; ?>
                    /><?php echo $option; ?>
                </label>
            </div>
		<?php
            if ($i % $size == 0 && $i < $numberOptions)
            {
            ?>
                </div>
                <div class="<?php echo $rowFluid . ' '
. $clearFixClass; ?>">
            <?php
            }
		}
		?>
    </div>
</fieldset>
PK̑�[O�o��!View/fieldlayout/controlgroup.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

$controlGroupClass = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('control-group') :
'control-group';
$controlLabelClass = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('control-label') :
'control-label';
$controlsClass     = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('controls') :
'controls';

if ($tableLess)
{
?>
    <div class="<?php echo $controlGroupClass; ?>"
<?php echo $controlGroupAttributes ?>>
        <div class="<?php echo $controlLabelClass
?>">
			<?php echo $label; ?>
        </div>
        <div class="<?php echo $controlsClass; ?>">
			<?php echo $input; ?>
        </div>
    </div>
<?php
}
else
{
?>
    <tr <?php echo $controlGroupAttributes; ?>>
        <td class="key">
			<?php
			echo $row->title;

			if ($row->required)
			{
				?>
                <span class="required">*</span>
				<?php
			}
			?>
        </td>
        <td>
			<?php echo $input; ?>
        </td>
    </tr>
<?php
}


PK̑�[��l���View/fieldlayout/heading.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

?>
<h3 class="hdp-heading" <?php echo $controlGroupAttributes;
?>><?php echo Text::_($title); ?></h3>
PK̑�[�W�B��View/fieldlayout/label.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;

$class      = '';
$useTooltip = false;

if (!empty($description))
{
	HTMLHelper::_('bootstrap.tooltip');
	Factory::getDocument()->addStyleDeclaration(".hasTip{display:block
!important}");
	$useTooltip = true;
	$class = 'hasTooltip hasTip';
}
?>
<label id="<?php echo $name; ?>-lbl" for="<?php
echo $name; ?>"<?php if ($class) echo ' class="'
. $class . '"' ?> <?php if ($useTooltip) echo '
title="' . HTMLHelper::tooltipText(trim($title, ':'),
$description, 0) . '"'; ?>>
	<?php
	echo $title;

	if ($row->required)
	{
	?>
		<span class="required">*</span>
	<?php
	}
	?>
</label>PK̑�[�K��View/fieldlayout/message.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

$controlGroup = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('control-group') :
'control-group';
?>
<div class="<?php echo $controlGroup; ?> hdp-message"
<?php echo $controlGroupAttributes; ?>><?php echo $description;
?></div>
PK̑�[k5�_bbView/fieldlayout/radio.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

$size          = (int) $row->size ?: 1;
$span          = intval(12 / $size);
$i             = 0;
$numberOptions = count($options);

$rowFluid        = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('row-fluid') :
'row-fluid';
$spanClass       = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('span' . $span) :
'span' . $span;
$clearFixClass   = $bootstrapHelper ?
$bootstrapHelper->getClassMapping('clearfix') :
'clearfix';
$ukFieldsetClass = $bootstrapHelper ?
$bootstrapHelper->getFrameworkClass('uk-fieldset', 2) :
'';
?>
<fieldset id="<?php echo $name; ?>" class="<?php
echo $ukFieldsetClass . $clearFixClass; ?>
hdp-radio-container">
	<div class="<?php echo $rowFluid . ' ' .
$clearFixClass; ?>">
		<?php
        $value = trim($value);

        foreach ($options as $option)
		{
            $i++;
            $checked = (trim($option) == $value) ? 'checked' :
'';
		?>
            <div class="<?php echo $spanClass ?>">
                <label class="radio">
                    <input type="radio" id="<?php echo
$name.$i; ?>"
                           name="<?php echo $name; ?>"
                           value="<?php echo
htmlspecialchars($option, ENT_COMPAT, 'UTF-8') ?>"
                        <?php echo $checked.$attributes; ?>
                    /><?php echo $option; ?>
                </label>
            </div>
		<?php
            if ($i % $size == 0 && $i < $numberOptions)
            {
            ?>
                </div>
                <div class="<?php echo $rowFluid . ' '
. $clearFixClass; ?>">
            <?php
            }
		}
		?>
	</div>
</fieldset>
PK̑�[
����View/fieldlayout/text.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;
?>
<input type="<?php echo $type; ?>"
       name="<?php echo $name; ?>" id="<?php echo
$name; ?>"
       value=""<?php echo $attributes; ?> />

PK̑�[�6U,��View/fieldlayout/textarea.phpnu�[���<?php
/**
 * @package        Joomla
 * @subpackage     OSMembership
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;
?>
<textarea name="<?php echo $name; ?>"
          id="<?php echo $name; ?>"<?php echo
$attributes; ?>><?php echo htmlspecialchars($value, ENT_COMPAT,
'UTF-8'); ?></textarea>
PK̑�[�S;�c)c)View/Ticket/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\View\Ticket;

use HelpdeskProHelperBootstrap;
use Joomla\CMS\Captcha\Captcha;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
use OSL\View\HtmlView;
use OSSolution\HelpdeskPro\Site\Helper\Database as
HelpdeskproHelperDatabase;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;
use OSSolution\HelpdeskPro\Site\Helper\Html as HelpdeskproHelperHtml;
use OSSolution\HelpdeskPro\Site\Helper\Jquery as HelpdeskproHelperJquery;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

defined('_JEXEC') or die;

/**
 * Class Html
 *
 * @property \OSSolution\HelpdeskPro\Admin\Model\Ticket $model
 */
class Html extends HtmlView
{
	protected function beforeRender()
	{
		// Load jQuery validation engine
		HelpdeskproHelperJquery::validateForm();

		// Remove the uploaded files data from section
		$this->container->session->clear('hdp_uploaded_files');
		$this->container->session->clear('hdp_uploaded_files_original_names');
		$this->bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();

		$layout = $this->getLayout();

		if ($layout == 'form')
		{
			$this->beforeRenderTicketForm();

			return;
		}

		HelpdeskproHelper::loadEditable();

		/* @var \JApplicationSite $app */
		$app         = $this->container->app;
		$user        = $this->container->user;
		$config      = HelpdeskproHelper::getConfig();
		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();
		$item        = $this->model->getData();

		if (!$item->id)
		{
			$app->enqueueMessage(Text::_('HDP_TICKET_NOT_EXISTS'));
			$app->redirect(Route::_(RouteHelper::getTicketsRoute(), false));
		}

		// Require users to login if they try to access support ticket via public
link
		if (!$config->allow_public_user_submit_ticket &&
$item->is_ticket_code)
		{
			$redirectUrl = RouteHelper::getTicketRoute($item->id);

			if ($user->id)
			{
				$app->redirect(Route::_($redirectUrl, false));
			}
			else
			{
				$app->enqueueMessage(Text::_('HDP_PLEASE_LOGIN_TO_CONTINUE'));
				$app->redirect(Route::_('index.php?option=com_users&view=login&return='
. base64_encode($redirectUrl)));
			}
		}

		$canAccess = HelpdeskproHelper::checkTicketAccess($item);

		if (!$canAccess)
		{
			if (!$user->id && !$item->is_ticket_code)
			{
				$app->enqueueMessage(Text::_('HDP_PLEASE_LOGIN_TO_CONTINUE'));
				$app->redirect(Route::_('index.php?option=com_users&view=login&return='
. base64_encode(Uri::getInstance()->toString())));
			}
			else
			{
				$app->enqueueMessage(Text::_('HDP_INVALID_TICKET'),
'warning');
				$app->redirect(Uri::root());
			}
		}

		$rows = HelpdeskproHelperDatabase::getAllCategories(
			'ordering',
			['access IN (' . implode(',',
$user->getAuthorisedViewLevels()) . ')'],
			$fieldSuffix
		);

		$children = [];

		if ($rows)
		{
			// first pass - collect children
			foreach ($rows as $v)
			{
				$pt   = $v->parent_id;
				$list = @$children[$pt] ? $children[$pt] : [];
				array_push($list, $v);
				$children[$pt] = $list;
			}
		}

		$categories = HTMLHelper::_('menu.treerecurse', 0,
'', [], $children, 9999, 0, 0);

		$rowStatuses =
HelpdeskproHelperDatabase::getAllStatuses('ordering',
$fieldSuffix);

		$rowPriorities =
HelpdeskproHelperDatabase::getAllPriorities('ordering',
$fieldSuffix);

		if ($user->id == $item->user_id || $item->is_ticket_code)
		{
			$isCustomer = 1;
		}
		else
		{
			$isCustomer = 0;
		}

		if ($isCustomer && ($item->status_id ==
$config->closed_ticket_status))
		{
			$canComment = false;
		}
		else
		{
			$canComment = true;
		}

		$message = $this->input->getHtml('message');

		if ($config->highlight_code)
		{
			HelpdeskproHelper::loadHighlighter();
		}

		$this->loadCaptcha($app, $config);

		// Add js variables
		$maxNumberOfFiles = $config->max_number_attachments ? (int)
$config->max_number_attachments : 1;

		$siteUrl = Uri::root();
		$this->container->document->addScriptDeclaration("
			var maxAttachment = $maxNumberOfFiles;
			var currentCategory = 0;
			var currentNumberAttachment = 1;
			var currentStatus = 0;
			var hdpSiteUrl = '$siteUrl';
			var jItemId = " . (int) $this->Itemid . ";
		");

		PluginHelper::importPlugin('helpdeskpro');

		//Trigger plugins
		$results =
$this->container->app->triggerEvent('onViewTicket',
[$item]);

		// Pathway
		$pathway = $app->getPathway();
		$pathway->addItem(Text::sprintf('HDP_TICKET_NUMBER',
$item->id));

		$this->fields        =
HelpdeskproHelper::getFields($item->category_id);
		$this->messages      = $this->model->getMessages();
		$this->fieldValues   = $this->model->getFieldsValue();
		$this->rowStatuses   = $rowStatuses;
		$this->rowPriorities = $rowPriorities;
		$this->categories    = $categories;
		$this->config        = $config;
		$this->item          = $item;
		$this->isCustomer    = $isCustomer;
		$this->canComment    = $canComment;
		$this->message       = $message;
		$this->results       = $results;
	}

	/**
	 * Prepare data to render submit ticket form
	 *
	 * @throws \Exception
	 */
	private function beforeRenderTicketForm()
	{
		/* @var \JApplicationSite $app */
		$app         = $this->container->app;
		$user        = $this->container->user;
		$config      = HelpdeskproHelper::getConfig();
		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();
		$userId      = $user->get('id');
		$active      = $app->getMenu()->getActive();

		if ($active && isset($active->query['view'],
$active->query['layout'])
			&& $active->query['view'] == 'ticket'
&& $active->query['layout'] == 'form')
		{
			$params = $active->getParams();
		}
		else
		{
			$params = new Registry;
		}

		$categoryId = $this->input->getInt('category_id', (int)
$params->get('default_category_id'));

		$priorityId = $this->input->getInt('priority_id', 0);

		if (!$userId && !$config->allow_public_user_submit_ticket)
		{
			//Redirect user to login page
			$app->enqueueMessage(Text::_('HDP_LOGIN_TO_SUBMIT_TICKET'));
			$app->redirect('index.php?option=com_users&view=login&return='
. base64_encode(Uri::getInstance()->toString()));
		}

		$filters = ['access IN (' . implode(',',
$user->getAuthorisedViewLevels()) . ')'];

		if ($params->get('category_ids'))
		{
			$categoryIds =
array_filter(ArrayHelper::toInteger(explode(',',
$params->get('category_ids'))));

			if (count($categoryIds))
			{
				$filters[] = ['id IN (' . implode(',',
$categoryIds) . ')'];
			}
		}

		$rows = HelpdeskproHelperDatabase::getAllCategories(
			'ordering',
			$filters,
			$fieldSuffix
		);

		$lists['category_id'] =
HelpdeskproHelperHtml::buildCategoryDropdown(
			$categoryId,
			'category_id',
			'class="uk-select form-control input-xlarge form-select
validate[required]"
onchange="HDP.showFields(this.form);"',
			$rows
		);

		$rowPriorities =
HelpdeskproHelperDatabase::getAllPriorities('ordering',
$fieldSuffix);

		if (count($rowPriorities))
		{
			$options              = [];
			$options[]            = HTMLHelper::_('select.option',
'', Text::_('HDP_CHOOSE_PRIORITY'), 'id',
'title');
			$options              = array_merge($options, $rowPriorities);
			$lists['priority_id'] =
HTMLHelper::_('select.genericlist', $options,
'priority_id',
				[
					'option.text.toHtml' => false,
					'option.text'        => 'title',
					'option.key'         => 'id',
					'list.attr'          => 'class="uk-select
input-large validate[required] form-select"',
					'list.select'        => $priorityId > 0 ? $priorityId
: $config->default_ticket_priority_id]);
		}

		// Custom fields
		$rowFields = HelpdeskproHelper::getAllFields();
		$form      = new \HDPForm($rowFields);

		$relation = HelpdeskproHelper::getFieldCategoryRelation();
		$form->prepareFormField($categoryId, $relation);

		$fieldJs = "fields = new Array();\n";
		foreach ($relation as $catId => $fieldList)
		{
			$fieldJs .= ' fields[' . $catId . '] = new
Array("' . implode('","', $fieldList) .
'");' . "\n";
		}

		$this->container->document->addScriptDeclaration($fieldJs);

		$data = $this->input->getData();

		if ($this->input->getMethod() == 'POST')
		{
			$useDefault = false;
		}
		else
		{
			$useDefault = true;
		}

		$form->bind($data, $useDefault);

		$this->loadCaptcha($app, $config);

		$maxNumberOfFiles = $config->max_number_attachments ? (int)
$config->max_number_attachments : 1;

		$this->container->document->addScriptDeclaration("
			var maxAttachment = $maxNumberOfFiles;
			var currentCategory = $categoryId;
			var currentNumberAttachment = 1; 
		");

		// Pathway
		$pathway = $app->getPathway();
		$pathway->addItem(Text::_('HDP_NEW_TICKET'));

		$this->lists         = $lists;
		$this->config        = $config;
		$this->userId        = $userId;
		$this->form          = $form;
		$this->categoryId    = $categoryId;
		$this->params        = $params;
		$this->rowCategories = $rows;
	}

	/**
	 * Load captcha for submit ticket and add comment form
	 *
	 * @param   \JApplicationSite   $app
	 * @param   \OSL\Config\Config  $config
	 */
	protected function loadCaptcha($app, $config)
	{
		// Captcha
		$showCaptcha = 0;
		$user        = $this->container->user;

		if (!$config->enable_captcha || ($user->id &&
$config->enable_captcha == '2'))
		{
			$enableCaptcha = false;
		}
		else
		{
			$enableCaptcha = true;
		}

		if ($enableCaptcha)
		{
			$captchaPlugin = $app->get('captcha',
$this->container->appConfig->get('captcha'));

			if (!$captchaPlugin)
			{
				// Hardcode to recaptcha, reduce support request
				$captchaPlugin = 'recaptcha';
			}

			// Check to make sure Captcha is enabled
			$plugin = PluginHelper::getPlugin('captcha', $captchaPlugin);

			if ($plugin)
			{
				$showCaptcha   = 1;
				$this->captcha =
Captcha::getInstance($captchaPlugin)->display('dynamic_recaptcha_1',
'dynamic_recaptcha_1', 'required');
			}
			else
			{
				$app->enqueueMessage(Text::_('EB_CAPTCHA_NOT_ACTIVATED_IN_YOUR_SITE'),
'error');
			}
		}

		$this->showCaptcha = $showCaptcha;
	}
}PK̑�[���}}View/Ticket/tmpl/default.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Editor\Editor;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

HTMLHelper::_('behavior.core');
HTMLHelper::_('behavior.keepalive');

if (!HelpdeskproHelper::isJoomla4())
{
	HTMLHelper::_('behavior.modal', 'a.hdp-modal');
}

$document = Factory::getDocument();
$rootUri  = Uri::root(true);

if (!$this->config->use_html_editor &&
$this->config->process_bb_code)
{
	$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/jquery.selection.js');
	$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/helpdeskpro.bbcode.js');
}

$document->addScript($rootUri .
'/media/com_helpdeskpro/js/site-ticket-default.js');

Text::script('HDP_ENTER_COMMENT_FOR_TICKET', true);

$cbIntegration    = file_exists(JPATH_ROOT .
'/components/com_comprofiler/comprofiler.php');
$editor           =
Editor::getInstance(Factory::getConfig()->get('editor'));
$user             = Factory::getUser();
$maxNumberOfFiles = $this->config->max_number_attachments ?
$this->config->max_number_attachments : 1;

if ($this->input->getMethod() == 'POST')
{
	$this->captchaInvalid = true;
}
else
{
	$this->captchaInvalid = false;
}

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper     = $this->bootstrapHelper;
$formHorizontalClass = $bootstrapHelper->getClassMapping('form
form-horizontal');
$rowFluidClass       =
$bootstrapHelper->getClassMapping('row-fluid');
$controlGroupClass   =
$bootstrapHelper->getClassMapping('control-group');
$controlLabelClass   =
$bootstrapHelper->getClassMapping('control-label');
$controlsClass       =
$bootstrapHelper->getClassMapping('controls');
$span3Class          =
$bootstrapHelper->getClassMapping('span3');
$span9Class          =
$bootstrapHelper->getClassMapping('span9');
$btnClass            =
$bootstrapHelper->getClassMapping('btn');
$btnPrimaryClass     = $bootstrapHelper->getClassMapping('btn
btn-primary');
?>
<h1 class="hdp_title"><?php echo
Text::_('HDP_VIEW_TICKET'); ?></h1>
<div id="hdp_container" class="container-fluid">
<form action="<?php echo
Route::_('index.php?option=com_helpdeskpro&view=ticket&Itemid='.$this->Itemid);
?>" method="post" name="adminForm"
id="adminForm" enctype="multipart/form-data">
<!--Toolbar buttons-->	
<div class="row-fluid admintable">
	<?php
		$layoutData = array(
			'categories'    => $this->categories,
			'rowStatuses'   => $this->rowStatuses,
			'rowPriorities' => $this->rowPriorities,
			'isCustomer'    => $this->isCustomer,
			'item'          => $this->item,
			'user'          => $user
		);
		echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/toolbar.php',
$layoutData);
	?>
</div>
<div class="row-fluid">
	<div id="hdp_left_panel" class="span9">					
		<table class="adminform">		
			<tr>
				<td>
					<strong>
						[#<?php echo $this->item->id ?>] - <?php echo
$this->escape($this->item->subject); ?>
					</strong>
				</td>
			</tr>					
			<tr>
				<td>
					<?php
						$layoutData = array(
							'item'          => $this->item,
							'rootUri'       => $rootUri,
							'config'        => $this->config
						);

						echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_detail.php',
$layoutData);
					?>						
				</td>
			</tr>
			<tr>
				<th>					
					<h2 class="hdp_heading hdp_comments_heading"><?php
echo Text::_('HDP_COMMENTS'); ?>
                        <?php
                            if ($this->canComment)
                            {
                            ?>
                                <a
href="javascript:HDP.showMessageBox();">
                                    <span
id="hdp_add_comment_link"><?php echo
Text::_('HDP_ADD_COMMENT'); ?></span>
                                    <img width="32"
height="32" src="<?php echo
$rootUri.'/media/com_helpdeskpro/assets/images/icons/icon_add.jpg'?>">
                                </a>
                            <?php
                            }
                        ?>
					</h2>													
				</th>
			</tr>
			<?php
				$layoutData = array(
					'canComment' => $this->canComment,
					'captchaInvalid' => $this->captchaInvalid,
					'config'    => $this->config,
					'maxNumberOfFiles' => $maxNumberOfFiles,
					'rootUri' => $rootUri,
					'editor' => $editor,
					'message' => $this->message,
					'captcha' => isset($this->captcha) ? $this->captcha
: ''
				);

				// Comment form
				echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_add_comment.php',
$layoutData);

				// List of comments
				$layoutData = array(
					'messages'      => $this->messages,
					'user'          => $user,
					'cbIntegration' => $cbIntegration,
					'rootUri'       => $rootUri,
					'config'        => $this->config
				);
				echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_comments.php',
$layoutData);
			?>
	</table>			
</div>		
<div id="hdp_right_panel" class="<?php echo
$span9Class; ?>">
	<?php
		// Customer information
		$layoutData = array(
			'item'        => $this->item,
			'fields'      => $this->fields,
			'fieldValues' => $this->fieldValues,
			'rootUri'     => $rootUri,
			'config'      => $this->config,
			'results'     => $this->results
		);

		echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_customer_info.php',
$layoutData);
	?>
</div>
</div>
	<input type="hidden" name="id" value="<?php
echo $this->item->id; ?>" />
	<input type="hidden" name="task" value=""
/>				
	<input type="hidden" name="new_value"
value="0" />
	<input type="hidden" name="Itemid"
value="<?php echo $this->Itemid; ?>" />
	
	<?php
		if ($this->item->is_ticket_code) {
		?>
			<input type="hidden" name="ticket_code"
value="<?php echo $this->item->ticket_code ?>" />
		<?php	
		}
	?>		
	<?php echo HTMLHelper::_( 'form.token' ); ?>
</form>
</div>PK̑�[�$����View/Ticket/tmpl/form.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Editor\Editor;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

HTMLHelper::_('behavior.core');
HTMLHelper::_('behavior.keepalive');

$document = Factory::getDocument();
$rootUri = Uri::root();

$editor =
Editor::getInstance(Factory::getConfig()->get('editor'));

if (!$this->config->use_html_editor &&
$this->config->process_bb_code)
{
	$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/jquery.selection.js');
	$document->addScript($rootUri .
'/media/com_helpdeskpro/assets/js/helpdeskpro.bbcode.js');
}

$document->addScript($rootUri .
'/media/com_helpdeskpro/js/site-ticket-form.js');

/* @var HelpdeskproViewTicketHtml $this */
$role = HelpdeskproHelper::getUserRole($this->userId);

/* @var $bootstrapHelper HelpdeskProHelperBootstrap */
$bootstrapHelper     = $this->bootstrapHelper;
$formHorizontalClass = $bootstrapHelper->getClassMapping('form
form-horizontal');
$rowFluidClass       =
$bootstrapHelper->getClassMapping('row-fluid');
$controlGroupClass   =
$bootstrapHelper->getClassMapping('control-group');
$controlLabelClass   =
$bootstrapHelper->getClassMapping('control-label');
$controlsClass       =
$bootstrapHelper->getClassMapping('controls');
$btnClass            =
$bootstrapHelper->getClassMapping('btn');
$btnPrimaryClass     = $bootstrapHelper->getClassMapping('btn
btn-primary');
?>
<div class="container-fluid">
<h1 class="hdp_title title"><?php echo
$this->params->get('page_heading') ?:
Text::_('HDP_NEW_TICKET'); ?></h1>
<form class="<?php echo $formHorizontalClass; ?>"
name="hdp_form" id="hdp_form" action="<?php
echo
Route::_('index.php?option=com_helpdeskpro&Itemid='.$this->Itemid);
?>" method="post"
enctype="multipart/form-data">
<?php
	if (!$this->userId)
	{
	?>
		<div class="<?php echo $controlGroupClass; ?>">
			<label class="<?php echo $controlLabelClass; ?>"
for="name"><?php echo Text::_('HDP_NAME');
?><span class="required">*</span></label>
			<div class="<?php echo $controlsClass; ?>">
      			<input type="text" id="name"
name="name" class="input-xlarge form-control
validate[required]" value="<?php echo
$this->escape($this->input->getString('name'));
?>" />
    		</div>			
		</div>
		<div class="<?php echo $controlGroupClass; ?>">
			<label class="<?php echo $controlLabelClass; ?>"
for="email"><?php echo Text::_('HDP_EMAIL');
?><span class="required">*</span></label>
			<div class="<?php echo $controlsClass; ?>">
      			<input type="text" id="email"
name="email" class="input-xlarge form-control
validate[required,custom[email]]" value="<?php echo
$this->escape($this->input->getString('email'));
?>" />
    		</div>			
		</div>
	<?php	
	}

	if (count($this->rowCategories) > 1)
    {
    ?>
        <div class="<?php echo $controlGroupClass;
?>">
            <label class="<?php echo $controlLabelClass;
?>" for="category_id"><?php echo
Text::_('HDP_CATEGORY'); ?><span
class="required">*</span></label>
            <div class="<?php echo $controlsClass;
?>">
			    <?php echo $this->lists['category_id'] ; ?>
            </div>
        </div>
    <?php
    }
?>
	<div class="<?php echo $controlGroupClass; ?>">
			<label class="<?php echo $controlLabelClass; ?>"
for="subject"><?php echo Text::_('HDP_SUBJECT');
?><span class="required">*</span></label>
			<div class="<?php echo $controlsClass; ?>">
      			   <input type="text" id="subject"
name="subject" class="input-xlarge form-control
validate[required]" value="<?php echo
$this->escape($this->input->getString('subject'));
?>" size="50" />
    		</div>			
	</div>
	<?php
		if (isset($this->lists['priority_id']))
		{
		?>
			<div class="<?php echo $controlGroupClass; ?>">
				<label class="<?php echo $controlLabelClass; ?>"
for="priority_id"><?php echo
Text::_('HDP_PRIORITY'); ?><span
class="required">*</span></label>
				<div class="<?php echo $controlsClass; ?>">
					<?php echo $this->lists['priority_id'] ; ?>
				</div>
			</div>
		<?php
		}

		$fields = $this->form->getFields();

		/* @var HDPFormField $field*/
		foreach ($fields as $field)
		{
			echo $field->getControlGroup(true, $this->bootstrapHelper);
		}
	?>
	<div class="<?php echo $controlGroupClass; ?>">
			<label class="<?php echo $controlLabelClass; ?>"
for="message"><?php echo Text::_('HDP_MESSAGE');
?><span class="required">*</span></label>
			<div class="<?php echo $controlsClass; ?>">
				<?php 
					if ($this->config->use_html_editor)
					{						
						echo $editor->display( 'message', 
$this->input->getHtml('message'), '100%',
'250', '75', '10' );
					}
					else 
					{
					?>
						<textarea rows="10" cols="70"
class="hdp_fullwidth form-control validate[required]"
name="message" id="message"><?php echo
$this->escape($this->input->getString('message'));
?></textarea>
					<?php	
					}
				?>										   			    
    		</div>						
	</div>

	<?php
	    if ($this->config->enable_attachment)
		{
		?>
			<div class="<?php echo $controlGroupClass; ?>">
				<label class="<?php echo $controlLabelClass;
?>"><?php echo Text::_('HDP_ATTACHMENTS');
?></label>
				<div class="<?php echo $controlsClass; ?>">
                    <div id="hdp_ticket_attachments"
class="dropzone needsclick dz-clickable">

                    </div>
	    		</div>						
			</div>	
		<?php	
		}
		if ($this->showCaptcha)
		{
		?>			
			<div class="<?php echo $controlGroupClass; ?>">
				<label class="<?php echo $controlLabelClass;
?>"><?php echo Text::_('HDP_CAPTCHA');
?><span class="required">*</span></label>
				<div class="<?php echo $controlsClass; ?>">
					<?php echo $this->captcha; ?>			
				</div>
			</div>	
		<?php							
		}
	?>	
	<div class="form-actions">
		<input type="button" name="btnSubmit"
class="<?php echo $btnPrimaryClass; ?>"
value="<?php echo Text::_('HDP_CANCEL'); ?>"
onclick="HDP.ticketList();" />
		<input type="submit" name="btnSubmit"
class="<?php echo $btnPrimaryClass; ?>"
value="<?php echo Text::_('HDP_SUBMIT_TICKET');
?>" />
	</div>
    <?php
        if ($this->config->enable_attachment)
        {
	        echo
HelpdeskproHelperHtml::loadCommonLayout('common/tmpl/ticket_upload_attachments.php');
        }
    ?>
	<input type="hidden" name="option"
value="com_helpdeskpro" />
	<input type="hidden" name="task"
value="ticket.save" />
	<input type="hidden" name="Itemid"
value="<?php echo $this->Itemid; ?>" />
    <?php
        if (count($this->rowCategories) == 1)
        {
            $categoryId = $this->rowCategories[0]->id;
        ?>
            <input type="hidden" name="category_id"
value="<?php echo $categoryId; ?>" />
        <?php
        }
    ?>

	<?php echo HTMLHelper::_( 'form.token' ); ?>
</form>	
</div>PK̑�[%τJView/Tickets/Html.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

namespace OSSolution\HelpdeskPro\Site\View\Tickets;

use HelpdeskProHelperBootstrap;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
use OSL\View\ListView;
use OSSolution\HelpdeskPro\Site\Helper\Database as
HelpdeskproHelperDatabase;
use OSSolution\HelpdeskPro\Site\Helper\Helper as HelpdeskproHelper;
use OSSolution\HelpdeskPro\Site\Helper\Html as HelpdeskproHelperHtml;

defined('_JEXEC') or die;

/**
 * Class Html
 *
 * @property-read \OSSolution\HelpdeskPro\Admin\Model\Tickets $model
 */
class Html extends ListView
{
	protected $lists = array();

	protected function beforeRender()
	{
		parent::beforeRender();

		$user = $this->container->user;

		if (!$user->id)
		{
			$redirectUrl =
Route::_('index.php?option=com_users&view=login&return='
. base64_encode(Uri::getInstance()->toString()));
			$this->container->app->enqueueMessage(Text::_('HDP_PLEASE_LOGIN_TO_CONTINUE'));
			$this->container->app->redirect($redirectUrl);
		}

		$config = HelpdeskproHelper::getConfig();

		// Category filter
		$filters = array();

		$role = 'admin';

		if (!$user->authorise('core.admin',
'com_helpdeskpro'))
		{
			$userId = $user->get('id');
			$email  = $user->get('email');

			$role               = HelpdeskproHelper::getUserRole();
			$managedCategoryIds =
HelpdeskproHelper::getTicketCategoryIds($user->get('username'));
			$managedCategoryIds = ArrayHelper::toInteger($managedCategoryIds);

			if (count($managedCategoryIds))
			{
				$filters[] = '(id IN (' . implode(',',
$managedCategoryIds) . ') OR id IN (SELECT DISTINCT category_id FROM
#__helpdeskpro_tickets AS t WHERE t.staff_id =' . $userId .
'))';
			}
			elseif ($role == 'staff')
			{
				$filters[] = 'id IN (SELECT DISTINCT category_id FROM
#__helpdeskpro_tickets AS t WHERE t.staff_id =' . $userId .
')';
			}
			else
			{

				$db        = $this->model->getDbo();
				$filters[] = 'id IN (SELECT DISTINCT category_id FROM
#__helpdeskpro_tickets AS t WHERE t.user_id = ' . $userId . ' OR
t.email = ' . $db->quote($email) . ')';
			}

			$filters[] = '`access` IN (' . implode(',',
$user->getAuthorisedViewLevels()) . ')';
		}

		$fieldSuffix = HelpdeskproHelper::getFieldSuffix();

		$rows = HelpdeskproHelperDatabase::getAllCategories('ordering',
$filters, $fieldSuffix);

		$this->lists['filter_category_id'] =
HelpdeskproHelperHtml::buildCategoryDropdown($this->state->filter_category_id,
'filter_category_id', 'class="input-large
form-select" onchange="submit();"', $rows);

		// Ticket status filter
		$rowStatuses =
HelpdeskproHelperDatabase::getAllStatuses('ordering',
$fieldSuffix);

		if (count($rowStatuses))
		{
			$options   = array();
			$options[] = HTMLHelper::_('select.option', -1,
Text::_('HDP_TICKET_STATUS'), 'id',
'title');
			$options[] = HTMLHelper::_('select.option', 0,
Text::_('HDP_ALL_STATUSES'), 'id', 'title');
			$options   = array_merge($options, $rowStatuses);

			$this->lists['filter_status_id'] =
HTMLHelper::_('select.genericlist', $options,
'filter_status_id',
				array(
					'option.text.toHtml' => false,
					'option.text'        => 'title',
					'option.key'         => 'id',
					'list.attr'          => 'class="input-medium
form-select" onchange="submit();"',
					'list.select'        =>
$this->state->filter_status_id));
		}

		$statusList = array();

		foreach ($rowStatuses as $status)
		{
			$statusList[$status->id] = $status->title;
		}

		// Ticket priority filter
		$rowPriorities =
HelpdeskproHelperDatabase::getAllPriorities('ordering',
$fieldSuffix);

		if (count($rowPriorities))
		{
			$options   = array();
			$options[] = HTMLHelper::_('select.option', 0,
Text::_('HDP_ALL_PRIORITIES'), 'id',
'title');
			$options   = array_merge($options, $rowPriorities);

			$this->lists['filter_priority_id'] =
HTMLHelper::_('select.genericlist', $options,
'filter_priority_id',
				array(
					'option.text.toHtml' => false,
					'option.text'        => 'title',
					'option.key'         => 'id',
					'list.attr'          => 'class="input-medium
form-select" onchange="submit();"',
					'list.select'        =>
$this->state->filter_priority_id));
		}

		$priorityList = array();

		foreach ($rowPriorities as $priority)
		{
			$priorityList[$priority->id] = $priority->title;
		}

		if (PluginHelper::isEnabled('helpdeskpro',
'assignticket') && in_array($role, ['admin',
'manager']))
		{
			$staffDisplayField = $config->get('staff_display_field',
'username') ?: 'username';

			$staffs                         =
HelpdeskproHelperDatabase::getAllStaffs($config->staff_group_id);
			$options                        = array();
			$options[]                      =
HTMLHelper::_('select.option', 0,
Text::_('HDP_SELECT_STAFF'), 'id',
$staffDisplayField);
			$options                        = array_merge($options, $staffs);
			$this->lists['filter_staff_id'] =
HTMLHelper::_('select.genericlist', $options,
'filter_staff_id', ' class="input-medium
form-select" onchange="submit();" ', 'id',
$staffDisplayField, $this->state->filter_staff_id);

			$rowStaffs = array();

			foreach ($staffs as $staff)
			{
				$rowStaffs[$staff->id] = $staff->{$staffDisplayField};
			}

			$this->staffs          = $rowStaffs;
			$this->showStaffColumn = true;
		}

		$active = Factory::getApplication()->getMenu()->getActive();

		if ($active && isset($active->query['view'])
&& $active->query['view'] == 'tickets')
		{
			$params = $active->getParams();
		}
		else
		{
			$params = new Registry;
		}

		$this->fields          =
HelpdeskproHelperDatabase::getFieldsOnListView($fieldSuffix);
		$this->fieldValues     =
$this->model->getFieldsData($this->fields);
		$this->statusList      = $statusList;
		$this->priorityList    = $priorityList;
		$this->config          = $config;
		$this->params          = $params;
		$this->bootstrapHelper = HelpdeskProHelperBootstrap::getInstance();
	}
}PK̑�[؁}��#�#View/Tickets/tmpl/default.phpnu�[���<?php
/**
 * @version        4.3.0
 * @package        Joomla
 * @subpackage     Helpdesk Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2013 - 2021 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined( '_JEXEC' ) or die ;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use OSSolution\HelpdeskPro\Site\Helper\Route as RouteHelper;

$ordering = $this->state->filter_order == 'tbl.ordering';

HTMLHelper::_('bootstrap.tooltip', '.hasTooltip',
array('placement' => 'top'));
$cols = 4;

$centerClass =
$this->bootstrapHelper->getClassMapping('center');
$pullLeft    =
$this->bootstrapHelper->getClassMapping('pull-left');
?>
<div id="hdp_container" class="container-fluid">
    <h1 class="hdp_title"><?php echo
$this->params->get('page_heading') ?:
Text::_('HDP_MY_TICKETS'); ?>
        <span class="newticket_link"><a
href="<?php echo
Route::_('index.php?option=com_helpdeskpro&task=ticket.add&Itemid='.$this->Itemid);
?>"><i class="icon-new"></i><?php echo
Text::_('HDP_SUBMIT_TICKET'); ?></a></span>
    </h1>
    <form action="<?php echo
Route::_(RouteHelper::getTicketsRoute()); ?>"
method="post" name="adminForm"
id="adminForm">
        <fieldset class="filters btn-toolbar <?php echo
$this->bootstrapHelper->getClassMapping('clearfix');
?>">
            <div class="filter-search btn-group <?php echo
$pullLeft; ?>>">
                <input type="text"
name="filter_search" id="filter_search"
placeholder="<?php echo Text::_('JSEARCH_FILTER');
?>" value="<?php echo
$this->escape($this->lists['search']); ?>"
class="hasTooltip" title="<?php echo
HTMLHelper::tooltipText('HDP_FILTER_SEARCH_TICKETS_DESC');
?>" />
            </div>
            <div class="btn-group <?php echo
$this->bootstrapHelper->getClassMapping('pull-left');
?>">
                <button type="submit" class="btn
hasTooltip" title="<?php echo
HTMLHelper::tooltipText('JSEARCH_FILTER_SUBMIT');
?>"><span class="<?php echo
$this->bootstrapHelper->getClassMapping('icon-search');
?>"></span></button>
                <button type="button" class="btn
hasTooltip" title="<?php echo
HTMLHelper::tooltipText('JSEARCH_FILTER_CLEAR'); ?>"
onclick="document.getElementById('filter_search').value='';this.form.submit();"><span
class="<?php echo
$this->bootstrapHelper->getClassMapping('icon-remove');
?>"></span></button>
            </div>
            <div class="btn-group <?php echo $pullLeft;
?>">
				<?php
				echo $this->lists['filter_category_id'];

				if (isset($this->lists['filter_status_id']))
				{
					echo $this->lists['filter_status_id'];
				}

				if (isset($this->lists['filter_priority_id']))
				{
					echo $this->lists['filter_priority_id'];
				}

				if (isset($this->lists['filter_staff_id']))
				{
					echo $this->lists['filter_staff_id'];
				}
				?>
            </div>
        </fieldset>
        <table class="<?php echo
$this->bootstrapHelper->getClassMapping('table table-striped
table-bordered'); ?> table-hover">
            <thead>
            <tr>
                <th style="text-align: left;">
					<?php echo HTMLHelper::_('grid.sort', 
Text::_('HDP_TITLE'), 'tbl.subject',
$this->state->filter_order_Dir, $this->state->filter_order );
?>
                </th>
				<?php
					foreach ($this->fields as $field)
					{
					    $cols++;

					?>
                        <th>
	                        <?php
	                        if ($field->is_searchable)
	                        {
		                        echo HTMLHelper::_('grid.sort',
Text::_($field->title), 'tbl.' . $field->name,
$this->state->filter_order_Dir, $this->state->filter_order);
	                        }
	                        else
	                        {
		                        echo $field->title;
	                        }
	                        ?>
                        </th>
					<?php
					}
				?>
                <th class="<?php echo $centerClass;
?>">
					<?php echo HTMLHelper::_('grid.sort', 
Text::_('HDP_CREATED_DATE'), 'tbl.created_date',
$this->state->filter_order_Dir, $this->state->filter_order );
?>
                </th>
                <th class="<?php echo $centerClass;
?>">
					<?php echo HTMLHelper::_('grid.sort', 
Text::_('HDP_MODIFIED_DATE'), 'tbl.modified_date',
$this->state->filter_order_Dir, $this->state->filter_order );
?>
                </th>
                <?php
                if (isset($this->lists['filter_status_id']))
                {
                    $cols++;
                ?>
                    <th width="8%">
                        <?php echo HTMLHelper::_('grid.sort', 
Text::_('HDP_STATUS'), 'tbl.status_id',
$this->state->filter_order_Dir, $this->state->filter_order );
?>
                    </th>
                <?php
                }

                if
(isset($this->lists['filter_priority_id']))
                {
                    $cols++;
                ?>
                    <th width="8%">
                        <?php echo HTMLHelper::_('grid.sort',
Text::_('HDP_PRIORITY'), 'tbl.priority_id',
$this->state->filter_order_Dir, $this->state->filter_order);
?>
                    </th>
                <?php
                }

                if (!empty($this->showStaffColumn))
				{
					$cols++;
				?>
                    <th width="10%">
						<?php echo HTMLHelper::_('grid.sort',
Text::_('HDP_ASSIGNED_TO'), 'tbl.staff_id',
$this->state->filter_order_Dir, $this->state->filter_order);
?>
                    </th>
				<?php
				}
				?>
                <th width="2%" class="<?php echo
$centerClass; ?>">
					<?php echo HTMLHelper::_('grid.sort', 
Text::_('HDP_ID'), 'tbl.id',
$this->state->filter_order_Dir, $this->state->filter_order );
?>
                </th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <td colspan="<?php echo $cols +
count($this->fields); ?>">
                    <div class="pagination"><?php echo
$this->pagination->getListFooter(); ?></div>
                </td>
            </tr>
            </tfoot>
            <tbody>
			<?php
			$k = 0;
			for ($i=0, $n=count( $this->items ); $i < $n; $i++)
			{
				$row = $this->items[$i];
				$link 	= Route::_(RouteHelper::getTicketRoute($row->id), false);
				?>
                <tr class="<?php echo "row$k"; ?>
hdp-ticket-status-<?php echo $row->status_id; ?>">
                    <td>
                        <a href="<?php echo $link;
?>"><?php echo $this->escape($row->subject) ;
?></a>	<br />
                        <small><?php echo
Text::_('HDP_CATEGORY'); ?>: <strong><?php echo
$row->category_title ; ?></strong></small>
                    </td>
					<?php
					if(count($this->fields))
					{
						foreach ($this->fields as $field)
						{
						?>
                            <td>
								<?php echo
isset($this->fieldValues[$row->id][$field->id]) ?
$this->fieldValues[$row->id][$field->id] : '';?>
                            </td>
						<?php
						}
					}
					?>
                    <td class="<?php echo $centerClass;
?>">
						<?php echo HTMLHelper::_('date', $row->created_date,
$this->config->date_format); ?>
                    </td>
                    <td class="<?php echo $centerClass;
?>">
						<?php echo HTMLHelper::_('date', $row->modified_date,
$this->config->date_format); ?>
                    </td>
                    <?php
                        if
(isset($this->lists['filter_status_id']))
                        {
                        ?>
                            <td>
		                        <?php echo
@$this->statusList[$row->status_id]; ?>
                            </td>
                        <?php
                        }

                        if
(isset($this->lists['filter_priority_id']))
                        {
                        ?>
                            <td>
		                        <?php echo
@$this->priorityList[$row->priority_id]; ?>
                            </td>
                        <?php
                        }

                        if (!empty($this->showStaffColumn))
                        {
                        ?>
                            <td>
                                <?php echo
$this->staffs[$row->staff_id]; ?>
                            </td>
                        <?php
                        }
					?>
                    <td class="<?php echo $centerClass;
?>">
						<?php echo $row->id; ?>
                    </td>
                </tr>
				<?php
				$k = 1 - $k;
			}
			?>
            </tbody>
        </table>
        <input type="hidden" name="task"
value="" />
        <input type="hidden" name="boxchecked"
value="0" />
        <input type="hidden" name="filter_order"
value="<?php echo $this->state->filter_order; ?>"
/>
        <input type="hidden" name="filter_order_Dir"
value="<?php echo $this->state->filter_order_Dir; ?>"
/>
		<?php echo HTMLHelper::_( 'form.token' ); ?>
    </form>
</div>PK̑�[r��v��views/article/tmpl/default.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="Article Detail">
		<message>
			Display detail information of a Knowledge Base article
		</message>
	</layout>
	<fields name="request">			
		<fieldset name="request"
			addfieldpath="/administrator/components/com_helpdeskpro/Model/fields">
			<field name="id" type="HelpdeskProArticle"
size="3" default="0" label="Select Article"
description="Select Article which you want to display" />
		</fieldset>	
	</fields>	
</metadata>PK̑�[�h~Reeviews/articles/tmpl/default.xmlnu�[���<metadata>
	<layout title="Knowledge Base Articles">
		<message>
			Display list of Knowledge Base categories.
		</message>
	</layout>
	<state>
		<name>Knowledge Base Articles</name>
		<description>Knowledge Base Articles</description>
		<fields name="request">
			<fieldset name="request"
addfieldpath="/administrator/components/com_helpdeskpro/fields">
				<field name="id" type="hdpcategory"
category_type="2" label="Category"
					   description="If you select a category here, only articles from
this category will be displayed" default="0" />
			</fieldset>
		</fields>
	</state>
</metadata>PK̑�[���jj!views/categories/tmpl/default.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="Knowledge Base Categories">
		<message>
			Display list of Knowledge Base Categories.
		</message>
		<fields name="params">
			<fieldset name="basic">
				<field type="text" name="number_columns"
label="Number Columns" default="2" />
			</fieldset>
		</fields>
	</layout>	
</metadata>PK̑�[U���views/ticket/tmpl/form.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="Submit Ticket">
		<message>
			Display Form allows users to submit support ticket
		</message>
		<fields name="params">
			<fieldset name="basic"
addfieldpath="/administrator/components/com_helpdeskpro/fields">
				<field name="default_category_id"
type="hdpcategory" category_type="1"
label="Default Category"
					   description="Select the default category for submit ticket
form" default="0" />
				<field name="category_ids" type="text"
label="Category Ids"
					   description="Enter IDs of categories which you want to allow
users to submit tickets to via this menu item, comma separated"
default="" />
			</fieldset>
		</fields>
	</layout>
</metadata>PK̑�[��c��views/tickets/tmpl/default.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="Ticket List/ Manage Tickets">
		<message>
			Display list of support tickets to register users and to managers
		</message>
	</layout>	
</metadata>PK̑�[����Controller/Api.phpnu�[���PK̑�[c���	�	�Controller/Controller.phpnu�[���PK̑�[�d(�((Chelpdeskpro.phpnu�[���PK̑�[q��Helper/bootstrap.phpnu�[���PK̑�[��Q���*Helper/Database.phpnu�[���PK̑�[×J�ѼѼ�;Helper/Helper.phpnu�[���PK̑�[a��800�Helper/Html.phpnu�[���PK̑�[E.����R
Helper/Jquery.phpnu�[���PK̑�[se�tXMXM\Helper/mime.mapping.phpnu�[���PK̑�[p#9#9#�`Helper/Route.phpnu�[���PK̑�[ł
KKt�Model/Article.phpnu�[���PK̑�[��7q���Model/Articles.phpnu�[���PK̑�[s'�,�Model/Categories.phpnu�[���PK̑�[џ�j
��router.phpnu�[���PK̑�[6c>Z����View/Article/Html.phpnu�[���PK̑�[�he::��View/Article/tmpl/default.phpnu�[���PK̑�[�����}�View/Articles/Html.phpnu�[���PK̑�[�
�q��S�View/Articles/tmpl/default.phpnu�[���PK̑�[�q{��V�View/Categories/Html.phpnu�[���PK̑�[A�V��
��View/Categories/tmpl/default.phpnu�[���PK̑�[VJ�
�
'��View/common/tmpl/ticket_add_comment.phpnu�[���PK̑�[�&�b��$��View/common/tmpl/ticket_comments.phpnu�[���PK̑�[*ځv�
�
)�View/common/tmpl/ticket_customer_info.phpnu�[���PK̑�[v��`��"�View/common/tmpl/ticket_detail.phpnu�[���PK̑�[2F��.	View/common/tmpl/ticket_upload_attachments.phpnu�[���PK̑�[�#�rView/common/tmpl/toolbar.phpnu�[���PK̑�[�s�XX�-View/fieldlayout/checkboxes.phpnu�[���PK̑�[O�o��!�5View/fieldlayout/controlgroup.phpnu�[���PK̑�[��l����:View/fieldlayout/heading.phpnu�[���PK̑�[�W�B��u<View/fieldlayout/label.phpnu�[���PK̑�[�K��M@View/fieldlayout/message.phpnu�[���PK̑�[k5�_bb�BView/fieldlayout/radio.phpnu�[���PK̑�[
����-JView/fieldlayout/text.phpnu�[���PK̑�[�6U,��LView/fieldlayout/textarea.phpnu�[���PK̑�[�S;�c)c)�MView/Ticket/Html.phpnu�[���PK̑�[���}}�wView/Ticket/tmpl/default.phpnu�[���PK̑�[�$����k�View/Ticket/tmpl/form.phpnu�[���PK̑�[%τJ��View/Tickets/Html.phpnu�[���PK̑�[؁}��#�#��View/Tickets/tmpl/default.phpnu�[���PK̑�[r��v����views/article/tmpl/default.xmlnu�[���PK̑�[�h~Ree�views/articles/tmpl/default.xmlnu�[���PK̑�[���jj!��views/categories/tmpl/default.xmlnu�[���PK̑�[U�����views/ticket/tmpl/form.xmlnu�[���PK̑�[��c����views/tickets/tmpl/default.xmlnu�[���PK,,k��