Esempio n. 1
0
 public function onQuestionRemove(OW_Event $e)
 {
     $params = $e->getParams();
     $questionId = (int) $params['id'];
     $posts = $this->service->findFullCommentList(EQUESTIONS_BOL_Service::ENTITY_TYPE, $questionId);
     foreach ($posts as $post) {
         $event = new OW_Event(EQUESTIONS_BOL_Service::EVENT_POST_REMOVED, array('questionId' => $questionId, 'id' => $post->id, 'userId' => $post->userId));
         OW::getEventManager()->trigger($event);
     }
     $this->service->deleteEntityComments(EQUESTIONS_BOL_Service::ENTITY_TYPE, $questionId);
 }
Esempio n. 2
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_CommentService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Esempio n. 3
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = LinkService::getInstance();
     $userId = $params->additionalParamList['entityId'];
     if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) {
         $this->setVisible(false);
         return;
     }
     /* Check privacy permissions */
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $ex) {
         $this->setVisible(false);
         return;
     }
     /* */
     if ($service->countUserLinks($userId) == 0 && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $this->assign('displayname', BOL_UserService::getInstance()->getDisplayName($userId));
     $this->assign('username', BOL_UserService::getInstance()->getUsername($userId));
     $list = array();
     $count = $params->customParamList['count'];
     $userLinkList = $service->findUserLinkList($userId, 0, $count);
     $idList = array();
     foreach ($userLinkList as $item) {
         /* Check privacy permissions */
         if ($item->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) {
             $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $item->userId, 'viewerId' => OW::getUser()->getId());
             try {
                 OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
             } catch (RedirectException $ex) {
                 continue;
             }
         }
         /* */
         $list[] = $item;
         $idList[] = $item->id;
     }
     $commentInfo = array();
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $tb = array();
         foreach ($list as $key => $item) {
             if (mb_strlen($item->getDescription()) > 100) {
                 $item->setDescription(UTIL_String::truncate($item->getDescription(), 100, '...'));
             }
             $list[$key]->setDescription(strip_tags($item->getDescription()));
             $tb[$item->getId()] = array(array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('links', 'comments'), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $item->getId()))), array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date'));
         }
         $this->assign('tb', $tb);
     }
     $this->assign('list', $list);
     $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('links-user', array('user' => BOL_UserService::getInstance()->getUserName($userId))))));
 }
Esempio n. 4
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('questions');
     $optionTotal = QUESTIONS_BOL_Service::getInstance()->findOptionCount($this->question->id);
     $answerCount = QUESTIONS_BOL_Service::getInstance()->findTotalAnswersCount($this->question->id);
     $postCount = BOL_CommentService::getInstance()->findCommentCount(QUESTIONS_BOL_Service::ENTITY_TYPE, $this->question->id);
     $questionUrl = OW::getRouter()->urlForRoute('questions-question', array('qid' => $this->question->id));
     $count = QUESTIONS_BOL_Service::DISPLAY_COUNT;
     if ($optionTotal - $count < 2) {
         $count = $optionTotal;
     }
     $answers = new QUESTIONS_CMP_Answers($this->question, $optionTotal, array(0, $count));
     $answers->setTotalAnswerCount($answerCount);
     $answers->setUsersContext($this->getContextUserIds());
     $bubbleActivity = $this->getBubbleActivity();
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $text = $this->getItemString($bubbleActivity, $jsSelector, $questionUrl);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($bubbleActivity->userId));
     $allowPopups = !isset($configs['allow_popups']) || $configs['allow_popups'];
     $features = array();
     $onClickStr = "window.location.href='{$questionUrl}'";
     if ($configs['allow_comments']) {
         if ($allowPopups) {
             $onClickStr = "return {$jsSelector}.openQuestionDelegate(true);";
         }
         $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-comments', 'iconClass' => 'ow_miniic_comment', 'label' => $postCount, 'onclick' => $onClickStr, 'string' => null);
     }
     if ($allowPopups) {
         $onClickStr = "return {$jsSelector}.openQuestionDelegate();";
     }
     $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-votes', 'iconClass' => 'questions_miniicon_check', 'label' => $answerCount, 'onclick' => $onClickStr, 'string' => null);
     if ($configs['enable_follow']) {
         $onClickStr = "OW.error('" . $language->text('questions', 'follow_not_allowed') . "')";
         $isFollowing = false;
         if (QUESTIONS_BOL_Service::getInstance()->isCurrentUserCanInteract($this->question)) {
             $userId = OW::getUser()->getId();
             $isFollowing = QUESTIONS_BOL_Service::getInstance()->isFollow($userId, $this->question->id);
             $onClickStr = $isFollowing ? $jsSelector . '.unfollowQuestion();' : $jsSelector . '.followQuestion();';
         } else {
             if (OW::getUser()->isAuthenticated()) {
                 $isFollowing = QUESTIONS_BOL_Service::getInstance()->isFollow($userId, $this->question->id);
                 if ($isFollowing) {
                     $onClickStr = $jsSelector . '.unfollowQuestion();';
                 }
             }
         }
         $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-follows', 'iconClass' => 'questions_miniic_follow', 'label' => QUESTIONS_BOL_Service::getInstance()->findFollowsCount($this->question->id), 'onclick' => $onClickStr, 'active' => $isFollowing);
     }
     $settings = $this->question->getSettings();
     $context = empty($settings['context']['url']) || empty($settings['context']['label']) ? null : array('url' => $settings['context']['url'], 'label' => $settings['context']['label']);
     $tplQuestion = array('questionId' => $this->question->id, 'uniqId' => $this->getUniqId(), 'text' => $text, 'timeStamp' => UTIL_DateTime::formatDate($bubbleActivity->timeStamp), 'lastItem' => $this->lastItem, 'answers' => $answers->render(), 'avatar' => $avatars[$bubbleActivity->userId], 'settings' => $settings, 'context' => $context, 'features' => $features, 'permalink' => $questionUrl);
     $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_LIST_ITEM_RENDER, array("questionId" => $this->question->id, "questionDto" => $this->question, "text" => $text, "settings" => $settings, "uniqId" => $this->getUniqId()), $tplQuestion);
     OW::getEventManager()->trigger($event);
     $this->assign('item', $event->getData());
 }
Esempio n. 5
0
 public function onAfterGroupDelete(OW_Event $event)
 {
     $params = $event->getParams();
     $groupId = $params['groupId'];
     BOL_ComponentEntityService::getInstance()->onEntityDelete(GROUPS_BOL_Service::WIDGET_PANEL_NAME, $groupId);
     BOL_CommentService::getInstance()->deleteEntityComments(GROUPS_BOL_Service::ENTITY_TYPE_WAL, $groupId);
     BOL_FlagService::getInstance()->deleteByTypeAndEntityId(GROUPS_BOL_Service::ENTITY_TYPE_GROUP, $groupId);
     OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => GROUPS_BOL_Service::FEED_ENTITY_TYPE, 'entityId' => $groupId)));
 }
