Exemple #1
1
 /**
  * Controller
  */
 public function process()
 {
     $bIsUserProfile = $this->getParam('bIsProfile');
     if ($bIsUserProfile) {
         $aUser = $this->getParam('aUser');
     }
     Phpfox::getUserParam('pages.can_view_browse_pages', true);
     if ($this->request()->getInt('req2') > 0) {
         /*
         Phpfox_Module::instance()->setCacheBlockData(array(
         		'table' => 'pages_design_order',
         		'field' => 'page_id',
         		'item_id' => $this->request()->getInt('req2'),
         		'controller' => 'pages.view'
         	)
         );
         */
         return Phpfox_Module::instance()->setController('pages.view');
     }
     if (($iDeleteId = $this->request()->getInt('delete')) && Phpfox::getService('pages.process')->delete($iDeleteId)) {
         $this->url()->send('pages', array(), Phpfox::getPhrase('pages.page_successfully_deleted'));
     }
     $sView = $this->request()->get('view');
     if (defined('PHPFOX_IS_AJAX_CONTROLLER')) {
         $bIsProfile = true;
         $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id'));
         $this->setParam('aUser', $aUser);
     } else {
         $bIsProfile = $this->getParam('bIsProfile');
         if ($bIsProfile === true) {
             $aUser = $this->getParam('aUser');
         }
     }
     if ($bIsProfile) {
         $this->template()->setTitle(Phpfox::getPhrase('pages.full_name_s_pages', array('full_name' => $aUser['full_name'])))->setBreadcrumb(Phpfox::getPhrase('pages.pages'), $this->url()->makeUrl($aUser['user_name'], array('pages')));
     } else {
         $this->template()->setTitle(Phpfox::getPhrase('pages.pages'))->setBreadcrumb(Phpfox::getPhrase('pages.pages'), $this->url()->makeUrl('pages'));
     }
     $this->search()->set(array('type' => 'pages', 'field' => 'pages.page_id', 'search_tool' => array('table_alias' => 'pages', 'search' => array('action' => $bIsProfile === true ? $this->url()->makeUrl($aUser['user_name'], array('pages', 'view' => $this->request()->get('view'))) : $this->url()->makeUrl('pages', array('view' => $this->request()->get('view'))), 'default_value' => Phpfox::getPhrase('pages.search_pages'), 'name' => 'search', 'field' => 'pages.title'), 'sort' => array('latest' => array('pages.time_stamp', Phpfox::getPhrase('pages.latest')), 'most-liked' => array('pages.total_like', Phpfox::getPhrase('pages.most_liked'))), 'show' => array(10, 15, 20))));
     $aBrowseParams = array('module_id' => 'pages', 'alias' => 'pages', 'field' => 'page_id', 'table' => Phpfox::getT('pages'), 'hide_view' => array('pending', 'my'));
     $aFilterMenu = array();
     if (!defined('PHPFOX_IS_USER_PROFILE')) {
         $aFilterMenu = array(Phpfox::getPhrase('pages.all_pages') => '', Phpfox::getPhrase('pages.my_pages') => 'my');
         if (!Phpfox::getParam('core.friends_only_community') && Phpfox::isModule('friend') && !Phpfox::getUserBy('profile_page_id')) {
             $aFilterMenu[Phpfox::getPhrase('pages.friends_pages')] = 'friend';
         }
         if (Phpfox::getUserParam('pages.can_moderate_pages')) {
             $iPendingTotal = Phpfox::getService('pages')->getPendingTotal();
             if ($iPendingTotal) {
                 $aFilterMenu['' . Phpfox::getPhrase('pages.pending_pages') . '<span class="pending">' . $iPendingTotal . '</span>'] = 'pending';
             }
         }
     }
     switch ($sView) {
         case 'my':
             Phpfox::isUser(true);
             $this->search()->setCondition('AND pages.app_id = 0 AND pages.view_id IN(0,1) AND pages.user_id = ' . Phpfox::getUserId());
             break;
         case 'pending':
             Phpfox::isUser(true);
             if (Phpfox::getUserParam('pages.can_moderate_pages')) {
                 $this->search()->setCondition('AND pages.app_id = 0 AND pages.view_id = 1');
             }
             break;
         default:
             if (Phpfox::getUserParam('privacy.can_view_all_items')) {
                 $this->search()->setCondition('AND pages.app_id = 0 ');
             } else {
                 $this->search()->setCondition('AND pages.app_id = 0 AND pages.view_id = 0 AND pages.privacy IN(%PRIVACY%)');
             }
             break;
     }
     // $this->template()->buildSectionMenu('pages', $aFilterMenu);
     $bIsValidCategory = false;
     if ($this->request()->get('req2') == 'category' && ($iCategoryId = $this->request()->getInt('req3')) && ($aType = Phpfox::getService('pages.type')->getById($iCategoryId))) {
         $bIsValidCategory = true;
         $this->setParam('iCategory', $iCategoryId);
         $this->template()->setBreadcrumb(Phpfox_Locale::instance()->convert($aType['name']), Phpfox::permalink('pages.category', $aType['type_id'], $aType['name']) . ($sView ? 'view_' . $sView . '/' . '' : ''), true);
     }
     if ($this->request()->get('req2') == 'sub-category' && ($iSubCategoryId = $this->request()->getInt('req3')) && ($aCategory = Phpfox::getService('pages.category')->getById($iSubCategoryId))) {
         $bIsValidCategory = true;
         $this->setParam('iCategory', $aCategory['type_id']);
         $this->template()->setBreadcrumb(Phpfox_Locale::instance()->convert($aCategory['type_name']), Phpfox::permalink('pages.category', $aCategory['type_id'], $aCategory['type_name']) . ($sView ? 'view_' . $sView . '/' . '' : ''));
         $this->template()->setBreadcrumb(Phpfox_Locale::instance()->convert($aCategory['name']), Phpfox::permalink('pages.sub-category', $aCategory['category_id'], $aCategory['name']) . ($sView ? 'view_' . $sView . '/' . '' : ''), true);
     }
     if (isset($aType['type_id'])) {
         $this->search()->setCondition('AND pages.type_id = ' . (int) $aType['type_id']);
     }
     if (isset($aType['category_id'])) {
         $this->search()->setCondition('AND pages.category_id = ' . (int) $aType['category_id']);
     } elseif (isset($aCategory['category_id'])) {
         $this->search()->setCondition('AND pages.category_id = ' . (int) $aCategory['category_id']);
     }
     if ($bIsUserProfile) {
         $this->search()->setCondition('AND pages.user_id = ' . (int) $aUser['user_id']);
     }
     $aPages = [];
     $aCategories = [];
     $bShowCategories = false;
     if ($this->search()->isSearch()) {
         $bIsValidCategory = true;
     }
     if ($bIsValidCategory) {
         $this->search()->browse()->params($aBrowseParams)->execute();
         $aPages = $this->search()->browse()->getRows();
         foreach ($aPages as $iKey => $aPage) {
             if (!isset($aPage['vanity_url']) || empty($aPage['vanity_url'])) {
                 $aPages[$iKey]['url'] = Phpfox::permalink('pages', $aPage['page_id'], $aPage['title']);
             } else {
                 $aPages[$iKey]['url'] = $aPage['vanity_url'];
             }
         }
         Phpfox_Pager::instance()->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount()));
     } else {
         $bShowCategories = true;
         $aCategories = Phpfox::getService('pages.category')->getForBrowse(0, true, $bIsProfile ? $aUser['user_id'] : null);
     }
     $this->template()->setHeader('cache', array('comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed', 'pages.js' => 'module_pages'))->assign(array('sView' => $sView, 'aPages' => $aPages, 'aCategories' => $aCategories, 'bShowCategories' => $bShowCategories));
     $this->setParam('global_moderation', array('name' => 'pages', 'ajax' => 'pages.pageModeration', 'menu' => array(array('phrase' => Phpfox::getPhrase('pages.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('pages.approve'), 'action' => 'approve'))));
     $iStartCheck = 0;
     if ($bIsValidCategory == true) {
         $iStartCheck = 5;
     }
     $aRediAllow = array('category');
     if (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE) {
         $aRediAllow[] = 'pages';
     }
     $aCheckParams = array('url' => $this->url()->makeUrl('pages'), 'start' => $iStartCheck, 'reqs' => array('2' => $aRediAllow));
     if (Phpfox::getParam('core.force_404_check') && !Phpfox::getService('core.redirect')->check404($aCheckParams)) {
         return Phpfox_Module::instance()->setController('error.404');
     }
 }
 public function get()
 {
     $sType = Phpfox::getParam('themesupporter.block_video_type');
     $sCacheId = $this->cache()->set('brodev_themesupporter_video_' . $sType);
     if (!($aRecords = $this->cache()->get($sCacheId, 300))) {
         switch ($sType) {
             case 'Recently Uploaded Videos':
                 $sOrder = 'time_stamp desc';
                 break;
             case 'Most Viewed Videos':
                 $sOrder = 'total_view desc';
                 break;
             case 'Random Videos':
                 $sOrder = 'rand()';
                 break;
         }
         $aRecords = $this->database()->select('v.*, u.user_name as user_name, u.full_name as full_name')->from($this->_sTable, 'v')->leftJoin(Phpfox::getT('user'), 'u', 'v.user_id = u.user_id')->order($sOrder)->where('v.privacy = 0 AND v.in_process = 0 AND v.view_id = 0')->limit(Phpfox::getParam('themesupporter.block_video_number'))->execute('getRows');
         if (empty($aRecords)) {
             return false;
         }
         foreach ($aRecords as $iKey => $aRow) {
             $aRecords[$iKey]['link'] = Phpfox::permalink('video', $aRow['video_id'], $aRow['title']);
         }
         $this->cache()->save($sCacheId, $aRecords);
     }
     return $aRecords;
 }
Exemple #3
0
	public function processRows(&$aRows)
	{
		foreach ($aRows as $iKey => $aRow)
		{				
			$aRows[$iKey]['link'] = ($this->_aCallback !== false ? Phpfox::getLib('url')->makeUrl($this->_aCallback['url'][0], array_merge($this->_aCallback['url'][1], array($aRow['title']))) : Phpfox::permalink('video', $aRow['video_id'], $aRow['title']));
		}
	}
Exemple #4
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     exit('Use AJAX method');
     Phpfox::isUser(true);
     if (!($iId = $this->request()->get('id'))) {
         return Phpfox_Error::display(Phpfox::getPhrase('video.id_must_be_defined'));
     }
     echo '<script type="text/javascript">';
     if (Phpfox::getService('video.convert')->process($iId)) {
         if ($this->request()->get('video-inline') == '1') {
             $iFeedId = Phpfox::getService('feed.process')->getLastId();
             echo 'window.parent.$.ajaxCall(\'video.displayFeed\', \'id=' . $iFeedId . '&video_id=' . $iId . '\', \'GET\');';
         } elseif ($this->request()->get('isajax')) {
             echo 'window.parent.Editor.insert({type: \'video\', id: \'' . (int) $iId . '\', editor_id: \'' . base64_decode($this->request()->get('editor-id')) . '\'});';
         } else {
             $aVideo = Phpfox::getService('video')->getForEdit($iId);
             echo 'window.parent.location.href = \'' . Phpfox::permalink('video', $aVideo['video_id'], $aVideo['title']) . '\';';
         }
     } else {
         Phpfox::getService('video.process')->delete($iId);
         echo 'window.parent.document.getElementById(\'js_video_upload_error\').style.display = \'block\';';
         echo 'window.parent.document.getElementById(\'js_video_upload_message\').innerHTML = \'' . implode('<br />', Phpfox_Error::get()) . '\';';
         echo 'window.parent.document.getElementById(\'js_upload_inner_form\').style.display = \'block\';';
         echo 'window.parent.document.getElementById(\'js_video_detail\').style.display = \'none\';';
         echo 'window.parent.document.getElementById(\'js_video_process\').style.display = \'none\';';
     }
     echo '</script>';
     exit;
 }
Exemple #5
0
 public function getReportRedirect($iId)
 {
     $aApp = Phpfox::getService('apps')->getAppById($iId);
     if (empty($aApp)) {
         Phpfox_Error::add(Phpfox::getPhrase('apps.app_not_found'));
     }
     return Phpfox::permalink('apps', $iId, $aApp['app_title']);
 }
Exemple #6
0
 public function processRows(&$aRows)
 {
     foreach ($aRows as $iKey => $aRow) {
         $aRows[$iKey]['link'] = Phpfox::permalink('apps', $aRow['app_id'], $aRow['app_title']);
         //Phpfox::getService('pages')->getUrl($aRow['page_id'], $aRow['title'], $aRow['vanity_url']);
         $aRows[$iKey]['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'pages', 'privacy' => 0, 'comment_privacy' => 0, 'like_type_id' => 'pages', 'feed_is_liked' => isset($aRow['is_liked']) ? $aRow['is_liked'] : false, 'item_id' => $aRow['page_id'], 'user_id' => $aRow['user_id'], 'total_comment' => $aRow['total_comment'], 'feed_total_like' => $aRow['total_like'], 'total_like' => $aRow['total_like'], 'feed_link' => Phpfox::getService('pages')->getUrl($aRow['page_id'], $aRow['pages_title'], $aRow['vanity_url']), 'feed_title' => $aRow['app_title']);
     }
 }
Exemple #7
0
 /**
  * parse text for showing on form based on the contest
  * it will replace some predefined symbol by the corresponding text
  * @by minhta
  * @param string $sToBeParsedText the text to be parsed 
  * @param array $aContest the corresponding contest
  * @return
  */
 public function parseTemplate($sToBeParsedText, $aContest, $iDonorId = 0, $iInviterId = 0)
 {
     //if a id of contest is passed
     if (!is_array($aContest)) {
         $aContest = Phpfox::getService('contest.contest')->getContestById($aContest);
     }
     $aContest['site_name'] = Phpfox::getParam('core.site_title');
     // in case we need inviter name
     if ($this->_iInviterId) {
         $aUser = Phpfox::getService('user')->getUser($this->_iInviterId);
         $aContest['inviter_name'] = $aUser['full_name'];
     }
     if ($this->_iEntryId) {
         $aEntry = Phpfox::getService('contest.entry')->getContestEntryById($this->_iEntryId);
         if ($aEntry) {
             $aContest['entry_name'] = $aEntry['title'];
             $sEntryUrl = Phpfox::permalink('contest', $aEntry['contest_id'], $aEntry['contest_name']) . 'entry_' . $aEntry['entry_id'] . '/';
             $aContest['entry_url'] = $sEntryUrl;
         }
     }
     if ($this->_iParticipantId) {
         $aParticipant = Phpfox::getService('contest.participant')->getParticipantById($this->_iParticipantId);
         $aUser = Phpfox::getService('user')->getUser($aParticipant['user_id']);
         $aContest['participant_name'] = $aUser['full_name'];
     }
     if ($this->_iEntryOwnerId) {
         $aUser = Phpfox::getService('user')->getUser($this->_iEntryOwnerId);
         $aContest['entry_owner_name'] = $aUser['full_name'];
     }
     $oDate = Phpfox::getLib('date');
     $aLink = Phpfox::getLib('url')->permalink('contest', $aContest['contest_id'], $aContest['contest_name']);
     $sLink = '<a href="' . $aLink . '" title = "' . $aContest['contest_name'] . '" target="_blank">' . $aLink . '</a>';
     $aContest['contest_url'] = $sLink;
     $format_datetime = 'l, F j, Y g:i a';
     $aContest['end_time'] = Phpfox::getTime($format_datetime, $aContest['end_time']);
     $aContest['stop_time'] = Phpfox::getTime($format_datetime, $aContest['stop_time']);
     $aContest['start_time'] = Phpfox::getTime($format_datetime, $aContest['start_time']);
     //the trick here ot send html email along with description
     $aContest['description'] = $aContest['description_parsed'];
     $aOnwerUser = Phpfox::getService('user')->getUser($aContest['user_id']);
     $aContest['owner_name'] = $aOnwerUser['full_name'];
     $aContest['award'] = $aContest['award_description'];
     $aBeReplaced = array();
     $aReplace = array();
     //setup replace and be replaced array
     foreach ($this->_aReplace as $sBeReplaced => $sReplace) {
         if (isset($aContest[$sReplace])) {
             $aBeReplaced[] = $sBeReplaced;
             $aReplace[] = $aContest[$sReplace];
         }
     }
     $sParsedText = str_replace($aBeReplaced, $aReplace, $sToBeParsedText);
     return $sParsedText;
 }
Exemple #8
0
 public function processRows(&$aRows)
 {
     foreach ($aRows as $iKey => $aRow) {
         if ($aRow['profile_id'] > 0) {
             $aRows[$iKey]['name'] = Phpfox::getPhrase('photo.profile_pictures');
             $aRows[$iKey]['link'] = Phpfox::permalink('photo.album.profile', $aRow['user_id'], $aRow['user_name']);
         } else {
             $aRows[$iKey]['link'] = Phpfox::permalink('photo.album', $aRow['album_id'], $aRow['name']);
         }
     }
 }
Exemple #9
0
 public function getPost($iId)
 {
     ($sPlugin = Phpfox_Plugin::get('forum.service_post_getpost')) ? eval($sPlugin) : false;
     if (Phpfox::isModule('like')) {
         $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'forum_post\' AND l.item_id = fp.post_id AND l.user_id = ' . Phpfox::getUserId());
     }
     $aPost = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post, ft.forum_id, ft.group_id, ft.user_id AS thread_user_id, ft.title AS thread_title')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_thread'), 'ft', 'ft.thread_id = fp.thread_id')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id')->where('fp.post_id = ' . $iId)->execute('getRow');
     $aPost['aFeed'] = array('privacy' => 0, 'comment_privacy' => 0, 'like_type_id' => 'forum_post', 'feed_is_liked' => $aPost['is_liked'] ? true : false, 'item_id' => $aPost['post_id'], 'user_id' => $aPost['user_id'], 'total_like' => $aPost['total_like'], 'feed_link' => Phpfox::permalink('forum.thread', $aPost['thread_id'], $aPost['thread_title']) . 'view_' . $aPost['post_id'] . '/', 'feed_title' => $aPost['thread_title'], 'feed_display' => 'mini', 'feed_total_like' => $aPost['total_like'], 'report_module' => 'forum_post', 'report_phrase' => Phpfox::getPhrase('forum.report_this_post'), 'time_stamp' => $aPost['time_stamp']);
     if ($aPost['total_attachment']) {
         list($iAttachmentCnt, $aPost['attachments']) = Phpfox::getService('attachment')->get('attachment.item_id = ' . $aPost['post_id'] . ' AND attachment.view_id = 0 AND attachment.category_id = \'forum\' AND attachment.is_inline = 0', 'attachment.attachment_id DESC', '', '', false);
     }
     $aPost['last_update_on'] = Phpfox::getPhrase('forum.last_update_on_time_stamp_by_update_user', array('time_stamp' => Phpfox::getTime(Phpfox::getParam('forum.forum_time_stamp'), $aPost['update_time']), 'update_user' => $aPost['update_user']));
     return $aPost;
 }
Exemple #10
0
 public function getList()
 {
     $sCacheId = $this->cache()->set('music_genre');
     if (!($aRows = $this->cache()->get($sCacheId))) {
         $aRows = $this->database()->select('genre_id, name, name_url')->from($this->_sTable)->order('name ASC')->execute('getRows');
         $this->cache()->save($sCacheId, $aRows);
     }
     foreach ($aRows as $iKey => $aRow) {
         if ($sView = Phpfox_Request::instance()->get('view')) {
             $aRows[$iKey]['link'] = Phpfox::permalink('music.genre', $aRow['genre_id'], $aRow['name'], false, null, array('view' => $sView));
         } else {
             $aRows[$iKey]['link'] = Phpfox::permalink('music.genre', $aRow['genre_id'], $aRow['name']);
         }
     }
     return $aRows;
 }
Exemple #11
0
 public function getForBrowse($iCategoryId = null)
 {
     // $sCacheId = $this->cache()->set('organization_category_browse' . ($iCategoryId === null ? '' : '_' . $iCategoryId));
     $aCategories = array();
     if ($iCategoryId > 0) {
         $aCategories = $this->database()->select('pc.*')->from($this->_sTable, 'pc')->where('pc.type_id = ' . (int) $iCategoryId . ' AND pc.is_active = 1')->order('pc.ordering ASC')->execute('getSlaveRows');
         foreach ($aCategories as $iKey => $aCategory) {
             $aCategories[$iKey]['link'] = Phpfox::permalink('organization.sub-category', $aCategory['category_id'], $aCategory['name']);
         }
         return $aCategories;
     }
     $aCategories = $this->database()->select('pt.*')->from(Phpfox::getT('organization_type'), 'pt')->where('pt.is_active = 1')->order('pt.ordering ASC')->execute('getSlaveRows');
     foreach ($aCategories as $iKey => $aCategory) {
         $aCategories[$iKey]['link'] = Phpfox::permalink('organization.category', $aCategory['type_id'], $aCategory['name']);
     }
     return $aCategories;
 }
Exemple #12
0
 public function processRows(&$aRows)
 {
     $oReq = Phpfox::getLib('request');
     foreach ($aRows as $iKey => $aRow) {
         $aRows[$iKey]['link'] = Phpfox::permalink('photo', $aRow['photo_id'], $aRow['title']);
         if (Phpfox::getUserId() && defined('PHPFOX_IS_USER_PROFILE') || $oReq->get('req1') == 'photo' && $oReq->get('view') == 'my') {
             $aRows[$iKey]['link'] .= 'userid_' . $aRow['user_id'] . '/';
         }
         $aRows[$iKey]['destination'] = Phpfox::getService('photo')->getPhotoUrl($aRow);
         if (Phpfox::getLib('request')->get('mode') == 'edit') {
             $sCategoryList = '';
             $aCategories = (array) $this->database()->select('category_id')->from(Phpfox::getT('photo_category_data'))->where('photo_id = ' . (int) $aRow['photo_id'])->execute('getSlaveRows');
             foreach ($aCategories as $aCategory) {
                 $sCategoryList .= $aCategory['category_id'] . ',';
             }
             $aRows[$iKey]['category_list'] = rtrim($sCategoryList, ',');
         }
     }
 }
Exemple #13
0
 public function execute()
 {
     if ($this->_sCategory !== null) {
         $sCategories = Phpfox::getService('video.category')->getAllCategories($this->_sCategory);
         $this->database()->innerJoin(Phpfox::getT('video_category_data'), 'vcd', 'vcd.video_id = m.video_id');
         $this->_aConditions[] = ' AND vcd.category_id IN(' . $sCategories . ')';
     }
     $this->_iCnt = $this->database()->select($this->_sCategory !== null ? 'COUNT(DISTINCT m.video_id)' : 'COUNT(*)')->from($this->_sTable, 'm')->where($this->_aConditions)->execute('getSlaveField');
     if ($this->_iCnt) {
         if ($this->_sCategory !== null) {
             $this->database()->innerJoin(Phpfox::getT('video_category_data'), 'vcd', 'vcd.video_id = m.video_id')->group('m.video_id');
         }
         $aVideos = $this->database()->select('m.*, ' . Phpfox::getUserField())->from($this->_sTable, 'm')->join(Phpfox::getT('user'), 'u', 'u.user_id = m.user_id')->where($this->_aConditions)->order($this->_sOrder)->group('m.video_id')->limit($this->_iPage, $this->_iPageSize, $this->_iCnt)->execute('getSlaveRows');
         foreach ($aVideos as $aVideo) {
             $aVideo['breadcrumb'] = Phpfox::getService('video.category')->getCategoriesById($aVideo['video_id']);
             $aVideo['link'] = Phpfox::permalink('video', $aVideo['video_id'], $aVideo['title']);
             $this->_aVideos[] = $aVideo;
         }
     }
 }
Exemple #14
0
 /**
  * This controller orchestrates to register a new application
  */
 public function process()
 {
     $bIsAdd = $bIsEdit = false;
     Phpfox::getUserParam('apps.can_add_app', true);
     if (!Phpfox::getParam('apps.enable_api_support')) {
         //return Phpfox_Error::display('No api');
     }
     if ($aVals = $this->request()->getArray('app')) {
         $bIsAdd = true;
         $aApp = Phpfox::getService('apps.process')->addApp($aVals);
         if ($aApp == false) {
             $this->template()->assign(array('sErrorMessage' => Phpfox_Error::get()));
         } else {
             $this->url()->send('apps.add', array('id' => $aApp['app_id']), Phpfox::getPhrase('apps.app_successfully_created'));
         }
     }
     if (($iId = $this->request()->getInt('id')) && $this->request()->get('req2') == 'add') {
         // is editing an app
         $aApp = Phpfox::getService('apps')->getAppById($iId);
         $this->template()->assign('aForms', $aApp);
         $bIsEdit = true;
         $aMenus = array('general' => Phpfox::getPhrase('apps.general'), 'photo' => Phpfox::getPhrase('apps.photo'), 'url' => Phpfox::getPhrase('apps.url'));
         $this->template()->buildPageMenu('js_apps_block', $aMenus, array('link' => Phpfox::permalink('apps', $aApp['app_id'], $aApp['app_title']), 'phrase' => Phpfox::getPhrase('apps.view_this_app')));
         if ($aVals = $this->request()->getArray('val')) {
             if (Phpfox::getService('apps.process')->updateApp($aVals, $aApp)) {
                 $this->url()->send('apps.add', array('id' => $aApp['app_id']), Phpfox::getPhrase('apps.successfully_updated_the_app'));
             }
         }
         // check that this user is owner of the app
         // we can have a user group setting here
         if ($aApp['user_id'] != Phpfox::getUserId() && !Phpfox::isAdmin()) {
             Phpfox_Error::display(Phpfox::getPhrase('apps.you_are_not_allowed_to_edit_this_app'));
         } else {
             $this->template()->assign(array('aApp' => $aApp))->setHeader(array('index.js' => 'module_apps'));
         }
     }
     $aCategories = Phpfox::getService('apps.category')->getAllCategories();
     $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('apps.editing_app') . ': ' . $aApp['app_title'] : Phpfox::getPhrase('apps.create_an_app'))->setFullSite()->setBreadcrumb(Phpfox::getPhrase('apps.apps'), $this->url()->makeUrl('apps'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('apps.editing_app') . ': ' . $aApp['app_title'] : Phpfox::getPhrase('apps.create_an_app'), $this->url()->makeUrl('apps.add'), true)->assign(array('aCategories' => $aCategories));
 }
Exemple #15
0
 public function get($iId = 0)
 {
     /*
     @title
     @info Get all public blogs. If you pass a user ID# it will return the blogs for that user. If you pass a blog ID# it will just return that blog.
     @method GET
     @extra user_id=#{User ID# of a specific user|int|no}&id=#{Blog ID# if you wish to return a specific blog|int|no}
     @return id=#{ID# for the blog|int}&title=#{Title of the blog|string}&permalink=#{Link to the blog|string}&likes=#{Total number of likes|int}&content=#{Blog content|string}&created_by=#{User that created the blog|string}&created_by_url=#{Link to the users profile|string}
     */
     if ((int) $this->_oApi->get('id') !== 0) {
         $iId = $this->_oApi->get('id');
     }
     $iUserId = $this->_oApi->get('user_id');
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'b')->where(empty($iId) ? '' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.is_approved = 1 AND b.privacy = 0 AND b.post_status = 1' : 'b.blog_id = ' . (int) $iId)->execute('getSlaveField');
     $this->_oApi->setTotal($iCnt);
     $aRows = $this->database()->select('b.*, bt.text_parsed, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('blog_text'), 'bt', 'bt.blog_id = b.blog_id')->where(empty($iId) ? '' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.is_approved = 1 AND b.privacy = 0 AND b.post_status = 1' : 'b.blog_id = ' . (int) $iId)->limit($this->_oApi->get('page'), 10, $iCnt)->order('b.time_stamp DESC')->execute('getSlaveRows');
     $aReturn = array();
     foreach ($aRows as $iKey => $aRow) {
         $aReturn[$iKey] = array('id' => $aRow['blog_id'], 'title' => $aRow['title'], 'likes' => $aRow['total_like'], 'permalink' => Phpfox::permalink('blog', $aRow['blog_id'], $aRow['title']), 'content' => Phpfox::getLib('parse.output')->parse($aRow['text_parsed']), 'created_by' => $aRow['full_name'], 'created_by_url' => Phpfox::getLib('url')->makeUrl($aRow['user_name']));
     }
     return $aReturn;
 }
Exemple #16
0
	public function processRows(&$aQuizzes)
	{
		foreach ($aQuizzes as $iKey => $aQuiz)
		{
			$aQuizzes[$iKey]['aFeed'] = array(			
				'feed_display' => 'mini',	
				'comment_type_id' => 'quiz',
				'privacy' => $aQuiz['privacy'],
				'comment_privacy' => $aQuiz['privacy_comment'],
				'like_type_id' => 'quiz',				
				'feed_is_liked' => (isset($aQuiz['is_liked']) ? $aQuiz['is_liked'] : false),
				'feed_is_friend' => (isset($aQuiz['is_friend']) ? $aQuiz['is_friend'] : false),
				'item_id' => $aQuiz['quiz_id'],
				'user_id' => $aQuiz['user_id'],
				'total_comment' => $aQuiz['total_comment'],
				'feed_total_like' => $aQuiz['total_like'],
				'total_like' => $aQuiz['total_like'],
				'feed_link' => Phpfox::permalink('quiz', $aQuiz['quiz_id'], $aQuiz['title']),
				'feed_title' => $aQuiz['title']			
			);				
		}
	}
Exemple #17
0
 public function getForBrowse($iCategoryId = null, $bIncludePages = false, $userId = null)
 {
     // $sCacheId = $this->cache()->set('pages_category_browse' . ($iCategoryId === null ? '' : '_' . $iCategoryId));
     $aCategories = array();
     if ($iCategoryId > 0) {
         $aCategories = $this->database()->select('pc.*')->from($this->_sTable, 'pc')->where('pc.type_id = ' . (int) $iCategoryId . ' AND pc.is_active = 1')->order('pc.ordering ASC')->execute('getSlaveRows');
         foreach ($aCategories as $iKey => $aCategory) {
             $aCategories[$iKey]['link'] = Phpfox::permalink('pages.sub-category', $aCategory['category_id'], $aCategory['name']);
         }
         return $aCategories;
     }
     $aCategories = $this->database()->select('pt.*')->from(Phpfox::getT('pages_type'), 'pt')->where('pt.is_active = 1')->order('pt.ordering ASC')->execute('getSlaveRows');
     foreach ($aCategories as $iKey => $aCategory) {
         if ($bIncludePages) {
             $aCategories[$iKey]['pages'] = $this->getLatestPages($aCategory['type_id'], $userId);
             foreach ($aCategories[$iKey]['pages'] as $iSubKey => $aRow) {
                 $aCategories[$iKey]['pages'][$iSubKey]['link'] = Phpfox::getService('pages')->getUrl($aRow['page_id'], $aRow['title'], $aRow['vanity_url']);
             }
         }
         $aCategories[$iKey]['link'] = Phpfox::permalink('pages.category', $aCategory['type_id'], $aCategory['name']);
     }
     return $aCategories;
 }
Exemple #18
0
 public function process()
 {
     header('Content-type: application/javascript');
     $ids = [];
     $forums = Forum_Service_Forum::instance()->getForums();
     foreach ($forums as $forum) {
         $ids[] = $forum['forum_id'];
         $childs = Forum_Service_Forum::instance()->id($forum['forum_id'])->getChildren();
         if ($childs) {
             foreach ($childs as $id) {
                 $ids[] = $id;
             }
         }
     }
     $cond[] = 'ft.forum_id IN(' . implode(',', $ids) . ') AND ft.group_id = 0 AND ft.view_id >= 0';
     list($cnt, $threads) = Forum_Service_Thread_Thread::instance()->get($cond, 'ft.time_update DESC', 0, 20);
     $json = [];
     foreach ($threads as $thread) {
         $json[] = (object) ['thread_id' => $thread['thread_id'], 'title' => $thread['title'], 'permalink' => Phpfox::permalink('forum.thread', $thread['thread_id'], $thread['title']), 'user' => htmlspecialchars($thread['full_name']), 'created' => Phpfox::getLib('date')->convertTime($thread['time_stamp'])];
     }
     echo ';function __Threads(callback) { var threads = ' . json_encode($json) . '; if (typeof(callback) == \'function\') { callback(threads); } };';
     exit;
 }
Exemple #19
0
	public function processRows(&$aRows)
	{
		foreach ($aRows as $iKey => $aRow)
		{				
			$aRows[$iKey]['link'] = Phpfox::permalink('photo', $aRow['photo_id'], $aRow['title']);
			$aRows[$iKey]['destination'] = Phpfox::getService('photo')->getPhotoUrl($aRow);
			
			if (Phpfox::getLib('request')->get('mode') == 'edit')
			{
				$sCategoryList = '';
				$aCategories = (array) $this->database()->select('category_id')
					->from(Phpfox::getT('photo_category_data'))
					->where('photo_id = ' . (int) $aRow['photo_id'])
					->execute('getSlaveRows');
					
				foreach ($aCategories as $aCategory)
				{
					$sCategoryList .= $aCategory['category_id'] . ',';
				}
				
				$aRows[$iKey]['category_list'] = rtrim($sCategoryList, ',');			
			}
		}
	}	
Exemple #20
0
 public function get($iId = 0)
 {
     /*
     @title
     @info Get a list of all public events. If you pass a user ID# it will return a list of the users events. If you pass a ID# it will return just that event.
     @method GET
     @extra user_id=#{User ID#|int|no}&id=#{Event ID#|int|no}
     @return event_id=#{Event ID#|int}&title=#{Title of the event|string}&likes=#{Total number of likes|int}&permalink=#{Link to the event|string}&info=#{Information about the event|string}&created_by=#{Person who created the event|string}&created_by_url=#{Link to creators profile|string}&photo_200px=#{Default photo for the event. Max 200px|string}
     */
     $iUserId = $this->_oApi->get('user_id');
     if ((int) $this->_oApi->get('id') !== 0) {
         $iId = $this->_oApi->get('id');
     }
     $iTimeDisplay = Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y'));
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'b')->where(empty($iId) ? 'b.view_id = 0 AND b.privacy = 0 AND b.item_id = 0 AND ' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.start_time >= \'' . Phpfox::getLib('date')->convertToGmt($iTimeDisplay) . '\'' : 'b.event_id = ' . (int) $iId)->execute('getSlaveField');
     $this->_oApi->setTotal($iCnt);
     $aRows = $this->database()->select('b.*, bt.description_parsed, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('event_text'), 'bt', 'bt.event_id = b.event_id')->where(empty($iId) ? 'b.view_id = 0 AND b.privacy = 0 AND b.item_id = 0 AND ' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.start_time >= \'' . Phpfox::getLib('date')->convertToGmt($iTimeDisplay) . '\'' : 'b.event_id = ' . (int) $iId)->limit($this->_oApi->get('page'), 10, $iCnt)->order('b.time_stamp DESC')->execute('getSlaveRows');
     $aReturn = array();
     foreach ($aRows as $iKey => $aRow) {
         $aReturn[$iKey] = array('event_id' => $aRow['event_id'], 'title' => $aRow['title'], 'likes' => $aRow['total_like'], 'permalink' => Phpfox::permalink('event', $aRow['event_id'], $aRow['title']), 'info' => Phpfox::getLib('parse.output')->parse($aRow['description_parsed']), 'created_by' => $aRow['full_name'], 'created_by_url' => Phpfox::getLib('url')->makeUrl($aRow['user_name']));
         $aReturn[$iKey]['photo_200px'] = Phpfox::getLib('image.helper')->display(array('path' => 'event.url_image', 'server_id' => $aRow['server_id'], 'file' => $aRow['image_path'], 'suffix' => '_200', 'return_url' => true));
     }
     return $aReturn;
 }
