Beispiel #1
0
 public function process()
 {
     define('PHPFOX_FEED_STREAM_MODE', true);
     if ($val = $this->request()->get('val')) {
         Phpfox::isUser(true);
         // if (isset($aVals['user_status']) && ($iId = Phpfox::getService('user.process')->updateStatus($aVals)))
         $val['user_status'] = $val['content'];
         $id = Phpfox::getService('user.process')->updateStatus($val);
         Feed_Service_Feed::instance()->processAjax($id);
         echo Phpfox_Ajax::instance()->getData();
         exit;
     }
     $aFeedCallback = [];
     if ($module = $this->request()->get('module')) {
         $aFeedCallback = ['module' => $this->request()->get('module'), 'table_prefix' => $this->request()->get('module') . '_', 'item_id' => $this->request()->get('item_id')];
     }
     $aFeed = Feed_Service_Feed::instance()->callback($aFeedCallback)->get(null, $this->request()->get('id'));
     header('Content-type: application/javascript');
     if (!isset($aFeed[0])) {
         echo ';__(' . json_encode(['url' => $this->url()->makeUrl('feed.stream', ['id' => $this->request()->get('id')]), 'content' => false]) . ');';
         exit;
     }
     $this->template()->assign('aGlobalUser', Phpfox::isUser() ? Phpfox::getUserBy(null) : array());
     $this->template()->assign('aFeed', $aFeed[0]);
     $url = $this->url()->makeUrl('feed.stream', ['id' => $this->request()->get('id')]);
     if ($aFeedCallback) {
         $this->template()->assign('aFeedCallback', $aFeedCallback);
         $url = $this->url()->makeUrl('feed.stream', ['id' => $this->request()->get('id'), 'module' => $this->request()->get('module'), 'item_id' => $this->request()->get('item_id')]);
     }
     $this->template()->getTemplate('feed.block.entry');
     echo ';__(' . json_encode(['url' => $url, 'content' => ob_get_clean()]) . ');';
     exit;
 }
Beispiel #2
0
 /**
  * Controller
  */
 public function process()
 {
     return Phpfox_Error::display('This section has been depreciated');
     Phpfox::getUserParam('comment.can_moderate_comments', true);
     if ($aIds = $this->request()->getArray('id')) {
         if ($this->request()->get('approve')) {
             foreach ($aIds as $iId) {
                 Phpfox::getService('feed.process')->approve($iId);
             }
             $this->url()->send('admincp.feed', array('view' => 'approval'), Phpfox::getPhrase('feed.profile_comment_s_successfully_approved'));
         } else {
             foreach ($aIds as $iId) {
                 Phpfox::getService('feed.process')->deleteFeed($iId);
             }
             $this->url()->send('admincp.feed', array('view' => 'approval'), Phpfox::getPhrase('feed.profile_comment_s_successfully_deleted'));
         }
     }
     $iPage = $this->request()->getInt('page');
     $aPages = array(20, 30, 40, 50);
     $aDisplays = array();
     foreach ($aPages as $iPageCnt) {
         $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt));
     }
     $aFilters = array('search' => array('type' => 'input:text', 'search' => "AND ls.name LIKE '%[VALUE]%'"), 'display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '20'), 'sort' => array('type' => 'select', 'options' => array('time_stamp' => Phpfox::getPhrase('comment.last_activity'), 'rating ' => Phpfox::getPhrase('comment.rating')), 'default' => 'time_stamp', 'alias' => 'feed'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC'));
     $oSearch = Phpfox_Search::instance()->set(array('type' => 'feeds', 'filters' => $aFilters, 'search' => 'search'));
     $oSearch->setCondition('AND feed.view_id = 1');
     list($iCnt, $aFeeds) = Feed_Service_Feed::instance()->getForBrowse($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $oSearch->getDisplay());
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $oSearch->getDisplay(), 'count' => $oSearch->getSearchTotal($iCnt)));
     $this->template()->setTitle(Phpfox::getPhrase('comment.comment_title'))->setBreadcrumb(Phpfox::getPhrase('comment.comment_title'), $this->url()->makeUrl('admincp.comment'))->setHeader('cache', array('comment.css' => 'style_css', 'pager.css' => 'style_css'))->assign(array('aFeeds' => $aFeeds, 'bIsCommentAdminPanel' => true));
 }
Beispiel #3
0
 public function get()
 {
     /*
     @title Get Feeds
     @info Get an activity feed for a specific user.
     @method GET
     @extra user_id=#{User ID#|int|yes}
     @return id=#{Item ID#|int}&title=#{Title of the item|string}&description=#{Description of the item|string}&likes=#{Total number of likes|int}&permalink=#{Link to the item|string}&content=#{Additional text some feeds might have|string}&image=#{Some feeds include an image|string}
     */
     define('PHPFOX_SKIP_LOOP_MAX_COUNT', true);
     $aFeeds = array();
     $aFeedRows = Feed_Service_Feed::instance()->get($this->_oApi->get('user_id'), null, $this->_oApi->get('page'));
     foreach ($aFeedRows as $iKey => $aFeedRow) {
         foreach ($aFeedRow as $sKey => $mValue) {
             if (substr($sKey, 0, 5) == 'feed_') {
                 if (in_array($sKey, array('feed_reference', 'feed_time_stamp', 'feed_icon', 'feed_month_year', 'feed_image_onclick', 'feed_is_liked'))) {
                     continue;
                 }
                 $sKey = str_replace('feed_', '', $sKey);
                 switch ($sKey) {
                     case 'total_like':
                         $sKey = 'likes';
                         break;
                     case 'info':
                         $mValue = '<a href="' . Phpfox_Url::instance()->makeUrl($aFeedRow['user_name']) . '">' . $aFeedRow['full_name'] . '</a> ' . $mValue;
                         break;
                 }
                 $aFeeds[$iKey][$sKey] = $mValue;
             }
         }
     }
     return $aFeeds;
 }