Esempio n. 6
0
 public function onCommentAdd(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['attachment'])) {
         return;
     }
     $commentId = $params['commentId'];
     $commentDto = BOL_CommentService::getInstance()->findComment($commentId);
     $this->processAttachment($params['userId'], $params['attachment'], $commentDto->message);
 }
Esempio n. 7
0
 public function delete(Link $dto)
 {
     BOL_CommentService::getInstance()->deleteEntityComments('link', $dto->getId());
     BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'link');
     BOL_VoteService::getInstance()->deleteEntityItemVotes($dto->getId(), 'link');
     BOL_FlagService::getInstance()->deleteByTypeAndEntityId('link', $dto->getId());
     OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
     OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'link', 'entityId' => $dto->getId())));
     $this->dao->delete($dto);
 }
Esempio n. 8
0
 public function initForm()
 {
     OW::getDocument()->addOnloadScript("window.owCommentCmps['{$this->id}'] = new OwMobileComments('{$this->cmpContextId}', '{$this->formName}', '{$this->id}');");
     $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getMobileCmpViewDir() . 'comments.html');
     $this->params->setCommentCountOnPage(BOL_CommentService::getInstance()->getConfigValue(BOL_CommentService::CONFIG_MB_COMMENTS_ON_PAGE));
     if ($this->isAuthorized) {
         $this->addComponent('form', new BASE_MCMP_CommentsForm($this->params, $this->id, $this->formName));
         $this->assign('formCmp', true);
     }
     $this->addComponent('commentList', new BASE_MCMP_CommentsList($this->params, $this->id));
 }
Esempio n. 9
0
 public function addAllGroupFeed()
 {
     if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
         return;
     }
     $commentService = BOL_CommentService::getInstance();
     $newsfeedService = NEWSFEED_BOL_Service::getInstance();
     $router = OW::getRouter();
     $displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
     $location = OW::getConfig()->getValue('grouprss', 'postLocation');
     include_once 'autoloader.php';
     $allFeeds = $this->feeddao->findAll();
     foreach ($allFeeds as $feed) {
         $simplefeed = new SimplePie();
         $simplefeed->set_feed_url($feed->feedUrl);
         $simplefeed->set_stupidly_fast(true);
         $simplefeed->enable_cache(false);
         $simplefeed->init();
         $simplefeed->handle_content_type();
         $items = $simplefeed->get_items(0, $feed->feedCount);
         foreach ($items as $item) {
             $content = UTIL_HtmlTag::autoLink($item->get_content());
             if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
                 $commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
             }
             if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
                 $statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
                 $content = UTIL_HtmlTag::autoLink($content);
                 $action = new NEWSFEED_BOL_Action();
                 $action->entityId = $statusObject->id;
                 $action->entityType = "groups-status";
                 $action->pluginKey = "newsfeed";
                 $data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
                 $action->data = json_encode($data);
                 $actionObject = $newsfeedService->saveAction($action);
                 $activity = new NEWSFEED_BOL_Activity();
                 $activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
                 $activity->activityId = $feed->userId;
                 $activity->actionId = $actionObject->id;
                 $activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
                 $activity->userId = $feed->userId;
                 $activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
                 $activity->timeStamp = time();
                 $activity->data = json_encode(array());
                 $activityObject = $newsfeedService->saveActivity($activity);
                 $newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
             }
         }
         $simplefeed->__destruct();
         unset($feed);
     }
 }
Esempio n. 10
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = PostService::getInstance();
     $count = $params->customParamList['count'];
     $previewLength = $params->customParamList['previewLength'];
     $list = $service->findList(0, $count);
     if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $posts = array();
     $userService = BOL_UserService::getInstance();
     $postIdList = array();
     foreach ($list as $dto) {
         /* @var $dto Post */
         if (mb_strlen($dto->getTitle()) > 50) {
             $dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...')));
         }
         $text = $service->processPostText($dto->getPost());
         $posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())));
         $idList[] = $dto->getAuthorId();
         $postIdList[] = $dto->id;
     }
     $commentInfo = array();
     if (!empty($idList)) {
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false);
         $this->assign('avatars', $avatars);
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($idList);
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList);
         $toolbars = array();
         foreach ($list as $dto) {
             $toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
         }
         $this->assign('tbars', $toolbars);
     }
     $this->assign('commentInfo', $commentInfo);
     $this->assign('list', $posts);
     if ($service->countPosts() > 0) {
         $toolbar = array();
         if (OW::getUser()->isAuthorized('blogs', 'add')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new'));
         }
         if (OW::getUser()->isAuthorized('blogs', 'view')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs'));
         }
         if (!empty($toolbar)) {
             $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
         }
     }
 }
Esempio n. 11
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = LinkService::getInstance();
     $count = $params->customParamList['count'];
     $list = $service->findList(0, $count);
     if ((empty($list) || false && !OW::getUser()->isAuthorized('links', 'add') && !OW::getUser()->isAuthorized('links', 'view')) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $links = array();
     $toolbars = array();
     $userService = BOL_UserService::getInstance();
     $authorIdList = array();
     foreach ($list as $dto) {
         $dto->setUrl(strip_tags($dto->getUrl()));
         $dto->setTitle(strip_tags($dto->getTitle()));
         $dto->setDescription(strip_tags($dto->getDescription()));
         $links[] = array('dto' => $dto);
         $idList[] = $dto->id;
         $authorIdList[] = $dto->getUserId();
     }
     $commentInfo = array();
     $this->assign('avatars', null);
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($authorIdList, true, false);
         $this->assign('avatars', $avatars);
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($authorIdList);
     }
     $tbars = array();
     foreach ($list as $dto) {
         $tbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => !empty($urls[$dto->getUserId()]) ? $urls[$dto->getUserId()] : '#', 'label' => !empty($avatars[$dto->getUserId()]['title']) ? $avatars[$dto->getUserId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
     }
     $this->assign('tbars', $tbars);
     $this->assign('commentInfo', $commentInfo);
     $this->assign('list', $links);
     if ($service->countAll()) {
         $toolbar = array();
         if (OW::getUser()->isAuthorized('links', 'add')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('links', 'add_new'), 'href' => OW::getRouter()->urlForRoute('link-save-new'));
         }
         if (OW::getUser()->isAuthorized('links', 'view')) {
             $toolbar[] = array('label' => OW::getLanguage()->text('links', 'go_to_links'), 'href' => Ow::getRouter()->urlForRoute('links'));
         }
         if (!empty($toolbar)) {
             $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
         }
     }
 }
