/**
  * Open specific ticket
  *
  * @access public
  * @param void
  * @return null
  */
 function open()
 {
     $ticket = ProjectTickets::findById(get_id());
     if (!$ticket instanceof ProjectTicket) {
         flash_error(lang('ticket dnx'));
         $this->redirectTo('tickets');
     }
     // if
     if (!$ticket->canChangeStatus(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('tickets'));
     }
     // if
     $status = $ticket->isClosed() ? 'closed' : 'open';
     try {
         DB::beginWork();
         $ticket->openTicket();
         ApplicationLogs::createLog($ticket, active_project(), ApplicationLogs::ACTION_OPEN);
         DB::commit();
         if ($status != 'open') {
             $change = new ProjectTicketChange();
             $change->setTicketId($ticket->getId());
             $change->setType('status');
             $change->setFromData($status);
             $change->setToData('open');
             $change->save();
         }
         try {
             Notifier::ticket($ticket, $ticket->getSubscribers(), 'open_ticket', logged_user());
         } catch (Exception $e) {
             // nothing here, just suppress error...
         }
         // try
         flash_success(lang('success open ticket'));
     } catch (Exception $e) {
         flash_error(lang('error open ticket'));
         DB::rollback();
     }
     // try
     $this->redirectToUrl(ProjectTickets::getIndexUrl());
 }
 /**
  * Handle on add comment event
  *
  * @param array $files Attached files
  * @return null
  */
 function onAttachFiles($files)
 {
     try {
         $this->setUpdated('attachment');
         $this->save();
         foreach ($files as $file) {
             $change = new ProjectTicketChange();
             $change->setTicketId($this->getId());
             $change->setType('attachment');
             $change->setToData($file->getFilename());
             $change->save();
         }
         // foreach
         Notifier::attachFilesToTicket($this, $files);
     } catch (Exception $e) {
         // nothing here, just suppress error...
     }
     // try
 }