/** * 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 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 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)); }
/** * Standard aed_module table function. * * @param array Details to go to build_url for link to the next screen. * @return array A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL. */ function nice_get_choose_table($url_map) { require_code('templates_results_table'); $default_order = 'g_name ASC'; $current_ordering = get_param('sort', $default_order, true); $sortables = array('g_name' => do_lang_tempcode('NAME')); if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); 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[] = 'sort'; $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('OPEN_MEMBERSHIP'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)', array('g_is_private_club' => 1)); require_code('form_templates'); list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, $count > 300 || !has_specific_permission(get_member(), 'control_usergroups') ? array('g_group_leader' => get_member(), 'g_is_private_club' => 1) : array('g_is_private_club' => 1)); foreach ($rows as $row) { $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF'); $fr = array(protect_from_escaping(ocf_get_group_link($row['id'])), $row['g_open_membership'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO')); $fr[] = protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id']))); $fields->attach(results_entry($fr, true)); } $search_url = build_url(array('page' => 'search', 'id' => 'ocf_clubs'), get_module_zone('search')); $archive_url = build_url(array('page' => 'groups'), get_module_zone('groups')); return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order, 'sort'), false, $search_url, $archive_url); }
/** * Standard aed_module table function. * * @param array Details to go to build_url for link to the next screen. * @return array A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL. */ function nice_get_choose_table($url_map) { require_code('templates_results_table'); $default_order = 'g_promotion_threshold ASC,id ASC'; $current_ordering = get_param('sort', $default_order, true); $sortables = array('g_name' => do_lang_tempcode('NAME'), 'g_is_presented_at_install' => do_lang_tempcode('IS_PRESENTED_AT_INSTALL'), 'g_is_default' => do_lang_tempcode('DEFAULT_GROUP'), 'g_open_membership' => do_lang_tempcode('OPEN_MEMBERSHIP')); if (addon_installed('points')) { $sortables = array_merge($sortables, array('g_promotion_threshold ASC,id' => do_lang_tempcode('PROMOTION_TARGET'))); } $sortables = array_merge($sortables, array('g_is_super_admin' => do_lang_tempcode('SUPER_ADMIN'), 'g_order' => do_lang_tempcode('ORDER'))); if ($current_ordering == 'g_promotion_threshold ASC,id ASC') { list($sortable, $sort_order) = array('g_promotion_threshold ASC,id', 'ASC'); } elseif ($current_ordering == 'g_promotion_threshold DESC,id DESC' || $current_ordering == 'g_promotion_threshold ASC,id DESC') { list($sortable, $sort_order) = array('g_promotion_threshold DESC,id', 'DESC'); } else { if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); 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[] = 'sort'; } $_header_row = array(do_lang_tempcode('NAME'), do_lang_tempcode('IS_PRESENTED_AT_INSTALL'), do_lang_tempcode('DEFAULT_GROUP'), do_lang_tempcode('OPEN_MEMBERSHIP')); if (addon_installed('points')) { $_header_row = array_merge($_header_row, array(do_lang_tempcode('PROMOTION_TARGET'))); } $_header_row = array_merge($_header_row, array(do_lang_tempcode('SUPER_ADMIN'), do_lang_tempcode('ORDER'), do_lang_tempcode('ACTIONS'))); $header_row = results_field_title($_header_row, $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); require_code('form_templates'); list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, $group_count > 300 ? array('g_is_private_club' => 0) : NULL); $changed = false; foreach ($rows as $row) { $new_order = post_param_integer('order_' . strval($row['id']), NULL); if (!is_null($new_order)) { $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_order' => $new_order), array('id' => $row['id']), '', 1); $changed = true; } } if ($changed) { list($rows, $max_rows) = $this->get_entry_rows(true, $current_ordering, $group_count > 300 ? array('g_is_private_club' => 0) : NULL); } foreach ($rows as $row) { $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF'); if ($row['id'] == db_get_first_id() + 8 && $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)', array('g_is_presented_at_install' => '1')) == 0) { $row['g_is_presented_at_install'] = 1; } $fr = array(protect_from_escaping(ocf_get_group_link($row['id'])), $row['g_is_presented_at_install'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $row['g_is_default'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $row['g_open_membership'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO')); if (addon_installed('points')) { $fr = array_merge($fr, array(is_null($row['g_promotion_target']) ? do_lang_tempcode('NA_EM') : make_string_tempcode(ocf_get_group_name($row['g_promotion_target']) . ' (' . strval($row['g_promotion_threshold']) . ')'))); } $fr = array_merge($fr, array($row['g_is_super_admin'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'))); $orderlist = new ocp_tempcode(); $selected_one = false; $order = $row['g_order']; for ($i = 0; $i < max(count($rows), $order); $i++) { $selected = $i === $order; if ($selected) { $selected_one = true; } $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1))); } if (!$selected_one) { $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1))); } $ordererx = protect_from_escaping(do_template('TABLE_TABLE_ROW_CELL_SELECT', array('LABEL' => do_lang_tempcode('ORDER'), 'NAME' => 'order_' . strval($row['id']), 'LIST' => $orderlist))); $fr[] = $ordererx; $fr[] = protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id']))); $fields->attach(results_entry($fr, true)); } $search_url = build_url(array('page' => 'search', 'id' => 'ocf_clubs'), get_module_zone('search')); $archive_url = build_url(array('page' => 'groups'), get_module_zone('groups')); return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, NULL, 8, 'gdfg43tfdgdfgdrfgd', true), true, $search_url, $archive_url); }