Exemple #1
0
 /**
  * Controller
  */
 public function process()
 {
     $bIsEdit = false;
     $oSession = Phpfox::getLib('session');
     $aValidation = array('product_id' => Phpfox::getPhrase('page.select_product'), 'title' => Phpfox::getPhrase('page.missing_title'), 'title_url' => Phpfox::getPhrase('page.missing_url_title'), 'is_active' => Phpfox::getPhrase('page.specify_page_active'), 'text' => Phpfox::getPhrase('page.page_missing_data'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if (($iPageId = $this->request()->getInt('id')) || ($iPageId = $this->request()->getInt('page_id'))) {
         Phpfox::getUserParam('page.can_manage_custom_pages', true);
         $aPage = Phpfox::getService('page')->getForEdit($iPageId);
         if (isset($aPage['page_id'])) {
             $bIsEdit = true;
             // $aPage['attachment'] = (Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getForItemEdit($aPage['page_id'], 'page', Phpfox::getUserId()) : '');
             if (Phpfox::isModule('tag')) {
                 $aTags = Tag_Service_Tag::instance()->getTagsById('page', $aPage['page_id']);
                 if (isset($aTags[$aPage['page_id']])) {
                     $aPage['tag_list'] = '';
                     foreach ($aTags[$aPage['page_id']] as $aTag) {
                         $aPage['tag_list'] .= ' ' . $aTag['tag_text'] . ',';
                     }
                     $aPage['tag_list'] = trim(trim($aPage['tag_list'], ','));
                 }
             }
             $this->template()->assign(array('aForms' => $aPage, 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access'])));
         }
     }
     if ($aVals = $this->request()->getArray('val')) {
         Phpfox::getLib('parse.input')->allowTitle(Phpfox::getLib('parse.input')->cleanTitle($aVals['title_url']), Phpfox::getPhrase('page.invalid_title'));
         if ($oValid->isValid($aVals)) {
             if ($bIsEdit) {
                 $sMessage = Phpfox::getPhrase('page.page_successfully_updated');
                 $sReturn = Phpfox::getService('page.process')->update($aPage['page_id'], $aVals, $aPage['user_id']);
                 $aUrl = null;
             } else {
                 $sMessage = Phpfox::getPhrase('page.successfully_added');
                 $sReturn = Phpfox::getService('page.process')->add($aVals);
                 $aUrl = null;
             }
             if ($sReturn) {
                 return ['redirect' => $this->url()->makeUrl($sReturn, null, $sMessage)];
             }
         } else {
             $aError = Phpfox_Error::get();
             $sError = '';
             if (is_array($aError)) {
                 $sError = implode(' ', $aError);
             } else {
                 $sError = $aError;
             }
             return ['error' => $sError];
         }
     }
     $this->template()->setSectionTitle('<a href="' . $this->url()->makeUrl('admincp.page') . '">Custom Pages</a>')->setTitle(Phpfox::getPhrase('page.add_new_page'))->setBreadCrumb(Phpfox::getPhrase('page.add_new_page'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aModules' => Phpfox_Module::instance()->getModules(), 'bFormIsPosted' => count($aVals) ? true : false))->setEditor()->setHeader(array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_menu.js' => 'static_script', '<script type="text/javascript">var Attachment = {sCategory: "page", iItemId: "' . (isset($aPage['page_id']) ? $aPage['page_id'] : '') . '"};</script>'));
 }
Exemple #2
0
 public function getForEdit($sCategory, $iId)
 {
     $sList = '';
     $aTags = Tag_Service_Tag::instance()->getTagsById($sCategory, $iId);
     if (isset($aTags[$iId])) {
         foreach ($aTags[$iId] as $aTag) {
             $sList .= ' ' . $aTag['tag_text'] . ',';
         }
         $sList = trim(trim($sList, ','));
     }
     return $sList;
 }
Exemple #3
0
 public function inlineUpdate()
 {
     if (($iUserId = Tag_Service_Tag::instance()->hasAccess($this->get('sType'), $this->get('item_id'), 'edit_own_tags', 'edit_user_tags')) && Phpfox::getService('tag.process')->update($this->get('sType'), $this->get('item_id'), $iUserId, Phpfox::getLib('parse.format')->isEmpty($this->get('quick_edit_input')) ? null : $this->get('quick_edit_input'))) {
         if (Phpfox::getLib('parse.format')->isEmpty($this->get('quick_edit_input'))) {
             $this->call('$(\'#' . $this->get('id') . '\').parent().remove();');
         } else {
             $aTags = Tag_Service_Tag::instance()->getTagsById($this->get('sType'), $this->get('item_id'));
             Phpfox::getBlock('tag.item', array('bDontCleanTags' => true, 'sType' => $this->get('sType'), 'sTags' => $aTags[$this->get('item_id')], 'iItemId' => $this->get('item_id'), 'iUserId' => $iUserId, 'bIsInline' => true));
             $this->html('#' . $this->get('id'), Phpfox::getLib('parse.output')->clean($this->getContent(false), false), '.highlightFade()');
             $this->html('#' . $this->get('content'), Phpfox::getLib('parse.output')->parse(Phpfox::getLib('parse.input')->clean($this->get('quick_edit_input'))));
         }
     }
 }
Exemple #4
0
 /**
  * Controller
  */
 public function process()
 {
     $oCache = Phpfox::getLib('cache');
     $sRequest = $this->request()->get('req1');
     $sCacheId = $oCache->set('page_' . md5($sRequest));
     $bIsCached = false;
     if (!($aPage = $oCache->get($sCacheId))) {
         $aPage = Phpfox::getService('page')->getPage($sRequest, true);
         $bIsCached = true;
     }
     if (!isset($aPage['page_id'])) {
         return Phpfox_Module::instance()->setController('error.404');
     }
     if (!Phpfox::isModule($aPage['module_id']) || $aPage['is_active'] == 0) {
         return Phpfox_Module::instance()->setController('error.404');
     }
     if ($bIsCached && !$aPage['add_view']) {
         $oCache->save($sCacheId, $aPage);
     }
     if (!empty($aPage['disallow_access'])) {
         $aUserGroups = unserialize($aPage['disallow_access']);
         if (in_array(Phpfox::getUserBy('user_group_id'), $aUserGroups)) {
             $this->url()->send('subscribe');
         }
     }
     if ($aPage['full_size']) {
         $this->template()->setFullSite();
     }
     $aPage['bookmark_url'] = $this->url()->makeUrl($aPage['title_url']);
     if (!$aPage['is_active'] && Phpfox::getUserParam('page.can_manage_custom_pages') && Phpfox::getUserParam('admincp.has_admin_access')) {
         return Phpfox_Module::instance()->setController('error.404');
     }
     if ($aPage['add_view'] && Phpfox::getUserId() && !$aPage['has_viewed']) {
         Phpfox::getService('track.process')->add('page', $aPage['page_id']);
         Phpfox::getService('page.process')->updateView($aPage['page_id']);
     }
     if ($aPage['total_tag'] > 0 && Phpfox::isModule('tag')) {
         $aTags = Tag_Service_Tag::instance()->getTagsById('page', $aPage['page_id']);
         if (isset($aTags[$aPage['page_id']])) {
             $aPage['tag_list'] = $aTags[$aPage['page_id']];
         }
     }
     if (!empty($aPage['keyword'])) {
         $this->template()->setMeta('keywords', $aPage['keyword']);
     }
     if (!empty($aPage['description'])) {
         $this->template()->setMeta('description', $aPage['description']);
     }
     ($sPlugin = Phpfox_Plugin::get('page.component_controller_view_process')) ? eval($sPlugin) : false;
     $this->template()->setTitle($aPage['is_phrase'] ? Phpfox::getPhrase($aPage['title']) : $aPage['title'])->assign(array('aPage' => $aPage));
 }
Exemple #5
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::getParam('tag.enable_hashtag_support')) {
         return false;
     }
     if (!defined('PHPFOX_TAG_PARENT_MODULE')) {
         define('PHPFOX_TAG_PARENT_MODULE', $this->getParam('sTagListParentModule', null));
     }
     if (!defined('PHPFOX_TAG_PARENT_ID')) {
         define('PHPFOX_TAG_PARENT_ID', $this->getParam('iTagListParentId', 0));
     }
     $this->template()->assign('sMicroKeywords', $this->getParam('sMicroKeywords'));
     if ($sType = $this->getParam('type')) {
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $iItemId = $this->getParam('item_id');
         $sTags = '';
         $sTagsClean = '';
         $aMainTags = Tag_Service_Tag::instance()->getTagsById($sType, $iItemId);
         if (!isset($aMainTags[$iItemId])) {
             return false;
         }
         foreach ($aMainTags[$iItemId] as $iKey => $aTag) {
             $aMainTags[$iItemId][$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iItemId][$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags[$iItemId], 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     } else {
         if (!($sType = $this->getParam('sType'))) {
             return Phpfox_Error::trigger(Phpfox::getPhrase('tag.missing_param_stype'), E_USER_ERROR);
         }
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $aMainTags = $this->getParam('sTags');
         $sTags = '';
         $sTagsClean = '';
         foreach ($aMainTags as $iKey => $aTag) {
             $aMainTags[$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags, 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     }
 }
Exemple #6
0
 /**
  * Controller
  */
 public function process()
 {
     if ((defined('PHPFOX_IS_USER_PROFILE') || defined('PHPFOX_IS_GROUP_VIEW') || defined('PHPFOX_IS_PAGES_VIEW')) && !defined('PHPFOX_SHOW_TAGS')) {
         return false;
     }
     $sType = $this->getParam('sTagType', null);
     $bNoTagBlock = $this->getParam('bNoTagBlock', false);
     if ($sType === null && !Phpfox::getParam('tag.enable_hashtag_support')) {
         return false;
     }
     $aRows = Tag_Service_Tag::instance()->getTagCloud($sType, $this->getParam('bIsProfile') === true && ($aUser = $this->getParam('aUser')) ? $aUser['user_id'] : null, $this->getParam('iTagDisplayLimit', null));
     if (!count($aRows)) {
         return false;
     }
     if ($this->getParam('bIsProfile') === true && !defined('TAG_ITEM_ID')) {
         foreach ($aRows as $iKey => $aRow) {
             $aRows[$iKey]['link'] = Phpfox::getService('user')->getLink($aUser['user_id'], $aUser['user_name'], array($sType, 'tag', $aRow['url']));
         }
     }
     if ($bNoTagBlock === false) {
         $this->template()->assign(array('sHeader' => Phpfox::getPhrase('tag.trending_topics')));
     }
     $iSince = PHPFOX_TIME - 86400 * Phpfox::getParam('tag.tag_days_treading');
     $sTrendingSince = date(Phpfox::getParam('tag.trending_topics_timestamp'), $iSince);
     if (strpos(Phpfox::getParam('tag.trending_topics_timestamp'), 'F') !== false) {
         $sTrendingSince = str_replace(date('F', $iSince), Phpfox::getLib('date')->getMonth(date('n', $iSince)), $sTrendingSince);
     } else {
         if (strpos(Phpfox::getParam('tag.trending_topics_timestamp'), 'M') !== false) {
             $sTrendingSince = str_replace(date('M', $iSince), substr(Phpfox::getLib('date')->getMonth(date('n', $iSince)), 0, 3), $sTrendingSince);
         }
     }
     $this->template()->assign(array('aRows' => $aRows, 'sTagGlobalType' => $sType, 'sTrendingSince' => $sTrendingSince));
     if ($sType === null) {
         $this->template()->assign(array('sDeleteBlock' => 'dashboard'));
     }
     return 'block';
 }
Exemple #7
0
 /**
  * Controller
  */
 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_Module::instance()->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_Module::instance()->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_Module::instance()->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')), '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_Locale::instance()->convert($aBlogCategory['name']));
             $this->template()->setBreadCrumb(Phpfox_Locale::instance()->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 = Tag_Service_Tag::instance()->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_Database::instance()->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 (Profile_Service_Profile::instance()->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_Url::instance()->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_Pager::instance()->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount()));
     Blog_Service_Blog::instance()->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', Tag_Service_Tag::instance()->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.
      */
     $cnt = $this->search()->browse()->getCount();
     $this->template()->assign(array('iCnt' => $cnt, 'aBlogs' => $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'))));
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_index_process_end')) ? eval($sPlugin) : false;
 }
Exemple #8
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::isMobile() && Phpfox_Module::instance()->getFullControllerName() == 'forum.forum' && !$this->request()->getInt('req2') && !in_array($this->request()->get('view'), array('subscribed', 'new', 'my-thread'))) {
         return Phpfox_Module::instance()->setController('forum.index');
     }
     Phpfox::getUserParam('forum.can_view_forum', true);
     $aParentModule = $this->getParam('aParentModule');
     $bIsSearch = $this->request()->get('search') ? true : false;
     $aCallback = $this->getParam('aCallback', null);
     $sView = $this->request()->get('view');
     $bShowPosts = false;
     $bIsTagSearch = false;
     $bIsModuleTagSearch = false;
     if ($this->request()->get('req2') == 'tag' && $this->request()->get('req3')) {
         $bIsSearch = true;
         $bIsTagSearch = true;
     }
     if ($this->request()->get('req2') == 'tag' && $this->request()->get('req5') && $this->request()->get('module')) {
         if ($aCallback = Phpfox::getService('group')->getGroup($this->request()->get('item'))) {
             $bIsSearch = true;
             $bIsTagSearch = true;
             $bIsModuleTagSearch = true;
             $aCallback['url_home'] = 'group.' . $aCallback['title_url'] . '.forum';
         }
     }
     $oSearch = Forum_Service_Forum::instance()->getSearchFilter($this->getParam('bIsSearchQuery', false), $this->request()->get('forum_id') ? $this->request()->get('forum_id') : $this->request()->getInt('req2'));
     if ($oSearch->isSearch() && $this->request()->getInt('req2') == 'search') {
         $aIds = [];
         $aForums = $this->request()->get('forum_id') ? Forum_Service_Forum::instance()->id($this->request()->get('forum_id'))->live()->getForums() : Forum_Service_Forum::instance()->live()->getForums();
         if ($this->request()->get('forum_id')) {
             $aIds[] = $this->request()->get('forum_id');
         }
         foreach ($aForums as $aForum) {
             $aIds[] = $aForum['forum_id'];
             $aChilds = (array) Forum_Service_Forum::instance()->id($aForum['forum_id'])->getChildren();
             foreach ($aChilds as $iId) {
                 $aIds[] = $iId;
             }
         }
         $oSearch->setCondition('AND ft.forum_id IN(' . implode(',', $aIds) . ')');
     }
     define('PHPFOX_PAGER_FORCE_COUNT', true);
     $iPage = $this->request()->getInt('page');
     $iPageSize = $oSearch->getDisplay();
     $sViewId = 'ft.view_id = 0';
     if ($aCallback === null) {
         $iForumId = $this->request()->getInt('req2');
         if (Phpfox::getUserParam('forum.can_approve_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($iForumId, 'approve_thread')) {
             $sViewId = 'ft.view_id >= 0';
         }
     }
     if ($aParentModule == null) {
         $iForumId = $this->request()->getInt('req2');
         $aForums = Forum_Service_Forum::instance()->live()->id($iForumId)->getForums();
         // $aForums = array();
         $aForum = Forum_Service_Forum::instance()->id($iForumId)->getForum();
         $this->template()->assign('isSubForumList', true);
     } else {
         $aForum = array();
         $aForums = array();
     }
     if (!$bIsSearch && $this->request()->get('view') != 'pending-post') {
         if ($aParentModule === null) {
             if (!isset($aForum['forum_id']) && empty($sView)) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
             }
             if (isset($aForum['forum_id'])) {
                 $this->setParam('iActiveForumId', $aForum['forum_id']);
             }
             if (!empty($sView)) {
                 switch ($sView) {
                     case 'my-thread':
                         $oSearch->setCondition('AND ft.user_id = ' . Phpfox::getUserId());
                         // $bShowPosts = true;
                         break;
                     case 'pending-thread':
                         if (Phpfox::getUserParam('forum.can_approve_forum_thread')) {
                             $sViewId = 'ft.view_id = 1';
                         }
                         break;
                     default:
                         break;
                 }
                 $oSearch->setCondition('AND ft.group_id = 0 AND ' . $sViewId . ' AND ft.is_announcement = 0');
                 $bIsSearch = true;
             } else {
                 $oSearch->setCondition('AND ft.forum_id = ' . $aForum['forum_id'] . ' AND ft.group_id = 0 AND ' . $sViewId . ' AND ft.is_announcement = 0');
             }
         } else {
             $oSearch->setCondition('AND ft.forum_id = 0 AND ft.group_id = ' . $aParentModule['item_id'] . ' AND ' . $sViewId . ' AND ft.is_announcement = 0');
         }
         // get the forums that we cant access
         $aForbiddenForums = Forum_Service_Forum::instance()->getForbiddenForums();
         if (!empty($aForbiddenForums)) {
             $oSearch->setCondition(' AND ft.forum_id NOT IN (' . implode(',', $aForbiddenForums) . ')');
         }
     }
     if ($oSearch->get('result') || $this->request()->get('view') == 'pending-post') {
         if ($this->request()->get('view') == 'pending-post') {
             $bIsSearch = true;
             $bForceResult = true;
             $oSearch->setCondition('AND fp.view_id = 1');
         }
         list($iCnt, $aThreads) = Phpfox::getService('forum.post')->callback($aCallback)->get($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $iPageSize);
     } else {
         if (($iDaysPrune = $oSearch->get('days_prune')) && $iDaysPrune != '-1') {
             $oSearch->setCondition('AND ft.time_stamp >= ' . (PHPFOX_TIME - $iDaysPrune * 86400));
         }
         if ($bIsTagSearch === true) {
             if ($bIsModuleTagSearch) {
                 $oSearch->setCondition("AND ft.group_id = " . (int) $aCallback['group_id'] . " AND tag.tag_url = '" . Phpfox_Database::instance()->escape($this->request()->get('req5')) . "'");
             } else {
                 $oSearch->setCondition("AND ft.group_id = 0 AND tag.tag_url = '" . Phpfox_Database::instance()->escape($this->request()->get('req3')) . "'");
             }
         }
         list($iCnt, $aThreads) = Forum_Service_Thread_Thread::instance()->isSearch($bIsSearch)->isTagSearch($bIsTagSearch)->isNewSearch($sView == 'new' ? true : false)->isSubscribeSearch($sView == 'subscribed' ? true : false)->isModuleSearch($bIsModuleTagSearch)->get($oSearch->getConditions(), 'ft.order_id DESC, ' . $oSearch->getSort(), $oSearch->getPage(), $iPageSize);
     }
     $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iForumId, Phpfox::getUserBy('user_group_id'));
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     $this->template()->assign(array('aThreads' => $aThreads, 'iSearchId' => $this->request()->getInt('search-id'), 'aCallback' => $aParentModule, 'sView' => $sView, 'aPermissions' => $aAccess))->setHeader('cache', array('forum.css' => 'style_css', 'pager.css' => 'style_css', 'selector.js' => 'static_script'));
     if ($bIsSearch && !isset($aForum['forum_id'])) {
         if (is_array($aCallback)) {
             $this->template()->setBreadcrumb('Pages', $this->url()->makeUrl('pages'))->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         } else {
             $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'));
         }
         if ($bIsTagSearch) {
             $aTag = Tag_Service_Tag::instance()->getTagInfo('forum', $bIsModuleTagSearch ? $this->request()->get('req5') : $this->request()->get('req3'));
             if (!empty($aTag['tag_text'])) {
                 if ($bIsModuleTagSearch) {
                     $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.threads_tagged_with') . ': ' . $aTag['tag_text'], $this->url()->makeUrl('forum.tag.module_group.item_' . $this->request()->get('item') . '.' . $this->request()->get('req5')), true);
                 } else {
                     $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.tags'), $this->url()->makeUrl('forum.tag'))->setBreadcrumb(Phpfox::getPhrase('forum.threads_tagged_with') . ': ' . $aTag['tag_text'], $this->url()->makeUrl('forum.tag.' . $this->request()->get('req3')), true);
                 }
             }
         } else {
             if (is_array($aCallback)) {
                 // $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.search'), $this->url()->makeUrl('forum.search', array('module' => 'pages', 'item' => $aCallback['group_id'])));
             } else {
                 // $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.search'), $this->url()->makeUrl('forum.search'));
             }
         }
         $this->template()->assign(array('bIsSearch' => true, 'bResult' => isset($bForceResult) ? true : $oSearch->get('result'), 'aForumResults' => $oSearch->get('forum'), 'bIsTagSearch' => $bIsTagSearch));
     } else {
         if (Phpfox::getParam('forum.rss_feed_on_each_forum')) {
             if ($aParentModule === null) {
                 $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.forum') . ': ' . $aForum['name'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'forum' => $aForum['forum_id'])) . '" />');
             } else {
                 $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.group_forum') . ': ' . $aCallback['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'group' => $aCallback['group_id'])) . '" />');
             }
         }
         if ($aCallback === null && $aParentModule === null) {
             if (!$aForum['is_closed'] && Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) {
                 $this->template()->setMenu(['forum.forum' => ['menu_id' => null, 'module' => 'forum', 'url' => $this->url()->makeUrl('forum.post.thread', ['id' => $aForum['forum_id']]), 'var_name' => 'new_thread']]);
             }
         } else {
             if ($aParentModule !== null) {
                 $this->template()->setMenu(['forum.forum' => ['menu_id' => null, 'module' => 'forum', 'url' => $this->url()->makeUrl('forum.post.thread', ['module' => $aParentModule['module_id'], 'item' => $aParentModule['item_id']]), 'var_name' => 'new_thread']]);
                 // d($aParentModule); exit;
             }
         }
         /*
         {if !$aForumData.is_closed && Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess('' . $aForumData.forum_id . '', 'add_thread')}
         <div class="sub_menu_bar_main"><a href="{url link='forum.post.thread' id=$aForumData.forum_id}">{phrase var='forum.new_thread'}</a></div>
         		{/if}
         	{else}
         		<div class="sub_menu_bar_main"><a href="{url link='forum.post.thread' module=$aCallback.module_id item=$aCallback.item_id}">{phrase var='forum.new_thread'}</a></div>
         	{/if}
         */
         if ($aParentModule === null) {
             if (!Forum_Service_Forum::instance()->hasAccess($aForum['forum_id'], 'can_view_forum')) {
                 $this->url()->send('forum');
             }
             $this->template()->setTitle(Phpfox_Locale::instance()->convert($aForum['name']))->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb(Phpfox_Locale::instance()->convert($aForum['name']), $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']), true)->assign(array('bDisplayThreads' => true, 'aAnnouncements' => Forum_Service_Thread_Thread::instance()->getAnnoucements($iForumId), 'aForums' => $aForums, 'aForumData' => $aForum, 'bHasCategory' => false, 'bIsSubForum' => true, 'bIsSearch' => false, 'bIsTagSearch' => false));
         } else {
             $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl(''))->setTitle(Phpfox::getPhrase('forum.discussions'))->assign(array('bDisplayThreads' => true, 'bHasCategory' => false, 'bIsSubForum' => true, 'bIsSearch' => false, 'bIsTagSearch' => false, 'aAnnouncements' => Forum_Service_Thread_Thread::instance()->getAnnoucements(null, isset($aParentModule['item_id']) ? $aParentModule['item_id'] : 1)));
         }
     }
     if ($bIsSearch && (isset($bForceResult) || $oSearch->get('result'))) {
         if (isset($bForceResult)) {
             $this->setParam('global_moderation', array('name' => 'forumpost', 'ajax' => 'forum.postModeration', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
         } else {
             $this->template()->assign('bIsPostSearch', true);
         }
     } else {
         $this->setParam('global_moderation', array('name' => 'forum', 'ajax' => 'forum.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
     }
 }
Exemple #9
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     $bIsEdit = false;
     $bCanEditPersonalData = true;
     $sModule = $this->request()->get('module');
     $iItemId = $this->request()->getInt('item');
     if (($aVals = $this->request()->getArray('val')) && !empty($aVals['module_id']) && !empty($aVals['item_id'])) {
         $sModule = $aVals['module_id'];
         $iItemId = $aVals['item_id'];
     }
     if (!empty($sModule) && !empty($iItemId)) {
         $this->template()->assign(array('sModule' => $sModule, 'iItem' => $iItemId));
     }
     if ($iEditId = $this->request()->getInt('id')) {
         $oBlog = Phpfox::getService('blog');
         $aRow = $oBlog->getBlogForEdit($iEditId);
         if ($aRow['is_approved'] != '1' && ($aRow['user_id'] != Phpfox::getUserId() && !Phpfox::getUserParam('blog.edit_user_blog'))) {
             return Phpfox_Error::display(Phpfox::getPhrase('blog.unable_to_edit_this_blog'));
         }
         if (Phpfox::isModule('tag')) {
             $aTags = Tag_Service_Tag::instance()->getTagsById('blog', $aRow['blog_id']);
             if (isset($aTags[$aRow['blog_id']])) {
                 $aRow['tag_list'] = '';
                 foreach ($aTags[$aRow['blog_id']] as $aTag) {
                     $aRow['tag_list'] .= ' ' . $aTag['tag_text'] . ',';
                 }
                 $aRow['tag_list'] = trim(trim($aRow['tag_list'], ','));
             }
         }
         Phpfox::getUserId() == $aRow['user_id'] ? Phpfox::getUserParam('blog.edit_own_blog', true) : Phpfox::getUserParam('blog.edit_user_blog', true);
         if (Phpfox::getUserParam('blog.edit_user_blog') && Phpfox::getUserId() != $aRow['user_id']) {
             $bCanEditPersonalData = false;
         }
         $aCategories = Phpfox::getService('blog.category')->getCategoriesById($aRow['blog_id']);
         $sCategories = '';
         if (isset($aCategories[$aRow['blog_id']])) {
             foreach ($aCategories[$aRow['blog_id']] as $aCategory) {
                 $sCategories .= $aCategory['category_id'] . ',';
             }
         }
         $aRow['selected_categories'] = $sCategories;
         $bIsEdit = true;
         $this->setParam('aSelectedCategories', isset($aCategories[$aRow['blog_id']]) ? $aCategories[$aRow['blog_id']] : []);
         $this->template()->assign(array('aForms' => $aRow));
         if (!empty($aRow['module_id'])) {
             $sModule = $aRow['module_id'];
             $iItemId = $aRow['item_id'];
         }
         ($sPlugin = Phpfox_Plugin::get('blog.component_controller_add_process_edit')) ? eval($sPlugin) : false;
     } else {
         Phpfox::getUserParam('blog.add_new_blog', true);
     }
     $aValidation = array('title' => array('def' => 'required', 'title' => Phpfox::getPhrase('blog.fill_title_for_blog')), 'text' => array('def' => 'required', 'title' => Phpfox::getPhrase('blog.add_content_to_blog')));
     if (Phpfox::isModule('captcha') && Phpfox::getUserParam('captcha.captcha_on_blog_add')) {
         $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_add_process_validation')) ? eval($sPlugin) : false;
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'core_js_blog_form', 'aParams' => $aValidation));
     if (!empty($sModule) && Phpfox::hasCallback($sModule, 'getItem')) {
         $aCallback = Phpfox::callback($sModule . '.getItem', $iItemId);
         $sUrl = $sCrumb = '';
         if ($bIsEdit) {
             $sUrl = $this->url()->makeUrl('blog', array('add', 'id' => $iEditId));
             $sCrumb = Phpfox::getPhrase('blog.editing_blog') . ': ' . Phpfox::getLib('parse.output')->shorten($aRow['title'], Phpfox::getService('core')->getEditTitleSize(), '...');
         } else {
             $sUrl = $this->url()->makeUrl('blog', array('add', 'module' => $aCallback['module'], 'item' => $iItemId));
             $sCrumb = Phpfox::getPhrase('blog.adding_a_new_blog');
         }
         $this->template()->setBreadcrumb(Phpfox::getPhrase($sModule . '.' . $sModule), $this->url()->makeUrl($sModule))->setBreadCrumb($aCallback['title'], Phpfox::permalink($sModule, $iItemId))->setBreadCrumb(Phpfox::getPhrase('blog.blogs'), $this->url()->makeUrl('pages', array($iItemId, 'blog')))->setBreadcrumb($sCrumb, $sUrl, true);
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('blog.blogs'), $this->url()->makeUrl('blog'))->setBreadcrumb(!empty($iEditId) ? Phpfox::getPhrase('blog.editing_blog') . ': ' . Phpfox::getLib('parse.output')->shorten($aRow['title'], Phpfox::getService('core')->getEditTitleSize(), '...') : Phpfox::getPhrase('blog.adding_a_new_blog'), $iEditId > 0 ? $this->url()->makeUrl('blog', array('add', 'id' => $iEditId)) : $this->url()->makeUrl('blog', array('add')), true);
     }
     if ($aVals = $this->request()->getArray('val')) {
         if ($oValid->isValid($aVals)) {
             // Add the new blog
             if (isset($aVals['publish']) || isset($aVals['draft'])) {
                 if (isset($aVals['draft'])) {
                     $aVals['post_status'] = 2;
                     $sMessage = Phpfox::getPhrase('blog.blog_successfully_saved');
                 } else {
                     $sMessage = Phpfox::getPhrase('blog.your_blog_has_been_added');
                 }
                 if (($iFlood = Phpfox::getUserParam('blog.flood_control_blog')) !== 0) {
                     $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('blog'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                     // actually check if flooding
                     if (Phpfox::getLib('spam')->check($aFlood)) {
                         Phpfox_Error::set(Phpfox::getPhrase('blog.your_are_posting_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                     }
                 }
                 if (Phpfox_Error::isPassed()) {
                     $iId = Phpfox::getService('blog.process')->add($aVals);
                 }
             }
             // Update a blog
             if ((isset($aVals['update']) || isset($aVals['draft_update']) || isset($aVals['draft_publish'])) && isset($aRow['blog_id']) && $bIsEdit) {
                 if (isset($aVals['draft_publish'])) {
                     $aVals['post_status'] = 1;
                 }
                 // Update the blog
                 $iId = Phpfox::getService('blog.process')->update($aRow['blog_id'], $aRow['user_id'], $aVals, $aRow);
                 $sMessage = Phpfox::getPhrase('blog.blog_updated');
             }
             if (isset($iId) && $iId) {
                 Phpfox::permalink('blog', $iId, $aVals['title'], true, $sMessage);
             }
         }
     }
     $this->template()->setTitle(!empty($iEditId) ? Phpfox::getPhrase('blog.editing_blog') . ': ' . $aRow['title'] : Phpfox::getPhrase('blog.adding_a_new_blog'))->setFullSite()->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'bCanEditPersonalData' => $bCanEditPersonalData))->setEditor(array('wysiwyg' => Phpfox::getUserParam('blog.can_use_editor_on_blog')))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'quick_edit.js' => 'static_script', 'pager.css' => 'style_css'));
     if (Phpfox::isModule('attachment') && Phpfox::getUserParam('attachment.can_attach_on_blog')) {
         $this->setParam('attachment_share', array('type' => 'blog', 'id' => 'core_js_blog_form', 'edit_id' => $bIsEdit ? $iEditId : 0));
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_controller_add_process')) ? eval($sPlugin) : false;
 }
Exemple #10
0
 public function getExtra(&$aItems, $sType = null)
 {
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getextra__start')) ? eval($sPlugin) : false;
     if (!is_array($aItems)) {
         $aItems = array();
     }
     $aIds = array();
     foreach ($aItems as $iKey => $aValue) {
         $aIds[] = $aValue['blog_id'];
     }
     $aCategories = Phpfox::getService('blog.category')->getCategoriesById(implode(', ', $aIds));
     if (Phpfox::isModule('tag')) {
         $aTags = Tag_Service_Tag::instance()->getTagsById('blog', implode(', ', $aIds));
     }
     $oFilterOutput = Phpfox::getLib('parse.output');
     foreach ($aItems as $iKey => $aValue) {
         if (isset($aCategories[$aValue['blog_id']])) {
             $sCategories = '';
             $aCacheCategory[$aValue['blog_id']] = array();
             foreach ($aCategories[$aValue['blog_id']] as $aCategory) {
                 if (isset($aCacheCategory[$aValue['blog_id']][$aCategory['category_id']])) {
                     continue;
                 }
                 $aCacheCategory[$aValue['blog_id']][$aCategory['category_id']] = true;
                 if ($aCategory['user_id'] && $sType == 'user_profile') {
                     $sCategories .= ', <a href="' . Phpfox_Url::instance()->permalink($aValue['user_name'] . '.blog.category', $aCategory['category_id'], $aCategory['category_name']) . '">' . Phpfox_Locale::instance()->convert($oFilterOutput->clean($aCategory['category_name'])) . '</a>';
                 } else {
                     $sCategories .= ', <a href="' . Phpfox_Url::instance()->permalink('blog.category', $aCategory['category_id'], $aCategory['category_name']) . '">' . Phpfox_Locale::instance()->convert($oFilterOutput->clean($aCategory['category_name'])) . '</a>';
                 }
             }
             $sCategories = trim(ltrim($sCategories, ','));
             $aItems[$iKey]['categories'] = $sCategories;
             $aItems[$iKey]['info'] = Phpfox::getPhrase('blog.posted_x_by_x_in_x', array('date' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aValue['time_stamp']), 'link' => Phpfox_Url::instance()->makeUrl($aValue['user_name']), 'user' => $aValue, 'categories' => $sCategories));
         } else {
             $aItems[$iKey]['info'] = Phpfox::getPhrase('blog.posted_x_by_x', array('date' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aValue['time_stamp']), 'link' => Phpfox_Url::instance()->makeUrl($aValue['user_name']), 'user' => $aValue));
         }
         if (isset($aTags[$aValue['blog_id']])) {
             $aItems[$iKey]['tag_list'] = $aTags[$aValue['blog_id']];
         }
         $aItems[$iKey]['bookmark_url'] = Phpfox::permalink('blog', $aValue['blog_id'], $aValue['title']);
         $aItems[$iKey]['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'blog', 'privacy' => $aValue['privacy'], 'comment_privacy' => $aValue['privacy_comment'], 'like_type_id' => 'blog', 'feed_is_liked' => isset($aValue['is_liked']) ? $aValue['is_liked'] : false, 'feed_is_friend' => isset($aValue['is_friend']) ? $aValue['is_friend'] : false, 'item_id' => $aValue['blog_id'], 'user_id' => $aValue['user_id'], 'total_comment' => $aValue['total_comment'], 'feed_total_like' => $aValue['total_like'], 'total_like' => $aValue['total_like'], 'feed_link' => $aItems[$iKey]['bookmark_url'], 'feed_title' => $aValue['title'], 'time_stamp' => $aValue['time_stamp'], 'type_id' => 'blog');
     }
     unset($aTags, $aCategories);
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getextra__end')) ? eval($sPlugin) : false;
 }
Exemple #11
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::getParam('photo.show_info_on_mouseover')) {
         $this->template()->setHeader(array('index.css' => 'module_photo', 'index.js' => 'module_photo'));
     }
     if (defined('PHPFOX_IS_USER_PROFILE') || defined('PHPFOX_IS_PAGES_VIEW')) {
         $aUser = !defined('PHPFOX_IS_PAGES_VIEW') ? $this->getParam('aUser') : $this->getParam('aPage');
         $bShowPhotos = $this->request()->get('req3') != 'albums' || $this->request()->get('req4') != 'albums';
         if ($this->request()->get('req3') == '' || $this->request()->get('req4') == '') {
             $bShowPhotos = Phpfox::getParam('photo.in_main_photo_section_show') != 'albums';
         }
         if (defined('PHPFOX_IS_PAGES_VIEW')) {
             $this->template()->setHeader(array('photo.css' => 'module_pages'));
             if (empty($aUser['vanity_url'])) {
                 $aUser['user_name'] = 'pages.' . $aUser['page_id'];
             } else {
                 $aUser['user_name'] = $aUser['vanity_url'];
             }
             $aUser['profile_page_id'] = 0;
             $aInfo = array('total_albums' => Phpfox::callback('pages.getAlbumCount', $aUser['page_id']), 'total_photos' => Phpfox::callback('pages.getPhotoCount', $aUser['page_id']));
         } else {
             $aInfo = array('total_albums' => Phpfox::getService('photo.album')->getAlbumCount($aUser['user_id']), 'total_photos' => $aUser['total_photo']);
         }
         $bSpecialMenu = !defined('PHPFOX_IS_AJAX_CONTROLLER');
         $this->template()->assign(array('bSpecialMenu' => $bSpecialMenu, 'aInfo' => $aInfo, 'bShowPhotos' => $bShowPhotos, 'sLinkPhotos' => $this->url()->makeUrl($aUser['user_name'] . '.photo.photos'), 'sLinkAlbums' => $this->url()->makeUrl($aUser['user_name'] . '.photo.albums')));
     } else {
         $this->template()->assign(array('bSpecialMenu' => false));
     }
     if (Phpfox::getParam('photo.show_info_on_mouseover') && isset($aUser['use_timeline']) && $aUser['use_timeline']) {
         $this->template()->setFullSite();
     }
     if (!$this->request()->get('delete') && defined('PHPFOX_IS_PAGES_VIEW') && ($this->request()->get('req3') == 'albums' || $this->request()->get('req4') == 'albums')) {
         Phpfox::getComponent('photo.albums', array('bNoTemplate' => true), 'controller');
         return;
     }
     if ((defined('PHPFOX_IS_USER_PROFILE') || !defined('PHPFOX_IS_USER_PROFILE')) && $this->request()->get('req3') != 'photos' && !in_array($this->request()->get('view'), array('my', 'photos', 'pending')) && !is_numeric($this->request()->get('req2')) && Phpfox::getParam('photo.in_main_photo_section_show') == 'albums' && !$this->request()->get('delete') && !$this->request()->get('search-id')) {
         Phpfox::getComponent('photo.albums', array('bNoTemplate' => true), 'controller');
         return;
     }
     $sAssert = $this->request()->get('req4', false);
     if (($this->request()->get('req3') == 'photos' || $this->request()->get('req3') == 'albums') && $sAssert == false) {
     } else {
         if (defined('PHPFOX_IS_USER_PROFILE') && ($sLegacyTitle = $this->request()->get('req3')) && !empty($sLegacyTitle)) {
             if (($sLegacyPhoto = $this->request()->get('req4')) && !empty($sLegacyPhoto)) {
                 $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('photo_id', 'title'), 'table' => 'photo', 'redirect' => 'photo', 'title' => $sLegacyPhoto));
             } else {
                 $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('album_id', 'name'), 'table' => 'photo_album', 'redirect' => 'photo.album', 'title' => $sLegacyTitle, 'search' => 'name_url'));
             }
         }
     }
     Phpfox::getUserParam('photo.can_view_photos', true);
     if ($this->request()->get('req2') == 'category') {
         $_SESSION['photo_category'] = $this->request()->get('req3');
         $this->template()->setHeader(array('<script type="text/javascript"> var sPhotoCategory = "' . $this->request()->get('req3') . '"; </script>'))->assign(array('sPhotoCategory' => $this->request()->get('req3')));
     } else {
         $_SESSION['photo_category'] = '';
     }
     $aParentModule = $this->getParam('aParentModule');
     if (($iRedirectId = $this->request()->getInt('redirect')) && ($aPhoto = Phpfox::getService('photo')->getForEdit($iRedirectId))) {
         if ($aPhoto['group_id']) {
             $aGroup = Phpfox::getService('group')->getGroup($aPhoto['group_id'], true);
             $this->url()->send('group', array($aGroup['title_url'], 'photo', 'view', $aPhoto['title_url']));
         } else {
             $this->url()->send($aPhoto['user_name'], array('photo', $aPhoto['album_id'] ? $aPhoto['album_url'] : 'view', $aPhoto['title_url']));
         }
     }
     if (($iRedirectAlbumId = $this->request()->getInt('aredirect')) && ($aAlbum = Phpfox::getService('photo.album')->getForEdit($iRedirectAlbumId))) {
         $this->url()->send($aAlbum['user_name'], array('photo', $aAlbum['name_url']));
     }
     if (($iUnFeature = $this->request()->getInt('unfeature')) && Phpfox::getUserParam('photo.can_feature_photo')) {
         if (Phpfox::getService('photo.process')->feature($iUnFeature, 0)) {
             $this->url()->send('photo', null, Phpfox::getPhrase('photo.photo_successfully_unfeatured'));
         }
     }
     if (empty($aParentModule) && $this->request()->get('req1') == 'pages') {
         $aParentModule = array('module_id' => 'pages', 'item_id' => $this->request()->get('req2'), 'url' => Phpfox::getService('pages')->getUrl($this->request()->get('req2')));
         define('PHPFOX_IS_PAGES_VIEW', true);
     }
     if ($aParentModule === null && $this->request()->getInt('req2') > 0) {
         return Phpfox_Module::instance()->setController('photo.view');
     }
     if (($sLegacyTitle = $this->request()->get('req2')) && !empty($sLegacyTitle) && !is_numeric($sLegacyTitle)) {
         if ((defined('PHPFOX_IS_USER_PROFILE') || defined('PHPFOX_IS_PAGES_VIEW')) && $sLegacyTitle == 'photo') {
         } else {
             if ($this->request()->get('req3') != '') {
                 $sLegacyTitle = $this->request()->get('req3');
             }
             $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('category_id', 'name'), 'table' => 'photo_category', 'redirect' => 'photo.category', 'title' => $sLegacyTitle, 'search' => 'name_url'));
         }
     }
     $bIsUserProfile = false;
     if (defined('PHPFOX_IS_AJAX_CONTROLLER') || defined('PHPFOX_LOADING_DELAYED')) {
         if ($this->request()->get('profile_id', null) !== null) {
             $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id'));
             $bIsUserProfile = true;
             $this->setParam('aUser', $aUser);
         } else {
             if ($this->request()->get('req1', null) !== null) {
                 if ($aUser = Phpfox::getService('user')->get($this->request()->get('req1'), false)) {
                     $bIsUserProfile = true;
                     $this->setParam('aUser', $aUser);
                 }
             }
         }
     }
     // Used to control privacy
     $bNoAccess = false;
     if (defined('PHPFOX_IS_USER_PROFILE')) {
         $bIsUserProfile = true;
         $aUser = $this->getParam('aUser');
         if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'photo.display_on_profile')) {
             $bNoAccess = true;
         }
     }
     if (isset($aUser) && $aUser['profile_page_id'] != 0) {
         $bIsUserProfile = false;
         $aParentModule = array('module_id' => 'pages', 'item_id' => $aUser['profile_page_id'], 'url' => Phpfox::getService('pages')->getUrl($aUser['profile_page_id']));
         define('PHPFOX_IS_PAGES_VIEW', true);
     }
     $aCallback = $this->getParam('aCallback', null);
     if (PHPFOX_IS_AJAX) {
         if ($this->request()->get('req1') == 'group') {
             $aGroup = Phpfox::getService('group')->getGroup($this->request()->get('req2'));
             if (isset($aGroup['group_id'])) {
                 $aCallback = array('group_id' => $aGroup['group_id'], 'url_home' => 'group.' . $aGroup['title_url'] . '.photo', 'url_home_array' => array('group', array($aGroup['title_url'])));
             }
         }
     }
     // http://www.phpfox.com/tracker/view/15103
     if (!isset($aUser) && defined('PHPFOX_IS_PAGES_VIEW')) {
         $aUser = $this->getParam('aUser');
     }
     $sCategory = null;
     $aSearch = $this->request()->getArray('search');
     $bIsTagSearch = false;
     $sPhotoUrl = $bIsUserProfile ? $this->url()->makeUrl($aUser['user_name'], 'photo') : ($aParentModule === null ? $this->url()->makeUrl('photo') : $aParentModule['url'] . 'photo/');
     $this->setParam('sTagType', 'photo');
     $sView = $this->request()->get('view', false);
     if ($iDeleteId = $this->request()->get('delete')) {
         if (Phpfox::getService('photo.process')->delete($iDeleteId)) {
             $this->url()->forward($sPhotoUrl, Phpfox::getPhrase('photo.photo_successfully_deleted'));
         }
     }
     $aSort = array('latest' => array('photo.photo_id', Phpfox::getPhrase('photo.latest')), 'most-viewed' => array('photo.total_view', Phpfox::getPhrase('photo.most_viewed')), 'most-talked' => array('photo.total_comment', Phpfox::getPhrase('photo.most_discussed')));
     if (Phpfox::getParam('photo.can_rate_on_photos')) {
         $aSort['top-rating'] = array('photo.total_rating', Phpfox::getPhrase('photo.top_rated'));
     }
     if (Phpfox::getParam('photo.enable_photo_battle')) {
         $aSort['top-battle'] = array('photo.total_battle', Phpfox::getPhrase('photo.top_battle'));
     }
     $aPhotoDisplays = Phpfox::getUserParam('photo.total_photos_displays');
     $this->search()->set(array('type' => 'photo', 'field' => 'photo.photo_id', 'search_tool' => array('table_alias' => 'photo', 'search' => array('action' => $sPhotoUrl, 'default_value' => Phpfox::getPhrase('photo.search_photos'), 'name' => 'search', 'field' => 'photo.title'), 'sort' => $aSort, 'show' => (array) $aPhotoDisplays)));
     $aBrowseParams = array('module_id' => 'photo', 'alias' => 'photo', 'field' => 'photo_id', 'table' => Phpfox::getT('photo'), 'hide_view' => array('pending', 'my'));
     $bIsMassEditUpload = false;
     $bRunPlugin = false;
     if (($sPlugin = Phpfox_Plugin::get('photo.component_controller_index_brunplugin1')) && eval($sPlugin) === false) {
         return false;
     }
     switch ($sView) {
         case 'pending':
             Phpfox::getUserParam('photo.can_approve_photos', true);
             $this->search()->setCondition('AND photo.view_id = 1');
             $this->template()->assign('bIsInApproveMode', true);
             break;
         case 'my':
             Phpfox::isUser(true);
             $this->search()->setCondition('AND photo.user_id = ' . Phpfox::getUserId());
             if ($this->request()->get('mode') == 'edit') {
                 list($iAlbumCnt, $aAlbums) = Phpfox::getService('photo.album')->get('pa.user_id = ' . Phpfox::getUserId());
                 $this->template()->assign('bIsEditMode', true);
                 $this->template()->assign('aAlbums', $aAlbums);
                 if ($aEditPhotos = $this->request()->get('photos')) {
                     // $sEditPhotos = base64_decode(urldecode($sEditPhotos));
                     // $aEditPhotos = explode(',', $sEditPhotos);
                     $sPhotoList = '';
                     foreach ($aEditPhotos as $iPhotoId) {
                         $iPhotoId = rtrim($iPhotoId, ',');
                         if (empty($iPhotoId)) {
                             continue;
                         }
                         $sPhotoList .= (int) $iPhotoId . ',';
                     }
                     $sPhotoList = rtrim($sPhotoList, ',');
                     if (!empty($sPhotoList)) {
                         $bIsMassEditUpload = true;
                         $this->search()->setCondition('AND photo.photo_id IN(' . $sPhotoList . ')');
                     }
                 }
             }
             break;
         default:
             if ($bRunPlugin) {
                 ($sPlugin = Phpfox_Plugin::get('photo.component_controller_index_plugin1')) ? eval($sPlugin) : false;
             } elseif ($bIsUserProfile) {
                 $this->search()->setCondition('AND photo.view_id ' . ($aUser['user_id'] == Phpfox::getUserId() ? 'IN(0,2)' : '= 0') . ' AND photo.group_id = 0 AND photo.type_id = 0 AND photo.privacy IN(' . (Phpfox::getParam('core.section_privacy_item_browsing') ? '%PRIVACY%' : Phpfox::getService('core')->getForBrowse($aUser)) . ') AND photo.user_id = ' . (int) $aUser['user_id']);
             } else {
                 if (defined('PHPFOX_IS_PAGES_VIEW')) {
                     $this->search()->setCondition('AND photo.view_id = 0 AND photo.module_id = \'' . Phpfox_Database::instance()->escape($aParentModule['module_id']) . '\' AND photo.group_id = ' . (int) $aParentModule['item_id'] . ' AND photo.privacy IN(%PRIVACY%)');
                 } else {
                     $this->search()->setCondition('AND photo.view_id = 0 AND photo.group_id = 0 AND photo.type_id = 0 AND photo.privacy IN(%PRIVACY%)');
                 }
             }
             break;
     }
     if ($this->request()->get('req2') == 'category') {
         $sCategory = $iCategory = $this->request()->getInt('req3');
         $sWhere = 'AND pcd.category_id = ' . (int) $sCategory;
         if (!is_int($iCategory)) {
             $iCategory = Phpfox::getService('photo.category')->getCategoryId($sCategory);
         }
         // Get sub-categories
         $aSubCategories = Phpfox::getService('photo.category')->getForBrowse($iCategory);
         if (!empty($aSubCategories) && is_array($aSubCategories)) {
             $aSubIds = Phpfox::getService('photo.category')->extractCategories($aSubCategories);
             if (!empty($aSubIds)) {
                 $sWhere = 'AND pcd.category_id IN (' . (int) $sCategory . ',' . join(',', $aSubIds) . ')';
             }
         }
         $this->search()->setCondition($sWhere);
         $this->setParam('hasSubCategories', true);
     }
     if ($this->request()->get('req2') == 'tag') {
         if ($aTag = Tag_Service_Tag::instance()->getTagInfo('photo', $this->request()->get('req3'))) {
             $this->template()->setBreadCrumb(Phpfox::getPhrase('tag.topic') . ': ' . $aTag['tag_text'] . '', $this->url()->makeUrl('current'), true);
             $this->search()->setCondition('AND tag.tag_text = \'' . Phpfox_Database::instance()->escape($aTag['tag_text']) . '\'');
         }
     }
     if ($sView == 'featured') {
         $this->search()->setCondition('AND photo.is_featured = 1');
     }
     Phpfox::getService('photo.browse')->category($sCategory);
     if (!Phpfox::getParam('photo.display_profile_photo_within_gallery')) {
         $this->search()->setCondition('AND photo.is_profile_photo = 0');
     }
     $this->search()->browse()->params($aBrowseParams)->execute();
     if ($bNoAccess == false) {
         $aPhotos = $this->search()->browse()->getRows();
         $iCnt = $this->search()->browse()->getCount();
     } else {
         $aPhotos = array();
         $iCnt = 0;
     }
     foreach ($aPhotos as $aPhoto) {
         $this->template()->setMeta('keywords', $this->template()->getKeywords($aPhoto['title']));
     }
     $aPager = array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount());
     if (Phpfox::getParam('photo.show_info_on_mouseover')) {
         $aPager['ajax'] = 'photo.browse';
     }
     if ($aPager['size'] > Phpfox::getUserParam('photo.max_photo_display_limit')) {
         $aPager['size'] = Phpfox::getUserParam('photo.max_photo_display_limit');
     }
     Phpfox_Pager::instance()->set($aPager);
     $this->template()->setTitle($bIsUserProfile ? Phpfox::getPhrase('photo.full_name_s_photos', array('full_name' => $aUser['full_name'])) : Phpfox::getPhrase('photo.photos'))->setBreadcrumb(Phpfox::getPhrase('photo.photos'), $sPhotoUrl)->setMeta('keywords', Phpfox::getParam('photo.photo_meta_keywords'))->setMeta('description', Phpfox::getParam('photo.photo_meta_description'));
     //->setMeta('description', Phpfox::getPhrase('photo.site_title_has_a_total_of_total_photo_s', array('site_title' => Phpfox::getParam('core.site_title'), 'total' => $iCnt)))
     if (defined('PHPFOX_IS_USER_PROFILE') || defined('PHPFOX_IS_PAGES_VIEW')) {
         $this->template()->setMeta('description', Phpfox::getPhrase('photo.site_title_has_a_total_of_total_photo_s', array('site_title' => $aUser['full_name'], 'total' => $iCnt)));
     } else {
         $this->template()->setMeta('description', Phpfox::getPhrase('photo.site_title_has_a_total_of_total_photo_s', array('site_title' => Phpfox::getParam('core.site_title'), 'total' => $iCnt)));
     }
     foreach ($aPhotos as $key => $photo) {
         $aPhotos[$key]['can_view'] = true;
         if ($photo['user_id'] != Phpfox::getUserId()) {
             if ($photo['mature'] == 1 && Phpfox::getUserParam(array('photo.photo_mature_age_limit' => array('>', (int) Phpfox::getUserBy('age'))))) {
                 // warning check cookie
                 $aPhotos[$key]['can_view'] = false;
             } elseif ($photo['mature'] == 2 && Phpfox::getUserParam(array('photo.photo_mature_age_limit' => array('>', (int) Phpfox::getUserBy('age'))))) {
                 $aPhotos[$key]['can_view'] = false;
             }
         }
     }
     $this->template()->setPhrase(array('photo.loading'))->setHeader('cache', array('jquery/plugin/jquery.mosaicflow.min.js' => 'static_script'))->assign(array('aPhotos' => $aPhotos, 'bIsAjax' => PHPFOX_IS_AJAX, 'sPhotoUrl' => $sPhotoUrl, 'sView' => $sView, 'bIsMassEditUpload' => $bIsMassEditUpload, 'iPhotosPerRow' => 3));
     if ($this->request()->get('req2') == 'category' && isset($aPhoto) && isset($aPhoto['category_name']) && isset($aPhoto['category_id'])) {
         $sCatUrl = str_replace(' ', '-', strtolower($aPhoto['category_name']));
         $this->template()->setBreadcrumb($aPhoto['category_name'], $this->url()->makeUrl('photo.category.' . $aPhoto['category_id'] . '.') . $sCatUrl . '/');
     }
     if ($aParentModule === null) {
         Phpfox::getService('photo')->buildMenu();
     }
     if (!empty($sCategory)) {
         $aCategories = Phpfox::getService('photo.category')->getParentBreadcrumb($sCategory);
         $iCnt = 0;
         foreach ($aCategories as $aCategory) {
             $iCnt++;
             $this->template()->setTitle($aCategory[0]);
             /*
             if ($aCallback !== null)
             {
             	$sHomeUrl = '/' . Phpfox_Url::instance()->doRewrite($aCallback['url_home_array'][0]) . '/' . implode('/', $aCallback['url_home_array'][1]) . '/' . Phpfox_Url::instance()->doRewrite('photo') . '/';
             	$aCategory[1] = preg_replace('/^http:\/\/(.*?)\/' . Phpfox_Url::instance()->doRewrite('photo') . '\/(.*?)$/i', 'http://\\1' . $sHomeUrl . '\\2', $aCategory[1]);
             }				
             */
             $this->template()->setBreadcrumb($aCategory[0], $aCategory[1], $iCnt === count($aCategories) ? true : false);
         }
     }
     $this->setParam('sCurrentCategory', $sCategory);
     $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'))));
     $iStartCheck = 0;
     if (!empty($sCategory)) {
         $iStartCheck = 5;
     }
     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', $iAllowIds);
     if (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE) {
         $aRediAllow[] = 'photo';
     }
     $aCheckParams = array('url' => $this->url()->makeUrl('photo'), 'start' => $iStartCheck, 'reqs' => array('2' => $aRediAllow, '3' => $aRediAllow), 'reserved' => array('mode', 'photos'));
     if (Phpfox::getParam('core.force_404_check') && !Phpfox::getService('core.redirect')->check404($aCheckParams)) {
         return Phpfox_Module::instance()->setController('error.404');
     }
 }
