Пример #1
0
 public function beforeContentAdd(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if (!empty($data)) {
         return;
     }
     if (empty($params["status"]) && empty($params["data"])) {
         $event->setData(false);
         return;
     }
     $attachId = null;
     $content = array();
     if (!empty($params["data"])) {
         $content = $params["data"];
         if ($content['type'] == 'photo' && !empty($content['genId'])) {
             $content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId']));
             $attachId = $content['genId'];
         }
         if ($content['type'] == 'video') {
             $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
         }
     }
     $status = UTIL_HtmlTag::autoLink($params["status"]);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $params['feedType'], $params['feedId'], $params['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     $event->setData($out);
 }
Пример #2
0
 public function __construct($entityType, $entityId, $likes = null)
 {
     parent::__construct();
     if ($likes === null) {
         $likes = NEWSFEED_BOL_Service::getInstance()->findEntityLikes($entityType, $entityId);
     }
     $this->count = count($likes);
     if ($this->count == 0) {
         $this->setVisible(false);
         return;
     }
     $userIds = array();
     foreach ($likes as $like) {
         $userIds[] = (int) $like->userId;
     }
     if ($this->count <= 3) {
         $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
         $urls = BOL_UserService::getInstance()->getUserUrlsForList($userIds);
         $langVars = array();
         foreach ($userIds as $i => $userId) {
             $langVars['user' . ($i + 1)] = '<a href="' . $urls[$userId] . '">' . $displayNames[$userId] . '</a>';
         }
         $string = OW::getLanguage()->text('newsfeed', 'feed_likes_' . $this->count . '_label', $langVars);
     } else {
         $url = "javascript: OW.showUsers(" . json_encode($userIds) . ")";
         $string = OW::getLanguage()->text('newsfeed', 'feed_likes_list_label', array('count' => $this->count, 'url' => $url));
     }
     $this->assign('string', $string);
 }
Пример #3
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);
     }
 }
Пример #4
0
 public function getActionList()
 {
     $actionList = $this->findActionList($this->params);
     if (empty($actionList)) {
         $this->count = 0;
         return array();
     }
     $this->count = $this->getActionCount();
     foreach ($actionList as $actionDto) {
         $this->actionIdList[$actionDto->entityType . ':' . $actionDto->entityId] = $actionDto->id;
     }
     $activityList = $this->findActivityList($this->params, array_values($this->actionIdList));
     $actionActivityList = array();
     foreach ($activityList as $activity) {
         $actionActivityList[$activity->actionId][$activity->id] = $activity;
     }
     $createActivityIdList = array();
     foreach ($actionList as $actionDto) {
         $aList = empty($actionActivityList[$actionDto->id]) ? array() : $actionActivityList[$actionDto->id];
         /* @var $actionDto NEWSFEED_BOL_Action */
         $action = $this->makeAction($actionDto, $aList);
         if ($action !== null) {
             $this->actionList[$actionDto->id] = $action;
             $createActivity = $action->getCreateActivity();
             if (!empty($createActivity)) {
                 $createActivityIdList[] = $createActivity->id;
             }
         }
     }
     $feedList = $this->service->findFeedListByActivityids($createActivityIdList);
     foreach ($this->actionList as $action) {
         /* @var $actionDto NEWSFEED_BOL_Action */
         $createActivity = $action->getCreateActivity();
         if (!empty($createActivity) && isset($feedList[$createActivity->id])) {
             $action->setFeedList($feedList[$createActivity->id]);
         }
     }
     return $this->actionList;
 }
