Beispiel #1
0
 public static function getStatusArray() {
     $db = XenForo_Application::get('db');
     $userModel = new Xenforo_Model_User;
     $options = XenForo_Application::get('options');
     $numStatusShown = $options->RCBDRecentStatusNumView;
     $showComments = $options->RCBDRecentStatusShowComments;
     $onePerUser = $options->RCBDRecentStatusOnePerUser;
     $data = XenForo_Application::getSimpleCacheData("RCBDRecentStatus_status_array");
     if (!$data) {
         if ($onePerUser == 1) {
             $statusArray = $db->fetchAll($db->limit("SELECT * FROM (SELECT * FROM xf_profile_post WHERE message_state <> 'deleted' AND profile_user_id = user_id ORDER BY post_date DESC) t1 GROUP BY t1.user_id ORDER BY post_date DESC", $numStatusShown));
             $statusArray = array_sort($statusArray, "post_date");
         } else {
             $statusArray = $db->fetchAll($db->limit("SELECT * FROM  xf_profile_post WHERE profile_user_id = user_id AND message_state <> 'deleted' ORDER BY post_date DESC", $numStatusShown));
         }
         XenForo_Application::setSimpleCacheData("RCBDRecentStatus_status_array", $statusArray);
     } else {
         $statusArray = $data;
     }
     $recentStatus = array();
     $postIds = array();
     if (sizeof($statusArray) == 0) {
         $statusArray = array(0 => array("profile_post_id" => 0, "user_id" => 1, "post_date" => time(), "message" => "No status entries yet, be the first!"));
     }
     foreach ($statusArray as $status) {
         $postIds[] = $status['profile_post_id'];
     }
     $commentsArray = array();
     $commentsSortedArray = array();
     if ($showComments == 1) {
         $matches = implode(',', $postIds);
         $data = XenForo_Application::getSimpleCacheData("RCBDRecentStatus_comments_array");
         if (!$data) {
             $commentsArray = $db->fetchAll($db->limit("SELECT * FROM  xf_profile_post_comment WHERE profile_post_id in(" . $matches . ") ORDER BY profile_post_id DESC, comment_date", $numStatusShown));
             XenForo_Application::setSimpleCacheData("RCBDRecentStatus_comments_array", $commentsArray);
         } else {
             $commentsArray = $data;
         }
         $commentsUserObjs = getUserData($commentsArray);
         $currentPostId = -99;
         $commentGroup = array();
         foreach ($commentsArray as $status) {
             if ($currentPostId != $status['profile_post_id']) {
                 if ($currentPostId != -99) {
                     $commentsSortedArray[$currentPostId] = $commentGroup;
                     $commentGroup = array();
                 }
                 $currentPostId = $status['profile_post_id'];
             }
             $commentGroup[] = array("user" => $commentsUserObjs[$status['user_id']], "status" => $status['message'], "time" => $status['comment_date'], "post_id" => $status['profile_post_id']);
         }
         $commentsSortedArray[$currentPostId] = $commentGroup;
     }
     $statusUserObjs = getUserData($statusArray);
     foreach ($statusArray as $status) {
         $recentStatus[] = array("user" => $statusUserObjs[$status['user_id']], "status" => $status['message'], "time" => $status['post_date'], "post_id" => $status['profile_post_id']);
     }
     $returnArrays = array("status" => $recentStatus, "comments" => $commentsSortedArray);
     return $returnArrays;
 }
