Example #1
0
 /**
  * Display a form for processing tickets in a batch
  *
  * @return  void
  */
 public function batchTask()
 {
     Request::setVar('hidemainmenu', 1);
     // Incoming
     $this->view->ids = Request::getVar('id', array());
     $this->view->tmpl = Request::getVar('tmpl', '');
     $this->view->filters = Utilities::getFilters();
     $this->view->lists = array();
     // 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'));
     $this->view->lists['owner'] = $this->_userSelect('owner', '', 1);
     // Output the HTML
     $this->view->display();
 }
Example #2
0
 /**
  * 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();
 }
Example #3
0
 /**
  * Create a new record
  *
  * @return    object
  */
 public function getConditions()
 {
     $conditions = new stdClass();
     $conditions->owner = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     // Groups
     $items = array($this->_value('*', Lang::txt('(any of mine)'), true));
     if ($xgroups = \Hubzero\User\Helper::getGroups(User::get('id'), 'members')) {
         foreach ($xgroups as $xgroup) {
             $xgroup->description = trim($xgroup->description) ?: $xgroup->cn;
             $items[] = $this->_value($xgroup->cn, stripslashes($this->escape($xgroup->description)), false);
         }
     }
     $conditions->group = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), $items);
     $conditions->login = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     $conditions->id = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('lt', 'less than', false), $this->_operator('gt', 'grater than', false), $this->_operator('=lt', 'less than or equal to', false), $this->_operator('gt=', 'greater than or equal to', false)), 'text');
     $conditions->report = $this->_expression(array($this->_operator('=', 'is', false), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', true), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     $conditions->open = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), array($this->_value('1', 'open', true), $this->_value('0', 'closed', false)));
     $sr = new \Components\Support\Tables\Status($this->database);
     $status = $sr->find('list', array('sort' => 'open', 'sort_Dir' => 'DESC'));
     $items = array();
     $items[] = $this->_value(0, $this->escape('open: New'), true);
     if (isset($status) && is_array($status)) {
         $switched = false;
         foreach ($status as $anode) {
             if (!$anode->open && !$switched) {
                 $items[] = $this->_value(-1, $this->escape('closed: No resolution'), false);
                 $switched = true;
             }
             $items[] = $this->_value($anode->id, $this->escape(($anode->open ? 'open: ' : 'closed: ') . stripslashes($anode->title)), false);
         }
     }
     $conditions->status = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     $conditions->created = $this->_expression(array($this->_operator('=', 'on', true), $this->_operator('lt', 'before', false), $this->_operator('gt', 'after', false)), 'text');
     $conditions->closed = $this->_expression(array($this->_operator('=', 'on', true), $this->_operator('lt', 'before', false), $this->_operator('gt', 'after', false)), 'text');
     $conditions->tag = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), 'text');
     $conditions->type = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), array($this->_value('0', 'user submitted', true), $this->_value('1', 'automatic', false), $this->_value('3', 'tool', false)));
     $severities = Utilities::getSeverities($this->config->get('severities'));
     $items = 'text';
     if (isset($severities) && is_array($severities)) {
         $items = array();
         foreach ($severities as $severity) {
             $sel = false;
             if ($severity == 'normal') {
                 $sel = true;
             }
             $items[] = $this->_value($severity, $severity, $sel);
         }
     }
     $conditions->severity = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     $sc = new Category($this->database);
     $categories = $sc->find('list');
     $items = 'text';
     if (isset($categories) && is_array($categories)) {
         $items = array();
         foreach ($categories as $anode) {
             $sel = false;
             $items[] = $this->_value($this->escape($anode->alias), $this->escape(stripslashes($anode->title)), $sel);
         }
     }
     $conditions->category = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     return $conditions;
 }
Example #4
0
 /**
  * Delete one or more records
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array(0));
     if (!is_array($ids)) {
         $ids = array(0);
     }
     // 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_CATEGORY_TO_DELETE'), 'error');
         return;
     }
     foreach ($ids as $id) {
         // Delete message
         $cat = new Category($this->database);
         $cat->delete(intval($id));
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SUPPORT_CATEGORY_SUCCESSFULLY_DELETED', count($ids)));
 }