Пример #5
0
    public function onCollectProfileActions(BASE_CLASS_EventCollector $event)
    {
        $params = $event->getParams();
        $userId = $params['userId'];
        if (!OW::getUser()->isAuthenticated() || OW::getUser()->getId() == $userId) {
            return;
        }
        $urlParams = array('userId' => $userId, 'backUri' => OW::getRouter()->getUri());
        $linkId = uniqid('follow');
        $isFollowing = NEWSFEED_BOL_Service::getInstance()->isFollow(OW::getUser()->getId(), 'user', $userId);
        $followUrl = OW::getRouter()->urlFor('NEWSFEED_CTRL_Feed', 'follow');
        $followUrl = OW::getRequest()->buildUrlQueryString($followUrl, $urlParams);
        $followLabel = OW::getLanguage()->text('newsfeed', 'follow_button');
        $unfollowUrl = OW::getRouter()->urlFor('NEWSFEED_CTRL_Feed', 'unFollow');
        $unfollowUrl = OW::getRequest()->buildUrlQueryString($unfollowUrl, $urlParams);
        $unfollowLabel = OW::getLanguage()->text('newsfeed', 'unfollow_button');
        $script = UTIL_JsGenerator::composeJsString('
            var isFollowing = {$isFollowing};

            $("#' . $linkId . '").click(function()
            {
                if ( !isFollowing && {$isBlocked} )
                {
                    OWM.error({$blockError});
                    return;
                }

                $.getJSON(isFollowing ? {$unfollowUrl} : {$followUrl}, function( r ) {
                    OWM.info(r.message);
                });

                isFollowing = !isFollowing;
                $(this).text(isFollowing ? {$unfollowLabel} : {$followLabel})
            });
        ', array('isFollowing' => $isFollowing, 'unfollowUrl' => $unfollowUrl, 'followUrl' => $followUrl, 'followLabel' => $followLabel, 'unfollowLabel' => $unfollowLabel, 'isBlocked' => BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId), 'blockError' => OW::getLanguage()->text('base', 'user_block_message')));
        OW::getDocument()->addOnloadScript($script);
        $resultArray = array("label" => $isFollowing ? $unfollowLabel : $followLabel, "href" => 'javascript://', "id" => $linkId);
        if (OW::getPluginManager()->isPluginActive('friends')) {
            $resultArray["group"] = "addition";
        }
        $event->add($resultArray);
    }
Пример #6
0
 public function unFollow()
 {
     $userId = (int) $_GET['userId'];
     $backUri = $_GET['backUri'];
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     if (empty($userId)) {
         throw new InvalidArgumentException('Invalid parameter `userId`');
     }
     $this->service->removeFollow(OW::getUser()->getId(), 'user', $userId);
     $backUrl = OW_URL_HOME . $backUri;
     $username = BOL_UserService::getInstance()->getDisplayName($userId);
     if (OW::getRequest()->isAjax()) {
         exit(json_encode(array('message' => OW::getLanguage()->text('newsfeed', 'unfollow_complete_message', array('username' => $username)))));
     } else {
         OW::getFeedback()->info(OW::getLanguage()->text('newsfeed', 'unfollow_complete_message', array('username' => $username)));
         $this->redirect($backUrl);
     }
 }
Пример #7
0
 public function getService($pluginKey)
 {
     switch ($pluginKey) {
         case 'newsfeed':
             return NEWSFEED_BOL_Service::getInstance();
         case 'blogs':
             return PostService::getInstance();
         case 'groups':
             return GROUPS_BOL_Service::getInstance();
         case 'event':
             return EVENT_BOL_EventService::getInstance();
         case 'links':
             return LinkService::getInstance();
         case 'video':
             return VIDEO_BOL_ClipService::getInstance();
         case 'forum':
             return FORUM_BOL_ForumService::getInstance();
         case 'photo':
             return PHOTO_BOL_PhotoService::getInstance();
     }
 }
Пример #8
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
         $this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
     }
     if (!OW::getUser()->isAuthenticated()) {
         $this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
     }
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_FILES['attachment']["tmp_name"])) {
         try {
             $attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment($_FILES['attachment']);
         } catch (InvalidArgumentException $ex) {
             $this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
         }
         $content = array("type" => "photo", "url" => $attachment["url"]);
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["genId"]));
     $this->echoOut($_POST['feedAutoId'], $out);
 }
