/** * 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'); $member = get_member(); $forum = get_forum_type(); $content = new ocp_tempcode(); $links = new ocp_tempcode(); if (!is_guest()) { // Admins can jump user $has_su = get_option('ocp_show_su') == '1' && has_specific_permission(get_member(), 'assume_any_member'); $staff_actions = new ocp_tempcode(); $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); if ($forum != 'none') { if (!has_no_forum() && get_option('forum_show_personal_stats_posts') == '1') { // Post count $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '371dfee46e8c40b1b109e0350055f8cc', 'KEY' => do_lang_tempcode('COUNT_POSTSCOUNT'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_post_count($member))))); } if (!has_no_forum() && get_option('forum_show_personal_stats_topics') == '1') { // Topic count $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('KEY' => do_lang_tempcode('COUNT_TOPICSCOUNT'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_topic_count($member))))); } // Member profile view link if (get_option('ocf_show_profile_link') == '1') { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, true, true); $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('_GUID' => '2c8648c953c802a9de41c3adeef0e97f', 'NAME' => do_lang_tempcode('MY_PROFILE'), 'URL' => $url, 'REL' => 'me'))); } } // Point count and point profile link if (addon_installed('points')) { require_lang('points'); require_code('points'); if (get_option('points_show_personal_stats_points_left') == '1') { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e58e30457576735f3a2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_POINTS_LEFT'), 'VALUE' => integer_format(available_points($member))))); } if (get_option('points_show_personal_stats_points_used') == '1') { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e58edfdsf735f3a2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_POINTS_USED'), 'VALUE' => integer_format(points_used($member))))); } if (get_option('points_show_personal_stats_total_points') == '1') { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '3e6183abf9054574c0cd292d25a4fe5c', 'KEY' => do_lang_tempcode('COUNT_POINTS_EVER'), 'VALUE' => integer_format(total_points($member))))); } if (get_option('points_show_personal_stats_gift_points_left') == '1') { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e5ssd45ddsdsdsa2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_GIFT_POINTS_LEFT'), 'VALUE' => integer_format(get_gift_points_to_give($member))))); } if (get_option('points_show_personal_stats_gift_points_used') == '1') { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241eddsd4sdddssdsa2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_GIFT_POINTS_USED'), 'VALUE' => integer_format(get_gift_points_used($member))))); } } if (get_option('ocp_show_personal_usergroup') == '1') { $group_id = $GLOBALS['FORUM_DRIVER']->pname_group($GLOBALS['FORUM_DRIVER']->pget_row($username)); $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); if (array_key_exists($group_id, $usergroups)) { if (get_forum_type() == 'ocf') { $group_url = build_url(array('page' => 'groups', 'type' => 'view', 'id' => $group_id), get_module_zone('groups')); $hyperlink = hyperlink($group_url, $usergroups[$group_id], false, true); $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE_COMPLEX', array('_GUID' => 'sas41eddsd4sdddssdsa2618fd7fff', 'KEY' => do_lang_tempcode('GROUP'), 'VALUE' => $hyperlink))); } else { $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '65180134fbc4cf7e227011463d466677', 'KEY' => do_lang_tempcode('GROUP'), 'VALUE' => $usergroups[$group_id]))); } } } if (get_option('ocp_show_personal_last_visit') == '1') { $row = $GLOBALS['FORUM_DRIVER']->pget_row($username); if (get_forum_type() == 'ocf') { $last_visit = intval(ocp_admirecookie('last_visit', strval($GLOBALS['FORUM_DRIVER']->pnamelast_visit($row)))); } else { $last_visit = $GLOBALS['FORUM_DRIVER']->pnamelast_visit($row); } $_last_visit = get_timezoned_date($last_visit, false); $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => 'sas41eddsdsdsdsdsa2618fd7fff', 'KEY' => do_lang_tempcode('LAST_HERE'), 'RAW_KEY' => strval($last_visit), 'VALUE' => $_last_visit))); } $avatar_url = ''; if (!has_no_forum()) { if (get_option('ocp_show_avatar') === '1') { $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member); } } // Subscription links if (get_forum_type() == 'ocf' && addon_installed('ecommerce') && get_option('ocp_show_personal_sub_links') == '1' && !has_zone_access(get_member(), 'adminzone') && has_actual_page_access(get_member(), 'purchase')) { $usergroup_subs = $GLOBALS['FORUM_DB']->query_select('f_usergroup_subs', array('id', 's_title', 's_group_id', 's_cost'), array('s_enabled' => 1)); $in_one = false; $members_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member); foreach ($usergroup_subs as $i => $sub) { $usergroup_subs[$i]['s_cost'] = floatval($sub['s_cost']); if (in_array($sub['s_group_id'], $members_groups)) { $in_one = true; break; } } if (!$in_one) { global $M_SORT_KEY; $M_SORT_KEY = 's_cost'; usort($usergroup_subs, 'multi_sort'); foreach ($usergroup_subs as $sub) { $url = build_url(array('page' => 'purchase', 'type' => 'message', 'product' => 'USERGROUP' . strval($sub['id'])), get_module_zone('purchase')); $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('NAME' => do_lang_tempcode('UPGRADE_TO', escape_html(get_translated_text($sub['s_title']))), 'URL' => $url))); } } } // Admin Zone link if (get_option('ocp_show_personal_adminzone_link') == '1' && has_zone_access(get_member(), 'adminzone')) { $url = build_url(array('page' => ''), 'adminzone'); $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('_GUID' => 'ae243058f780f9528016f7854763a5fa', 'ACCESSKEY' => 'I', 'NAME' => do_lang_tempcode('ADMIN_ZONE'), 'URL' => $url))); } // Conceded mode link if ($GLOBALS['SESSION_CONFIRMED'] == 1 && get_option('ocp_show_conceded_mode_link') == '1') { $url = build_url(array('page' => 'login', 'type' => 'concede', 'redirect' => get_page_name() == 'login' ? NULL : SELF_REDIRECT), get_module_zone('login')); $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK_2', array('_GUID' => '81fa81cfd3130e42996bf72b0e03d8aa', 'POST' => true, 'NAME' => do_lang_tempcode('CONCEDED_MODE'), 'DESCRIPTION' => do_lang_tempcode('DESCRIPTION_CONCEDED_MODE'), 'URL' => $url))); } // Becomes-invisible link if (get_option('is_on_invisibility') == '1') { $visible = array_key_exists(get_session_id(), $GLOBALS['SESSION_CACHE']) && $GLOBALS['SESSION_CACHE'][get_session_id()]['session_invisible'] == 0; $url = build_url(array('page' => 'login', 'type' => 'invisible', 'redirect' => get_page_name() == 'login' ? NULL : SELF_REDIRECT), get_module_zone('login')); $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK_2', array('NAME' => do_lang_tempcode($visible ? 'INVISIBLE' : 'BE_VISIBLE'), 'DESCRIPTION' => '', 'URL' => $url))); } // Logout link $url = build_url(array('page' => 'login', 'type' => 'logout'), get_module_zone('login')); if (!is_httpauth_login()) { $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LOGOUT', array('_GUID' => 'd1caacba272a7ee3bf5b2a758e4e54ee', 'NAME' => do_lang_tempcode('LOGOUT'), 'URL' => $url))); } return do_template('BLOCK_SIDE_PERSONAL_STATS', array('_GUID' => '99f9bc3387102daaeeedf99843b0502e', 'AVATAR_URL' => $avatar_url, 'LINKS' => $links, 'HAS_SU' => $has_su, 'CONTENT' => $content, 'USERNAME' => $username, 'STAFF_ACTIONS' => $staff_actions)); } else { $title = do_lang_tempcode('NOT_LOGGED_IN'); if (get_page_name() != 'join' && get_page_name() != 'login') { if (count($_POST) > 0) { $_this_url = build_url(array('page' => ''), '', array('keep_session' => 1, 'redirect' => 1)); } else { $_this_url = build_url(array('page' => '_SELF'), '_SELF', array('keep_session' => 1, 'redirect' => 1), true); } } else { $_this_url = build_url(array('page' => ''), '', array('keep_session' => 1, 'redirect' => 1)); } $this_url = $_this_url->evaluate(); $login_url = build_url(array('page' => 'login', 'type' => 'login', 'redirect' => $this_url), get_module_zone('login')); $full_link = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $this_url), get_module_zone('login')); $join_url = get_forum_type() != 'none' ? $GLOBALS['FORUM_DRIVER']->join_url() : ''; return do_template('BLOCK_SIDE_PERSONAL_STATS_NO', array('_GUID' => '32aade68b98dfd191f0f84c6648f7dde', 'TITLE' => $title, 'FULL_LINK' => $full_link, 'JOIN_LINK' => $join_url, 'LOGIN_URL' => $login_url)); } }
/** * The UI for a points profile. * * @param MEMBER The ID of the member who is being viewed * @param ?MEMBER The ID of the member who is doing the viewing (NULL: current member) * @return tempcode The UI */ function points_profile($member_id_of, $member_id_viewing) { require_code('points'); require_css('points'); require_lang('points'); require_javascript('javascript_validation'); // Get info about viewing/giving user if (!is_guest($member_id_viewing)) { $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing); } // Get info about viewed user $name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($name) || is_guest($member_id_of)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } $title = get_page_title('_POINTS', true, array(escape_html($name))); $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id_of, false, true); // Show stats about $member_id_of $post_count = $GLOBALS['FORUM_DRIVER']->get_post_count($member_id_of); $_point_info = point_info($member_id_of); $points_gained_given = array_key_exists('points_gained_given', $_point_info) ? $_point_info['points_gained_given'] : 0; $points_gained_rating = array_key_exists('points_gained_rating', $_point_info) ? $_point_info['points_gained_rating'] : 0; $points_gained_voting = array_key_exists('points_gained_voting', $_point_info) ? $_point_info['points_gained_voting'] : 0; $cedi_post_count = array_key_exists('points_gained_seedy', $_point_info) ? $_point_info['points_gained_seedy'] : 0; $chat_post_count = array_key_exists('points_gained_chat', $_point_info) ? $_point_info['points_gained_chat'] : 0; $points_used = points_used($member_id_of); $remaining = available_points($member_id_of); $gift_points_used = get_gift_points_used($member_id_of); //$_point_info['gift_points_used']; $gift_points_available = get_gift_points_to_give($member_id_of); $points_posting = intval(get_option('points_posting')); $points_rating = intval(get_option('points_rating')); $points_voting = intval(get_option('points_voting')); $points_joining = intval(get_option('points_joining')); $points_cedi_posting = intval(get_option('points_cedi', true)); $points_chat_posting = intval(get_option('points_chat', true)); $points_per_day = intval(get_option('points_per_day', true)); $points_per_daily_visit = intval(get_option('points_per_daily_visit', true)); $days_joined = intval(floor(floatval(time() - $GLOBALS['FORUM_DRIVER']->get_member_join_timestamp($member_id_of)) / (60.0 * 60.0 * 24.0))); $points_gained_auto = $points_per_day * $days_joined; $to = points_get_transactions('to', $member_id_of, $member_id_viewing); $from = points_get_transactions('from', $member_id_of, $member_id_viewing); // If we're staff, we can show the charge log too $chargelog_details = new ocp_tempcode(); if (has_specific_permission($member_id_viewing, 'view_charge_log')) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'charge_start'; $NON_CANONICAL_PARAMS[] = 'charge_sort'; $start = get_param_integer('charge_start', 0); $max = get_param_integer('charge_max', 10); $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT')); $test = explode(' ', get_param('charge_sort', 'date_and_time DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } 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'); } $max_rows = $GLOBALS['SITE_DB']->query_value('chargelog', 'COUNT(*)', array('user_id' => $member_id_of)); $rows = $GLOBALS['SITE_DB']->query_select('chargelog c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.reason', array('*'), array('user_id' => $member_id_of), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $charges = new ocp_tempcode(); $fromname = get_site_name(); $toname = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($toname)) { $toname = do_lang('UNKNOWN'); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'charge_sort', $sortable . ' ' . $sort_order); foreach ($rows as $myrow) { $date = get_timezoned_date($myrow['date_and_time']); $amount = $myrow['amount']; if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) { $reason = new ocp_tempcode(); if (!$reason->from_assembly($myrow['text_parsed'], true)) { $reason = get_translated_tempcode($myrow['reason']); } } else { $reason = get_translated_tempcode($myrow['reason']); } $charges->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), escape_html($fromname), escape_html($toname), $reason))); } $chargelog_details = results_table(do_lang_tempcode('CHARGES'), $start, 'charge_start', $max, 'charge_max', $max_rows, $fields_title, $charges, $sortables, $sortable, $sort_order, 'charge_sort', NULL, NULL, NULL, 8, 'fgfdgfdgfdgfdger4gtrhg', false, 'tab__points'); $chargelog_details->attach(do_template('POINTS_CHARGE', array('_GUID' => 'f1e2d45a7d920ab91553a5fd0728a5ad', 'URL' => build_url(array('page' => 'admin_points', 'type' => 'charge', 'redirect' => get_self_url(true)), get_module_zone('admin_points')), 'USER' => strval($member_id_of)))); } // Show giving form if (is_guest($member_id_viewing)) { $give_template = do_lang_tempcode('POINTS_MUST_LOGIN'); } else { $have_negative_gift_points = has_specific_permission($member_id_viewing, 'have_negative_gift_points'); $enough_ok = $viewer_gift_points_available > 0 || $have_negative_gift_points; $give_ok = $member_id_viewing != $member_id_of || has_specific_permission($member_id_viewing, 'give_points_self'); if ($enough_ok && $give_ok) { // Show how many points are available also $give_url = build_url(array('page' => 'points', 'type' => 'give', 'id' => $member_id_of), get_module_zone('points')); $give_template = do_template('POINTS_GIVE', array('_GUID' => 'fa1749d5a803d86b1efbcfde2ad81702', 'GIVE_URL' => $give_url, 'USER' => strval($member_id_of), 'VIEWER_GIFT_POINTS_AVAILABLE' => $have_negative_gift_points ? '' : integer_format($viewer_gift_points_available))); } else { $give_template = do_lang_tempcode('PE_LACKING_GIFT_POINTS'); } if (!$give_ok) { $give_template = new ocp_tempcode(); } if (!has_specific_permission($member_id_of, 'use_points')) { $give_template = new ocp_tempcode(); } } return do_template('POINTS_PROFILE', array('_GUID' => 'f91208ef0f9a1e1a8633ce307a778a8d', 'TITLE' => $title, 'MEMBER' => strval($member_id_of), 'PROFILE_LINK' => $profile_link, 'NAME' => $name, 'POINTS_JOINING' => integer_format($points_joining), 'POST_COUNT' => integer_format($post_count), 'POINTS_POSTING' => integer_format($points_posting), 'MULT_POINTS_POSTING' => integer_format($points_posting * $post_count), 'POINTS_PER_DAY' => integer_format($points_per_day), 'DAYS_JOINED' => integer_format($days_joined), 'MULT_POINTS_PER_DAY' => integer_format($points_per_day * $days_joined), 'POINTS_GAINED_AUTO' => integer_format($points_gained_auto), 'CEDI_POST_COUNT' => integer_format($cedi_post_count), 'POINTS_CEDI_POSTING' => integer_format($points_cedi_posting), 'MULT_POINTS_CEDI_POSTING' => integer_format($cedi_post_count * $points_cedi_posting), 'CHAT_POST_COUNT' => integer_format($chat_post_count), 'POINTS_CHAT_POSTING' => integer_format($points_chat_posting), 'MULT_POINTS_CHAT_POSTING' => integer_format($chat_post_count * $points_chat_posting), 'POINTS_RATING' => integer_format($points_rating), 'POINTS_GAINED_RATING' => integer_format($points_gained_rating), 'MULT_POINTS_RATING' => integer_format($points_rating * $points_gained_rating), 'POINTS_VOTING' => integer_format($points_voting), 'POINTS_GAINED_VOTING' => integer_format($points_gained_voting), 'MULT_POINTS_VOTING' => integer_format($points_voting * $points_gained_voting), 'POINTS_PER_DAILY_VISIT' => integer_format($points_per_daily_visit), 'POINTS_GAINED_GIVEN' => integer_format($points_gained_given), 'POINTS_USED' => integer_format($points_used), 'REMAINING' => integer_format($remaining), 'GIFT_POINTS_USED' => integer_format($gift_points_used), 'GIFT_POINTS_AVAILABLE' => integer_format($gift_points_available), 'TO' => $to, 'FROM' => $from, 'CHARGELOG_DETAILS' => $chargelog_details, 'GIVE' => $give_template)); }
/** * The actualiser for a gift point transaction. * * @return tempcode The UI */ function do_give() { $member_id_of = get_param_integer('id'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USER_POINT_FIND')), array('_SELF:_SELF:member:id=' . strval($member_id_of), do_lang_tempcode('_POINTS', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id_of)))))); $title = get_page_title('POINTS'); $trans_type = post_param('trans_type', 'gift'); $amount = post_param_integer('amount'); $reason = post_param('reason'); $worked = false; $member_id_viewing = get_member(); if ($member_id_of == $member_id_viewing && !has_specific_permission($member_id_viewing, 'give_points_self')) { $message = do_lang_tempcode('PE_SELF'); } elseif (is_guest($member_id_viewing)) { $message = do_lang_tempcode('MUST_LOGIN'); } else { if ($trans_type == 'gift') { $anonymous = post_param_integer('anonymous', 0); $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing); //$viewer_gift_points_used=get_gift_points_used($member_id_viewing); if ($viewer_gift_points_available < $amount && !has_specific_permission($member_id_viewing, 'have_negative_gift_points')) { $message = do_lang_tempcode('PE_LACKING_GIFT_POINTS'); } elseif ($amount < 0 && !has_specific_permission($member_id_viewing, 'give_negative_points')) { $message = do_lang_tempcode('PE_NEGATIVE_GIFT'); } elseif ($reason == '') { $message = do_lang_tempcode('IMPROPERLY_FILLED_IN'); } else { // Write transfer require_code('points2'); give_points($amount, $member_id_of, $member_id_viewing, $reason, $anonymous == 1); // Randomised gifts if (mt_rand(0, 4) == 1) { $message = do_lang_tempcode('PR_LUCKY'); $_current_gift = point_info($member_id_viewing); $current_gift = array_key_exists('points_gained_given', $_current_gift) ? $_current_gift['points_gained_given'] : 0; $GLOBALS['FORUM_DRIVER']->set_custom_field($member_id_viewing, 'points_gained_given', $current_gift + 25); // TODO: 25 should be a config option } else { $message = do_lang_tempcode('PR_NORMAL'); } $worked = true; } } if ($trans_type == 'refund') { $trans_type = 'charge'; $amount = -$amount; } if ($trans_type == 'charge') { if (has_actual_page_access($member_id_viewing, 'adminzone')) { require_code('points2'); charge_member($member_id_of, $amount, $reason); $left = available_points($member_id_of); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $message = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left))); $worked = true; } else { access_denied('I_ERROR'); } } } if ($worked) { // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $member_id_of), '_SELF'); return redirect_screen($title, $url, $message); } else { return warn_screen($title, $message); } }