Exemple #21
0
 public function getCategoriesById($iId = null, &$aCategories = null)
 {
     $oUrl = Phpfox_Url::instance();
     if ($aCategories === null) {
         $aCategories = $this->database()->select('pc.parent_id, pc.category_id, pc.name')->from(Phpfox::getT('marketplace_category_data'), 'pcd')->join($this->_sTable, 'pc', 'pc.category_id = pcd.category_id')->where('pcd.listing_id = ' . (int) $iId)->order('pc.parent_id ASC, pc.ordering ASC')->execute('getSlaveRows');
     }
     if (!count($aCategories)) {
         return null;
     }
     $aBreadcrumb = array();
     if (count($aCategories) > 1) {
         foreach ($aCategories as $aCategory) {
             $aBreadcrumb[] = array(Phpfox_Locale::instance()->convert($aCategory['name']), Phpfox::permalink('marketplace.category', $aCategory['category_id'], $aCategory['name']));
         }
     } else {
         $aBreadcrumb[] = array(Phpfox_Locale::instance()->convert($aCategories[0]['name']), Phpfox::permalink('marketplace.category', $aCategories[0]['category_id'], $aCategories[0]['name']));
     }
     return $aBreadcrumb;
 }
Exemple #22
0
 /**
  * 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);
 }
<?php 
                    }
                }
                ?>
									</ul>
<?php 
            } else {
                if (!isset($this->_aVars['bForceLogoOnMenu']) && $this->_aVars['aMainMenu']['url'] == 'apps' && count($this->_aVars['aInstalledApps'])) {
                    ?>
									<ul>
<?php 
                    if (count((array) $this->_aVars['aInstalledApps'])) {
                        foreach ((array) $this->_aVars['aInstalledApps'] as $this->_aVars['aInstalledApp']) {
                            ?>
										<li><a href="<?php 
                            echo Phpfox::permalink('apps', $this->_aVars['aInstalledApp']['app_id'], $this->_aVars['aInstalledApp']['app_title'], false, null, (array) array());
                            ?>
" title="<?php 
                            echo Phpfox::getLib('phpfox.parse.output')->clean($this->_aVars['aInstalledApp']['app_title']);
                            ?>
"><?php 
                            echo Phpfox::getLib('phpfox.image.helper')->display(array('server_id' => 0, 'path' => 'app.url_image', 'file' => $this->_aVars['aInstalledApp']['image_path'], 'suffix' => '_square', 'max_width' => 16, 'max_height' => 16, 'title' => $this->_aVars['aInstalledApp']['app_title'], 'class' => 'v_middle'));
                            ?>
 <?php 
                            echo Phpfox::getLib('phpfox.parse.output')->shorten(Phpfox::getLib('phpfox.parse.output')->clean($this->_aVars['aInstalledApp']['app_title']), 22, '...');
                            ?>
</a></li>
<?php 
                        }
                    }
                    ?>
Exemple #24
0
 public function process()
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('mail.can_compose_message', true);
     $bClaiming = $this->getParam('page_id') != false;
     if (Phpfox::getParam('mail.spam_check_messages') && Phpfox::isSpammer()) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.currently_your_account_is_marked_as_a_spammer'));
     }
     $aVals = $this->request()->getArray('val');
     $bIsSending = isset($aVals['sending_message']);
     $aUser = array();
     if (($iUserId = $this->request()->get('id')) || ($iUserId = $this->getParam('id'))) {
         $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField());
         if (isset($aUser['user_id'])) {
             if ($bClaiming == false && $bIsSending != true && Phpfox::getService('mail')->canMessageUser($aUser['user_id']) == false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_send_a_private_message_to_this_user_at_the_moment'));
             }
             $this->template()->assign('aUser', $aUser);
             if ($bClaiming) {
                 $aPage = Phpfox::getService('pages')->getPage($this->getParam('page_id'));
                 $this->template()->assign(array('iPageId' => $this->getParam('page_id'), 'aPage' => $aPage, 'sMessageClaim' => Phpfox::getPhrase('mail.page_claim_message', array('title' => $aPage['title'], 'url' => Phpfox::permalink('pages', $aPage['page_id'], $aPage['title'])))));
             }
         }
         ($sPlugin = Phpfox_Plugin::get('mail.component_controller_compose_controller_to')) ? eval($sPlugin) : false;
     }
     $bIsThreadForward = false;
     $iThreadId = 0;
     if ($iThreadId = $this->request()->getInt('forward_thread_id')) {
         $bIsThreadForward = true;
     }
     $aValidation = array('subject' => Phpfox::getPhrase('mail.provide_subject_for_your_message'), 'message' => Phpfox::getPhrase('mail.provide_message'));
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         unset($aValidation['subject']);
     }
     if (Phpfox::isModule('captcha') && Phpfox::getUserParam('mail.enable_captcha_on_mail')) {
         $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
     }
     ($sPlugin = Phpfox_Plugin::get('mail.component_controller_compose_controller_validation')) ? eval($sPlugin) : false;
     $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->getArray('val')) {
         // Lets make sure they are actually trying to send someone a message.
         if ((!isset($aVals['to']) || isset($aVals['to']) && !count($aVals['to'])) && (!isset($aVals['copy_to_self']) || $aVals['copy_to_self'] != 1)) {
             Phpfox_Error::set(Phpfox::getPhrase('mail.select_a_member_to_send_a_message_to'));
         }
         if ($oValid->isValid($aVals)) {
             if (Phpfox::getParam('mail.mail_hash_check')) {
                 Phpfox::getLib('spam.hash', array('table' => 'mail_hash', 'total' => Phpfox::getParam('mail.total_mail_messages_to_check'), 'time' => Phpfox::getParam('mail.total_minutes_to_wait_for_pm'), 'content' => $aVals['message']))->isSpam();
             }
             if (Phpfox::getParam('mail.spam_check_messages')) {
                 if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['message']))))) {
                     Phpfox_Error::set(Phpfox::getPhrase('mail.this_message_feels_like_spam_try_again'));
                 }
             }
             if (Phpfox_Error::isPassed()) {
                 if ($bClaiming) {
                     $aVals['claim_page'] = true;
                 }
                 if ($aIds = Phpfox::getService('mail.process')->add($aVals)) {
                     if (isset($aVals['page_id']) && !empty($aVals['page_id'])) {
                         Phpfox::getLib('database')->insert(Phpfox::getT('pages_claim'), array('status_id' => '1', 'page_id' => (int) $aVals['page_id'], 'user_id' => Phpfox::getUserId(), 'time_stamp' => PHPFOX_TIME));
                     }
                     if (PHPFOX_IS_AJAX) {
                         $this->_bReturn = true;
                         return true;
                     }
                     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
                         $this->url()->send('mail.thread', array('id' => $aIds));
                     } else {
                         if (count($aIds) > 1) {
                             $this->url()->send('mail.view', array('id' => base64_encode(serialize($aIds))));
                         } elseif (isset($aIds[0])) {
                             $this->url()->send('mail.view', array('id' => $aIds[0]));
                         }
                     }
                 } else {
                     if (PHPFOX_IS_AJAX) {
                         $this->_bReturn = false;
                         return false;
                     }
                 }
             } else {
                 if (PHPFOX_IS_AJAX) {
                     $this->_bReturn = false;
                     return false;
                 }
             }
         } else {
             if (PHPFOX_IS_AJAX) {
                 $this->_bReturn = false;
                 return false;
             }
         }
     }
     Phpfox::getService('mail')->buildMenu();
     if (Phpfox::isModule('friend')) {
         $this->template()->setPhrase(array('friend.loading'));
     }
     if (Phpfox::getParam('core.wysiwyg') == 'tiny_mce') {
         Phpfox::getService('tinymce')->load();
         $sTinyMceCode = str_replace('\'', '\\\'', Phpfox::getService('tinymce')->getJsCode());
         $sTinyMceCode = str_replace(array("\r\n", "\n", "\r"), '', $sTinyMceCode);
         //break here so I know where I left
         //$this->template()->assign(array('sTinyMceCode' => $sTinyMceCode));
     }
     $this->template()->setTitle(Phpfox::getPhrase('mail.compose_new_message'))->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setBreadcrumb(Phpfox::getPhrase('mail.compose_new_message'), $this->url()->makeUrl('mail.compose'), true)->setPhrase(array('mail.add_new_folder', 'mail.adding_new_folder', 'mail.view_folders', 'mail.edit_folders', 'mail.you_will_delete_every_message_in_this_folder'))->setEditor()->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'mail.js' => 'module_mail', 'pager.css' => 'style_css'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'iMaxRecipients' => Phpfox::getUserParam('mail.send_message_to_max_users_each_time'), 'bIsThreadForward' => $bIsThreadForward, 'sThreadsToForward' => $this->request()->get('forwards'), 'sForwardThreadId' => $iThreadId));
     if (!Phpfox::getUserParam('mail.can_add_attachment_on_mail')) {
         $this->template()->assign('bNoAttachaFile', true);
     }
     $this->setParam('attachment_share', array('type' => 'mail', 'inline' => true, 'id' => 'js_form_mail'));
 }
 public function getActivityFeedMusic_Comment($aRow)
 {
     if (Phpfox::isUser()) {
         $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.song_id, b.title, b.time_stamp, b.privacy, 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('music_song'), 'b', 'c.type_id = \'music_song\' AND c.item_id = b.song_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['song_id'])) {
         return false;
     }
     $sLink = Phpfox::permalink('music', $aItem['song_id'], $aItem['title']);
     $sTitle = Phpfox::getLib('parse.output')->shorten($aItem['title'], Phpfox::isModule('notification') ? Phpfox::getParam('notification.total_notification_title_length') : 50);
     $sUser = Phpfox::getLib('url')->makeUrl($aItem['user_name']);
     $sGender = Phpfox::getService('user')->gender($aItem['gender'], 1);
     if ($aRow['user_id'] == $aItem['user_id']) {
         $sMessage = Phpfox::getPhrase('music.posted_a_comment_on_gender_song_a_href_link_title_a', array('gender' => $sGender, 'link' => $sLink, 'title' => $sTitle));
     } else {
         $sMessage = Phpfox::getPhrase('music.posted_a_comment_on_user_name_s_song_a_href_link_title_a', array('user_name' => $sUser, 'link' => $sLink, 'title' => $sTitle));
     }
     $bCanViewItem = true;
     if ($aItem['privacy'] > 0) {
         $bCanViewItem = Phpfox::getService('privacy')->check('music', $aItem['song_id'], $aItem['user_id'], $aItem['privacy'], $aItem['is_friend'], true);
     }
     $aReturn = array('no_share' => true, 'feed_info' => '', '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/music.png', 'return_url' => true)), 'time_stamp' => $aRow['time_stamp'], 'like_type_id' => 'feed_mini');
     if ($bCanViewItem) {
         $aReturn['feed_image'] = Phpfox::getLib('image.helper')->display(array('theme' => 'misc/play_button.png', 'return_url' => true));
         $aReturn['feed_image_onclick'] = '$.ajaxCall(\'music.playInFeed\', \'id=' . $aItem['song_id'] . '&amp;feed_id=' . $aRow['feed_id'] . '\', \'GET\'); return false;';
         $aReturn['feed_image_onclick_no_image'] = true;
     }
     return $aReturn;
 }
Exemple #26
0
 public function updateCoverPosition()
 {
     if (Phpfox::getService('pages.process')->updateCoverPosition($this->get('page_id'), $this->get('position'))) {
         $this->call('window.location.href = "' . Phpfox::permalink('pages', $this->get('page_id'), '') . '";');
         //$this->call('location.reload();');
         Phpfox::addMessage(Phpfox::getPhrase('pages.position_set_correctly'));
     } else {
         $aErr = Phpfox_Error::get();
         $sErr = implode($aErr);
     }
 }
Exemple #27
0
	/**
	 * Casts a vote on a poll
	 * @param integer $iUser User identifier
	 * @param integer $iPoll Poll identifier
	 * @param integer $iAnswer Answer identifier
	 * @return boolean|Phpfox_Error
	 */
	public function addVote($iUser, $iPoll, $iAnswer)
	{		
		if ( $this->hasUserVoted($iUser, $iPoll) !== false)
		{
			// user has voted on this poll already
			if (Phpfox::getUserParam('poll.poll_can_change_own_vote'))
			{
				// update the vote
				// first delete current vote
				$this->database()->delete(Phpfox::getT('poll_result'), 'user_id = ' . (int)$iUser . ' AND answer_id = ' . (int)$iAnswer);
				// now insert the new vote
				$this->database()->insert(Phpfox::getT('poll_result'), array(
						'poll_id' => $iPoll,
						'answer_id' => $iAnswer,
						'user_id' => $iUser,
						'time_stamp' => PHPFOX_TIME
					)
				);
				return Phpfox_Error::set(Phpfox::getPhrase('poll.poll_vote_updated'));
			}
			else
			{
				// send error
				return Phpfox_Error::set(Phpfox::getPhrase('subscribe.your_membership_group_does_not_have_rights'));				
			}
		}
		else
		{
			// is user has not voted on this poll
			// check if user has permission to view this item
			$aPoll = $this->database()->select('p.poll_id, p.user_id, p.question, p.privacy, pa.answer')
				->from($this->_sTable, 'p')
				->join(Phpfox::getT('poll_answer'), 'pa', 'pa.answer_id = ' . (int) $iAnswer . ' AND pa.poll_id = ' . (int) $iPoll)
				->where('p.poll_id = ' . (int)$iPoll)
				->execute('getSlaveRow');
			
			if (!isset($aPoll['poll_id']))
			{
				return Phpfox_Error::set('Unable to find this poll.');
			}
			
			// insert new vote			
			$this->database()->insert(Phpfox::getT('poll_result'), array(
					'poll_id' => $iPoll,
					'answer_id' => $iAnswer,
					'user_id' => $iUser,
					'time_stamp' => PHPFOX_TIME
				)
			);
			
			// update the total votes field
			$bVotes = $this->database()->update(Phpfox::getT('poll_answer'), array('total_votes' => array('= total_votes +', 1)), 'answer_id = ' . $iAnswer);
			
			$sLink = Phpfox::permalink('poll', $aPoll['poll_id'], $aPoll['question']);
			
			Phpfox::getLib('mail')->to($aPoll['user_id'])
				->subject(Phpfox::getUserBy('full_name') . " voted on your poll \"" . $aPoll['question'] . "\"")
				->message(Phpfox::getUserBy('full_name') . " voted \"" . $aPoll['answer'] . "\" on your poll \"" . $aPoll['question'] . "\"\nTo view this poll follow the link below:\n<a href=\"" . $sLink . "\">" . $sLink . "</a>")
				->send();
				
			Phpfox::getService('notification.process')->add('poll', $iPoll, $aPoll['user_id']);			
			
			return true;
		}
	}
