public function beforeRemove()
 {
     $this->conversationId = $this->object->conversationId;
     if (!($this->conversation = $this->modx->getObject('modxTalksConversation', $this->conversationId))) {
         return $this->modx->lexicon('modxtalks.empty_conversation');
     }
     $cProperties = $this->conversation->getProperties('comments');
     $this->conversation->setProperties(array('total' => ++$cProperties['total'], 'deleted' => $cProperties['deleted'], 'unconfirmed' => $cProperties['unconfirmed'] > 0 ? --$cProperties['unconfirmed'] : 0), 'comments', false);
     $q = $this->modx->newQuery('modxTalksPost', array('conversationId' => $this->conversationId));
     $q->sortby('idx', 'DESC');
     $idx = 0;
     if ($lastComment = $this->modx->getObject('modxTalksPost', $q)) {
         $idx = $lastComment->get('idx');
     }
     $this->comment = $this->modx->newObject('modxTalksPost');
     $time = time();
     $commentParams = array('idx' => ++$idx, 'conversationId' => $this->conversationId, 'time' => $time, 'date' => strftime('%Y%m', $time), 'content' => $this->object->content, 'ip' => $this->object->ip);
     if ($this->object->userId > 0) {
         $commentParams['userId'] = $this->object->userId;
     } else {
         $commentParams['username'] = $this->object->username;
         $commentParams['useremail'] = $this->object->useremail;
     }
     $this->comment->fromArray($commentParams);
     if ($this->comment->save() !== true) {
         return $this->modx->lexicon('modxtalks.error');
     }
     if ($this->conversation->save() !== true) {
         return $this->modx->lexicon('modxtalks.error');
     }
     $this->modx->invokeEvent('OnModxTalksCommentAfterAdd', array('mode' => modSystemEvent::MODE_NEW, $this->comment->getPK() => $this->comment->getPrimaryKey(), 'modxtalks.post' => &$this->comment, 'object' => &$this->comment));
     return parent::beforeRemove();
 }
 /**
  * Cache the comment
  *
  * @access public
  *
  * @param object $comment Comment object
  *
  * @return bool
  */
 public function cacheComment(modxTalksPost &$comment)
 {
     $cache = $this->modx->getCacheManager();
     if ($this->mtCache && $cache) {
         $tmp = $comment->toArray('', true);
         $tmp['raw_content'] = $comment->content;
         $tmp['content'] = $this->bbcode($comment->content);
         if (!$this->modx->cacheManager->set($comment->idx, $tmp, 0, array(xPDO::OPT_CACHE_KEY => 'modxtalks/conversation/' . $comment->conversationId))) {
             return false;
         }
     }
     return true;
 }