/** * 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 show a usergroup. * * @return tempcode The UI */ function usergroup() { $id = get_param_integer('id'); if ($id == db_get_first_id()) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $map = has_specific_permission(get_member(), 'see_hidden_groups') ? array('id' => $id) : array('id' => $id, 'g_hidden' => 0); $groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $map, '', 1); if (!array_key_exists(0, $groups)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $group = $groups[0]; $club = $group['g_is_private_club'] == 1; $name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']); $title = get_page_title($club ? 'CLUB' : 'USERGROUP', true, array(escape_html($name))); // Leadership if (!is_null($group['g_group_leader']) && !is_null($GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']))) { $leader_name = $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']); if (is_null($leader_name)) { $leader_name = do_lang('UNKNOWN'); } $leader_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $group['g_group_leader']), get_module_zone('members')); $leader_link = hyperlink($leader_url, $leader_name, false, true); $leader = paragraph(do_lang_tempcode('GROUP_LED_BY', $leader_link), 'gfgdfggdf'); } else { $leader = new ocp_tempcode(); } // Promotion if (addon_installed('points') && !is_null($group['g_promotion_threshold']) && !is_null($group['g_promotion_target'])) { $promote_link = ocf_get_group_link($group['g_promotion_target']); $promotion_info = do_lang_tempcode('OCF_PROMOTION_INFO', integer_format($group['g_promotion_threshold']), $promote_link->evaluate()); } else { $promotion_info = new ocp_tempcode(); } // To add if (ocf_may_control_group($id, get_member())) { $add_url = build_url(array('page' => '_SELF', 'type' => 'add_to', 'id' => $id), '_SELF'); } else { $add_url = new ocp_tempcode(); } // To apply $my_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(get_member(), false, false); if (is_guest()) { $apply_url = new ocp_tempcode(); $apply_text = new ocp_tempcode(); } else { if (!in_array($id, $my_groups)) { $apply_url = build_url(array('page' => '_SELF', 'type' => 'apply', 'id' => $id), '_SELF'); $apply_text = do_lang_tempcode('APPLY_TO_GROUP'); } elseif (ocf_get_member_primary_group(get_member()) != $id) { $apply_url = build_url(array('page' => '_SELF', 'type' => 'resign', 'id' => $id), '_SELF'); $apply_text = do_lang_tempcode('RESIGN_FROM_GROUP'); } else { $apply_url = new ocp_tempcode(); $apply_text = new ocp_tempcode(); } } require_code('templates_results_table'); $sortables = array(); list($sortable, $sort_order) = explode(' ', get_param('p_sort', 'date_and_time DESC')); // Primary members $start = get_param_integer('p_start', 0); $max = get_param_integer('p_max', 50); $_primary_members = ocf_get_group_members_raw($id, true, true, false, false, $max, $start); if (count($_primary_members) > 0) { $max_rows = ocf_get_group_members_raw_count($id, true, true, false, false); $primary_members = new ocp_tempcode(); foreach ($_primary_members as $i => $primary_member) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($primary_member['gm_member_id'], false, true); $temp = do_template('OCF_VIEW_GROUP_MEMBER', array('_GUID' => 'b96b674ac713e9790ecb78c15af1baab', 'NAME' => $primary_member['m_username'], 'URL' => $url)); $primary_members->attach(results_entry(array($temp))); } $fields_title = results_field_title(array(do_lang_tempcode('PRIMARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $primary_members = results_table(do_lang_tempcode('PRIMARY_MEMBERS'), $start, 'p_start', $max, 'p_max', $max_rows, $fields_title, $primary_members, $sortables, $sortable, $sort_order, 'p_sort', NULL, NULL, NULL, 6); } else { $primary_members = new ocp_tempcode(); } $edit_url = new ocp_tempcode(); $s_start = get_param_integer('s_start', 0); $s_max = get_param_integer('s_max', 50); $_secondary_members = ocf_get_group_members_raw($id, false, true, true, ocf_may_control_group($id, get_member()), $s_max, $s_start); $secondary_members = new ocp_tempcode(); $prospective_members = new ocp_tempcode(); $s_max_rows = ocf_get_group_members_raw_count($id, false, false, true, ocf_may_control_group($id, get_member())); $d_max_rows = ocf_get_group_members_raw_count($id, false, true, true, ocf_may_control_group($id, get_member())); foreach ($_secondary_members as $secondary_member) { $m_username = $GLOBALS['FORUM_DRIVER']->get_member_row_field($secondary_member['gm_member_id'], 'm_username'); if (is_null($m_username)) { continue; } if ($secondary_member['gm_validated'] == 1) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true); $remove_url = build_url(array('page' => '_SELF', 'type' => 'remove_from', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $temp = do_template('OCF_VIEW_GROUP_MEMBER' . (ocf_may_control_group($id, get_member()) ? '_SECONDARY' : ''), array('REMOVE_URL' => $remove_url, 'NAME' => $m_username, 'URL' => $url)); $secondary_members->attach(results_entry(array($temp))); } elseif (!$add_url->is_empty()) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true); $accept_url = build_url(array('page' => '_SELF', 'type' => 'accept', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $decline_url = build_url(array('page' => '_SELF', 'type' => 'decline', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $temp = do_template('OCF_VIEW_GROUP_MEMBER_PROSPECTIVE', array('_GUID' => '16e93cf50a14e3b6a3bdf31525fd5e7f', 'ACCEPT_URL' => $accept_url, 'DECLINE_URL' => $decline_url, 'NAME' => $m_username, 'URL' => $url)); $prospective_members->attach(results_entry(array($temp))); } } if (!$secondary_members->is_empty()) { $fields_title = results_field_title(array(do_lang_tempcode('SECONDARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $secondary_members = results_table(do_lang_tempcode('SECONDARY_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $s_max_rows, $fields_title, $secondary_members, $sortables, $sortable, $sort_order, 's_sort', NULL, NULL, NULL, 6); } if (!$prospective_members->is_empty()) { $fields_title = results_field_title(array(do_lang_tempcode('PROSPECTIVE_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $prospective_members = results_table(do_lang_tempcode('PROSPECTIVE_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $d_max_rows, $fields_title, $prospective_members, $sortables, $sortable, $sort_order, 'd_sort', NULL, NULL, NULL, 6); } elseif (has_actual_page_access(get_member(), 'cms_ocf_groups', get_module_zone('cms_ocf_groups'))) { $is_super_admin = $group['g_is_super_admin']; if (!has_specific_permission(get_member(), 'control_usergroups') || $is_super_admin == 1) { $leader_tmp = $group['g_group_leader']; if ($leader_tmp == get_member()) { $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups')); } } else { $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups')); } } breadcrumb_set_self(make_string_tempcode(escape_html($name))); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USERGROUPS')))); if (has_actual_page_access(get_member(), 'admin_ocf_groups', get_module_zone('admin_ocf_groups'))) { $edit_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('admin_ocf_groups')); } $club_forum = NULL; if ($group['g_is_private_club'] == 1) { $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', $name))); } $group_name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']); $GLOBALS['META_DATA'] += array('created' => '', 'creator' => is_null($group['g_group_leader']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']), 'publisher' => '', 'modified' => '', 'type' => 'Usergroup', 'title' => $group_name, 'identifier' => '_SEARCH:groups:view:' . strval($id), 'description' => '', 'image' => find_theme_image('bigicons/usergroups')); require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $forum_id = NULL; if ($club) { $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $group_name, 'f_category_id' => intval(get_option('club_forum_parent_category')), 'f_parent_forum' => intval(get_option('club_forum_parent_forum')))); } return do_template('OCF_VIEW_GROUP_SCREEN', array('_GUID' => 'fc6cac5c73f92ab4410b492d58976dbe', 'GROUP_NAME' => $group_name, 'ID' => strval($id), 'FORUM' => is_null($forum_id) ? '' : strval($forum_id), 'CLUB' => $club, 'EDIT_URL' => $edit_url, 'TITLE' => $title, 'LEADER' => $leader, 'PROMOTION_INFO' => $promotion_info, 'ADD_URL' => $add_url, 'APPLY_URL' => $apply_url, 'APPLY_TEXT' => $apply_text, 'PRIMARY_MEMBERS' => $primary_members, 'SECONDARY_MEMBERS' => $secondary_members, 'PROSPECTIVE_MEMBERS' => $prospective_members)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_css('side_blocks'); $count = 0; $members = get_online_members(false, NULL, $count); if (is_null($members)) { return new ocp_tempcode(); } // Too many to show if (get_forum_type() == 'ocf') { require_code('ocf_general'); require_code('ocf_members'); require_css('ocf'); } $out = new ocp_tempcode(); $guests = 0; $_members = 0; $done_members = array(); $done_ips = array(); foreach ($members as $_member) { $member = $_member['the_user']; $name = $_member['cache_username']; $ip = $_member['ip']; if (is_guest($member) || is_null($name)) { if (!array_key_exists($ip, $done_ips)) { $done_ips[$ip] = 1; $guests++; } } else { if (!array_key_exists($member, $done_members)) { $colour = get_forum_type() == 'ocf' ? get_group_colour(ocf_get_member_primary_group($member)) : NULL; $done_members[$member] = 1; $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, true, true); $out->attach(do_template('BLOCK_SIDE_USERS_ONLINE_USER', array('_GUID' => 'a0b55810fe2f306c2886ec0c4cd8e8fd', 'URL' => $url, 'NAME' => $name, 'COLOUR' => $colour))); $_members++; } } } $newest = new ocp_tempcode(); $birthdays = new ocp_tempcode(); if (get_forum_type() == 'ocf') { require_lang('ocf'); // Show newest member if (get_option('usersonline_show_newest_member', true) == '1') { $newest_member = $GLOBALS['FORUM_DB']->query_select('f_members', array('m_username', 'id'), array('m_validated' => 1), 'ORDER BY id DESC', 1); $username_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($newest_member[0]['id'], false, $newest_member[0]['m_username']); $newest->attach(paragraph(do_lang_tempcode('NEWEST_MEMBER_WELCOME', $username_link), 'gdgdfhrug')); } // Birthdays if (get_option('usersonline_show_birthdays', true) == '1') { require_code('ocf_members'); $_birthdays = ocf_find_birthdays(); foreach ($_birthdays as $_birthday) { $colour = get_group_colour(ocf_get_member_primary_group($_birthday['id'])); $birthday = do_template('OCF_USER_MEMBER', array('_GUID' => 'b2d355ff45f4b4170b937ef0753e6a78', 'COLOUR' => $colour, 'AGE' => array_key_exists('age', $_birthday) ? integer_format($_birthday['age']) : NULL, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_birthday['id'], false, true), 'USERNAME' => $_birthday['username'])); $birthdays->attach($birthday); } if (!$birthdays->is_empty()) { $birthdays = do_template('OCF_BIRTHDAYS', array('_GUID' => '080ed2e74efd6410bd6b83ec01962c04', 'BIRTHDAYS' => $birthdays)); } } } return do_template('BLOCK_SIDE_USERS_ONLINE', array('_GUID' => 'fdfa68dff479b4ea7d517585297ea6af', 'CONTENT' => $out, 'GUESTS' => integer_format($guests), 'MEMBERS' => integer_format($_members), '_GUESTS' => strval($guests), '_MEMBERS' => strval($_members), 'BIRTHDAYS' => $birthdays, 'NEWEST' => $newest)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_topicview'); require_css('ocf'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $NON_CANONICAL_PARAMS[] = 'start'; $NON_CANONICAL_PARAMS[] = 'threaded'; $start = get_param_integer('start', 0); $default_max = intval(get_option('forum_posts_per_page')); $max = get_param_integer('max', $default_max); if ($max == 0) { $max = $default_max; } if ($max == 0) { $max = 1; } if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) { $max = $default_max; } $first_unread_id = -1; global $NON_CANONICAL_PARAMS; foreach (array_keys($_GET) as $key) { if (substr($key, 0, 3) == 'kfs') { $NON_CANONICAL_PARAMS[] = $key; } } $type = get_param('type', 'misc'); $id = get_param_integer('id', NULL); if (is_guest() && is_null($id)) { access_denied('NOT_AS_GUEST'); } if ($type == 'findpost') { $post_id = get_param_integer('id'); $redirect = find_post_id_url($post_id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } else { if ($type == 'first_unread') { $redirect = find_first_unread_url($id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } } if (!is_null($id)) { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id); } $view_poll_results = get_param_integer('view_poll_results', 0); // Mark as read if (!is_null($id)) { if (!is_guest()) { $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true); // race condition } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true); } // Load up topic info $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1); $GLOBALS['META_DATA'] += $topic_info['meta_data']; global $SEO_TITLE; $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']); // Render posts according to whether threaded or not $threaded = $topic_info['is_threaded'] == 1; $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info)); if (!$threaded) { $GLOBALS['META_DATA']['description'] = $topic_info['description']; // Poster detail hooks $hooks = find_all_hooks('modules', 'topicview'); $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } // Render non-threaded $posts = new ocp_tempcode(); $replied = false; if (is_null($topic_info['forum_id'])) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $second_poster = $topic_info['first_poster']; foreach ($topic_info['posts'] as $array_id => $_postdetails) { if ($array_id == 0) { $description = $topic_info['description']; } else { $description = NULL; } if ($_postdetails['poster'] == get_member()) { $replied = true; } if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) { $second_poster = $_postdetails['poster']; } if (array_key_exists('last_edit_time', $_postdetails)) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username'])); } else { $last_edited = new ocp_tempcode(); } $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0'; $is_spacer_post = $_postdetails['is_spacer_post']; // Post buttons $buttons = new ocp_tempcode(); if (!$is_spacer_post) { $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply); } // Avatar if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') { $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar'])); } else { $post_avatar = new ocp_tempcode(); } // Rank images $rank_images = new ocp_tempcode(); if (!$is_spacer_post) { $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster']))); } } } // Poster details if (!$is_spacer_post) { if (!is_guest($_postdetails['poster'])) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); if (array_key_exists('ip_address', $_postdetails)) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address']))); $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields)); } else { $poster_details = new ocp_tempcode(); } } } else { $poster_details = new ocp_tempcode(); } if (!is_guest($_postdetails['poster'])) { $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL)); } else { $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode(); $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username'])); } // Signature $signature = new ocp_tempcode(); if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) { $signature = $_postdetails['signature']; } $post_title = $_postdetails['title']; $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode(); $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode(); $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $emphasis = ocf_get_post_emphasis($_postdetails); require_code('feedback'); if (!array_key_exists('intended_solely_for', $_postdetails)) { actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']); $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']); } else { $rating = new ocp_tempcode(); } $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating)); $posts->attach($rendered_post); } $serialized_options = mixed(); $hash = mixed(); } else { require_code('topics'); $threaded_topic_ob = new OCP_Topic(); // Load some settings into the renderer $threaded_topic_ob->first_post_id = $topic_info['first_post_id']; $threaded_topic_ob->topic_description = $topic_info['description']; $threaded_topic_ob->topic_description_link = $topic_info['description_link']; $threaded_topic_ob->topic_title = $topic_info['title']; $threaded_topic_ob->topic_info = $topic_info; // Other settings we need $max_thread_depth = intval(get_option('max_thread_depth')); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); // Load posts $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true); $threaded_topic_ob->is_threaded = true; // Render posts list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false); $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description; // Get other gathered details $replied = $threaded_topic_ob->replied; if (!is_null($threaded_topic_ob->topic_title)) { // Updated topic title $topic_info['title'] = $threaded_topic_ob->topic_title; } $topic_info['max_rows'] = $threaded_topic_ob->total_posts; $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id(); // No definitive post orders } // Buttons for topic as whole $button_array = array(); if (!is_null($id)) { if (get_value('no_threaded_buttons') !== '1') { if ($threaded) { $view_as_linear_url = get_self_url(false, false, array('threaded' => 0)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear'); } else { $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded'); } } if (!is_guest()) { $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days')); if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) { $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $mark_unread_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread'); } } if ($may_reply && is_null(get_bot_type())) { $reply_prevented = false; // "Staff-only" reply for support tickets if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) { require_code('tickets'); if (is_ticket_forum($topic_info['forum_id'])) { if (is_guest($second_poster)) { $reply_prevented = true; } require_lang('tickets'); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id()); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply'); } } if (!$reply_prevented) { if ($topic_info['is_threaded'] == 0) { $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed'); } } else { unset($topic_info['may_use_quick_reply']); } } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) { $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']); $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1); if ($test != -1 && $test != 0) { $map['kfs' . strval($topic_info['forum_id'])] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend'); } if (!is_null($topic_info['forum_id'])) { if (get_value('disable_add_topic_btn_in_topic') !== '1') { if (ocf_may_post_topic($topic_info['forum_id'], get_member())) { $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic'); } } } else { $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member'); } } $buttons = ocf_screen_button_wrap($button_array); // Poll if (array_key_exists('poll', $topic_info)) { $_poll = $topic_info['poll']; $voted_already = $_poll['voted_already']; $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]); $answers = new ocp_tempcode(); $real_button = false; if ($_poll['is_open']) { if ($poll_results) { $button = new ocp_tempcode(); } elseif ($_poll['requires_reply'] && !$replied) { $button = do_lang_tempcode('POLL_REQUIRES_REPLY'); } else { if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) { $button = do_lang_tempcode('VOTE_DENIED'); } else { if (!is_null($voted_already)) { $button = do_lang_tempcode('NOVOTE'); } else { require_lang('polls'); $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $results_url = build_url($map, get_module_zone('topics')); $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url)); $real_button = true; } } } } else { $button = do_lang_tempcode('TOPIC_POLL_CLOSED'); } foreach ($_poll['answers'] as $answer) { if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) { $num_votes = $answer['num_votes']; $total_votes = $_poll['total_votes']; if ($total_votes != 0) { $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes))); } else { $width = 0; } $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } else { $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } $answers->attach($answer_tpl); } $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $vote_url = build_url($map, get_module_zone('topics')); if ($_poll['is_private']) { $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs'); } else { $private = new ocp_tempcode(); } if ($_poll['maximum_selections'] > 1) { $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs'); } else { $num_choices = new ocp_tempcode(); } $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections']))); } else { $poll = new ocp_tempcode(); } // Forum nav tree if (!is_null($topic_info['forum_id'])) { $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false); } else { $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); $tree->attach(do_template('BREADCRUMB_ESCAPED')); if (has_specific_permission(get_member(), 'view_other_pt')) { $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to']; } else { $of_member = get_member(); } $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member); if (is_null($of_username)) { $of_username = do_lang('UNKNOWN'); } $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); } // Quick reply if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) { $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_post_url = build_url($map, get_module_zone('topics')); $post_url = $_post_url->evaluate(); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $more_url = build_url($map, get_module_zone('topics')); $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode(); $first_post = $_postdetails; $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); $display = 'block'; $expand_type = 'contract'; if ($topic_info['max_rows'] > $start + $max) { $display = 'none'; $expand_type = 'expand'; } $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $post_warning = ''; if ($topic_info['is_really_threaded'] == 1) { $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning); } $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'))); } else { $quick_reply = new ocp_tempcode(); } $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics')); if (!is_null($id)) { // Moderation options $moderator_actions = ''; if (is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>'; } if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) { $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']); if (count($multi_moderations) != 0) { $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">'; foreach ($multi_moderations as $mm_id => $mm_name) { $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>'; } $moderator_actions .= '</optgroup>'; } } if (array_key_exists('may_move_topic', $topic_info)) { $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_topic', $topic_info)) { $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>'; } if (array_key_exists('may_delete_topic', $topic_info)) { $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>'; } if (array_key_exists('may_pin_topic', $topic_info)) { $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>'; } if (array_key_exists('may_unpin_topic', $topic_info)) { $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>'; } if (array_key_exists('may_sink_topic', $topic_info)) { $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>'; } if (array_key_exists('may_unsink_topic', $topic_info)) { $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>'; } if (array_key_exists('may_cascade_topic', $topic_info)) { $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_uncascade_topic', $topic_info)) { $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_open_topic', $topic_info)) { $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>'; } if (array_key_exists('may_close_topic', $topic_info)) { $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_poll', $topic_info)) { $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_delete_poll', $topic_info)) { $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_attach_poll', $topic_info)) { $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>'; } if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) { $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>'; } if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>'; } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } // Marked post actions $map = array('page' => 'topics', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics'), NULL, false, true); $marked_post_actions = ''; if (array_key_exists('may_move_posts', $topic_info)) { $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>'; $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>'; } if (array_key_exists('may_delete_posts', $topic_info)) { $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>'; } if (array_key_exists('may_validate_posts', $topic_info)) { $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>'; } if (get_value('disable_multi_quote') !== '1') { if ($may_reply) { $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>'; } } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($marked_post_actions); } } else { $moderator_actions = ''; $marked_post_actions = ''; } $max_rows = $topic_info['max_rows']; if ($max_rows > $max && !$threaded) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30)); } else { $results_browser = new ocp_tempcode(); } // Members viewing this topic $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true); $num_guests = 0; $num_members = 0; if (is_null($members)) { $members_viewing = new ocp_tempcode(); } else { $members_viewing = new ocp_tempcode(); foreach ($members as $member_id => $at_details) { $username = $at_details['mt_cache_username']; if (is_guest($member_id)) { $num_guests++; } else { $num_members++; $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username); if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) { $map['AT'] = escape_html($at_details['the_title']); } $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id)); $members_viewing->attach(do_template('OCF_USER_MEMBER', $map)); } } if ($members_viewing->is_empty()) { $members_viewing = do_lang_tempcode('NONE_EM'); } } if (!is_null($id)) { breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC')); } if (is_null($id)) { $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id())); $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO')); breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS')); } if ($topic_info['validated'] == 0) { $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded)); if (is_null($id)) { $title = get_page_title('INLINE_PERSONAL_POSTS'); } else { if (is_null($topic_info['forum_id'])) { $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC')); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('topic', strval($id)); } else { $awards = array(); } $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards); } } return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']); }
/** * Get details on a member profile. * * @param MEMBER The member to get details of. * @param boolean Whether to get a 'lite' version (contains less detail, therefore less costly). * @return array A map of details. */ function ocf_read_in_member_profile($member_id, $lite = true) { $row = $GLOBALS['OCF_DRIVER']->get_member_row($member_id); if (is_null($row)) { return array(); } $last_visit_time = $member_id == get_member() && array_key_exists('last_visit', $_COOKIE) ? intval($_COOKIE['last_visit']) : $row['m_last_visit_time']; $join_time = $row['m_join_time']; $out = array('username' => $row['m_username'], 'last_visit_time' => $last_visit_time, 'last_visit_time_string' => get_timezoned_date($last_visit_time), 'signature' => $row['m_signature'], 'posts' => $row['m_cache_num_posts'], 'join_time' => $join_time, 'join_time_string' => get_timezoned_date($join_time)); if (addon_installed('points')) { require_code('points'); $num_points = total_points($member_id); $out['points'] = $num_points; } if (!$lite) { $out['groups'] = ocf_get_members_groups($member_id); // Custom fields $out['custom_fields'] = ocf_get_all_custom_fields_match_member($member_id, get_member() != $member_id && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, get_member() != $member_id && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL); // Birthdate if ($row['m_reveal_age'] == 1) { $out['birthdate'] = $row['m_dob_year'] . '/' . $row['m_dob_month'] . '/' . $row['m_dob_day']; } // Find title if (addon_installed('ocf_member_titles')) { $title = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_title'); if ($title == '') { $primary_group = ocf_get_member_primary_group($member_id); $title = ocf_get_group_property($primary_group, $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'title')); } if ($title != '') { $out['title'] = $title; } } // Find photo $photo = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_photo_thumb_url'); if ($photo != '' && addon_installed('ocf_member_photos')) { if (url_is_local($photo)) { $photo = get_complex_base_url($photo) . '/' . $photo; } $out['photo'] = $photo; } // Any warnings? if (has_specific_permission(get_member(), 'see_warnings') && addon_installed('ocf_warnings')) { $out['warnings'] = ocf_get_warnings($member_id); } } // Find avatar $avatar = $GLOBALS['OCF_DRIVER']->get_member_avatar_url($member_id); if ($avatar != '') { $out['avatar'] = $avatar; } // Primary usergroup $primary_group = ocf_get_member_primary_group($member_id); $out['primary_group'] = $primary_group; $out['primary_group_name'] = ocf_get_group_name($primary_group); // Find how many points we need to advance if (addon_installed('points')) { $promotion_threshold = ocf_get_group_property($primary_group, 'promotion_threshold'); if (!is_null($promotion_threshold)) { $num_points_advance = $promotion_threshold - $num_points; $out['num_points_advance'] = $num_points_advance; } } return $out; }
/** * Render a topic row (i.e. a row in a forum or results view), from given details (from ocf_get_topic_array). * * @param array The details (array containing: last_post_id, id, modifiers, emoticon, first_member_id, first_username, first_post, num_posts, num_views). * @param boolean Whether the viewing member has the facility to mark off topics (send as false if there are no actions for them to perform). * @param boolean Whether the topic is a Private Topic. * @param ?string The forum name (NULL: do not show the forum name). * @return tempcode The topic row. */ function ocf_render_topic($topic, $has_topic_marking, $pt = false, $show_forum = NULL) { if (array_key_exists('last_post_id', $topic) && !is_null($topic['last_post_id'])) { $last_post_url = build_url(array('page' => 'topicview', 'id' => $topic['last_post_id'], 'type' => 'findpost'), get_module_zone('topicview')); $last_post_url->attach('#post_' . strval($topic['last_post_id'])); if (!is_null($topic['last_member_id'])) { if ($topic['last_member_id'] != $GLOBALS['OCF_DRIVER']->get_guest_id()) { //$colour=get_group_colour(ocf_get_member_primary_group($topic['last_member_id'])); $poster = do_template('OCF_USER_MEMBER', array('USERNAME' => $topic['last_username'], 'PROFILE_URL' => $GLOBALS['OCF_DRIVER']->member_profile_url($topic['last_member_id'], false, true))); } else { $poster = protect_from_escaping(escape_html($topic['last_username'] == '' ? do_lang('SYSTEM') : $topic['last_username'])); } } else { $poster = do_lang_tempcode('NA'); } $last_post = do_template('OCF_FORUM_TOPIC_ROW_LAST_POST', array('_GUID' => '6aa8d0f4024ae12bf94b68b74faae7cf', 'ID' => strval($topic['id']), 'DATE_RAW' => strval($topic['last_time']), 'DATE' => $topic['last_time_string'], 'POSTER' => $poster, 'LAST_URL' => $last_post_url)); } else { $last_post = do_lang_tempcode('NA_EM'); } $map = array('page' => 'topicview', 'id' => $topic['id']); if (array_key_exists('forum_id', $topic) && is_null(get_bot_type()) && get_param_integer('start', 0) != 0) { $map['kfs' . strval($topic['forum_id'])] = get_param_integer('start', 0); } $url = build_url($map, get_module_zone('topicview')); // Modifiers $topic_row_links = new ocp_tempcode(); $modifiers = $topic['modifiers']; if (in_array('unread', $modifiers)) { $first_unread_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'first_unread'), get_module_zone('topicview')); $first_unread_url->attach('#first_unread'); $topic_row_links->attach(do_template('OCF_TOPIC_ROW_LINK', array('_GUID' => '6f52881ed999f4c543c9d8573b37fa48', 'URL' => $first_unread_url, 'IMG' => 'unread', 'ALT' => do_lang_tempcode('JUMP_TO_FIRST_UNREAD')))); } $topic_row_modifiers = new ocp_tempcode(); foreach ($modifiers as $modifier) { if ($modifier != 'unread') { $topic_row_modifiers->attach(do_template('OCF_TOPIC_ROW_MODIFIER', array('_GUID' => 'fbcb8791b571187fd699aa6796c3f401', 'IMG' => $modifier, 'ALT' => do_lang_tempcode('MODIFIER_' . $modifier)))); } } // Emoticon if ($topic['emoticon'] != '') { $emoticon = do_template('OCF_TOPIC_EMOTICON', array('_GUID' => 'dfbe0e4a11b3caa4d2da298ff23ca221', 'EMOTICON' => $topic['emoticon'])); } else { $emoticon = do_template('OCF_TOPIC_EMOTICON_NONE'); } if ($topic['first_member_id'] != $GLOBALS['OCF_DRIVER']->get_guest_id()) { $poster_profile_url = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['first_member_id'], false, true); //$colour=get_group_colour(ocf_get_member_primary_group($topic['first_member_id'])); $poster = do_template('OCF_USER_MEMBER', array('PROFILE_URL' => $poster_profile_url, 'USERNAME' => $topic['first_username'])); } else { $poster = make_string_tempcode(escape_html($topic['first_username'])); } if ($pt) { $with = $topic['pt_from'] == $topic['first_member_id'] ? $topic['pt_to'] : $topic['pt_from']; $with_username = $GLOBALS['OCF_DRIVER']->get_username($with); if (is_null($with_username)) { $with_username = do_lang('UNKNOWN'); } $colour = get_group_colour(ocf_get_member_primary_group($with)); $b = do_template('OCF_USER_MEMBER', array('COLOUR' => $colour, 'PROFILE_URL' => $GLOBALS['OCF_DRIVER']->member_profile_url($with, false, true), 'USERNAME' => $with_username)); $poster = do_template('OCF_PT_BETWEEN', array('_GUID' => '619cd7076c4baf7b26cb3149694af929', 'A' => $poster, 'B' => $b)); } // Marker $marker = new ocp_tempcode(); if ($has_topic_marking) { $marker = do_template('OCF_TOPIC_MARKER', array('_GUID' => '62ff977640d3d4270cf333edab42a18f', 'ID' => strval($topic['id']))); } // Title $title = $topic['first_title']; // Page jump $max = intval(get_option('forum_posts_per_page')); require_code('templates_result_launcher'); $pages = results_launcher(do_lang_tempcode('NAMED_TOPIC', escape_html($title)), 'topicview', $topic['id'], $max, $topic['num_posts'], 'view', 5); // Tpl $post = $topic['first_post']; if (!is_null($show_forum)) { $hover = do_lang_tempcode('FORUM_AND_TIME_HOVER', escape_html($show_forum), escape_html(get_timezoned_date($topic['first_time']))); $breadcrumbs = ocf_forum_breadcrumbs($topic['forum_id'], NULL, NULL, false); } else { $hover = protect_from_escaping(is_null($topic['first_time']) ? '' : escape_html(get_timezoned_date($topic['first_time']))); $breadcrumbs = new ocp_tempcode(); } return do_template('OCF_FORUM_TOPIC_ROW', array('_GUID' => '1aca672272132f390c9ec23eebe0d171', 'BREADCRUMBS' => $breadcrumbs, 'RAW_TIME' => is_null($topic['first_time']) ? '' : strval($topic['first_time']), 'UNREAD' => in_array('unread', $modifiers), 'ID' => strval($topic['id']), 'HOVER' => $hover, 'PAGES' => $pages, 'MARKER' => $marker, 'TOPIC_ROW_LINKS' => $topic_row_links, 'TOPIC_ROW_MODIFIERS' => $topic_row_modifiers, 'POST' => $post, 'EMOTICON' => $emoticon, 'DESCRIPTION' => $topic['description'], 'URL' => $url, 'TITLE' => $title, 'POSTER' => $poster, 'NUM_POSTS' => integer_format($topic['num_posts']), 'NUM_VIEWS' => integer_format($topic['num_views']), 'LAST_POST' => $last_post)); }
/** * Standard modular run function for rendering a search result. * * @param array The data row stored when we retrieved the result * @return array The output */ function render_tabular($row) { $member_id = $row['id']; $preview = true; if (get_forum_type() != 'ocf') { return array(); } $username = $GLOBALS['OCF_DRIVER']->get_username($member_id); if (is_null($username)) { return array(); } require_lang('ocf'); require_code('ocf_groups'); $_lines = array(); $primary_group = ocf_get_member_primary_group($member_id); if (is_null($primary_group)) { return array(); } if (addon_installed('galleries') && get_option('show_gallery_counts') == '1') { $num_galleries = $GLOBALS['SITE_DB']->query('SELECT COUNT(*) AS cnt FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name LIKE \'' . db_encode_like('member_' . strval($member_id) . '_%') . '\''); } $_lines += array(do_lang('USERNAME') => hyperlink($GLOBALS['OCF_DRIVER']->member_profile_url($member_id, false, true), $username, false, true), do_lang('JOIN_DATE') => escape_html(get_timezoned_date($GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_join_time'), false))); if (get_option('show_gallery_counts') == '1' && addon_installed('galleries')) { if ($num_galleries[0]['cnt'] > 1) { require_lang('galleries'); $_lines[do_lang('GALLERIES')] = escape_html(integer_format($num_galleries[0]['cnt'])); } } $day = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_day'); $month = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_month'); $year = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_year'); if ($GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_reveal_age') == 1 && !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); } $_lines[do_lang('DATE_OF_BIRTH')] = escape_html($dob); } $fields = ocf_get_all_custom_fields_match_member($member_id, get_member() != $member_id && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, get_member() == $member_id && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, NULL, 0, NULL, $preview ? NULL : 1, $preview ? 1 : NULL); foreach ($fields as $key => $val) { if (is_string($val['RAW']) && $val['RAW'] != '' || is_object($val['RAW']) && !$val['RAW']->is_empty()) { $_lines[$key] = $val['RENDERED']; } } if (!$preview && addon_installed('ocf_contactmember') && has_actual_page_access(get_member(), 'contactmember')) { $redirect = get_self_url(true); $email_member_url = build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id), get_module_zone('contactmember')); $_lines[do_lang('ACTIONS')] = hyperlink($email_member_url, do_lang_tempcode('_EMAIL_MEMBER')); } return $_lines; }
/** * From a member profile-row, get the member's primary usergroup. * * @param array The profile-row * @return GROUP The member's primary usergroup */ function pname_group($r) { require_code('ocf_members'); return ocf_get_member_primary_group($r['id']); }
/** * Turn a post row, into a detailed map of information that is suitable for use as display parameters for that post. * * @param array The post row. * @param boolean Whether the post is the only post in the topic. * @return array The detailed map. */ function ocf_get_details_to_show_post($_postdetails, $only_post = false) { $forum_id = $_postdetails['p_cache_forum_id']; $primary_group = ocf_get_member_primary_group($_postdetails['p_poster']); if (is_null($primary_group)) { $_postdetails['p_poster'] = db_get_first_id(); $primary_group = db_get_first_id(); } $post = array('id' => $_postdetails['id'], 'topic_id' => $_postdetails['p_topic_id'], 'title' => $_postdetails['p_title'], 'post' => $_postdetails['message'], 'time' => $_postdetails['p_time'], 'time_string' => get_timezoned_date($_postdetails['p_time']), 'validated' => $_postdetails['p_validated'], 'is_emphasised' => $_postdetails['p_is_emphasised'], 'poster_username' => $_postdetails['p_poster_name_if_guest'], 'poster' => $_postdetails['p_poster'], 'has_history' => !is_null($_postdetails['h_post_id'])); if (array_key_exists('message_comcode', $_postdetails)) { $post['message_comcode'] = $_postdetails['message_comcode']; } // Edited? if (!is_null($_postdetails['p_last_edit_by'])) { $post['last_edit_by'] = $_postdetails['p_last_edit_by']; $post['last_edit_time'] = $_postdetails['p_last_edit_time']; $post['last_edit_time_string'] = get_timezoned_date($_postdetails['p_last_edit_time']); $post['last_edit_by_username'] = $GLOBALS['OCF_DRIVER']->get_username($_postdetails['p_last_edit_by']); if ($post['last_edit_by_username'] == '') { $post['last_edit_by_username'] = do_lang('UNKNOWN'); } // Shouldn't happen, but imported data can be weird } // Find title $title = addon_installed('ocf_member_titles') ? $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_title') : ''; if ($title == '') { $title = get_translated_text(ocf_get_group_property($primary_group, 'title'), $GLOBALS['FORUM_DB']); } $post['poster_title'] = $title; // If this isn't guest posted, we can put some member details in if (!is_null($_postdetails['p_poster']) && $_postdetails['p_poster'] != $GLOBALS['OCF_DRIVER']->get_guest_id()) { if (addon_installed('points')) { require_code('points'); $post['poster_points'] = total_points($_postdetails['p_poster']); } $post['poster_posts'] = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_cache_num_posts'); $post['poster_highlighted_name'] = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_highlighted_name'); // Signature if (($GLOBALS['OCF_DRIVER']->get_member_row_field(get_member(), 'm_views_signatures') == 1 || get_value('disable_views_sigs_option') === '1') && $_postdetails['p_skip_sig'] == 0 && addon_installed('ocf_signatures')) { global $SIGNATURES_CACHE; if (array_key_exists($_postdetails['p_poster'], $SIGNATURES_CACHE)) { $sig = $SIGNATURES_CACHE[$_postdetails['p_poster']]; } else { $sig = get_translated_tempcode($GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_signature'), $GLOBALS['FORUM_DB']); $SIGNATURES_CACHE[$_postdetails['p_poster']] = $sig; } $post['signature'] = $sig; } // Any custom fields to show? $post['custom_fields'] = ocf_get_all_custom_fields_match_member($_postdetails['p_poster'], get_member() != $_postdetails['p_poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, get_member() == $_postdetails['p_poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, NULL, NULL, NULL, 1); // Usergroup $post['primary_group'] = $primary_group; $post['primary_group_name'] = ocf_get_group_name($primary_group); // Find avatar $avatar = $GLOBALS['OCF_DRIVER']->get_member_avatar_url($_postdetails['p_poster']); if ($avatar != '') { $post['poster_avatar'] = $avatar; } // Any warnings? if (has_specific_permission(get_member(), 'see_warnings') && addon_installed('ocf_warnings')) { $num_warnings = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_cache_warnings'); /*if ($num_warnings!=0)*/ $post['poster_num_warnings'] = $num_warnings; } // Join date $post['poster_join_date'] = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['p_poster'], 'm_join_time'); $post['poster_join_date_string'] = get_timezoned_date($post['poster_join_date']); } elseif ($_postdetails['p_poster'] == $GLOBALS['OCF_DRIVER']->get_guest_id()) { if ($_postdetails['p_poster_name_if_guest'] == do_lang('SYSTEM')) { $post['poster_avatar'] = find_theme_image('ocf_default_avatars/default_set/ocp_fanatic', true); } } // Do we have any special controls over this post? require_code('ocf_posts'); if (ocf_may_edit_post_by($_postdetails['p_poster'], $forum_id)) { $post['may_edit'] = true; } if (ocf_may_delete_post_by($_postdetails['p_poster'], $forum_id) && !$only_post) { $post['may_delete'] = true; } // More if (has_specific_permission(get_member(), 'see_ip')) { $post['ip_address'] = $_postdetails['p_ip_address']; } if (!is_null($_postdetails['p_intended_solely_for'])) { $post['intended_solely_for'] = $_postdetails['p_intended_solely_for']; } return $post; }
/** * Get tempcode for a mouseover for a member. For use with OCF_POSTER_MEMBER.tpl. * * @param mixed Either a member ID or an array containing: ip_address, poster_num_warnings, poster, poster_posts, poster_points, poster_join_date_string, primary_group_name. * @param boolean Whether only to show 'preview' details * @param ?array An array of hooks. (NULL: lookup) * @param ?array An array of hook objects that allow us to collect additional mouse-over member information. (NULL: lookup) * @param boolean Whether to show the avatar * @param ?array Map of extra fields to show (NULL: none) * @return tempcode The mouseover tempcode */ function ocf_show_member_box($_postdetails, $preview = false, $hooks = NULL, $hook_objects = NULL, $show_avatar = true, $extra_fields = NULL) { require_lang('ocf'); require_css('ocf'); // Have to build up $_postdetails instead? if (!is_array($_postdetails)) { if (addon_installed('points')) { require_code('points'); $points = integer_format(total_points($_postdetails)); } else { $points = ''; } $primary_group = ocf_get_member_primary_group($_postdetails); if (is_null($primary_group)) { return new ocp_tempcode(); } require_code('ocf_groups'); $_postdetails = array('poster' => $_postdetails, 'poster_posts' => $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails, 'm_cache_num_posts'), 'poster_join_date' => $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails, 'm_join_time'), 'poster_join_date_string' => get_timezoned_date($GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails, 'm_join_time')), 'primary_group_name' => ocf_get_group_name($primary_group)); $_postdetails['custom_fields'] = ocf_get_all_custom_fields_match_member($_postdetails['poster'], get_member() != $_postdetails['poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, get_member() == $_postdetails['poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, NULL, 0, NULL, $preview ? NULL : 1, $preview ? 1 : NULL); if ($preview) { $_postdetails['custom_fields_full'] = ocf_get_all_custom_fields_match_member($_postdetails['poster'], get_member() != $_postdetails['poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, get_member() == $_postdetails['poster'] && !has_specific_permission(get_member(), 'view_any_profile_field') ? 1 : NULL, NULL, 0, NULL, 1, 0); } else { $_postdetails['custom_fields_full'] = array(); } if (has_specific_permission(get_member(), 'see_warnings') && addon_installed('ocf_warnings')) { $num_warnings = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_cache_warnings'); /*if ($num_warnings!=0)*/ $_postdetails['poster_num_warnings'] = $num_warnings; } if (has_specific_permission(get_member(), 'see_ip')) { $_postdetails['ip_address'] = $GLOBALS['OCF_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_ip_address'); } } else { $points = array_key_exists('points', $_postdetails) ? integer_format($_postdetails['points']) : ''; } $member_id = $_postdetails['poster']; if (is_null($hooks)) { // Poster detail hooks $hooks = find_all_hooks('modules', 'topicview'); $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } } $custom_fields = new ocp_tempcode(); foreach ($_postdetails['custom_fields'] as $name => $value) { if (!is_null($value) && $value !== '') { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '10b72cd1ec240c315e56bc8a0f3a92a1', 'NAME' => $name, 'RAW' => $value['RAW'], 'VALUE' => is_object($value['RENDERED']) ? protect_from_escaping($value['RENDERED']) : $value['RENDERED']))); } } $custom_fields_full = new ocp_tempcode(); if (array_key_exists('custom_fields_full', $_postdetails)) { foreach ($_postdetails['custom_fields_full'] as $name => $value) { if (!is_null($value) && $value !== '') { $custom_fields_full->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '20b72cd1ec240c315e56bc8a0f3a92a1', 'NAME' => $name, 'RAW' => $value['RAW'], 'VALUE' => is_object($value['RENDERED']) ? protect_from_escaping($value['RENDERED']) : $value['RENDERED']))); } } } $ip_address = NULL; if (array_key_exists('ip_address', $_postdetails)) { $ip_address = $_postdetails['ip_address']; } $num_warnings = NULL; if (array_key_exists('poster_num_warnings', $_postdetails) && addon_installed('ocf_warnings')) { $num_warnings = integer_format($_postdetails['poster_num_warnings']); } $galleries = NULL; if (addon_installed('galleries') && get_option('show_gallery_counts') == '1') { $gallery_cnt = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) AS cnt FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name LIKE \'' . db_encode_like('member_' . strval($member_id) . '_%') . '\''); if ($gallery_cnt > 1) { require_lang('galleries'); $galleries = integer_format($gallery_cnt); } } $dob = NULL; $age = NULL; $day = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_day'); if ($GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_reveal_age') == 1 && !is_null($day)) { $month = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_month'); $year = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_dob_year'); 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); } $age = intval(date('Y')) - $year; if ($month > intval(date('m'))) { $age--; } if ($month == intval(date('m')) && $day > intval(date('D'))) { $age--; } } if (!is_null($extra_fields)) { foreach ($extra_fields as $key => $val) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('NAME' => $key, 'VALUE' => $val))); } } foreach (array_keys($hooks) as $hook) { $hook_result = $hook_objects[$hook]->run($member_id); if (!is_null($hook_result)) { $custom_fields->attach($hook_result); } } $_usergroups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id, true); $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $_usergroups); $usergroups = array(); foreach ($_usergroups as $u) { if (array_key_exists($u, $all_usergroups)) { $usergroups[] = $all_usergroups[$u]; } } return do_template('OCF_POSTER_DETAILS', array('_GUID' => 'dfskfdsf9', 'POSTER' => strval($member_id), 'POSTS' => integer_format($_postdetails['poster_posts']), 'POINTS' => $points, 'JOIN_DATE_RAW' => strval($_postdetails['poster_join_date']), 'JOIN_DATE' => $_postdetails['poster_join_date_string'], 'PRIMARY_GROUP_NAME' => $_postdetails['primary_group_name'], 'OTHER_USERGROUPS' => $usergroups, 'CUSTOM_FIELDS' => $custom_fields, 'CUSTOM_FIELDS_FULL' => $custom_fields_full, 'ONLINE' => member_is_online($member_id), 'AVATAR_URL' => $show_avatar ? $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id) : '', 'IP_ADDRESS' => $ip_address, 'NUM_WARNINGS' => $num_warnings, 'GALLERIES' => $galleries, 'DATE_OF_BIRTH' => $dob, 'AGE' => is_null($age) ? NULL : integer_format($age))); }
/** * The UI to show the member directory. * * @return tempcode The UI */ function directory() { require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $title = get_page_title('MEMBERS'); require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title); if (is_object($test_tpl)) { return $test_tpl; } if (running_script('iframe')) { $get_url = find_script('iframe'); } else { $get_url = find_script('index'); } $hidden = new ocp_tempcode(); $hidden->attach(build_keep_form_fields('_SELF', true, array('filter'))); $hidden->attach(form_input_hidden('zone', get_zone_name())); $start = get_param_integer('md_start', 0); $max = get_param_integer('md_max', 50); $sortables = array('m_username' => do_lang_tempcode('USERNAME'), 'm_primary_group' => do_lang_tempcode('PRIMARY_GROUP'), 'm_cache_num_posts' => do_lang_tempcode('COUNT_POSTS'), 'm_join_time' => do_lang_tempcode('JOIN_DATE')); $default_sort_order = get_value('md_default_sort_order'); if (is_null($default_sort_order)) { $default_sort_order = 'm_join_time DESC'; } $test = explode(' ', get_param('md_sort', $default_sort_order), 2); if (count($test) == 1) { $test[] = 'ASC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'md_sort'; $group_filter = get_param('group_filter', ''); $_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $group_filter == '' ? NULL : array(intval($group_filter))); $usergroups = array(); require_code('ocf_groups2'); foreach ($_usergroups as $group_id => $group) { $num = ocf_get_group_members_raw_count($group_id, true); $usergroups[$group_id] = array('USERGROUP' => $group, 'NUM' => strval($num)); } $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $query .= ' AND m_validated=1'; } if ($group_filter != '') { if (is_numeric($group_filter)) { $title = get_page_title('USERGROUP', true, array(escape_html($usergroups[intval($group_filter)]['USERGROUP']))); } require_code('ocfiltering'); $filter = ocfilter_to_sqlfragment($group_filter, 'm_primary_group', 'f_groups', NULL, 'm_primary_group', 'id'); $query .= ' AND ' . $filter; } $search = get_param('filter', ''); $sup = $search != '' ? ' AND m_username LIKE \'' . db_encode_like(str_replace('*', '%', $search)) . '\'' : ''; if ($sortable == 'm_join_time') { $query .= $sup . ' ORDER BY m_join_time ' . $sort_order . ',' . 'id ' . $sort_order; } else { $query .= $sup . ' ORDER BY ' . $sortable . ' ' . $sort_order; } $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); $rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query, $max, $start); if (count($rows) == 0) { return inform_screen($title, do_lang_tempcode('NO_RESULTS')); } $members = new ocp_tempcode(); $member_boxes = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('COUNT_POSTS'), do_lang_tempcode('JOIN_DATE')), $sortables, 'md_sort', $sortable . ' ' . $sort_order); require_code('ocf_members2'); foreach ($rows as $row) { $link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'], true, $row['m_username']); if ($row['m_validated'] == 0) { $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED')); } if ($row['m_validated_email_confirm_code'] != '') { $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED')); } $member_primary_group = ocf_get_member_primary_group($row['id']); $primary_group = ocf_get_group_link($member_primary_group); $members->attach(results_entry(array($link, $primary_group, escape_html(integer_format($row['m_cache_num_posts'])), escape_html(get_timezoned_date($row['m_join_time']))))); $member_boxes[] = ocf_show_member_box($row['id'], true); } $results_table = results_table(do_lang_tempcode('MEMBERS'), $start, 'md_start', $max, 'md_max', $max_rows, $fields_title, $members, $sortables, $sortable, $sort_order, 'md_sort'); $results_browser = results_browser(do_lang_tempcode('MEMBERS'), NULL, $start, 'md_start', $max, 'md_max', $max_rows, NULL, NULL, true, true); $symbols = NULL; if (get_option('allow_alpha_search') == '1') { $alpha_query = $GLOBALS['FORUM_DB']->query('SELECT m_username FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()) . ' ORDER BY m_username ASC'); $symbols = array(array('START' => '0', 'SYMBOL' => do_lang('ALL')), array('START' => '0', 'SYMBOL' => '#')); foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z') as $s) { foreach ($alpha_query as $i => $q) { if (strtolower(substr($q['m_username'], 0, 1)) == $s) { break; } } if (substr(strtolower($q['m_username']), 0, 1) != $s) { $i = intval($symbols[count($symbols) - 1]['START']); } $symbols[] = array('START' => strval(intval($max * floor(floatval($i) / floatval($max)))), 'SYMBOL' => $s); } } return do_template('OCF_MEMBER_DIRECTORY_SCREEN', array('_GUID' => '096767e9aaabce9cb3e6591b7bcf95b8', 'MAX' => strval($max), 'RESULTS_BROWSER' => $results_browser, 'MEMBER_BOXES' => $member_boxes, 'USERGROUPS' => $usergroups, 'HIDDEN' => $hidden, 'SYMBOLS' => $symbols, 'SEARCH' => $search, 'GET_URL' => $get_url, 'TITLE' => $title, 'RESULTS_TABLE' => $results_table)); }
/** * Get some template code showing the number of chatters in a room. * * @param array A mapping (user=>username) of the chatters in the room * @return tempcode The Tempcode */ function get_chatters_in_room_tpl($users) { $usernames = new ocp_tempcode(); $some_users = false; foreach ($users as $member_id => $username) { if (!member_blocked(get_member(), $member_id)) { $some_users = true; if (!$usernames->is_empty()) { $usernames->attach(escape_html(', ')); } if (!is_guest($member_id)) { if (get_forum_type() == 'ocf') { require_code('ocf_general'); require_code('ocf_members'); $colour = get_group_colour(ocf_get_member_primary_group($member_id)); $usernames->attach(do_template('OCF_USER_MEMBER', array('PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, true, true), 'USERNAME' => $username, 'COLOUR' => $colour))); } else { $usernames->attach($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($member_id, true, $username)); } } else { $usernames->attach(escape_html(do_lang('GUEST'))); } } } if (!$some_users) { $usernames = do_lang_tempcode('NONE_EM'); } return $usernames; }
Copyright (c) ocProducts, 2004-2012 See text/EN/licence.txt for full licencing information. */ require_code('ocf_groups'); require_code('ocf_members'); echo '<div class="wide_table_wrap"><table class="wide_table solidborder spaced_table"><colgroup><col width="100" /><col width="250" /><col width="100%" /></colgroup>'; echo '<tr><th>Avatar</th><th>Details</th><th>Signature</th></tr>'; $gifts = $GLOBALS['SITE_DB']->query('SELECT gift_to,SUM(amount) as cnt FROM ' . get_table_prefix() . 'gifts g LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=g.reason WHERE text_original LIKE \'' . db_encode_like($map['param']) . ': %\' AND gift_from<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' GROUP BY gift_to ORDER BY cnt DESC', 10); $count = 0; foreach ($gifts as $gift) { $member_id = $gift['gift_to']; $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (!is_null($username)) { $link = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id); $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id); $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_signature'), $GLOBALS['FORUM_DB']); $points = $gift['cnt']; $rank = get_translated_text(ocf_get_group_property(ocf_get_member_primary_group($member_id), 'name'), $GLOBALS['FORUM_DB']); if ($avatar_url == '') { $avatar = ''; } else { $avatar = '<img style="max-width: 100%" alt="" src="' . escape_html($avatar_url) . '" />'; } echo '<tr><td>' . $avatar . '</td><td>Username: <a href="' . escape_html($link) . '">' . escape_html($username) . '</a><br /><br />Role points: ' . number_format($points) . '<br /><br />Rank: ' . $rank . '</td><td style="font-size: 0.8em;">' . $signature->evaluate() . '</td></tr>'; $count++; } } if ($count == 0) { echo '<tr><td colspan="3" style="font-weight: bold; padding: 10px">Nobody yet – could you be here?</td></tr>'; } echo '</table></div>';