/** * Recaches member's friends * * @access public * @param array $member Member array to recache * @return boolean */ public function recacheFriends($member) { /* INIT */ $friends = array(); /* Check the member id */ if (!$member['member_id']) { return FALSE; } /* Get our friends */ $this->DB->build(array('select' => '*', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'])); $this->DB->execute(); while ($row = $this->DB->fetch()) { $friends[$row['friends_friend_id']] = $row['friends_approved']; } /* Update the cache */ IPSMember::packMemberCache($member['member_id'], array('friends' => $friends)); return TRUE; }
/** * Fixes the member's RSS Key if none set * * @return @e void */ public function checkMemberRSSKey() { if (!$this->memberData['_cache']['rc_rss_key']) { $new_rss_key = md5(uniqid(microtime(), true)); $this->DB->build(array('select' => '*', 'from' => 'rc_modpref', 'where' => "mem_id=" . $this->memberData['member_id'])); $this->DB->execute(); if ($this->DB->getTotalRows() == 1) { $this->DB->update('rc_modpref', array('rss_key' => $new_rss_key), "mem_id=" . $this->memberData['member_id']); } else { $this->DB->insert('rc_modpref', array('rss_key' => $new_rss_key, 'mem_id' => $this->memberData['member_id'], 'rss_cache' => '')); } $memberCache = $this->memberData['_cache']; $memberCache['rc_rss_key'] = $new_rss_key; $this->member->setProperty('_cache', $memberCache); IPSMember::packMemberCache($this->memberData['member_id'], array('rc_rss_key' => $new_rss_key)); } }
/** * Marks everything within an app as read * * @access public * @param string [App Optional. If ommited, all apps are marked as read] * @return @e void */ public function markAppAsRead($app = '') { /* Search engine? */ if ($this->member->is_not_human === TRUE) { return; } /* Cookie */ $cookie['global'] = time(); $cookie['greset'] = array(); /* One app or all? */ if ($app) { /* Reset member cache */ IPSMember::packMemberCache($this->memberData['member_id'], array('gb_mark__' . $app => time())); /* Mark rows for deletion */ $this->DB->update('core_item_markers', array('item_is_deleted' => 1), "item_app='" . $app . "' AND item_member_id=" . intval($this->memberData['member_id'])); /* Update cookies */ $this->_updateCookieData('itemMarking_' . $app . '_items', array()); $this->_updateCookieData('itemMarking_' . $app, $cookie); } else { /* Do 'em all */ $cache = array(); $apps = IPSLib::getEnabledApplications(array('itemMarking')); foreach ($apps as $app => $data) { $cache['gb_mark__' . $app] = time(); /* Update cookies */ $this->_updateCookieData('itemMarking_' . $app . '_items', array()); $this->_updateCookieData('itemMarking_' . $app, $cookie); } if (count($cache)) { /* Reset member cache */ IPSMember::packMemberCache($this->memberData['member_id'], $cache); } /* Mark rows for deletion */ $this->DB->update('core_item_markers', array('item_is_deleted' => 1), 'item_member_id=' . intval($this->memberData['member_id'])); /* Reset internal array */ $this->_itemMarkers = array(); } /* Save cookie */ $this->_setSaveCookie(); }
/** * Recache the user's watched forums * * @param int Member ID * @return boolean * @author Matt */ public function recacheWatchedForums($memberID) { /* INIT */ $final = array(); $memberID = intval($memberID); /* Get forums the member follows */ require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $_like = classes_like::bootstrap('forums', 'forums'); $forums = $_like->getDataByMemberIdAndArea($memberID); $forums = is_array($forums) ? array_keys($forums) : array(); foreach ($forums as $forum) { if ($this->registry->permissions->check('view', $this->forum_by_id[$forum]) === TRUE) { $final[] = $forum; } } IPSMember::packMemberCache($memberID, array('watchedForums' => $final)); return TRUE; }
/** * Toggles a specific notification key for a user * * @return string XML */ protected function _hanldeToggleNotificaionKey() { /* INIT */ $notifyKey = $this->request['key']; $notifyStatus = $this->request['status']; /* Check the form hash */ if ($this->member->form_hash != $this->request['form_hash']) { $this->_returnError("Invalid Request"); } /* Notifications Library */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications'); $notifyLibrary = new $classToLoad($this->registry); $notifyLibrary->setMember($this->memberData); /* Notifications Data */ $_notifyConfig = $notifyLibrary->getMemberNotificationConfig($this->memberData); if ($notifyStatus) { $_notifyConfig[$notifyKey]['selected'][] = 'mobile'; } else { $_newConfig = array(); foreach ($_notifyConfig[$notifyKey]['selected'] as $_v) { if ($_v != 'mobile') { $_newConfig[] = $_v; } } $_notifyConfig[$notifyKey]['selected'] = $_newConfig; } /* Save */ IPSMember::packMemberCache($this->memberData['member_id'], array('notifications' => $_notifyConfig), $this->memberData['members_cache']); }
/** * UserCP Save Form: Settings * * @access public * @return array Errors */ public function saveForumSettings() { //----------------------------------------- // INIT //----------------------------------------- $_trackChoice = ''; //----------------------------------------- // Check... //----------------------------------------- if (!in_array($this->request['postpage'], explode(',', $this->settings['postpage_contents']))) { $this->request['postpage'] = '-1'; } if (!in_array($this->request['topicpage'], explode(',', $this->settings['topicpage_contents']))) { $this->request['topicpage'] = '-1'; } //----------------------------------------- // Type of track //----------------------------------------- if ($this->request['auto_track']) { if (in_array($this->request['trackchoice'], array('none', 'immediate', 'delayed', 'daily', 'weekly'))) { $_trackChoice = $this->request['trackchoice']; } } IPSCookie::set('topicmode', $this->request['topic_display_mode'], 1); IPSMember::save($this->memberData['member_id'], array('core' => array('view_avs' => intval($this->request['viewAvatars']), 'view_sigs' => intval($this->request['viewSignatures']), 'view_img' => intval($this->request['viewImages']), 'email_full' => intval($this->request['send_full_msg']), 'auto_track' => $_trackChoice, 'view_prefs' => intval($this->request['postpage']) . "&" . intval($this->request['topicpage'])))); IPSMember::packMemberCache($this->memberData['member_id'], array('qr_open' => intval($this->request['fastReplyOpen'])), $this->memberData['_cache']); return TRUE; }
/** * UserCP Save Form: Notifications config * * @return boolean Successful */ public function saveFormNotifications() { //----------------------------------------- // Notifications library //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications'); $notifyLibrary = new $classToLoad($this->registry); $notifyLibrary->setMember($this->memberData); //----------------------------------------- // Show the form //----------------------------------------- $_basicOptions = array(array('email', $this->lang->words['notopt__email']), array('inline', $this->lang->words['notopt__inline']), array('mobile' => $this->lang->words['notopt__mobile'])); $_configOptions = $notifyLibrary->getNotificationData(); $_notifyConfig = $notifyLibrary->getMemberNotificationConfig($this->memberData); $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig(); $_saveConfig = array(); foreach ($_configOptions as $option) { $_saveConfig[$option['key']] = array(); $_saveConfig[$option['key']]['selected'] = array(); //----------------------------------------- // Loop through and mark what we selected. // Do not allow changing of stuff from disable_override // and disabled, however //----------------------------------------- if (is_array($this->request['config_' . $option['key']]) and count($this->request['config_' . $option['key']])) { foreach ($this->request['config_' . $option['key']] as $_selected) { if (!is_array($_defaultConfig[$option['key']]['disabled']) or !in_array($_selected, $_defaultConfig[$option['key']]['disabled'])) { $_saveConfig[$option['key']]['selected'][] = $_selected; } } } if ($_defaultConfig[$option['key']]['disable_override']) { $_saveConfig[$option['key']]['selected'] = $_defaultConfig[$option['key']]['selected']; } } //----------------------------------------- // Save //----------------------------------------- IPSMember::packMemberCache($this->memberData['member_id'], array('notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup'])), $this->memberData['members_cache']); //----------------------------------------- // Topic preferences //----------------------------------------- $_trackChoice = ''; if ($this->request['auto_track']) { if (in_array($this->request['trackchoice'], array('none', 'immediate', 'offline', 'daily', 'weekly'))) { $_trackChoice = $this->request['trackchoice']; } } //----------------------------------------- // Profile preferences //----------------------------------------- IPSMember::save($this->memberData['member_id'], array('core' => array('allow_admin_mails' => intval($this->request['admin_send']), 'auto_track' => $_trackChoice))); return TRUE; }
/** * Edit a member [process] * * @return @e void */ protected function _memberDoEdit() { //----------------------------------------- // INIT //----------------------------------------- $this->request['member_id'] = intval($this->request['member_id']); //----------------------------------------- // Send to form if this isn't a POST request //----------------------------------------- if ($this->request['request_method'] != 'post') { $this->_memberView(); return; } //----------------------------------------- // Auth check... //----------------------------------------- ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']); //----------------------------------------- // Load and config the std/rte editors //----------------------------------------- IPSText::getTextClass('editor')->from_acp = 1; //----------------------------------------- // Get member //----------------------------------------- $member = IPSMember::load($this->request['member_id'], 'all'); //----------------------------------------- // Allowed to edit administrators? //----------------------------------------- if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) { $this->registry->output->global_message = $this->lang->words['m_editadmin']; $this->_memberView(); return; } //----------------------------------------- // Allowed to change an admin's groups? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) { $same = false; if ($this->request['member_group_id'] == $member['member_group_id']) { $member['mgroup_others'] = IPSText::cleanPermString($member['mgroup_others']); $omgroups = $member['mgroup_others'] ? explode(',', $member['mgroup_others']) : array(); $groups = $this->request['mgroup_others'] ? $this->request['mgroup_others'] : array(); if (!count(array_diff($omgroups, $groups)) and !count(array_diff($groups, $omgroups))) { $same = true; } } if (!$same) { $this->registry->output->global_message = $this->lang->words['m_admindemote']; $this->_memberView(); return; } } //----------------------------------------- // What about promoting to admin? //----------------------------------------- if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) { $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array(); $groups[] = intval($this->request['member_group_id']); foreach ($groups as $group_id) { if ($this->caches['group_cache'][$group_id]['g_access_cp']) { $this->registry->output->global_message = $this->lang->words['m_adminpromote']; $this->_memberView(); return; } } } //----------------------------------------- // What about moving member in general? //----------------------------------------- if ($this->request['member_group_id'] != $member['member_group_id'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move')) { $this->registry->output->global_message = $this->lang->words['m_movemembers']; $this->_memberView(); return; } //----------------------------------------- // Restricted? //----------------------------------------- $restricted = (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) ? true : false; /* Load editor stuff */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite'); $_editor = new $classToLoad(); /* Load parser */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser'); $parser = new $classToLoad(); /* Get signature */ $_editor->setAllowBbcode(true); $_editor->setAllowSmilies(false); $_editor->setIsHtml($this->request['bw_html_sig'] && $member['g_dohtml']); $_editor->setAllowHtml($member['g_dohtml']); $_editor->setBbcodeSection('signatures'); $signature = $_editor->process($_POST['signature']); $cacheSignature = $parser->display($signature); /* About me editor */ $_editor->setAllowBbcode(true); $_editor->setAllowSmilies(true); $_editor->setAllowHtml($member['g_dohtml']); $_editor->setBbcodeSection('aboutme'); $aboutme = $_editor->process($_POST['aboutme']); //----------------------------------------- // Ok? Load interface and child classes //----------------------------------------- $additionalCore = array(); $additionalExtended = array(); $additionalMCache = array(); IPSLib::loadInterface('admin/member_form.php'); foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) { if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) { $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php', 'admin_member_form__' . $app_dir, $app_dir); $_object = new $_class($this->registry); $remote = $_object->getForSave(); $additionalCore = is_array($remote['core']) ? array_merge($remote['core'], $additionalCore) : $additionalCore; $additionalExtended = is_array($remote['extendedProfile']) ? array_merge($remote['extendedProfile'], $additionalExtended) : $additionalExtended; $additionalMCache = is_array($remote['member_cache']) ? array_merge($remote['member_cache'], $additionalMCache) : $additionalMCache; } } //----------------------------------------- // Fix custom title // @see http://forums.invisionpower.com/index.php?app=tracker&showissue=17383 //----------------------------------------- $memberTitle = $this->request['title']; $rankCache = ipsRegistry::cache()->getCache('ranks'); if (is_array($rankCache) && count($rankCache)) { foreach ($rankCache as $k => $v) { if ($member['posts'] >= $v['POSTS']) { /* If this is the title passed to us from the form, we didn't have a custom title */ if ($v['TITLE'] == $memberTitle) { $memberTitle = ''; } break; } } } //----------------------------------------- // Start array //----------------------------------------- $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'members_auto_dst' => intval($this->request['dstCheck']), 'dst_in_use' => intval($this->request['dstOption']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $this->request['mgroup_others'] ? ',' . implode(",", $this->request['mgroup_others']) . ',' : '', 'members_bitoptions' => IPSBWOPtions::freeze($this->request, 'members', 'global'), 'member_uploader' => $this->request['member_uploader']); //----------------------------------------- // Notifications library //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications'); $notifyLibrary = new $classToLoad($this->registry); $notifyLibrary->setMember($member); //----------------------------------------- // Show the form //----------------------------------------- $_basicOptions = array(array('email', $this->lang->words['notopt__email']), array('inline', $this->lang->words['notopt__inline']), array('mobile', $this->lang->words['notopt__mobile'])); $_configOptions = $notifyLibrary->getNotificationData(); $_notifyConfig = $notifyLibrary->getMemberNotificationConfig($newMember); $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig(); $_saveConfig = array(); foreach ($_configOptions as $option) { $_saveConfig[$option['key']] = array(); $_saveConfig[$option['key']]['selected'] = array(); //----------------------------------------- // Loop through and mark what we selected. // Do not allow changing of stuff from disable_override // and disabled, however //----------------------------------------- if (is_array($this->request['config_' . $option['key']]) and count($this->request['config_' . $option['key']])) { foreach ($this->request['config_' . $option['key']] as $_selected) { if (!is_array($_defaultConfig[$option['key']]['disabled']) or !in_array($_selected, $_defaultConfig[$option['key']]['disabled'])) { $_saveConfig[$option['key']]['selected'][] = $_selected; } } } if ($_defaultConfig[$option['key']]['disable_override']) { $_saveConfig[$option['key']]['selected'] = $_defaultConfig[$option['key']]['selected']; } } //----------------------------------------- // Save //----------------------------------------- IPSMember::packMemberCache($member['member_id'], array_merge($additionalMCache, array('notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup']))), $member['members_cache']); //----------------------------------------- // Topic preferences //----------------------------------------- $_trackChoice = ''; if ($this->request['auto_track']) { if (in_array($this->request['auto_track_method'], array('none', 'immediate', 'offline', 'daily', 'weekly'))) { $_trackChoice = $this->request['auto_track_method']; } } $newMember['auto_track'] = $_trackChoice; //----------------------------------------- // Custom profile field stuff //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields'); $fields = new $classToLoad(); $fields->initData('edit'); $fields->parseToSave($_POST); /* Check the website url field */ $website_field = $fields->getFieldIDByKey('website'); if ($website_field && $fields->out_fields['field_' . $website_field]) { if (stristr($fields->out_fields['field_' . $website_field], 'http://') === FALSE && stristr($fields->out_fields['field_' . $website_field], 'https://') === FALSE) { $fields->out_fields['field_' . $website_field] = 'http://' . $fields->out_fields['field_' . $website_field]; } } //----------------------------------------- // Throw to the DB //----------------------------------------- IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends']), 'pp_customization' => $this->request['removeCustomization'] ? serialize(array()) : $member['pp_customization']), $additionalExtended), 'customFields' => count($fields->out_fields) ? $fields->out_fields : array())); if ($member['member_group_id'] != $newMember['member_group_id']) { IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id'], $member['member_group_id']); //----------------------------------------- // Remove restrictions if member demoted // Commenting out as this may cause more problems than it's worth // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions //----------------------------------------- /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] ) { $this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" ); }*/ //----------------------------------------- // Restriction permissions stuff //----------------------------------------- $is_admin = 0; $groups = ipsRegistry::cache()->getCache('group_cache'); if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) { foreach ($this->request['mgroup_others'] as $omg) { if ($groups[intval($omg)]['g_access_cp']) { $is_admin = 1; break; } } } if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) { $is_admin = 1; } if ($is_admin && $restricted) { //------------------------------------------------- // Copy restrictions if they do not have any yet... //------------------------------------------------- $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id'])); if (!$check['row_updated']) { $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type')); } } } //----------------------------------------- // Moved from validating group? //----------------------------------------- if ($member['member_group_id'] == $this->settings['auth_group']) { if ($this->request['member_group_id'] != $this->settings['auth_group']) { //----------------------------------------- // Yes... //----------------------------------------- $this->DB->delete('validating', "member_id=" . $this->request['member_id']); } } /* Update cache */ IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature); /* Rebuild birthday cache */ $this->cache->rebuildCache('birthdays', 'calendar'); //----------------------------------------- // Redirect //----------------------------------------- ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name'])); $this->registry->output->global_message = $this->lang->words['m_edited']; if ($is_admin) { if (!$restricted) { $member = IPSMember::load($member['member_id']); $this->_showAdminForm($member, array()); $this->_memberView(); } else { $this->registry->output->global_message = $this->lang->words['m_edited_restricted']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']); } } else { $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']); } }
/** * Disables the live meta editor * * @return @e void */ public function end() { IPSMember::packMemberCache($this->memberData['member_id'], array('ipseo_live_meta_edit' => 0)); $this->registry->output->silentRedirect(ipsRegistry::$settings['base_url'] . $this->request['url']); }
/** * 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 ? '&pid=' . $find_pid : ''; $linear_pid = $find_pid ? '&view=findpost&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(); }
/** * 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(); } } }
/** * Recache the user's watched forums * * @access public * @param int Member ID * @return boolean * @author Matt */ public function recacheWatchedForums($memberID) { /* INIT */ $forums = array(); $memberID = intval($memberID); /* Grab SQL */ $this->DB->build(array('select' => 'forum_id', 'from' => 'forum_tracker', 'where' => 'member_id=' . $memberID)); $this->DB->execute(); while ($row = $this->DB->fetch()) { if ($this->registry->permissions->check('view', $this->forum_by_id[$row['forum_id']]) !== TRUE) { /* Could grab the IDs and remove from the table at some point? */ continue; } $forums[] = $row['forum_id']; } IPSMember::packMemberCache($memberID, array('watchedForums' => $forums)); return TRUE; }
/** * Marks everything within an app as read * * @access public * @param string [App Optional. If ommited, all apps are marked as read] * @return void */ public function markAppAsRead($app = '') { /* Search engine? */ if ($this->member->is_not_human === TRUE) { return; } /* Cookie */ $cookie['global'] = time(); $cookie['greset'] = array(); /* Reset flag */ $this->_savedStorage = FALSE; /* Mark markers as having changed */ $this->_changesMade = TRUE; /* One app or all? */ if ($app) { /* Reset member cache */ IPSMember::packMemberCache($this->memberData['member_id'], array('gb_mark__' . $app => time())); /* Delete permanent rows */ $this->DB->delete('core_item_markers', "item_app='" . $app . "' AND item_member_id=" . intval($this->memberData['member_id'])); /* Update the last global reset time and clear the read array */ $this->_itemMarkers[$app][$_key]['item_read_array'] = array(); $this->_itemMarkers[$app][$_key]['item_global_reset'] = time(); $this->_itemMarkers[$app][$_key]['item_unread_count'] = 0; $this->_itemMarkers[$app][$_key]['item_last_update'] = time(); /* Save markers */ if ($this->fetchInstantSaveStatus()) { $this->_saveStorage(); } /* Update cookies */ $this->_updateCookieData('itemMarking_' . $app . '_items', array()); $this->_updateCookieData('itemMarking_' . $app, $cookie); } else { /* Do 'em all */ $cache = array(); foreach ($this->_itemMarkers as $app => $data) { $cache['gb_mark__' . $app] = time(); /* Update cookies */ $this->_updateCookieData('itemMarking_' . $app . '_items', array()); $this->_updateCookieData('itemMarking_' . $app, $cookie); } if (count($cache)) { /* Reset member cache */ IPSMember::packMemberCache($this->memberData['member_id'], $cache); } /* Delete temporary storage */ $this->DB->delete('core_item_markers_storage', 'item_member_id=' . intval($this->memberData['member_id'])); /* Delete permanent rows */ $this->DB->delete('core_item_markers', "item_member_id=" . intval($this->memberData['member_id'])); /* Reset internal array */ $this->_itemMarkers = array(); /* Reset flag */ $this->_savedStorage = TRUE; } /* Save cookie */ $this->_saveCookie(); }