Beispiel #2
0
 public function _bakeProtectedTags()
 {
     $bbmCached = XenForo_Application::getSimpleCacheData('bbm_active');
     $visitor = XenForo_Visitor::getInstance();
     if (!is_array($bbmCached) || !isset($bbmCached['protected']) || !is_array($bbmCached['protected']) || empty($bbmCached['protected'])) {
         return false;
     }
     $allProtectedTags = array();
     $protectedTags = $bbmCached['protected'];
     if ($this->_checkVisitorPerms == true) {
         $visitorUserGroupIds = array_merge(array((string) $visitor['user_group_id']), explode(',', $visitor['secondary_group_ids']));
     }
     foreach ($protectedTags as $tag => $perms) {
         if ($this->_checkVisitorPerms == true && array_intersect($visitorUserGroupIds, $perms)) {
             continue;
         }
         $allProtectedTags[$tag] = array('callback' => $this->_generalTagCallback);
     }
     /*XenForo protected tags check*/
     $xenProtectedTags = array('attach', 'email', 'img', 'media', 'url');
     foreach ($xenProtectedTags as $tagName) {
         $permKey = "bbm_hide_{$tagName}";
         if ($visitor->hasPermission('bbm_bbcodes_grp', $permKey)) {
             $allProtectedTags[$tagName] = array('callback' => $this->_generalTagCallback);
         }
     }
     $this->_protectedTags = $allProtectedTags;
 }
 /**
  *
  * @param array $matches
  * @return string
  */
 public static function removeCopyrightNotice(array $matches)
 {
     $copyrightModification = XenForo_Application::getSimpleCacheData(parent::COPYRIGHT_MODIFICATION_SIMPLE_CACHE_KEY);
     if ($copyrightModification < XenForo_Application::$time) {
         XenForo_Application::setSimpleCacheData(parent::COPYRIGHT_MODIFICATION_SIMPLE_CACHE_KEY, XenForo_Application::$time);
     }
     return $matches[0];
 }
Beispiel #4
0
 public static function getChildNodes()
 {
     $childNodes = XenForo_Application::getSimpleCacheData(self::SIMPLE_CACHE_CHILD_NODES);
     if ($childNodes === false) {
         return self::rebuildChildNodesCache();
     }
     return $childNodes;
 }
Beispiel #5
0
 protected function _getFromCache()
 {
     list($cachedValue, $time) = XenForo_Application::getSimpleCacheData(self::CACHE_KEY);
     if (!$cachedValue) {
         return array(0, 0);
     } else {
         return array($cachedValue, $time);
     }
 }
Beispiel #6
0
 public function getAllCachedCollections()
 {
     $collections = XenForo_Application::getSimpleCacheData(self::$allCacheKey);
     if (!$collections) {
         $collections = $this->getCollections();
         XenForo_Application::setSimpleCacheData(self::$allCacheKey, $collections);
     }
     return $collections;
 }
Beispiel #7
0
 public function getModule()
 {
     $boardTotals = $this->getModelFromCache('XenForo_Model_DataRegistry')->get('boardTotals');
     if (!$boardTotals) {
         $boardTotals = $this->getModelFromCache('XenForo_Model_Counters')->rebuildBoardTotalsCounter();
     }
     $boardTotals['most_users'] = XenForo_Application::getSimpleCacheData('EWRporta_MostUsers');
     return $boardTotals;
 }
Beispiel #8
0
 public function getAllCachedFields()
 {
     $fields = XenForo_Application::getSimpleCacheData(self::$allCacheKey);
     if (!$fields) {
         $fields = $this->getFields();
         XenForo_Application::setSimpleCacheData(self::$allCacheKey, $fields);
     }
     return $fields;
 }
 public function rebuildUserBannerGroupCache()
 {
     $userBannerGroups = $this->getUserBannerGroups();
     if ($userBannerGroups) {
         XenForo_Application::setSimpleCacheData('th_userBannerGroups', $userBannerGroups);
     } elseif (XenForo_Application::getSimpleCacheData('th_userBannerGroups')) {
         XenForo_Application::setSimpleCacheData('th_userBannerGroups', false);
     }
     return $userBannerGroups;
 }
Beispiel #10
0
 public function getAllCachedCategories()
 {
     $categories = XenForo_Application::getSimpleCacheData(self::$allCacheKey);
     if (!$categories) {
         $categories = $this->getCategories(array(), array('order' => 'lft'));
         XenForo_Application::setSimpleCacheData(self::$allCacheKey, $categories);
     }
     $categories = $this->prepareCategories($categories);
     return $categories;
 }
Beispiel #11
0
 public function getGroupsCached()
 {
     if (!$this->_groupCached) {
         $this->_groupCached = XenForo_Application::getSimpleCacheData(TEAM_DATAREGISTRY_KEY);
         if (!$this->_groupCached) {
             $this->_groupCached = $this->saveGroupPermDataCache();
         }
     }
     return $this->_groupCached;
 }
