| @@ -11,23 +11,49 @@ | ||
| 11 | 11 | defined('ABSPATH') or die('No script kiddies please!'); |
| 12 | 12 | |
| 13 | 13 | jimport('joomla.application.component.view'); |
| 14 | 14 | |
| 15 | -class VikbookingViewOperators extends JViewVikBooking { | |
| 16 | - function display($tpl = null) { | |
| 15 | +class VikbookingViewOperators extends JViewVikBooking | |
| 16 | +{ | |
| 17 | + public function display($tpl = null) | |
| 18 | + { | |
| 17 | 19 | VikBooking::prepareViewContent(); |
| 18 | 20 | |
| 19 | - $operator = VikBooking::getOperatorInstance()->getOperatorAccount(); | |
| 21 | + $app = JFactory::getApplication(); | |
| 20 | 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 | + | |
| 21 | 32 | if ($operator === false) { |
| 22 | 33 | // operator needs to log in (default_login.php) |
| 23 | 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'); | |
| 24 | 42 | } else { |
| 25 | 43 | // operator is logged in (default_dashboard.php) |
| 26 | 44 | $tpl = 'dashboard'; |
| 27 | 45 | } |
| 28 | 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 | + | |
| 29 | 54 | $this->operator = $operator; |
| 55 | + $this->tool = $tool; | |
| 30 | 56 | |
| 31 | 57 | parent::display($tpl); |
| 32 | 58 | } |
| 33 | 59 | } |