Beispiel #4
0
 /**
  * Controller
  */
 public function process()
 {
     if (!Profile_Service_Profile::instance()->timeline() && !$this->getParam('bIsPage')) {
         return false;
     }
     $aUser = $this->getParam('aUser');
     if ($aUser === null) {
         $aUser = $this->getParam('aPage');
         $this->setParam('aUser', $aUser);
     }
     if (isset($aUser['is_page']) && $aUser['is_page'] && isset($aUser['owner_language_id']) && isset($aUser['link']) && isset($aUser['page_user_id'])) {
         $aUser['user_id'] = $aUser['page_user_id'];
     }
     if (empty($aUser['user_id'])) {
         return false;
     }
     if (!isset($aUser['birthday_search'])) {
         $aUser['birthday_search'] = PHPFOX_TIME;
     }
     if (defined('PHPFOX_IS_PAGES_VIEW')) {
         $aUser['birthday_search'] = Feed_Service_Feed::instance()->getOldPost($aUser['page_id']);
     }
     //$aTimeline = Feed_Service_Feed::instance()->getTimeLineYears($aUser['user_id'], $aUser['birthday_search']);
     if (isset($aUser['birthday']) && $aUser['birthday'] == null) {
         $aTimeline = Feed_Service_Feed::instance()->getTimeLineYears($aUser['user_id'], $aUser['joined']);
     } else {
         $aTimeline = Feed_Service_Feed::instance()->getTimeLineYears($aUser['user_id'], $aUser['birthday_search']);
     }
     $this->template()->assign(array('aTimelineDates' => $aTimeline));
 }
Beispiel #5
0
 public function getUserFeed(&$aUser)
 {
     $aFeeds = Feed_Service_Feed::instance()->get($aUser['user_id']);
     $oXmlBuilder = Phpfox::getLib('xml.builder');
     $oXmlBuilder->setXml(array('version' => '1.0', 'encoding' => 'UTF-8'));
     $oXmlBuilder->addGroup('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'));
     $oXmlBuilder->addGroup('channel');
     $oXmlBuilder->addTag('atom:link', '', array('href' => Phpfox_Url::instance()->makeUrl($aUser['user_name'], 'rss'), 'rel' => 'self', 'type' => 'application/rss+xml'))->addTag('title', Phpfox::getLib('parse.output')->clean($aUser['full_name']))->addTag('link', Phpfox_Url::instance()->makeUrl($aUser['user_name']))->addTag('description', Phpfox::getPhrase('rss.latest_updates_from_full_name', array('full_name' => Phpfox::getLib('parse.output')->clean($aUser['full_name']))));
     $iLog = $this->database()->select('COUNT(*)')->from(Phpfox::getT('rss_log_user'))->where('user_id = ' . $aUser['user_id'] . ' AND id_hash = \'' . Phpfox_Request::instance()->getIdHash() . '\'')->execute('getSlaveField');
     if (!$iLog) {
         $this->database()->insert(Phpfox::getT('rss_log_user'), array('user_id' => $aUser['user_id'], 'id_hash' => Phpfox_Request::instance()->getIdHash(), 'ip_address' => Phpfox::getIp(), 'user_agent' => substr(Phpfox_Request::instance()->getBrowser(), 0, 100), 'time_stamp' => PHPFOX_TIME));
         $this->database()->updateCounter('user_field', 'rss_count', 'user_id', $aUser['user_id']);
     }
     if (is_array($aFeeds) && count($aFeeds)) {
         foreach ($aFeeds as $aItem) {
             $oXmlBuilder->addGroup('item');
             $oXmlBuilder->addTag('title', Phpfox::getLib('parse.output')->clean($aItem['full_name']) . ' ' . strip_tags(!empty($aItem['feed_info']) ? $aItem['feed_info'] : (!empty($aItem['feed_content']) ? $aItem['feed_content'] : '')));
             $oXmlBuilder->addTag('link', $aItem['feed_link']);
             $oXmlBuilder->addTag('description', !empty($aItem['feed_content']) ? $aItem['feed_content'] : '');
             $oXmlBuilder->addTag('guid', $aItem['feed_link']);
             $oXmlBuilder->addTag('pubDate', date('r', $aItem['time_stamp']));
             $oXmlBuilder->addTag('dc:creator', Phpfox::getLib('parse.output')->clean($aItem['full_name']));
             $oXmlBuilder->closeGroup('item');
             // item
         }
     }
     $oXmlBuilder->closeGroup();
     // channel
     $oXmlBuilder->closeGroup();
     // rss
     return $oXmlBuilder->output();
 }
Beispiel #6
0
 /**
  * Controller
  */
 public function process()
 {
     $aLikes = Feed_Service_Feed::instance()->getLikes($this->request()->get('feed_id'));
     if (!count($aLikes)) {
         return Phpfox_Error::set(Phpfox::getPhrase('feed.nobody_likes_this'));
     }
     $this->template()->assign(array('aLikes' => $aLikes));
 }
Beispiel #7
0
 public function process()
 {
     $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;
     }
     $this->template()->assign(['aFeedStatusLinks' => Feed_Service_Feed::instance()->getShareLinks(), 'bLoadCheckIn' => $bLoadCheckIn]);
 }
 /**
  * Controller
  */
 public function process()
 {
     $aRows = Feed_Service_Feed::instance()->get();
     $iCtn = count($aRows);
     if (!$iCtn) {
         return false;
     }
     $this->template()->assign(['iCnt' => $iCtn]);
 }
