/** * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License * @copyright ocProducts Ltd * @package group_points */ function total_points($member) { $points = non_overrided__total_points($member); $totalised_group_points = 0; $group_points = get_group_points(); $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member); foreach ($groups as $group) { $totalised_group_points += isset($group_points[$group]['p_points_one_off']) ? $group_points[$group]['p_points_one_off'] : 0; } global $TOTAL_POINTS_CACHE; $TOTAL_POINTS_CACHE[$member] = $points + $totalised_group_points; return $points + $totalised_group_points; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { require_code('points'); $time = time(); $last_time = intval(get_value('last_group_points')); if ($last_time > time() - 24 * 60 * 60 * 27) { return; } // Only once within a month if (date('j') != '1') { return; } // Only on first day require_code('points'); require_code('points2'); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true, true); $group_points = get_group_points(); $fields = new ocp_tempcode(); foreach ($groups as $group_id => $group_name) { if (isset($group_points[$group_id])) { $points = $group_points[$group_id]; if ($points['p_points_per_month'] != 0) { $start = 0; do { $members = $GLOBALS['FORUM_DRIVER']->member_group_query(array($group_id), 100, $start); foreach ($members as $member_row) { $member_id = $GLOBALS['FORUM_DRIVER']->pname_id($member_row); system_gift_transfer('Being in the ' . $group_name . ' usergroup', $points['p_points_per_month'], $member_id); } $start += 100; } while (count($members) > 0); } } } set_value('last_group_points', strval($time)); }
<?php require_code('points'); $_id = isset($map['param']) ? $map['param'] : ''; if ($_id == '') { $id = get_member(); } else { $id = intval($_id); } $username = $GLOBALS['FORUM_DRIVER']->get_username($id); $group_points = get_group_points(); $fields = new ocp_tempcode(); asort($group_points); echo '<div class="wide_table_wrap"><table class="solidborder wide_table spaced_table"><thead></thead><tbody><tr><th>Usergroup</th><th>One-off point bonus</th><th>Monthly points</th><th>' . escape_html($username) . ' in this group?</th></tr>'; $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true, true); $my_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($id); $done = 0; foreach ($group_points as $group_id => $points) { if ($points['p_points_one_off'] != 0 || in_array($group_id, $my_groups)) { $group_name = $groups[$group_id]; echo '<tr ><td>' . escape_html($group_name) . '</td> <td>' . escape_html(integer_format($points['p_points_one_off'])) . '</td> <td>' . escape_html(integer_format($points['p_points_per_month'])) . ' <span class="associated_details">per month</span></td> <td>' . (in_array($group_id, $my_groups) ? '<img src="' . escape_html(find_theme_image('checklist/checklist1')) . '" /> Yes' : '<img src="' . escape_html(find_theme_image('checklist/checklist0')) . '" /> No') . '</td> </tr>'; $done++; } } if ($done == 0) { echo '<tr><td colspan="4"><p class="nothing_here">No bonuses configured yet. <a href="' . escape_html(static_evaluate_tempcode(build_url(array('page' => 'group_points'), 'adminzone'))) . '">Configure bonuses here</a>.</p></td></tr>';