Beispiel #12
0
 public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     $options = XenForo_Application::get('options');
     $enableadvxenforo = $options->enableadvxenforo;
     $thread_id = $hookParams['thread']['thread_id'];
     if ($enableadvxenforo) {
         $PermissionEnable = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_enable_adv') ? TRUE : FALSE;
         if ($hookName == 'account_preferences_options' && $PermissionEnable) {
             $ourTemplate = $template->create('adv_xenforo_account_options', $template->getparams());
             $rendered = $ourTemplate->render();
             $contents = $contents . $rendered;
         }
         $hasPermission = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_show') ? TRUE : FALSE;
         $advs = XenForo_Application::getSimpleCacheData('adv_xenforo');
         $user = XenForo_Visitor::getInstance()->toArray();
         $enable_adv = $PermissionEnable === TRUE ? $user['enable_adv'] : TRUE;
         $containerData = self::$containerData;
         if (empty(self::$containerData)) {
             $containerData = XenForo_Template_Public::getExtraContainerData();
         }
         if ($enable_adv) {
             if ($hasPermission === TRUE && $advs["AdvsHook"]) {
                 $isMobile = XenForo_Visitor::isBrowsingWith('mobile');
                 switch (TRUE) {
                     case $isMobile == TRUE:
                         $adv_adv = 'adv_small';
                         break;
                     default:
                         $adv_adv = 'adv_large';
                         break;
                 }
                 foreach ($advs["AdvsHook"] as $_asv) {
                     if ($_asv['active'] && XenForo_Helper_Criteria::userMatchesCriteria($_asv['user_criteria'], TRUE, $user) && XenForo_Helper_Criteria::pageMatchesCriteria($_asv['page_criteria'], TRUE, $template->getParams(), $containerData)) {
                         $ourTemplate = $template->create('ads_xf_ar_xenforo', array('advanced' => $_asv[$adv_adv]));
                         $rendered = $ourTemplate->render();
                         if ($hookName == 'message_content' && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE) === FALSE) {
                             if ($hookParams['message']['thread_id']) {
                                 $decode = XenForo_Helper_Criteria::prepareCriteriaForSelection($_asv['post_criteria']);
                                 $position = $decode['active']['page'] ? $hookParams['message']['position'] % $options->messagesPerPage : $hookParams['message']['position'];
                                 if ($position == $decode['active']['post_id'] - 1) {
                                     $contents = $decode['active']['position'] ? Turki_Adv_Helper_Helpers::advhtml($contents, $rendered) : $contents . $rendered;
                                 }
                             }
                         } else {
                             if ($hookName == $_asv['adv_hook_name'] && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE)) {
                                 $contents = $_asv['display'] == 'top' ? $rendered . $contents : $contents . $rendered;
                             }
                         }
                     }
                 }
             }
         }
         self::_templateHook($hookName, $contents, $hookParams, $template);
     }
 }
Beispiel #13
0
 public function getAllNodes()
 {
     if ($this->_nodes === null) {
         $nodes = XenForo_Application::getSimpleCacheData(self::$nodesCacheKey);
         if ($nodes === false) {
             $nodes = $this->_getNodeModel()->getAllNodes();
             XenForo_Application::setSimpleCacheData(self::$nodesCacheKey, $nodes);
         }
         $this->_nodes = $nodes;
     }
     return $this->_nodes;
 }
Beispiel #14
0
 public function actionBbCodes()
 {
     $parent = parent::actionBbCodes();
     $bbmBbCodes = $this->getModelFromCache('BBM_Model_BbCodes')->getAllActiveBbCodes('strict');
     $bbmBbCodesInCache = XenForo_Application::getSimpleCacheData('bbm_active');
     if (!empty($bbmBbCodesInCache['nohelp'])) {
         foreach ($bbmBbCodesInCache['nohelp'] as $tag) {
             unset($bbmBbCodes[$tag]);
         }
     }
     $parent->subView->params['bbmBbCodes'] = $bbmBbCodes;
     return $parent;
 }
Beispiel #15
0
 public function _bakeAllTags($parentTags)
 {
     $bbmCache = XenForo_Application::getSimpleCacheData('bbm_active');
     $bbmTags = $bbmCache['list'];
     $allTags = $parentTags;
     foreach ($bbmTags as $bbmTag) {
         $allTags[$bbmTag] = array();
     }
     foreach ($allTags as &$tag) {
         foreach ($tag as $key => $config) {
             unset($tag[$key]);
         }
         $tag['replace'] = array('', '');
     }
     $this->_allTags = $allTags;
 }
