/** * Delete one or more records * * @return void */ public function removeTask() { // Check for request forgeries Request::checkToken(); // Incoming $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; // Check for an ID if (count($ids) < 1) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SUPPORT_ERROR_SELECT_MESSAGE_TO_DELETE'), 'error'); return; } foreach ($ids as $id) { // Delete message $msg = new Message($this->database); $msg->delete(intval($id)); } // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SUPPORT_MESSAGE_SUCCESSFULLY_DELETED', count($ids))); }
/** * Displays a ticket and comments * * @param mixed $comment * @return void */ public function editTask($comment = null) { Request::setVar('hidemainmenu', 1); $layout = 'edit'; // Incoming $id = Request::getInt('id', 0); // Initiate database class and load info $row = Ticket::getInstance($id); // Editing or creating a ticket? if (!$row->exists()) { $layout = 'add'; // Creating a new ticket $row->set('severity', 'normal'); $row->set('status', 0); $row->set('created', Date::toSql()); $row->set('login', User::get('username')); $row->set('name', User::get('name')); $row->set('email', User::get('email')); $row->set('cookies', 1); $browser = new \Hubzero\Browser\Detector(); $row->set('os', $browser->platform() . ' ' . $browser->platformVersion()); $row->set('browser', $browser->name() . ' ' . $browser->version()); $row->set('uas', Request::getVar('HTTP_USER_AGENT', '', 'server')); $row->set('ip', Request::ip()); $row->set('hostname', gethostbyaddr(Request::getVar('REMOTE_ADDR', '', 'server'))); $row->set('section', 1); } $this->view->filters = Utilities::getFilters(); $this->view->lists = array(); // Get messages $sm = new Tables\Message($this->database); $this->view->lists['messages'] = $sm->getMessages(); // Get categories $sa = new Tables\Category($this->database); $this->view->lists['categories'] = $sa->find('list'); // Get severities $this->view->lists['severities'] = Utilities::getSeverities($this->config->get('severities')); if (trim($row->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('owner', $row->get('owner'), 1, '', trim($row->get('group'))); } elseif (trim($this->config->get('group'))) { $this->view->lists['owner'] = $this->_userSelectGroup('owner', $row->get('owner'), 1, '', trim($this->config->get('group'))); } else { $this->view->lists['owner'] = $this->_userSelect('owner', $row->get('owner'), 1); } $this->view->row = $row; if ($watch = Request::getWord('watch', '')) { $watch = strtolower($watch); // Already watching if ($this->view->row->isWatching(User::getInstance())) { // Stop watching? if ($watch == 'stop') { $this->view->row->stopWatching(User::getInstance()); } } else { // Start watching? if ($watch == 'start') { $this->view->row->watch(User::getInstance()); if (!$this->view->row->isWatching(User::getInstance(), true)) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_WATCH')); } } } } if (!$comment) { $comment = new Comment(); } $this->view->comment = $comment; // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Output the HTML $this->view->set('config', $this->config)->setLayout($layout)->display(); }
/** * 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(); }