Beispiel #9
0
 public function getCommentNewsFeed($aRow)
 {
     return false;
     if ($aRow['owner_user_id'] == $aRow['viewer_user_id']) {
         $aRow['text'] = Phpfox::getPhrase('feed.a_href_owner_link_owner_full_name_a_commented_on_their_own_a_href_link_feed_a', array('owner_link' => Phpfox_Url::instance()->makeUrl($aRow['owner_user_name']), 'owner_full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'link' => Phpfox_Url::instance()->makeUrl($aRow['viewer_user_name'], array('feed' => $aRow['item_id'], '#feed'))));
     } else {
         $aRow['text'] = Phpfox::getPhrase('feed.owner_full_name_commented_on_full_names_feed', array('owner_link' => Phpfox_Url::instance()->makeUrl($aRow['owner_user_name']), 'owner_full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'viewer_link' => Phpfox_Url::instance()->makeUrl($aRow['viewer_user_name']), 'viewer_full_name' => $this->preParse()->clean($aRow['viewer_full_name']), 'link' => Phpfox_Url::instance()->makeUrl($aRow['viewer_user_name'], array('feed' => $aRow['item_id'], '#feed'))));
     }
     $aRow['text'] .= Feed_Service_Feed::instance()->quote($aRow['content']);
     return $aRow;
 }
Beispiel #10
0
 public function getCommentNewsFeed($aRow)
 {
     $oUrl = Phpfox_Url::instance();
     $oParseOutput = Phpfox::getLib('parse.output');
     if ($aRow['owner_user_id'] == $aRow['item_id']) {
         $aRow['text'] = Phpfox::getPhrase('profile.a_href_user_link_full_name_a_added_a_new_comment_on_their_own_a_href_title_link_profile_a', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link']));
     } elseif ($aRow['item_id'] == Phpfox::getUserId()) {
         $aRow['text'] = Phpfox::getPhrase('profile.a_href_user_link_full_name_a_added_a_new_comment_on_your_a_href_title_link_profile_a', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link']));
     } else {
         $aRow['text'] = Phpfox::getPhrase('profile.a_href_user_link_full_name_a_added_a_new_comment_on_a_href_title_link_item_user_name_s_a_profile', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link'], 'item_user_name' => $this->preParse()->clean($aRow['viewer_full_name'])));
     }
     $aRow['text'] .= Feed_Service_Feed::instance()->quote($aRow['content']);
     return $aRow;
 }
Beispiel #11
0
 /**
  * Controller
  */
 public function process()
 {
     // Make sure we have an (int) ID#
     if (!($iId = $this->request()->getInt('id'))) {
         return Phpfox_Error::display(Phpfox::getPhrase('feed.missing_feed_id'));
     }
     // Get the feed Link
     $mLink = Feed_Service_Feed::instance()->getRedirect($iId);
     // Is this an actual feed or not?
     if ($mLink === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('feed.invalid_feed_id'));
     }
     // Send them to the correct item
     $this->url()->forward($mLink);
 }
Beispiel #12
0
 /**
  * @return Feed\Object|Feed\Object[]
  */
 public function get($params = null)
 {
     $this->auth();
     $feeds = [];
     $isSingle = false;
     if (is_numeric($params)) {
         $id = (int) $params;
         $params = [];
         $params['id'] = $id;
         $isSingle = true;
     } else {
         if (is_string($params)) {
             $type = $params;
             $params = [];
             $params['type_id'] = $type;
         }
     }
     if (isset($_GET['page'])) {
         $params['page'] = $_GET['page'];
     }
     if (isset($_GET['limit'])) {
         $params['limit'] = $_GET['limit'];
     }
     $params['is_api'] = true;
     $rows = \Feed_Service_Feed::instance()->get($params);
     // d($rows); exit;
     foreach ($rows as $row) {
         $object = ['id' => (int) $row['feed_id'], 'content' => $row['content'], 'total_likes' => (int) $row['feed_total_like'], 'total_comments' => (int) (isset($row['total_comment']) ? $row['total_comment'] : 0), 'user' => $row];
         if ($row['type_id'] != 'app') {
             $object['custom'] = ['item_id' => $row['item_id'], 'url' => $row['feed_link'], 'external_url' => isset($row['feed_link_actual']) ? $row['feed_link_actual'] : '', 'title' => $row['feed_title'], 'description' => isset($row['feed_content']) ? $row['feed_content'] : null, 'time_stamp' => $row['feed_time_stamp'], 'image' => isset($row['feed_image']) ? $row['feed_image'] : null, 'type' => $row['type_id'], 'privacy' => $row['privacy'], 'likes' => $row['feed_total_like'], 'is_liked' => $row['feed_is_liked'], 'comments' => isset($row['total_comment']) ? $row['total_comment'] : 0];
         }
         $feeds[] = new Feed\Object($object);
     }
     if ($isSingle) {
         if (!isset($feeds[0])) {
             throw new \Exception('Unable to find this feed.');
         }
         $feed = $feeds[0];
         if (!$this->isApi() && $feed instanceof Feed\Object) {
             \Phpfox_Component::setPublicParam('aFeed', ['comment_type_id' => 'app', 'privacy' => $feed->custom->privacy, 'comment_privacy' => $feed->custom->privacy, 'like_type_id' => 'app', 'feed_is_liked' => $feed->custom->is_liked, 'item_id' => $feed->custom->item_id, 'user_id' => $feed->user->id, 'total_comment' => $feed->custom->comments, 'total_like' => $feed->custom->likes, 'feed_link' => $feed->custom->url, 'feed_title' => $feed->custom->title, 'feed_display' => 'view', 'feed_total_like' => $feed->custom->likes, 'report_module' => $feed->custom->type, 'report_phrase' => 'Report', 'time_stamp' => $feed->custom->time_stamp]);
         }
         return $feed;
     }
     return $feeds;
 }
Beispiel #13
0
 public function addViaStatusUpdate()
 {
     Phpfox::isUser(true);
     define('PHPFOX_FORCE_IFRAME', true);
     $aVals = (array) $this->get('val');
     $aCallback = null;
     if (isset($aVals['callback_module']) && Phpfox::hasCallback($aVals['callback_module'], 'addLink')) {
         $aCallback = Phpfox::callback($aVals['callback_module'] . '.addLink', $aVals);
     }
     if (!empty($aCallback) && $aCallback['module'] == 'pages') {
         $aPage = Phpfox::getService('pages')->getForView($aCallback['item_id']);
         if (isset($aPage['use_timeline']) && $aPage['use_timeline']) {
             if (!defined('PAGE_TIME_LINE')) {
                 define('PAGE_TIME_LINE', true);
             }
         }
     }
     if ($iId = Phpfox::getService('link.process')->add($aVals, false, $aCallback)) {
         ($sPlugin = Phpfox_Plugin::get('link.component_ajax_addviastatusupdate')) ? eval($sPlugin) : false;
         Feed_Service_Feed::instance()->callback($aCallback)->processAjax($iId);
     }
 }
Beispiel #14
0
 public function processAjax($iId)
 {
     $oAjax = Phpfox_Ajax::instance();
     $aFeeds = Feed_Service_Feed::instance()->get(Phpfox::getUserId(), $iId);
     if (!isset($aFeeds[0])) {
         $oAjax->alert(Phpfox::getPhrase('feed.this_item_has_successfully_been_submitted'));
         $oAjax->call('$Core.resetActivityFeedForm();');
         return;
     }
     if (isset($aFeeds[0]['type_id'])) {
         Phpfox_Template::instance()->assign(array('aFeed' => $aFeeds[0], 'aFeedCallback' => array('module' => str_replace('_comment', '', $aFeeds[0]['type_id']), 'item_id' => $aFeeds[0]['item_id'])))->getTemplate(Profile_Service_Profile::instance()->timeline() ? 'feed.block.timeline' : 'feed.block.entry');
     } else {
         Phpfox_Template::instance()->assign(array('aFeed' => $aFeeds[0]))->getTemplate('feed.block.entry');
     }
     $sId = 'js_tmp_comment_' . md5('feed_' . uniqid() . Phpfox::getUserId()) . '';
     $sNewContent = '<div id="' . $sId . '" class="js_temp_new_feed_entry js_feed_view_more_entry_holder">' . $oAjax->getContent(false) . '</div>';
     if (Profile_Service_Profile::instance()->timeline()) {
         $oAjax->prepend('.timeline_left_new', '<div class="timeline_feed_row"><div class="timeline_arrow_left">0</div><div class="timeline_float_left">0</div>' . $sNewContent . '</div>');
     } else {
         $oAjax->prepend('#js_new_feed_comment', $sNewContent);
     }
     // $oAjax->call('$(\'#' . $sId . '\').highlightFade();');
     $oAjax->removeClass('.js_user_feed', 'row_first');
     $oAjax->call("iCnt = 0; \$('.js_user_feed').each(function(){ iCnt++; if (iCnt == 1) { \$(this).addClass('row_first'); } });");
     if ($oAjax->get('force_form')) {
         $oAjax->call('tb_remove();');
         $oAjax->show('#js_main_feed_holder');
         $oAjax->call('$Core.resetActivityFeedForm();');
     } else {
         $oAjax->call('$Core.resetActivityFeedForm();');
     }
     $oAjax->call('$Core.loadInit();');
 }
Beispiel #15
0
 /**
  * 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));
 }
Beispiel #16
0
 public function addViaStatusUpdate()
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('blog.add_new_blog', true);
     $aVals = $this->get('val');
     $aVals['title'] = $aVals['blog_title'];
     $aVals['text'] = $aVals['status_info'];
     if (Phpfox::getLib('parse.format')->isEmpty($aVals['text'])) {
         $this->call('$Core.resetActivityFeedError(\'' . Phpfox::getPhrase('blog.please_provide_some_text_for_your_blog') . '\');');
     } else {
         if ($iBlogId = Phpfox::getService('blog.process')->add($aVals)) {
             $iId = Phpfox::getService('feed.process')->getLastId();
             ($sPlugin = Phpfox_Plugin::get('blog.component_ajax_addviastatusupdate')) ? eval($sPlugin) : false;
             Feed_Service_Feed::instance()->processAjax($iId);
         }
     }
 }
Beispiel #17
0
 public function addFeedComment()
 {
     Phpfox::isUser(true);
     $aVals = (array) $this->get('val');
     if (!defined('PAGE_TIME_LINE')) {
         // Check if this item is a page and is using time line
         if (isset($aVals['callback_module']) && $aVals['callback_module'] == 'pages' && isset($aVals['callback_item_id']) && Phpfox::getService('pages')->timelineEnabled($aVals['callback_item_id'])) {
             define('PAGE_TIME_LINE', true);
         }
     }
     if (Phpfox::getLib('parse.format')->isEmpty($aVals['user_status'])) {
         $this->alert(Phpfox::getPhrase('user.add_some_text_to_share'));
         $this->call('$Core.activityFeedProcess(false);');
         return;
     }
     $aPage = Phpfox::getService('pages')->getPage($aVals['callback_item_id']);
     if (!isset($aPage['page_id'])) {
         $this->alert(Phpfox::getPhrase('pages.unable_to_find_the_page_you_are_trying_to_comment_on'));
         $this->call('$Core.activityFeedProcess(false);');
         return;
     }
     $sLink = Phpfox::getService('pages')->getUrl($aPage['page_id'], $aPage['title'], $aPage['vanity_url']);
     $aCallback = array('module' => 'pages', 'table_prefix' => 'pages_', 'link' => $sLink, 'email_user_id' => $aPage['user_id'], 'subject' => Phpfox::getPhrase('pages.full_name_wrote_a_comment_on_your_page_title', array('full_name' => Phpfox::getUserBy('full_name'), 'title' => $aPage['title'])), 'message' => Phpfox::getPhrase('pages.full_name_wrote_a_comment_link', array('full_name' => Phpfox::getUserBy('full_name'), 'link' => $sLink, 'title' => $aPage['title'])), 'notification' => $this->get('custom_pages_post_as_page') ? null : 'pages_comment', 'feed_id' => 'pages_comment', 'item_id' => $aPage['page_id']);
     $aVals['parent_user_id'] = $aVals['callback_item_id'];
     if (isset($aVals['user_status']) && ($iId = Phpfox::getService('feed.process')->callback($aCallback)->addComment($aVals))) {
         Phpfox_Database::instance()->updateCounter('pages', 'total_comment', 'page_id', $aPage['page_id']);
         Feed_Service_Feed::instance()->callback($aCallback)->processAjax($iId);
     } else {
         $this->call('$Core.activityFeedProcess(false);');
     }
 }
Beispiel #18
0
 public function getNewsFeedSong_Album($aRow)
 {
     if ($sPlugin = Phpfox_Plugin::get('music.song_album_service_callback_getnewsfeed_start')) {
         eval($sPlugin);
     }
     $aContent = unserialize($aRow['content']);
     $aRow['text'] = Phpfox::getPhrase('music.full_name_uploaded_a_new_song_to_the_album', array('full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'profile_link' => Phpfox_Url::instance()->makeUrl($aRow['owner_user_name']), 'title' => Feed_Service_Feed::instance()->shortenTitle($aContent['title']), 'album_title' => Feed_Service_Feed::instance()->shortenTitle($aContent['album']['name']), 'album_link' => Phpfox_Url::instance()->makeUrl($aRow['owner_user_name'], array('music', $aContent['album']['name_url'])), 'link' => $aRow['link']));
     $aRow['icon'] = 'module/music.png';
     $aRow['enable_like'] = true;
     return $aRow;
 }
Beispiel #19
0
 /**
  * Controller
  */
 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_Module::instance();
         $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');
     }
     $bStreamMode = true;
     $bUseFeedForm = true;
     if (Phpfox_Module::instance()->getFullControllerName() == 'core.index-member' || defined('PHPFOX_CURRENT_TIMELINE_PROFILE') && PHPFOX_CURRENT_TIMELINE_PROFILE == Phpfox::getUserId()) {
         $bUseFeedForm = false;
     }
     if (!Phpfox::isUser() || defined('PHPFOX_IS_PAGES_VIEW') || $sCustomViewType) {
         $bStreamMode = false;
     }
     $bForceReloadOnPage = PHPFOX_IS_AJAX ? false : Phpfox::getParam('feed.force_ajax_on_load');
     $aRows = array();
     if (PHPFOX_IS_AJAX || !$bForceReloadOnPage || $bIsCustomFeedView) {
         $aRows = Feed_Service_Feed::instance()->callback($aFeedCallback)->get($bIsProfile > 0 ? $iUserId : null, $this->request()->get('feed') ? $this->request()->get('feed') : null, $iFeedPage, $bStreamMode);
         if (empty($aRows)) {
             $iFeedPage++;
             $aRows = Feed_Service_Feed::instance()->callback($aFeedCallback)->get($bIsProfile > 0 ? $iUserId : null, $this->request()->get('feed') ? $this->request()->get('feed') : null, $iFeedPage, $bStreamMode);
         }
     }
     /*
     else
     {
     	$aRows = Feed_Service_Feed::instance()->callback($aFeedCallback)->get(($bIsProfile > 0 ? $iUserId : null), ($this->request()->get('feed') ? $this->request()->get('feed') : null), $iFeedPage);
     }
     */
     foreach ($aRows as $iKey => $aRow) {
         if (isset($aRow['feed_mini'])) {
             // unset($aRows[$iKey]['feed_mini'], $aRows[$iKey]['feed_mini'], $aRows[$iKey]['feed_mini_content']);
         }
     }
     // d($aRows); exit;
     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])) {
         if (isset($aRows[0]['feed_total_like'])) {
             $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 = Feed_Service_Feed::instance();
     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('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('bUseFeedForm' => $bUseFeedForm, 'bStreamMode' => $bStreamMode, 'bForceReloadOnPage' => $bForceReloadOnPage, 'bHideEnterComment' => true, 'aFeeds' => $aRows, 'iFeedNextPage' => $bForceReloadOnPage ? 0 : $iFeedPage + 1, 'iFeedCurrentPage' => $iFeedPage, 'iTotalFeedPages' => 1, 'aFeedVals' => $this->request()->getArray('val'), 'sCustomViewType' => $sCustomViewType, 'aFeedStatusLinks' => Feed_Service_Feed::instance()->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));
     return 'block';
 }
Beispiel #20
0
 public function updateStatus()
 {
     Phpfox::isUser(true);
     $aVals = (array) $this->get('val');
     if (isset($aVals['user_status']) && ($iId = Phpfox::getService('user.process')->updateStatus($aVals))) {
         ($sPlugin = Phpfox_Plugin::get('user.component_ajax_updatestatus')) ? eval($sPlugin) : false;
         Feed_Service_Feed::instance()->processAjax($iId);
     } else {
         $this->call('$Core.activityFeedProcess(false);');
     }
 }
Beispiel #21
0
 public function getNewsFeedReply($aRow)
 {
     $oUrl = Phpfox_Url::instance();
     $oParseOutput = Phpfox::getLib('parse.output');
     $aParts = unserialize($aRow['content']);
     $aRow['text'] = Phpfox::getPhrase('forum.full_name_replied_to_the_thread_title_with_link', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'thread_link' => $aRow['link'], 'title' => Feed_Service_Feed::instance()->shortenTitle($aParts['thread_title'])));
     $aRow['icon'] = 'module/forum.png';
     $aRow['enable_like'] = true;
     return $aRow;
 }
Beispiel #22
0
 public function getAll($sType, $iItem)
 {
     $aLikes = $this->getLikes($sType, $iItem);
     $aFeed = array('likes' => $aLikes);
     $aFeed['type_id'] = $sType;
     $aFeed['item_id'] = $iItem;
     $sLikePhrase = Feed_Service_Feed::instance()->getPhraseForLikes($aFeed);
     $aDislikes = $this->getActionsFor($sType, $iItem);
     $aOut = array('likes' => array('total' => count($aLikes), 'phrase' => $sLikePhrase), 'dislikes' => array('total' => isset($aDislikes[2]) ? $aDislikes[2]['total_votes_combined'] : 0, 'phrase' => isset($aDislikes[2]) ? $aDislikes[2]['phrase'] : ''));
     return $aOut;
 }
 public function getCommentNewsFeed($aRow)
 {
     $oUrl = Phpfox_Url::instance();
     $oParseOutput = Phpfox::getLib('parse.output');
     $aPart = unserialize($aRow['content']);
     $aRow['content'] = $aPart['content'];
     $aRow['image_path'] = $aPart['destination'];
     if ($aRow['owner_user_id'] == $aRow['viewer_user_id']) {
         $aRow['text'] = Phpfox::getPhrase('photo.a_href_user_link_full_name_a_added_a_new_comment_on_their_own_a_href_title_link_photo', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['owner_user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link']));
     } else {
         if ($aRow['item_user_id'] == Phpfox::getUserBy('user_id')) {
             $aRow['text'] = Phpfox::getPhrase('photo.a_href_user_link_full_name_a_added_a_new_comment_on_your_a_href_title_link_photo_a', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['owner_user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link']));
         } else {
             $aRow['text'] = Phpfox::getPhrase('photo.a_href_user_link_full_name_a_added_a_new_comment_on', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['owner_user_id'])), 'full_name' => $this->preParse()->clean($aRow['owner_full_name']), 'title_link' => $aRow['link'], 'item_user_name' => $this->preParse()->clean($aRow['viewer_full_name']), 'item_user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['viewer_user_id']))));
         }
     }
     $sImage = '';
     if (!empty($aRow['image_path'])) {
         $sImage = Phpfox::getLib('image.helper')->display(array('server_id' => $aPart['server_id'], 'path' => 'photo.url_photo', 'file' => $aRow['image_path'], 'suffix' => '_50', 'max_width' => 75, 'max_height' => 75, 'style' => 'vertical-align:top; padding-right:5px;'));
         if (isset($aPart['mature'])) {
             if ($aPart['mature'] == 0 || ($aPart['mature'] == 1 || $aPart['mature'] == 2) && Phpfox::getUserId() && Phpfox::getUserParam('photo.photo_mature_age_limit') <= Phpfox::getUserBy('age') || $aRow['user_id'] == Phpfox::getUserId()) {
                 $sImage = '<a href="' . $aRow['link'] . '">' . $sImage . '</a>';
             } elseif ($aPart['mature'] == 1) {
                 $sImage = '<a href="' . $aRow['link'] . '" onclick="tb_show(\'' . Phpfox::getPhrase('photo.warning') . '\', $.ajaxBox(\'photo.warning\', \'height=300&amp;width=350&amp;link=' . $aRow['link'] . '\')); return false;"><img src="' . Phpfox_Template::instance()->getStyle('image', 'misc/no_access.png') . '" alt="" width="100px" /></a>';
             } else {
                 $sImage = '<a href="' . $aRow['link'] . '"' . '><img src="' . Phpfox_Template::instance()->getStyle('image', 'misc/no_access.png') . '" alt="" width="100px" /></a>';
             }
         } else {
             $sImage = '<a href="' . $aRow['link'] . '">' . $sImage . '</a>';
         }
     }
     $aRow['text'] .= '<div class="p_4"><div class="go_left">' . $sImage . '</div><div style="margin-left:75px;">' . Feed_Service_Feed::instance()->quote($aRow['content']) . '</div><div class="clear"></div></div>';
     return $aRow;
 }
