Example #1
0
 /**
  * Removes a ticket and all associated records (tags, comments, etc.)
  *
  * @return	void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     // 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_TICKET_TO_DELETE'), 'error');
         return;
     }
     foreach ($ids as $id) {
         $id = intval($id);
         // Delete tags
         $tags = new Tags($id);
         $tags->removeAll();
         // Delete comments
         $comment = new Tables\Comment($this->database);
         $comment->deleteComments($id);
         // Delete attachments
         $attach = new Tables\Attachment($this->database);
         $attach->deleteAllForTicket($id);
         // Delete ticket
         $ticket = new Tables\Ticket($this->database);
         $ticket->delete($id);
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SUPPORT_TICKET_SUCCESSFULLY_DELETED', count($ids)));
 }
Example #2
0
 /**
  * Get a count of or list of comments on this model
  *
  * @param   string   $rtrn     Data to return state in [count, list]
  * @param   array    $filters  Filters to apply to the query
  * @param   boolean  $clear    Clear data cache?
  * @return  mixed
  */
 public function comments($rtrn = 'list', $filters = array(), $clear = false)
 {
     if (!isset($filters['ticket'])) {
         $filters['ticket'] = $this->get('id');
     }
     if (!isset($filters['access'])) {
         $filters['access'] = 1;
         //$this->access('read', 'private_comments');
     }
     if (!isset($filters['sort'])) {
         $filters['sort'] = 'id';
     }
     if (!isset($filters['sort_Dir'])) {
         $filters['sort_Dir'] = 'ASC';
     }
     switch (strtolower($rtrn)) {
         case 'count':
             if (!is_numeric($this->_data->get('comments.count')) || $clear) {
                 $tbl = new Tables\Comment($this->_db);
                 $this->_data->set('comments.count', $tbl->countComments($filters['access'], $filters['ticket']));
             }
             return $this->_data->get('comments.count');
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_data->get('comments.list') instanceof ItemList || $clear) {
                 $tbl = new Tables\Comment($this->_db);
                 if ($results = $tbl->getComments($filters['access'], $filters['ticket'], $filters['sort'], $filters['sort_Dir'])) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Comment($result);
                     }
                 } else {
                     $results = array();
                 }
                 $this->_data->set('comments.list', new ItemList($results));
             }
             return $this->_data->get('comments.list');
             break;
     }
 }
Example #3
0
 /**
  * Removes a ticket and all associated records (tags, comments, etc.)
  *
  * @return	void
  */
 public function deleteTask()
 {
     // Incoming
     $id = Request::getInt('id', 0);
     // Check for an ID
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=tickets'));
         return;
     }
     // Delete tags
     $tags = new Tags($id);
     $tags->removeAll();
     // Delete comments
     $comment = new Tables\Comment($this->database);
     $comment->deleteComments($id);
     $attach = new Tables\Attachment($this->database);
     if (!$attach->deleteAllForTicket($id)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=tickets'), $attach->getError(), 'error');
         return;
     }
     // Delete ticket
     $ticket = new Tables\Ticket($this->database);
     $ticket->delete($id);
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=tickets'));
 }