Esempio n. 12
0
 /**
  * @return Constructor.
  */
 public function __construct($paramObj)
 {
     parent::__construct();
     // check if comments are empty and user can't add comments
     if ((int) BOL_CommentService::getInstance()->findCommentCount('base_index_wall', 1) === 0) {
         if (!OW::getUser()->isAuthenticated()) {
             $this->setVisible(false);
         }
     }
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_index_wall');
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     $commentParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
Esempio n. 13
0
 protected function init()
 {
     if ($this->commentCount === 0 && $this->params->getDisplayType() !== BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC) {
         $this->assign('noComments', true);
     }
     if ($this->commentCount === 0) {
         $commentList = array();
     } else {
         if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST) {
             $commentList = $this->commentService->findFullCommentList($this->params->getEntityType(), $this->params->getEntityId());
         } else {
             if (in_array($this->params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST, BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC))) {
                 $commentList = empty($this->batchData['commentsList']) ? $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), 1, $this->params->getCommentCountOnPage()) : $this->batchData['commentsList'];
                 $commentList = array_reverse($commentList);
                 if ($this->commentCount > $this->params->getCommentCountOnPage()) {
                     $this->assign('viewAllLink', OW::getLanguage()->text('base', 'comment_view_all', array('count' => $this->commentCount)));
                 }
             } else {
                 $commentList = $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), $this->page, $this->params->getCommentCountOnPage());
             }
         }
     }
     OW::getEventManager()->trigger(new OW_Event('base.comment_list_prepare_data', array('list' => $commentList)));
     OW::getEventManager()->bind('base.comment_item_process', array($this, 'itemHandler'));
     $this->assign('comments', $this->processList($commentList));
     $pages = false;
     if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING) {
         $pagesCount = $this->commentService->findCommentPageCount($this->params->getEntityType(), $this->params->getEntityId(), $this->params->getCommentCountOnPage());
         if ($pagesCount > 1) {
             $pages = $this->getPages($this->page, $pagesCount, 8);
             $this->assign('pages', $pages);
         }
     } else {
         $pagesCount = 0;
     }
     static $dataInit = false;
     if (!$dataInit) {
         $staticDataArray = array('respondUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'getCommentList'), 'delUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteComment'), 'delAtchUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteCommentAtatchment'), 'delConfirmMsg' => OW::getLanguage()->text('base', 'comment_delete_confirm_message'), 'preloaderImgUrl' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl() . 'ajax_preloader_button.gif');
         OW::getDocument()->addOnloadScript("window.owCommentListCmps.staticData=" . json_encode($staticDataArray) . ";");
         $dataInit = true;
     }
     $jsParams = json_encode(array('totalCount' => $this->commentCount, 'contextId' => $this->cmpContextId, 'displayType' => $this->params->getDisplayType(), 'entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pagesCount' => $pagesCount, 'commentIds' => $this->commentIdList, 'pages' => $pages, 'pluginKey' => $this->params->getPluginKey(), 'ownerId' => $this->params->getOwnerId(), 'commentCountOnPage' => $this->params->getCommentCountOnPage(), 'cid' => $this->id, 'actionArray' => $this->actionArr));
     OW::getDocument()->addOnloadScript("window.owCommentListCmps.items['{$this->id}'] = new OwCommentsList({$jsParams});\n            window.owCommentListCmps.items['{$this->id}'].init();");
 }
Esempio n. 14
0
function vwvc_add_comment_notification(OW_Event $event)
{
    $params = $event->getParams();
    if (empty($params['entityType']) || $params['entityType'] !== 'vwvc_comments') {
        return;
    }
    $entityId = $params['entityId'];
    $userId = $params['userId'];
    $commentId = $params['commentId'];
    $clipService = VWVC_BOL_ClipService::getInstance();
    $userService = BOL_UserService::getInstance();
    $clip = $clipService->findClipById($entityId);
    if ($clip->userId != $userId) {
        $comment = BOL_CommentService::getInstance()->findComment($commentId);
        $url = OW::getRouter()->urlForRoute('vwview_clip', array('id' => $entityId));
        $event = new OW_Event('base.notify', array('plugin' => 'vwvc', 'pluginIcon' => 'ow_ic_vwvc', 'action' => 'vwvc-add_comment', 'userId' => $clip->userId, 'string' => OW::getLanguage()->text('vwvc', 'email_notifications_comment', array('userName' => $userService->getDisplayName($userId), 'userUrl' => $userService->getUserUrl($userId), 'vwvcUrl' => $url, 'vwvcTitle' => strip_tags($clip->title))), 'content' => $comment->getMessage(), 'url' => $url));
        OW::getEventManager()->trigger($event);
    }
}
Esempio n. 15
0
 public function initForm()
 {
     $jsParams = array('entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pluginKey' => $this->params->getPluginKey(), 'contextId' => $this->cmpContextId, 'userAuthorized' => $this->isAuthorized, 'customId' => $this->params->getCustomId());
     if ($this->isAuthorized) {
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.autosize.js');
         $taId = 'cta' . $this->id;
         $attchId = 'attch' . $this->id;
         $attchUid = BOL_CommentService::getInstance()->generateAttachmentUid($this->params->getEntityType(), $this->params->getEntityId());
         $jsParams['ownerId'] = $this->params->getOwnerId();
         $jsParams['cCount'] = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $jsParams['initialCount'] = $this->params->getInitialCommentsCount();
         $jsParams['loadMoreCount'] = $this->params->getLoadMoreCount();
         $jsParams['countOnPage'] = $this->params->getCommentCountOnPage();
         $jsParams['uid'] = $this->id;
         $jsParams['addUrl'] = OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment');
         $jsParams['displayType'] = $this->params->getDisplayType();
         $jsParams['textAreaId'] = $taId;
         $jsParams['attchId'] = $attchId;
         $jsParams['attchUid'] = $attchUid;
         $jsParams['enableSubmit'] = true;
         $jsParams['mediaAllowed'] = BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed();
         $jsParams['labels'] = array('emptyCommentMsg' => OW::getLanguage()->text('base', 'empty_comment_error_msg'), 'disabledSubmit' => OW::getLanguage()->text('base', 'submit_disabled_error_msg'), 'attachmentLoading' => OW::getLanguage()->text('base', 'submit_attachment_not_loaded'));
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $buttonContId = 'bCcont' . $this->id;
         if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
             $this->addComponent('attch', new BASE_CLASS_Attachment($this->params->getPluginKey(), $attchUid, $buttonContId));
         }
         $this->assign('buttonContId', $buttonContId);
         $this->assign('currentUserInfo', $userInfoToAssign);
         $this->assign('formCmp', true);
         $this->assign('taId', $taId);
         $this->assign('attchId', $attchId);
     }
     OW::getDocument()->addOnloadScript("new OwComments(" . json_encode($jsParams) . ");");
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
Esempio n. 16
0
 private function getCommentInfoForDelete()
 {
     if (!isset($_POST['commentId']) || (int) $_POST['commentId'] < 1) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'comment_ajax_error')));
         exit;
     }
     /* @var $comment BOL_Comment */
     $comment = $this->commentService->findComment((int) $_POST['commentId']);
     /* @var $commentEntity BOL_CommentEntity */
     $commentEntity = $this->commentService->findCommentEntityById($comment->getCommentEntityId());
     if ($comment === null || $commentEntity === null) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'comment_ajax_error')));
         exit;
     }
     $params = $this->getParamsObject();
     $isModerator = OW::getUser()->isAuthorized($params->getPluginKey());
     $isOwnerAuthorized = OW::getUser()->isAuthenticated() && $params->getOwnerId() !== null && (int) $params->getOwnerId() === (int) OW::getUser()->getId();
     $commentOwner = (int) OW::getUser()->getId() === (int) $comment->getUserId();
     if (!$isModerator && !$isOwnerAuthorized && !$commentOwner) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'auth_ajax_error')));
         exit;
     }
     return array('comment' => $comment, 'commentEntity' => $commentEntity);
 }
