Exemple #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;
 }
Exemple #2
0
 private function deleteAttachmentFiles(BOL_Comment $comment)
 {
     // delete attachments
     $attch = $comment->getAttachment();
     if ($attch !== null) {
         $tempArr = json_decode($attch, true);
         if (!empty($tempArr['uid']) && !empty($tempArr['pluginKey'])) {
             BOL_AttachmentService::getInstance()->deleteAttachmentByBundle($tempArr['pluginKey'], $tempArr['uid']);
         }
     }
 }
Exemple #3
0
 private function deleteAttachmentFiles(BOL_Comment $comment)
 {
     // delete attachments
     $attch = $comment->getAttachment();
     if ($attch !== null) {
         $tempArr = json_decode($attch, true);
         if ($tempArr['type'] == 'photo') {
             OW::getEventManager()->call('base.attachment_delete_image', array('url' => $tempArr['url']));
         }
     }
 }