Beispiel #24
0
 public function deleteFeed($iId, $sModule = null, $iItem = 0)
 {
     $aCallback = null;
     if (!empty($sModule)) {
         if (Phpfox::hasCallback($sModule, 'getFeedDetails')) {
             $aCallback = Phpfox::callback($sModule . '.getFeedDetails', $iItem);
         }
     }
     $aFeed = Feed_Service_Feed::instance()->callback($aCallback)->getFeed($iId);
     if (!isset($aFeed['feed_id'])) {
         return false;
     }
     // http://www.phpfox.com/tracker/view/15253/
     if ($aFeed['type_id'] == 'photo') {
         Phpfox::callback($aFeed['type_id'] . '.deleteFeedItem', $aFeed['item_id']);
     }
     if ($sPlugin = Phpfox_Plugin::get('feed.service_process_deletefeed')) {
         eval($sPlugin);
     }
     $bCanDelete = false;
     if (Phpfox::getUserParam('feed.can_delete_own_feed') && $aFeed['user_id'] == Phpfox::getUserId()) {
         $bCanDelete = true;
     }
     if (defined('PHPFOX_FEED_CAN_DELETE')) {
         $bCanDelete = true;
     }
     if (Phpfox::getUserParam('feed.can_delete_other_feeds')) {
         $bCanDelete = true;
     }
     if ($bCanDelete === true) {
         if (isset($aCallback['table_prefix'])) {
             $this->database()->delete(Phpfox::getT($aCallback['table_prefix'] . 'feed'), 'feed_id = ' . (int) $iId);
         }
         //$this->database()->delete(Phpfox::getT('feed'), 'feed_id = ' . $aFeed['feed_id'] . ' AND user_id = ' . $aFeed['user_id'] .' AND time_stamp = ' . $aFeed['time_stamp']);
         if ($aFeed['type_id'] == 'feed_comment') {
             $aCore = Phpfox_Request::instance()->getArray('core');
             if (isset($aCore['is_user_profile']) && $aCore['profile_user_id'] != Phpfox::getUserId()) {
                 $this->database()->delete(Phpfox::getT('feed'), 'user_id = ' . $aFeed['user_id'] . ' AND time_stamp = ' . $aFeed['time_stamp'] . ' AND parent_user_id = ' . $aCore['profile_user_id']);
             } elseif (isset($aCore['is_user_profile']) && $aCore['profile_user_id'] == Phpfox::getUserId()) {
                 $this->database()->delete(Phpfox::getT('feed'), 'feed_id = ' . (int) $aFeed['feed_id']);
             }
             $this->database()->delete(Phpfox::getT('feed'), 'user_id = ' . $aFeed['user_id'] . ' AND time_stamp = ' . $aFeed['time_stamp'] . ' AND parent_user_id = ' . Phpfox::getUserId());
         } else {
             $this->database()->delete(Phpfox::getT('feed'), 'user_id = ' . $aFeed['user_id'] . ' AND time_stamp = ' . $aFeed['time_stamp']);
         }
         // Delete likes that belonged to this feed
         $this->database()->delete(Phpfox::getT('like'), 'type_id = "' . $aFeed['type_id'] . '" AND item_id = ' . $aFeed['item_id']);
         if (!empty($sModule)) {
             if (Phpfox::hasCallback($sModule, 'deleteFeedItem')) {
                 Phpfox::callback($sModule . '.deleteFeedItem', $iItem);
             }
         }
         // $this->cache()->remove('feed_' . $aFeed['user_id'], 'substr');
         return true;
     }
     return false;
 }