Esempio n. 17
0
 public function __construct($questionId, $userContext = null, $count = null, $options = null)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('questions');
     $count = empty($count) ? QUESTIONS_BOL_Service::MORE_DISPLAY_COUNT : $count;
     $uniqId = uniqid('question_');
     $this->assign('uniqId', $uniqId);
     $service = QUESTIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $question = $service->findQuestion($questionId);
     if (empty($question)) {
         $this->assign('noQuestion', true);
         return;
     }
     $settings = $question->getSettings();
     $isPoll = !$settings['allowAddOprions'];
     $optionTotal = $service->findOptionCount($questionId);
     $answerCount = $service->findTotalAnswersCount($questionId);
     $postCount = BOL_CommentService::getInstance()->findCommentCount('question', $questionId);
     $isAutor = $question->userId == $userId;
     if ($optionTotal - $count < 10) {
         $count = $optionTotal;
     }
     $limit = $count ? array(0, $count) : null;
     $answers = new QUESTIONS_CMP_Answers($question, $optionTotal, $limit);
     $answers->setExpandedView();
     $answers->setSettings($options);
     if (isset($options['inPopup']) && $options['inPopup'] === true) {
         $answers->setInPopupMode();
     }
     if (isset($options['loadStatic']) && $options['loadStatic'] === false) {
         $answers->setDoNotLoadStatic();
     }
     $editable = $service->isCurrentUserCanInteract($question);
     $answers->setEditable($editable && $service->isCurrentUserCanAnswer($question));
     if ($userContext !== null) {
         $answers->setUsersContext($userContext);
     }
     $answers->showAddNew();
     $this->addComponent('answers', $answers);
     $followsCount = $service->findFollowsCount($question->id, $userContext, array($question->userId));
     $statusCmp = new QUESTIONS_CMP_QuestionStatus($answers->getUniqId(), $postCount, $answerCount, $followsCount);
     $plugin = OW::getPluginManager()->getPlugin('questions');
     $statusCmp->setTemplate($plugin->getCmpViewDir() . 'question_static_status.html');
     $this->addComponent('questionStatus', $statusCmp);
     $tplQuestion = array('text' => nl2br($question->text));
     $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_QUESTION_RENDER, array("questionId" => $question->id, "questionDto" => $question, "text" => $question->text, "settings" => $settings, "uniqId" => $uniqId), $tplQuestion);
     OW::getEventManager()->trigger($event);
     $this->assign('question', $event->getData());
     $js = UTIL_JsGenerator::newInstance()->newObject('question', 'QUESTIONS_Question', array($uniqId, $question->id));
     if ($configs['allow_comments']) {
         $commentsParams = new BASE_CommentsParams('questions', QUESTIONS_BOL_Service::ENTITY_TYPE);
         $commentsParams->setEntityId($question->id);
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
         $commentsParams->setCommentCountOnPage(5);
         $commentsParams->setOwnerId($question->userId);
         $commentsParams->setAddComment($editable);
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         //$commentTemplate = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'comments.html';
         //$commentCmp->setTemplate($commentTemplate);
         $this->addComponent('comments', $commentCmp);
         if (!empty($options['focusToPost'])) {
             $js->addScript('question.focusOnPostInput()');
         }
     }
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $js->addScript('question.setAnswerList(' . $jsSelector . ');');
     if (!empty($options['relation'])) {
         $js->addScript($jsSelector . '.setRelation("' . $options['relation'] . '");');
     }
     $js->equateVarables(array('QUESTIONS_QuestionColletction', $uniqId), 'question');
     OW::getDocument()->addOnloadScript($js);
     $toolbar = array();
     if ($service->isCurrentUserCanInteract($question)) {
         if ($configs['enable_follow']) {
             $this->assign('follow', array('isFollow' => $service->isFollow($userId, $question->id), 'followId' => $answers->getUniqId() . '-follow', 'unfollowId' => $answers->getUniqId() . '-unfollow', 'followClick' => $jsSelector . '.followQuestion()', 'unfollowClick' => $jsSelector . '.unfollowQuestion()'));
             /*$followLabel = $language->text('questions', 'toolbar_follow_btn');
                             $unfollowLabel = $language->text('questions', 'toolbar_unfollow_btn');
             
                             if ( $service->isFollow($userId, $question->id) )
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }
                             else
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }*/
         }
     }
     if ($isPoll) {
         $list = $service->findUserAnswerListByQuestionId($userId, $question->id);
         if (count($list)) {
             $toolbar[] = array('label' => '<a id="' . $answers->getUniqId() . '-unvote" href="javascript://" onclick="' . $jsSelector . '.unvote()">' . $language->text('questions', 'toolbar_unvote_btn') . '</a>');
         }
     }
     if ($service->isCurrentUserCanEdit($question)) {
         $condEmbed = "confirm('" . $language->text('questions', 'delete_question_confirm') . "')";
         $toolbar[] = array('label' => '<a href="javascript://" onclick="if(' . $condEmbed . ') ' . $jsSelector . '.deleteQuestion();">' . $language->text('questions', 'toolbar_delete_btn') . '</a>');
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($question->userId));
     $questionInfo = array('avatar' => $userData[$question->userId], 'profileUrl' => $userData[$question->userId]['url'], 'displayName' => $userData[$question->userId]['title'], 'content' => '', 'toolbar' => $toolbar, 'date' => UTIL_DateTime::formatDate($question->timeStamp));
     $this->assign('questionInfo', $questionInfo);
 }
