/** * 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); }
/** * Get the value of a special 'ocp_' custom profile field. For OCF it can also do it for a pure field title, e.g. "Example Field". * * @param ID_TEXT The CPF name stem * @param ?MEMBER Member to lookup for (NULL: current member) * @return string The value (blank: has a blank value, or does not exist) */ function get_ocp_cpf($cpf, $member = NULL) { if (is_null($member)) { $member = get_member(); } if ($cpf == 'fullname' && get_option('signup_fullname') == '1') { return preg_replace('# \\(\\d+\\)$#', '', $GLOBALS['FORUM_DRIVER']->get_username($member)); } $values = $GLOBALS['FORUM_DRIVER']->get_custom_fields($member); if (is_null($values)) { return ''; } if (array_key_exists($cpf, $values)) { return $values[$cpf]; } if (get_forum_type() == 'ocf') { $values = ocf_get_all_custom_fields_match_member($member); if (array_key_exists($cpf, $values)) { $ret = $values[$cpf]['RAW']; if (is_object($ret)) { $ret = $ret->evaluate(); } return $ret; } } return ''; }
/** * 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; }
/** * Get custom profile fields values for all 'ocp_' prefixed keys. * * @param MEMBER The member id * @return ?array A map of the custom profile fields, key_suffix=>value (NULL: no fields) */ function get_custom_fields($member) { // Check member exists $username = $this->get_username($member); if (is_null($username)) { return NULL; } require_code('ocf_members'); $info = ocf_get_all_custom_fields_match_member($member, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); $out = array(); foreach ($info as $field => $value) { $out[substr($field, 4)] = $value['RAW']; } return $out; }
/** * 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; }
/** * 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; }
/** * The UI to add an author. * * @return tempcode The UI */ function _ad() { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'author'; $author = get_param('author', $GLOBALS['FORUM_DRIVER']->get_username(get_member())); if (!has_edit_author_permission(get_member(), $author)) { if (get_author_id_from_name($author) == get_member()) { access_denied('SPECIFIC_PERMISSION', 'set_own_author_profile'); } access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content'); } $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'url', 'skills', 'forum_handle'), array('author' => $author), '', 1); if (array_key_exists(0, $rows)) { $myrow = $rows[0]; $description = get_translated_text($myrow['description']); $url = $myrow['url']; $skills = get_translated_text($myrow['skills']); $handle = $myrow['forum_handle']; $may_delete = true; } else { $description = ''; if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_lang('ocf'); $info = ocf_get_all_custom_fields_match_member(get_member()); if (array_key_exists(do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME'), $info)) { $description = $info[do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME')]['RENDERED']; if (is_object($description)) { $description = $description->evaluate(); } } } $url = ''; $skills = ''; $handle = NULL; $may_delete = false; } if (is_null($handle)) { $handle = $GLOBALS['FORUM_DRIVER']->get_member_from_username($author); if (!is_null($handle)) { $handle = strval($handle); } } if ($author == '' || is_null($handle)) { $title = get_page_title('DEFINE_AUTHOR'); } else { $title = get_page_title('_DEFINE_AUTHOR', true, array(escape_html($author))); } $post_url = build_url(array('page' => '_SELF', 'type' => '__ad', 'author' => $author), '_SELF'); $submit_name = do_lang_tempcode('SAVE'); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); if (is_null($handle)) { $fields->attach(form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_NAME'), 'author', $author, true)); } $fields->attach(form_input_line(do_lang_tempcode('AUTHOR_URL'), do_lang_tempcode('DESCRIPTION_AUTHOR_URL'), 'url', $url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('SKILLS'), do_lang_tempcode('DESCRIPTION_SKILLS'), 'skills', $skills, false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_MEMBER_DESCRIPTION'), 'description', $description, false)); if (has_specific_permission(get_member(), 'edit_midrange_content', 'cms_authors')) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => !is_null($handle), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_username(do_lang_tempcode('MEMBER_ID'), do_lang_tempcode('DESCRIPTION_MEMBER_ID'), 'forum_handle', is_null($handle) ? '' : $GLOBALS['FORUM_DRIVER']->get_username(intval($handle)), false)); } else { $hidden->attach(form_input_hidden('forum_handle', $handle)); } require_code('fields'); if (has_tied_catalogue('author')) { append_form_custom_fields('author', $author, $fields, $hidden); } require_code('seo2'); $fields->attach(seo_get_fields('authors', $author)); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('author', $author)); } if ($may_delete) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return do_template('FORM_SCREEN', array('_GUID' => '1d71c934e3e23fe394f5611191089630', 'PREVIEW' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); }
/** * 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))); }