Exemple #12
0
 /**
  * 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;
 }
Exemple #13
0
 /**
  * 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;
 }
Exemple #14
0
 public function getPhoto($sId, $iUserId = 0, $aCallback = null)
 {
     /*
     if ($aCallback === null)
     {
     	$sView = 'p.view_id = 0';
     	if ($iUserId == Phpfox::getUserId() || Phpfox::getUserParam('photo.can_approve_photos'))
     	{
     		$sView = 'p.view_id IN(0,1)';
     	}		
     	$this->database()->where($sView . ' AND p.group_id = 0 AND p.title_url = \'' . $this->database()->escape($sId) . '\' AND p.user_id = ' . (int) $iUserId);
     }
     else 
     {
     	$this->database()->where('p.view_id = 0 AND p.group_id = ' . $aCallback['group_id'] . ' AND p.title_url = \'' . $this->database()->escape($sId) . '\'');			
     }
     */
     if (Phpfox::isModule('like')) {
         $this->database()->select('lik.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'lik', 'lik.type_id = \'photo\' AND lik.item_id = p.photo_id AND lik.user_id = ' . Phpfox::getUserId());
     }
     $this->database()->select('f.friend_id AS is_friend, ')->leftJoin(Phpfox::getT('friend'), 'f', "f.user_id = p.user_id AND f.friend_user_id = " . Phpfox::getUserId());
     $this->database()->where('p.photo_id = ' . (int) $sId);
     $aPhoto = $this->database()->select('' . Phpfox::getUserField() . ', p.*, pi.*, pa.name AS album_url, pa.name AS album_title, pa.profile_id AS album_profile_id, pt.item_id AS is_viewed')->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->leftJoin(Phpfox::getT('photo_info'), 'pi', 'pi.photo_id = p.photo_id')->leftJoin(Phpfox::getT('photo_album'), 'pa', 'pa.album_id = p.album_id')->leftJoin(Phpfox::getT('photo_track'), 'pt', 'pt.item_id = p.photo_id AND pt.user_id = ' . Phpfox::getUserId())->execute('getSlaveRow');
     if (!isset($aPhoto['photo_id'])) {
         return false;
     }
     if (!Phpfox::isModule('like')) {
         $aPhoto['is_liked'] = false;
     }
     if (Phpfox::isModule('tag')) {
         $aTags = Tag_Service_Tag::instance()->getTagsById('photo', $aPhoto['photo_id']);
         if (isset($aTags[$aPhoto['photo_id']])) {
             $aPhoto['tag_list'] = $aTags[$aPhoto['photo_id']];
         }
     }
     $aPhoto['categories'] = Phpfox::getService('photo.category')->getCategoriesById($aPhoto['photo_id']);
     $aPhoto['category_list'] = Phpfox::getService('photo.category')->getCategoryIds($aPhoto['photo_id']);
     if (empty($aPhoto['album_id'])) {
         $aPhoto['album_url'] = 'view';
     }
     $aPhoto['original_destination'] = $aPhoto['destination'];
     $aPhoto['destination'] = $this->getPhotoUrl($aPhoto);
     if ($aPhoto['album_id'] > 0) {
         if ($aPhoto['album_profile_id'] > 0) {
             $aPhoto['album_title'] = Phpfox::getPhrase('photo.profile_pictures');
             $aPhoto['album_url'] = Phpfox::permalink('photo.album.profile', $aPhoto['user_id'], $aPhoto['user_name']);
         } else {
             $aPhoto['album_url'] = Phpfox::permalink('photo.album', $aPhoto['album_id'], $aPhoto['album_title']);
         }
     }
     return $aPhoto;
 }
 /**
  * Controller
  */
 public function process()
 {
     define('PHPFOX_PAGER_FORCE_COUNT', true);
     Phpfox::getUserParam('forum.can_view_forum', true);
     $iPage = $this->request()->getInt('page');
     $iPageSize = Phpfox::getParam('forum.total_posts_per_thread');
     $aThreadCondition = array();
     $aCallback = $this->getParam('aCallback', null);
     if (($iPostRedirect = $this->request()->getInt('permalink')) && ($sUrl = Phpfox::getService('forum.callback')->getFeedRedirectPost($iPostRedirect))) {
         $this->url()->forward(preg_replace('/\\/post_(.*)\\//i', '/view_\\1/', $sUrl));
     }
     if (Phpfox::isUser() && ($iView = $this->request()->getInt('view')) && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('forum_subscribed_post', $iView, Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('forum_post_like', $iView, Phpfox::getUserId());
     }
     if (($iRedirect = $this->request()->getInt('redirect')) && ($aThread = Forum_Service_Thread_Thread::instance()->getForRedirect($iRedirect))) {
         if ($aThread['group_id'] > 0) {
             $aCallback = Phpfox::callback('group.addForum', $aThread['group_id']);
             if (isset($aCallback['module'])) {
                 $this->url()->send($aCallback['url_home'], array('forum', $aThread['title_url']));
             }
         }
         $this->url()->send('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url']));
     }
     $threadId = $this->request()->getInt('req3');
     if ($this->request()->segment(3) == 'replies' && $this->request()->getInt('id')) {
         $threadId = $this->request()->getInt('id');
         $iPage = 1;
         $iPageSize = 200;
         $this->template()->setBreadCrumb('Latest Replies', $this->url()->current(), true);
         $this->template()->assign(['isReplies' => true]);
     }
     $aThreadCondition[] = 'ft.thread_id = ' . $threadId . '';
     $sPermaView = $this->request()->get('view', null);
     if ((int) $sPermaView <= 0) {
         $sPermaView = null;
     }
     list($iCnt, $aThread) = Forum_Service_Thread_Thread::instance()->getThread($aThreadCondition, array(), 'fp.time_stamp ASC', $iPage, $iPageSize, $sPermaView);
     if (!isset($aThread['thread_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
     }
     if ($aThread['group_id'] > 0) {
         $aCallback = Phpfox::callback('pages.addForum', $aThread['group_id']);
         if (!Phpfox::getService('pages')->hasPerm($aThread['group_id'], 'forum.view_browse_forum')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
     }
     Phpfox::getService('core.redirect')->check($aThread['title'], 'req4');
     if ($aThread['view_id'] != '0' && $aThread['user_id'] != Phpfox::getUserId()) {
         if (!Phpfox::getUserParam('forum.can_approve_forum_thread') && !Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_thread')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
     }
     if ($aCallback === null && !Phpfox::getService('forum')->hasAccess($aThread['forum_id'], 'can_view_forum')) {
         if (Phpfox::isUser()) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.you_do_not_have_the_proper_permission_to_view_this_thread'));
         } else {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.log_in_to_view_thread'));
         }
     }
     if ($aCallback === null && !Phpfox::getService('forum')->hasAccess($aThread['forum_id'], 'can_view_thread_content')) {
         $this->url()->send('forum', null, Phpfox::getPhrase('forum.you_do_not_have_the_proper_permission_to_view_this_thread'));
     }
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum();
     if ($this->request()->get('approve') && (Phpfox::getUserParam('forum.can_approve_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_thread')) && $aThread['view_id']) {
         $sCurrentUrl = $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title']);
         if (Phpfox::getService('forum.thread.process')->approve($aThread['thread_id'], $sCurrentUrl)) {
             $this->url()->forward($sCurrentUrl);
         }
     }
     if ($iPostId = $this->request()->getInt('post')) {
         $iCurrentPage = Forum_Service_Post_Post::instance()->getPostPage($aThread['thread_id'], $iPostId, $iPageSize);
         $sFinalLink = $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title'], false, null, array('page' => $iCurrentPage));
         $this->url()->forward($sFinalLink . '#post' . $iPostId);
     }
     if (!$aThread['is_seen']) {
         if ($aCallback === null) {
             Phpfox::getService('forum.process')->updateTrack($aForum['forum_id']);
         }
         Phpfox::getService('forum.thread.process')->updateTrack($aThread['thread_id']);
     }
     if (Phpfox::isModule('tag') && $aCallback === null) {
         $aTags = Tag_Service_Tag::instance()->getTagsById($aCallback === null ? 'forum' : 'forum_group', $aThread['thread_id']);
         if (isset($aTags[$aThread['thread_id']])) {
             $aThread['tag_list'] = $aTags[$aThread['thread_id']];
         }
     }
     // Add tags to meta keywords
     if (!empty($aThread['tag_list']) && $aThread['tag_list'] && Phpfox::isModule('tag')) {
         $this->template()->setMeta('keywords', Tag_Service_Tag::instance()->getKeywords($aThread['tag_list']));
     }
     $this->setParam('iActiveForumId', $aForum['forum_id']);
     if (Phpfox::getParam('forum.rss_feed_on_each_forum')) {
         if ($aCallback === null) {
             $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.forum') . ': ' . $aForum['name'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'forum' => $aForum['forum_id'])) . '" />');
         } else {
             $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.group_forum') . ': ' . $aCallback['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'group' => $aCallback['group_id'])) . '" />');
         }
     }
     if (Phpfox::getParam('forum.enable_rss_on_threads')) {
         $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('forum.thread') . ': ' . $aThread['title'] . '" href="' . $this->url()->makeUrl('forum', array('rss', 'thread' => $aThread['thread_id'])) . '" />');
     }
     if ($aCallback === null) {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'))->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb(Phpfox_Locale::instance()->convert($aForum['name']), $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']));
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages'));
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/');
     }
     $bCanManageThread = false;
     $bCanEditThread = false;
     $bCanDeleteThread = false;
     $bCanStickThread = false;
     $bCanCloseThread = false;
     $bCanMergeThread = false;
     if ($aCallback === null) {
         if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) {
             $bCanEditThread = true;
         }
         if (Phpfox::getUserParam('forum.can_delete_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_delete_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'delete_post')) {
             $bCanDeleteThread = true;
         }
         if (Phpfox::getUserParam('forum.can_stick_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'post_sticky')) {
             $bCanStickThread = true;
         }
         if (Phpfox::getUserParam('forum.can_close_a_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'close_thread')) {
             $bCanCloseThread = true;
         }
         if (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'merge_thread')) {
             $bCanMergeThread = true;
         }
         if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post') || (Phpfox::getUserParam('forum.can_move_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'move_thread')) || (Phpfox::getUserParam('forum.can_copy_forum_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'copy_thread')) || Phpfox::getUserParam('forum.can_delete_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_delete_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'delete_post') || (Phpfox::getUserParam('forum.can_stick_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'post_sticky')) || (Phpfox::getUserParam('forum.can_close_a_thread') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'close_thread')) || (Phpfox::getUserParam('forum.can_merge_forum_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'merge_thread'))) {
             $bCanManageThread = true;
         }
     } else {
         if (Phpfox::getService('pages')->isAdmin($aCallback['item'])) {
             $bCanEditThread = true;
             $bCanDeleteThread = true;
             $bCanStickThread = true;
             $bCanCloseThread = true;
             $bCanMergeThread = true;
             $bCanManageThread = true;
         }
     }
     $bCanPurchaseSponsor = false;
     if ((Phpfox::getUserParam('forum.can_purchase_sponsor') && $aThread['user_id'] == Phpfox::getUserId() || ($bCanCloseThread || $bCanStickThread) || Phpfox::getUserParam('forum.can_sponsor_thread')) && !defined('PHPFOX_IS_GROUP_VIEW')) {
         $bCanPurchaseSponsor = true;
     }
     $sCurrentThreadLink = $aCallback === null ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], $aThread['title_url']);
     if ($this->request()->get('view')) {
         Phpfox_Module::instance()->appendPageClass('single_mode');
     }
     if (Phpfox::isUser()) {
         $this->template()->menu('Reply', '#', 'onclick="$Core.box(\'forum.reply\', 800, \'id=' . $aThread['thread_id'] . '\'); return false;"');
     }
     $this->template()->setTitle($aThread['title'])->setBreadcrumb($aThread['title'], $this->url()->permalink('forum.thread', $aThread['thread_id'], $aThread['title']), true)->setMeta('description', $aThread['title'] . ' - ' . $aForum['name'])->setMeta('keywords', $this->template()->getKeywords($aThread['title']))->setPhrase(array('forum.provide_a_reply', 'forum.adding_your_reply', 'forum.are_you_sure', 'forum.post_successfully_deleted'))->setEditor()->setHeader('cache', array('jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'forum.js' => 'module_forum', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'feed.js' => 'module_feed'))->assign(array('aThread' => $aThread, 'aPost' => isset($aThread['post_starter']) ? $aThread['post_starter'] : '', 'iTotalPosts' => $iCnt, 'sCurrentThreadLink' => $sCurrentThreadLink, 'aCallback' => $aCallback, 'bCanManageThread' => $bCanManageThread, 'bCanEditThread' => $bCanEditThread, 'bCanDeleteThread' => $bCanDeleteThread, 'bCanStickThread' => $bCanStickThread, 'bCanCloseThread' => $bCanCloseThread, 'bCanMergeThread' => $bCanMergeThread, 'bCanPurchaseSponsor' => $bCanPurchaseSponsor, 'sPermaView' => $sPermaView, 'aPoll' => empty($aThread['poll']) ? false : $aThread['poll'], 'bIsViewingPoll' => true, 'bIsCustomPoll' => true, 'sMicroPropType' => 'CreativeWork'));
     $this->setParam('global_moderation', array('name' => 'forumpost', 'ajax' => 'forum.postModeration', 'menu' => array(array('phrase' => Phpfox::getPhrase('forum.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('forum.approve'), 'action' => 'approve'))));
     Phpfox::getLib('parse.output')->setEmbedParser(array('width' => 640, 'height' => 360));
     if ($this->request()->get('is_ajax_get')) {
         $this->template()->assign('isReplies', true);
         Phpfox_Module::instance()->getControllerTemplate();
         $content = ob_get_contents();
         ob_clean();
         return ['run' => "\$('.thread_replies .fa').remove();", 'html' => ['to' => '.tr_content', 'with' => $content]];
     }
 }
Exemple #16
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     $bCanEditPersonalData = true;
     $aCallback = false;
     if ($this->request()->get('module')) {
         $this->template()->assign(array('bIsGroup' => '1'));
     }
     if (($sModule = $this->request()->get('module')) && Phpfox::isModule($sModule) && ($iItemId = $this->request()->getInt('item')) && Phpfox::hasCallback($sModule, 'addForum')) {
         $aCallback = Phpfox::callback($sModule . '.addForum', $iItemId);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages'));
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/');
         if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItemId, 'forum.share_forum')) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings'));
         }
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum'));
     }
     $iId = $this->request()->getInt('id');
     $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iId, Phpfox::getUserBy('user_group_id'));
     if ($aAccess['can_view_thread_content']['value'] != true) {
         return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings'));
     }
     if (Phpfox::isModule('poll')) {
         $this->template()->setHeader('cache', array('poll.js' => 'module_poll', '<script type="text/javascript">$Behavior.loadSortableAnswers = function() {$(".sortable").sortable({placeholder: "placeholder", axis: "y"});}</script>'));
     }
     $this->template()->setEditor()->setTitle(Phpfox::getPhrase('forum.forum'))->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'pager.css' => 'style_css', 'forum.css' => 'style_css'));
     $bIsEdit = false;
     if ($this->request()->get('req3') == 'thread') {
         if ($iEditId = $this->request()->getInt('edit')) {
             $aThread = Forum_Service_Thread_Thread::instance()->getForEdit($iEditId);
             if (!isset($aThread['thread_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
             }
             if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) {
                 $bIsEdit = true;
                 if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aThread['user_id']) {
                     $bCanEditPersonalData = false;
                 }
                 $iId = $aThread['forum_id'];
                 if (Phpfox::isModule('tag')) {
                     $aThread['tag_list'] = Tag_Service_Tag::instance()->getForEdit('forum', $aThread['thread_id']);
                 }
                 $this->template()->assign(array('aForms' => $aThread, 'iEditId' => $aThread['thread_id']));
             } else {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread'));
             }
         }
         if ($aCallback === false) {
             $aForum = Phpfox::getService('forum')->id($iId)->getForum();
             if (!isset($aForum['forum_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
             }
             if ($aForum['is_closed']) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed'));
             }
         }
         if (!$bIsEdit) {
             $bPass = false;
             if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) {
                 $bPass = true;
             }
             if ($bPass === false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread'));
             }
         }
         if (!Forum_Service_Forum::instance()->hasAccess($iId, 'can_start_thread')) {
             return Phpfox_Error::display('You are unable to create a new post in this forum.');
         }
         $aValidation = array('title' => Phpfox::getPhrase('forum.provide_a_title_for_your_thread'), 'text' => Phpfox::getPhrase('forum.provide_some_text'));
         if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) {
             $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
         }
         $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
         $bPosted = false;
         if ($aVals = $this->request()->getArray('val')) {
             if (isset($aVals['type_id']) && $aVals['type_id'] == 'announcement') {
                 $bPosted = true;
             }
             if ($oValid->isValid($aVals)) {
                 if ($bIsEdit) {
                     $aVals['post_id'] = $aThread['start_id'];
                     $aVals['was_announcement'] = $aThread['is_announcement'];
                     $aVals['forum_id'] = $aThread['forum_id'];
                     if (Phpfox::getService('forum.thread.process')->update($aThread['thread_id'], $aThread['user_id'], $aVals)) {
                         $this->url()->permalink('forum.thread', $aThread['thread_id'], Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true, Phpfox::getPhrase('forum.thread_successfully_updated'));
                     }
                 } else {
                     if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) {
                         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                         // actually check if flooding
                         if (Phpfox::getLib('spam')->check($aFlood)) {
                             Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                         }
                     }
                     if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, $aCallback))) {
                         $this->url()->permalink('forum.thread', $iId, Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true);
                     }
                 }
             }
         }
         if ($aCallback === false) {
             $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true);
         } else {
             $this->template()->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true);
         }
         $this->template()->assign(array('iForumId' => $iId, 'iActualForumId' => $iId, 'sFormLink' => $aCallback == false ? $this->url()->makeUrl('forum.post.thread', array('id' => $iId)) : $this->url()->makeUrl('forum.post.thread', array('module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sForumParents' => $aCallback === false ? Phpfox::getUserParam('forum.can_post_announcement') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'post_announcement') ? Phpfox::getService('forum')->active($aForum['forum_id'])->getJumpTool(true) : '' : '', 'bPosted' => $bPosted, 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback));
         if (Phpfox::getUserParam('forum.can_add_forum_attachments')) {
             $this->setParam('attachment_share', array('type' => 'forum', 'id' => 'js_forum_form'));
         }
     } else {
         if ($iEditId = $this->request()->getInt('edit')) {
             $aPost = Phpfox::getService('forum.post')->getForEdit($iEditId);
             if (!isset($aPost['post_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_post'));
             }
             $bCanEditPost = Phpfox::getUserParam('forum.can_edit_own_post') && $aPost['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aPost['forum_id'], 'edit_post');
             if ($bCanEditPost) {
                 $bIsEdit = true;
                 if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aPost['user_id']) {
                     $bCanEditPersonalData = false;
                 }
                 $iId = $aPost['thread_id'];
                 $this->template()->assign(array('aForms' => $aPost, 'iEditId' => $aPost['post_id']));
                 if (PHPFOX_IS_AJAX) {
                     Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : Phpfox::getLib('parse.output')->shorten($aPost['title'], 80, '...')));
                 }
             } else {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread'));
             }
         }
         $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($iId, $aCallback);
         if (!isset($aThread['thread_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread'));
         }
         if ($aThread['is_closed'] && (isset($bCanEditPost) && !$bCanEditPost || !isset($bCanEditPost))) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_closed'));
         }
         if ($aCallback === false && $aThread['forum_is_closed']) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed'));
         }
         if (!$iEditId && $aThread['is_announcement']) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_an_announcement_not_allowed_to_leave_a_reply'));
         }
         if (!$bIsEdit) {
             $bPass = false;
             if (Phpfox::getUserParam('forum.can_reply_to_own_thread') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_reply_on_other_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'can_reply')) {
                 $bPass = true;
             }
             if ($bPass === false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread'));
             }
         }
         $sExtraText = '';
         if ($sSavedText = $this->request()->get('save_text')) {
             $sExtraText .= Phpfox::getLib('parse.output')->clean($sSavedText);
         }
         if (Phpfox::getUserParam('forum.can_multi_quote_forum') && (($iQuote = $this->request()->getInt('quote')) || ($sCookie = Phpfox::getCookie('forum_quote')) && !empty($sCookie))) {
             $sCookie = Phpfox::getCookie('forum_quote');
             if (!empty($sCookie)) {
                 $iQuote = $sCookie . $iQuote;
             }
             $sExtraText .= Phpfox::getService('forum.post')->getQuotes($aThread['thread_id'], $iQuote);
         }
         if (($iQuoteId = $this->request()->getInt('quote')) && ($aQuotePost = Phpfox::getService('forum.post')->getForEdit($iQuoteId))) {
             Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.replying_to_a_post_by_full_name', array('full_name' => Phpfox::getLib('parse.output')->shorten($aQuotePost['full_name'], 80, '...'))));
         }
         $aSubForms = array();
         if (isset($aThread['is_subscribed'])) {
             $aSubForms['is_subscribed'] = $aThread['is_subscribed'];
         }
         if (!empty($sExtraText)) {
             $aSubForms['text'] = $sExtraText;
         }
         if (isset($bCanEditPost) && $bCanEditPost) {
             $aSubForms = array_merge($aSubForms, $aPost);
         }
         $this->template()->assign('aForms', $aSubForms);
         $aValidation = array('text' => Phpfox::getPhrase('forum.provide_some_text'));
         if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) {
             $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
         }
         $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
         $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum();
         if ($aVals = $this->request()->getArray('val')) {
             $aVals['forum_id'] = $aThread['forum_id'];
             if ($oValid->isValid($aVals)) {
                 Phpfox::setCookie('forum_quote', '', -1);
                 if ($bIsEdit) {
                     if (Phpfox::getService('forum.post.process')->update($aPost['post_id'], $aPost['user_id'], $aVals)) {
                         $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $aPost['post_id']));
                     }
                 } else {
                     if (($iFlood = Phpfox::getUserParam('forum.forum_post_flood_control')) !== 0) {
                         $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_post'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                         // actually check if flooding
                         if (Phpfox::getLib('spam')->check($aFlood)) {
                             Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_reply_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                         }
                     }
                     if (Phpfox_Error::isPassed()) {
                         if ($iId = Phpfox::getService('forum.post.process')->add($aVals, $aCallback)) {
                             $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $iId));
                         } else {
                             if (Phpfox::getUserParam('forum.approve_forum_post')) {
                                 $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, Phpfox::getPhrase('forum.your_post_has_successfully_been_added_however_it_is_pending_an_admins_approval_before_it_can_be_displayed_publicly'), array('post' => $iId));
                             }
                         }
                     }
                 }
             }
         }
         if ($aCallback === false) {
             $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->makeUrl('forum', $aForum['name_url'] . '-' . $aForum['forum_id']));
         } else {
         }
         $this->template()->setBreadcrumb($aThread['title'], $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : $aPost['title']) : Phpfox::getPhrase('forum.post_new_reply'), $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', array($aThread['title_url'], 'post' => $aPost['post_id'])) : null, true)->assign(array('iThreadId' => $iId, 'iActualForumId' => $aForum['forum_id'], 'sFormLink' => $aCallback === false ? $this->url()->makeUrl('forum.post.reply', array('id' => $iId)) : $this->url()->makeUrl('forum.post.reply', array('id' => $iId, 'module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(PHPFOX_IS_AJAX ? false : true), 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'sThreadReturnLink' => $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], array('forum', $aThread['title_url'])), 'aPreviews' => Phpfox::getService('forum.post')->getPreview($aThread['thread_id']), 'iTotalPosts' => $aThread['total_post'], 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback, 'iTotalPostPreview' => Phpfox::getParam('forum.total_forum_post_preview')));
         if (Phpfox::getUserParam('forum.can_add_forum_attachments')) {
             $this->setParam('attachment_share', array('type' => 'forum', 'inline' => PHPFOX_IS_AJAX ? true : false, 'id' => 'js_forum_form', 'edit_id' => $bIsEdit ? $aPost['post_id'] : ''));
         }
     }
 }