Пример #9
0
 public function addStatus($userId, $feedType, $feedId, $visibility, $status, $data = array())
 {
     $statusDto = NEWSFEED_BOL_Service::getInstance()->saveStatus($feedType, $feedId, $status);
     $data["statusId"] = (int) $statusDto->id;
     $data["status"] = $status;
     $event = new OW_Event('feed.after_status_update', array('feedType' => $feedType, 'feedId' => $feedId, 'visibility' => (int) $visibility, 'userId' => $userId), $data);
     OW::getEventManager()->trigger($event);
     return array('entityType' => $feedType . '-status', 'entityId' => $statusDto->id);
 }
Пример #10
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);
 }
Пример #11
0
    public function onCollectProfileActions(BASE_CLASS_EventCollector $event)
    {
        $params = $event->getParams();
        $userId = $params['userId'];
        if (!OW::getUser()->isAuthenticated() || OW::getUser()->getId() == $userId) {
            return;
        }
        $urlParams = array('userId' => $userId, 'backUri' => OW::getRouter()->getUri());
        $linkId = 'follow' . rand(10, 1000000);
        $isFollowing = NEWSFEED_BOL_Service::getInstance()->isFollow(OW::getUser()->getId(), 'user', $userId);
        $followUrl = OW::getRouter()->urlFor('NEWSFEED_CTRL_Feed', 'follow');
        $followUrl = OW::getRequest()->buildUrlQueryString($followUrl, $urlParams);
        $followLabel = OW::getLanguage()->text('newsfeed', 'follow_button');
        $unfollowUrl = OW::getRouter()->urlFor('NEWSFEED_CTRL_Feed', 'unFollow');
        $unfollowUrl = OW::getRequest()->buildUrlQueryString($unfollowUrl, $urlParams);
        $unfollowLabel = OW::getLanguage()->text('newsfeed', 'unfollow_button');
        $script = UTIL_JsGenerator::composeJsString('
            var isFollowing = {$isFollowing};

            $("#' . $linkId . '").click(function()
            {
                if ( !isFollowing && {$isBlocked} )
                {
                    OW.error({$blockError});
                    return;
                }

                $.getJSON(isFollowing ? {$unfollowUrl} : {$followUrl}, function( r ) {
                    OW.info(r.message);
                });

                isFollowing = !isFollowing;
                $(this).text(isFollowing ? {$unfollowLabel} : {$followLabel})
            });

        ', array('isFollowing' => $isFollowing, 'unfollowUrl' => $unfollowUrl, 'followUrl' => $followUrl, 'followLabel' => $followLabel, 'unfollowLabel' => $unfollowLabel, 'isBlocked' => BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId), 'blockError' => OW::getLanguage()->text('base', 'user_block_message')));
        OW::getDocument()->addOnloadScript($script);
        $event->add(array(BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL => $isFollowing ? $unfollowLabel : $followLabel, BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF => 'javascript://', BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID => $linkId, BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY => "newsfeed.follow"));
    }
Пример #12
0
 public function getTplData($cycle = null)
 {
     $action = $this->action;
     $data = $this->getActionData($action);
     $usersInfo = $this->sharedData['usersInfo'];
     $configs = $this->sharedData['configs'];
     $userNameEmbed = '<a href="' . $usersInfo['urls'][$action->getUserId()] . '"><b>' . $usersInfo['names'][$action->getUserId()] . '</b></a>';
     $assigns = empty($data['assign']) ? array() : $data['assign'];
     $replaces = array_merge(array('user' => $userNameEmbed), $assigns);
     $data['content'] = $this->renderContent($data['content']);
     foreach ($assigns as &$item) {
         $item = $this->renderContent($item);
     }
     $permalink = empty($data['permalink']) ? NEWSFEED_BOL_Service::getInstance()->getActionPermalink($action->getId(), $this->sharedData['feedType'], $this->sharedData['feedId']) : null;
     $string = $this->getLocalizedText($data['string']);
     $line = $this->getLocalizedText($data['line']);
     $creatorsInfo = $this->getActionUsersInfo($data);
     $item = array('id' => $action->getId(), 'view' => $data['view'], 'toolbar' => $data['toolbar'], 'string' => $this->processAssigns($string, $assigns), 'line' => $this->processAssigns($line, $assigns), 'content' => $this->processAssigns($data['content'], $assigns), 'context' => $data['context'], 'entityType' => $data['action']['entityType'], 'entityId' => $data['action']['entityId'], 'createTime' => UTIL_DateTime::formatDate($data['action']['createTime']), 'updateTime' => $action->getUpdateTime(), "user" => reset($creatorsInfo), 'users' => $creatorsInfo, 'permalink' => $permalink, 'cycle' => $cycle);
     $item['autoId'] = $this->autoId;
     $item['features'] = $this->getFeatures($data);
     $item['contextActionMenu'] = $this->getContextMenu($data);
     return $item;
 }
Пример #13
0
 public function findExpiredIdList($inactivePeriod, $count = null)
 {
     $activityDao = NEWSFEED_BOL_ActivityDao::getInstance();
     $systemActivities = NEWSFEED_BOL_Service::getInstance()->SYSTEM_ACTIVITIES;
     $limit = '';
     if (!empty($count)) {
         $limit = ' LIMIT ' . $count;
     }
     $query = 'SELECT DISTINCT cactivity.actionId FROM ' . $activityDao->getTableName() . ' cactivity
         LEFT JOIN ' . $activityDao->getTableName() . ' activity
                 ON cactivity.actionId=activity.actionId AND activity.activityType NOT IN ("' . implode('", "', $systemActivities) . '")
             WHERE activity.id IS NULL AND cactivity.activityType=:c AND cactivity.timeStamp < :ts' . $limit;
     return $this->dbo->queryForColumnList($query, array('c' => NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE, 'ts' => time() - $inactivePeriod));
 }
Пример #14
0
 public function __construct()
 {
     $this->service = NEWSFEED_BOL_Service::getInstance();
     $this->defaultParams = array('offset' => 0, 'length' => false, 'displayCount' => 20, "formats" => null);
 }
Пример #15
0
 public function deleteExpired()
 {
     $this->service->markExpiredForDelete();
 }
Пример #16
0
 private function __construct()
 {
     $this->service = NEWSFEED_BOL_Service::getInstance();
 }
Пример #17
0
 public function findFeedActivity($feedType, $feedId, $actionIds)
 {
     $actionFeedDao = NEWSFEED_BOL_ActionFeedDao::getInstance();
     $unionQueryList = array();
     $queryParts = BOL_UserDao::getInstance()->getUserQueryFilter("activity", "userId", array("method" => "NEWSFEED_BOL_ActivityDao::findFeedActivity"));
     $unionQueryList[] = 'SELECT activity.* FROM ' . $this->getTableName() . ' activity
         WHERE activity.actionId IN(' . implode(', ', $actionIds) . ') AND activity.status=:s 
         AND activity.privacy=:peb AND activity.visibility & :v
         AND activity.activityType IN ("' . implode('", "', NEWSFEED_BOL_Service::getInstance()->SYSTEM_ACTIVITIES) . '")';
     foreach ($actionIds as $actionId) {
         $unionQueryList[] = 'SELECT a.* FROM ( SELECT DISTINCT activity.* FROM ' . $this->getTableName() . ' activity
             ' . $queryParts["join"] . '
             INNER JOIN ' . $actionFeedDao->getTableName() . ' action_feed ON activity.id=action_feed.activityId
             WHERE ' . $queryParts["where"] . ' AND activity.actionId = ' . $actionId . ' AND
                 (
                     activity.status=:s
                     AND activity.privacy=:peb
                     AND action_feed.feedType=:ft
                     AND action_feed.feedId=:fi
                     AND activity.visibility & :v
                     OR
                     activity.activityType=:ac
                 )
             ORDER BY activity.timeStamp DESC, activity.id DESC LIMIT 100 ) a';
     }
     $query = implode(' UNION ', $unionQueryList) . " ORDER BY 7 DESC, 1 DESC ";
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), array('ft' => $feedType, 'fi' => $feedId, 's' => NEWSFEED_BOL_Service::ACTION_STATUS_ACTIVE, 'v' => NEWSFEED_BOL_Service::VISIBILITY_FEED, 'peb' => NEWSFEED_BOL_Service::PRIVACY_EVERYBODY, 'ac' => NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE));
 }
