/** * Controller */ public function process() { $aUser = PHPFOX_IS_AJAX ? Phpfox::getService('user')->get(Phpfox::getUserId(), true) : $this->getParam('aUser'); if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'friend.view_friend')) { return false; } $iTotal = (int) Phpfox::getComponentSetting($aUser['user_id'], 'friend.friend_display_limit_profile', Phpfox::getParam('friend.friend_display_limit')); $aRows = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . $aUser['user_id'], 'friend.is_top_friend DESC, friend.ordering ASC, RAND()', 0, $iTotal, false); $iCount = count($aRows); if (!$iCount) { return false; } $sFriendsLink = Phpfox::getService('user')->getLink($aUser['user_id'], $aUser['user_name'], 'friend'); $this->template()->assign(array('sHeader' => '<a href="' . $this->url()->makeUrl($aUser['user_name'], 'friend') . '">' . Phpfox::getPhrase('friend.friends') . '<span>' . $aUser['total_friend'] . '</span></a>', 'aFriends' => $aRows, 'sFriendsLink' => $sFriendsLink, 'sBlockJsId' => 'profile_friend')); /* if (Phpfox::getUserParam('friend.can_remove_friends_from_profile') && $aUser['user_id'] == Phpfox::getUserId()) { $this->template()->assign(array( 'aEditBar' => array( 'ajax_call' => 'friend.getEditBar', 'params' => '&type_id=profile' ) ) ); $this->template()->assign('sDeleteBlock', 'profile'); } */ return 'block'; }
public function getRecentLoggedInUsers() { $iFriendsOnly = (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'log.user_login_display_limit', 0); $iLimit = 10; if ($iFriendsOnly === 1) { $aUsers = $this->database()->select(Phpfox::getUserField()) ->from(Phpfox::getT('friend'), 'f') ->join(Phpfox::getT('user'), 'u', 'u.user_id = f.friend_user_id') ->where('f.user_id = ' . Phpfox::getUserId() . ' AND is_invisible != 1') ->order('u.last_login DESC') ->limit($iLimit) ->execute('getSlaveRows'); } else { $aUsers = $this->database()->select(Phpfox::getUserField()) ->from(Phpfox::getT('user'), 'u') ->order('u.last_login DESC') ->where('u.user_id != ' . Phpfox::getUserId() .' AND is_invisible != 1 AND u.status_id = 0 AND u.view_id = 0') ->limit($iLimit) ->execute('getSlaveRows'); } return $aUsers; }
/** * Controller */ public function process() { if (!defined('PHPFOX_IS_USER_PROFILE') && !Phpfox::isUser()) { return false; } $aUser = $this->getParam('aUser'); $iTotal = (int) Phpfox::getComponentSetting(defined('PHPFOX_IS_USER_PROFILE') ? $aUser['user_id'] : Phpfox::getUserId(), 'friend.friend_display_limit_profile', Phpfox::getParam('friend.friend_display_limit')); $aTopFriends = Friend_Service_Friend::instance()->getTop(defined('PHPFOX_IS_USER_PROFILE') ? $aUser['user_id'] : Phpfox::getUserId(), $iTotal); $iCount = count($aTopFriends); if (defined('PHPFOX_IS_USER_PROFILE') && !$iCount) { return false; } $this->template()->assign(array('aTopFriends' => $aTopFriends)); if (defined('PHPFOX_IS_USER_PROFILE')) { $this->template()->assign(array('bMoveCursor' => false)); } else { $this->template()->assign(array('bMoveCursor' => true)); } if (!$this->getParam('bIsAjax')) { $this->template()->assign(array('sHeader' => Phpfox::getPhrase('friend.top_friends'), 'sBlockJsId' => 'top_friends')); $bCanEditSettings = false; if (defined('PHPFOX_IS_USER_PROFILE')) { if ($aUser['user_id'] == Phpfox::getUserId()) { // $bCanEditSettings = true; } $bCanEditSettings = false; } else { $bCanEditSettings = true; } if ($bCanEditSettings) { $this->template()->assign(array('aEditBar' => array('ajax_call' => 'friend.getEditBar', 'params' => '&type_id=profile&no_delete_link=true&is_edit_top=true'))); } return 'block'; } }
/** * Class process method wnich is used to execute this component. */ public function process() { Phpfox::isUser(true); if (($aVals = $this->request()->getArray('val')) && !empty($aVals['status'])) { if ($iId = Phpfox::getService('user.process')->updateStatus(Phpfox::getUserId(), $aVals['status'])) { $this->url()->send(''); } } $iFeedPage = $this->request()->get('page', 1); if (Phpfox::isModule('feed')) { $aFeeds = Phpfox::getService('feed')->get(null, null, $iFeedPage); $iTotalFeeds = (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'feed.feed_display_limit_dashboard', Phpfox::getParam('feed.feed_display_limit')); $this->url()->setParam(array('core', 'index-member')); // Phpfox::getLib('pager')->set(array('page' => $iFeedPage, 'size' => $iTotalFeeds, 'count' => $iFeedCount)); $this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('bMobileHomeIsActive' => true, 'aFeeds' => $aFeeds)); } }
public function getRecentLoggedInUsers() { if (Phpfox::getParam('user.cache_recent_logged_in') > 0) { $sCacheId = $this->cache()->set(array('user', 'recentloggedin')); } if (Phpfox::getParam('user.cache_recent_logged_in') > 0 && ($aUsers = $this->cache()->get($sCacheId, Phpfox::getParam('user.cache_recent_logged_in')))) { } else { $iFriendsOnly = (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'log.user_login_display_limit', 0); $iLimit = 10; ($sPlugin = Phpfox_Plugin::get('log.service_log_getrecentloggedinusers_1')) ? eval($sPlugin) : false; if ($iFriendsOnly === 1) { $aUsers = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('friend'), 'f')->join(Phpfox::getT('user'), 'u', 'u.user_id = f.friend_user_id')->where('f.user_id = ' . Phpfox::getUserId() . ' AND is_invisible != 1')->order('u.last_login DESC')->limit($iLimit)->execute('getSlaveRows'); } else { $aUsers = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->order('u.last_login DESC')->where('u.user_id != ' . Phpfox::getUserId() . ' AND is_invisible != 1 AND u.status_id = 0 AND u.view_id = 0')->limit($iLimit)->execute('getSlaveRows'); } if (Phpfox::getParam('user.cache_recent_logged_in') > 0) { $this->cache()->save($sCacheId, $aUsers); } } if (is_bool($aUsers)) { $aUsers = array(); } return $aUsers; }
/** * Controller */ public function process() { $aUser = Phpfox::getService('user')->get($this->request()->get('req1'), false); if (!isset($aUser['user_id'])) { return Phpfox_Module::instance()->setController('error.404'); } define('PHPFOX_IS_USER_PROFILE', true); $sImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true, $aUser)), array('title' => $aUser['full_name'], 'path' => 'core.url_user', 'file' => $aUser['user_image'], 'suffix' => '_120', 'max_width' => 120, 'max_height' => 120, 'no_default' => Phpfox::getUserId() == $aUser['user_id'] ? false : true, 'no_link' => true))); $oUser = Phpfox::getService('user'); $aUser['gender_name'] = $oUser->gender($aUser['gender']); $aUser['birthday_time_stamp'] = $aUser['birthday']; $aUser['birthday'] = $oUser->age($aUser['birthday']); $aUser['location'] = Phpfox::getPhraseT(Phpfox::getService('core.country')->getCountry($aUser['country_iso']), 'country'); if (isset($aUser['country_child_id']) && $aUser['country_child_id'] > 0) { $aUser['location_child'] = Phpfox::getService('core.country')->getChild($aUser['country_child_id']); } $this->setParam('aUser', $aUser); $this->template()->setMobileHeader(array('profile.css' => 'style_css')); if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'profile.view_profile')) { return Phpfox_Module::instance()->setController('profile.private'); } Phpfox::getUserParam('profile.can_view_users_profile', true); $aProfileMenu = array($this->url()->makeUrl($aUser['user_name']) => Phpfox::getPhrase('profile.wall')); if (Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'profile.basic_info')) { $aProfileMenu[$this->url()->makeUrl($aUser['user_name'], 'info')] = Phpfox::getPhrase('profile.info'); } $this->template()->assign(array('aUser' => $aUser, 'sProfileImage' => $sImage, 'bMobileProfileIsActive' => true, 'aMobileSubMenus' => $aProfileMenu, 'sActiveMobileSubMenu' => $this->url()->makeUrl($aUser['user_name'], $this->request()->get('req2') == '' ? null : $this->request()->get('req2')))); if ($this->request()->get('req2') == 'info') { return Phpfox_Module::instance()->setController('profile.info-mobile'); } if ($aVals = $this->request()->getArray('val')) { Phpfox::isUser(true); if (isset($aVals['status'])) { if (!empty($aVals['status'])) { if ($iId = Phpfox::getService('user.process')->updateStatus(Phpfox::getUserId(), $aVals['status'])) { $this->url()->send($aUser['user_name']); } } } else { Phpfox::getUserParam('comment.can_post_comments', true); if (!Phpfox::getService('user.privacy')->hasAccess($aVals['item_id'], 'comment.add_comment')) { Phpfox_Error::set(Phpfox::getPhrase('feed.you_do_not_have_permission_to_add_a_comment_on_this_persons_profile')); } if (($iFlood = Phpfox::getUserParam('comment.comment_post_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('feed'), 'condition' => 'type_id = \'comment_profile_my\' AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('feed.posting_a_comment_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox::getLib('parse.format')->isEmpty($aVals['feed_text'])) { Phpfox_Error::set(Phpfox::getPhrase('feed.add_some_text_to_your_comment')); } if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('feed.process')->addComment($aVals))) { $this->url()->send($aUser['user_name']); } } } $bHideFeedOnProfile = false; if (Phpfox::isModule('feed')) { $iFeedPage = $this->request()->get('page', 1); list($iFeedCount, $aFeeds) = Feed_Service_Feed::instance()->get($aUser['user_id'], null, $iFeedPage); if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'feed.display_on_profile')) { $iFeedCount = 0; $aFeeds = array(); $bHideFeedOnProfile = true; } $iTotalFeeds = (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'feed.feed_display_limit_dashboard', Phpfox::getParam('feed.feed_display_limit')); Phpfox_Pager::instance()->set(array('page' => $iFeedPage, 'size' => $iTotalFeeds, 'count' => $iFeedCount)); $this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('aFeeds' => $aFeeds)); } $this->template()->assign(array('bHideFeedOnProfile' => $bHideFeedOnProfile)); }
public function get($iUserid = null, $iFeedId = null, $iPage = 0, $bForceReturn = false) { $params = []; if (is_array($iUserid)) { $params = $iUserid; $iUserid = null; if (isset($params['id'])) { $iFeedId = $params['id']; } if (isset($params['page'])) { $iPage = $params['page']; } } $oUrl = Phpfox_Url::instance(); $oReq = Phpfox_Request::instance(); $oParseOutput = Phpfox::getLib('parse.output'); $bIsCheckForUpdate = defined('PHPFOX_CHECK_FOR_UPDATE_FEED') ? 1 : 0; $iLastFeedId = defined('PHPFOX_CHECK_FOR_UPDATE_FEED_ID') ? PHPFOX_CHECK_FOR_UPDATE_FEED_ID : 0; if ($oReq->get('get-new')) { // $bForceReturn = true; } if ($iCommentId = $oReq->getInt('comment-id')) { if (isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'' . $this->_aCallback['feed_comment'] . '\' AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']); } else { $aCustomCondition = array('feed.type_id IN(\'feed_comment\', \'feed_egift\') AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $iUserid); } $iFeedId = true; } elseif ($iStatusId = $oReq->getInt('status-id')) { $aCustomCondition = array('feed.type_id = \'user_status\' AND feed.item_id = ' . (int) $iStatusId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iLinkId = $oReq->getInt('link-id')) { $aCustomCondition = array('feed.type_id = \'link\' AND feed.item_id = ' . (int) $iLinkId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iLinkId = $oReq->getInt('plink-id')) { $aCustomCondition = array('feed.type_id = \'link\' AND feed.item_id = ' . (int) $iLinkId . ' AND feed.parent_user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iPokeId = $oReq->getInt('poke-id')) { $aCustomCondition = array('feed.type_id = \'poke\' AND feed.item_id = ' . (int) $iPokeId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } $iTotalFeeds = (int) Phpfox::getComponentSetting($iUserid === null ? Phpfox::getUserId() : $iUserid, 'feed.feed_display_limit_' . ($iUserid !== null ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')); if (isset($params['limit'])) { $iTotalFeeds = $params['limit']; } $iOffset = $iPage * $iTotalFeeds; $extra = ''; ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_start')) ? eval($sPlugin) : false; if (isset($params['type_id'])) { $extra .= ' AND type_id ' . (is_array($params['type_id']) ? 'IN(' . implode(',', array_map(function ($value) { return "'{$value}'"; }, $params['type_id'])) . ')' : '= \'' . $params['type_id'] . '\'') . ''; // d($extra); exit; } $sOrder = 'feed.time_update DESC'; if (Phpfox::getUserBy('feed_sort') || defined('PHPFOX_IS_USER_PROFILE')) { $sOrder = 'feed.time_stamp DESC'; } $aCond = array(); if (isset($this->_aCallback['module'])) { $aNewCond = array(); if ($iCommentId = $oReq->getInt('comment-id')) { if (!isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'' . $this->_aCallback['module'] . '_comment\' AND feed.item_id = ' . (int) $iCommentId . ''); } } $aNewCond[] = 'AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']; if ($iUserid !== null && $iFeedId !== null) { $aNewCond[] = 'AND feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid; } if ($iUserid === null && $iFeedId !== null) { $aNewCond = []; $aNewCond[] = 'AND feed.feed_id = ' . (int) $iFeedId; } $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from(Phpfox::getT($this->_aCallback['table_prefix'] . 'feed'), 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where(isset($aCustomCondition) ? $aCustomCondition : $aNewCond)->order($sOrder)->limit($iOffset, $iTotalFeeds, null, false, true)->execute('getSlaveRows'); // Fixes missing page_user_id, required to create the proper feed target if ($this->_aCallback['module'] == 'pages') { foreach ($aRows as $iKey => $aValue) { $aRows[$iKey]['page_user_id'] = $iUserid; } } } elseif ($sIds = $oReq->get('ids')) { $aParts = explode(',', $oReq->get('ids')); $sNewIds = ''; foreach ($aParts as $sPart) { $sNewIds .= (int) $sPart . ','; } $sNewIds = rtrim($sNewIds, ','); $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where('feed.feed_id IN(' . $sNewIds . ')')->order('feed.time_stamp DESC')->execute('getSlaveRows'); } elseif ($iUserid === null && $iFeedId !== null) { $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where('feed.feed_id = ' . (int) $iFeedId)->order('feed.time_stamp DESC')->execute('getSlaveRows'); } elseif ($iUserid !== null && $iFeedId !== null) { $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where(isset($aCustomCondition) ? $aCustomCondition : 'feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid . '')->order('feed.time_stamp DESC')->limit(1)->execute('getSlaveRows'); } elseif ($iUserid !== null) { if ($iUserid == Phpfox::getUserId()) { $aCond[] = 'AND feed.privacy IN(0,1,2,3,4)'; } else { if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend) { $aCond[] = 'AND feed.privacy IN(0,1,2)'; } else { if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend_of_friend) { $aCond[] = 'AND feed.privacy IN(0,2)'; } else { $aCond[] = 'AND feed.privacy IN(0)'; } } } // There is no reciprocal feed when you add someone as friend $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.type_id = \'friend\' AND feed.user_id = ' . (int) $iUserid)->union(); ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_userprofile')) ? eval($sPlugin) : ''; $iTimelineYear = 0; if (($iTimelineYear = Phpfox_Request::instance()->get('year')) && !empty($iTimelineYear)) { $iMonth = 12; $iDay = 31; if (($iTimelineMonth = Phpfox_Request::instance()->get('month')) && !empty($iTimelineMonth)) { $iMonth = $iTimelineMonth; $iDay = Phpfox::getLib('date')->lastDayOfMonth($iMonth, $iTimelineYear); } $aCond[] = 'AND feed.time_stamp <= \'' . mktime(0, 0, 0, $iMonth, $iDay, $iTimelineYear) . '\''; } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND type_id = \'feed_comment\' AND feed.user_id = ' . (int) $iUserid . '')))->union(); $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND feed.user_id = ' . (int) $iUserid . ' AND feed.feed_reference = 0 AND feed.parent_user_id = 0')))->union(); if (Phpfox::isUser()) { if (Phpfox::isModule('privacy')) { $this->database()->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id')->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . ''); } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(4) AND feed.user_id = ' . (int) $iUserid . ' AND feed.feed_reference = 0')->union(); } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND feed.parent_user_id = ' . (int) $iUserid)))->union(); $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField())->unionFrom('feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->order('feed.time_stamp DESC')->group('feed.feed_id')->limit($iOffset, $iTotalFeeds, null, false, true)->execute('getSlaveRows'); } else { // Users must be active within 7 days or we skip their activity feed $iLastActiveTimeStamp = (int) Phpfox::getParam('feed.feed_limit_days') <= 0 ? 0 : PHPFOX_TIME - 86400 * Phpfox::getParam('feed.feed_limit_days'); if (Phpfox::isModule('privacy') && Phpfox::getUserParam('privacy.can_view_all_items') && $oReq->get('view-all')) { $this->_hashSearch(); $sSelect = 'feed.*, ' . Phpfox::getUserField(); if (Phpfox::isModule('friend')) { $sSelect .= ', f.friend_id AS is_friend'; $this->database()->leftJoin(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()); } $sWhere = 'feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' ' . $extra . ' AND feed.feed_reference = 0'; if ($bIsCheckForUpdate) { $sWhere .= ' AND feed.feed_id>' . intval($iLastFeedId); } $aRows = $this->database()->select($sSelect)->from(Phpfox::getT('feed'), 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->order($sOrder)->group('feed.feed_id')->limit($iOffset, $iTotalFeeds)->where($sWhere)->execute('getSlaveRows'); } else { if (Phpfox::getParam('feed.feed_only_friends') && !isset($params['is_api']) && $oReq->segment(1) != 'hashtag') { if (Phpfox::isModule('friend')) { // Get my friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId())->where('feed.privacy IN(0,1,2) ' . $extra . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); // Get my feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(0,1,2,3,4) ' . $extra . ' AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); } } else { $sMyFeeds = '1,2,3,4'; ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_buildquery')) ? eval($sPlugin) : ''; if (Phpfox::isModule('friend')) { // Get my friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId())->where('feed.privacy IN(1,2) ' . $extra . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->limit($iTotalFeeds)->union(); // Get my friends of friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f1', 'f1.user_id = feed.user_id')->join(Phpfox::getT('friend'), 'f2', 'f2.user_id = ' . Phpfox::getUserId() . ' AND f2.friend_user_id = f1.friend_user_id')->where('feed.privacy IN(2) ' . $extra . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->limit($iTotalFeeds)->union(); } // Get my feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(' . $sMyFeeds . ') ' . $extra . ' AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); // Get public feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(0) ' . $extra . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); if (Phpfox::isModule('privacy')) { $this->database()->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id')->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . ''); } // Get feeds based on custom friends lists $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(4) ' . $extra . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); } $this->_hashSearch(); $sSelect = 'feed.*, u.view_id, ' . Phpfox::getUserField(); if (Phpfox::isModule('friend')) { $sSelect .= ', f.friend_id AS is_friend'; $this->database()->leftJoin(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()); } $sWhere = ' 1 '; if ($bIsCheckForUpdate) { $sWhere .= ' AND feed.feed_id > ' . intval($iLastFeedId); } $aRows = $this->database()->select($sSelect)->unionFrom('feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where($sWhere)->order($sOrder)->group('feed.feed_id')->limit($iOffset, $iTotalFeeds, null, false, true)->execute('getSlaveRows'); } } if ($bForceReturn === true) { return $aRows; } $bFirstCheckOnComments = false; if (Phpfox::getParam('feed.allow_comments_on_feeds') && Phpfox::isUser() && Phpfox::isModule('comment')) { $bFirstCheckOnComments = true; } $aFeeds = array(); $aParentFeeds = array(); foreach ($aRows as $sKey => $aRow) { $aRow['feed_time_stamp'] = $aRow['time_stamp']; if ($aReturn = $this->_processFeed($aRow, $sKey, $iUserid, $bFirstCheckOnComments)) { if (isset($aReturn['force_user'])) { $aReturn['user_name'] = $aReturn['force_user']['user_name']; $aReturn['full_name'] = $aReturn['force_user']['full_name']; $aReturn['user_image'] = $aReturn['force_user']['user_image']; $aReturn['server_id'] = $aReturn['force_user']['server_id']; } $aReturn['feed_month_year'] = date('m_Y', $aRow['feed_time_stamp']); $aReturn['feed_time_stamp'] = $aRow['feed_time_stamp']; /* Lets figure out the phrases for like.display right here */ //if (Phpfox::getParam('like.allow_dislike')) if (Phpfox::isModule('like')) { $this->getPhraseForLikes($aReturn); } if (Phpfox::getParam('feed.cache_each_feed_entry') && !empty($aReturn['like_type_id']) && Phpfox::isUser() && isset($aReturn['likes']) && count($aReturn['likes'])) { $iUserLiked = isset($aReturn['likes_history'][Phpfox::getUserId()]) ? true : false; $aReturn['feed_is_liked'] = $iUserLiked; $aReturn['is_liked'] = $iUserLiked; } if (Phpfox::getParam('feed.cache_each_feed_entry') && isset($aReturn['comments']) && count($aReturn['comments'])) { foreach ($aReturn['comments'] as $iCommentKey => $aCommentValue) { $aReturn['comments'][$iCommentKey]['is_liked'] = isset($aCommentValue['liked_history'][Phpfox::getUserId()]) ? true : false; } } $aFeeds[] = $aReturn; } // Show the feed properly. If user A posted on page 1, then feed will say "user A > page 1 posted ..." if (isset($this->_aCallback['module']) && $this->_aCallback['module'] == 'pages') { // If defined parent user, and the parent user is not the same page (logged in as a page) if (isset($aRow['page_user_id']) && $aReturn['page_user_id'] != $aReturn['user_id']) { $aParentFeeds[$aReturn['feed_id']] = $aRow['page_user_id']; } } elseif (isset($this->_aCallback['module']) && $this->_aCallback['module'] == 'event') { // Keep it empty $aParentFeeds = array(); } elseif (isset($aRow['parent_user_id']) && !isset($aRow['parent_user']) && $aRow['type_id'] != 'friend') { $aParentFeeds[$aRow['feed_id']] = $aRow['parent_user_id']; } if (empty($aFeeds) && defined('PHPFOX_IS_USER_PROFILE')) { return $this->get($iUserid, $iFeedId, ++$iPage, $bForceReturn); } } // Get the parents for the feeds so it displays arrow.png if (!empty($aParentFeeds)) { $aParentUsers = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->where('user_id IN (' . implode(',', array_values($aParentFeeds)) . ')')->execute('getSlaveRows'); $aFeedsWithParents = array_keys($aParentFeeds); foreach ($aFeeds as $sKey => $aRow) { if (in_array($aRow['feed_id'], $aFeedsWithParents) && $aRow['type_id'] != 'photo_tag') { foreach ($aParentUsers as $aUser) { if ($aUser['user_id'] == $aRow['parent_user_id']) { $aTempUser = array(); foreach ($aUser as $sField => $sVal) { $aTempUser['parent_' . $sField] = $sVal; } $aFeeds[$sKey]['parent_user'] = $aTempUser; } } } } } $oReq = Phpfox_Request::instance(); if (($oReq->getInt('status-id') || $oReq->getInt('comment-id') || $oReq->getInt('link-id') || $oReq->getInt('poke-id')) && isset($aFeeds[0])) { $aFeeds[0]['feed_view_comment'] = true; // $this->setParam('aFeed', array_merge(array('feed_display' => 'view', 'total_like' => $aRows[0]['feed_total_like']), $aRows[0])); } if ($oReq->getInt('page') == 0 && Phpfox::isModule('ad') && Phpfox::getParam('ad.multi_ad') && $iFeedId == null && ($iAd = Ad_Service_Ad::instance()->getSponsoredFeed()) != false) { $aFeeds = array_splice($aFeeds, 0, count($aFeeds) - 1); $aSponsored = $this->get(null, $iAd); if (isset($aSponsored[0])) { $aSponsored[0]['sponsored_feed'] = true; $aFeeds = array_merge($aSponsored, $aFeeds); } } // d($aFeeds); exit; return $aFeeds; }
/** * Controller */ public function process() { $bIsProfile = $this->request()->get('type_id') == 'profile' ? true : false; $this->template()->assign(array('bIsProfile' => $bIsProfile, 'iDefaultSetting' => Phpfox::getComponentSetting(Phpfox::getUserId(), 'feed.feed_display_limit_' . ($bIsProfile ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')), 'sSettingName' => 'feed.feed_display_limit_' . ($bIsProfile ? 'profile' : 'dashboard'), 'aSettings' => Phpfox::getParam('feed.user_feed_display_limit'), 'iProfileUserId' => Phpfox::getUserId())); }
/** * Class process method wnich is used to execute this component. */ public function process() { if (defined('PHPFOX_IS_PAGES_WIDGET')) { return false; } if (defined('PHPFOX_IS_PAGES_VIEW') && ($this->request()->get('req3') == 'info' || $this->request()->get('req2') == 'info')) { return false; } $iUserId = $this->getParam('user_id'); $aPage = $this->getParam('aPage'); // Dont display the feed if approving users if (isset($aPage['page_id']) && $this->request()->get('req3') == 'pending') { return false; } if (isset($aPage['landing_page']) && $aPage['landing_page'] == 'info' && (empty($aPage['vanity_url']) && $this->request()->get('req3') == '' || !empty($aPage['vanity_url']) && ($this->request()->get('req2') == 'info' || $this->request()->get('req2') == ''))) { return false; } $bForceFormOnly = $this->getParam('bForceFormOnly'); if (isset($aPage['page_user_id'])) { $bHasPerm = Phpfox::getService('pages')->hasPerm($aPage['page_id'], 'pages.view_browse_updates'); if ($bHasPerm == false) { return false; } $iUserId = $aPage['page_user_id']; /* Get all blocks for location 2 and 3 */ $oBlock = Phpfox::getLib('module'); $aExtraBlocks = array(); $aBlocks = $oBlock->getModuleBlocks(1, true); $aBlocks = array_merge($aBlocks, $oBlock->getModuleBlocks(3, true)); foreach ($aBlocks as $iKey => $sBlock) { switch ($sBlock) { case 'pages.menu': case 'pages.photo': if ($sBlock == 'pages.menu') { $aExtraBlocks[] = $sBlock; } unset($aBlocks[$iKey]); break; } } $aBlocks = array_merge($aBlocks, $aExtraBlocks); $this->template()->assign(array('aLoadBlocks' => $aBlocks)); } $bIsCustomFeedView = false; $sCustomViewType = null; if (PHPFOX_IS_AJAX && ($iUserId = $this->request()->get('profile_user_id'))) { if (!defined('PHPFOX_IS_USER_PROFILE')) { define('PHPFOX_IS_USER_PROFILE', true); } $aUser = Phpfox::getService('user')->get($iUserId); $this->template()->assign(array('aUser' => $aUser)); } if (PHPFOX_IS_AJAX && $this->request()->get('callback_module_id')) { $aCallback = Phpfox::callback($this->request()->get('callback_module_id') . '.getFeedDisplay', $this->request()->get('callback_item_id')); $this->setParam('aFeedCallback', $aCallback); } $aFeedCallback = $this->getParam('aFeedCallback', null); $bIsProfile = is_numeric($iUserId) && $iUserId > 0; if ($this->request()->get('feed') && $bIsProfile) { switch ($this->request()->get('flike')) { default: if ($sPlugin = Phpfox_Plugin::get('feed.component_block_display_process_flike')) { eval($sPlugin); } break; } } if (defined('PHPFOX_IS_USER_PROFILE') && !Phpfox::getService('user.privacy')->hasAccess($iUserId, 'feed.view_wall')) { return false; } if (defined('PHPFOX_IS_PAGES_VIEW') && !Phpfox::getService('pages')->hasPerm(null, 'pages.share_updates')) { $aFeedCallback['disable_share'] = true; } $iFeedPage = $this->request()->get('page', 0); if ($this->request()->getInt('status-id') || $this->request()->getInt('comment-id') || $this->request()->getInt('link-id') || $this->request()->getInt('plink-id') || $this->request()->getInt('poke-id') || $this->request()->getInt('feed')) { $bIsCustomFeedView = true; if ($this->request()->getInt('status-id')) { $sCustomViewType = Phpfox::getPhrase('feed.status_update_iid', array('iId' => $this->request()->getInt('status-id'))); } elseif ($this->request()->getInt('link-id')) { $sCustomViewType = Phpfox::getPhrase('feed.link_iid', array('iId' => $this->request()->getInt('link-id'))); } elseif ($this->request()->getInt('plink-id')) { $sCustomViewType = Phpfox::getPhrase('feed.link_iid', array('iId' => $this->request()->getInt('plink-id'))); } elseif ($this->request()->getInt('poke-id')) { $sCustomViewType = Phpfox::getPhrase('feed.poke_iid', array('iId' => $this->request()->getInt('poke-id'))); } elseif ($this->request()->getInt('comment-id')) { $sCustomViewType = Phpfox::getPhrase('feed.wall_comment_iid', array('iId' => $this->request()->getInt('comment-id'))); Phpfox::getService('notification.process')->delete('feed_comment_profile', $this->request()->getInt('comment-id'), Phpfox::getUserId()); } elseif ($this->request()->getInt('feed')) { $sCustomViewType = Phpfox::getPhrase('feed.feed'); } } if (!isset($aFeedCallback['item_id']) || $aFeedCallback['item_id'] == 0) { $aFeedCallback['item_id'] = (int) $this->request()->get('amp;callback_item_id') > 0 ? $this->request()->get('amp;callback_item_id') : $this->request()->get('callback_item_id'); } $bForceReloadOnPage = PHPFOX_IS_AJAX ? false : Phpfox::getParam('feed.force_ajax_on_load'); $aRows = array(); if (PHPFOX_IS_AJAX || !$bForceReloadOnPage || $bIsCustomFeedView) { $aRows = Phpfox::getService('feed')->callback($aFeedCallback)->get($bIsProfile > 0 ? $iUserId : null, $this->request()->get('feed') ? $this->request()->get('feed') : null, $iFeedPage); if (empty($aRows)) { $iFeedPage++; $aRows = Phpfox::getService('feed')->callback($aFeedCallback)->get($bIsProfile > 0 ? $iUserId : null, $this->request()->get('feed') ? $this->request()->get('feed') : null, $iFeedPage); } } /* else { $aRows = Phpfox::getService('feed')->callback($aFeedCallback)->get(($bIsProfile > 0 ? $iUserId : null), ($this->request()->get('feed') ? $this->request()->get('feed') : null), $iFeedPage); } */ if (($this->request()->getInt('status-id') || $this->request()->getInt('comment-id') || $this->request()->getInt('link-id') || $this->request()->getInt('poke-id') || $this->request()->getInt('feed')) && isset($aRows[0])) { $aRows[0]['feed_view_comment'] = true; $this->setParam('aFeed', array_merge(array('feed_display' => 'view', 'total_like' => $aRows[0]['feed_total_like']), $aRows[0])); } ($sPlugin = Phpfox_Plugin::get('feed.component_block_display_process')) ? eval($sPlugin) : false; if ($bIsCustomFeedView && !count($aRows) && $bIsProfile) { $aUser = $this->getParam('aUser'); $this->url()->send($aUser['user_name'], null, Phpfox::getPhrase('feed.the_activity_feed_you_are_looking_for_does_not_exist')); } $iUserid = $bIsProfile > 0 ? $iUserId : null; $iTotalFeeds = (int) Phpfox::getComponentSetting($iUserid === null ? Phpfox::getUserId() : $iUserid, 'feed.feed_display_limit_' . ($iUserid !== null ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')); /* if (isset($sActivityFeedHeader)) { $this->template()->assign(array( 'sHeader' => $sActivityFeedHeader ) ); } */ $aUserLocation = Phpfox::getUserBy('location_latlng'); if (!empty($aUserLocation)) { $this->template()->assign(array('aVisitorLocation' => json_decode($aUserLocation, true))); } $bLoadCheckIn = false; if (!defined('PHPFOX_IS_PAGES_VIEW') && Phpfox::getParam('feed.enable_check_in') && (Phpfox::getParam('core.ip_infodb_api_key') || Phpfox::getParam('core.google_api_key'))) { $bLoadCheckIn = true; } $oFeed = Phpfox::getService('feed'); foreach ($aRows as $iKey => $aRow) { if (!isset($aRow['feed_like_phrase'])) { if (Phpfox::isModule('like')) { $aRows[$iKey]['feed_like_phrase'] = $oFeed->getPhraseForLikes($aRow); } } } $bIsHashTagPop = $this->request()->get('hashtagpopup') ? true : false; if ($bIsHashTagPop) { define('PHPFOX_FEED_HASH_POPUP', true); } // http://www.phpfox.com/tracker/view/15392/ $sIsHashTagSearchValue = urldecode(strip_tags($this->request()->get('hashtagsearch') ? $this->request()->get('hashtagsearch') : ($this->request()->get('req1') == 'hashtag' ? $this->request()->get('req2') : ''))); if (preg_match_all('/[0-9]+/', $sIsHashTagSearchValue, $aMatches)) { $sIsHashTagSearchValue = ''; foreach ($aMatches[0] as $sMatch) { $sIsHashTagSearchValue .= preg_replace('/[0-9]+/', '&#$0;', $sMatch); } } $this->template()->assign(array('bForceReloadOnPage' => $bForceReloadOnPage, 'bHideEnterComment' => true, 'aFeeds' => $aRows, 'iFeedNextPage' => $bForceReloadOnPage ? 0 : $iFeedPage + 1, 'iFeedCurrentPage' => $iFeedPage, 'iTotalFeedPages' => 1, 'aFeedVals' => $this->request()->getArray('val'), 'sCustomViewType' => $sCustomViewType, 'aFeedStatusLinks' => Phpfox::getService('feed')->getShareLinks(), 'aFeedCallback' => $aFeedCallback, 'bIsCustomFeedView' => $bIsCustomFeedView, 'sTimelineYear' => $this->request()->get('year'), 'sTimelineMonth' => $this->request()->get('month'), 'iFeedUserSortOrder' => Phpfox::getUserBy('feed_sort'), 'bLoadCheckIn' => $bLoadCheckIn, 'bForceFormOnly' => $bForceFormOnly, 'sIsHashTagSearch' => urlencode(strip_tags($this->request()->get('hashtagsearch') ? $this->request()->get('hashtagsearch') : ($this->request()->get('req1') == 'hashtag' ? $this->request()->get('req2') : ''))), 'sIsHashTagSearchValue' => $sIsHashTagSearchValue, 'bIsHashTagPop' => $bIsHashTagPop)); if (Phpfox::getParam('video.convert_servers_enable') && !PHPFOX_IS_AJAX) { $aVideoServers = Phpfox::getParam('video.convert_servers'); $sCustomServerUrl = $aVideoServers[rand(0, count($aVideoServers) - 1)]; $this->template()->assign('sVideoServerUrl', $sCustomServerUrl); $this->template()->assign('sCustomVideoHash', Phpfox::getService('video')->addCustomHash()); } if (Phpfox::getService('profile')->timeline()) { $aFeedTimeline = Phpfox::getService('feed')->getTimeline(); if (($this->request()->getInt('status-id') || $this->request()->getInt('comment-id') || $this->request()->getInt('link-id') || $this->request()->getInt('poke-id') || $this->request()->getInt('feed')) && isset($aRows[0])) { $aFeedTimeline['left'][0]['feed_view_comment'] = true; } $this->template()->assign(array('aFeedTimeline' => $aFeedTimeline, 'sLastDayInfo' => Phpfox::getService('feed')->getLastDay())); if (!PHPFOX_IS_AJAX) { $aUser = $this->getParam('aUser'); if ($aUser['birthday'] == null) { $aTimeline = Phpfox::getService('feed')->getTimeLineYears($aUser['user_id'], $aUser['joined']); } else { $aTimeline = Phpfox::getService('feed')->getTimeLineYears($aUser['user_id'], $aUser['birthday_search']); } $this->template()->assign(array('aTimelineDates' => $aTimeline)); } } /* if ($bIsProfile) { if (!Phpfox::getService('user.privacy')->hasAccess($iUserId, 'feed.display_on_profile')) { return false; } } */ return 'block'; }
/** * Controller */ public function process() { $this->template()->assign(array('iDefaultSetting' => (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'log.user_login_display_limit', '0'))); }
public function get($iUserid = null, $iFeedId = null, $iPage = 0, $bForceReturn = false) { $oUrl = Phpfox::getLib('url'); $oReq = Phpfox::getLib('request'); $oParseOutput = Phpfox::getLib('parse.output'); if ($oReq->get('get-new')) { // $bForceReturn = true; } if ($iCommentId = $oReq->getInt('comment-id')) { if (isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'' . $this->_aCallback['feed_comment'] . '\' AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']); } else { $aCustomCondition = array('feed.type_id IN(\'feed_comment\', \'feed_egift\') AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $iUserid); } $iFeedId = true; } elseif ($iStatusId = $oReq->getInt('status-id')) { $aCustomCondition = array('feed.type_id = \'user_status\' AND feed.item_id = ' . (int) $iStatusId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iLinkId = $oReq->getInt('link-id')) { $aCustomCondition = array('feed.type_id = \'link\' AND feed.item_id = ' . (int) $iLinkId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iLinkId = $oReq->getInt('plink-id')) { $aCustomCondition = array('feed.type_id = \'link\' AND feed.item_id = ' . (int) $iLinkId . ' AND feed.parent_user_id = ' . (int) $iUserid); $iFeedId = true; } elseif ($iPokeId = $oReq->getInt('poke-id')) { $aCustomCondition = array('feed.type_id = \'poke\' AND feed.item_id = ' . (int) $iPokeId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } $iTotalFeeds = (int) Phpfox::getComponentSetting($iUserid === null ? Phpfox::getUserId() : $iUserid, 'feed.feed_display_limit_' . ($iUserid !== null ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')); $iOffset = $iPage * $iTotalFeeds; ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_start')) ? eval($sPlugin) : false; $sOrder = 'feed.time_update DESC'; if (Phpfox::getUserBy('feed_sort') || defined('PHPFOX_IS_USER_PROFILE')) { $sOrder = 'feed.time_stamp DESC'; } $aCond = array(); if (isset($this->_aCallback['module'])) { $aNewCond = array(); if ($iCommentId = $oReq->getInt('comment-id')) { if (!isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'' . $this->_aCallback['module'] . '_comment\' AND feed.item_id = ' . (int) $iCommentId . ''); } } $aNewCond[] = 'AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']; if ($iUserid !== null && $iFeedId !== null) { $aNewCond[] = 'AND feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid; } $iTimelineYear = 0; if (($iTimelineYear = Phpfox::getLib('request')->get('year')) && !empty($iTimelineYear)) { $iMonth = 12; $iDay = 31; if (($iTimelineMonth = Phpfox::getLib('request')->get('month')) && !empty($iTimelineMonth)) { $iMonth = $iTimelineMonth; $iDay = Phpfox::getLib('date')->lastDayOfMonth($iMonth, $iTimelineYear); } $aNewCond[] = 'AND feed.time_stamp <= \'' . mktime(0, 0, 0, $iMonth, $iDay, $iTimelineYear) . '\''; } $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from(Phpfox::getT($this->_aCallback['table_prefix'] . 'feed'), 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where(isset($aCustomCondition) ? $aCustomCondition : $aNewCond)->order($sOrder)->limit($iOffset, $iTotalFeeds)->execute('getSlaveRows'); // Fixes missing page_user_id, required to create the proper feed target if ($this->_aCallback['module'] == 'pages') { foreach ($aRows as $iKey => $aValue) { $aRows[$iKey]['page_user_id'] = $iUserid; } } } elseif ($sIds = $oReq->get('ids')) { $aParts = explode(',', $oReq->get('ids')); $sNewIds = ''; foreach ($aParts as $sPart) { $sNewIds .= (int) $sPart . ','; } $sNewIds = rtrim($sNewIds, ','); $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where('feed.feed_id IN(' . $sNewIds . ')')->order('feed.time_stamp DESC')->execute('getSlaveRows'); } elseif ($iUserid === null && $iFeedId !== null) { $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->where('feed.feed_id = ' . (int) $iFeedId)->order('feed.time_stamp DESC')->execute('getSlaveRows'); } elseif ($iUserid !== null && $iFeedId !== null) { $aRows = $this->database()->select('feed.*, apps.app_title, ' . Phpfox::getUserField() . ', u.view_id')->from($this->_sTable, 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id')->where(isset($aCustomCondition) ? $aCustomCondition : 'feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid . '')->order('feed.time_stamp DESC')->limit(1)->execute('getSlaveRows'); } elseif ($iUserid !== null) { if ($iUserid == Phpfox::getUserId()) { $aCond[] = 'AND feed.privacy IN(0,1,2,3,4)'; } else { if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend) { $aCond[] = 'AND feed.privacy IN(0,1,2)'; } else { if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend_of_friend) { $aCond[] = 'AND feed.privacy IN(0,2)'; } else { $aCond[] = 'AND feed.privacy IN(0)'; } } } // There is no reciprocal feed when you add someone as friend $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.type_id = \'friend\' AND feed.user_id = ' . (int) $iUserid)->union(); ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_userprofile')) ? eval($sPlugin) : ''; $iTimelineYear = 0; if (($iTimelineYear = Phpfox::getLib('request')->get('year')) && !empty($iTimelineYear)) { $iMonth = 12; $iDay = 31; if (($iTimelineMonth = Phpfox::getLib('request')->get('month')) && !empty($iTimelineMonth)) { $iMonth = $iTimelineMonth; $iDay = Phpfox::getLib('date')->lastDayOfMonth($iMonth, $iTimelineYear); } $aCond[] = 'AND feed.time_stamp <= \'' . mktime(0, 0, 0, $iMonth, $iDay, $iTimelineYear) . '\''; } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND type_id = \'feed_comment\' AND feed.user_id = ' . (int) $iUserid . '')))->union(); $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND feed.user_id = ' . (int) $iUserid . ' AND feed.feed_reference = 0 AND feed.parent_user_id = 0')))->union(); if (Phpfox::isUser()) { if (Phpfox::isModule('privacy')) { $this->database()->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id')->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . ''); } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(4) AND feed.user_id = ' . (int) $iUserid . ' AND feed.feed_reference = 0')->union(); } $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where(array_merge($aCond, array('AND feed.parent_user_id = ' . (int) $iUserid)))->union(); $aRows = $this->database()->select('feed.*, apps.app_title, ' . Phpfox::getUserField())->unionFrom('feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id')->order('feed.time_stamp DESC')->group('feed.feed_id')->limit($iOffset, $iTotalFeeds)->execute('getSlaveRows'); } else { // Users must be active within 7 days or we skip their activity feed $iLastActiveTimeStamp = (int) Phpfox::getParam('feed.feed_limit_days') <= 0 ? 0 : PHPFOX_TIME - 86400 * Phpfox::getParam('feed.feed_limit_days'); if (Phpfox::isModule('privacy') && Phpfox::getUserParam('privacy.can_view_all_items')) { $this->_hashSearch(); $sSelect = 'feed.*, apps.app_title, ' . Phpfox::getUserField(); if (Phpfox::isModule('friend')) { $sSelect .= ', f.friend_id AS is_friend'; $this->database()->leftJoin(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()); } $aRows = $this->database()->select($sSelect)->from(Phpfox::getT('feed'), 'feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id')->order($sOrder)->group('feed.feed_id')->limit($iOffset, $iTotalFeeds)->where('feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->execute('getSlaveRows'); } else { if (Phpfox::getParam('feed.feed_only_friends')) { if (Phpfox::isModule('friend')) { // Get my friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId())->where('feed.privacy IN(0,1,2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); // Get my feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(0,1,2,3,4) AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); } } else { $sMyFeeds = '1,2,3,4'; ($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_buildquery')) ? eval($sPlugin) : ''; if (Phpfox::isModule('friend')) { // Get my friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId())->where('feed.privacy IN(1,2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->limit($iTotalFeeds)->union(); // Get my friends of friends feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->join(Phpfox::getT('friend'), 'f1', 'f1.user_id = feed.user_id')->join(Phpfox::getT('friend'), 'f2', 'f2.user_id = ' . Phpfox::getUserId() . ' AND f2.friend_user_id = f1.friend_user_id')->where('feed.privacy IN(2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->limit($iTotalFeeds)->union(); } // Get my feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(' . $sMyFeeds . ') AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); // Get public feeds $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(0) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); if (Phpfox::isModule('privacy')) { $this->database()->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id')->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . ''); } // Get feeds based on custom friends lists $this->database()->select('feed.*')->from($this->_sTable, 'feed')->where('feed.privacy IN(4) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\' AND feed.feed_reference = 0')->union(); } $this->_hashSearch(); $sSelect = 'feed.*, apps.app_title, u.view_id, ' . Phpfox::getUserField(); if (Phpfox::isModule('friend')) { $sSelect .= ', f.friend_id AS is_friend'; $this->database()->leftJoin(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()); } $aRows = $this->database()->select($sSelect)->unionFrom('feed')->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id')->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id')->order($sOrder)->group('feed.feed_id')->limit($iOffset, $iTotalFeeds)->execute('getSlaveRows'); } } if ($bForceReturn === true) { return $aRows; } $bFirstCheckOnComments = false; if (Phpfox::getParam('feed.allow_comments_on_feeds') && Phpfox::isUser() && Phpfox::isModule('comment')) { $bFirstCheckOnComments = true; } $iLoopMaxCount = Phpfox::getParam('feed.group_duplicate_feeds'); if (Phpfox::getService('profile')->timeline() || Phpfox::getParam('feed.cache_each_feed_entry')) { $iLoopMaxCount = 0; } if (defined('PHPFOX_SKIP_LOOP_MAX_COUNT')) { $iLoopMaxCount = 0; } $aFeedLoop = array(); $aLoopHistory = array(); if (Phpfox::getLib('request')->get('hashtagsearch')) { $aFeedLoop = $aRows; } else { if ($iLoopMaxCount > 0) { foreach ($aRows as $iKey => $aRow) { $sFeedKey = $aRow['user_id'] . $aRow['type_id'] . date('dmyH', $aRow['time_stamp']); if (isset($aRow['type_id'])) { $aModule = explode('_', $aRow['type_id']); if (isset($aModule[0]) && Phpfox::isModule($aModule[0]) && Phpfox::hasCallback($aModule[0] . (isset($aModule[1]) ? '_' . $aModule[1] : ''), 'getReportRedirect')) { $aRow['report_module'] = $aRows[$iKey]['report_module'] = $aModule[0] . (isset($aModule[1]) ? '_' . $aModule[1] : ''); $aRow['report_phrase'] = $aRows[$iKey]['report_phrase'] = Phpfox::getPhrase('feed.report_this_entry'); $aRow['force_report'] = $aRows[$iKey]['force_report'] = true; } } if (isset($aFeedLoop[$sFeedKey])) { if (!isset($aLoopHistory[$sFeedKey])) { $aLoopHistory[$sFeedKey] = 0; } $aLoopHistory[$sFeedKey]++; if ($aLoopHistory[$sFeedKey] >= $iLoopMaxCount - 1) { $bIsLoop = true; $this->_aViewMoreFeeds[$sFeedKey][] = $aRow; } else { $aFeedLoop[$sFeedKey . $aLoopHistory[$sFeedKey]] = $aRow; continue; } } else { $aFeedLoop[$sFeedKey] = $aRow; } if (isset($bIsLoop)) { unset($bIsLoop); } } } else { $aFeedLoop = $aRows; } } $aFeeds = array(); $aCacheData = array(); $sLastFriendId = ''; $sLastPhotoId = 0; if (Phpfox::isModule('like')) { $oLike = Phpfox::getService('like'); } $aParentFeeds = array(); foreach ($aFeedLoop as $sKey => $aRow) { $aRow['feed_time_stamp'] = $aRow['time_stamp']; if ($aReturn = $this->_processFeed($aRow, $sKey, $iUserid, $bFirstCheckOnComments)) { if (isset($aReturn['force_user'])) { $aReturn['user_name'] = $aReturn['force_user']['user_name']; $aReturn['full_name'] = $aReturn['force_user']['full_name']; $aReturn['user_image'] = $aReturn['force_user']['user_image']; $aReturn['server_id'] = $aReturn['force_user']['server_id']; } $aReturn['feed_month_year'] = date('m_Y', $aRow['feed_time_stamp']); $aReturn['feed_time_stamp'] = $aRow['feed_time_stamp']; if (isset($aReturn['like_type_id']) && isset($oLike) && Phpfox::getParam('like.allow_dislike')) { $aReturn['marks'] = $oLike->getActionsFor($aReturn['like_type_id'], isset($aReturn['like_item_id']) ? $aReturn['like_item_id'] : $aReturn['item_id']); } /* Lets figure out the phrases for like.display right here */ //if (Phpfox::getParam('like.allow_dislike')) if (Phpfox::isModule('like')) { $this->getPhraseForLikes($aReturn); } if (Phpfox::getParam('feed.cache_each_feed_entry') && !empty($aReturn['like_type_id']) && Phpfox::isUser() && isset($aReturn['likes']) && count($aReturn['likes'])) { $iUserLiked = isset($aReturn['likes_history'][Phpfox::getUserId()]) ? true : false; $aReturn['feed_is_liked'] = $iUserLiked; $aReturn['is_liked'] = $iUserLiked; } if (Phpfox::getParam('feed.cache_each_feed_entry') && isset($aReturn['comments']) && count($aReturn['comments'])) { foreach ($aReturn['comments'] as $iCommentKey => $aCommentValue) { $aReturn['comments'][$iCommentKey]['is_liked'] = isset($aCommentValue['liked_history'][Phpfox::getUserId()]) ? true : false; } } $aFeeds[] = $aReturn; } // Show the feed properly. If user A posted on page 1, then feed will say "user A > page 1 posted ..." if (isset($this->_aCallback['module']) && $this->_aCallback['module'] == 'pages') { // If defined parent user, and the parent user is not the same page (logged in as a page) if (isset($aRow['page_user_id']) && $aReturn['page_user_id'] != $aReturn['user_id']) { $aParentFeeds[$aReturn['feed_id']] = $aRow['page_user_id']; } } elseif (isset($aRow['parent_user_id']) && !isset($aRow['parent_user']) && $aRow['type_id'] != 'friend') { $aParentFeeds[$aRow['feed_id']] = $aRow['parent_user_id']; } } // Get the parents for the feeds so it displays arrow.png if (!empty($aParentFeeds)) { $aParentUsers = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->where('user_id IN (' . implode(',', array_values($aParentFeeds)) . ')')->execute('getSlaveRows'); $aFeedsWithParents = array_keys($aParentFeeds); foreach ($aFeeds as $sKey => $aRow) { if (in_array($aRow['feed_id'], $aFeedsWithParents) && $aRow['type_id'] != 'photo_tag') { foreach ($aParentUsers as $aUser) { if ($aUser['user_id'] == $aRow['parent_user_id']) { $aTempUser = array(); foreach ($aUser as $sField => $sVal) { $aTempUser['parent_' . $sField] = $sVal; } $aFeeds[$sKey]['parent_user'] = $aTempUser; } } } } } $oReq = Phpfox::getLib('request'); if (($oReq->getInt('status-id') || $oReq->getInt('comment-id') || $oReq->getInt('link-id') || $oReq->getInt('poke-id')) && isset($aFeeds[0])) { $aFeeds[0]['feed_view_comment'] = true; // $this->setParam('aFeed', array_merge(array('feed_display' => 'view', 'total_like' => $aRows[0]['feed_total_like']), $aRows[0])); } if (Phpfox::getService('profile')->timeline()) { $iSubCnt = 0; foreach ($aFeeds as $iKey => $aFeed) { if (is_int($iKey / 2)) { $this->_aFeedTimeline['left'][] = $aFeed; } else { $this->_aFeedTimeline['right'][] = $aFeed; } $iSubCnt++; if ($iSubCnt === 1) { $sMonth = date('m', $aFeed['feed_time_stamp']); $sYear = date('Y', $aFeed['feed_time_stamp']); if ($sMonth == date('m', PHPFOX_TIME) && $sYear == date('Y', PHPFOX_TIME)) { $this->_sLastDayInfo = ''; } elseif ($sYear == date('Y', PHPFOX_TIME)) { $this->_sLastDayInfo = Phpfox::getTime('F', $aFeed['feed_time_stamp'], false); } else { $this->_sLastDayInfo = Phpfox::getTime('F Y', $aFeed['feed_time_stamp'], false); } } } } if ($oReq->getInt('page') == 0 && Phpfox::isModule('ad') && Phpfox::getParam('ad.multi_ad') && $iFeedId == null && ($iAd = Phpfox::getService('ad')->getSponsoredFeed()) != false) { $aFeeds = array_splice($aFeeds, 0, count($aFeeds) - 1); $aSponsored = $this->get(null, $iAd); if (isset($aSponsored[0])) { $aSponsored[0]['sponsored_feed'] = true; $aFeeds = array_merge($aSponsored, $aFeeds); } } return $aFeeds; }
/** * Controller */ public function process() { $bIsProfile = $this->request()->get('type_id') == 'profile' ? true : false; $this->template()->assign(array('bIsProfile' => $bIsProfile, 'iDefaultSetting' => Phpfox::getComponentSetting(Phpfox::getUserId(), 'friend.friend_display_limit_' . ($bIsProfile ? 'profile' : 'dashboard'), Phpfox::getParam('friend.friend_display_limit')), 'sSettingName' => 'friend.friend_display_limit_' . ($bIsProfile ? 'profile' : 'dashboard'), 'aSettings' => Phpfox::getParam('friend.friend_user_feed_display_limit'), 'bNoDeleteLink' => $this->request()->get('no_delete_link') ? true : false, 'bIsEditTop' => $this->request()->get('is_edit_top') ? true : false)); }
public function getNewMenu($bForEdit = false) { $sCacheId = $this->cache()->set('core_new_menu'); $sModuleBlock = ''; if (!($aSubMenus = $this->cache()->get($sCacheId))) { /* $aMenus1['user'] = array( 'Members' => array( 'ajax' => '#user.getNew?id=js_new_item_holder', 'id' => 'member', 'block' => 'user.new' ) ); $aMenus2 = Phpfox::massCallback('getWhatsNew'); $aMenus = array_merge($aMenus1, $aMenus2); */ $aMenus = Phpfox::massCallback('getWhatsNew'); $aSubMenus = array(); foreach ($aMenus as $sModule => $aMenu) { $aKey = array_keys($aMenu); $aValue = array_values($aMenu); $aSubMenus[$aKey[0]] = $aValue[0]; } $this->cache()->save($sCacheId, $aSubMenus); } if ($aSubMenus === true) { $aSubMenus = array(); } if ($bForEdit === true) { $sUserSettings = Phpfox::getComponentSetting(Phpfox::getUserId(), 'core.whats_new_blocks', null); if ($sUserSettings !== null) { $aUserSettings = unserialize($sUserSettings); } foreach ($aSubMenus as $sName => $aSubMenu) { $aSubMenus[$sName]['name'] = Phpfox::getPhrase($sName); $aSubMenus[$sName]['is_used'] = isset($aUserSettings['m']) && in_array($aSubMenu['id'], $aUserSettings['m']) ? true : ($sUserSettings === null ? true : false); } return $aSubMenus; } else { $sUserSettings = Phpfox::getComponentSetting(Phpfox::getUserId(), 'core.whats_new_blocks', null); if ($sUserSettings !== null) { $aUserSettings = unserialize($sUserSettings); } $iCnt = 0; $aFinalMenu = array(); foreach ($aSubMenus as $sName => $aSubMenu) { if (isset($aUserSettings['m']) && !in_array($aSubMenu['id'], $aUserSettings['m'])) { continue; } $iCnt++; if ($iCnt === 1) { $sModuleBlock = $aSubMenu['block']; } $aFinalMenu[Phpfox::getPhrase($sName)] = $aSubMenu['ajax']; } return array($aFinalMenu, $sModuleBlock); } }
public function get($iUserid = null, $iFeedId = null, $iPage = 0, $bForceReturn = false) { $oUrl = Phpfox::getLib('url'); $oReq = Phpfox::getLib('request'); $oParseOutput = Phpfox::getLib('parse.output'); if ($oReq->get('get-new')) { // $bForceReturn = true; } if (($iCommentId = $oReq->getInt('comment-id'))) { if (isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'' . $this->_aCallback['feed_comment'] . '\' AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']); } else { $aCustomCondition = array('feed.type_id IN(\'feed_comment\', \'feed_egift\') AND feed.item_id = ' . (int) $iCommentId . ' AND feed.parent_user_id = ' . (int) $iUserid); } $iFeedId = true; } elseif (($iStatusId = $oReq->getInt('status-id'))) { $aCustomCondition = array('feed.type_id = \'user_status\' AND feed.item_id = ' . (int) $iStatusId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif (($iLinkId = $oReq->getInt('link-id'))) { $aCustomCondition = array('feed.type_id = \'link\' AND feed.item_id = ' . (int) $iLinkId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } elseif (($iPokeId = $oReq->getInt('poke-id'))) { $aCustomCondition = array('feed.type_id = \'poke\' AND feed.item_id = ' . (int) $iPokeId . ' AND feed.user_id = ' . (int) $iUserid); $iFeedId = true; } $iTotalFeeds = (int) Phpfox::getComponentSetting(($iUserid === null ? Phpfox::getUserId() : $iUserid), 'feed.feed_display_limit_' . ($iUserid !== null ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')); $iOffset = ($iPage * $iTotalFeeds); (($sPlugin = Phpfox_Plugin::get('feed.service_feed_get_start')) ? eval($sPlugin) : false); $aCond = array(); if (isset($this->_aCallback['module'])) { $aNewCond = array(); if (($iCommentId = $oReq->getInt('comment-id'))) { if (!isset($this->_aCallback['feed_comment'])) { $aCustomCondition = array('feed.type_id = \'event_comment\' AND feed.item_id = ' . (int) $iCommentId . ''); } } $aNewCond[] = 'AND feed.parent_user_id = ' . (int) $this->_aCallback['item_id']; if ($iUserid !== null && $iFeedId !== null) { $aNewCond[] = 'AND feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid; } $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField()) ->from(Phpfox::getT($this->_aCallback['table_prefix'] . 'feed'), 'feed') ->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id') ->where((isset($aCustomCondition) ? $aCustomCondition : $aNewCond)) ->order('feed.time_stamp DESC') ->limit($iOffset, $iTotalFeeds) ->execute('getSlaveRows'); } elseif (($sIds = $oReq->get('ids'))) { $aParts = explode(',', $oReq->get('ids')); $sNewIds = ''; foreach ($aParts as $sPart) { $sNewIds .= (int) $sPart . ','; } $sNewIds = rtrim($sNewIds, ','); $aRows = $this->database()->select('feed.*, ' . Phpfox::getUserField()) ->from($this->_sTable, 'feed') ->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id') ->where('feed.feed_id IN(' . $sNewIds . ')') ->order('feed.time_stamp DESC') ->execute('getSlaveRows'); } elseif ($iUserid !== null && $iFeedId !== null) { $aRows = $this->database()->select('feed.*, apps.app_title, ' . Phpfox::getUserField()) ->from($this->_sTable, 'feed') ->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id') ->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id') ->where((isset($aCustomCondition) ? $aCustomCondition : 'feed.feed_id = ' . (int) $iFeedId . ' AND feed.user_id = ' . (int) $iUserid)) ->order('feed.time_stamp DESC') ->limit(1) ->execute('getSlaveRows'); } elseif ($iUserid !== null) { if ($iUserid == Phpfox::getUserId()) { $aCond[] = 'AND feed.privacy IN(0,1,2,3,4)'; } else { if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend) { $aCond[] = 'AND feed.privacy IN(0,1,2)'; } else if (Phpfox::getService('user')->getUserObject($iUserid)->is_friend_of_friend) { $aCond[] = 'AND feed.privacy IN(0,2)'; } else { $aCond[] = 'AND feed.privacy IN(0)'; } } $this->database()->select('feed.*') ->from($this->_sTable, 'feed') // ->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()) ->where(array_merge($aCond, array('AND feed.user_id = ' . (int) $iUserid))) ->union(); if (Phpfox::isUser()) { $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id') ->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . '') ->where('feed.privacy IN(4) AND feed.user_id = ' . (int) $iUserid) ->union(); } $this->database()->select('feed.*') ->from($this->_sTable, 'feed') // ->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()) ->where(array_merge($aCond, array('AND feed.parent_user_id = ' . (int) $iUserid))) ->union(); $aRows = $this->database()->select('feed.*, apps.app_title, ' . Phpfox::getUserField()) // ->from($this->_sTable, 'feed') ->unionFrom('feed') ->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id') ->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id') // ->where($aCond) ->order('feed.time_stamp DESC') ->limit($iOffset, $iTotalFeeds) ->execute('getSlaveRows'); } else { // Users must be active within 7 days or we skip their activity feed $iLastActiveTimeStamp = ((int) Phpfox::getParam('feed.feed_limit_days') <= 0 ? 0 : (PHPFOX_TIME - (86400 * Phpfox::getParam('feed.feed_limit_days')))); if (Phpfox::getParam('feed.feed_only_friends')) { // Get my friends feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()) ->where('feed.privacy IN(0,1,2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); // Get my feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->where('feed.privacy IN(0,1,2,3,4) AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); } else { // Get my friends feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->join(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()) ->where('feed.privacy IN(1,2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); // Get my friends of friends feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->join(Phpfox::getT('friend'), 'f1', 'f1.user_id = feed.user_id') ->join(Phpfox::getT('friend'), 'f2', 'f2.user_id = ' . Phpfox::getUserId() . ' AND f2.friend_user_id = f1.friend_user_id') ->where('feed.privacy IN(2) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); // Get my feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->where('feed.privacy IN(1,2,3,4) AND feed.user_id = ' . Phpfox::getUserId() . ' AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); // Get public feeds $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->where('feed.privacy IN(0) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); // Get feeds based on custom friends lists $this->database()->select('feed.*') ->from($this->_sTable, 'feed') ->join(Phpfox::getT('privacy'), 'p', 'p.module_id = feed.type_id AND p.item_id = feed.item_id') ->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId() . '') ->where('feed.privacy IN(4) AND feed.time_stamp > \'' . $iLastActiveTimeStamp . '\'') ->union(); } $aRows = $this->database()->select('feed.*, f.friend_id AS is_friend, apps.app_title, ' . Phpfox::getUserField()) ->unionFrom('feed') ->join(Phpfox::getT('user'), 'u', 'u.user_id = feed.user_id') ->leftJoin(Phpfox::getT('friend'), 'f', 'f.user_id = feed.user_id AND f.friend_user_id = ' . Phpfox::getUserId()) ->leftJoin(Phpfox::getT('app'), 'apps', 'apps.app_id = feed.app_id') ->order('feed.time_stamp DESC') ->group('feed.feed_id') ->limit($iOffset, $iTotalFeeds) ->execute('getSlaveRows'); } if ($bForceReturn === true) { return $aRows; } $bFirstCheckOnComments = false; if (Phpfox::getParam('feed.allow_comments_on_feeds') && Phpfox::isUser() && Phpfox::isModule('comment')) { $bFirstCheckOnComments = true; } $iLoopMaxCount = Phpfox::getParam('feed.group_duplicate_feeds'); $aFeedLoop = array(); $aLoopHistory = array(); if ($iLoopMaxCount > 0) { foreach ($aRows as $iKey => $aRow) { $sFeedKey = $aRow['user_id'] . $aRow['type_id'] . date('dmyH', $aRow['time_stamp']); if (isset($aFeedLoop[$sFeedKey])) { if (!isset($aLoopHistory[$sFeedKey])) { $aLoopHistory[$sFeedKey] = 0; } $aLoopHistory[$sFeedKey]++; if ($aLoopHistory[$sFeedKey] >= ($iLoopMaxCount - 1)) { $bIsLoop = true; $this->_aViewMoreFeeds[$sFeedKey][] = $aRow; } else { $aFeedLoop[$sFeedKey . $aLoopHistory[$sFeedKey]] = $aRow; continue; } } else { $aFeedLoop[$sFeedKey] = $aRow; } if (isset($bIsLoop)) { unset($bIsLoop); } } } else { $aFeedLoop = $aRows; } $aFeeds = array(); $aCacheData = array(); $sLastFriendId = ''; $sLastPhotoId = 0; foreach ($aFeedLoop as $sKey => $aRow) { /* if ($aRow['type_id'] == 'friend') { if ($aRow['item_id'] . $aRow['user_id'] == $sLastFriendId) { $sLastFriendId = ''; continue; } $sLastFriendId = $aRow['user_id'] . $aRow['item_id']; } else { $sLastFriendId = ''; } */ if (($aReturn = $this->_processFeed($aRow, $sKey, $iUserid, $bFirstCheckOnComments))) { if (isset($aReturn['force_user'])) { $aReturn['user_name'] = $aReturn['force_user']['user_name']; $aReturn['full_name'] = $aReturn['force_user']['full_name']; $aReturn['user_image'] = $aReturn['force_user']['user_image']; $aReturn['server_id'] = $aReturn['force_user']['server_id']; } $aFeeds[] = $aReturn; } } return $aFeeds; }
/** * Class process method wnich is used to execute this component. */ public function process() { $iUserId = $this->getParam('user_id'); $bIsCustomFeedView = false; $sCustomViewType = null; if (PHPFOX_IS_AJAX && ($iUserId = $this->request()->get('profile_user_id'))) { if (!defined('PHPFOX_IS_USER_PROFILE')) { define('PHPFOX_IS_USER_PROFILE', true); } $aUser = Phpfox::getService('user')->get($iUserId); $this->template()->assign(array( 'aUser' => $aUser ) ); } if (PHPFOX_IS_AJAX && $this->request()->get('callback_module_id')) { $aCallback = Phpfox::callback($this->request()->get('callback_module_id') . '.getFeedDisplay', $this->request()->get('callback_item_id')); $this->setParam('aFeedCallback', $aCallback); } $aFeedCallback = $this->getParam('aFeedCallback', null); $bIsProfile = (is_numeric($iUserId) && $iUserId > 0); if ($this->request()->get('feed') && $bIsProfile) { switch ($this->request()->get('flike')) { default: if ($sPlugin = Phpfox_Plugin::get('feed.component_block_display_process_flike')) { eval($sPlugin); } break; } } if (defined('PHPFOX_IS_USER_PROFILE') && !Phpfox::getService('user.privacy')->hasAccess($iUserId, 'feed.view_wall')) { return false; } if (defined('PHPFOX_IS_PAGES_VIEW') && !Phpfox::getService('pages')->hasPerm(null, 'pages.share_updates')) { $aFeedCallback['disable_share'] = true; } $iFeedPage = $this->request()->get('page', 0); if ($this->request()->getInt('status-id') || $this->request()->getInt('comment-id') || $this->request()->getInt('link-id') || $this->request()->getInt('poke-id') || $this->request()->getInt('feed') ) { $bIsCustomFeedView = true; if ($this->request()->getInt('status-id')) { $sCustomViewType = 'Status Update: #' . $this->request()->getInt('status-id'); } elseif ($this->request()->getInt('link-id')) { $sCustomViewType = 'Link: #' . $this->request()->getInt('link-id'); } elseif ($this->request()->getInt('poke-id')) { $sCustomViewType = 'Poke: #' . $this->request()->getInt('poke-id'); } elseif ($this->request()->getInt('comment-id')) { $sCustomViewType = 'Wall Comment: #' . $this->request()->getInt('comment-id'); Phpfox::getService('notification.process')->delete('feed_comment_profile', $this->request()->getInt('comment-id'), Phpfox::getUserId()); } elseif ($this->request()->getInt('feed')) { $sCustomViewType = 'Feed'; } } $aRows = Phpfox::getService('feed')->callback($aFeedCallback)->get(($bIsProfile > 0 ? $iUserId : null), ($this->request()->get('feed') ? $this->request()->get('feed') : null), $iFeedPage); if (($this->request()->getInt('status-id') || $this->request()->getInt('comment-id') || $this->request()->getInt('link-id') || $this->request()->getInt('poke-id') ) && isset($aRows[0])) { $aRows[0]['feed_view_comment'] = true; $this->setParam('aFeed', array_merge(array('feed_display' => 'view', 'total_like' => $aRows[0]['feed_total_like']), $aRows[0])); } (($sPlugin = Phpfox_Plugin::get('feed.component_block_display_process')) ? eval($sPlugin) : false); if ($bIsCustomFeedView && !count($aRows) && $bIsProfile) { $aUser = $this->getParam('aUser'); $this->url()->send($aUser['user_name'], null, Phpfox::getPhrase('feed.the_activity_feed_you_are_looking_for_does_not_exist')); } $iUserid = ($bIsProfile > 0 ? $iUserId : null); $iTotalFeeds = (int) Phpfox::getComponentSetting(($iUserid === null ? Phpfox::getUserId() : $iUserid), 'feed.feed_display_limit_' . ($iUserid !== null ? 'profile' : 'dashboard'), Phpfox::getParam('feed.feed_display_limit')); if (!Phpfox::isMobile()) { $this->template()->assign(array( 'sHeader' => 'Activity Feed' ) ); } $this->template()->assign(array( 'aFeeds' => $aRows, 'iFeedNextPage' => ($iFeedPage + 1), 'iFeedCurrentPage' => $iFeedPage, 'iTotalFeedPages' => 1, 'aFeedVals' => $this->request()->getArray('val'), 'sCustomViewType' => $sCustomViewType, 'aFeedStatusLinks' => Phpfox::getService('feed')->getShareLinks(), 'aFeedCallback' => $aFeedCallback, 'bIsCustomFeedView' => $bIsCustomFeedView ) ); if ($bIsProfile) { if (!Phpfox::getService('user.privacy')->hasAccess($iUserId, 'feed.display_on_profile')) { return false; } } return 'block'; }