/**
  * Handle on add comment event
  *
  * @param Comment $comment
  * @return null
  */
 function onAddComment(Comment $comment)
 {
     try {
         Notifier::newMessageComment($comment);
     } catch (Exception $e) {
         // nothing here, just suppress error...
     }
     // try
 }
 /**
  * Add comment
  *
  * @access public
  * @param void
  * @return null
  */
 function add_comment()
 {
     $message = ProjectMessages::findById(get_id());
     if (!$message instanceof ProjectMessage) {
         flash_error(lang('message dnx'));
         $this->redirectTo('message');
     }
     // if
     if (!$message->canAddComment(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToUrl($message->getViewUrl());
     }
     // if
     $comment = new MessageComment();
     $comment_data = array_var($_POST, 'comment');
     tpl_assign('message', $message);
     tpl_assign('comment', $comment);
     tpl_assign('comment_data', $comment_data);
     if (is_array($comment_data)) {
         $comment->setFromAttributes($comment_data);
         $comment->setMessageId($message->getId());
         if (!logged_user()->isMemberOfOwnerCompany()) {
             $comment->setIsPrivate(false);
         }
         try {
             DB::beginWork();
             $comment->save();
             ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             // Try to send notification but don't break
             try {
                 Notifier::newMessageComment($comment);
             } catch (Exception $e) {
             }
             // try
             flash_success(lang('success add comment'));
             $this->redirectToUrl($message->getViewUrl());
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         // try
     }
     // if
 }