Esempio n. 18
0
 public function onComment(OW_Event $event)
 {
     $params = $event->getParams();
     if ($params['entityType'] != UHEADER_CLASS_CommentsBridge::ENTITY_TYPE) {
         return;
     }
     $userId = OW::getUser()->getId();
     $cover = UHEADER_BOL_Service::getInstance()->findCoverById($params['entityId']);
     if ($cover->userId == $userId) {
         return;
     }
     $userUrl = BOL_UserService::getInstance()->getUserUrl($cover->userId);
     $comment = BOL_CommentService::getInstance()->findComment($params['commentId']);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $avatar = $avatars[$userId];
     $previewImage = null;
     $notificationParams = array('pluginKey' => $this->plugin->getKey(), 'action' => self::ACTION_COMMENT, 'entityType' => self::TYPE_COMMENT, 'entityId' => $cover->userId, 'userId' => $cover->userId, 'time' => time());
     $users = array();
     $users[] = array('userId' => $userId, 'userName' => $avatar['title'], 'userUrl' => $avatar['url']);
     $notificationData = array('string' => array('key' => 'uheader+notifications_comment_1', 'vars' => array('user' => '<a href="' . $users[0]['userUrl'] . '">' . $users[0]['userName'] . '</a>')), 'users' => $users, 'userIds' => array($userId), 'avatar' => $avatar, 'content' => $comment->getMessage(), 'contentImage' => $previewImage, 'url' => $userUrl, "coverId" => $cover->id);
     $event = new OW_Event('notifications.add', $notificationParams, $notificationData);
     OW::getEventManager()->trigger($event);
 }
Esempio n. 19
0
 public function deleteComment($params)
 {
     if (empty($params['id']) || intval($params['id']) <= 0) {
         throw new InvalidArgumentException();
     }
     $id = (int) $params['id'];
     $isAuthorized = true;
     // TODO: Authorization needed
     if (!$isAuthorized) {
         exit;
     }
     BOL_CommentService::getInstance()->deleteComment($id);
     OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'manage_page_comment_deleted_msg'));
     $this->redirect($_GET['back-to']);
 }
Esempio n. 20
0
 public function onDeleteUserContent(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = (int) $params['userId'];
     if ($userId > 0) {
         $moderatorId = BOL_AuthorizationService::getInstance()->getModeratorIdByUserId($userId);
         if ($moderatorId !== null) {
             BOL_AuthorizationService::getInstance()->deleteModerator($moderatorId);
         }
         BOL_AuthorizationService::getInstance()->deleteUserRolesByUserId($userId);
         if (isset($params['deleteContent']) && (bool) $params['deleteContent']) {
             BOL_CommentService::getInstance()->deleteUserComments($userId);
             BOL_RateService::getInstance()->deleteUserRates($userId);
             BOL_VoteService::getInstance()->deleteUserVotes($userId);
         }
         //delete widgets
         BOL_ComponentEntityService::getInstance()->onEntityDelete(BOL_ComponentEntityService::PLACE_DASHBOARD, $userId);
         BOL_ComponentEntityService::getInstance()->onEntityDelete(BOL_ComponentEntityService::PLACE_PROFILE, $userId);
         // delete email verify
         BOL_EmailVerifyService::getInstance()->deleteByUserId($userId);
         // delete remote auth info
         BOL_RemoteAuthService::getInstance()->deleteByUserId($userId);
         // delete user auth token
         BOL_AuthTokenDao::getInstance()->deleteByUserId($userId);
     }
 }
Esempio n. 21
0
 public function loadItem()
 {
     $params = json_decode($_GET['p'], true);
     $feedData = $params['feedData'];
     $driverClass = $feedData['driver']['class'];
     /* @var $driver NEWSFEED_CLASS_Driver */
     $driver = new $driverClass();
     $driver->setup($feedData['driver']['params']);
     if (isset($params['actionId'])) {
         $action = $driver->getActionById($params['actionId']);
     } else {
         if (isset($params['entityType']) && isset($params['entityId'])) {
             $action = $driver->getAction($params['entityType'], $params['entityId']);
         } else {
             throw new InvalidArgumentException('Invalid paraeters: `entityType` and `entityId` or `actionId`');
         }
     }
     if ($action === null) {
         $this->echoError('Action not found');
     }
     $data = $feedData['data'];
     $sharedData['feedAutoId'] = $data['feedAutoId'];
     $sharedData['feedType'] = $data['feedType'];
     $sharedData['feedId'] = $data['feedId'];
     $sharedData['configs'] = OW::getConfig()->getValues('newsfeed');
     $userIdList = array($action->getUserId());
     $sharedData['usersIdList'] = $userIdList;
     $usersInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIdList);
     $sharedData['usersInfo']['avatars'][$action->getUserId()] = $usersInfo[$action->getUserId()]['src'];
     $sharedData['usersInfo']['urls'][$action->getUserId()] = $usersInfo[$action->getUserId()]['url'];
     $sharedData['usersInfo']['names'][$action->getUserId()] = $usersInfo[$action->getUserId()]['title'];
     $sharedData['usersInfo']['roleLabels'][$action->getUserId()] = array('label' => $usersInfo[$action->getUserId()]['label'], 'labelColor' => $usersInfo[$action->getUserId()]['labelColor']);
     $entityList = array();
     $entityList[] = array('entityType' => $action->getEntity()->type, 'entityId' => $action->getEntity()->id, 'pluginKey' => $action->getPluginKey(), 'userId' => $action->getUserId(), 'countOnPage' => $sharedData['configs']['comments_count']);
     $sharedData['commentsData'] = BOL_CommentService::getInstance()->findBatchCommentsData($entityList);
     $sharedData['likesData'] = NEWSFEED_BOL_Service::getInstance()->findLikesByEntityList($entityList);
     $cmp = $this->createFeedItem($action, $sharedData);
     $cmp->setDisplayType($data['displayType']);
     $html = $cmp->renderMarkup(empty($params['cycle']) ? null : $params['cycle']);
     $this->synchronizeData($data['feedAutoId'], array('data' => $data, 'driver' => $driver->getState()));
     $this->echoMarkup($html);
 }