Beispiel #25
0
 public function getCommentNewsFeed($aRow, $iUserId = null)
 {
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_callback_getcommentnewsfeed__start')) ? eval($sPlugin) : false;
     $oUrl = Phpfox_Url::instance();
     $oParseOutput = Phpfox::getLib('parse.output');
     if ($aRow['owner_user_id'] == $aRow['item_user_id']) {
         $aRow['text'] = Phpfox::getPhrase('blog.user_added_a_new_comment_on_their_own_blog', array('user_name' => $aRow['owner_full_name'], 'user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'title_link' => $aRow['link']));
     } elseif ($aRow['item_user_id'] == Phpfox::getUserBy('user_id')) {
         $aRow['text'] = Phpfox::getPhrase('blog.user_added_a_new_comment_on_your_blog', array('user_name' => $aRow['owner_full_name'], 'user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'title_link' => $aRow['link']));
     } else {
         $aRow['text'] = Phpfox::getPhrase('blog.user_name_added_a_new_comment_on_item_user_name_blog', array('user_name' => $aRow['owner_full_name'], 'user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'title_link' => $aRow['link'], 'item_user_name' => $aRow['viewer_full_name'], 'item_user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['viewer_user_id']))));
     }
     $aRow['text'] .= Feed_Service_Feed::instance()->quote($aRow['content']);
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_callback_getcommentnewsfeed__end')) ? eval($sPlugin) : false;
     return $aRow;
 }
Beispiel #26
0
 public function appendMore()
 {
     $aRows = Feed_Service_Feed::instance()->get();
     $sCustomIds = '';
     foreach ($aRows as $aRow) {
         $sCustomIds .= $aRow['feed_id'];
         $this->template()->assign(array('aFeed' => $aRow));
         $this->template()->getTemplate('feed.block.entry');
     }
     $sIds = 'js_feed_' . md5($sCustomIds);
     $this->call('$(\'.js_parent_feed_entry\').each(function(){$(this).removeClass(\'row_first\');});');
     $this->prepend('#js_new_feed_update', '<div id="' . $sIds . '" style="display:none;">' . $this->getContent(false) . '</div>');
     $this->hide('#activity_feed_updates_link_holder');
     $this->slideDown('#' . $sIds);
     $this->call('$Core.loadInit();');
 }
Beispiel #27
0
 public function addFeedComment()
 {
     Phpfox::isUser(true);
     $aVals = (array) $this->get('val');
     if (Phpfox::getLib('parse.format')->isEmpty($aVals['user_status'])) {
         $this->alert(Phpfox::getPhrase('user.add_some_text_to_share'));
         $this->call('$Core.activityFeedProcess(false);');
         return;
     }
     $aEvent = Event_Service_Event::instance()->getForEdit($aVals['callback_item_id'], true);
     if (!isset($aEvent['event_id'])) {
         $this->alert(Phpfox::getPhrase('event.unable_to_find_the_event_you_are_trying_to_comment_on'));
         $this->call('$Core.activityFeedProcess(false);');
         return;
     }
     $sLink = Phpfox::permalink('event', $aEvent['event_id'], $aEvent['title']);
     $aCallback = array('module' => 'event', 'table_prefix' => 'event_', 'link' => $sLink, 'email_user_id' => $aEvent['user_id'], 'subject' => Phpfox::getPhrase('event.full_name_wrote_a_comment_on_your_event_title', array('full_name' => Phpfox::getUserBy('full_name'), 'title' => $aEvent['title'])), 'message' => Phpfox::getPhrase('event.full_name_wrote_a_comment_on_your_event_message', array('full_name' => Phpfox::getUserBy('full_name'), 'link' => $sLink, 'title' => $aEvent['title'])), 'notification' => 'event_comment', 'feed_id' => 'event_comment', 'item_id' => $aEvent['event_id']);
     $aVals['parent_user_id'] = $aVals['callback_item_id'];
     if (isset($aVals['user_status']) && ($iId = Phpfox::getService('feed.process')->callback($aCallback)->addComment($aVals))) {
         Phpfox_Database::instance()->updateCounter('event', 'total_comment', 'event_id', $aEvent['event_id']);
         Feed_Service_Feed::instance()->callback($aCallback)->processAjax($iId);
     } else {
         $this->call('$Core.activityFeedProcess(false);');
     }
 }
Beispiel #28
0
 public function addViaStatusUpdate()
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('poll.can_create_poll', true);
     $this->error(false);
     $aVals = (array) $this->get('val');
     $aVals['question'] = $aVals['poll_question'];
     $iFlood = Phpfox::getUserParam('poll.poll_flood_control');
     if ($iFlood != '0') {
         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('poll'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
         // actually check if flooding
         if (Phpfox::getLib('spam')->check($aFlood)) {
             // Set an error
             Phpfox_Error::set(Phpfox::getPhrase('poll.poll_flood_control', array('x' => $iFlood)));
         }
     }
     $mErrors = Phpfox::getService('poll')->checkStructure($aVals);
     if (is_array($mErrors)) {
         foreach ($mErrors as $sError) {
             Phpfox_Error::set($sError);
         }
     }
     $bIsError = false;
     if (Phpfox_Error::isPassed()) {
         // check if question has a question mark
         if (strpos($aVals['question'], '?') === false) {
             $aVals['question'] = $aVals['question'] . '?';
         }
         if (list($iPollId, $aPoll) = Phpfox::getService('poll.process')->add(Phpfox::getUserId(), $aVals)) {
             $iId = Phpfox::getService('feed.process')->getLastId();
             ($sPlugin = Phpfox_Plugin::get('user.component_ajax_addviastatusupdate')) ? eval($sPlugin) : false;
             Feed_Service_Feed::instance()->processAjax($iId);
         } else {
             $bIsError = true;
         }
     } else {
         $bIsError = true;
     }
     if ($bIsError) {
         $this->call('$Core.resetActivityFeedError(\'' . implode('<br />', Phpfox_Error::get()) . '\');');
     } else {
         $this->call('$("#global_attachment_poll input:text").val(" ");');
     }
 }
Beispiel #29
0
 public function getThread($aThreadCondition = array(), $mConditions = array(), $sOrder = 'fp.time_stamp ASC', $iPage = '', $iPageSize = '', $sPermaView = null)
 {
     if (Phpfox::getParam('forum.forum_database_tracking')) {
         $this->database()->select('ftr.thread_id AS is_seen, ftr.time_stamp AS last_seen_time, ')->leftJoin(Phpfox::getT('forum_thread_track'), 'ftr', 'ftr.thread_id = ft.thread_id AND ftr.user_id = ' . Phpfox::getUserId());
     }
     $aThread = $this->database()->select('ft.thread_id, ft.time_stamp, ft.time_update, ft.group_id, ft.view_id, ft.forum_id, ft.is_closed, ft.user_id, ft.is_announcement, ft.order_id, ft.title_url, ft.time_update AS last_time_stamp, ft.title, fs.subscribe_id AS is_subscribed, ft.poll_id')->from($this->_sTable, 'ft')->leftJoin(Phpfox::getT('forum_subscribe'), 'fs', 'fs.thread_id = ft.thread_id AND fs.user_id = ' . Phpfox::getUserId())->where($aThreadCondition)->execute('getSlaveRow');
     if (!isset($aThread['thread_id'])) {
         return array(0, array());
     }
     if (!isset($aThread['is_seen'])) {
         $aThread['is_seen'] = 0;
     }
     // Thread not seen
     if (!$aThread['is_seen']) {
         // User has signed up after the post so they have already seen the post
         if (Phpfox::isUser() && Phpfox::getUserBy('joined') > $aThread['last_time_stamp'] || !Phpfox::isUser() && Phpfox::getCookie('visit') > $aThread['last_time_stamp']) {
             $aThread['is_seen'] = 1;
         } elseif (($iLastTimeViewed = Phpfox::getLib('session')->getArray('forum_view', $aThread['thread_id'])) && (int) $iLastTimeViewed > $aThread['last_time_stamp']) {
             $aThread['is_seen'] = 1;
         } elseif (PHPFOX_TIME - Phpfox::getParam('forum.keep_active_posts') * 60 > $aThread['last_time_stamp']) {
             $aThread['is_seen'] = 1;
         }
         // http://www.phpfox.com/tracker/view/14893/
         /*elseif (!empty($aThread['last_time_stamp']) && Phpfox::isUser() && $aThread['last_time_stamp'] < Phpfox::getCookie('last_login'))
         		{
         			$aThread['is_seen'] = 1;
         		}*/
     } else {
         // New post was added
         if ($aThread['last_time_stamp'] > $aThread['last_seen_time']) {
             $aThread['is_seen'] = 0;
         }
     }
     $sViewId = ' AND fp.view_id = 0';
     if (Phpfox::getUserParam('forum.can_approve_forum_post') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_post')) {
         $sViewId = '';
     }
     $mConditions[] = 'fp.thread_id = ' . $aThread['thread_id'] . $sViewId;
     $iCnt = $this->database()->select('COUNT(*)')->from(Phpfox::getT('forum_post'), 'fp')->where($mConditions)->execute('getSlaveField');
     $aThread['last_update_on'] = '';
     if ($sPermaView !== null) {
         $iCurrentPage = Phpfox::getService('forum.post')->getPostPage($aThread['thread_id'], $sPermaView, $iPageSize);
         $mConditions[] = 'AND fp.post_id = ' . (int) $sPermaView;
     }
     if (!empty($aThread['poll_id']) && Phpfox::isModule('poll')) {
         $aThread['poll'] = Phpfox::getService('poll')->getPollByUrl((int) $aThread['poll_id']);
         $aThread['poll']['bCanEdit'] = false;
     }
     ($sPlugin = Phpfox_Plugin::get('forum.service_thread_getthread_query')) ? eval($sPlugin) : false;
     if (!isset($bLeftJoinQuery)) {
         $bLeftJoinQuery = false;
     }
     $theJoins = function () use($bLeftJoinQuery) {
         if (isset($bLeftJoinQuery) && $bLeftJoinQuery !== false) {
             $this->database()->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->leftJoin(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id');
         } else {
             $this->database()->join(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id');
         }
         if (Phpfox::isModule('like')) {
             $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'forum_post\' AND l.item_id = fp.post_id AND l.user_id = ' . Phpfox::getUserId());
         }
     };
     if (!$iPage) {
         $theJoins();
         $aThread['post_starter'] = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->where($mConditions)->order('fp.time_stamp ASC')->limit(1)->get();
     }
     if (!$iPage) {
         $iPageSize = 4;
         $sOrder = 'fp.time_stamp DESC';
     }
     $theJoins();
     $aThread['posts'] = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->where($mConditions)->order($sOrder)->limit($iPage, $iPageSize, $iCnt, false, false)->execute('getSlaveRows');
     if (!count($aThread['posts'])) {
         throw error('no_items');
     }
     if (isset($aThread['post_starter'])) {
         // $aThread['posts'] = array_merge($aThread['post_starter'], $aThread['posts']);
         $aThread['posts'][] = $aThread['post_starter'];
         $aThread['posts'] = array_reverse($aThread['posts']);
     }
     $sPostIds = '';
     $iTotal = $iPage > 1 ? $iPageSize * $iPage - $iPageSize : 0;
     foreach ($aThread['posts'] as $iKey => $aPost) {
         $iTotal++;
         /*
         if ($aPost['cache_name']) {
         	$aThread['posts'][$iKey]['user_id'] = 0;
         	$aThread['posts'][$iKey]['user_image'] = '';
         	$aThread['posts'][$iKey]['full_name'] = $aPost['cache_name'];
         	$aThread['posts'][$iKey]['no_link'] = true;
         }
         */
         $aThread['posts'][$iKey]['count'] = $sPermaView === null ? $iTotal : Phpfox::getService('forum.post')->getPostCount();
         $aThread['posts'][$iKey]['forum_id'] = $aThread['forum_id'];
         $aThread['posts'][$iKey]['last_update_on'] = Phpfox::getPhrase('forum.last_update_on_time_stamp_by_update_user', array('time_stamp' => Phpfox::getTime(Phpfox::getParam('forum.forum_time_stamp'), $aPost['update_time']), 'update_user' => $aPost['update_user']));
         $aThread['posts'][$iKey]['aFeed'] = array('privacy' => 0, 'comment_privacy' => 0, 'like_type_id' => 'forum_post', 'feed_is_liked' => $aPost['is_liked'] ? true : false, 'item_id' => $aPost['post_id'], 'user_id' => $aPost['user_id'], 'total_like' => $aPost['total_like'], 'feed_link' => Phpfox::permalink('forum.thread', $aThread['thread_id'], $aThread['title']) . 'view_' . $aPost['post_id'] . '/', 'feed_title' => $aThread['title'], 'feed_display' => 'mini', 'feed_total_like' => $aPost['total_like'], 'report_module' => 'forum_post', 'report_phrase' => Phpfox::getPhrase('forum.report_this_post'), 'force_report' => true, 'time_stamp' => $aPost['time_stamp'], 'type_id' => 'forum_post');
         if (Phpfox::isModule('like') && Phpfox::isModule('feed')) {
             $aThread['posts'][$iKey]['aFeed']['feed_like_phrase'] = Feed_Service_Feed::instance()->getPhraseForLikes($aThread['posts'][$iKey]['aFeed']);
         }
         if (isset($aThread['post_starter']) && $aThread['post_starter']['post_id'] == $aPost['post_id']) {
             $aThread['post_starter'] = array_merge($aThread['post_starter'], $aThread['posts'][$iKey]);
             unset($aThread['posts'][$iKey]);
             continue;
         }
         if ($aPost['total_attachment']) {
             $sPostIds .= $aPost['post_id'] . ',';
         }
     }
     $sPostIds = rtrim($sPostIds, ',');
     if (!empty($sPostIds)) {
         list($iAttachmentCnt, $aAttachments) = Phpfox::getService('attachment')->get('attachment.item_id IN(' . $sPostIds . ') AND attachment.view_id = 0 AND attachment.category_id = \'forum\' AND attachment.is_inline = 0', 'attachment.attachment_id DESC', '', '', false);
         $aAttachmentCache = array();
         foreach ($aAttachments as $aAttachment) {
             $aAttachmentCache[$aAttachment['item_id']][] = $aAttachment;
         }
         foreach ($aThread['posts'] as $iKey => $aPost) {
             if (isset($aAttachmentCache[$aPost['post_id']])) {
                 $aThread['posts'][$iKey]['attachments'] = $aAttachmentCache[$aPost['post_id']];
             }
         }
     }
     return array($iCnt, $aThread);
 }
Beispiel #30
-1
 public function process()
 {
     $feed = Feed_Service_Feed::instance()->getForItem($this->request()->get('type'), $this->request()->get('id'));
     $aFeed = Feed_Service_Feed::instance()->get(null, $feed['feed_id']);
     $this->setParam('aFeed', array_merge($aFeed[0], ['feed_display' => 'view']));
     $this->template()->assign('showOnlyComments', true);
     $this->template()->assign('nextIteration', (int) $this->request()->get('page') + 1);
     Phpfox::getBlock('feed.comment');
     $out = "var comment = " . json_encode(['html' => ob_get_contents()]) . "; ";
     $out .= "\$('#js_feed_comment_pager_{$this->request()->get('id')}').prepend(comment.html); \$Core.loadInit();";
     $out .= "obj.remove();";
     ob_clean();
     header('Content-type: application/json');
     echo json_encode(['run' => $out]);
     exit;
 }