Beispiel #16
0
 public function getShortUrlLengthHttps($token)
 {
     $data = XenForo_Application::getSimpleCacheData(self::SIMPLE_CACHE_DATA_KEY_SHORT_URL_LENGTH_HTTPS);
     if (empty($data) or XenForo_Application::$time - $data['timestamp'] > 86400) {
         $response = bdSocialShare_Helper_Twitter::helpConfiguration($token['oauth_token'], $token['oauth_token_secret']);
         if (!empty($response['short_url_length_https'])) {
             $data = array('value' => $response['short_url_length_https'], 'timestamp' => time());
             XenForo_Application::setSimpleCacheData(self::SIMPLE_CACHE_DATA_KEY_SHORT_URL_LENGTH_HTTPS, $data);
         } else {
             // for some reason we cannot get configuration from Twitter,
             // return our best guess then: as of September 13, 2014 it is 23
             return 30;
         }
     }
     return $data['value'];
 }
Beispiel #17
0
 public function getBypass($params)
 {
     $visitor = XenForo_Visitor::getInstance();
     $sessionModel = $this->getModelFromCache('XenForo_Model_Session');
     $onlineUsers = $sessionModel->getSessionActivityQuickList($visitor->toArray(), array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())), $visitor['user_id'] ? $visitor->toArray() : null);
     $onlineUsers['most_users'] = XenForo_Application::getSimpleCacheData('EWRporta_MostUsers');
     if (empty($onlineUsers['most_users']) || $onlineUsers['total'] > $onlineUsers['most_users']['total']) {
         $onlineUsers['most_users'] = array('total' => $onlineUsers['total'], 'time' => XenForo_Application::$time);
         XenForo_Application::setSimpleCacheData('EWRporta_MostUsers', $onlineUsers['most_users']);
     }
     if (!$params['option']['staff']) {
         foreach ($onlineUsers['records'] as &$user) {
             $user['is_staff'] = false;
         }
     }
     return $onlineUsers;
 }
Beispiel #18
0
 public static function getInstances()
 {
     if (!self::$_instance) {
         /* @var $self sonnbUpThread_Model_Up*/
         $self = self::create('sonnbUpThread_Model_Up');
         if (!$self->_nodes) {
             $nodes = XenForo_Application::getSimpleCacheData($self->_nodesCacheKey);
             if ($nodes === false) {
                 $nodes = $self->_getNodeModel()->getAllNodes();
                 XenForo_Application::setSimpleCacheData($self->_nodesCacheKey, $nodes);
             }
             $self->_nodes = $nodes;
         }
         self::$_instance = $self;
     }
     return self::$_instance;
 }
Beispiel #19
0
 public function getGlobalWidgets($useCached = true, $prepare = true)
 {
     $widgets = false;
     /* try to use cached data */
     if ($useCached) {
         $widgets = XenForo_Application::getSimpleCacheData(self::SIMPLE_CACHE_KEY);
     }
     /* fallback to database */
     if ($widgets === false) {
         $widgets = $this->fetchAllKeyed("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM `xf_widget`\n\t\t\t\t\tWHERE `widget_page_id` = 0\n\t\t\t\t\tORDER BY display_order ASC\n\t\t\t\t\t", 'widget_id');
     }
     foreach ($widgets as &$widget) {
         $this->_prepareWidgetMandatory($widget);
         if ($prepare) {
             $this->prepareWidget($widget);
         }
     }
     return $widgets;
 }
