/** * Display a ticket and associated comments * * @param mixed $comment * @return void */ public function ticketTask($comment = null) { // Get the ticket ID $id = Request::getInt('id', 0); if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->controller . '&task=tickets'), Lang::txt('COM_SUPPORT_ERROR_MISSING_TICKET_ID'), 'error'); return; } // Initiate database class and load info $this->view->row = Ticket::getInstance($id); if (!$this->view->row->exists()) { App::abort(404, Lang::txt('COM_SUPPORT_ERROR_TICKET_NOT_FOUND')); return; } // Check authorization if (User::isGuest()) { $return = base64_encode(Route::url($this->view->row->link(), false, true)); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return, false)); return; } // Ensure the user is authorized to view this ticket if (!$this->view->row->access('read', 'tickets')) { App::abort(403, Lang::txt('COM_SUPPORT_ERROR_NOT_AUTH')); return; } $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'show' => Request::getState($this->_option . '.' . $this->_controller . '.show', 'show', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''))); if ($watch = Request::getWord('watch', '')) { // Already watching if ($this->view->row->isWatching(User::get('id'))) { // Stop watching? if ($watch == 'stop') { $this->view->row->stopWatching(User::get('id')); } } else { // Start watching? if ($watch == 'start') { $this->view->row->watch(User::get('id')); if (!$this->view->row->isWatching(User::get('id'), true)) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_WATCH')); } } } } $this->view->lists = array(); $sc = new Tables\Category($this->database); $this->view->lists['categories'] = $sc->find('list'); // Get messages $sm = new Tables\Message($this->database); $this->view->lists['messages'] = $sm->getMessages(); // Get severities $this->view->lists['severities'] = Utilities::getSeverities($this->config->get('severities')); // Populate the list of assignees based on if the ticket belongs to a group or not if (trim($this->view->row->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('ticket[owner]', $this->view->row->get('owner'), 1, '', trim($this->view->row->get('group'))); } elseif (trim($this->config->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('ticket[owner]', $this->view->row->get('owner'), 1, '', trim($this->config->get('group'))); } else { $this->view->lists['owner'] = $this->_userSelect('ticket[owner]', $this->view->row->get('owner'), 1); } // Set the pathway $this->_buildPathway($this->view->row); // Set the page title $this->_buildTitle($this->view->row); $this->view->title = $this->_title; $this->view->database = $this->database; if (\Notify::any('support')) { foreach (\Notify::messages('support') as $error) { if ($error['type'] == 'error') { $this->view->setError($error['message']); } } } if (!$comment) { $comment = new Comment(); } $this->view->comment = $comment; // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->set('config', $this->config)->setLayout('ticket')->display(); }
/** * Save cached data * * @return void */ public function onAfterRender() { if (App::isAdmin() || Config::get('debug')) { return; } if (Notify::any()) { return; } if (User::isGuest()) { // We need to check again here, because auto-login plugins // have not been fired before the first aid check App::get('cache')->put($this->getId(), App::get('response')->getContent(), App::get('config')->get('lifetime', 45)); } }
/** * Save cached data * * @return void */ public function onAfterRender() { if (App::isAdmin() || Config::get('debug')) { return; } if (Notify::any() || !App::has('cache')) { return; } if (User::isGuest() && $this->params->get('pagecache', false)) { $path = trim(str_replace(Request::base(), '', Request::current())); $path = trim($path, '/'); if ($this->isExempt($path) || $this->isExempt(Request::current())) { return; } // We need to check again here, because auto-login plugins // have not been fired before the first aid check App::get('cache')->put($this->getId(), App::get('response')->getContent(), App::get('config')->get('lifetime', 45)); } }