Exemple #28
0
 public function processRows(&$aPolls2)
 {
     $aPolls = $aPolls2;
     $aPolls2 = array();
     // 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, ',');
     if (empty($sPolls)) {
         return;
     }
     $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
     $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'], 'type_id' => 'poll');
         $aPolls2[$aPoll['poll_id']] = $aPoll;
         if (isset($aPoll['poll_id']['user_id']) && $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']);
         }
     }
     unset($aPolls);
 }
<?php

if ((Phpfox_Module::instance()->getFullControllerName() == 'forum.thread' || PHPFOX_IS_AJAX && isset($_POST['core']) && $_POST['core']['call'] == 'forum.addReply') && Phpfox::isUser()) {
    $aPost = $this->getVar('aPost');
    $aThread = (array) $this->getVar('aThread');
    echo '<a class="forum_post_count" href="' . Phpfox::permalink('forum.thread', $aPost['thread_id'], $aThread['title'], false, null, array('view' => $aPost['post_id'])) . '">#' . $aPost['count'] . '</a>';
}
Exemple #30
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     $aParentModule = $this->getParam('aParentModule');
     if ($aParentModule === null && $this->request()->getInt('req2') > 0) {
         if ($this->request()->get('req1') == 'pages' && Phpfox::isModule('pages') == false || $aParentModule['module_id'] == 'pages' && Phpfox::getService('pages')->hasPerm($aParentModule['item_id'], 'blog.view_browse_blog') == false) {
             return Phpfox_Error::display(Phpfox::getPhrase('blog.cannot_display_due_to_privacy'));
         }
         return Phpfox::getLib('module')->setController('blog.view');
     }
     if (defined('PHPFOX_IS_USER_PROFILE') && ($sLegacyTitle = $this->request()->get('req3')) && !empty($sLegacyTitle)) {
         Phpfox::getService('core')->getLegacyItem(array('field' => array('blog_id', 'title'), 'table' => 'blog', 'redirect' => 'blog', 'title' => $sLegacyTitle, 'search' => 'title'));
     }
     if ($this->request()->get('req2') == 'main') {
         return Phpfox::getLib('module')->setController('error.404');
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_index_process_start')) ? eval($sPlugin) : false;
     if (($iRedirectId = $this->request()->get('redirect')) && ($aRedirectBlog = Phpfox::getService('blog')->getBlogForEdit($iRedirectId))) {
         Phpfox::permalink('blog', $aRedirectBlog['blog_id'], $aRedirectBlog['title'], true);
     }
     Phpfox::getUserParam('blog.view_blogs', true);
     if (defined('PHPFOX_IS_AJAX_CONTROLLER')) {
         $bIsProfile = true;
         $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id'));
         $this->setParam('aUser', $aUser);
     } else {
         $bIsProfile = $this->getParam('bIsProfile');
         if ($bIsProfile === true) {
             $aUser = $this->getParam('aUser');
             $this->search()->setCondition('AND blog.user_id = ' . $aUser['user_id']);
         }
     }
     /**
      * Check if we are going to view an actual blog instead of the blog index page.
      * The 2nd URL param needs to be numeric.
      */
     if (!Phpfox::isAdminPanel()) {
         if ($this->request()->getInt('req2') > 0 && !isset($aParentModule['module_id'])) {
             /**
              * Since we are going to be viewing a blog lets reset the controller and get out of this one.
              */
             return Phpfox::getLib('module')->setController('blog.view');
         }
     }
     if ($this->request()->get('req2') == 'category' && ($sLegacyTitle = $this->request()->get('req3')) && !empty($sLegacyTitle) && !is_numeric($sLegacyTitle)) {
         $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('category_id', 'name'), 'table' => 'blog_category', 'redirect' => 'blog.category', 'title' => $sLegacyTitle, 'search' => 'name_url'));
     }
     /**
      * This creates a global variable that can be used in other components. This is a good way to 
      * pass information to other components.
      */
     $this->setParam('sTagType', 'blog');
     $this->template()->setTitle($bIsProfile ? Phpfox::getPhrase('blog.full_name_s_blogs', array('full_name' => $aUser['full_name'])) : Phpfox::getPhrase('blog.blog_title'))->setBreadCrumb($bIsProfile ? Phpfox::getPhrase('blog.blogs') : Phpfox::getPhrase('blog.blog_title'), $bIsProfile ? $this->url()->makeUrl($aUser['user_name'], 'blog') : $this->url()->makeUrl('blog'));
     $sView = $this->request()->get('view');
     $this->search()->set(array('type' => 'blog', 'field' => 'blog.blog_id', 'search_tool' => array('table_alias' => 'blog', 'search' => array('action' => $bIsProfile === true ? $this->url()->makeUrl($aUser['user_name'], array('blog', 'view' => $this->request()->get('view'))) : $this->url()->makeUrl('blog', array('view' => $this->request()->get('view'))), 'default_value' => Phpfox::getPhrase('blog.search_blogs_dot'), 'name' => 'search', 'field' => array('blog.title', 'blog_text.text')), 'sort' => array('latest' => array('blog.time_stamp', Phpfox::getPhrase('blog.latest')), 'most-viewed' => array('blog.total_view', Phpfox::getPhrase('blog.most_viewed')), 'most-liked' => array('blog.total_like', Phpfox::getPhrase('blog.most_liked')), 'most-talked' => array('blog.total_comment', Phpfox::getPhrase('blog.most_discussed'))), 'show' => array(5, 10, 15))));
     $aBrowseParams = array('module_id' => 'blog', 'alias' => 'blog', 'field' => 'blog_id', 'table' => Phpfox::getT('blog'), 'hide_view' => array('pending', 'my'));
     $aFilterMenu = array();
     if (!defined('PHPFOX_IS_USER_PROFILE') && !isset($aParentModule['module_id'])) {
         $aFilterMenu = array(Phpfox::getPhrase('blog.all_blogs') => '', Phpfox::getPhrase('blog.my_blogs') => 'my');
         if (!Phpfox::getParam('core.friends_only_community') && Phpfox::isModule('friend')) {
             $aFilterMenu[Phpfox::getPhrase('blog.friends_blogs')] = 'friend';
         }
         if (Phpfox::getUserParam('blog.can_approve_blogs')) {
             $iPendingTotal = Phpfox::getService('blog')->getPendingTotal();
             if ($iPendingTotal) {
                 $aFilterMenu[Phpfox::getPhrase('blog.pending_blogs') . (Phpfox::getUserParam('blog.can_approve_blogs') ? '<span class="pending">' . $iPendingTotal . '</span>' : 0)] = 'pending';
             }
         }
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_index_process_search')) ? eval($sPlugin) : false;
     $this->template()->buildSectionMenu('blog', $aFilterMenu);
     switch ($sView) {
         case 'spam':
             Phpfox::isUser(true);
             if (Phpfox::getUserParam('blog.can_approve_blogs')) {
                 $this->search()->setCondition('AND blog.is_approved = 9');
             }
             break;
         case 'pending':
             Phpfox::isUser(true);
             if (Phpfox::getUserParam('blog.can_approve_blogs')) {
                 $this->search()->setCondition('AND blog.is_approved = 0');
             }
             break;
         case 'my':
             Phpfox::isUser(true);
             $this->search()->setCondition('AND blog.user_id = ' . Phpfox::getUserId());
             break;
         case 'draft':
             Phpfox::isUser(true);
             $this->search()->setCondition("AND blog.user_id = " . $aUser['user_id'] . " AND blog.is_approved IN(" . ($aUser['user_id'] == Phpfox::getUserId() ? '0,1' : '1') . ") AND blog.privacy IN(" . (Phpfox::getParam('core.section_privacy_item_browsing') ? '%PRIVACY%' : Phpfox::getService('core')->getForBrowse($aUser)) . ") AND blog.post_status = 2");
             break;
         default:
             $aPage = $this->getParam('aPage');
             $sCondition = "AND blog.is_approved = 1 AND blog.post_status = 1" . (Phpfox::getUserParam('privacy.can_comment_on_all_items') ? "" : " AND blog.privacy IN(%PRIVACY%)");
             if (isset($aPage['privacy']) && $aPage['privacy'] == 1) {
                 $sCondition = "AND blog.is_approved = 1 AND blog.privacy IN(%PRIVACY%, 1) AND blog.post_status = 1";
             }
             $this->search()->setCondition($sCondition);
             break;
     }
     if ($this->request()->get($bIsProfile === true ? 'req3' : 'req2') == 'category') {
         if ($aBlogCategory = Phpfox::getService('blog.category')->getCategory($this->request()->getInt($bIsProfile === true ? 'req4' : 'req3'))) {
             $this->template()->setBreadCrumb(Phpfox::getPhrase('blog.category'));
             $this->search()->setCondition('AND blog_category.category_id = ' . $this->request()->getInt($bIsProfile === true ? 'req4' : 'req3') . ' AND blog_category.user_id = ' . ($bIsProfile ? (int) $aUser['user_id'] : 0));
             $this->template()->setTitle(Phpfox::getLib('locale')->convert($aBlogCategory['name']));
             $this->template()->setBreadCrumb(Phpfox::getLib('locale')->convert($aBlogCategory['name']), $this->url()->makeUrl('current'), true);
             $this->search()->setFormUrl($this->url()->permalink(array('blog.category', 'view' => $this->request()->get('view')), $aBlogCategory['category_id'], $aBlogCategory['name']));
             $bIsValidCategory = true;
         }
     } elseif ($this->request()->get(defined('PHPFOX_IS_PAGES_VIEW') ? 'req4' : ($bIsProfile === true ? 'req3' : 'req2')) == 'tag') {
         if ($aTag = Phpfox::getService('tag')->getTagInfo('blog', $this->request()->get(defined('PHPFOX_IS_PAGES_VIEW') ? 'req5' : ($bIsProfile === true ? 'req4' : 'req3')))) {
             $this->template()->setBreadCrumb(Phpfox::getPhrase('tag.topic') . ': ' . $aTag['tag_text'] . '', $this->url()->makeUrl('current'), true);
             $this->search()->setCondition('AND tag.tag_text = \'' . Phpfox::getLib('database')->escape($aTag['tag_text']) . '\'');
             $bIsValidTag = true;
         }
     }
     if (isset($aParentModule) && isset($aParentModule['module_id'])) {
         /* Only get items without a parent (not belonging to pages) */
         $this->search()->setCondition('AND blog.module_id = \'' . $aParentModule['module_id'] . '\' AND blog.item_id = ' . (int) $aParentModule['item_id']);
     } else {
         if ($aParentModule === null) {
             if (($sView == 'pending' || $sView == 'draft') && Phpfox::getUserParam('blog.can_approve_blogs')) {
             } else {
                 $this->search()->setCondition('AND blog.module_id = \'blog\'');
             }
         }
     }
     // http://www.phpfox.com/tracker/view/15375/
     if (defined('PHPFOX_IS_PAGES_VIEW') && Phpfox::getService('pages')->hasPerm(null, 'blog.view_browse_blogs') || !defined('PHPFOX_IS_PAGES_VIEW') && $aParentModule['module_id'] == 'pages' && Phpfox::getService('pages')->hasPerm($aParentModule['item_id'], 'blog.view_browse_blogs')) {
         if (Phpfox::getService('pages')->isAdmin($aParentModule['item_id'])) {
             $this->request()->set('view', 'pages_admin');
         } elseif (Phpfox::getService('pages')->isMember($aParentModule['item_id'])) {
             $this->request()->set('view', 'pages_member');
         }
     }
     // http://www.phpfox.com/tracker/view/15445/
     if (Phpfox::getService('profile')->timeline() && ($bIsProfile || defined('PHPFOX_IS_PAGES_VIEW'))) {
         // Should we set the special menu?
         $bSpecialMenu = !defined('PHPFOX_IS_AJAX_CONTROLLER');
         // Are we viewing the content of the special menu?
         $bIsActive = $sView == 'draft' ? true : false;
         $aDrafts = array('phrase' => Phpfox::getPhrase('profile.drafts'), 'url' => Phpfox::getLib('url')->makeUrl('profile.blog.view_draft'), 'total' => Phpfox::getService('blog')->getTotalDrafts($aUser['user_id']), 'active' => $bIsActive);
         $this->template()->setHeader(array('profile.css' => 'module_blog'))->assign(array('bSpecialMenu' => $bSpecialMenu, 'aDrafts' => $aDrafts));
     }
     // END
     $this->search()->browse()->params($aBrowseParams)->execute();
     $aItems = $this->search()->browse()->getRows();
     Phpfox::getLib('pager')->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount()));
     Phpfox::getService('blog')->getExtra($aItems, 'user_profile');
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_index_process_middle')) ? eval($sPlugin) : false;
     $this->template()->setMeta('keywords', Phpfox::getParam('blog.blog_meta_keywords'));
     $this->template()->setMeta('description', Phpfox::getParam('blog.blog_meta_description'));
     if ($bIsProfile) {
         $this->template()->setMeta('description', '' . $aUser['full_name'] . ' has ' . $this->search()->browse()->getCount() . ' blogs.');
     }
     foreach ($aItems as $aItem) {
         $this->template()->setMeta('keywords', $this->template()->getKeywords($aItem['title']));
         if (!empty($aItem['tag_list'])) {
             $this->template()->setMeta('keywords', Phpfox::getService('tag')->getKeywords($aItem['tag_list']));
         }
     }
     /**
      * Here we assign the needed variables we plan on using in the template. This is used to pass
      * on any information that needs to be used with the specific template for this component.
      */
     $this->template()->assign(array('iCnt' => $this->search()->browse()->getCount(), 'aItems' => $aItems, 'sSearchBlock' => Phpfox::getPhrase('blog.search_blogs_'), 'bIsProfile' => $bIsProfile, 'sTagType' => $bIsProfile === true ? 'blog_profile' : 'blog', 'sBlogStatus' => $this->request()->get('status'), 'iShorten' => Phpfox::getParam('blog.length_in_index'), 'sView' => $sView))->setHeader('cache', array('quick_submit.js' => 'module_blog', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed'));
     $this->setParam('global_moderation', array('name' => 'blog', 'ajax' => 'blog.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('blog.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('blog.approve'), 'action' => 'approve'))));
     $iStartCheck = 0;
     if (isset($bIsValidCategory)) {
         $iStartCheck = 5;
     } elseif (isset($bIsValidTag)) {
         $iStartCheck = 4;
     }
     if (!defined('PHPFOX_ALLOW_ID_404_CHECK')) {
         $iAllowIds = uniqid();
         define('PHPFOX_ALLOW_ID_404_CHECK', $iAllowIds);
     } else {
         $iAllowIds = PHPFOX_ALLOW_ID_404_CHECK;
     }
     $aRediAllow = array('category', 'tag', $iAllowIds);
     if (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE) {
         $aRediAllow[] = 'blog';
     }
     $aCheckParams = array('url' => $this->url()->makeUrl('blog'), 'start' => $iStartCheck, 'reqs' => array('2' => $aRediAllow, '3' => $aRediAllow));
     if (Phpfox::getParam('core.force_404_check') && !Phpfox::getService('core.redirect')->check404($aCheckParams)) {
         return Phpfox::getLib('module')->setController('error.404');
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_index_process_end')) ? eval($sPlugin) : false;
 }