/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); if (get_forum_type() != 'ocf') { return new ocp_tempcode(); } if (is_guest()) { return new ocp_tempcode(); } require_css('side_blocks'); ocf_require_all_forum_stuff(); require_code('ocf_notifications'); // Only show what's new in week. Some forums may want to tweak this, but forums themselves only mark unread topics for a week. $rows = ocf_get_pp_rows(); // if (count($rows)==0) return new ocp_tempcode(); require_lang('ocf'); $out = new ocp_tempcode(); foreach ($rows as $topic) { $topic_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'findpost'), get_module_zone('topicview')); $topic_url->attach('#post_' . strval($topic['id'])); $title = $topic['t_cache_first_title']; $date = get_timezoned_date($topic['t_cache_last_time'], true); $username = $topic['t_cache_last_username']; $member_link = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['t_cache_last_member_id'], false, true); $num_posts = $topic['t_cache_num_posts']; $out->attach(do_template('TOPIC_LIST', array('_GUID' => '55ae21a9f8d67ba6237c118a18b9657b', 'USER_LINK' => $member_link, 'TOPIC_LINK' => $topic_url, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic['t_cache_last_time']), 'USERNAME' => $username, 'NUM_POSTS' => integer_format($num_posts)))); } $send_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'redirect' => SELF_REDIRECT), get_module_zone('topics')); if (!ocf_may_make_personal_topic()) { $send_url = new ocp_tempcode(); } $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); return do_template('BLOCK_SIDE_OCF_PERSONAL_TOPICS', array('_GUID' => '9376cd47884a78f3d1914c176b67ee28', 'SEND_URL' => $send_url, 'VIEW_URL' => $view_url, 'CONTENT' => $out, 'FORUM_NAME' => do_lang_tempcode('PERSONAL_TOPICS'))); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('PROFILE'); $order = 10; $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); if ($photo_url != '' && addon_installed('ocf_member_photos') && has_specific_permission($member_id_viewing, 'view_member_photos')) { require_code('images'); $photo_thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); $photo_thumb_url = ensure_thumbnail($photo_url, $photo_thumb_url, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member_id_of, 'm_photo_thumb_url'); if (url_is_local($photo_url)) { $photo_url = get_complex_base_url($photo_url) . '/' . $photo_url; } if (url_is_local($photo_thumb_url)) { $photo_thumb_url = get_complex_base_url($photo_thumb_url) . '/' . $photo_thumb_url; } } else { $photo_url = ''; $photo_thumb_url = ''; } $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id_of); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); // Things staff can do with this user $modules = array(); if (has_specific_permission($member_id_viewing, 'warn_members') && has_actual_page_access($member_id_viewing, 'warnings') && addon_installed('ocf_warnings')) { $redir_url = get_self_url(true); $modules[] = array('usage', do_lang_tempcode('WARN_MEMBER'), build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $member_id_of, 'redirect' => $redir_url), get_module_zone('warnings'))); $modules[] = array('usage', do_lang_tempcode('PUNITIVE_HISTORY'), build_url(array('page' => 'warnings', 'type' => 'history', 'id' => $member_id_of), get_module_zone('warnings'))); } if (has_specific_permission($member_id_viewing, 'view_content_history') && has_actual_page_access($member_id_viewing, 'admin_ocf_history')) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('usage', do_lang_tempcode('POST_HISTORY'), build_url(array('page' => 'admin_ocf_history', 'member_id' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_lookup')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('INVESTIGATE_USER'), build_url(array('page' => 'admin_lookup', 'param' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_security')) { require_lang('security'); $modules[] = array('usage', do_lang_tempcode('SECURITY_LOGGING'), build_url(array('page' => 'admin_security', 'member_id' => $member_id_of), 'adminzone')); } if (addon_installed('actionlog')) { if (has_actual_page_access($member_id_viewing, 'admin_actionlog')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('VIEW_ACTION_LOGS'), build_url(array('page' => 'admin_actionlog', 'type' => 'list', 'id' => $member_id_of), 'adminzone')); } } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('ocf_forum') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH_POSTS'), build_url(array('page' => 'search', 'type' => 'results', 'id' => 'ocf_posts', 'author' => $username, 'sort' => 'add_date', 'direction' => 'DESC', 'content' => ''), get_module_zone('search')), 'search'); } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH'), build_url(array('page' => 'search', 'type' => 'misc', 'author' => $username), get_module_zone('search')), 'search'); } if (addon_installed('authors')) { $author = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT author FROM ' . get_table_prefix() . 'authors WHERE (forum_handle=' . strval($member_id_viewing) . ') OR (forum_handle IS NULL AND ' . db_string_equal_to('author', $username) . ')'); if (has_actual_page_access($member_id_viewing, 'authors') && !is_null($author)) { $modules[] = array('content', do_lang_tempcode('AUTHOR'), build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')), 'me'); } } require_code('ocf_members2'); if (!is_guest() && ocf_may_whisper($member_id_of) && has_actual_page_access($member_id_viewing, 'topics') && ocf_may_make_personal_topic() && $member_id_viewing != $member_id_of) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('contact', do_lang_tempcode('ADD_PERSONAL_TOPIC'), build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => $member_id_of), get_module_zone('topics')), 'reply'); } $extra_sections = array(); $info_details = array(); $hooks = find_all_hooks('modules', 'members'); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/members/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_members_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } if (method_exists($object, 'run')) { $hook_result = $object->run($member_id_of); $modules = array_merge($modules, $hook_result); } if (method_exists($object, 'get_info_details')) { $hook_result = $object->get_info_details($member_id_of); $info_details = array_merge($info_details, $hook_result); } if (method_exists($object, 'get_sections')) { $hook_result = $object->get_sections($member_id_of); $extra_sections = array_merge($extra_sections, $hook_result); } } if (addon_installed('ocf_contactmember')) { if (($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_allow_emails') == 1 || get_option('allow_email_disable') == '0') && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address') != '' && !is_guest($member_id_of) && has_actual_page_access($member_id_viewing, 'contactmember') && $member_id_viewing != $member_id_of) { $redirect = get_self_url(true); $modules[] = array('contact', do_lang_tempcode('_EMAIL_MEMBER'), build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id_of), get_module_zone('contactmember')), 'reply'); } } require_lang('menus'); $sections = array('contact' => do_lang_tempcode('CONTACT'), 'profile' => do_lang_tempcode('EDIT_PROFILE'), 'views' => do_lang_tempcode('ACCOUNT'), 'usage' => do_lang_tempcode('USAGE'), 'content' => do_lang_tempcode('CONTENT')); $actions = array(); global $M_SORT_KEY; $M_SORT_KEY = mixed(); $M_SORT_KEY = 1; @uasort($modules, 'multi_sort'); /* @ is to stop PHP bug warning about altered array contents when Tempcode copies are evaluated internally */ foreach ($sections as $section_code => $section_title) { $links = new ocp_tempcode(); foreach ($modules as $module) { if (count($module) == 3) { list($_section_code, $lang, $url) = $module; $rel = NULL; } else { list($_section_code, $lang, $url, $rel) = $module; } if ($section_code == $_section_code) { $links->attach(do_template('OCF_MEMBER_ACTION', array('_GUID' => '67b2a640a368c6f53f1b1fa10f922fd0', 'ID' => strval($member_id_of), 'URL' => $url, 'LANG' => $lang, 'REL' => $rel))); } } $actions[$section_code] = $links; } // Custom fields $_custom_fields = ocf_get_all_custom_fields_match_member($member_id_of, $member_id_viewing != $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_viewing == $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL); $custom_fields = array(); require_code('encryption'); $value = mixed(); foreach ($_custom_fields as $name => $_value) { $value = $_value['RAW']; $rendered_value = $_value['RENDERED']; $encrypted_value = ''; if (is_data_encrypted($value)) { $encrypted_value = remove_magic_encryption_marker($value); } elseif (is_integer($value)) { $value = strval($value); } elseif (is_float($value)) { $value = float_to_raw_string($value); } if (!is_object($value) && $value != '' || is_object($value) && !$value->is_empty()) { $custom_fields[] = array('NAME' => $name, 'RAW_VALUE' => $value, 'VALUE' => $rendered_value, 'ENCRYPTED_VALUE' => $encrypted_value); if ($name == do_lang('KEYWORDS')) { $GLOBALS['SEO_KEYWORDS'] = is_object($value) ? $value->evaluate() : $value; } if ($name == do_lang('DESCRIPTION')) { $GLOBALS['SEO_DESCRIPTION'] = is_object($value) ? $value->evaluate() : $value; } } } // Birthday $dob = ''; if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_reveal_age') == 1) { $day = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_day'); $month = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_month'); $year = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_year'); if (!is_null($day)) { if (@strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') { $dob = strval($year) . '-' . str_pad(strval($month), 2, '0', STR_PAD_LEFT) . '-' . str_pad(strval($day), 2, '0', STR_PAD_LEFT); } else { $dob = get_timezoned_date(mktime(12, 0, 0, $month, $day, $year), false, true, true); } } } // Find forum with most posts $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'); $best_yet_forum = 0; // Initialise to integer type $best_yet_forum = NULL; $most_active_forum = NULL; $_best_yet_forum = $GLOBALS['FORUM_DB']->query_select('f_posts', array('COUNT(*) as cnt', 'p_cache_forum_id'), array('p_poster' => $member_id_of), 'GROUP BY p_cache_forum_id'); $_best_yet_forum = collapse_2d_complexity('p_cache_forum_id', 'cnt', $_best_yet_forum); foreach ($forums as $forum) { if (array_key_exists($forum['id'], $_best_yet_forum) && (is_null($best_yet_forum) || $_best_yet_forum[$forum['id']] > $best_yet_forum)) { $most_active_forum = has_category_access($member_id_viewing, 'forums', strval($forum['id'])) ? protect_from_escaping(escape_html($forum['f_name'])) : do_lang_tempcode('PROTECTED_FORUM'); $best_yet_forum = $_best_yet_forum[$forum['id']]; } } $post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_cache_num_posts'); $best_post_fraction = $post_count == 0 ? do_lang_tempcode('NA_EM') : make_string_tempcode(integer_format(100 * $best_yet_forum / $post_count)); $most_active_forum = is_null($best_yet_forum) ? new ocp_tempcode() : do_lang_tempcode('_MOST_ACTIVE_FORUM', $most_active_forum, make_string_tempcode(integer_format($best_yet_forum)), array($best_post_fraction)); $time_for_them_raw = tz_time(time(), get_users_timezone($member_id_of)); $time_for_them = get_timezoned_time(time(), true, $member_id_of); $banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned') == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $last_submit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_submit_time'); $submit_days_ago = intval(floor(floatval(time() - $last_submit_time) / 60.0 / 60.0 / 24.0)); require_code('ocf_groups'); $primary_group_id = ocf_get_member_primary_group($member_id_of); $primary_group = ocf_get_group_link($primary_group_id); $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $last_visit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_visit_time'); if (member_is_online($member_id_of)) { $online_now = do_lang_tempcode('YES'); $_online_now = true; } else { $_online_now = false; $minutes_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0)); $hours_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0)); $days_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0)); $months_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0 / 31.0)); if ($minutes_ago < 180) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MINUTES', integer_format($minutes_ago)); } elseif ($hours_ago < 72) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_HOURS', integer_format($hours_ago)); } elseif ($days_ago < 93) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_DAYS', integer_format($days_ago)); } else { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MONTHS', integer_format($months_ago)); } } $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_join_time'); $days_joined = intval(round((time() - $join_time) / 60 / 60 / 24)); $total_posts = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)'); $join_date = $join_time == 0 ? '' : get_timezoned_date($join_time, false); $count_posts = do_lang_tempcode('_COUNT_POSTS', integer_format($post_count), float_format(floatval($post_count) / floatval($days_joined == 0 ? 1 : $days_joined)), array(float_format(floatval(100 * $post_count) / floatval($total_posts == 0 ? 1 : $total_posts)))); $a = $avatar_url == '' ? 0 : ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $b = $photo_thumb_url == '' ? 0 : intval(get_option('thumb_width')); $right_margin = max($a, $b) == 0 ? 'auto' : strval(max($a, $b) + 6) . 'px'; breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MEMBERS')))); if (has_specific_permission($member_id_viewing, 'see_ip')) { $ip_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_ip_address'); } else { $ip_address = ''; } $secondary_groups = ocf_get_members_groups($member_id_of, true); unset($secondary_groups[$primary_group_id]); if (count($secondary_groups) > 0) { $_secondary_groups = array(); $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, array_keys($secondary_groups), $member_id_of); foreach (array_keys($secondary_groups) as $key) { $_secondary_groups[$key] = $all_groups[$key]; } $secondary_groups = $_secondary_groups; } if (addon_installed('points')) { require_code('points'); $count_points = integer_format(total_points($member_id_of)); } else { $count_points = ''; } $user_agent = NULL; $operating_system = NULL; if (has_specific_permission($member_id_viewing, 'show_user_browsing') && addon_installed('stats')) { $last_stats = $GLOBALS['SITE_DB']->query_select('stats', array('browser', 'operating_system'), array('the_user' => $member_id_of), 'ORDER BY date_and_time DESC', 1); if (array_key_exists(0, $last_stats)) { $user_agent = $last_stats[0]['browser']; $operating_system = $last_stats[0]['operating_system']; } } /*if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden')) { $remote=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of,'m_password_compat_scheme')=='remote'; } else */ $remote = NULL; $_on_probation = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if (is_null($_on_probation) || $_on_probation <= time()) { $on_probation = NULL; } else { $on_probation = strval($_on_probation); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $join_time), 'creator' => $username, 'publisher' => '', 'modified' => '', 'type' => 'Member', 'title' => '', 'identifier' => '_SEARCH:members:view:' . strval($member_id_of), 'description' => '', 'image' => $avatar_url == '' && has_specific_permission($member_id_viewing, 'view_member_photos') ? $photo_url : $avatar_url); // Look up member's clubs $clubs = array(); if (addon_installed('ocf_clubs')) { $club_ids = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of, true); $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1), '', 200)); if (count($club_rows) == 200) { $club_rows = NULL; } foreach ($club_ids as $club_id) { if (is_null($club_rows)) { $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1, 'id' => $club_id), '', 200)); if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; $club_rows = NULL; } else { if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; } $club_name = get_translated_text($club_row['g_name'], $GLOBALS['FORUM_DB']); $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $club_name))); $clubs[] = array('CLUB_NAME' => $club_name, 'CLUB_ID' => strval($club_row['id']), 'CLUB_FORUM' => is_null($club_forum) ? '' : strval($club_forum)); } } $content = do_template('OCF_MEMBER_PROFILE_ABOUT', array('_GUID' => 'fodfjdsfjsdljfdls', 'CLUBS' => $clubs, 'REMOTE' => $remote, 'RIGHT_MARGIN' => $right_margin, 'AVATAR_WIDTH' => strval($a) . 'px', 'PHOTO_WIDTH' => strval($b) . 'px', 'MOST_ACTIVE_FORUM' => $most_active_forum, 'TIME_FOR_THEM' => $time_for_them, 'TIME_FOR_THEM_RAW' => strval($time_for_them_raw), 'SUBMIT_DAYS_AGO' => integer_format($submit_days_ago), 'SUBMIT_TIME_RAW' => strval($last_submit_time), 'LAST_VISIT_TIME_RAW' => strval($last_visit_time), 'ONLINE_NOW' => $online_now, '_ONLINE_NOW' => $_online_now, 'BANNED' => $banned, 'USER_AGENT' => $user_agent, 'OPERATING_SYSTEM' => $operating_system, 'DOB' => $dob, 'IP_ADDRESS' => $ip_address, 'COUNT_POSTS' => $count_posts, 'COUNT_POINTS' => $count_points, 'PRIMARY_GROUP' => $primary_group, 'PRIMARY_GROUP_ID' => strval($primary_group_id), 'PHOTO_URL' => $photo_url, 'PHOTO_THUMB_URL' => $photo_thumb_url, 'EMAIL_ADDRESS' => $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address'), 'AVATAR_URL' => $avatar_url, 'SIGNATURE' => $signature, 'JOIN_DATE' => $join_date, 'JOIN_DATE_RAW' => strval($join_time), 'CUSTOM_FIELDS' => $custom_fields, 'ACTIONS_contact' => $actions['contact'], 'ACTIONS_profile' => $actions['profile'], 'ACTIONS_views' => $actions['views'], 'ACTIONS_usage' => $actions['usage'], 'ACTIONS_content' => $actions['content'], 'USERNAME' => $username, 'MEMBER_ID' => strval($member_id_of), 'SECONDARY_GROUPS' => $secondary_groups, 'VIEW_PROFILES' => $member_id_viewing == $member_id_of || has_specific_permission($member_id_viewing, 'view_profiles'), 'ON_PROBATION' => $on_probation, 'EXTRA_INFO_DETAILS' => $info_details, 'EXTRA_SECTIONS' => $extra_sections)); return array($title, $content, $order); }
/** * The UI to make a post. * * @return tempcode The UI */ function new_post() { require_code('ocf_posts2'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'quote'; $NON_CANONICAL_PARAMS[] = 'intended_solely_for'; $topic_id = get_param_integer('id'); $parent_id = either_param_integer('parent_id', NULL); $intended_solely_for = get_param_integer('intended_solely_for', -1); $post = post_param('post', NULL); // Copy existing post into box (from quick reply 'more options' button) if (is_null($post)) { $quotes = array(); $quote = get_param_integer('quote', -1); if ($quote == -1) { $quotes = $this->get_markers(); } else { $quotes[] = $quote; } $post = $this->attach_quotes($quotes); } $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $topic_info[0]['t_forum_id']; $topic_title = $topic_info[0]['t_cache_first_title']; if ($topic_title == '') { $topic_title = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_title', array('p_topic_id' => $topic_id)); } if (is_null($topic_title)) { $topic_title = ''; } if (!is_null($forum_id)) { if (!has_category_access(get_member(), 'forums', strval($forum_id))) { access_denied('CATEGORY_ACCESS'); } // Can happen if trying to reply to a stated whisper made to you in a forum you don't have access to } else { // It must be a Private Topic. Do we have access? $from = $topic_info[0]['t_pt_from']; $to = $topic_info[0]['t_pt_to']; if ($from != get_member() && $to != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt')) { access_denied('SPECIFIC_PERMISSION', 'view_other_pt'); } } $this->handle_topic_breadcrumbs($forum_id, $topic_id, $topic_title, do_lang_tempcode('ADD_POST')); if ($topic_info[0]['t_is_open'] == 0) { $may_moderate_forum = ocf_may_moderate_forum($forum_id); if (!$may_moderate_forum) { warn_exit(do_lang_tempcode('TOPIC_IS_CLOSED')); } } $hidden_fields = new ocp_tempcode(); $hidden_fields->attach(form_input_hidden('topic_id', strval($topic_id))); $hidden_fields->attach(form_input_hidden('from_url', get_self_url(true, false, array('type' => get_param('type', 'misc'))))); $map = array('page' => '_SELF', 'type' => '_add_reply', 'parent_id' => $parent_id); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $post_url = build_url($map, '_SELF'); // Certain aspects relating to the posting system $specialisation = new ocp_tempcode(); if (get_option('is_on_post_titles') == '1') { $specialisation->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'title', post_param('title', ''), false, 1)); } if (ocf_may_moderate_forum($forum_id, get_member())) { $moderation_options = array(array(do_lang_tempcode('EMPHASISED'), 'is_emphasised', false, do_lang_tempcode('DESCRIPTION_EMPHASISED'))); if (addon_installed('unvalidated')) { $moderation_options[] = array(do_lang_tempcode('VALIDATED'), 'validated', true, do_lang_tempcode('DESCRIPTION_VALIDATED')); } //if ($intended_solely_for==-1) $moderation_options[]=array(do_lang_tempcode('CASCADING'),'cascading',false,do_lang_tempcode('DESCRIPTION_CASCADING')); } else { $moderation_options = array(); $hidden_fields->attach(form_input_hidden('validated', '1')); } $options = array(); if (!is_guest()) { if (get_value('disable_skip_sig') !== '1') { if (addon_installed('ocf_signatures')) { $options[] = array(do_lang_tempcode('SKIP_SIGNATURE'), 'skip_sig', false, do_lang_tempcode('DESCRIPTION_SKIP_SIGNATURE')); } } if (get_option('is_on_anonymous_posts') == '1') { $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION')); } } $specialisation2 = form_input_various_ticks($options, ''); if (count($moderation_options) != 0) { $specialisation2->attach(form_input_various_ticks($moderation_options, '', NULL, do_lang_tempcode('MODERATION_OPTIONS'))); } if (!is_null($forum_id)) { $post_templates = $this->post_templates($forum_id); $specialisation->attach($post_templates[0]); if (is_object($post) && $post->is_empty() || $post === '') { $post = $post_templates[1]; } } $_intended_solely_for = ''; if ($intended_solely_for != -1) { $_intended_solely_for = $GLOBALS['FORUM_DRIVER']->get_username($intended_solely_for); if (is_null($_intended_solely_for)) { $_intended_solely_for = ''; } } if (ocf_may_make_personal_topic()) { if ($_intended_solely_for != '' || get_value('no_inline_pp_advertise') !== '1') { $specialisation->attach(form_input_username(do_lang_tempcode('WHISPER'), do_lang_tempcode('DESCRIPTION_WHISPER'), 'intended_solely_for', $_intended_solely_for, false)); } } if (is_guest()) { $specialisation->attach(form_input_line(do_lang_tempcode('GUEST_NAME'), '', 'poster_name_if_guest', do_lang('GUEST'), true)); } require_code('fields'); if (has_tied_catalogue('post')) { append_form_custom_fields('post', NULL, $specialisation, $hidden_fields); } $text = new ocp_tempcode(); if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $specialisation->attach(form_input_captcha()); $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY'))); } } if (addon_installed('points')) { $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login')); $_login_url = escape_html($login_url->evaluate()); if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) { $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url))); } } if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_lowrange_content', 'topics', array('forums', $forum_id))) { $text->attach(paragraph(do_lang_tempcode('WILL_NEED_VALIDATING'))); } // Awards? if (addon_installed('awards')) { require_code('awards'); $specialisation->attach(get_award_fields('post')); } // Moderator reply if (ocf_may_moderate_forum($forum_id, get_member())) { require_code('ocf_forums2'); $specialisation2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('TOPIC_MODERATION')))); $specialisation2->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'new_title', $topic_title, false)); $specialisation2->attach(form_input_tree_list(do_lang_tempcode('DESTINATION_FORUM'), do_lang_tempcode('DESCRIPTION_DESTINATION_FORUM'), 'to', NULL, 'choose_forum', array(), false, is_null($forum_id) ? '' : strval($forum_id))); $options = array(array(do_lang_tempcode('OPEN'), 'open', $topic_info[0]['t_is_open'] == 1, do_lang_tempcode('DESCRIPTION_OPEN')), array(do_lang_tempcode('PINNED'), 'pinned', $topic_info[0]['t_pinned'] == 1, do_lang_tempcode('DESCRIPTION_PINNED'))); if (addon_installed('unvalidated')) { if ($topic_info[0]['t_validated'] == 0) { $topic_info[0]['t_validated'] = get_param_integer('validated', 0); if ($topic_info[0]['t_validated'] == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } $options[] = array(do_lang_tempcode('VALIDATED'), 'topic_validated', $topic_info[0]['t_validated'] == 1, do_lang_tempcode('DESCRIPTION_VALIDATED')); } if (get_value('disable_sunk') !== '1') { $moderation_options[] = array(do_lang_tempcode('SUNK'), 'sunk', $topic_info[0]['t_sunk'] == 1, do_lang_tempcode('DESCRIPTION_SUNK')); } if (!is_null($forum_id)) { $options[] = array(do_lang_tempcode('CASCADING'), 'cascading', $topic_info[0]['t_cascading'] == 1, do_lang_tempcode('DESCRIPTION_CASCADING')); } $specialisation2->attach(form_input_various_ticks($options, '')); if (addon_installed('calendar')) { $specialisation2->attach(form_input_date__scheduler(do_lang_tempcode('OCF_PUBLICATION_TIME'), do_lang_tempcode('OCF_DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true)); } } $topic_posts = new ocp_tempcode(); $posts = $GLOBALS['FORUM_DB']->query('SELECT *,p.id AS id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=p.p_post WHERE p_topic_id=' . strval($topic_id) . ' AND (p_intended_solely_for IS NULL OR p_intended_solely_for=' . strval(get_member()) . ' OR p_poster=' . strval(get_member()) . ') AND p_validated=1 ORDER BY p_time DESC,p.id DESC', 20); foreach ($posts as $row) { $topic_posts->attach(do_template('OCF_POSTING_SCREEN_POST', array('TITLE' => $row['p_title'], 'ID' => strval($row['id']), 'POSTER' => strval($row['p_poster']), 'POST' => ocf_show_isolated_post($row, true)))); } if (!$topic_posts->is_empty()) { $topic_posts = do_template('OCF_POSTING_SCREEN_POSTS', array('_GUID' => '3d3b14cf3a48b2a16eed5b1bd92b1187', 'POSTS' => $topic_posts)); } if (is_object($post)) { $post = $post->evaluate(); } $posting_form = get_posting_form(do_lang('ADD_POST'), $post, $post_url, $hidden_fields, $specialisation, NULL, $topic_posts->evaluate(), $specialisation2, NULL, $this->_post_javascript()); $title = get_page_title('_ADD_POST', true, array(escape_html($topic_title))); if (post_param_integer('add_poll', 0) == 1) { // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'add_poll'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); } return do_template('POSTING_SCREEN', array('_GUID' => 'ca2eab9a9ffdab267a48eb7be48ccdc0', 'TEXT' => $text, 'TITLE' => $title, 'POSTING_FORM' => $posting_form)); }
/** * Read in a great big map of details relating to a topic. * * @param ?AUTO_LINK The ID of the topic we are getting details of (NULL: whispers). * @param integer The start row for getting details of posts in the topic (i.e. 0 is start of topic, higher is further through). * @param integer The maximum number of posts to get detail of. * @param boolean Whether we are viewing poll results for the topic (if there is no poll for the topic, this is irrelevant). * @param boolean Whether to check permissions. * @return array The map of details. */ function ocf_read_in_topic($topic_id, $start, $max, $view_poll_results = false, $check_perms = true) { if (!is_null($topic_id)) { $_topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums f ON f.id=t.t_forum_id', array('t.*', 'f.f_is_threaded'), array('t.id' => $topic_id), '', 1); if (!array_key_exists(0, $_topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $topic_info = $_topic_info[0]; // Are we allowed into here? // Check forum $forum_id = $topic_info['t_forum_id']; if (!is_null($forum_id)) { if ($check_perms) { if (!has_category_access(get_member(), 'forums', strval($forum_id))) { access_denied('CATEGORY_ACCESS_LEVEL'); } } } else { // It must be a personal topic. Do we have access? $from = $topic_info['t_pt_from']; $to = $topic_info['t_pt_to']; if ($from != get_member() && $to != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt')) { access_denied('SPECIFIC_PERMISSION', 'view_other_pt'); } decache('_new_pp', array(get_member())); decache('side_ocf_personal_topics', array(get_member())); } // Check validated if ($topic_info['t_validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } } if (is_null(get_param_integer('threaded', NULL))) { if ($start > 0) { if ($topic_info['f_is_threaded'] == 1) { $_GET['threaded'] = '0'; } } } $is_threaded = get_param_integer('threaded', is_null($topic_info['f_is_threaded']) ? 0 : $topic_info['f_is_threaded']); if ($is_threaded != 1) { $is_threaded = 0; } // In case of invalid URLs causing inconsistent handling // Some general info $out = array('num_views' => $topic_info['t_num_views'], 'num_posts' => $topic_info['t_cache_num_posts'], 'validated' => $topic_info['t_validated'], 'title' => $topic_info['t_cache_first_title'], 'description' => $topic_info['t_description'], 'description_link' => $topic_info['t_description_link'], 'emoticon' => $topic_info['t_emoticon'], 'forum_id' => $topic_info['t_forum_id'], 'first_post' => $topic_info['t_cache_first_post'], 'first_poster' => $topic_info['t_cache_first_member_id'], 'first_post_id' => $topic_info['t_cache_first_post_id'], 'pt_from' => $topic_info['t_pt_from'], 'pt_to' => $topic_info['t_pt_to'], 'is_open' => $topic_info['t_is_open'], 'is_threaded' => $is_threaded, 'is_really_threaded' => is_null($topic_info['f_is_threaded']) ? 0 : $topic_info['f_is_threaded'], 'last_time' => $topic_info['t_cache_last_time'], 'meta_data' => array('created' => date('Y-m-d', $topic_info['t_cache_first_time']), 'creator' => $topic_info['t_cache_first_username'], 'publisher' => '', 'modified' => date('Y-m-d', $topic_info['t_cache_last_time']), 'type' => 'Forum topic', 'title' => $topic_info['t_cache_first_title'], 'identifier' => '_SEARCH:topicview:misc:' . strval($topic_id), 'numcomments' => strval($topic_info['t_cache_num_posts']), 'image' => find_theme_image('bigicons/forums'))); // Poll? if (!is_null($topic_info['t_poll_id'])) { require_code('ocf_polls'); $voted_already = $GLOBALS['FORUM_DB']->query_value_null_ok('f_poll_votes', 'pv_member_id', array('pv_poll_id' => $topic_info['t_poll_id'], 'pv_member_id' => get_member())); $out['poll'] = ocf_poll_get_results($topic_info['t_poll_id'], $view_poll_results || !is_null($voted_already)); $out['poll']['voted_already'] = $voted_already; $out['poll_id'] = $topic_info['t_poll_id']; } // Post query $where = ocf_get_topic_where($topic_id); $query = 'SELECT p.*,t.text_parsed AS text_parsed,t.text_original AS message_comcode,h.h_post_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_post_history h ON (h.h_post_id=p.id AND h.h_action_date_and_time=p.p_last_edit_time) LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND p.p_post=t.id WHERE ' . $where . ' ORDER BY p_time,p.id'; } else { $out = array('num_views' => 0, 'num_posts' => 0, 'validated' => 1, 'title' => do_lang('INLINE_PERSONAL_POSTS'), 'description' => '', 'description_link' => '', 'emoticon' => '', 'forum_id' => NULL, 'first_post' => NULL, 'first_poster' => NULL, 'first_post_id' => NULL, 'pt_from' => NULL, 'pt_to' => NULL, 'is_open' => 1, 'is_threaded' => 0, 'last_time' => time(), 'meta_data' => array()); // Post query $where = 'p_intended_solely_for=' . strval(get_member()); $query = 'SELECT p.*,t.text_parsed AS text_parsed,t.text_original AS message_comcode,h.h_post_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_post_history h ON (h.h_post_id=p.id AND h.h_action_date_and_time=p.p_last_edit_time) LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND p.p_post=t.id WHERE ' . $where . ' ORDER BY p_time,p.id'; } // Posts if ($out['is_threaded'] == 0) { $_postdetailss = list_to_map('id', $GLOBALS['FORUM_DB']->query($query, $max, $start)); if ($start == 0 && count($_postdetailss) < $max) { $out['max_rows'] = $max; } else { $out['max_rows'] = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $where); } $posts = array(); // Precache member/group details in one fell swoop $members = array(); foreach ($_postdetailss as $_postdetails) { $members[$_postdetails['p_poster']] = 1; if ($out['title'] == '') { $out['title'] = $_postdetails['p_title']; } } ocf_cache_member_details(array_keys($members)); $i = 0; foreach ($_postdetailss as $_postdetails) { if (is_null($_postdetails['message_comcode'])) { $_postdetails['message_comcode'] = get_translated_text($_postdetails['p_post'], $GLOBALS['FORUM_DB']); } $linked_type = ''; $linked_id = ''; $linked_url = ''; // If it's a spacer post, see if we can detect it better $is_spacer_post = $i == 0 && substr($_postdetails['message_comcode'], 0, strlen('[semihtml]' . do_lang('SPACER_POST_MATCHER'))) == '[semihtml]' . do_lang('SPACER_POST_MATCHER'); if ($is_spacer_post) { $c_prefix = do_lang('COMMENT') . ': #'; if (substr($out['description'], 0, strlen($c_prefix)) == $c_prefix && $out['description_link'] != '') { list($linked_type, $linked_id) = explode('_', substr($out['description'], strlen($c_prefix)), 2); $linked_url = $out['description_link']; $out['description'] = ''; } } // Load post if (get_page_name() == 'search' || is_null($_postdetails['text_parsed']) || $_postdetails['text_parsed'] == '' || $_postdetails['p_post'] == 0) { $_postdetails['message'] = get_translated_tempcode($_postdetails['p_post'], $GLOBALS['FORUM_DB']); } else { $_postdetails['message'] = new ocp_tempcode(); if (!$_postdetails['message']->from_assembly($_postdetails['text_parsed'], true)) { $_postdetails['message'] = get_translated_tempcode($_postdetails['p_post'], $GLOBALS['FORUM_DB']); } } // Fake a quoted post? (kind of a nice 'tidy up' feature if a forum's threading has been turned off, leaving things for flat display) if (!is_null($_postdetails['p_parent_id']) && strpos($_postdetails['message_comcode'], '[quote') === false) { $p = mixed(); // NULL if (array_key_exists($_postdetails['p_parent_id'], $_postdetailss)) { $p = $_postdetailss[$_postdetails['p_parent_id']]; // Load post if (get_page_name() == 'search' || is_null($p['text_parsed']) || $p['text_parsed'] == '' || $p['p_post'] == 0) { $p['message'] = get_translated_tempcode($p['p_post'], $GLOBALS['FORUM_DB']); } else { $p['message'] = new ocp_tempcode(); if (!$p['message']->from_assembly($p['text_parsed'], true)) { $p['message'] = get_translated_tempcode($p['p_post'], $GLOBALS['FORUM_DB']); } } } else { $_p = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $_postdetails['p_parent_id']), '', 1); if (array_key_exists(0, $_p)) { $p = $_p[0]; $p['message'] = get_translated_tempcode($p['p_post'], $GLOBALS['FORUM_DB']); } } $temp = $_postdetails['message']; $_postdetails['message'] = new ocp_tempcode(); $_postdetails['message'] = do_template('COMCODE_QUOTE_BY', array('SAIDLESS' => false, 'BY' => $p['p_poster_name_if_guest'], 'CONTENT' => $p['message'])); $_postdetails['message']->attach($temp); } // Spacer posts may have a better first post put in place if ($is_spacer_post) { require_code('ocf_posts'); list($new_description, $new_post) = ocf_display_spacer_post($linked_type, $linked_id); //if (!is_null($new_description)) $out['description']=$new_description; Actually, it's a bit redundant if (!is_null($new_post)) { $_postdetails['message'] = $new_post; } $out['title'] = do_lang('SPACER_TOPIC_TITLE_WRAP', $out['title']); $_postdetails['p_title'] = do_lang('SPACER_TOPIC_TITLE_WRAP', $_postdetails['p_title']); } // Put together $collated_post_details = ocf_get_details_to_show_post($_postdetails, $start == 0 && count($_postdetailss) == 1); $collated_post_details['is_spacer_post'] = $is_spacer_post; $posts[] = $collated_post_details; $i++; } $out['posts'] = $posts; } // Any special topic/for-any-post-in-topic controls? if (!is_null($topic_id)) { $out['last_poster'] = $topic_info['t_cache_last_member_id']; $out['last_post_id'] = $topic_info['t_cache_last_post_id']; if (is_null($forum_id) || ocf_may_post_in_topic($forum_id, $topic_id, $topic_info['t_cache_last_member_id'])) { $out['may_reply'] = true; } if (ocf_may_report_post()) { $out['may_report_posts'] = true; } if (ocf_may_make_personal_topic()) { $out['may_pt_members'] = true; } if (ocf_may_edit_topics_by($forum_id, get_member(), $topic_info['t_cache_first_member_id'])) { $out['may_edit_topic'] = true; } require_code('ocf_moderation'); require_code('ocf_forums'); if (ocf_may_warn_members()) { $out['may_warn_members'] = true; } if (ocf_may_delete_topics_by($forum_id, get_member(), $topic_info['t_cache_first_member_id'])) { $out['may_delete_topic'] = true; } if (ocf_may_perform_multi_moderation($forum_id)) { $out['may_multi_moderate'] = true; } if (has_specific_permission(get_member(), 'use_quick_reply')) { $out['may_use_quick_reply'] = true; } $may_moderate_forum = ocf_may_moderate_forum($forum_id); if ($may_moderate_forum) { if ($topic_info['t_is_open'] == 0) { $out['may_open_topic'] = 1; } else { $out['may_close_topic'] = 1; } if ($topic_info['t_pinned'] == 0) { $out['may_pin_topic'] = 1; } else { $out['may_unpin_topic'] = 1; } if ($topic_info['t_sunk'] == 0) { $out['may_sink_topic'] = 1; } else { $out['may_unsink_topic'] = 1; } if ($topic_info['t_cascading'] == 0) { $out['may_cascade_topic'] = 1; } else { $out['may_uncascade_topic'] = 1; } $out['may_move_topic'] = 1; $out['may_post_closed'] = 1; $out['may_move_posts'] = 1; $out['may_delete_posts'] = 1; $out['may_validate_posts'] = 1; $out['may_make_personal'] = 1; $out['may_change_max'] = 1; } else { if ($topic_info['t_cache_first_member_id'] == get_member() && has_specific_permission(get_member(), 'close_own_topics') && $topic_info['t_is_open'] == 1) { $out['may_close_topic'] = 1; } } if (!is_null($topic_info['t_poll_id'])) { require_code('ocf_polls'); if (ocf_may_edit_poll_by($forum_id, $topic_info['t_cache_first_member_id'])) { $out['may_edit_poll'] = 1; } if (ocf_may_delete_poll_by($forum_id, $topic_info['t_cache_first_member_id'])) { $out['may_delete_poll'] = 1; } } else { require_code('ocf_polls'); if (ocf_may_attach_poll($topic_id, $topic_info['t_cache_first_member_id'], !is_null($topic_info['t_poll_id']), $forum_id)) { $out['may_attach_poll'] = 1; } } } else { $out['last_poster'] = NULL; $out['last_post_id'] = NULL; $out['may_reply'] = false; } return $out; }
/** * Get a map of details relating to the Private Topics of a certain member. * * @param integer The start row for getting details of topics in the Private Topic forum (i.e. 0 is newest, higher is starting further back in time). * @param ?integer The maximum number of topics to get detail of (NULL: default). * @param ?MEMBER The member to get Private Topics of (NULL: current member). * @return array The details. */ function ocf_get_personal_topics($start = 0, $max = NULL, $member_id = NULL) { if (is_null($max)) { $max = intval(get_option('forum_topics_per_page')); } if (is_null($member_id)) { $member_id = get_member(); } else { if (!has_specific_permission(get_member(), 'view_other_pt') && $member_id != get_member()) { access_denied('SPECIFIC_PERMISSION', 'view_other_pt'); } } // Find topics $where = '(t_pt_from=' . strval($member_id) . ' OR t_pt_to=' . strval($member_id) . ') AND t_forum_id IS NULL'; $filter = get_param('category', ''); $where .= ' AND (' . db_string_equal_to('t_pt_from_category', $filter) . ' AND t_pt_from=' . strval($member_id) . ' OR ' . db_string_equal_to('t_pt_to_category', $filter) . ' AND t_pt_to=' . strval($member_id) . ')'; $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $where; $max_rows = 0; $union = ''; if ($filter == do_lang('INVITED_TO_PTS')) { global $SITE_INFO; if (!(isset($SITE_INFO['mysql_old']) && $SITE_INFO['mysql_old'] == '1' || !isset($SITE_INFO['mysql_old']) && is_file(get_file_base() . '/mysql_old'))) { $or_list = ''; $s_rows = $GLOBALS['FORUM_DB']->query_select('f_special_pt_access', array('s_topic_id'), array('s_member_id' => get_member())); foreach ($s_rows as $s_row) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'id=' . strval($s_row['s_topic_id']); } if ($or_list != '') { $query2 = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $or_list; $union = ' UNION SELECT * ' . $query2; $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query2); } } } $order = get_param('order', 'last_time'); $order2 = 't_cache_last_time DESC'; if ($order == 'first_post') { $order2 = 't_cache_first_time DESC'; } elseif ($order == 'title') { $order2 = 't_cache_first_title ASC'; } if (get_value('disable_sunk') !== '1') { $order2 = 't_sunk ASC,' . $order2; } $topic_rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query . $union . ' ORDER BY t_pinned DESC,' . $order2, $max, $start, false, true); $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); $topics = array(); $hot_topic_definition = intval(get_option('hot_topic_definition')); foreach ($topic_rows as $topic_row) { $topic = array(); $topic['id'] = $topic_row['id']; $topic['num_views'] = $topic_row['t_num_views']; $topic['num_posts'] = $topic_row['t_cache_num_posts']; $topic['first_time'] = $topic_row['t_cache_first_time']; $topic['first_title'] = $topic_row['t_cache_first_title']; $topic['first_post'] = is_null($topic_row['t_cache_first_post']) ? new ocp_tempcode() : get_translated_tempcode($topic_row['t_cache_first_post'], $GLOBALS['FORUM_DB']); $topic['first_post']->singular_bind('ATTACHMENT_DOWNLOADS', make_string_tempcode('?')); $topic['first_username'] = $topic_row['t_cache_first_username']; $topic['first_member_id'] = $topic_row['t_cache_first_member_id']; $topic['last_post_id'] = $topic_row['t_cache_last_post_id']; $topic['last_time'] = $topic_row['t_cache_last_time']; $topic['last_time_string'] = is_null($topic_row['t_cache_last_time']) ? '' : get_timezoned_date($topic_row['t_cache_last_time']); $topic['last_title'] = $topic_row['t_cache_last_title']; $topic['last_username'] = $topic_row['t_cache_last_username']; $topic['last_member_id'] = $topic_row['t_cache_last_member_id']; $topic['emoticon'] = $topic_row['t_emoticon']; $topic['description'] = $topic_row['t_description']; $topic['pt_from'] = $topic_row['t_pt_from']; $topic['pt_to'] = $topic_row['t_pt_to']; // Modifiers $topic['modifiers'] = array(); $has_read = ocf_has_read_topic($topic['id'], $topic_row['t_cache_last_time'], $member_id); if (!$has_read) { $topic['modifiers'][] = 'unread'; } if ($topic_row['t_pinned'] == 1) { $topic['modifiers'][] = 'pinned'; } if ($topic_row['t_sunk'] == 1) { $topic['modifiers'][] = 'sunk'; } if ($topic_row['t_is_open'] == 0) { $topic['modifiers'][] = 'closed'; } if (!is_null($topic_row['t_poll_id'])) { $topic['modifiers'][] = 'poll'; } $num_posts = $topic_row['t_cache_num_posts']; $start_time = $topic_row['t_cache_first_time']; $end_time = $topic_row['t_cache_last_time']; $days = floatval($end_time - $start_time) / 60.0 / 60.0 / 24.0; if ($days == 0.0) { $days = 1.0; } if (intval(round($num_posts / $days)) >= $hot_topic_definition) { $topic['modifiers'][] = 'hot'; } $topics[] = $topic; } $out = array('topics' => $topics, 'max_rows' => $max_rows); if (has_specific_permission($member_id, 'moderate_personal_topic') && ($member_id == get_member() || has_specific_permission($member_id, 'multi_delete_topics'))) { $out['may_move_topics'] = 1; $out['may_delete_topics'] = 1; $out['may_change_max'] = 1; } if (ocf_may_make_personal_topic()) { $out['may_post_topic'] = 1; } return $out; }