| @@ -1,0 +1,59 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @package VikBooking | |
| 4 | + * @subpackage com_vikbooking | |
| 5 | + * @author Alessio Gaggii - e4j - Extensionsforjoomla.com | |
| 6 | + * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. | |
| 7 | + * @license GNU General Public License version 2 or later; see LICENSE | |
| 8 | + * @link https://vikwp.com | |
| 9 | + */ | |
| 10 | + | |
| 11 | +defined('ABSPATH') or die('No script kiddies please!'); | |
| 12 | + | |
| 13 | +jimport('joomla.application.component.view'); | |
| 14 | + | |
| 15 | +class VikbookingViewOperators extends JViewVikBooking | |
| 16 | +{ | |
| 17 | + public function display($tpl = null) | |
| 18 | + { | |
| 19 | + VikBooking::prepareViewContent(); | |
| 20 | + | |
| 21 | + $app = JFactory::getApplication(); | |
| 22 | + | |
| 23 | + // access the global operators object | |
| 24 | + $oper_obj = VikBooking::getOperatorInstance(); | |
| 25 | + | |
| 26 | + // attempt to get the current operator | |
| 27 | + $operator = $oper_obj->getOperatorAccount(); | |
| 28 | + | |
| 29 | + // check request value for a custom tool | |
| 30 | + $tool = $app->input->getString('tool', ''); | |
| 31 | + | |
| 32 | + if ($operator === false) { | |
| 33 | + // operator needs to log in (default_login.php) | |
| 34 | + $tpl = 'login'; | |
| 35 | + } elseif ($tool) { | |
| 36 | + /** | |
| 37 | + * Change layout from default to "tool" (tool.php). | |
| 38 | + * | |
| 39 | + * @since 1.16.9 (J) - 1.6.9 (WP) | |
| 40 | + */ | |
| 41 | + $this->setLayout('tool'); | |
| 42 | + } else { | |
| 43 | + // operator is logged in (default_dashboard.php) | |
| 44 | + $tpl = 'dashboard'; | |
| 45 | + } | |
| 46 | + | |
| 47 | + // convert the JSON strings into array values | |
| 48 | + if ($operator) { | |
| 49 | + $operator['perms'] = !empty($operator['perms']) ? (is_scalar($operator['perms']) ? (array) json_decode($operator['perms'], true) : $operator['perms']) : []; | |
| 50 | + $operator['work_days_week'] = !empty($operator['work_days_week']) ? (is_scalar($operator['work_days_week']) ? (array) json_decode($operator['work_days_week'], true) : $operator['work_days_week']) : []; | |
| 51 | + $operator['work_days_exceptions'] = !empty($operator['work_days_exceptions']) ? (is_scalar($operator['work_days_exceptions']) ? (array) json_decode($operator['work_days_exceptions'], true) : $operator['work_days_exceptions']) : []; | |
| 52 | + } | |
| 53 | + | |
| 54 | + $this->operator = $operator; | |
| 55 | + $this->tool = $tool; | |
| 56 | + | |
| 57 | + parent::display($tpl); | |
| 58 | + } | |
| 59 | +} | |