Beispiel #20
0
 /**
  * Returns all widgets from widget portal table.
  * @param bool $useCached
  * @param bool $prepare
  * @return array|bool|false|mixed
  */
 public function getAllWidgets($useCached = true, $prepare = true)
 {
     $widgets = false;
     /* try to use cached data */
     if ($useCached) {
         $widgets = XenForo_Application::getSimpleCacheData(self::SIMPLE_CACHE_KEY);
     }
     /* fallback to database */
     if ($widgets === false) {
         $portalModel = $this->_getPortalModel();
         $pos = $this->_getDb()->quote($portalModel->getPortalWidgetPositions());
         $widgets = $this->fetchAllKeyed("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `xf_widget`\n\t\t\t\tWHERE position IN (" . $pos . ")\n\t\t\t\tORDER BY display_order ASC\n\t\t\t", 'widget_id');
     }
     /* prepare information for widgets */
     if ($prepare) {
         foreach ($widgets as &$widget) {
             $this->_prepare($widget);
         }
     }
     return $widgets;
 }
 public static function getMediaForBlock($content, $params, XenForo_Template_Abstract $template)
 {
     /* @var $mediaModel XenGallery_Model_Media */
     $mediaModel = XenForo_Model::create('XenGallery_Model_Media');
     $visitor = XenForo_Visitor::getInstance();
     $conditions = array('viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()));
     if ($params['categories']) {
         $conditions['category_id'] = explode(',', $params['categories']);
     } else {
         $conditions['category_id'] = 'nocategories';
     }
     if ($params['categories'] == 'all') {
         $conditions['category_id'] = $params['categories'];
     }
     $fetchOptions = array('join' => XenGallery_Model_Media::FETCH_USER | XenGallery_Model_Media::FETCH_CATEGORY | XenGallery_Model_Media::FETCH_ALBUM | XenGallery_Model_Media::FETCH_ATTACHMENT, 'order' => $params['type'], 'orderDirection' => 'desc', 'limit' => $params['limit']);
     if ($params['type'] == 'rand') {
         $mediaIds = XenForo_Application::getSimpleCacheData('xengalleryRandomMediaCache');
         if (!$mediaIds) {
             return '';
             // No random media cache, do not proceed.
         }
         shuffle($mediaIds);
         $mediaIds = array_slice($mediaIds, 0, $params['limit'] * 4);
         $conditions['media_id'] = $mediaIds;
         unset($fetchOptions['limit'], $fetchOptions['order']);
     }
     if ($params['albums']) {
         $conditions = $conditions + array('privacyUserId' => $visitor->user_id, 'mediaBlock' => true);
         $fetchOptions['join'] |= XenGallery_Model_Media::FETCH_PRIVACY;
     } else {
         $conditions['album_id'] = 'noalbums';
     }
     $media = $mediaModel->getMedia($conditions, $fetchOptions);
     if ($params['type'] == 'rand') {
         shuffle($media);
         $media = array_slice($media, 0, $params['limit']);
     }
     $viewParams = array('media' => $mediaModel->prepareMediaItems($media), 'captions' => !empty($params['captions']) ? true : false);
     return $template->create('xengallery_media_block_items', $viewParams);
 }
Beispiel #22
0
 public function getModule()
 {
     if (!($addon = $this->getModelFromCache('XenForo_Model_AddOn')->getAddOnById('EWRhabla')) || empty($addon['active'])) {
         return "killModule";
     }
     $options = XenForo_Application::get('options');
     $server = $options->EWRhabla_server;
     $channel = $options->EWRhabla_channel;
     $chatUsers = array('total' => 0);
     if (!($chatUsers['rooms'] = $this->getModelFromCache('EWRhabla_Model_Chat')->fetchUsers($server, $channel))) {
         return array('rooms' => array());
     }
     foreach ($chatUsers['rooms'] as $room) {
         $chatUsers['total'] += $room['count'];
     }
     $chatUsers['most_users'] = XenForo_Application::getSimpleCacheData('EWRporta_ChatUsers');
     if (empty($chatUsers['most_users']) || $chatUsers['total'] > $chatUsers['most_users']['total']) {
         $chatUsers['most_users'] = array('total' => $chatUsers['total'], 'time' => XenForo_Application::$time);
         XenForo_Application::setSimpleCacheData('EWRporta_ChatUsers', $chatUsers['most_users']);
     }
     return $chatUsers;
 }
 public function run()
 {
     if (self::$checkRedirectRules == $this->_templateName) {
         $redirectRules = XenForo_Application::getSimpleCacheData('th_redirectRules');
         $user = XenForo_Visitor::getInstance()->toArray();
         $template = $this->_template;
         $containerData = $this->_containerData;
         if ($redirectRules) {
             foreach ($redirectRules as $redirectRule) {
                 if (XenForo_Helper_Criteria::userMatchesCriteria($redirectRule['user_criteria'], true, $user) && XenForo_Helper_Criteria::pageMatchesCriteria($redirectRule['page_criteria'], true, $template->getParams(), $containerData)) {
                     $url = $this->_getRedirectUrl($redirectRule['reroute_domain']);
                     if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) !== FALSE) {
                         header("HTTP/1.1 301 Moved Permanently");
                         header('Location : ' . $url);
                         exit;
                     }
                 }
             }
         }
     }
     return parent::run();
 }
