コード例 #1
0
ファイル: callback.class.php プロジェクト: nima7r/phpfox-dist
 public function getActivityFeedComment($aRow)
 {
     if (Phpfox::isUser() && Phpfox::isModule('like')) {
         $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'feed_mini\' AND l.item_id = c.comment_id AND l.user_id = ' . Phpfox::getUserId());
     }
     $aItem = $this->database()->select('b.poll_id, b.privacy, b.question, b.time_stamp, b.total_comment, b.total_like, c.total_like, ct.text_parsed AS text, f.friend_id AS is_friend, ' . Phpfox::getUserField())->from(Phpfox::getT('comment'), 'c')->join(Phpfox::getT('comment_text'), 'ct', 'ct.comment_id = c.comment_id')->join(Phpfox::getT('poll'), 'b', 'c.type_id = \'poll\' AND c.item_id = b.poll_id AND c.view_id = 0')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->leftJoin(Phpfox::getT('friend'), 'f', "f.user_id = b.user_id AND f.friend_user_id = " . Phpfox::getUserId())->where('c.comment_id = ' . (int) $aRow['item_id'])->execute('getSlaveRow');
     if (!isset($aItem['poll_id'])) {
         return false;
     }
     $bCanViewItem = true;
     if (Phpfox::isModule('privacy') && $aItem['privacy'] > 0) {
         $bCanViewItem = Privacy_Service_Privacy::instance()->check('poll', $aItem['poll_id'], $aItem['user_id'], $aItem['privacy'], $aItem['is_friend'], true);
     }
     if (!$bCanViewItem) {
         return false;
     }
     $sLink = Phpfox::permalink('poll', $aItem['poll_id'], $aItem['question']);
     $sTitle = Phpfox::getLib('parse.output')->shorten($aItem['question'], Phpfox::isModule('notification') ? Phpfox::getParam('notification.total_notification_title_length') : 50);
     $sUser = '******' . Phpfox_Url::instance()->makeUrl($aItem['user_name']) . '">' . $aItem['full_name'] . '</a>';
     $sGender = Phpfox::getService('user')->gender($aItem['gender'], 1);
     if ($aRow['user_id'] == $aItem['user_id']) {
         $sMessage = Phpfox::getPhrase('poll.posted_a_comment_on_gender_poll_a_href_link_title_a', array('gender' => $sGender, 'link' => $sLink, 'title' => $sTitle));
     } else {
         $sMessage = Phpfox::getPhrase('poll.posted_a_comment_on_user_name_s_poll_a_href_link_title_a', array('user_name' => $sUser, 'link' => $sLink, 'title' => $sTitle));
     }
     return array('no_share' => true, 'feed_info' => $sMessage, 'feed_link' => $sLink, 'feed_status' => $aItem['text'], 'feed_total_like' => $aItem['total_like'], 'feed_is_liked' => isset($aItem['is_liked']) ? $aItem['is_liked'] : false, 'feed_icon' => Phpfox::getLib('image.helper')->display(array('theme' => 'module/poll.png', 'return_url' => true)), 'time_stamp' => $aRow['time_stamp'], 'like_type_id' => 'feed_mini');
 }
コード例 #2
0
ファイル: build.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     $aPrivacySettings = Privacy_Service_Privacy::instance()->get($this->getParam('privacy_module_id'), $this->getParam('privacy_item_id'));
     if (!count($aPrivacySettings)) {
         return false;
     }
     $this->template()->assign(array('aPrivacySettings' => $aPrivacySettings, 'sPrivacyArray' => $this->getParam('privacy_array', null)));
 }
コード例 #3
0
ファイル: list.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     $aUsers = array();
     if ($this->getParam('id')) {
         $aUsers = Privacy_Service_Privacy::instance()->get($this->getParam('type'), $this->getParam('id'));
     }
     $this->template()->assign(array('aPrivacyUsers' => $aUsers, 'sPrivacyInputName' => $this->getParam('input')));
 }
コード例 #4
0
ファイル: process.class.php プロジェクト: lev1976g/core
 public function add($sType, $iItemId, $iUserId = null)
 {
     $bIsNotNull = false;
     if ($iUserId === null) {
         $iUserId = Phpfox::getUserId();
         $bIsNotNull = true;
     }
     if ($sType == 'pages') {
         $bIsNotNull = false;
     }
     // check if iUserId can Like this item
     $aFeed = $this->database()->select('privacy, user_id')->from(Phpfox::getT('feed'))->where('item_id = ' . (int) $iItemId . ' AND type_id = "' . Phpfox::getLib('parse.input')->clean($sType) . '"')->execute('getSlaveRow');
     /* if (($sType != 'pages') && $sType != 'event' && empty($aFeed))
     		{
     			return Phpfox_Error::display('Item does not exist.');
     		}
     		*/
     if (!empty($aFeed) && isset($aFeed['privacy']) && !empty($aFeed['privacy']) && !empty($aFeed['user_id']) && $aFeed['user_id'] != $iUserId) {
         if ($aFeed['privacy'] == 1 && Friend_Service_Friend::instance()->isFriend($iUserId, $aFeed['user_id']) != true) {
             return Phpfox_Error::display('Not allowed to like this item.');
         } else {
             if ($aFeed['privacy'] == 2 && Friend_Service_Friend::instance()->isFriendOfFriend($iUserId) != true) {
                 return Phpfox_Error::display('Not allowed to like this item.');
             } else {
                 if ($aFeed['privacy'] == 3 && $aFeed['user_id'] != Phpfox::getUserId()) {
                     return Phpfox_Error::display('Not allowed to like this item.');
                 } else {
                     if ($aFeed['privacy'] == 4 && ($bCheck = Privacy_Service_Privacy::instance()->check($sType, $iItemId, $aFeed['user_id'], $aFeed['privacy'], null, true)) != true) {
                         return Phpfox_Error::display('Not allowed to like this item.');
                     }
                 }
             }
         }
     }
     $iCheck = $this->database()->select('COUNT(*)')->from(Phpfox::getT('like'))->where('type_id = \'' . $this->database()->escape($sType) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . $iUserId)->execute('getField');
     if ($iCheck) {
         return Phpfox_Error::set(Phpfox::getPhrase('feed.you_have_already_liked_this_feed'));
     }
     $iCnt = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('like_cache'))->where('type_id = \'' . $this->database()->escape($sType) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . (int) $iUserId)->execute('getSlaveField');
     $this->database()->insert($this->_sTable, array('type_id' => $sType, 'item_id' => (int) $iItemId, 'user_id' => $iUserId, 'time_stamp' => PHPFOX_TIME));
     $iCnt = 0;
     if (!$iCnt) {
         $this->database()->insert(Phpfox::getT('like_cache'), array('type_id' => $sType, 'item_id' => (int) $iItemId, 'user_id' => $iUserId));
     }
     Phpfox::getService('feed.process')->clearCache($sType, $iItemId);
     if ($sPlugin = Phpfox_Plugin::get('like.service_process_add__1')) {
         eval($sPlugin);
     }
     Phpfox::callback($sType . '.addLike', $iItemId, $iCnt ? true : false, $bIsNotNull ? null : $iUserId);
     return true;
 }
コード例 #5
0
ファイル: view.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     if ($playId = $this->request()->get('play')) {
         Music_Service_Process::instance()->play($this->request()->get('play'));
         return ['played' => true];
     }
     Phpfox::getUserParam('music.can_access_music', true);
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_music_song', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_song_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if (!($aSong = Phpfox::getService('music')->getSong($this->request()->get('req2')))) {
         return Phpfox_Error::display(Phpfox::getPhrase('music.the_song_you_are_looking_for_cannot_be_found'));
     }
     if (Phpfox::isModule('notification') && $aSong['user_id'] == Phpfox::getUserId()) {
         Phpfox::getService('notification.process')->delete('music_songapproved', $aSong['song_id'], Phpfox::getUserId());
     }
     $aCallback = false;
     if (!empty($aSong['module_id'])) {
         if ($aCallback = Phpfox::callback($aSong['module_id'] . '.getMusicDetails', $aSong)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             if ($aSong['module_id'] == 'pages' && !Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'music.view_browse_music')) {
                 return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_view_this_item_due_to_privacy_settings'));
             }
         }
     }
     Phpfox::getService('core.redirect')->check($aSong['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('music_song', $aSong['song_id'], $aSong['user_id'], $aSong['privacy'], $aSong['is_friend']);
     }
     $this->setParam('aSong', $aSong);
     $this->setParam('aRatingCallback', array('type' => 'music_song', 'total_rating' => Phpfox::getPhrase('music.total_rating_ratings', array('total_rating' => $aSong['total_rating'])), 'default_rating' => $aSong['total_score'], 'item_id' => $aSong['song_id'], 'stars' => array('2' => Phpfox::getPhrase('music.poor'), '4' => Phpfox::getPhrase('music.nothing_special'), '6' => Phpfox::getPhrase('music.worth_listening_too'), '8' => Phpfox::getPhrase('music.pretty_cool'), '10' => Phpfox::getPhrase('music.awesome'))));
     $this->template()->setBreadcrumb(Phpfox::getPhrase('music.music'), $aCallback === false ? $this->url()->makeUrl('music') : $aCallback['url_home_photo']);
     if (!empty($aSong['album_url'])) {
         $this->template()->setBreadcrumb($aSong['album_url'], $this->url()->permalink('music.album', $aSong['album_id'], $aSong['album_url']));
     }
     $this->template()->setBreadcrumb($aSong['title'], $this->url()->permalink('music', $aSong['song_id'], $aSong['title']), true);
     $this->setParam('aFeed', array('comment_type_id' => 'music_song', 'privacy' => $aSong['privacy'], 'comment_privacy' => $aSong['privacy_comment'], 'like_type_id' => 'music_song', 'feed_is_liked' => $aSong['is_liked'], 'feed_is_friend' => $aSong['is_friend'], 'item_id' => $aSong['song_id'], 'user_id' => $aSong['user_id'], 'total_comment' => $aSong['song_total_comment'], 'total_like' => $aSong['total_like'], 'feed_link' => $this->url()->permalink('music', $aSong['song_id'], $aSong['title']), 'feed_title' => $aSong['title'], 'feed_display' => 'view', 'feed_total_like' => $aSong['total_like'], 'report_module' => 'music_song', 'report_phrase' => Phpfox::getPhrase('music.report_this_song_lowercase')));
     if (Phpfox::isModule('rate')) {
         $this->template()->setPhrase(array('rate.thanks_for_rating'))->setHeader('cache', array('rate.js' => 'module_rate'))->setHeader(array('<script type="text/javascript">$Behavior.rateSong = function() {  $Core.rate.init({module: \'music_song\', display: ' . ($aSong['has_rated'] ? 'false' : ($aSong['user_id'] == Phpfox::getUserId() ? 'false' : 'true')) . ', error_message: \'' . ($aSong['has_rated'] ? Phpfox::getPhrase('music.you_have_already_voted', array('phpfox_squote' => true)) : Phpfox::getPhrase('music.you_cannot_rate_your_own_song', array('phpfox_squote' => true))) . '\'}); }</script>'));
     }
     $this->template()->setTitle($aSong['title'])->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('user' => $aSong, 'suffix' => '_50', 'return_url' => true)))->setMeta('description', $aSong['title'])->setHeader('cache', array('jquery/plugin/star/jquery.rating.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'jquery.rating.css' => 'style_css', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed', 'view.css' => 'module_music'))->setHeader(array('<script type="text/javascript">var bLoadedMusicSong = false; $Behavior.playSongOnView = function() { bLoadedMusicSong = false; if ($(\'#js_music_player\').length > 0) { $Core.player.load({on_start: function() { if (!bLoadedMusicSong) {  bLoadedMusicSong = true; $.ajaxCall(\'music.play\', \'id=' . $aSong['song_id'] . '\', \'GET\'); } }, id: \'js_music_player\', type: \'music\', auto: true, play: \'' . $aSong['song_path'] . '\'}); } $Behavior.playSongOnView = function() {}; }</script>'))->setEditor(array('load' => 'simple'))->assign(array('aSong' => $aSong));
     if ($sPlugin = Phpfox_Plugin::get('music.component_controller_music_view')) {
         eval($sPlugin);
     }
 }