Esempio n. 22
0
 public function onAddBlogPostComment(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['entityType']) || $params['entityType'] !== 'blog-post') {
         return;
     }
     $entityId = $params['entityId'];
     $userId = $params['userId'];
     $commentId = $params['commentId'];
     $postService = PostService::getInstance();
     $post = $postService->findById($entityId);
     if ($userId == $post->authorId) {
         return;
     }
     $actor = array('name' => BOL_UserService::getInstance()->getDisplayName($userId), 'url' => BOL_UserService::getInstance()->getUserUrl($userId));
     $comment = BOL_CommentService::getInstance()->findComment($commentId);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $event = new OW_Event('notifications.add', array('pluginKey' => 'blogs', 'entityType' => 'blogs-add_comment', 'entityId' => (int) $comment->getId(), 'action' => 'blogs-add_comment', 'userId' => $post->authorId, 'time' => time()), array('avatar' => $avatars[$userId], 'string' => array('key' => 'blogs+comment_notification_string', 'vars' => array('actor' => $actor['name'], 'actorUrl' => $actor['url'], 'title' => $post->getTitle(), 'url' => OW::getRouter()->urlForRoute('post', array('id' => $post->getId())))), 'content' => $comment->getMessage(), 'url' => OW::getRouter()->urlForRoute('post', array('id' => $post->getId()))));
     OW::getEventManager()->trigger($event);
 }
Esempio n. 23
0
 /**
  * @param OW_Event $event
  */
 public function notifyOnNewComment(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['entityType']) || $params['entityType'] !== 'photo_comments') {
         return;
     }
     $entityId = $params['entityId'];
     $userId = $params['userId'];
     $commentId = $params['commentId'];
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $userService = BOL_UserService::getInstance();
     $ownerId = $photoService->findPhotoOwner($entityId);
     if ($ownerId != $userId) {
         $params = array('pluginKey' => 'photo', 'entityType' => 'photo_add_comment', 'entityId' => $commentId, 'action' => 'photo-add_comment', 'userId' => $ownerId, 'time' => time());
         $comment = BOL_CommentService::getInstance()->findComment($commentId);
         $url = OW::getRouter()->urlForRoute('view_photo', array('id' => $entityId));
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
         $data = array('avatar' => $avatars[$userId], 'string' => array('key' => 'photo+email_notifications_comment', 'vars' => array('userName' => $userService->getDisplayName($userId), 'userUrl' => $userService->getUserUrl($userId), 'photoUrl' => $url)), 'content' => $comment->getMessage(), 'url' => $url, 'contentImage' => $photoService->getPhotoUrlByType($entityId, PHOTO_BOL_PhotoService::TYPE_SMALL));
         $event = new OW_Event('notifications.add', $params, $data);
         OW::getEventManager()->trigger($event);
     }
 }
Esempio n. 24
0
 public function index($params)
 {
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('blogs', 'view');
         throw new AuthorizationException($status['msg']);
         return;
     }
     /*
      @var $service PostService
     */
     $service = PostService::getInstance();
     /*
      @var $userService BOL_UserService
     */
     $userService = BOL_UserService::getInstance();
     /*
      @var $author BOL_User
     */
     if (!empty($params['user'])) {
         $author = $userService->findByUsername($params['user']);
     } else {
         $author = $userService->findUserById(OW::getUser()->getId());
     }
     if (empty($author)) {
         throw new Redirect404Exception();
         return;
     }
     /* Check privacy permissions */
     $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => OW::getUser()->getId());
     OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     /* */
     $displaySocialSharing = true;
     try {
         $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => 0);
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $ex) {
         $displaySocialSharing = false;
     }
     if ($displaySocialSharing && !BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser(0, 'blogs', 'view')) {
         $displaySocialSharing = false;
     }
     $this->assign('display_social_sharing', $displaySocialSharing);
     $displayName = $userService->getDisplayName($author->getId());
     $this->assign('author', $author);
     $this->assign('username', $author->getUsername());
     $this->assign('displayname', $displayName);
     $this->setPageHeading(OW::getLanguage()->text('blogs', 'user_blog_page_heading', array('name' => $author->getUsername())));
     $this->setPageHeadingIconClass('ow_ic_write');
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page');
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     if (!empty($_GET['month'])) {
         $archive_params = htmlspecialchars($_GET['month']);
         $arr = explode('-', $archive_params);
         $month = $arr[0];
         $year = $arr[1];
         $lb = mktime(null, null, null, $month, 1, $year);
         $ub = mktime(null, null, null, $month + 1, null, $year);
         $list = $service->findUserPostListByPeriod($author->getId(), $lb, $ub, $first, $count);
         $itemsCount = $service->countUserPostByPeriod($author->getId(), $lb, $ub);
         $l = OW::getLanguage();
         $arciveHeaderPart = ', ' . $l->text('base', "month_{$month}") . " {$year} " . $l->text('base', 'archive');
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_archive_title', array('month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_archive_description', array('year' => $year, 'month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName)));
     } else {
         $list = $service->findUserPostList($author->getId(), $first, $count);
         $itemsCount = $service->countUserPost($author->getId());
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_title', array('display_name' => $displayName)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_description', array('display_name' => $displayName)));
     }
     $this->assign('archiveHeaderPart', !empty($arciveHeaderPart) ? $arciveHeaderPart : '');
     $posts = array();
     $commentInfo = array();
     $idList = array();
     foreach ($list as $dto) {
         $idList[] = $dto->getId();
         $dto_post = BASE_CMP_TextFormatter::fromBBtoHtml($dto->getPost());
         $dto->setPost($dto_post);
         $parts = explode('<!--more-->', $dto->getPost());
         if (!empty($parts)) {
             $text = $parts[0];
             //$text = UTIL_HtmlTag::sanitize($text);
         } else {
             $text = $dto->getPost();
         }
         $posts[] = array('id' => $dto->getId(), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())), 'title' => UTIL_String::truncate($dto->getTitle(), 65, '...'), 'text' => $text, 'truncated' => count($parts) > 1 ? true : false);
     }
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $idList);
         $this->assign('commentInfo', $commentInfo);
         $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('blog-post', $idList);
         $this->assign('tagsInfo', $tagsInfo);
         $tb = array();
         foreach ($list as $dto) {
             $tb[$dto->getId()] = array(array('label' => UTIL_DateTime::formatDate($dto->timestamp)));
             //if ( $commentInfo[$dto->getId()] )
             //{
             $tb[$dto->getId()][] = array('href' => OW::getRouter()->urlForRoute('post', array('id' => $dto->getId())), 'label' => '<span class="ow_outline">' . $commentInfo[$dto->getId()] . '</span> ' . OW::getLanguage()->text('blogs', 'toolbar_comments'));
             //}
             if ($tagsInfo[$dto->getId()]) {
                 $tags =& $tagsInfo[$dto->getId()];
                 $t = OW::getLanguage()->text('blogs', 'tags');
                 for ($i = 0; $i < (count($tags) > 3 ? 3 : count($tags)); $i++) {
                     $t .= " <a href=\"" . OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')) . "?tag={$tags[$i]}\">{$tags[$i]}</a>" . ($i != 2 ? ',' : '');
                 }
                 $tb[$dto->getId()][] = array('label' => mb_substr($t, 0, mb_strlen($t) - 1));
             }
         }
         $this->assign('tb', $tb);
     }
     $this->assign('list', $posts);
     $info = array('lastPost' => $service->findUserLastPost($author->getId()), 'author' => $author);
     $this->assign('info', $info);
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->assign('paging', $paging->render());
     $rows = $service->findUserArchiveData($author->getId());
     $archive = array();
     foreach ($rows as $row) {
         if (!array_key_exists($row['y'], $archive)) {
             $archive[$row['y']] = array();
         }
         $archive[$row['y']][] = $row['m'];
     }
     $this->assign('archive', $archive);
     $this->assign('my_drafts_url', OW::getRouter()->urlForRoute('blog-manage-drafts'));
     if (OW::getUser()->isAuthenticated()) {
         $isOwner = $params['user'] == OW::getUser()->getUserObject()->getUsername() ? true : false;
     } else {
         $isOwner = false;
     }
     $this->assign('isOwner', $isOwner);
 }
