Ejemplo n.º 1
0
 public static function processSettingList($settings, $place, $isAdmin)
 {
     if ($place != BOL_ComponentService::PLACE_DASHBOARD && !OW::getUser()->isAdmin()) {
         $settings['content'] = UTIL_HtmlTag::stripJs($settings['content']);
         //$settings['content'] = UTIL_HtmlTag::stripTags($settings['content'], array('frame'), array(), true, true);
     } else {
         $settings['content'] = UTIL_HtmlTag::sanitize($settings['content']);
     }
     return parent::processSettingList($settings, $place, $isAdmin);
 }
Ejemplo n.º 2
0
 public function process($ctrl)
 {
     OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
     $service = PostService::getInstance();
     /* @var $postDao PostService */
     $data = $this->getValues();
     $data['title'] = UTIL_HtmlTag::stripJs($data['title']);
     $postIsNotPublished = $this->post->getStatus() == 2;
     $text = UTIL_HtmlTag::sanitize($data['post']);
     /* @var $post Post */
     $this->post->setTitle($data['title']);
     $this->post->setPost($text);
     $this->post->setIsDraft($_POST['command'] == 'draft');
     $isCreate = empty($this->post->id);
     if ($isCreate) {
         $this->post->setTimestamp(time());
         //Required to make #698 and #822 work together
         if ($_POST['command'] == 'draft') {
             $this->post->setIsDraft(2);
         }
         BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog');
     } else {
         //If post is not new and saved as draft, remove their item from newsfeed
         if ($_POST['command'] == 'draft') {
             OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id)));
         } else {
             if ($postIsNotPublished) {
                 // Update timestamp if post was published for the first time
                 $this->post->setTimestamp(time());
             }
         }
     }
     $service->save($this->post);
     $tags = array();
     if (intval($this->post->getId()) > 0) {
         $tags = $data['tf'];
         foreach ($tags as $id => $tag) {
             $tags[$id] = UTIL_HtmlTag::stripTags($tag);
         }
     }
     $tagService = BOL_TagService::getInstance();
     $tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags);
     if ($this->post->isDraft()) {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), false);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg'));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg'));
         }
     } else {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), true);
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId()));
         OW::getEventManager()->trigger($event);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId())));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId())));
         }
         $ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId())));
     }
 }