Exemple #17
0
 public function add($aVals, $bIsUpdate = false, $iUserId = null)
 {
     $oFilter = Phpfox::getLib('parse.input');
     Phpfox::getService('ban')->checkAutomaticBan($aVals['title'] . ' ' . $aVals['text']);
     $aDisallow = array();
     $aCanModify = array();
     $aUserGroups = Phpfox::getService('user.group')->get();
     if (isset($aVals['allow_access']) || isset($aVals['can_modify'])) {
         foreach ($aUserGroups as $aUserGroup) {
             if (isset($aVals['allow_access']) && !in_array($aUserGroup['user_group_id'], $aVals['allow_access'])) {
                 $aDisallow[] = $aUserGroup['user_group_id'];
             }
         }
     } else {
         foreach ($aUserGroups as $aUserGroup) {
             $aDisallow[] = $aUserGroup['user_group_id'];
         }
     }
     // Make sure the phrase is really a phrase
     if (isset($aVals['is_phrase']) && $aVals['is_phrase']) {
         if (!Phpfox_Locale::instance()->isPhrase($aVals['title'])) {
             $aVals['is_phrase'] = 0;
         }
     }
     $aVals['disallow_access'] = count($aDisallow) ? serialize($aDisallow) : null;
     // Fix HTML
     $aVals['text_parsed'] = Phpfox::getLib('parse.input')->fixHtml($aVals['text']);
     // BBCode
     if (isset($aVals['parse_bbcode'])) {
         $oFilterBbcode = Phpfox::getLib('parse.bbcode');
         $aVals['text_parsed'] = $oFilterBbcode->preParse($aVals['text_parsed']);
         $aVals['text_parsed'] = $oFilterBbcode->parse($aVals['text_parsed']);
     }
     // Parse Emoticons
     if (isset($aVals['parse_emoticons']) && Phpfox::isModule('emoticon')) {
         $aVals['text_parsed'] = Phpfox::getService('emoticon')->parse($aVals['text_parsed']);
     }
     // Allowed to use PHP?
     if (!isset($aVals['parse_php'])) {
         $aVals['text_parsed'] = preg_replace("/<\\?[php|=| ](.*?)\\?>/is", "", $aVals['text_parsed']);
         $aVals['parse_php'] = 0;
     } else {
         $aVals['text_parsed'] = preg_replace("/<\\?(php|=| )(.*?)\\?>/is", "{php}\\2{/php}", $aVals['text_parsed']);
     }
     // Add Breaks: <br />
     if (isset($aVals['parse_breaks']) && !isset($aVals['parse_wiki'])) {
         $aVals['text_parsed'] = Phpfox::getLib('parse.input')->addBreak($aVals['text_parsed']);
     }
     $aVals['text_parsed'] = Phpfox::getLib('template.cache')->parse($aVals['text_parsed'], true);
     /*
     p(htmlspecialchars($aVals['text_parsed']));
     exit;		
     */
     $aVals['keyword'] = !empty($aVals['keyword']) ? $oFilter->clean($aVals['keyword']) : null;
     $aVals['description'] = !empty($aVals['description']) ? $oFilter->clean($aVals['description']) : null;
     $aVals['title'] = $oFilter->clean($aVals['title'], 255);
     $aVals['total_tag'] = Phpfox::isModule('tag') && isset($aVals['tag_list']) ? Tag_Service_Tag::instance()->getCount($aVals['tag_list']) : 0;
     $aSql = array('module_id', 'product_id', 'is_active' => 'int', 'is_phrase' => 'int', 'parse_php' => 'int', 'has_bookmark' => 'int', 'add_view' => 'int', 'full_size' => 'int', 'title', 'title_url', 'disallow_access', 'total_attachment' => 'int', 'total_tag' => 'int');
     $aSqlText = array('keyword', 'description', 'text', 'text_parsed');
     if (empty($aVals['module_id'])) {
         $aVals['module_id'] = 'core';
     }
     if ($bIsUpdate) {
         // If we uploaded any attachments make sure we update the 'item_id'
         if (Phpfox::isModule('attachment') && !empty($aVals['attachment'])) {
             Phpfox::getService('attachment.process')->updateItemId($aVals['attachment'], Phpfox::getUserId(), $aVals['page_id']);
         }
         $aVals['total_attachment'] = Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getCountForItem($aVals['page_id'], 'page') : 0;
         $sNewTitle = Phpfox::getLib('parse.input')->cleanTitle($aVals['title_url']);
         if (isset($aVals['old_url']) && $aVals['old_url'] != $sNewTitle) {
             $aVals['title_url'] = Phpfox::getService('page')->prepareTitle($aVals['title_url']);
         }
         $iId = $aVals['page_id'];
         $this->database()->process($aSql, $aVals)->update($this->_sTable, 'page_id = ' . (int) $aVals['page_id']);
         $this->database()->process($aSqlText, $aVals)->update(Phpfox::getT('page_text'), 'page_id = ' . (int) $aVals['page_id']);
         Phpfox::getService('page.log.process')->add($iId, Phpfox::getUserId());
         /*
         if (Phpfox::isModule('tag'))
         {
         	Phpfox::getService('tag.process')->update('page', $iId, $iUserId, (!Phpfox::getLib('parse.format')->isEmpty($aVals['tag_list']) ? $aVals['tag_list'] : null));				
         }
         */
         if (isset($aVals['menu_id']) && $aVals['menu_id'] > 0) {
             $this->database()->update(Phpfox::getT('menu'), array('url_value' => $aVals['title_url']), 'menu_id = ' . (int) $aVals['menu_id']);
             $this->cache()->remove('menu', 'substr');
         }
     } else {
         $aVals['added'] = PHPFOX_TIME;
         $aVals['user_id'] = Phpfox::getUserId();
         $aVals['title_url'] = Phpfox::getService('page')->prepareTitle($aVals['title_url']);
         $aVals['total_attachment'] = Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getCount($aVals['attachment']) : 0;
         $aSql[] = 'user_id';
         $aSql[] = 'added';
         $iId = $this->database()->process($aSql, $aVals)->insert($this->_sTable);
         $aSqlText[] = 'page_id';
         $aVals['page_id'] = $iId;
         $this->database()->process($aSqlText, $aVals)->insert(Phpfox::getT('page_text'));
         if (Phpfox::isModule('tag') && isset($aVals['tag_list']) && !empty($aVals['tag_list'])) {
             Phpfox::getService('tag.process')->add('page', $iId, Phpfox::getUserId(), $aVals['tag_list']);
         }
         // If we uploaded any attachments make sure we update the 'item_id'
         if (Phpfox::isModule('attachment') && !empty($aVals['attachment'])) {
             Phpfox::getService('attachment.process')->updateItemId($aVals['attachment'], Phpfox::getUserId(), $iId);
         }
     }
     $this->cache()->remove('page', 'substr');
     if ($aVals['is_active']) {
         return $aVals['title_url'];
     } else {
         return Phpfox::getLib('url')->makeUrl('admincp.page');
     }
 }