Esempio n. 25
0
 public function removeAction($entityType, $entityId)
 {
     $dto = $this->actionDao->findAction($entityType, $entityId);
     if ($dto === null) {
         return;
     }
     $event = new OW_Event(self::EVENT_BEFORE_ACTION_DELETE, array("actionId" => $dto->id, "entityType" => $dto->entityType, "entityId" => $dto->entityId));
     OW::getEventManager()->trigger($event);
     $this->likeDao->deleteByEntity($dto->entityType, $dto->entityId);
     $this->actionDao->delete($dto);
     $activityIds = $this->activityDao->findIdListByActionIds(array($dto->id));
     $this->actionFeedDao->deleteByActivityIds($activityIds);
     $this->activityDao->deleteByIdList($activityIds);
     $commentEntity = BOL_CommentService::getInstance()->findCommentEntity($dto->entityType, $dto->entityId);
     if (!empty($commentEntity) && $commentEntity->pluginKey == 'newsfeed') {
         BOL_CommentService::getInstance()->deleteEntityComments($commentEntity->entityType, $commentEntity->entityId);
         BOL_CommentService::getInstance()->deleteCommentEntity($commentEntity->id);
     }
     $actionData = json_decode($dto->data, true);
     // delete attachments
     if (!empty($actionData['attachmentId'])) {
         BOL_AttachmentService::getInstance()->deleteAttachmentByBundle("newsfeed", $actionData['attachmentId']);
     }
 }
Esempio n. 26
0
 public function deleteExpiredClip()
 {
     $config = OW::getConfig();
     $availability = $config->getValue('vwls', 'availability');
     if ($availability != 0) {
         // get all clips
         $example = new OW_Example();
         $example->andFieldEqual('status', 'approved');
         $example->andFieldEqual('privacy', 'everybody');
         $example->setOrder('`addDatetime` DESC');
         $clips = $this->findListByExample($example);
         // if modifDatetime > $avTime, delete clip
         $avTime = $availability * 86400;
         // second
         $expTime = time() - $avTime;
         foreach ($clips as $clip) {
             if ($clip->modifDatetime < $expTime) {
                 $id = $clip->id;
                 $this->deleteById($id);
                 BOL_CommentService::getInstance()->deleteEntityComments('vwls_comments', $id);
                 BOL_RateService::getInstance()->deleteEntityRates($id, 'vwls_rates');
                 BOL_TagService::getInstance()->deleteEntityTags($id, 'vwls');
                 BOL_FlagService::getInstance()->deleteByTypeAndEntityId('vwls_clip', $id);
                 OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'vwls_comments', 'entityId' => $id)));
             }
         }
     }
 }