Beispiel #24
0
 protected function _preInstall()
 {
     $addOn = $this->getModelFromCache('XenForo_Model_AddOn')->getAddOnById('ThemeHouse_Warnings');
     if ($addOn && $addOn['version_id'] <= '1378250672') {
         throw new XenForo_Exception('Unable to upgrade from this version. Upgrade to 1.0.3 first.');
     }
     if (XenForo_Application::$versionId >= 1030000) {
         $this->_db->query('
             UPDATE xf_warning_action
 			SET action = \'groups\'
 			WHERE action = \'groups_length\'
         ');
         if ($this->_isTableExists('xf_warning_user_group')) {
             $this->_db->query('
                     INSERT INTO xf_user_change_temp
                     (user_id, action_type, action_modifier, new_value, old_value, create_date, expiry_date)
                     SELECT user_id, \'groups\', CONCAT(\'warning_action_\', warning_action_id),
                     extra_user_group_ids, \'N;\', warning_action_date, end_date
                     FROM xf_warning_user_group
                 ');
             $this->_db->query('
                     DELETE FROM xf_user_group_change
                     WHERE change_key IN (
                         SELECT CONCAT(\'warningUserGroup\', warning_user_group_id)
                         FROM xf_warning_user_group
                     )
                 ');
             $this->_db->query('
                     DROP TABLE xf_warning_user_group
                 ');
         }
     }
     if (XenForo_Application::$versionId != XenForo_Application::getSimpleCacheData('th_warnings_xfVersionId')) {
         XenForo_Application::setSimpleCacheData('th_warnings_xfVersionId', XenForo_Application::$versionId);
     }
 }
Beispiel #25
0
 protected function _updateJustUninstalled()
 {
     if (isset($this->_data['addon_id'])) {
         if (XenForo_Application::$versionId < 1020000 && defined('Waindigo_Listener_InitDependencies::JUST_UNINSTALLED_SIMPLE_CACHE_KEY')) {
             $justUninstalled = XenForo_Application::getSimpleCacheData(Waindigo_Listener_InitDependencies::JUST_UNINSTALLED_SIMPLE_CACHE_KEY);
             if (!$justUninstalled) {
                 $justUninstalled = array();
             }
             if (!in_array($this->_data['addon_id'], $justUninstalled)) {
                 $justUninstalled[] = $this->_data['addon_id'];
             }
             XenForo_Application::setSimpleCacheData(Waindigo_Listener_InitDependencies::JUST_UNINSTALLED_SIMPLE_CACHE_KEY, $justUninstalled);
         } elseif (XenForo_Application::$versionId >= 1020000) {
             XenForo_Application::defer('Waindigo_Deferred', array_merge($this->_data, array('uninstall' => true)));
         }
     }
 }
Beispiel #26
0
 /**
  * Helper to get the user banner for the specified user.
  *
  * @param array $user
  * @param boolean $allowCustomTitle Allows the user title to come from the
  * custom title
  * @param boolean $disableStacking If true, stacking is always disabled
  * (highest priority title used)
  *
  * @return string
  */
 public static function helperUserBanner($user, $extraClass = '', $disableStacking = false)
 {
     $opt = XenForo_Application::getOptions()->userBanners;
     if (!$opt['displayMultiple'] || $disableStacking) {
         return XenForo_Template_Helper_Core::callHelper('th_userbanner_userbannergroups', array($user, $extraClass, $disableStacking));
     }
     if (!is_array($user) || !array_key_exists('user_group_id', $user) || !array_key_exists('secondary_group_ids', $user)) {
         return '';
     }
     if (empty($user['user_id'])) {
         $user['user_group_id'] = XenForo_Model_User::$defaultGuestGroupId;
         $user['secondary_group_ids'] = '';
     }
     $banners = array();
     $opt = XenForo_Application::getOptions()->userBanners;
     $memberGroupIds = array($user['user_group_id']);
     if (!empty($user['secondary_group_ids'])) {
         $memberGroupIds = array_merge($memberGroupIds, explode(',', $user['secondary_group_ids']));
     }
     $userBannerGroups = XenForo_Application::getSimpleCacheData('th_userBannerGroups');
     $bannerGroups = array();
     foreach (self::$_userBanners as $groupId => $banner) {
         if (!in_array($groupId, $memberGroupIds)) {
             continue;
         }
         $bannerGroupId = $banner['user_banner_group_id'];
         if ($bannerGroupId && !isset($userBannerGroups[$bannerGroupId])) {
             continue;
         }
         $bannerText = '<em class="' . $banner['class'] . ' ' . $extraClass . ' ' . $userBannerGroups[$bannerGroupId]['banner_css_class'] . '" itemprop="title"><span class="before"></span><strong>' . $banner['text'] . '</strong><span class="after"></span></em>';
         if (!$bannerGroupId || !$userBannerGroups[$bannerGroupId]['display_style_priority']) {
             if (!$bannerGroupId || $userBannerGroups[$bannerGroupId]['display_multiple'] || empty($userBannerGroups[$bannerGroupId]['banners'])) {
                 $banners[$groupId] = $bannerText;
             }
         }
         $userBannerGroups[$bannerGroupId]['banners'][] = $bannerText;
     }
     foreach ($userBannerGroups as $userBannerGroupId => $userBannerGroup) {
         if (!$userBannerGroup['display_style_priority']) {
             continue;
         }
         if (empty($userBannerGroup['banners'])) {
             continue;
         }
         if ($userBannerGroup['display_multiple']) {
             $bannerGroups[$userBannerGroupId] = implode("\n", $userBannerGroup['banners']);
         } else {
             $bannerGroups[$userBannerGroupId] = reset($userBannerGroup['banners']);
         }
     }
     if ($bannerGroups) {
         $banners = array('groups' => implode("\n", $bannerGroups)) + $banners;
     }
     if (!empty($user['is_staff']) && !empty($opt['showStaff'])) {
         $p = new XenForo_Phrase('staff_member');
         $banners = array('staff' => '<em class="userBanner bannerStaff ' . $extraClass . '" itemprop="title"><span class="before"></span><strong>' . $p . '</strong><span class="after"></span></em>') + $banners;
     }
     if (!$banners) {
         return '';
     }
     if ($opt['displayMultiple'] && !$disableStacking) {
         return implode("\n", $banners);
     } else {
         if ($opt['showStaffAndOther'] && isset($banners['staff']) && count($banners) >= 2) {
             $staffBanner = $banners['staff'];
             unset($banners['staff']);
             return $staffBanner . "\n" . reset($banners);
         } else {
             return reset($banners);
         }
     }
 }
Beispiel #27
0
 protected function _getLastXmlUploadDate()
 {
     return XenForo_Application::getSimpleCacheData(self::LAST_XML_UPLOAD_DATE_SIMPLE_CACHE_KEY);
 }
Beispiel #28
0
 public static function getResourcePrefixCache()
 {
     $prefixes = XenForo_Application::getSimpleCacheData('resourcePrefixes');
     return $prefixes ? $prefixes : array();
 }
 /**
  * Fetch the list of dismissed notices into the session if it's not already there
  */
 protected function _updateDismissedNoticeSessionCache()
 {
     if (!XenForo_Application::get('options')->enableNotices) {
         return;
     }
     if (!XenForo_Application::isRegistered('session')) {
         return;
     }
     if (!($userId = XenForo_Visitor::getUserId())) {
         return;
     }
     $session = XenForo_Application::getSession();
     $lastNoticeReset = intval(XenForo_Application::getSimpleCacheData('lastNoticeReset'));
     $sessionLastReset = 0;
     if ($session->isRegistered('lastNoticeReset')) {
         $sessionLastReset = $session->get('lastNoticeReset');
     }
     if (!$session->isRegistered('dismissedNotices') || $lastNoticeReset > $sessionLastReset) {
         try {
             $notices = $this->getModelFromCache('XenForo_Model_Notice')->getDismissedNoticeIdsForUser($userId);
         } catch (Exception $e) {
             $notices = array();
         }
         $session->set('dismissedNotices', $notices);
         $session->set('lastNoticeReset', $lastNoticeReset);
     }
 }
 protected function _getInvalidatedCacheInfo()
 {
     return XenForo_Application::getSimpleCacheData(self::INVALIDED_CACHE_ITEM_NAME);
 }