Example #1
0
 /**
  * @return BOL_Comment
  */
 public function addComment($entityType, $entityId, $pluginKey, $userId, $message, $attachment = null)
 {
     $commentEntity = $this->commentEntityDao->findByEntityTypeAndEntityId($entityType, $entityId);
     if ($commentEntity === null) {
         $commentEntity = new BOL_CommentEntity();
         $commentEntity->setEntityType(trim($entityType));
         $commentEntity->setEntityId((int) $entityId);
         $commentEntity->setPluginKey($pluginKey);
         $this->commentEntityDao->save($commentEntity);
     }
     //$message = UTIL_HtmlTag::stripTags($message, $this->configs[self::CONFIG_ALLOWED_TAGS], $this->configs[self::CONFIG_ALLOWED_ATTRS]);
     //$message = UTIL_HtmlTag::stripJs($message);
     //$message = UTIL_HtmlTag::stripTags($message, array('frame', 'style'), array(), true);
     if ($attachment !== null && strlen($message) == 0) {
         $message = '';
     } else {
         $message = UTIL_HtmlTag::autoLink(nl2br(htmlspecialchars($message)));
     }
     $comment = new BOL_Comment();
     $comment->setCommentEntityId($commentEntity->getId());
     $comment->setMessage(trim($message));
     $comment->setUserId($userId);
     $comment->setCreateStamp(time());
     if ($attachment !== null) {
         $comment->setAttachment($attachment);
     }
     $this->commentDao->save($comment);
     return $comment;
 }