Esempio n. 27
0
 public function onCommentNotification(OW_Event $event)
 {
     $params = $event->getParams();
     if ($params['entityType'] != 'user-status') {
         return;
     }
     $userId = $params['userId'];
     $commentId = $params['commentId'];
     $userService = BOL_UserService::getInstance();
     $action = NEWSFEED_BOL_Service::getInstance()->findAction($params['entityType'], $params['entityId']);
     if (empty($action)) {
         return;
     }
     $actionData = json_decode($action->data, true);
     $status = empty($actionData['data']['status']) ? empty($actionData['string']) ? null : $actionData['string'] : $actionData['data']['status'];
     if (empty($actionData['data']['userId'])) {
         $cActivities = $this->service->findActivity(NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE . ':' . $action->id);
         $cActivity = reset($cActivities);
         if (empty($cActivity)) {
             return;
         }
         $ownerId = $cActivity->userId;
     } else {
         $ownerId = $actionData['data']['userId'];
     }
     $comment = BOL_CommentService::getInstance()->findComment($commentId);
     $contentImage = null;
     if (!empty($comment->attachment)) {
         $attachment = json_decode($comment->attachment, true);
         if (!empty($attachment["thumbnail_url"])) {
             $contentImage = $attachment["thumbnail_url"];
         }
         if ($attachment["type"] == "photo") {
             $contentImage = $attachment["url"];
         }
     }
     $url = OW::getRouter()->urlForRoute('newsfeed_view_item', array('actionId' => $action->id));
     if ($ownerId != $userId) {
         $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId), true, true, true, false);
         $stringKey = empty($status) ? 'newsfeed+email_notifications_empty_status_comment' : 'newsfeed+email_notifications_status_comment';
         $event = new OW_Event('notifications.add', array('pluginKey' => 'newsfeed', 'entityType' => 'status_comment', 'entityId' => $commentId, 'userId' => $ownerId, 'action' => 'newsfeed-status_comment'), array('format' => "text", 'avatar' => $avatar[$userId], 'string' => array('key' => $stringKey, 'vars' => array('userName' => $userService->getDisplayName($userId), 'userUrl' => $userService->getUserUrl($userId), 'status' => UTIL_String::truncate($status, 100, '...'), 'url' => $url)), 'content' => $comment->getMessage(), 'contentImage' => $contentImage, 'url' => $url));
         OW::getEventManager()->trigger($event);
     }
 }
 public function onItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if ($params['action']['entityType'] != QUESTIONS_BOL_Service::ENTITY_TYPE) {
         return;
     }
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('questions');
     $questionId = $params['action']['entityId'];
     $userId = OW::getUser()->getId();
     $question = $this->service->findQuestion($questionId);
     $optionTotal = $this->service->findOptionCount($questionId);
     $answerCount = $this->service->findTotalAnswersCount($questionId);
     $postCount = BOL_CommentService::getInstance()->findCommentCount(QUESTIONS_BOL_Service::ENTITY_TYPE, $params['action']['entityId']);
     $userContext = array();
     $count = QUESTIONS_BOL_Service::DISPLAY_COUNT;
     if ($optionTotal - $count < 2) {
         $count = $optionTotal;
     }
     $cmp = new QUESTIONS_CMP_Answers($question, $optionTotal, array(0, $count));
     $cmp->setTotalAnswerCount($answerCount);
     if (in_array($params['feedType'], array('user', 'my'))) {
         foreach ($params['activity'] as $act) {
             if ($act['activityType'] == 'answer') {
                 $userContext[] = $act['userId'];
             }
         }
         $cmp->setUsersContext($userContext);
     }
     $lastActivity = $this->getBubbleActivity($params);
     $data['assign']['answers'] = $cmp->render();
     $questionUrl = OW::getRouter()->urlForRoute('questions-question', array('qid' => $question->id));
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $cmp->getUniqId();
     $allowPopups = !isset($configs['allow_popups']) || $configs['allow_popups'];
     $data['assign']['string'] = $data['string'] = $this->getItemString($question, $lastActivity, $jsSelector, $questionUrl);
     $data['features'] = array();
     $onClickStr = "window.location.href='{$questionUrl}'";
     if ($configs['allow_comments']) {
         if ($allowPopups) {
             $onClickStr = "return {$jsSelector}.openQuestionDelegate(true);";
         }
         $data['features']["q-comments"] = array('class' => 'q-' . $cmp->getUniqId() . '-status-comments', 'iconClass' => 'ow_miniic_comment', 'label' => $postCount, 'onclick' => $onClickStr, 'string' => null);
     }
     if ($allowPopups) {
         $onClickStr = "return {$jsSelector}.openQuestionDelegate();";
     }
     $data['features']["q-votes"] = array('class' => 'q-' . $cmp->getUniqId() . '-status-votes', 'iconClass' => 'questions_miniicon_check', 'label' => $answerCount, 'onclick' => $onClickStr, 'string' => null);
     if ($configs['enable_follow']) {
         $onClickStr = "OW.error('" . $language->text('questions', 'follow_not_allowed') . "')";
         $isFollowing = false;
         if ($this->service->isCurrentUserCanInteract($question)) {
             $isFollowing = $this->service->isFollow($userId, $question->id);
             $onClickStr = $isFollowing ? $jsSelector . '.unfollowQuestion();' : $jsSelector . '.followQuestion();';
         } else {
             if (OW::getUser()->isAuthenticated()) {
                 $isFollowing = $this->service->isFollow($userId, $question->id);
                 if ($isFollowing) {
                     $onClickStr = $jsSelector . '.unfollowQuestion();';
                 }
             }
         }
         $data['features']["q-follows"] = array('class' => 'q-' . $cmp->getUniqId() . '-status-follows', 'iconClass' => 'questions_miniic_follow', 'label' => $this->service->findFollowsCount($question->id), 'onclick' => $onClickStr, 'active' => $isFollowing);
     }
     $settings = $question->getSettings();
     $selfContext = isset($settings['context']['type']) && $settings['context']['type'] == "user" && $settings['context']['id'] == $question->userId;
     if (!$selfContext && isset($settings['context']) && $settings['context']['type'] != $params['feedType']) {
         if (!empty($settings['context']['url']) && !empty($settings['context']['label'])) {
             $data['context'] = $settings['context'];
         }
     }
     if ($selfContext) {
         $data['context'] = null;
     }
     $event->setData($data);
 }
Esempio n. 29
0
function eventx_add_comment(OW_Event $e)
{
    $params = $e->getParams();
    if (empty($params['entityType']) || $params['entityType'] != 'eventx') {
        return;
    }
    $entityId = $params['entityId'];
    $userId = $params['userId'];
    $commentId = $params['commentId'];
    $event = EVENTX_BOL_EventService::getInstance()->findEvent($entityId);
    $comment = BOL_CommentService::getInstance()->findComment($commentId);
    $eventUrl = OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->id));
    $eventImage = null;
    if (!empty($event->image)) {
        $eventImage = EVENTX_BOL_EventService::getInstance()->generateImageUrl($event->image, true);
    }
    $string = OW::getLanguage()->text('eventx', 'feed_activity_comment_string');
    OW::getEventManager()->trigger(new OW_Event('feed.activity', array('activityType' => 'comment', 'activityId' => $commentId, 'entityId' => $entityId, 'entityType' => $params['entityType'], 'userId' => $userId, 'pluginKey' => 'eventx'), array('string' => $string, 'line' => null)));
    if ($userId != $event->userId) {
        $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId), true, true, false, false);
        $avatar = $avatars[$userId];
        $contentImage = array();
        if (!empty($eventImage)) {
            $contentImage = array('src' => $eventImage);
        }
        $event = new OW_Event('notifications.add', array('pluginKey' => 'eventx', 'entityType' => $params['entityType'], 'entityId' => $params['entityId'], 'action' => 'event-add_comment', 'userId' => $event->userId, 'time' => time()), array('avatar' => $avatar, 'string' => array('key' => 'eventx+email_notification_comment', 'vars' => array('userName' => BOL_UserService::getInstance()->getDisplayName($userId), 'userUrl' => BOL_UserService::getInstance()->getUserUrl($userId), 'url' => $eventUrl, 'title' => strip_tags($event->title))), 'url' => $eventUrl, 'contentImage' => $contentImage));
        OW::getEventManager()->trigger($event);
    }
}
Esempio n. 30
0
 public function delete(Post $dto)
 {
     BOL_CommentService::getInstance()->deleteEntityComments('blog-post', $dto->getId());
     BOL_RateService::getInstance()->deleteEntityRates($dto->getId(), 'blog-post');
     BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'blog-post');
     BOL_FlagService::getInstance()->deleteByTypeAndEntityId('blog_post', $dto->getId());
     OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
     OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $dto->getId())));
     $this->dao->delete($dto);
 }