/**
  * Modern profile
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _viewModern()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['id']) ? intval($this->request['id']) : intval($this->request['MID']);
     $member_id = $member_id ? $member_id : $this->memberData['member_id'];
     $tab = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($this->request['tab']))), 0, 20);
     $firsttab = '';
     $member = array();
     $comments = array();
     $comments_html = "";
     $friends = array();
     $visitors = array();
     $comment_perpage = 5;
     $pips = 0;
     $tabs = array();
     $_tabs = array();
     $_positions = array(0 => 0);
     $custom_path = IPSLib::getAppDir('members') . '/sources/tabs';
     $_member_ids = array();
     $sql_extra = '';
     $pass = 0;
     $mod = 0;
     $_todays_date = getdate();
     $time_adjust = $this->settings['time_adjust'] == "" ? 0 : $this->settings['time_adjust'];
     $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies'];
     //-----------------------------------------
     // Check input..
     //-----------------------------------------
     if (!$member_id) {
         $this->registry->output->silentRedirect($this->settings['base_url']);
     }
     //-----------------------------------------
     // Configure tabs
     //-----------------------------------------
     if (is_dir($custom_path)) {
         foreach (new DirectoryIterator($custom_path) as $f) {
             if (!$f->isDot() && !$f->isDir()) {
                 $file = $f->getFileName();
                 if ($file[0] == '.') {
                     continue;
                 }
                 if (preg_match("#\\.conf\\.php\$#i", $file)) {
                     $classname = str_replace(".conf.php", "", $file);
                     require $custom_path . '/' . $file;
                     //-------------------------------
                     // Allowed to use?
                     //-------------------------------
                     if ($CONFIG['plugin_enabled']) {
                         if (in_array($this->settings['search_method'], array('traditional', 'sphinx')) && $CONFIG['plugin_key'] == 'recentActivity') {
                             continue;
                         }
                         $_position = in_array($CONFIG['plugin_order'], $_positions) ? count($_positions) + 1 : $CONFIG['plugin_order'];
                         $_tabs[$_position] = $CONFIG;
                         $_positions[$_position] = $_position;
                     }
                 }
             }
         }
     }
     ksort($_tabs);
     foreach ($_tabs as $_pos => $data) {
         if (!$firsttab) {
             $firsttab = $data['plugin_key'];
         }
         $data['_lang'] = isset($this->lang->words[$data['plugin_lang_bit']]) ? $this->lang->words[$data['plugin_lang_bit']] : $data['plugin_name'];
         $tabs[$data['plugin_key']] = $data;
     }
     if ($tab != 'comments' and $tab != 'settings' and !file_exists($custom_path . '/' . $tab . '.php')) {
         $tab = $firsttab;
     }
     //-----------------------------------------
     // Grab all data...
     //-----------------------------------------
     $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups', 'id');
     if (!$member['member_id']) {
         $this->registry->output->showError('profiles_no_member', 10246);
     }
     /* Check USER permalink... */
     $this->registry->getClass('output')->checkPermalink($member['members_seo_name'] ? $member['members_seo_name'] : IPSText::makeSeoTitle($member['members_display_name']));
     /* Build data */
     $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile', 'checkFormat' => 1, 'cfGetGroupData' => 1, 'signature' => 1));
     //-----------------------------------------
     // Recent visitor?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id']) {
         list($be_anon, $loggedin) = explode('&', $this->memberData['login_anonymous']);
         if (!$be_anon) {
             $this->_addRecentVisitor($member, $this->memberData['member_id']);
         }
     }
     //-----------------------------------------
     // DST?
     //-----------------------------------------
     if ($member['dst_in_use'] == 1) {
         $member['time_offset'] += 1;
     }
     //-----------------------------------------
     // Format extra user data
     //-----------------------------------------
     $member['_age'] = $member['bday_year'] ? date('Y') - $member['bday_year'] : 0;
     if ($member['bday_month'] > date('n')) {
         $member['_age'] -= 1;
     } else {
         if ($member['bday_month'] == date('n')) {
             if ($member['bday_day'] > date('j')) {
                 $member['_age'] -= 1;
             }
         }
     }
     $member['_local_time'] = $member['time_offset'] != "" ? gmstrftime($this->settings['clock_long'], time() + $member['time_offset'] * 3600 + $time_adjust * 60) : '';
     $member['g_title'] = IPSLib::makeNameFormatted($member['g_title'], $member['g_id'], $member['prefix'], $member['suffix']);
     $member['_posts_day'] = 0;
     $member['_total_pct'] = 0;
     $member['_bday_month'] = $member['bday_month'] ? $this->lang->words['M_' . $member['bday_month']] : 0;
     //-----------------------------------------
     // BIO
     //-----------------------------------------
     $member['pp_bio_content'] = IPSText::getTextClass('bbcode')->stripBadWords($member['pp_bio_content']);
     $member['pp_bio_content'] = IPSText::wordwrap($member['pp_bio_content'], '25', ' ');
     if (!$this->settings['disable_profile_stats']) {
         $posts = $this->DB->buildAndFetch(array('select' => "COUNT(*) as total_posts", 'from' => "posts", 'where' => "author_id=" . $member['member_id']));
         $member['posts'] = $posts['total_posts'];
         //-----------------------------------------
         // Total posts
         //-----------------------------------------
         if ($member['posts'] and $board_posts) {
             $member['_posts_day'] = round($member['posts'] / ((time() - $member['joined']) / 86400), 2);
             # Fix the issue when there is less than one day
             $member['_posts_day'] = $member['_posts_day'] > $member['posts'] ? $member['posts'] : $member['_posts_day'];
             $member['_total_pct'] = sprintf('%.2f', $member['posts'] / $board_posts * 100);
         }
         $member['_posts_day'] = floatval($member['_posts_day']);
         //-----------------------------------------
         // Most active in
         //-----------------------------------------
         $favorite = $this->DB->buildAndFetch(array('select' => 'COUNT(p.author_id) as f_posts', 'from' => array('posts' => 'p'), 'where' => 'p.author_id=' . $member['member_id'] . ' AND ' . $this->registry->permissions->buildPermQuery('i'), 'order' => 'f_posts DESC', 'group' => 't.forum_id', 'add_join' => array(array('select' => 't.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id'), array('from' => array('permission_index' => 'i'), 'where' => "i.perm_type='forum' AND i.perm_type_id=t.forum_id"))));
         $member['favorite_id'] = $favorite['forum_id'];
         $member['_fav_posts'] = $favorite['f_posts'];
         if ($member['posts']) {
             $member['_fav_percent'] = round($favorite['f_posts'] / $member['posts'] * 100);
         }
     }
     //-----------------------------------------
     // Comments
     //-----------------------------------------
     if ($member['pp_setting_count_comments']) {
         require_once IPSLib::getAppDir('members') . '/sources/comments.php';
         $comment_lib = new profileCommentsLib($this->registry);
         $comment_html = $comment_lib->buildComments($member);
     }
     //-----------------------------------------
     // Visitors
     //-----------------------------------------
     if ($member['pp_setting_count_visitors']) {
         $_pp_last_visitors = unserialize($member['pp_last_visitors']);
         $_visitor_info = array();
         $_count = 1;
         if (is_array($_pp_last_visitors)) {
             krsort($_pp_last_visitors);
             $_members = IPSMember::load(array_values($_pp_last_visitors), 'extendedProfile');
             foreach ($_members as $_id => $_member) {
                 $_visitor_info[$_id] = IPSMember::buildDisplayData($_member, 0);
             }
             foreach ($_pp_last_visitors as $_time => $_id) {
                 if ($_count > $member['pp_setting_count_visitors']) {
                     break;
                 }
                 $_count++;
                 if (!$_visitor_info[$_id]['members_display_name_short']) {
                     $_visitor_info[$_id] = IPSMember::setUpGuest();
                 }
                 $_visitor_info[$_id]['_visited_date'] = ipsRegistry::getClass('class_localization')->getDate($_time, 'TINY');
                 $_visitor_info[$_id]['members_display_name_short'] = $_visitor_info[$_id]['members_display_name_short'] ? $_visitor_info[$_id]['members_display_name_short'] : $this->lang->words['global_guestname'];
                 $visitors[] = $_visitor_info[$_id];
             }
         }
     }
     //-----------------------------------------
     // Friends
     //-----------------------------------------
     # Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
     # also fall back on last 10 if no cache
     if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
         $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
         if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
             foreach ($member['_cache']['friends'] as $id => $approved) {
                 $id = intval($id);
                 if ($approved and $id) {
                     $_member_ids[] = $id;
                 }
             }
             $member['_total_approved_friends'] = count($_member_ids);
             if (is_array($_member_ids) and count($_member_ids)) {
                 $_max = count($_member_ids) > 50 ? 50 : count($_member_ids);
                 $_rand = array_rand($_member_ids, $_max);
                 $_final = array();
                 # If viewing member is in list, let's show em
                 if (in_array($this->memberData['member_id'], $_member_ids)) {
                     $_final[] = $this->memberData['member_id'];
                     $new_mids = array();
                     foreach ($_member_ids as $mid) {
                         if ($mid == $this->memberData['member_id']) {
                             continue;
                         }
                         $new_mids[] = $mid;
                     }
                     $_member_ids = $new_mids;
                     unset($new_mids);
                     if (is_array($_rand)) {
                         if (count($_rand) >= 50) {
                             array_pop($_rand);
                         }
                     }
                 }
                 if (is_array($_rand) and count($_rand)) {
                     foreach ($_rand as $_id) {
                         $_final[] = $_member_ids[$_id];
                     }
                 }
                 if (count($_final)) {
                     $sql_extra = ' AND pf.friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')';
                 }
             }
         }
         $this->DB->build(array('select' => 'pf.*', 'from' => array('profile_friends' => 'pf'), 'where' => 'pf.friends_member_id=' . $member_id . ' AND pf.friends_approved=1' . $sql_extra, 'limit' => array(0, 50), 'order' => 'm.members_display_name ASC', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pf.friends_friend_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
         $outer = $this->DB->execute();
         while ($row = $this->DB->fetch($outer)) {
             $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT');
             $row['_location'] = $row['location'] ? $row['location'] : $this->lang->words['no_info'];
             $row = IPSMember::buildProfilePhoto($row);
             $row['members_display_name_short'] = IPSText::truncate($row['members_display_name'], 13);
             $friends[] = $row;
         }
     }
     $member['_total_displayed_friends'] = count($friends);
     //-----------------------------------------
     // Online location
     //-----------------------------------------
     $member = IPSMember::getLocation($member);
     //-----------------------------------------
     // Add profile view
     //-----------------------------------------
     $this->DB->insert('profile_portal_views', array('views_member_id' => $member['member_id']), true);
     //-----------------------------------------
     // Grab default tab...
     //-----------------------------------------
     $tab_html = '';
     if ($tab != 'comments' and $tab != 'settings') {
         if (file_exists($custom_path . '/' . $tab . '.php')) {
             require $custom_path . '/pluginParentClass.php';
             require $custom_path . '/' . $tab . '.php';
             $_func_name = 'profile_' . $tab;
             $plugin = new $_func_name($this->registry);
             $tab_html = $plugin->return_html_block($member);
         }
     }
     //-----------------------------------------
     // Set description tag
     //-----------------------------------------
     $_desc = $member['pp_about_me'] ? $member['pp_about_me'] : $member['signature'];
     if ($_desc) {
         $this->registry->output->addMetaTag('description', $member['members_display_name'] . ': ' . IPSText::getTextClass('bbcode')->stripAllTags($_desc));
     }
     //-----------------------------------------
     // Add to output
     //-----------------------------------------
     $this->member_name = $member['members_display_name'];
     $this->output = $this->registry->getClass('output')->getTemplate('profile')->profileModern($tabs, $member, $comment_html, $friends, $visitors, $tab, $tab_html, $fields);
 }
 /**
  * Set up a member
  *
  * @return	@e void
  */
 protected static function setUpMember()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cache = ipsRegistry::cache()->getCache('group_cache');
     //-----------------------------------------
     // Unpack cache
     //-----------------------------------------
     if (isset(self::$data_store['members_cache'])) {
         self::$data_store['_cache'] = IPSMember::unpackMemberCache(self::$data_store['members_cache']);
     } else {
         self::$data_store['_cache'] = array();
     }
     if (!isset(self::$data_store['_cache']['friends']) or !is_array(self::$data_store['_cache']['friends'])) {
         self::$data_store['_cache']['friends'] = array();
     }
     //-----------------------------------------
     // Unpack ignored users
     //-----------------------------------------
     if (isset(self::$data_store['ignored_users'])) {
         self::$data_store['_ignoredUsers'] = @unserialize(self::$data_store['ignored_users']);
     } else {
         self::$data_store['_ignoredUsers'] = array();
     }
     //-----------------------------------------
     // Set up main 'display' group
     //-----------------------------------------
     if (is_array($cache[self::$data_store['member_group_id']])) {
         self::$data_store = array_merge(self::$data_store, $cache[self::$data_store['member_group_id']]);
     }
     //-----------------------------------------
     // Work out permissions
     //-----------------------------------------
     self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
     /* Ensure we don't have a ,, string */
     self::$data_store['org_perm_id'] = IPSText::cleanPermString(self::$data_store['org_perm_id']);
     self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
     self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
     //-----------------------------------------
     // Synchronise the last visit and activity times if
     // we have some in the member profile
     //-----------------------------------------
     if (!self::$data_store['last_activity']) {
         self::$data_store['last_activity'] = IPS_UNIX_TIME_NOW;
     }
     //-----------------------------------------
     // If there hasn't been a cookie update in 2 hours,
     // we assume that they've gone and come back
     //-----------------------------------------
     if (!self::$data_store['last_visit']) {
         //-----------------------------------------
         // No last visit set, do so now!
         //-----------------------------------------
         ipsRegistry::DB()->update('members', array('last_visit' => self::$data_store['last_activity'], 'last_activity' => IPS_UNIX_TIME_NOW), "member_id=" . self::$data_store['member_id'], true);
         self::$data_store['last_visit'] = self::$data_store['last_activity'];
     } else {
         if (IPS_UNIX_TIME_NOW - self::$data_store['last_activity'] > 300) {
             //-----------------------------------------
             // If the last click was longer than 5 mins ago and this is a member
             // Update their profile.
             //-----------------------------------------
             $be_anon = IPSMember::isLoggedInAnon(self::$data_store);
             ipsRegistry::DB()->update('members', array('login_anonymous' => "{$be_anon}&1", 'last_activity' => IPS_UNIX_TIME_NOW), 'member_id=' . self::$data_store['member_id'], true);
         }
     }
     //-----------------------------------------
     // Group promotion based on time since joining
     //-----------------------------------------
     /* Are we checking for auto promotion? */
     if (self::$data_store['g_promotion'] != '-1&-1') {
         /* Are we checking for post based auto incrementation? 0 is post based, 1 is date based, so...  */
         if (self::$data_store['gbw_promote_unit_type']) {
             list($gid, $gdate) = explode('&', self::$data_store['g_promotion']);
             if ($gid > 0 and $gdate > 0) {
                 if (self::$data_store['joined'] <= time() - $gdate * 86400) {
                     IPSMember::save(self::$data_store['member_id'], array('core' => array('member_group_id' => $gid)));
                     /* Now reset the members group stuff */
                     self::$data_store = array_merge(self::$data_store, $cache[$gid]);
                     self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
                     self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
                     self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Get 12 random friends
  *
  * @param	array 	$member	Member data
  * @return	@e array
  */
 protected function _getRandomFriends($member)
 {
     # Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
     # also fall back on last 10 if no cache
     $_member_ids = array();
     $friends = array();
     if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
         $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
         if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
             foreach ($member['_cache']['friends'] as $id => $approved) {
                 $id = intval($id);
                 if ($approved and $id) {
                     $_member_ids[] = $id;
                 }
             }
             $member['_total_approved_friends'] = count($_member_ids);
             if (is_array($_member_ids) and $member['_total_approved_friends']) {
                 $_max = $member['_total_approved_friends'] > 12 ? 12 : $member['_total_approved_friends'];
                 $_rand = array_rand($_member_ids, $_max);
                 $_final = array();
                 # If viewing member is in list, let's show em
                 if (in_array($this->memberData['member_id'], $_member_ids)) {
                     $_final[] = $this->memberData['member_id'];
                     $new_mids = array();
                     foreach ($_member_ids as $mid) {
                         if ($mid == $this->memberData['member_id']) {
                             continue;
                         }
                         $new_mids[] = $mid;
                     }
                     $_member_ids = $new_mids;
                     unset($new_mids);
                     if (is_array($_rand)) {
                         if (count($_rand) >= 12) {
                             array_pop($_rand);
                         }
                     }
                 }
                 if (is_array($_rand) and count($_rand)) {
                     foreach ($_rand as $_id) {
                         $_final[] = $_member_ids[$_id];
                     }
                 }
                 if (count($_final)) {
                     $sql_extra = ' AND friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')';
                 }
             }
         }
         /* Fetch friends */
         $_memberIds = array();
         $_members = array();
         $_friends = array();
         $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id')), 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1' . ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')' . $sql_extra, 'limit' => array(0, 12), 'order' => 'friends_approved DESC'));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $_memberIds[] = $row['friends_friend_id'];
             $_friends[] = $row;
         }
         /* Got members? */
         $_members = IPSMember::load($_memberIds, 'core,extendedProfile');
         foreach ($_friends as $row) {
             if (!isset($_members[$row['friends_friend_id']])) {
                 continue;
             }
             $row = array_merge($row, $_members[$row['friends_friend_id']]);
             $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT');
             $row = IPSMember::buildProfilePhoto($row);
             $friends[] = $row;
         }
     }
     return $friends;
 }
 /**
  * Main Execution Function
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $post_data = array();
     $poll_data = '';
     $function = '';
     //-----------------------------------------
     // INIT module
     //-----------------------------------------
     $this->loadTopicAndForum();
     //-----------------------------------------
     // Topic rating: Rating
     //-----------------------------------------
     $this->can_rate = $this->memberData['member_id'] ? intval($this->memberData['g_topic_rate_setting']) : 0;
     //-----------------------------------------
     // Reputation Cache
     //-----------------------------------------
     if ($this->settings['reputation_enabled']) {
         /* Load the class */
         require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php';
         $this->registry->setClass('repCache', new classReputationCache());
         /* Update the filter? */
         if (isset($this->request['rep_filter']) && $this->request['rep_filter'] == 'update') {
             $_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
             if ($this->request['rep_filter_set'] == '*') {
                 $_mem_cache['rep_filter'] = '*';
             } else {
                 $_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
             }
             IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
             $this->memberData['_members_cache'] = $_mem_cache;
         } else {
             $this->memberData['_members_cache'] = IPSMember::unpackMemberCache($this->memberData['members_cache']);
         }
     }
     //-----------------------------------------
     // Process the topic
     //-----------------------------------------
     $this->topicSetUp();
     //-----------------------------------------
     // Which view are we using?
     // If mode='show' we're viewing poll results, don't change view mode
     //-----------------------------------------
     $this->topic_view_mode = $this->_generateTopicViewMode();
     //-----------------------------------------
     // VIEWS
     //-----------------------------------------
     $this->_doViewCheck();
     //-----------------------------------------
     // UPDATE TOPIC?
     //-----------------------------------------
     $this->_doUpdateTopicCheck();
     //-----------------------------------------
     // Check PPD
     //-----------------------------------------
     $this->_ppd_ok = $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->memberData, TRUE);
     //-----------------------------------------
     // Post ID stuff
     //-----------------------------------------
     $find_pid = $this->request['pid'] == "" ? isset($this->request['p']) ? $this->request['p'] : 0 : (isset($this->request['pid']) ? $this->request['pid'] : 0);
     $threaded_pid = $find_pid ? '&amp;pid=' . $find_pid : '';
     $linear_pid = $find_pid ? '&amp;view=findpost&amp;p=' . $find_pid : '';
     //-----------------------------------------
     // Remove potential [attachmentid= tag in title
     //-----------------------------------------
     $this->topic['title'] = IPSText::stripAttachTag($this->topic['title']);
     //-----------------------------------------
     // Get posts
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     if ($this->topic_view_mode == 'threaded') {
         require_once IPSLib::getAppDir('forums') . '/sources/classes/threaded.php';
         $threaded = new threadedModeLibrary($this->registry, $this);
         $post_data = $threaded->_getTopicDataThreaded();
     } else {
         $post_data = $this->_getTopicDataLinear();
     }
     unset($this->cached_members);
     IPSDebug::setMemoryDebugFlag("TOPICS: Parsed Posts - Completed", $_NOW);
     //-----------------------------------------
     // Generate template
     //-----------------------------------------
     $this->topic['id'] = $this->topic['forum_id'];
     /* Posting Allowed? */
     $this->forum['_user_can_post'] = 1;
     //( $this->_ppd_ok === TRUE ) ? 1 : 0;
     if (!$this->registry->permissions->check('start', $this->forum)) {
         $this->forum['_user_can_post'] = 0;
     }
     if (!$this->forum['sub_can_post']) {
         $this->forum['_user_can_post'] = 0;
     }
     if ($this->forum['min_posts_post'] && $this->forum['min_posts_post'] > $this->memberData['posts']) {
         $this->forum['_user_can_post'] = 0;
     }
     if (!$this->forum['status']) {
         $this->forum['_user_can_post'] = 0;
     }
     if (!$this->memberData['g_post_new_topics']) {
         $this->forum['_user_can_post'] = 0;
     }
     //-----------------------------------------
     // This has to be called first to set $this->poll_only
     //-----------------------------------------
     $poll_data = $this->topic['poll_state'] ? $this->_generatePollOutput() : '';
     $displayData = array('threaded_mode_enabled' => $this->topic_view_mode == 'threaded' ? 1 : 0, 'fast_reply' => $this->_getFastReplyData(), 'multi_mod' => $this->_getMultiModerationData(), 'reply_button' => $this->_getReplyButtonData(), 'active_users' => $this->_getActiveUserData(), 'mod_links' => $this->_generateModerationPanel(), 'poll_data' => $poll_data);
     $post_data = $this->_parseAttachments($post_data);
     /* Rules */
     if ($this->forum['show_rules'] == 2) {
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_html = 1;
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberdata['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others'];
         $this->forum['rules_text'] = IPSText::getTextClass('bbcode')->preDisplayParse($this->forum['rules_text']);
     }
     //-----------------------------------------
     // Fix post order if linear+ and ordering
     // posts DESC (rare, I know): 16221
     //-----------------------------------------
     if ($this->topic_view_mode == 'linearplus' and $this->settings['post_order_sort'] == 'desc') {
         $newPosts = array();
         foreach ($post_data as $pid => $data) {
             if ($pid == $this->topic['topic_firstpost']) {
                 array_unshift($newPosts, $data);
             } else {
                 $newPosts[] = $data;
             }
         }
         //-----------------------------------------
         // Nothing else relies on the key being pid
         //-----------------------------------------
         $post_data = $newPosts;
     }
     $template = $this->registry->output->getTemplate('topic')->topicViewTemplate($this->forum, $this->topic, $post_data, $displayData);
     //-----------------------------------------
     // Send for output
     //-----------------------------------------
     $this->registry->output->setTitle($this->topic['title'] . ' - ' . $this->settings['board_name']);
     $this->registry->output->addContent($template);
     if (is_array($this->nav) and count($this->nav)) {
         foreach ($this->nav as $_nav) {
             $this->registry->output->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]);
         }
     }
     /**
      * Update cache monitor
      */
     IPSContentCache::updateMonitor($this->_cacheMonitor);
     /**
      * Add navigational links
      */
     $this->registry->output->addToDocumentHead('raw', "<link rel='up' href='" . $this->registry->output->buildSEOUrl('showforum=' . $this->topic['forum_id'], 'public', $this->forum['name_seo'], 'showforum') . "' />");
     $this->registry->output->addToDocumentHead('raw', "<link rel='author' href='" . $this->registry->output->buildSEOUrl('showuser='******'starter_id'], 'public', $this->topic['seo_first_name'], 'showuser') . "' />");
     /* Add Meta Content */
     if ($this->_firstPostContent) {
         $this->registry->output->addMetaTag('keywords', $this->topic['title'] . ' ' . str_replace("\n", " ", str_replace("\r", "", strip_tags($this->_firstPostContent))), TRUE);
     }
     $this->registry->output->addMetaTag('description', $this->topic['title'] . ': ' . $this->topic['description'], TRUE);
     $this->registry->output->sendOutput();
 }