コード例 #6
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('music.can_access_music', true);
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_music_album', $this->request()->getInt('req3'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_song_album', $this->request()->getInt('req3'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_album_like', $this->request()->getInt('req3'), Phpfox::getUserId());
     }
     $aAlbum = Phpfox::getService('music.album')->getAlbum($this->request()->getInt('req3'));
     if (!isset($aAlbum['album_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_find_the_album_you_are_looking_for'));
     }
     $aCallback = false;
     if (!empty($aAlbum['module_id'])) {
         if ($aCallback = Phpfox::callback($aAlbum['module_id'] . '.getMusicDetails', $aAlbum)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             if ($aAlbum['module_id'] == 'pages' && !Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'music.view_browse_music')) {
                 return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_view_this_item_due_to_privacy_settings'));
             }
         }
     }
     Phpfox::getService('core.redirect')->check($aAlbum['name'], 'req4');
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('music_album', $aAlbum['album_id'], $aAlbum['user_id'], $aAlbum['privacy'], $aAlbum['is_friend']);
     }
     $this->setParam('aAlbum', $aAlbum);
     $this->setParam('aRatingCallback', array('type' => 'music_album', 'total_rating' => Phpfox::getPhrase('music.total_rating_ratings', array('total_rating' => $aAlbum['total_rating'])), 'default_rating' => $aAlbum['total_score'], 'item_id' => $aAlbum['album_id'], 'stars' => array('2' => Phpfox::getPhrase('music.poor'), '4' => Phpfox::getPhrase('music.nothing_special'), '6' => Phpfox::getPhrase('music.worth_listening_too'), '8' => Phpfox::getPhrase('music.pretty_cool'), '10' => Phpfox::getPhrase('music.awesome'))));
     $this->setParam('aFeed', array('comment_type_id' => 'music_album', 'privacy' => $aAlbum['privacy'], 'comment_privacy' => $aAlbum['privacy_comment'], 'like_type_id' => 'music_album', 'feed_is_liked' => $aAlbum['is_liked'], 'feed_is_friend' => $aAlbum['is_friend'], 'item_id' => $aAlbum['album_id'], 'user_id' => $aAlbum['user_id'], 'total_comment' => $aAlbum['total_comment'], 'total_like' => $aAlbum['total_like'], 'feed_link' => $this->url()->permalink('music.album', $aAlbum['album_id'], $aAlbum['name']), 'feed_title' => $aAlbum['name'], 'feed_display' => 'view', 'feed_total_like' => $aAlbum['total_like'], 'report_module' => 'music_album', 'report_phrase' => Phpfox::getPhrase('music.report_this_album')));
     $this->setParam(array('album_user_id' => $aAlbum['user_id'], 'album_id' => $aAlbum['album_id']));
     $this->template()->setBreadcrumb(Phpfox::getPhrase('music.music'), $aCallback === false ? $this->url()->makeUrl('music') : $aCallback['url_home_photo']);
     if ($aCallback === false) {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('music.albums'), $this->url()->makeUrl('music.browse.album'));
     }
     define('PHPFOX_IS_ALBUM_VIEW', true);
     if (Phpfox::isModule('rate')) {
         $this->template()->setPhrase(array('rate.thanks_for_rating'))->setHeader('cache', array('rate.js' => 'module_rate', '<script type="text/javascript">$Behavior.rateMusicAlbum = function() { $Core.rate.init({module: \'music_album\', display: ' . ($aAlbum['has_rated'] ? 'false' : ($aAlbum['user_id'] == Phpfox::getUserId() ? 'false' : 'true')) . ', error_message: \'' . ($aAlbum['has_rated'] ? Phpfox::getPhrase('music.you_have_already_voted', array('phpfox_squote' => true)) : Phpfox::getPhrase('music.you_cannot_rate_your_own_album', array('phpfox_squote' => true))) . '\'}); }</script>'));
     }
     $this->template()->setTitle($aAlbum['name']);
     if (!empty($aAlbum['image_path'])) {
         $this->template()->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('server_id' => $aAlbum['server_id'], 'path' => 'music.url_image', 'file' => $aAlbum['image_path'], 'suffix' => '_200', 'return_url' => true)));
     }
     $this->template()->setBreadcrumb($aAlbum['name'], $this->url()->permalink('music.album', $aAlbum['album_id'], $aAlbum['name']), true)->setMeta('description', $aAlbum['name'])->setHeader('cache', array('jquery/plugin/star/jquery.rating.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'feed.js' => 'module_feed', 'album.js' => 'module_music'))->setEditor(array('load' => 'simple'))->assign(array('aAlbum' => $aAlbum));
 }
コード例 #7
0
ファイル: view.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     if ($this->request()->get('req2') == 'view' && ($sLegacyTitle = $this->request()->get('req3')) && !empty($sLegacyTitle)) {
         Phpfox::getService('core')->getLegacyItem(array('field' => array('listing_id', 'title'), 'table' => 'marketplace', 'redirect' => 'marketplace', 'title' => $sLegacyTitle));
     }
     Phpfox::getUserParam('marketplace.can_access_marketplace', true);
     if (!($iListingId = $this->request()->get('req2'))) {
         $this->url()->send('marketplace');
     }
     if (!($aListing = Phpfox::getService('marketplace')->getListing($iListingId))) {
         return Phpfox_Error::display(Phpfox::getPhrase('marketplace.the_listing_you_are_looking_for_either_does_not_exist_or_has_been_removed'));
     }
     $this->setParam('aListing', $aListing);
     if (Phpfox::isUser() && $aListing['invite_id'] && !$aListing['visited_id'] && $aListing['user_id'] != Phpfox::getUserId()) {
         Phpfox::getService('marketplace.process')->setVisit($aListing['listing_id'], Phpfox::getUserId());
     }
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_marketplace', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('marketplace_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if (Phpfox::isModule('notification') && $aListing['user_id'] == Phpfox::getUserId()) {
         Phpfox::getService('notification.process')->delete('marketplace_approved', $aListing['listing_id'], Phpfox::getUserId());
     }
     Phpfox::getService('core.redirect')->check($aListing['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('marketplace', $aListing['listing_id'], $aListing['user_id'], $aListing['privacy'], $aListing['is_friend']);
     }
     $this->setParam('aRatingCallback', array('type' => 'user', 'default_rating' => $aListing['total_score'], 'item_id' => $aListing['user_id'], 'stars' => range(1, 10)));
     $this->setParam('aFeed', array('comment_type_id' => 'marketplace', 'privacy' => $aListing['privacy'], 'comment_privacy' => $aListing['privacy_comment'], 'like_type_id' => 'marketplace', 'feed_is_liked' => $aListing['is_liked'], 'feed_is_friend' => $aListing['is_friend'], 'item_id' => $aListing['listing_id'], 'user_id' => $aListing['user_id'], 'total_comment' => $aListing['total_comment'], 'total_like' => $aListing['total_like'], 'feed_link' => $this->url()->permalink('marketplace', $aListing['listing_id'], $aListing['title']), 'feed_title' => $aListing['title'], 'feed_display' => 'view', 'feed_total_like' => $aListing['total_like'], 'report_module' => 'marketplace', 'report_phrase' => Phpfox::getPhrase('marketplace.report_this_listing_lowercase')));
     $sExchangeRate = '';
     if ($aListing['currency_id'] != Phpfox::getService('core.currency')->getDefault()) {
         if ($sAmount = Phpfox::getService('core.currency')->getXrate($aListing['currency_id'], $aListing['price'])) {
             $sExchangeRate .= ' (' . Phpfox::getService('core.currency')->getCurrency($sAmount) . ')';
         }
     }
     $this->template()->setTitle($aListing['title'] . ($aListing['view_id'] == '2' ? ' (' . Phpfox::getPhrase('marketplace.sold') . ')' : ''))->setBreadcrumb(Phpfox::getPhrase('marketplace.marketplace'), $this->url()->makeUrl('marketplace'))->setMeta('description', $aListing['description'])->setMeta('keywords', $this->template()->getKeywords($aListing['title'] . $aListing['description']))->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('server_id' => $aListing['listing_id'], 'path' => 'marketplace.url_image', 'file' => $aListing['image_path'], 'suffix' => '_400', 'return_url' => true)))->setBreadcrumb($aListing['title'] . ($aListing['view_id'] == '2' ? ' (' . Phpfox::getPhrase('marketplace.sold') . ')' : ''), $this->url()->permalink('marketplace', $aListing['listing_id'], $aListing['title']), true)->setHeader('cache', array('jquery/plugin/star/jquery.rating.js' => 'static_script', 'jquery.rating.css' => 'style_css', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'view.js' => 'module_marketplace', 'view.css' => 'module_marketplace', 'feed.js' => 'module_feed'))->setEditor(array('load' => 'simple'))->assign(array('aListing' => $aListing, 'sMicroPropType' => 'Product', 'aImages' => Phpfox::getService('marketplace')->getImages($aListing['listing_id']), 'sListingPrice' => ($aListing['price'] == '0.00' ? Phpfox::getPhrase('marketplace.free') : Phpfox::getService('core.currency')->getCurrency(number_format($aListing['price'], 2), $aListing['currency_id'])) . $sExchangeRate . ($aListing['view_id'] == '2' ? ' (' . Phpfox::getPhrase('marketplace.sold') . ')' : '')));
     if (Phpfox::isModule('rate')) {
         $this->template()->setPhrase(array('rate.thanks_for_rating'))->setHeader(array('rate.js' => 'module_rate', '<script type="text/javascript">$Behavior.rateMarketplaceUser = function() { $Core.rate.init({display: false}); }</script>'));
     }
     ($sPlugin = Phpfox_Plugin::get('marketplace.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #8
0
ファイル: view.class.php プロジェクト: noikiy/phpfox-dist
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('pages.can_view_browse_pages', true);
     $mId = $this->request()->getInt('req2');
     if (!($aPage = Phpfox::getService('pages')->getForView($mId))) {
         return Phpfox_Error::display(Phpfox::getPhrase('pages.the_page_you_are_looking_for_cannot_be_found'));
     }
     if ($this->request()->get('req3') != '') {
         $this->template()->assign(array('bRefreshPhoto' => true));
     }
     if (Phpfox::getUserParam('pages.can_moderate_pages') || $aPage['is_admin']) {
     } else {
         if ($aPage['view_id'] != '0') {
             return Phpfox_Error::display(Phpfox::getPhrase('pages.the_page_you_are_looking_for_cannot_be_found'));
         }
     }
     if ($aPage['view_id'] == '2') {
         return Phpfox_Error::display(Phpfox::getPhrase('pages.the_page_you_are_looking_for_cannot_be_found'));
     }
     if (Phpfox::getUserBy('profile_page_id') <= 0 && Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('pages', $aPage['page_id'], $aPage['user_id'], $aPage['privacy'], isset($aPage['is_friend']) ? $aPage['is_friend'] : 0);
     }
     $bCanViewPage = true;
     // http://www.phpfox.com/tracker/view/15190/
     $sCurrentModule = Phpfox_Url::instance()->reverseRewrite($this->request()->get($this->request()->get('req1') == 'pages' ? 'req3' : 'req2'));
     Phpfox::getService('pages')->buildWidgets($aPage['page_id']);
     ($sPlugin = Phpfox_Plugin::get('pages.component_controller_view_build')) ? eval($sPlugin) : false;
     $this->setParam('aParentModule', array('module_id' => 'pages', 'item_id' => $aPage['page_id'], 'url' => Phpfox::getService('pages')->getUrl($aPage['page_id'], $aPage['title'], $aPage['vanity_url'])));
     if (isset($aPage['is_admin']) && $aPage['is_admin']) {
         define('PHPFOX_IS_PAGE_ADMIN', true);
     }
     $sModule = $sCurrentModule;
     // http://www.phpfox.com/tracker/view/15190/
     if (empty($sModule) && !empty($aPage['landing_page'])) {
         $sModule = $aPage['landing_page'];
         $sCurrentModule = $aPage['landing_page'];
     }
     ($sPlugin = Phpfox_Plugin::get('pages.component_controller_view_assign')) ? eval($sPlugin) : false;
     /*
     if (isset($aPage['use_timeline']) && $aPage['use_timeline'])
     {
     	$aPageMenus = Phpfox::getService('pages')->getMenu($aPage);
     	if (!defined('PAGE_TIME_LINE'))
     	{
     		define('PAGE_TIME_LINE', true);
     	}
     	$aPage['user_name'] = $aPage['title'];
     
     	$this->template()->setFullSite()
     		->assign(array(
     		    'aUser' => $aPage,
     		    'aProfileLinks' => $aPageMenus))
     		->setHeader(array(
     			'<script type="text/javascript">oParams["keepContent4"] = false;</script>'
     			));
     }
     */
     $this->setParam('aPage', $aPage);
     $this->template()->assign(array('aPage' => $aPage, 'sCurrentModule' => $sCurrentModule, 'bCanViewPage' => $bCanViewPage, 'iViewCommentId' => $this->request()->getInt('comment-id'), 'bHasPermToViewPageFeed' => Phpfox::getService('pages')->hasPerm($aPage['page_id'], 'pages.view_browse_updates')))->setHeader('cache', array('profile.css' => 'style_css', 'pages.css' => 'style_css', 'pages.js' => 'module_pages'));
     if (Phpfox::isMobile()) {
         $this->template()->setBreadcrumb($aPage['title'], Phpfox::getService('pages')->getUrl($aPage['page_id'], $aPage['title'], $aPage['vanity_url']), true);
     }
     /*
     $this->setParam('aCallbackShoutbox', array(
     		'module' => 'pages',
     		'item' => $aPage['page_id']
     	)
     );
     */
     if ($bCanViewPage && $sModule && Phpfox::isModule($sModule) && Phpfox::hasCallback($sModule, 'getPageSubMenu') && !$this->request()->getInt('comment-id')) {
         if (Phpfox::hasCallback($sModule, 'canViewPageSection') && !Phpfox::callback($sModule . '.canViewPageSection', $aPage['page_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('pages.unable_to_view_this_section_due_to_privacy_settings'));
         }
         $this->template()->assign('bIsPagesViewSection', true);
         $this->setParam('bIsPagesViewSection', true);
         $this->setParam('sCurrentPageModule', $sModule);
         Phpfox::getComponent($sModule . '.index', array('bNoTemplate' => true), 'controller');
         Phpfox_Module::instance()->resetBlocks();
     } elseif ($bCanViewPage && $sModule && Phpfox::getService('pages')->isWidget($sModule) && !$this->request()->getInt('comment-id')) {
         define('PHPFOX_IS_PAGES_WIDGET', true);
         $this->template()->assign(array('aWidget' => Phpfox::getService('pages')->getWidget($sModule)));
     } else {
         $bCanPostComment = true;
         if ($sCurrentModule == 'pending') {
             $this->template()->assign('aPendingUsers', Pages_Service_Pages::instance()->getPendingUsers($aPage['page_id']));
             $this->setParam('global_moderation', array('name' => 'pages', 'ajax' => 'pages.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('pages.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('pages.approve'), 'action' => 'approve'))));
         }
         if (Phpfox::getService('pages')->isAdmin($aPage)) {
             define('PHPFOX_FEED_CAN_DELETE', true);
         }
         if (Phpfox::getUserId()) {
             $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aPage['user_id'], Phpfox::getUserId());
             if ($bIsBlocked) {
                 $bCanPostComment = false;
             }
         }
         // http://www.phpfox.com/tracker/view/15316/
         if ($sCurrentModule != 'info') {
             define('PHPFOX_IS_PAGES_IS_INDEX', true);
         }
         $this->setParam('aFeedCallback', array('module' => 'pages', 'table_prefix' => 'pages_', 'ajax_request' => 'pages.addFeedComment', 'item_id' => $aPage['page_id'], 'disable_share' => $bCanPostComment ? false : true, 'feed_comment' => 'pages_comment'));
         if (isset($aPage['text']) && !empty($aPage['text'])) {
             $this->template()->setMeta('description', $aPage['text']);
         }
         $this->template()->setTitle($aPage['title'])->setEditor()->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'index.css' => 'module_pages', 'feed.js' => 'module_feed'));
     }
 }