Пример #18
0
 public function getTplData($cycle = null)
 {
     $action = $this->action;
     $data = $this->getActionData($action);
     $permalink = empty($data['permalink']) ? NEWSFEED_BOL_Service::getInstance()->getActionPermalink($action->getId(), $this->sharedData['feedType'], $this->sharedData['feedId']) : $data['permalink'];
     $this->itemPermalink = $permalink;
     $userId = (int) $data['action']['userId'];
     $content = null;
     if (is_array($data["content"]) && !empty($data["content"]["format"])) {
         $vars = empty($data["content"]["vars"]) ? array() : $data["content"]["vars"];
         $content = $this->renderFormat($data["content"]["format"], $vars);
     }
     $respond = empty($data["respond"]) ? array() : $data["respond"];
     $creatorsInfo = $this->getActionUsersInfo($data);
     $desktopUrl = $permalink;
     if (strpos($permalink, OW_URL_HOME) === 0) {
         $permalinkUri = str_replace(OW_URL_HOME, "", $permalink);
         $desktopUrl = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute("base.desktop_version"), array("back-uri" => urlencode($permalinkUri)));
     }
     $item = array('id' => $action->getId(), 'view' => $data['view'], 'toolbar' => $data['toolbar'], 'string' => $this->getLocalizedText($data['string']), 'line' => $this->getLocalizedText($data['line']), 'content' => $content, 'context' => $data['context'], 'entityType' => $data['action']['entityType'], 'entityId' => $data['action']['entityId'], 'createTime' => UTIL_DateTime::formatDate($data['action']['createTime']), 'updateTime' => $action->getUpdateTime(), 'respond' => $respond, "responded" => !empty($respond), "user" => reset($creatorsInfo), 'users' => $creatorsInfo, 'permalink' => $permalink, 'cycle' => $cycle, "disabled" => !empty($data["disabled"]) && $data["disabled"], "desktopUrl" => $desktopUrl);
     $item['autoId'] = $this->autoId;
     $item['features'] = $this->getFeatures($data);
     $item['contextActionMenu'] = $this->getContextMenu($data);
     return $item;
 }
Пример #19
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
         $this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
     }
     if (!OW::getUser()->isAuthenticated()) {
         $this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
     }
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_FILES['attachment']["tmp_name"])) {
         try {
             $attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment("newsfeed", $_FILES['attachment']);
         } catch (InvalidArgumentException $ex) {
             $this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
         }
         $content = array("type" => "photo", "url" => $attachment["url"]);
     }
     $userId = OW::getUser()->getId();
     $event = new OW_Event("feed.before_content_add", array("feedType" => $_POST['feedType'], "feedId" => $_POST['feedId'], "visibility" => $_POST['visibility'], "userId" => $userId, "status" => $status, "type" => empty($content["type"]) ? "text" : $content["type"], "data" => $content));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!empty($data)) {
         $item = empty($data["entityType"]) || empty($data["entityId"]) ? null : array("entityType" => $data["entityType"], "entityId" => $data["entityId"]);
         $this->echoOut($_POST['feedAutoId'], array("item" => $item, "message" => empty($data["message"]) ? null : $data["message"], "error" => empty($data["error"]) ? null : $data["error"]));
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["uid"]));
     $this->echoOut($_POST['feedAutoId'], array("item" => $out));
 }