Beispiel #5
0
 /**
  * Unpack the repuation cache, yo.
  *
  * @return	@e void
  */
 protected function _unpackRepCache()
 {
     if ($this->settings['reputation_enabled']) {
         /* Load the class */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         $this->registry->setClass('repCache', new $classToLoad());
         /* Update the filter? */
         if (isset($this->request['rep_filter']) && $this->request['rep_filter'] == 'update') {
             $_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
             if ($this->request['rep_filter_set'] == '*') {
                 $_mem_cache['rep_filter'] = '*';
             } else {
                 $_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
             }
             IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
             $this->memberData['_members_cache'] = $_mem_cache;
         } else {
             $this->memberData['_members_cache'] = IPSMember::unpackMemberCache($this->memberData['members_cache']);
         }
         $this->memberData['_members_cache']['rep_filter'] = isset($this->memberData['_members_cache']['rep_filter']) ? $this->memberData['_members_cache']['rep_filter'] : '*';
     }
 }
 /**
  * Constructor
  *
  * @param	object		Registry reference
  * @return	@e void
  */
 public function __construct(ipsRegistry $registry)
 {
     /* Make objects */
     $this->registry = $registry;
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->lang = $this->registry->getClass('class_localization');
     $this->member = $this->registry->member();
     $this->memberData =& $this->registry->member()->fetchMemberData();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     /* Set default member */
     $this->setMemberData($this->memberData);
     /* Check for class_forums */
     if (!$this->registry->isClassLoaded('class_forums')) {
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums');
         $this->registry->setClass('class_forums', new $classToLoad($registry));
         $this->registry->strip_invisible = 0;
         $this->registry->class_forums->forumsInit();
     }
     /* Load tagging stuff */
     if (!$this->registry->isClassLoaded('tags')) {
         require_once IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php';
         /*noLibHook*/
         $this->registry->setClass('tags', classes_tags_bootstrap::run('forums', 'topics'));
     }
     /* Unpack reputation @todo this isn't ideal here but it'll do for now */
     if ($this->settings['reputation_enabled']) {
         /* Load the class */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         $this->registry->setClass('repCache', new $classToLoad());
         /* Update the filter? */
         if (isset($this->request['rep_filter']) and $this->request['rep_filter'] == 'update') {
             /**
              * Check secure key
              * @link	http://community.invisionpower.com/tracker/issue-22078-i-can-edit-your-treshold
              */
             if ($this->request['secure_key'] != $this->member->form_hash) {
                 $this->registry->output->showError('usercp_forums_bad_key', 1021522);
             }
             $_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
             if ($this->request['rep_filter_set'] == '*') {
                 $_mem_cache['rep_filter'] = '*';
             } else {
                 $_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
             }
             IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
             $this->memberData['_members_cache'] = $_mem_cache;
         } else {
             $this->memberData['_members_cache'] = isset($this->memberData['members_cache']) ? IPSMember::unpackMemberCache($this->memberData['members_cache']) : array();
         }
     }
 }
 /**
  * Get the member's notification configuration
  *
  * @access	public
  * @param	array		Member data
  * @return	array
  * @link	http://community.invisionpower.com/tracker/issue-23529-notification-defaults-dont-apply/
  * @link	http://community.invisionpower.com/tracker/issue-23663-notification-issues/
  */
 public function getMemberNotificationConfig($member)
 {
     $_cache = !empty($member['members_cache']) ? IPSMember::unpackMemberCache($member['members_cache']) : array();
     if (!empty($_cache['notifications'])) {
         $savedTypes = array_keys($_cache['notifications']);
         $_default = $this->getDefaultNotificationConfig();
         $defaultTypes = array_keys($_default);
         $missingTypes = array_diff($defaultTypes, $savedTypes);
         //-----------------------------------------
         // Grab any missing types
         //-----------------------------------------
         foreach ($missingTypes as $_type) {
             $_cache['notifications'][$_type] = $_default[$_type]['selected'];
         }
         //-----------------------------------------
         // Make changes if admin has disallowed override
         // since we saved our config
         //-----------------------------------------
         foreach ($_default as $k => $sub) {
             if ($sub['disable_override']) {
                 $_cache['notifications'][$k]['selected'] = $sub['selected'];
             } else {
                 if ($sub['disabled']) {
                     $_newSelection = array();
                     if (is_array($_cache['notifications'][$k]['selected']) and count($_cache['notifications'][$k]['selected'])) {
                         foreach ($_cache['notifications'][$k]['selected'] as $_thisType) {
                             if (!in_array($_thisType, $sub['disabled'])) {
                                 $_newSelection[] = $_thisType;
                             }
                         }
                     }
                     $_cache['notifications'][$k]['selected'] = $_newSelection;
                 }
             }
         }
         return $_cache['notifications'];
     } else {
         return $this->getDefaultNotificationConfig();
     }
 }