コード例 #9
0
ファイル: view.class.php プロジェクト: lev1976g/core
 /**
  * Controller
  */
 public function process()
 {
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_view__1')) ? eval($sPlugin) : false;
     Phpfox::getUserParam('photo.can_view_photos', true);
     define('PHPFOX_SHOW_TAGS', true);
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_view__2')) ? eval($sPlugin) : false;
     $aCallback = $this->getParam('aCallback', null);
     $sId = $this->request()->get('req2');
     $sAction = $this->request()->get('req4');
     $aUser = $this->getParam('aUser');
     $this->setParam('sTagType', 'photo');
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_view_process_start')) ? eval($sPlugin) : false;
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_photo', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('photo_like', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('photo_tag', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     // Get the photo
     $aPhoto = Phpfox::getService('photo')->getPhoto($sId, $aUser['user_id']);
     if (!empty($aPhoto['module_id']) && $aPhoto['module_id'] != 'photo') {
         if ($aCallback = Phpfox::callback($aPhoto['module_id'] . '.getPhotoDetails', $aPhoto)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home'])->assign(array('aCallback' => $aCallback));
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             if ($aPhoto['module_id'] == 'pages' && !Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'photo.view_browse_photos')) {
                 return Phpfox_Error::display('Unable to view this item due to privacy settings.');
             }
         }
     }
     // No photo founds lets get out of here
     if (!isset($aPhoto['photo_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('photo.sorry_the_photo_you_are_looking_for_no_longer_exists', array('link' => $this->url()->makeUrl('photo'))));
     }
     if ($aPhoto['user_id'] == Phpfox::getUserId() && $this->request()->get('refresh')) {
         header("Cache-Control: no-cache, must-revalidate");
         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     }
     Phpfox::getService('core.redirect')->check($aPhoto['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('photo', $aPhoto['photo_id'], $aPhoto['user_id'], $aPhoto['privacy'], $aPhoto['is_friend']);
     }
     if ($aPhoto['mature'] != 0) {
         if (Phpfox::getUserId()) {
             if ($aPhoto['user_id'] != Phpfox::getUserId()) {
                 if ($aPhoto['mature'] == 1 && Phpfox::getUserParam(array('photo.photo_mature_age_limit' => array('>', (int) Phpfox::getUserBy('age'))))) {
                     // warning check cookie
                 } elseif ($aPhoto['mature'] == 2 && Phpfox::getUserParam(array('photo.photo_mature_age_limit' => array('>', (int) Phpfox::getUserBy('age'))))) {
                     return Phpfox_Error::display(Phpfox::getPhrase('photo.sorry_this_photo_can_only_be_viewed_by_those_older_then_the_age_of_limit', array('limit' => Phpfox::getUserParam('photo.photo_mature_age_limit'))));
                 }
             }
         } else {
             Phpfox::isUser(true);
         }
     }
     $this->setParam('bIsValidImage', true);
     /* 
     	Don't like that this is here, but if added in the service class it would require an extra JOIN to the user table and its such a waste of a query when we could
     	just get the users details vis the cached user array.		
     */
     $aPhoto['bookmark_url'] = $this->url()->permalink('photo', $aPhoto['photo_id'], $aPhoto['title']);
     // Increment the total view
     $aPhoto['total_view'] = (int) $aPhoto['total_view'] + 1;
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_view_process_photo')) ? eval($sPlugin) : false;
     // Assign the photo array so other blocks can use this information
     $this->setParam('aPhoto', $aPhoto);
     define('TAG_ITEM_ID', $aPhoto['photo_id']);
     // to be used with the cloud block
     // Check if we should set another controller
     /*
     if (!empty($sAction))
     {
     	switch ($sAction)
     	{
     		case 'all':
     			return Phpfox_Module::instance()->setController('photo.size');
     			break;
     		case 'download':
     			return Phpfox_Module::instance()->setController('photo.download');
     			break;
     		default:
     			(($sPlugin = Phpfox_Plugin::get('photo.component_controller_view_process_controller')) ? eval($sPlugin) : false);
     			break;
     	}			
     }
     */
     // Increment the view counter
     if (Phpfox::isModule('track') && Phpfox::isUser() && Phpfox::getUserId() != $aPhoto['user_id'] && !$aPhoto['is_viewed']) {
         Phpfox::getService('track.process')->add('photo', $aPhoto['photo_id']);
         Phpfox::getService('photo.process')->updateCounter($aPhoto['photo_id'], 'total_view');
     }
     // Add photo tags to meta keywords
     if (!empty($aPhoto['tag_list']) && $aPhoto['tag_list'] && Phpfox::isModule('tag')) {
         $this->template()->setMeta('keywords', Tag_Service_Tag::instance()->getKeywords($aPhoto['tag_list']));
     }
     $this->template()->setTitle($aPhoto['title']);
     /*
     if (Phpfox::getParam('photo.how_many_categories_to_show_in_title') > 0)
     {
         $aCategories = explode('<br />',$aPhoto['categories']);
         $sCategories = '';
         foreach ($aCategories as $iCount => $sCategory)
         {
     		if ($iCount >= Phpfox::getParam('photo.how_many_categories_to_show_in_title'))
     		{
     		    break;
     		} // clean the categories
     		
     		$sCategories .= strip_tags($sCategory) . ' - ';
         }
         
         $this->template()->setTitle(rtrim($sCategories, ' - '));
     }
     */
     $this->setParam('aFeed', array('comment_type_id' => 'photo', 'privacy' => $aPhoto['privacy'], 'comment_privacy' => $aPhoto['privacy_comment'], 'like_type_id' => 'photo', 'feed_is_liked' => $aPhoto['is_liked'], 'feed_is_friend' => $aPhoto['is_friend'], 'item_id' => $aPhoto['photo_id'], 'user_id' => $aPhoto['user_id'], 'total_comment' => $aPhoto['total_comment'], 'total_like' => $aPhoto['total_like'], 'feed_link' => $this->url()->permalink('photo', $aPhoto['photo_id'], $aPhoto['title']), 'feed_title' => $aPhoto['title'], 'feed_display' => 'view', 'feed_total_like' => $aPhoto['total_like'], 'report_module' => 'photo', 'report_phrase' => Phpfox::getPhrase('photo.report_this_photo')));
     $iUserId = $this->request()->get('userid') ? $this->request()->get('userid') : 0;
     if ($iUserId > 0) {
         $this->template()->assign(array('feedUserId' => $iUserId));
     }
     $iCategory = $this->request()->getInt('category') ? $this->request()->getInt('category') : null;
     if ($this->request()->get('theater')) {
         define('PHPFOX_IS_THEATER_MODE', true);
     }
     if (defined('PHPFOX_IS_HOSTED_SCRIPT') || $aPhoto['server_id'] > 0 && Phpfox::getParam('core.allow_cdn')) {
         $sImageUrl = Phpfox::getLib('image.helper')->display(array('server_id' => $aPhoto['server_id'], 'path' => 'photo.url_photo', 'file' => $aPhoto['destination'], 'suffix' => '_1024', 'return_url' => true));
         $iCdnMax = $aPhoto['height'] < $aPhoto['width'] ? 800 : 500;
         list($iNewImageHeight, $iNewImageWidth) = Phpfox::getLib('image.helper')->getNewSize(array($sImageUrl, $aPhoto['width'], $aPhoto['height']), $iCdnMax, $iCdnMax);
         $this->template()->assign(array('iNewImageHeight' => $iNewImageHeight, 'iNewImageWidth' => $iNewImageWidth));
     }
     $this->template()->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.tag.js' => 'static_script', 'imgnotes.css' => 'style_css', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'view.js' => 'module_photo', 'photo.js' => 'module_photo', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'view.css' => 'module_photo', 'feed.js' => 'module_feed', 'edit.css' => 'module_photo', 'index.js' => 'module_photo'));
     $this->template()->setFullSite()->setBreadcrumb(Phpfox::getPhrase('photo.photos'), $aCallback === null ? $this->url()->makeUrl('photo') : $this->url()->makeUrl($aCallback['url_home_photo']))->setBreadcrumb($aPhoto['title'], $this->url()->permalink('photo', $aPhoto['photo_id'], $aPhoto['title']), true)->setMeta('description', Phpfox::getPhrase('photo.full_name_s_photo_from_time_stamp', array('full_name' => $aPhoto['full_name'], 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.description_time_stamp'), $aPhoto['time_stamp']))) . ': ' . (empty($aPhoto['description']) ? $aPhoto['title'] : $aPhoto['title'] . '.' . $aPhoto['description']))->setMeta('keywords', $this->template()->getKeywords($aPhoto['title']))->setMeta('keywords', Phpfox::getParam('photo.photo_meta_keywords'))->setMeta('description', Phpfox::getParam('photo.photo_meta_description'))->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('server_id' => $aPhoto['server_id'], 'path' => 'photo.url_photo', 'file' => $aPhoto['destination'], 'suffix' => '_240', 'return_url' => true)))->setHeader(array('jquery/plugin/imgnotes/jquery.imgareaselect.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.imgnotes.js' => 'static_script', 'imgareaselect-default.css' => 'style_css'))->setPhrase(array('photo.none_of_your_files_were_uploaded_please_make_sure_you_upload_either_a_jpg_gif_or_png_file', 'photo.updating_photo', 'photo.save', 'photo.cancel', 'photo.click_here_to_tag_as_yourself'))->keepBody(true)->setEditor(array('load' => 'simple'))->assign(array('aForms' => $aPhoto, 'bVertical' => $aPhoto['height'] > $aPhoto['width'], 'aCallback' => $aCallback, 'aPhotoStream' => Phpfox::getService('photo')->getPhotoStream($aPhoto['photo_id'], $this->request()->getInt('albumid') ? $this->request()->getInt('albumid') : '0', $aCallback, $iUserId, $iCategory, $aPhoto['user_id']), 'bIsTheater' => $this->request()->get('theater') ? true : false, 'sPhotoJsContent' => Phpfox::getService('photo.tag')->getJs($aPhoto['photo_id']), 'iForceAlbumId' => $this->request()->getInt('albumid') > 0 ? $this->request()->getInt('albumid') : 0, 'sCurrentPhotoUrl' => Phpfox_Url::instance()->makeUrl('current'), 'sMicroPropType' => 'Photograph'));
     if (($iCategory = $this->request()->getInt('category')) && isset($aPhoto['categories']) && !empty($aPhoto['categories'])) {
         foreach ($aPhoto['categories'] as $aCategory) {
             if (isset($aCategory['category_id']) && $aCategory['category_id'] == $iCategory) {
                 // $this->template()->setBreadcrumb($aCategory[0], $aCategory[1]);
             }
         }
     }
     if (!empty($aPhoto['album_title'])) {
         $this->template()->setTitle($aPhoto['album_title']);
         $this->template()->setMeta('description', '' . Phpfox::getPhrase('photo.part_of_the_photo_album') . ': ' . $aPhoto['album_title']);
     }
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #10
0
ファイル: view.class.php プロジェクト: Goudarzi-hahram/phpfox
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('poll.can_access_polls', true);
     ($sPlugin = Phpfox_Plugin::get('poll.component_controller_view_process_start')) ? eval($sPlugin) : false;
     // there are times when this controller is actually called
     // in the Poll_Component_Controller_Profile like when the poll
     // is in the profile
     $sSuffix = '_' . Phpfox::getParam('poll.poll_max_image_pic_size');
     $iPage = $this->request()->getInt('page', 0);
     $iPageSize = 10;
     // we need to make sure we're getting the
     if (!($iPoll = $this->request()->getInt('req2'))) {
         $this->url()->send('poll');
     }
     if (Phpfox::isModule('notification') && Phpfox::isUser()) {
         Phpfox::getService('notification.process')->delete('comment_poll', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('poll_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     // we need to load one poll
     $aPoll = Phpfox::getService('poll')->getPollByUrl($iPoll, $iPage, $iPageSize, true);
     Phpfox_Pager::instance()->set(array('ajax' => 'poll.pageVotes', 'page' => 0, 'size' => Phpfox::getParam('poll.show_x_users_who_took_poll'), 'count' => $aPoll['total_votes']));
     if ($aPoll === false) {
         return Phpfox_Error::display('Not a valid poll.');
     }
     if (Phpfox::getUserId() == $aPoll['user_id'] && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('poll_approved', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if (!isset($aPoll['is_friend'])) {
         $aPoll['is_friend'] = 0;
     }
     Phpfox::getService('core.redirect')->check($aPoll['question']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('poll', $aPoll['poll_id'], $aPoll['user_id'], $aPoll['privacy'], $aPoll['is_friend']);
     }
     // set if we can show the poll results
     // is guest the owner of the poll
     $bIsOwner = $aPoll['user_id'] == Phpfox::getUserId();
     $bShowResults = false;
     if ($bIsOwner && Phpfox::getUserParam('poll.can_view_user_poll_results_own_poll') || !$bIsOwner && Phpfox::getUserParam('poll.can_view_user_poll_results_other_poll')) {
         $bShowResults = true;
     }
     $this->template()->assign(array('bShowResults' => $bShowResults));
     if ($aPoll['view_id'] == 1) {
         if (!Phpfox::getUserParam('poll.poll_can_moderate_polls') && $aPoll['user_id'] != Phpfox::getUserId()) {
             return Phpfox_Error::display(Phpfox::getPhrase('poll.unable_to_view_this_poll'));
         }
         if ($sModerate = $this->request()->get('moderate')) {
             Phpfox::getUserParam('poll.poll_can_moderate_polls', true);
             switch ($sModerate) {
                 case 'approve':
                     if (Phpfox::getService('poll.process')->moderatePoll($aPoll['poll_id'], 0)) {
                         $this->url()->send($aUser['user_name'], array('poll', $aPoll['question_url']), Phpfox::getPhrase('poll.poll_successfully_approved'));
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     // Track users
     if (Phpfox::isModule('track') && Phpfox::isUser() && Phpfox::getUserId() != $aPoll['user_id'] && !$aPoll['poll_is_viewed'] && !Phpfox::getUserBy('is_invisible')) {
         Phpfox::getService('track.process')->add('poll', $aPoll['poll_id']);
         Phpfox::getService('poll.process')->updateView($aPoll['poll_id']);
     }
     if (Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aPoll['user_id'] && $aPoll['poll_is_viewed'] && !Phpfox::getUserBy('is_invisible')) {
         Phpfox::getService('track.process')->update('poll_track', $aPoll['poll_id']);
     }
     // check editing permissions
     $aPoll['bCanEdit'] = Phpfox::getService('poll')->bCanEdit($aPoll['user_id']);
     // Define params for "review views" block tracker
     $this->setParam(array('sTrackType' => 'poll', 'iTrackId' => $aPoll['poll_id'], 'iTrackUserId' => $aPoll['user_id'], 'aPoll' => $aPoll));
     $this->setParam('aFeed', array('comment_type_id' => 'poll', 'privacy' => $aPoll['privacy'], 'comment_privacy' => $aPoll['privacy_comment'], 'like_type_id' => 'poll', 'feed_is_liked' => $aPoll['is_liked'], 'feed_is_friend' => $aPoll['is_friend'], 'item_id' => $aPoll['poll_id'], 'user_id' => $aPoll['user_id'], 'total_comment' => $aPoll['total_comment'], 'total_like' => $aPoll['total_like'], 'feed_link' => $this->url()->permalink('poll', $aPoll['poll_id'], $aPoll['question']), 'feed_title' => $aPoll['question'], 'feed_display' => 'view', 'feed_total_like' => $aPoll['total_like'], 'report_module' => 'poll', 'report_phrase' => Phpfox::getPhrase('poll.report_this_poll_lowercase')));
     $this->template()->setTitle($aPoll['question'])->setBreadcrumb(Phpfox::getPhrase('poll.polls'), $this->url()->makeUrl('poll'))->setBreadcrumb($aPoll['question'], $this->url()->permalink('poll', $aPoll['poll_id'], $aPoll['question']), true)->setMeta('keywords', $this->template()->getKeywords($aPoll['question']))->setMeta('description', Phpfox::getPhrase('poll.full_name_s_poll_from_time_stamp_question', array('full_name' => $aPoll['full_name'], 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.description_time_stamp'), $aPoll['time_stamp']), 'question' => $aPoll['question'])))->setMeta('description', Phpfox::getParam('poll.poll_meta_description'))->setMeta('keywords', Phpfox::getParam('poll.poll_meta_keywords'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'poll.css' => 'module_poll', 'feed.js' => 'module_feed'))->setEditor(array('load' => 'simple'))->assign(array('bIsViewingPoll' => true, 'aPoll' => $aPoll, 'sSuffix' => $sSuffix));
     if (isset($aPoll['answer']) && is_array($aPoll['answer'])) {
         foreach ($aPoll['answer'] as $aAnswer) {
             $this->template()->setMeta('keywords', $this->template()->getKeywords($aAnswer['answer']));
         }
     }
     ($sPlugin = Phpfox_Plugin::get('poll.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #11
0
ファイル: view.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * Controller
  */
 public function process()
 {
     if ($this->request()->get('req2') == 'view' && ($sLegacyTitle = $this->request()->get('req3')) && !empty($sLegacyTitle)) {
         Phpfox::getService('core')->getLegacyItem(array('field' => array('event_id', 'title'), 'table' => 'event', 'redirect' => 'event', 'title' => $sLegacyTitle));
     }
     Phpfox::getUserParam('event.can_access_event', true);
     $sEvent = $this->request()->get('req2');
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         if ($this->request()->getInt('comment-id')) {
             Phpfox::getService('notification.process')->delete('event_comment', $this->request()->getInt('comment-id'), Phpfox::getUserId());
             Phpfox::getService('notification.process')->delete('event_comment_feed', $this->request()->getInt('comment-id'), Phpfox::getUserId());
             Phpfox::getService('notification.process')->delete('event_comment_like', $this->request()->getInt('comment-id'), Phpfox::getUserId());
         }
         Phpfox::getService('notification.process')->delete('event_like', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('event_invite', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if (!($aEvent = Event_Service_Event::instance()->getEvent($sEvent))) {
         return Phpfox_Error::display(Phpfox::getPhrase('event.the_event_you_are_looking_for_does_not_exist_or_has_been_removed'), 404);
     }
     Phpfox::getService('core.redirect')->check($aEvent['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('event', $aEvent['event_id'], $aEvent['user_id'], $aEvent['privacy'], $aEvent['is_friend']);
     }
     $this->setParam('aEvent', $aEvent);
     $bCanPostComment = true;
     if (isset($aEvent['privacy_comment']) && $aEvent['user_id'] != Phpfox::getUserId() && !Phpfox::getUserParam('privacy.can_comment_on_all_items')) {
         switch ($aEvent['privacy_comment']) {
             // Everyone is case 0. Skipped.
             // Friends only
             case 1:
                 if (!Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $aEvent['user_id'])) {
                     $bCanPostComment = false;
                 }
                 break;
                 // Friend of friends
             // Friend of friends
             case 2:
                 if (!Friend_Service_Friend::instance()->isFriendOfFriend($aEvent['user_id'])) {
                     $bCanPostComment = false;
                 }
                 break;
                 // Only me
             // Only me
             case 3:
                 $bCanPostComment = false;
                 break;
         }
     }
     $aCallback = false;
     if ($aEvent['item_id'] && Phpfox::hasCallback($aEvent['module_id'], 'viewEvent')) {
         $aCallback = Phpfox::callback($aEvent['module_id'] . '.viewEvent', $aEvent['item_id']);
         $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         if ($aEvent['module_id'] == 'pages' && !Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'event.view_browse_events')) {
             return Phpfox_Error::display('Unable to view this item due to privacy settings.');
         }
     }
     if (Phpfox::getUserId()) {
         $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aEvent['user_id'], Phpfox::getUserId());
         if ($bIsBlocked) {
             $bCanPostComment = false;
         }
     }
     $this->setParam('aFeedCallback', array('module' => 'event', 'table_prefix' => 'event_', 'ajax_request' => 'event.addFeedComment', 'item_id' => $aEvent['event_id'], 'disable_share' => $bCanPostComment ? false : true));
     if ($aEvent['view_id'] == '1') {
         $this->template()->setHeader('<script type="text/javascript">$Behavior.eventIsPending = function(){ $(\'#js_block_border_feed_display\').addClass(\'js_moderation_on\').hide(); }</script>');
     }
     if (Phpfox::getUserId() == $aEvent['user_id']) {
         if (Phpfox::isModule('notification')) {
             Phpfox::getService('notification.process')->delete('event_approved', $this->request()->getInt('req2'), Phpfox::getUserId());
         }
         define('PHPFOX_FEED_CAN_DELETE', true);
     }
     $this->template()->setTitle($aEvent['title'])->setMeta('description', $aEvent['description'])->setMeta('keywords', $this->template()->getKeywords($aEvent['title']))->setBreadcrumb(Phpfox::getPhrase('event.events'), $aCallback === false ? $this->url()->makeUrl('event') : $this->url()->makeUrl($aCallback['url_home_pages']))->setBreadcrumb($aEvent['title'], $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title']), true)->setEditor(array('load' => 'simple'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed', 'event.js' => 'module_event'))->assign(array('aEvent' => $aEvent, 'aCallback' => $aCallback, 'sMicroPropType' => 'Event'));
     ($sPlugin = Phpfox_Plugin::get('event.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #12
0
ファイル: view.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * Controller
  */
 public function process()
 {
     if ($this->request()->getInt('id')) {
         return Phpfox_Module::instance()->setController('error.404');
     }
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_blog', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('blog_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     Phpfox::getUserParam('blog.view_blogs', true);
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_view_process_start')) ? eval($sPlugin) : false;
     $bIsProfile = $this->getParam('bIsProfile');
     if ($bIsProfile === true) {
         $this->setParam(array('bViewProfileBlog' => true, 'sTagType' => 'blog'));
     }
     $aItem = Phpfox::getService('blog')->getBlog($this->request()->getInt('req2'));
     if (!isset($aItem['blog_id']) || isset($aItem['module_id']) && Phpfox::isModule($aItem['module_id']) != true) {
         return Phpfox_Error::display(Phpfox::getPhrase('blog.blog_not_found'));
     }
     if (Phpfox::getUserId() == $aItem['user_id'] && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('blog_approved', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     Phpfox::getService('core.redirect')->check($aItem['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('blog', $aItem['blog_id'], $aItem['user_id'], $aItem['privacy'], $aItem['is_friend']);
     }
     // http://www.phpfox.com/tracker/view/14944/
     if (isset($aItem['module_id']) && $aItem['module_id'] == 'pages' && Phpfox::isModule($aItem['module_id'])) {
         if (!Phpfox::getService('pages')->hasPerm($aItem['item_id'], 'blog.view_browse_blogs')) {
             Phpfox_Url::instance()->send('privacy.invalid');
         }
     }
     if (!Phpfox::getUserParam('blog.can_approve_blogs')) {
         if ($aItem['is_approved'] != '1' && $aItem['user_id'] != Phpfox::getUserId()) {
             return Phpfox_Error::display(Phpfox::getPhrase('blog.blog_not_found'), 404);
         }
     }
     if ($aItem['post_status'] == 2 && Phpfox::getUserId() != $aItem['user_id'] && !Phpfox::getUserParam('blog.edit_user_blog')) {
         return Phpfox_Error::display(Phpfox::getPhrase('blog.blog_not_found'));
     }
     if (Phpfox::isModule('track') && Phpfox::isUser() && Phpfox::getUserId() != $aItem['user_id'] && !$aItem['is_viewed']) {
         Phpfox::getService('track.process')->add('blog', $aItem['blog_id']);
         Phpfox::getService('blog.process')->updateView($aItem['blog_id']);
     }
     if (Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aItem['user_id'] && $aItem['is_viewed'] && !Phpfox::getUserBy('is_invisible')) {
         Phpfox::getService('track.process')->update('blog_track', $aItem['blog_id']);
     }
     // Define params for "review views" block
     $this->setParam(array('sTrackType' => 'blog', 'iTrackId' => $aItem['blog_id'], 'iTrackUserId' => $aItem['user_id']));
     if ($sPassword = $this->request()->get('blog_password')) {
         if (Phpfox::getUserParam('blog.can_view_password_protected_blog')) {
             if (Phpfox::getService('blog')->verifyPassword($aItem['blog_id'], $sPassword)) {
                 $this->url()->permalink('blog', $aItem['blog_id'], $aItem['title'], true);
             } else {
                 $this->url()->permalink('blog', $aItem['blog_id'], $aItem['title'], true, Phpfox::getPhrase('blog.password_is_invalid'));
             }
         } else {
             $this->url()->permalink('blog', $aItem['blog_id'], $aItem['title'], true, Phpfox::getPhrase('blog.unable_to_view_password_protected_blogs'));
         }
     }
     $aCategories = Phpfox::getService('blog.category')->getCategoriesById($aItem['blog_id']);
     if (Phpfox::isModule('tag')) {
         $aTags = Tag_Service_Tag::instance()->getTagsById('blog', $aItem['blog_id']);
         if (isset($aTags[$aItem['blog_id']])) {
             $aItem['tag_list'] = $aTags[$aItem['blog_id']];
         }
     }
     if (isset($aCategories[$aItem['blog_id']])) {
         $sCategories = '';
         foreach ($aCategories[$aItem['blog_id']] as $iKey => $aCategory) {
             $sCategories .= ($iKey != 0 ? ',' : '') . ' <a href="' . ($aCategory['user_id'] ? $this->url()->permalink($aItem['user_name'] . '.blog.category', $aCategory['category_id'], $aCategory['category_name']) : $this->url()->permalink('blog.category', $aCategory['category_id'], $aCategory['category_name'])) . '">' . Phpfox_Locale::instance()->convert(Phpfox::getLib('parse.output')->clean($aCategory['category_name'])) . '</a>';
             $this->template()->setMeta('keywords', $aCategory['category_name']);
         }
     }
     if (isset($sCategories)) {
         $aItem['info'] = Phpfox::getPhrase('blog.posted_x_by_x_in_x', array('date' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aItem['time_stamp']), 'link' => Phpfox_Url::instance()->makeUrl('profile', array($aItem['user_name'])), 'user' => $aItem, 'categories' => $sCategories));
     } else {
         $aItem['info'] = Phpfox::getPhrase('blog.posted_x_by_x', array('date' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aItem['time_stamp']), 'link' => Phpfox_Url::instance()->makeUrl('profile', array($aItem['user_name'])), 'user' => $aItem));
     }
     $aItem['bookmark_url'] = Phpfox::permalink('blog', $aItem['blog_id'], $aItem['title']);
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_view_process_middle')) ? eval($sPlugin) : false;
     // Add tags to meta keywords
     if (!empty($aItem['tag_list']) && $aItem['tag_list'] && Phpfox::isModule('tag')) {
         $this->template()->setMeta('keywords', Tag_Service_Tag::instance()->getKeywords($aItem['tag_list']));
     }
     if (isset($aItem['module_id']) && Phpfox::hasCallback($aItem['module_id'], 'getVideoDetails')) {
         if ($aCallback = Phpfox::callback($aItem['module_id'] . '.getVideoDetails', $aItem)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             //$this->template()->setBreadcrumb()
         }
     }
     $this->setParam('aFeed', array('comment_type_id' => 'blog', 'privacy' => $aItem['privacy'], 'comment_privacy' => $aItem['privacy_comment'], 'like_type_id' => 'blog', 'feed_is_liked' => isset($aItem['is_liked']) ? $aItem['is_liked'] : false, 'feed_is_friend' => $aItem['is_friend'], 'item_id' => $aItem['blog_id'], 'user_id' => $aItem['user_id'], 'total_comment' => $aItem['total_comment'], 'total_like' => $aItem['total_like'], 'feed_link' => $aItem['bookmark_url'], 'feed_title' => $aItem['title'], 'feed_display' => 'view', 'feed_total_like' => $aItem['total_like'], 'report_module' => 'blog', 'report_phrase' => Phpfox::getPhrase('blog.report_this_blog'), 'time_stamp' => $aItem['time_stamp']));
     $sBreadcrumb = $this->url()->makeUrl('blog');
     if (isset($aCallback) && isset($aCallback['item_id'])) {
         $sBreadcrumb = $this->url()->makeUrl('pages.' . $aCallback['item_id'] . '.blog');
     }
     if (isset($aCallback) && isset($aCallback['module_id']) && $aCallback['module_id'] == 'pages') {
         $this->setParam('sTagListParentModule', $aItem['module_id']);
         $this->setParam('iTagListParentId', (int) $aItem['item_id']);
     }
     $this->template()->setTitle($aItem['title'])->setBreadCrumb(Phpfox::getPhrase('blog.blogs_title'), $sBreadcrumb)->setBreadCrumb($aItem['title'], $this->url()->permalink('blog', $aItem['blog_id'], $aItem['title']), true)->setMeta('description', $aItem['title'] . '.')->setMeta('description', $aItem['text'] . '.')->setMeta('description', $aItem['info'] . '.')->setMeta('keywords', $this->template()->getKeywords($aItem['title']))->assign(array('aItem' => $aItem, 'bBlogView' => true, 'bIsProfile' => $bIsProfile, 'sTagType' => $bIsProfile === true ? 'blog_profile' : 'blog', 'iShorten' => Phpfox::getParam('blog.length_in_index'), 'sMicroPropType' => 'BlogPosting'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed'));
     if (Phpfox::getUserId()) {
         $this->template()->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')));
     }
     if (Phpfox::getParam('blog.digg_integration')) {
         $this->template()->setHeader('<script type="text/javascript">$Behavior.blog_view_digg = function() {var s = document.createElement(\'SCRIPT\'), s1 = document.getElementsByTagName(\'SCRIPT\')[0];s.type = \'text/javascript\';s.async = true;s.src = \'http://widgets.digg.com/buttons.js\';s1.parentNode.insertBefore(s, s1);};</script>');
     }
     if ($this->request()->get('req4') == 'comment') {
         $this->template()->setHeader('<script type="text/javascript">var $bScrollToBlogComment = false; $Behavior.scrollToBlogComment = function () { if ($bScrollToBlogComment) { return; } $bScrollToBlogComment = true; if ($(\'#js_feed_comment_pager_' . $aItem['blog_id'] . '\').length > 0) { $.scrollTo(\'#js_feed_comment_pager_' . $aItem['blog_id'] . '\', 800); } }</script>');
     }
     if ($this->request()->get('req4') == 'add-comment') {
         $this->template()->setHeader('<script type="text/javascript">var $bScrollToBlogComment = false; $Behavior.scrollToBlogComment = function () { if ($bScrollToBlogComment) { return; } $bScrollToBlogComment = true; if ($(\'#js_feed_comment_form_' . $aItem['blog_id'] . '\').length > 0) { $.scrollTo(\'#js_feed_comment_form_' . $aItem['blog_id'] . '\', 800); $Core.commentFeedTextareaClick($(\'.js_comment_feed_textarea\')); } }</script>');
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #13
0
 public function getActivityFeedTag($aItem, $aCallback = null)
 {
     $aRow = $this->database()->select('p.photo_id, p.title, p.time_stamp, p.server_id, p.destination, p.user_id AS photo_user_id, p.privacy, f.friend_id AS is_friend, pi.description, ' . Phpfox::getUserField() . ', ' . Phpfox::getUserField('u2', 'photo_'))->from(Phpfox::getT('photo_tag'), 'pt')->join(Phpfox::getT('photo'), 'p', 'p.photo_id = pt.photo_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = ' . (int) $aItem['parent_user_id'])->join(Phpfox::getT('user'), 'u2', 'u2.user_id = p.user_id')->leftJoin(Phpfox::getT('friend'), 'f', "f.user_id = p.user_id AND f.friend_user_id = " . Phpfox::getUserId())->leftJoin(Phpfox::getT('photo_info'), 'pi', 'pi.photo_id = p.photo_id')->where('pt.tag_id = ' . (int) $aItem['item_id'])->execute('getSlaveRow');
     if (!isset($aRow['photo_id'])) {
         return false;
     }
     $bCanViewItem = true;
     if ($aRow['privacy'] > 0) {
         $bCanViewItem = Privacy_Service_Privacy::instance()->check('photo', $aRow['photo_id'], $aRow['photo_user_id'], $aRow['privacy'], $aRow['is_friend'], true);
     }
     $sLink = Phpfox::permalink('photo', $aRow['photo_id'], $aRow['title']);
     if ($aItem['user_id'] == $aRow['photo_user_id']) {
         $sPhrase = Phpfox::getPhrase('feed.tagged_a_href_row_link_full_name_a_on_gender_a_href_link_photo_a', array('row_link' => Phpfox_Url::instance()->makeUrl($aRow['user_name']), 'full_name' => $aRow['full_name'], 'gender' => Phpfox::getService('user')->gender($aItem['gender'], 1), 'link' => $sLink));
     } elseif ($aItem['user_id'] == $aRow['user_id']) {
         $sPhrase = Phpfox::getPhrase('photo.tagged_gender_on_a_href_link_photo_full_name_s_photo', array('gender' => Phpfox::getService('user')->gender($aItem['gender'], 2), 'link' => Phpfox_Url::instance()->makeUrl($aRow['photo_user_name']), 'photo_full_name' => $aRow['photo_full_name']));
     } else {
         $sPhrase = Phpfox::getPhrase('feed.tagged_a_href_row_link_full_name_a_on_a_href_photo_user_name_photo_full_name_a_a_href_link_photo_a', array('row_link' => Phpfox_Url::instance()->makeUrl($aRow['user_name']), 'full_name' => $aRow['full_name'], 'photo_user_name' => Phpfox_Url::instance()->makeUrl($aRow['photo_user_name']), 'photo_full_name' => $aRow['photo_full_name'], 'link' => $sLink));
     }
     $aReturn = array('feed_info' => $sPhrase, 'feed_link' => Phpfox::permalink('photo', $aRow['photo_id'], $aRow['title']), 'feed_icon' => Phpfox::getLib('image.helper')->display(array('theme' => 'misc/group.png', 'return_url' => true)), 'time_stamp' => $aRow['time_stamp'], 'enable_like' => false);
     if ($bCanViewItem) {
         $aReturn['feed_image'] = Phpfox::getLib('image.helper')->display(array('server_id' => $aRow['server_id'], 'path' => 'photo.url_photo', 'file' => Phpfox::getService('photo')->getPhotoUrl($aRow), 'suffix' => '_100', 'max_width' => 100, 'max_height' => 100, 'class' => 'photo_holder'));
         $aReturn['feed_title'] = $aRow['title'];
         $aReturn['feed_content'] = $aRow['description'];
     }
     return $aReturn;
 }
コード例 #14
0
ファイル: browse.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * 
  * Execute the browse routine. Runs the SQL query.
  */
 public function execute()
 {
     $aActualConditions = (array) $this->search()->getConditions();
     list($sModule, $sService) = explode('.', $this->_aParams['service']);
     if (Phpfox::isModule('input') && isset($_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sModule][Phpfox_Request::instance()->get('search-id')]['input'])) {
         $aInputs = $_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sModule][Phpfox_Request::instance()->get('search-id')]['input'];
         $aInputsToSearch = array();
         foreach ($aInputs as $iInputId => $mValue) {
             if (!is_numeric($iInputId) || $iInputId < 1) {
                 continue;
             }
             $aInputsToSearch[$iInputId] = $mValue;
         }
         $aJoins = Phpfox::getService('input')->getJoinsForSearch($aInputsToSearch, $sModule);
         if (empty($aJoins)) {
             $aJoins = array(0);
         }
         $aActualConditions[] = 'AND (' . $this->_aParams['alias'] . '.' . $this->_aParams['field'] . ' IN (' . implode(',', $aJoins) . '))';
     }
     $this->_aConditions = array();
     foreach ($aActualConditions as $sCond) {
         switch ($this->_sView) {
             case 'friend':
                 $this->_aConditions[] = str_replace('%PRIVACY%', '0,1,2', $sCond);
                 break;
             case 'my':
                 $this->_aConditions[] = str_replace('%PRIVACY%', '0,1,2,3,4', $sCond);
                 break;
             case 'pages_member':
                 $this->_aConditions[] = str_replace('%PRIVACY%', '0,1', $sCond);
                 break;
             case 'pages_admin':
                 $this->_aConditions[] = str_replace('%PRIVACY%', '0,1,2', $sCond);
                 break;
             default:
                 $this->_aConditions[] = str_replace('%PRIVACY%', '0', $sCond);
                 break;
         }
     }
     // d($this->_aConditions); exit;
     // testing:
     // $this->_aConditions = array_merge( (array)array_pop($this->_aConditions), (array)array_pop($this->_aConditions));
     // d($this->_aConditions);die();
     /*
     if (Phpfox::getParam('core.section_privacy_item_browsing') && (isset($this->_aParams['hide_view']) && !in_array($this->_sView, $this->_aParams['hide_view'])))
     {			
     	Privacy_Service_Privacy::instance()->buildPrivacy(array_merge($this->_aParams, array('count' => true)));
     	
     	$this->_iCnt = $this->database()->joinCount('total_item')->execute('getSlaveField');		
     }
     else 
     {
     	$this->_oBrowse->getQueryJoins(true);
     	
     	$this->_iCnt = $this->database()->select((isset($this->_aParams['distinct']) ? 'COUNT(DISTINCT ' . $this->_aParams['field'] . ')' : 'COUNT(*)'))
     		->from($this->_aParams['table'], $this->_aParams['alias'])
     		->where($this->_aConditions)
     		//->limit($this->search()->getPage(), $this->search()->getDisplay())
     		->execute('getSlaveField');
     }
     */
     if (Phpfox::getParam('core.section_privacy_item_browsing') && (isset($this->_aParams['hide_view']) && !in_array($this->_sView, $this->_aParams['hide_view']))) {
         Privacy_Service_Privacy::instance()->buildPrivacy($this->_aParams);
         $this->database()->unionFrom($this->_aParams['alias']);
     } else {
         $this->_oBrowse->getQueryJoins();
         $this->database()->from($this->_aParams['table'], $this->_aParams['alias'])->where($this->_aConditions);
     }
     $this->_oBrowse->query();
     $this->_aRows = $this->database()->select($this->_aParams['alias'] . '.*, ' . (isset($this->_aParams['select']) ? $this->_aParams['select'] : '') . Phpfox::getUserField())->join(Phpfox::getT('user'), 'u', 'u.user_id = ' . $this->_aParams['alias'] . '.user_id')->order($this->search()->getSort())->limit($this->search()->getPage(), $this->search()->getDisplay(), $this->_iCnt, false, false)->execute('getSlaveRows');
     if ($this->search()->getPage() > 0 && count($this->_aRows) < 1) {
         // Phpfox_Url::instance()->send('error.404');
         throw error('no_items');
     }
     if (method_exists($this->_oBrowse, 'processRows')) {
         $this->_oBrowse->processRows($this->_aRows);
     }
     /*
     else if ($this->search()->getPage() > 0)
     {
     	// Phpfox_Url::instance()->send('error.404');
     	throw error('no_items');
     }
     */
 }
コード例 #15
0
ファイル: album.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * Controller
  */
 public function process()
 {
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_album__1')) ? eval($sPlugin) : false;
     Phpfox::getUserParam('photo.can_view_photo_albums', true);
     Phpfox::getUserParam('photo.can_view_photos', true);
     // Get the user details (person we are viewing)
     $aUser = $this->getParam('aUser');
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_photo_album', $this->request()->getInt('req3'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('photo_album_like', $this->request()->getInt('req3'), Phpfox::getUserId());
     }
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_album_process_start')) ? eval($sPlugin) : false;
     $bIsProfilePictureAlbum = false;
     if ($this->request()->getInt('req3') == 'profile') {
         $bIsProfilePictureAlbum = true;
         $aAlbum = Phpfox::getService('photo.album')->getForProfileView($this->request()->getInt('req4'));
     } else {
         // Get the current album we are trying to view
         $aAlbum = Phpfox::getService('photo.album')->getForView($this->request()->getInt('req3'));
         if ($aAlbum['profile_id'] > 0) {
             $bIsProfilePictureAlbum = true;
         }
     }
     // Make sure this is a valid album
     if ($aAlbum === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('photo.invalid_photo_album'));
     }
     // http://www.phpfox.com/tracker/view/15419/
     if ($bIsProfilePictureAlbum) {
         $aAlbum['name'] = Phpfox::getPhrase('photo.profile_pictures');
     }
     $aCallback = null;
     if (!empty($aAlbum['module_id'])) {
         if ($aCallback = Phpfox::callback($aAlbum['module_id'] . '.getPhotoDetails', $aAlbum)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         }
     }
     if (!$bIsProfilePictureAlbum) {
         Phpfox::getService('core.redirect')->check($aAlbum['name'], 'req4');
     }
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('photo_album', $aAlbum['album_id'], $aAlbum['user_id'], $aAlbum['privacy'], $aAlbum['is_friend']);
     }
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_album_process_album')) ? eval($sPlugin) : false;
     // Store the album details so we can use it in a block later on
     $this->setParam('aAlbum', $aAlbum);
     // Setup the page data
     $iPage = $this->request()->getInt('page');
     $iPageSize = Phpfox::getUserParam('photo.total_photo_display_profile');
     // Create the SQL condition array
     $aConditions = array();
     $aConditions[] = 'p.album_id = ' . $aAlbum['album_id'] . '';
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_album_process_conditions')) ? eval($sPlugin) : false;
     // Get the photos based on the conditions
     list($iCnt, $aPhotos) = Phpfox::getService('photo')->get($aConditions, 'p.photo_id DESC', $iPage, $iPageSize);
     // Set the pager for the photos
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     foreach ($aPhotos as $aPhoto) {
         $this->template()->setMeta('keywords', $this->template()->getKeywords($aPhoto['title']));
         if ($aPhoto['is_cover']) {
             $this->template()->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('server_id' => $aPhoto['server_id'], 'path' => 'photo.url_photo', 'file' => $aPhoto['destination'], 'suffix' => '_240', 'return_url' => true)));
         }
     }
     if (Phpfox::getUserBy('profile_page_id')) {
         Phpfox::getService('pages')->setIsInPage();
     }
     $this->setParam('aFeed', array('comment_type_id' => 'photo_album', 'privacy' => $aAlbum['privacy'], 'comment_privacy' => $aAlbum['privacy_comment'], 'like_type_id' => 'photo_album', 'feed_is_liked' => $aAlbum['is_liked'], 'feed_is_friend' => $aAlbum['is_friend'], 'item_id' => $aAlbum['album_id'], 'user_id' => $aAlbum['user_id'], 'total_comment' => $aAlbum['total_comment'], 'total_like' => $aAlbum['total_like'], 'feed_link' => $this->url()->permalink('photo.album', $aAlbum['album_id'], $aAlbum['name']), 'feed_title' => $aAlbum['name'], 'feed_display' => 'view', 'feed_total_like' => $aAlbum['total_like'], 'report_module' => 'photo_album', 'report_phrase' => Phpfox::getPhrase('photo.report_this_photo_album')));
     // Assign the template vars
     $this->template()->setTitle($aAlbum['name'])->setBreadcrumb(Phpfox::getPhrase('photo.photos'), $aCallback === null ? $this->url()->makeUrl('photo') : $this->url()->makeUrl($aCallback['url_home_photo']))->setBreadcrumb($aAlbum['name'], $this->url()->permalink('photo.album', $aAlbum['album_id'], $aAlbum['name']), true)->setMeta('description', empty($aAlbum['description']) ? $aAlbum['name'] : $aAlbum['description'])->setMeta('keywords', $this->template()->getKeywords($aAlbum['name']))->setMeta('keywords', Phpfox::getParam('photo.photo_meta_keywords'))->setPhrase(array('photo.updating_album', 'photo.none_of_your_files_were_uploaded_please_make_sure_you_upload_either_a_jpg_gif_or_png_file'))->setEditor()->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.tag.js' => 'static_script', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'view.js' => 'module_photo', 'photo.js' => 'module_photo', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'index.css' => 'module_photo', 'view.css' => 'module_photo', 'feed.js' => 'module_feed', 'browse.css' => 'module_photo', 'edit.css' => 'module_photo', 'index.js' => 'module_photo'))->assign(array('aPhotos' => $aPhotos, 'aForms' => $aAlbum, 'aAlbum' => $aAlbum, 'aCallback' => null, 'bIsInAlbumMode' => true, 'iForceAlbumId' => $aAlbum['album_id'], 'iPhotosPerRow' => 5));
     $this->setParam('global_moderation', array('name' => 'photo', 'ajax' => 'photo.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('photo.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('photo.approve'), 'action' => 'approve'))));
     ($sPlugin = Phpfox_Plugin::get('photo.component_controller_album_process_end')) ? eval($sPlugin) : false;
 }
コード例 #16
0
ファイル: poll.class.php プロジェクト: lev1976g/core
 /**
  * Gets the polls given the conditions in $aCond which can be an array or just a string,
  * orders by date as in newest first
  *
  * @deprecated
  * @since 3.0.0beta1
  * @param mixed $aCond
  * @param integer $iUser user id to check if this user has already voted
  * @param integer $iPage Page to show
  * @param integer $iPageSize How many items per page
  * @return array
  */
 public function getPolls($aCond = array(), $iPage = false, $iPageSize = false, $sOrder = null)
 {
     ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getpolls_start')) ? eval($sPlugin) : false;
     $aCond = array();
     foreach ($this->search()->getConditions() as $sCond) {
         switch (Phpfox_Request::instance()->get('view')) {
             case 'friend':
                 $aCond[] = str_replace('%PRIVACY%', '0,1,2', $sCond);
                 break;
             case 'my':
                 $aCond[] = str_replace('%PRIVACY%', '0,1,2,3,4', $sCond);
                 break;
             default:
                 $aCond[] = str_replace('%PRIVACY%', '0', $sCond);
                 break;
         }
     }
     if (Phpfox::getParam('core.section_privacy_item_browsing')) {
         Privacy_Service_Privacy::instance()->buildPrivacy(array('module_id' => 'poll', 'alias' => 'poll', 'field' => 'poll_id', 'count' => true, 'table' => Phpfox::getT('poll'), 'service' => 'poll'));
         $iCnt = $this->database()->joinCount('total_item')->execute('getSlaveField');
     } else {
         $iCnt = $this->database()->select("COUNT(*)")->from($this->_sTable, 'poll')->where($aCond)->execute('getSlaveField');
     }
     // quick check
     if (empty($iCnt) || $iCnt == 0) {
         return array(0, array());
     }
     if (Phpfox::getParam('core.section_privacy_item_browsing')) {
         Privacy_Service_Privacy::instance()->buildPrivacy(array('module_id' => 'poll', 'alias' => 'poll', 'field' => 'poll_id', 'table' => Phpfox::getT('poll'), 'service' => 'poll'));
         $this->database()->unionFrom('poll');
     } else {
         $this->database()->from($this->_sTable, 'poll')->where($aCond);
     }
     $aPolls = $this->database()->select('poll.*,  pd.background, pd.percentage, pd.border, pr.answer_id, pr.user_id as voted, friends.friend_id AS is_friend, ' . Phpfox::getUserField())->join(Phpfox::getT('user'), 'u', 'u.user_id = poll.user_id')->leftjoin(Phpfox::getT('poll_design'), 'pd', 'pd.poll_id = poll.poll_id')->leftjoin(Phpfox::getT('poll_result'), 'pr', 'pr.poll_id = poll.poll_id AND pr.user_id = ' . Phpfox::getUserId())->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'poll\' AND l.item_id = poll.poll_id AND l.user_id = ' . Phpfox::getUserId())->leftJoin(Phpfox::getT('friend'), 'friends', 'friends.user_id = poll.user_id AND friends.friend_user_id = ' . Phpfox::getUserId())->limit($iPage, $iPageSize, $iCnt)->order('poll.time_stamp DESC')->execute('getSlaveRows');
     // we "implode" the poll_ids to run only one query on the DB to get the
     // answers
     $sPolls = '';
     foreach ($aPolls as $aPoll) {
         $sPolls .= $aPoll['poll_id'] . ',';
     }
     $sPolls = rtrim($sPolls, ',');
     $aAnswers = $this->database()->select('pa.*, pr.user_id as voted')->from(Phpfox::getT('poll_answer'), 'pa')->where('pa.poll_id IN(' . $sPolls . ')')->leftjoin(Phpfox::getT('poll_result'), 'pr', 'pr.answer_id = pa.answer_id AND pr.user_id = ' . Phpfox::getUserId())->order('pa.ordering ASC')->execute('getSlaveRows');
     // now merge both arrays by their poll_id and add the count for the total votes
     $aPolls2 = array();
     $iTotalVotes = 0;
     $aTotalVotes = array();
     foreach ($aAnswers as $aAnswer) {
         if ($aAnswer['total_votes'] > 0) {
             if (isset($aTotalVotes[$aAnswer['poll_id']])) {
                 $aTotalVotes[$aAnswer['poll_id']] += $aAnswer['total_votes'];
                 //$aTotalVotes[$aAnswer['poll_id']]+1;
             } else {
                 $aTotalVotes[$aAnswer['poll_id']] = $aAnswer['total_votes'];
             }
         }
     }
     foreach ($aPolls as $iKey => $aPoll) {
         $aPoll['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'poll', 'privacy' => $aPoll['privacy'], 'comment_privacy' => $aPoll['privacy_comment'], 'like_type_id' => 'poll', 'feed_is_liked' => isset($aPoll['is_liked']) ? $aPoll['is_liked'] : false, 'feed_is_friend' => isset($aPoll['is_friend']) ? $aPoll['is_friend'] : false, 'item_id' => $aPoll['poll_id'], 'user_id' => $aPoll['user_id'], 'total_comment' => $aPoll['total_comment'], 'feed_total_like' => $aPoll['total_like'], 'total_like' => $aPoll['total_like'], 'feed_link' => Phpfox::permalink('poll', $aPoll['poll_id'], $aPoll['question']), 'feed_title' => $aPoll['question']);
         $aPolls2[$aPoll['poll_id']] = $aPoll;
         if ($aPoll['poll_id']['user_id'] == Phpfox::getUserId()) {
             $aPolls2[$aPoll['poll_id']]['user_voted_this_poll'] = 'true';
         } else {
             $aPolls2[$aPoll['poll_id']]['user_voted_this_poll'] = 'false';
             // this could be tricky, test and see if it works everywhere
         }
         if (!isset($aPolls2[$aPoll['poll_id']]['total_votes'])) {
             $aPolls2[$aPoll['poll_id']]['total_votes'] = 0;
         }
         foreach ($aAnswers as &$aAnswer) {
             // we add the total votes for the poll
             if (!isset($aAnswer['vote_percentage'])) {
                 $aAnswer['vote_percentage'] = 0;
             }
             if (!isset($aAnswer['total_votes'])) {
                 $aAnswer['total_votes'] = 0;
             }
             // Normalize if user voted this answer or not
             if (isset($aAnswer['voted']) && $aAnswer['voted'] == Phpfox::getUserId()) {
                 $aAnswer['user_voted_this_answer'] = 1;
             } else {
                 $aAnswer['user_voted_this_answer'] = 2;
             }
             if ($aPoll['poll_id'] == $aAnswer['poll_id']) {
                 if (isset($aTotalVotes[$aAnswer['poll_id']]) && $aTotalVotes[$aAnswer['poll_id']] > 0) {
                     $aAnswer['vote_percentage'] = round($aAnswer['total_votes'] / $aTotalVotes[$aAnswer['poll_id']] * 100);
                 } else {
                     $aAnswer['vote_percentage'] = 0;
                 }
                 $aPolls2[$aPoll['poll_id']]['answer'][$aAnswer['answer_id']] = $aAnswer;
                 $aPolls2[$aPoll['poll_id']]['total_votes'] += $aAnswer['total_votes'];
             }
         }
         if ($aPoll['randomize'] == 1 && !empty($aPolls2[$aPoll['poll_id']]['answer'])) {
             shuffle($aPolls2[$aPoll['poll_id']]['answer']);
         }
     }
     ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getpolls_end')) ? eval($sPlugin) : false;
     return array($iCnt, $aPolls2);
 }
コード例 #17
0
ファイル: process.class.php プロジェクト: haisay/phpfox
 public function add($aVals, $iUserId = null, $sUserName = null)
 {
     $iUserId = $iUserId === null ? Phpfox::getUserId() : (int) $iUserId;
     $sUserName = $sUserName === null ? Phpfox::getUserBy('full_name') : $sUserName;
     // http://www.phpfox.com/tracker/view/15205/
     // check if user can comment on this item
     if (Phpfox::isModule('feed') && isset($aVals['is_via_feed']) && !empty($aVals['is_via_feed'])) {
         $aFeed = $this->database()->select('privacy, privacy_comment, user_id')->from(Phpfox::getT('feed'))->where('item_id = ' . (int) $aVals['item_id'] . ' AND type_id = "' . Phpfox::getLib('parse.input')->clean($aVals['type']) . '"')->execute('getSlaveRow');
         if (!empty($aFeed) && !Phpfox::getUserParam('privacy.can_comment_on_all_items')) {
             if (isset($aFeed['privacy_comment']) && !empty($aFeed['privacy']) && !empty($aFeed['user_id']) && $aFeed['user_id'] != $iUserId) {
                 if ($aFeed['privacy_comment'] == 1 && Friend_Service_Friend::instance()->isFriend($iUserId, $aFeed['user_id']) != true) {
                     return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                 } else {
                     if ($aFeed['privacy_comment'] == 2 && Friend_Service_Friend::instance()->isFriendOfFriend($iUserId) != true) {
                         return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                     } else {
                         if ($aFeed['privacy_comment'] == 3 && $aFeed['user_id'] != Phpfox::getUserId()) {
                             return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                         } else {
                             if ($aFeed['privacy_comment'] == 4 && ($bCheck = Privacy_Service_Privacy::instance()->check($aVals['type'], $aVals['item_id'], $aFeed['user_id'], $aFeed['privacy_comment'], null, true)) != true) {
                                 return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                             }
                         }
                     }
                 }
             }
             // Fallback: if the item is private and it cannot be accessed by the one trying to comment, then, the user should not be able to.
             if (isset($aFeed['privacy']) && !empty($aFeed['privacy']) && !empty($aFeed['user_id']) && $aFeed['user_id'] != $iUserId) {
                 if ($aFeed['privacy'] == 1 && Friend_Service_Friend::instance()->isFriend($iUserId, $aFeed['user_id']) != true) {
                     return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                 } else {
                     if ($aFeed['privacy'] == 2 && Friend_Service_Friend::instance()->isFriendOfFriend($iUserId) != true) {
                         return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                     } else {
                         if ($aFeed['privacy'] == 3 && $aFeed['user_id'] != Phpfox::getUserId()) {
                             return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                         } else {
                             if ($aFeed['privacy'] == 4 && ($bCheck = Privacy_Service_Privacy::instance()->check($aVals['type'], $aVals['item_id'], $aFeed['user_id'], $aFeed['privacy'], null, true)) != true) {
                                 return Phpfox_Error::display(Phpfox::getPhrase('feed.unable_to_post_a_comment_on_this_item_due_to_privacy_settings'));
                             }
                         }
                     }
                 }
             }
         }
     }
     // END
     if (isset($aVals['parent_group_id']) && isset($aVals['group_view_id']) && $aVals['group_view_id'] > 0) {
         define('PHPFOX_SKIP_FEED', true);
     }
     if (Phpfox::getParam('comment.comment_hash_check')) {
         if (Phpfox::getLib('spam.hash', array('table' => 'comment_hash', 'total' => Phpfox::getParam('comment.comments_to_check'), 'time' => Phpfox::getParam('comment.total_minutes_to_wait_for_comments'), 'content' => $aVals['text']))->isSpam()) {
             return false;
         }
     }
     if ($aVals['type'] != 'app') {
         $aItem = Phpfox::callback($aVals['type'] . '.getCommentItem', $aVals['item_id']);
         if (!isset($aItem['comment_item_id'])) {
             return false;
         }
     } else {
         $feed = $this->database()->select('*')->from(':feed')->where(['feed_id' => $aVals['item_id']])->get();
         $aItem['comment_user_id'] = $feed['user_id'];
         $aItem['comment_view_id'] = 0;
     }
     $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aItem['comment_user_id'], Phpfox::getUserId());
     if ($bIsBlocked) {
         Phpfox_Error::set('Unable to leave a comment at this time.');
         return false;
     }
     $aVals = array_merge($aItem, $aVals);
     $bCheck = Phpfox::getService('ban')->checkAutomaticBan($aVals['text']);
     if ($bCheck == false) {
         return false;
     }
     $aInsert = array('parent_id' => $aVals['parent_id'], 'type_id' => $aVals['type'], 'item_id' => $aVals['item_id'], 'user_id' => $iUserId, 'owner_user_id' => $aItem['comment_user_id'], 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox_Request::instance()->getServer('REMOTE_ADDR'), 'view_id' => $aItem['comment_view_id'] == 2 && $aItem['comment_user_id'] != $iUserId ? '1' : '0', 'author' => !empty($aVals['is_via_feed']) ? (int) $aVals['is_via_feed'] : '');
     if (!$iUserId) {
         $aInsert['author'] = substr($aVals['author'], 0, 255);
         $aInsert['author_email'] = $aVals['author_email'];
         if (!empty($aVals['author_url']) && Phpfox_Validator::instance()->verify('url', $aVals['author_url'])) {
             $aInsert['author_url'] = $aVals['author_url'];
         }
     }
     $bIsSpam = false;
     if (Phpfox::getParam('comment.spam_check_comments')) {
         if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['text']))))) {
             $aInsert['view_id'] = '9';
             $bIsSpam = true;
             Phpfox_Error::set(Phpfox::getPhrase('comment.your_comment_has_been_marked_as_spam_it_will_have_to_be_approved_by_an_admin'));
         }
     }
     if (Phpfox::getUserParam('comment.approve_all_comments')) {
         $aInsert['view_id'] = '1';
         $bIsSpam = true;
         Phpfox_Ajax::instance()->sPopupMessage = Phpfox::getPhrase('core.notice');
         Phpfox_Error::set(Phpfox::getPhrase('comment.your_comment_has_successfully_been_added_however_it_is_pending_an_admins_approval'));
     }
     ($sPlugin = Phpfox_Plugin::get('comment.service_process_add')) ? eval($sPlugin) : false;
     $iId = $this->database()->insert($this->_sTable, $aInsert);
     Phpfox::getLib('parse.bbcode')->useVideoImage($aVals['type'] == 'feed' ? true : false);
     $aVals['text_parsed'] = Phpfox::getLib('parse.input')->prepare($aVals['text'], false, ['comment' => $iId]);
     $this->database()->insert(Phpfox::getT('comment_text'), array('comment_id' => $iId, 'text' => Phpfox::getLib('parse.input')->clean($aVals['text']), 'text_parsed' => $aVals['text_parsed']));
     // http://www.phpfox.com/tracker/view/14660/
     $sComment = Phpfox::getLib('parse.input')->clean($aVals['text']);
     if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_hashtag_support')) {
         Phpfox::getService('tag.process')->add($aInsert['type_id'], $aInsert['item_id'], Phpfox::getUserId(), $sComment, true);
     }
     $aVals['comment_id'] = $iId;
     if (!empty($aVals['parent_id'])) {
         $this->database()->updateCounter('comment', 'child_total', 'comment_id', (int) $aVals['parent_id']);
     }
     if ($bIsSpam === true) {
         return false;
     }
     Phpfox::getService('user.process')->notifyTagged($aVals['text'], $iId, $aVals['type']);
     // Callback this action to other modules
     Phpfox::callback($aVals['type'] . '.addComment', $aVals, $iUserId, $sUserName);
     if ($aItem['comment_view_id'] == 2 && $aItem['comment_user_id'] != $iUserId) {
         Phpfox::isModule('request') ? Phpfox::getService('request.process')->add('comment_pending', $iId, $aItem['comment_user_id']) : false;
         return 'pending_moderation';
     }
     // Update user activity
     Phpfox::getService('user.activity')->update(Phpfox::getUserId(), 'comment');
     $sFeedPrefix = '';
     $sNewTypeId = $aVals['type'];
     if (!empty($aItem['parent_module_id']) && ($aItem['parent_module_id'] == 'pages' || $aItem['parent_module_id'] == 'event')) {
         $sFeedPrefix = $aItem['parent_module_id'] . '_';
         if ($sNewTypeId == 'pages') {
             $sNewTypeId = 'pages_comment';
         }
         if ($sNewTypeId == 'event') {
             $sNewTypeId = 'event_comment';
         }
     }
     /*
     p($sFeedPrefix);
     p('type_id = \'' . $this->database()->escape($aVals['type']) . '\' AND item_id = ' . (int) $aVals['item_id']);
     exit;
     */
     Phpfox::getService('feed.process')->clearCache($aVals['type'], $aVals['item_id']);
     $this->database()->update(Phpfox::getT($sFeedPrefix . 'feed'), array('time_update' => PHPFOX_TIME), 'type_id = \'' . $this->database()->escape($sNewTypeId) . '\' AND item_id = ' . (int) $aVals['item_id']);
     ($sPlugin = Phpfox_Plugin::get('comment.service_process_add_end')) ? eval($sPlugin) : false;
     return $iId;
 }
コード例 #18
0
ファイル: view.class.php プロジェクト: nima7r/phpfox-dist
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('quiz.can_access_quiz', true);
     if (Phpfox::isModule('notification') && Phpfox::isUser()) {
         Phpfox::getService('notification.process')->delete('comment_quiz', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('quiz_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if ($this->request()->get('req4') && $this->request()->get('req4') == 'answer') {
         // check that this user has not taken the quiz yet
         $aVals = $this->request()->getArray('val');
         if (Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $this->request()->get('req2'))) {
             Phpfox_Error::set(Phpfox::getPhrase('quiz.you_have_already_answered_this_quiz'));
         } elseif (!isset($aVals['answer'])) {
             Phpfox_Error::set(Phpfox::getPhrase('quiz.you_have_to_answer_the_questions_if_you_want_to_do_that'));
         } else {
             Phpfox::isUser(true);
             // check if user is allowed to answer their own quiz
             $aQuizC = Phpfox::getService('quiz')->getQuizById($this->request()->get('req2'));
             if (!isset($aQuizC['user_id']) || empty($aQuizC['user_id'])) {
                 $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.that_quiz_does_not_exist_or_its_awaiting_moderation'));
             }
             if (!Phpfox::getUserParam('quiz.can_answer_own_quiz') && $aQuizC['user_id'] == Phpfox::getUserId()) {
                 $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.you_are_not_allowed_to_answer_your_own_quiz'));
             }
             $iScore = false;
             $iScore = Quiz_Service_Process::instance()->answerQuiz($this->request()->get('req2'), $aVals['answer']);
             if (is_numeric($iScore)) {
                 // Answers submitted correctly
                 $aUser = $this->getParam('aUser');
                 $this->url()->permalink('quiz', $this->request()->get('req2'), $this->request()->get('req3'), true, Phpfox::getPhrase('quiz.your_answers_have_been_submitted_and_your_score_is_score', array('score' => $iScore)), array('results', 'id' => Phpfox::getUserId()));
             } else {
                 Phpfox_Error::set($iScore);
             }
         }
     }
     $this->setParam('bViewingQuiz', true);
     $aQuiz = array();
     $bShowResults = false;
     $bShowUsers = false;
     $bCanTakeQuiz = true;
     // $bShowResults == true -> only when viewing results for one user only
     // $bShowUsers == true -> when viewing all results from a quiz
     $sQuizUrl = $this->request()->get('req2');
     $sQuizUrl = Phpfox::getLib('parse.input')->clean($sQuizUrl);
     if ($this->request()->get('req4') == 'results') {
         $bHasTaken = Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $sQuizUrl);
         if ($bHasTaken) {
             $bCanTakeQuiz = false;
         }
         if ($iUser = $this->request()->getInt('id')) {
             // show the results of just one user
             $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, $iUser);
             $bShowResults = true;
         } else {
             $bShowUsers = true;
             $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false);
         }
         // need it here to have the quiz' info
         if (!Phpfox::getUserParam('quiz.can_view_results_before_answering') && !$bHasTaken && $aQuiz['user_id'] != Phpfox::getUserId()) {
             $this->url()->send($this->request()->get('req1') . '/' . $this->request()->get('req2') . '/' . $sQuizUrl, null, Phpfox::getPhrase('quiz.you_need_to_answer_the_quiz_before_looking_at_the_results'));
         }
         if (Phpfox::getUserParam('quiz.can_post_comment_on_quiz')) {
             $this->template()->assign(array('bShowInputComment' => true))->setHeader(array('comment.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'pager.css' => 'style_css'));
             if (Phpfox::getUserId()) {
                 $this->template()->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')));
             }
         }
     } elseif ($this->request()->get('req4') == 'take') {
         $bShowResults = false;
         $bShowUsers = false;
         $bCanTakeQuiz = false;
         $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, true, true);
     } else {
         if (Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $sQuizUrl)) {
             $bCanTakeQuiz = false;
             $bShowResults = false;
             $bShowUsers = true;
             $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false);
         } else {
             $bCanTakeQuiz = true;
             $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false, true);
         }
         if (Phpfox::getUserParam('quiz.can_post_comment_on_quiz')) {
             $this->template()->assign(array('bShowInputComment' => true))->setHeader(array('comment.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'pager.css' => 'style_css'));
             if (Phpfox::getUserId()) {
                 $this->template()->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')));
             }
         }
     }
     // crash control, in a perfect world this shouldnt happen
     if (empty($aQuiz)) {
         $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.that_quiz_does_not_exist_or_its_awaiting_moderation'));
     }
     if (Phpfox::getUserId() == $aQuiz['user_id'] && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('quiz_approved', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     Phpfox::getService('core.redirect')->check($aQuiz['title']);
     if (Phpfox::isModule('privacy')) {
         if (!isset($aQuiz['is_friend'])) {
             $aQuiz['is_friend'] = 0;
         }
         Privacy_Service_Privacy::instance()->check('quiz', $aQuiz['quiz_id'], $aQuiz['user_id'], $aQuiz['privacy'], $aQuiz['is_friend']);
     }
     // extra info: used for displaying results for one user
     if (isset($aQuiz['results'][0])) {
         $aQuiz['takerInfo']['userinfo'] = array('user_name' => $aQuiz['results'][0]['user_name'], 'user_id' => $aQuiz['results'][0]['user_id'], 'server_id' => $aQuiz['results'][0]['server_id'], 'full_name' => $aQuiz['results'][0]['full_name'], 'gender' => $aQuiz['results'][0]['gender'], 'user_image' => $aQuiz['results'][0]['user_image']);
         $aQuiz['takerInfo']['time_stamp'] = $aQuiz['results'][0]['time_stamp'];
     }
     if (!isset($aQuiz['is_viewed'])) {
         $aQuiz['is_viewed'] = 0;
     }
     if (Phpfox::isUser() && Phpfox::getUserId() != $aQuiz['user_id'] && !$aQuiz['is_viewed'] && !Phpfox::getUserBy('is_invisible')) {
         // the updateView should only happen when the user has submitted a
         Quiz_Service_Process::instance()->updateView($aQuiz, Phpfox::getUserId());
         if (Phpfox::isModule('track')) {
             Phpfox::getService('track.process')->add('quiz', $aQuiz['quiz_id']);
         }
     }
     if (Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aQuiz['quiz_id'] && $aQuiz['is_viewed'] && !Phpfox::getUserBy('is_invisible')) {
         Phpfox::getService('track.process')->update('quiz_track', $aQuiz['quiz_id']);
     }
     if (isset($aQuiz['aTakenBy'])) {
         $this->setParam('aTakers', $aQuiz['aTakenBy']);
     }
     if (Phpfox::isModule('notification') && $aQuiz['user_id'] == Phpfox::getUserId()) {
         Phpfox::getService('notification.process')->delete('quiz_notifyLike', $aQuiz['quiz_id'], Phpfox::getUserId());
     }
     /*
      * the quiz_track table is used to track who has viewed the quiz
      * the quiz_result to track who has taken the quiz.
      */
     $this->setParam(array('sTrackType' => 'quiz', 'iTrackId' => $aQuiz['quiz_id'], 'iTrackUserId' => $aQuiz['user_id']));
     $this->setParam('aFeed', array('comment_type_id' => 'quiz', 'privacy' => $aQuiz['privacy'], 'comment_privacy' => $aQuiz['privacy_comment'], 'like_type_id' => 'quiz', 'feed_is_liked' => $aQuiz['is_liked'], 'feed_is_friend' => $aQuiz['is_friend'], 'item_id' => $aQuiz['quiz_id'], 'user_id' => $aQuiz['user_id'], 'total_comment' => $aQuiz['total_comment'], 'total_like' => $aQuiz['total_like'], 'feed_link' => $this->url()->permalink('quiz', $aQuiz['quiz_id'], $aQuiz['title']), 'feed_title' => $aQuiz['title'], 'feed_display' => 'view', 'feed_total_like' => $aQuiz['total_like'], 'report_module' => 'quiz', 'report_phrase' => Phpfox::getPhrase('quiz.report_this_quiz')));
     $this->template()->setTitle($aQuiz['title'])->setTitle(Phpfox::getPhrase('quiz.quizzes'))->setBreadcrumb(Phpfox::getPhrase('quiz.quizzes'), $this->url()->makeUrl('quiz'))->setBreadcrumb($aQuiz['title'], $this->url()->permalink('quiz', $aQuiz['quiz_id'], $aQuiz['title']), true)->setMeta('description', Phpfox::getPhrase('quiz.full_name_s_quiz_from_time_stamp_title', array('full_name' => $aQuiz['full_name'], 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.description_time_stamp'), $aQuiz['time_stamp']), 'title' => $aQuiz['title'])))->setMeta('keywords', $this->template()->getKeywords($aQuiz['title']))->setMeta('keywords', Phpfox::getParam('quiz.quiz_meta_keywords'))->setMeta('description', Phpfox::getParam('quiz.quiz_meta_description'))->assign(array('bIsViewingQuiz' => true, 'bShowResults' => $bShowResults, 'bShowUsers' => $bShowUsers, 'bCanTakeQuiz' => $bCanTakeQuiz, 'aQuiz' => $aQuiz, 'sSuffix' => '_' . Phpfox::getParam('quiz.quiz_max_image_pic_size')))->setPhrase(array('quiz.are_you_sure_you_want_to_delete_this_quiz'))->setHeader('cache', array('quiz.js' => 'module_quiz', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'feed.js' => 'module_feed'));
     ($sPlugin = Phpfox_Plugin::get('quiz.component_controller_view_process_end')) ? eval($sPlugin) : false;
 }
コード例 #19
0
 public function getLatestPages($iId, $userId = null)
 {
     Privacy_Service_Privacy::instance()->buildPrivacy(array('module_id' => 'pages', 'alias' => 'pages', 'field' => 'page_id', 'table' => Phpfox::getT('pages'), 'service' => 'pages.browse'));
     $this->database()->unionFrom('pages');
     return $this->database()->select('pages.*, pu.vanity_url, ' . Phpfox::getUserField('u2', 'profile_'))->join(Phpfox::getT('user'), 'u2', 'u2.profile_page_id = pages.page_id')->leftJoin(Phpfox::getT('pages_url'), 'pu', 'pu.page_id = pages.page_id')->limit(8)->order('pages.time_stamp DESC')->where('pages.type_id = ' . (int) $iId . ($userId ? ' AND pages.user_id = ' . (int) $userId : ''))->execute('getSlaveRows');
 }