Exemple #1
0
function go_global_info()
{
    global $wpdb;
    global $current_user_id;
    global $current_points;
    global $current_currency;
    global $current_bonus_currency;
    global $current_penalty;
    $current_user = wp_get_current_user();
    $current_user_id = $current_user->ID;
    $current_points = go_return_points($current_user_id);
    $current_currency = go_return_currency($current_user_id);
    $current_bonus_currency = go_return_bonus_currency($current_user_id);
    $current_penalty = go_return_penalty($current_user_id);
    go_get_rank($current_user_id);
}
Exemple #2
0
function go_clipboard_intable()
{
    global $wpdb;
    $class_a_choice = $_POST['go_clipboard_class_a_choice'];
    $table_name_user_meta = $wpdb->prefix . 'usermeta';
    $table_name_go = $wpdb->prefix . 'go';
    $uid = $wpdb->get_results("SELECT user_id \n\t\tFROM {$table_name_user_meta} \n\t\tWHERE meta_key = '{$wpdb->prefix}capabilities' \n\t\tAND meta_value NOT LIKE '%administrator%'");
    print_r($uid);
    foreach ($uid as $id) {
        foreach ($id as $value) {
            $class_a = get_user_meta($value, 'go_classifications', true);
            if ($class_a) {
                if ($class_a[$class_a_choice]) {
                    $user_data_key = get_userdata($value);
                    $user_login = $user_data_key->user_login;
                    $user_display = $user_data_key->display_name;
                    $user_first_name = $user_data_key->user_firstname;
                    $user_last_name = $user_data_key->user_lastname;
                    $user_url = $user_data_key->user_url;
                    $user_focuses = go_display_user_focuses($value);
                    $focus_name = get_option('go_focus_name');
                    $focuses = get_option('go_focus');
                    $focuses_list = '';
                    $focuses_list = "<option value='No {$focus_name}' " . (empty($user_focuses) || $user_focuses == "No {$focus_name}" ? "selected" : "") . ">No {$focus_name}</option>";
                    foreach ($focuses as $focus) {
                        $focuses_list .= "<option value='{$focus}' " . ($focus == $user_focuses ? "selected" : "") . ">{$focus}</option>";
                    }
                    $bonus_currency = go_return_bonus_currency($value);
                    $penalty = go_return_penalty($value);
                    $currency = go_return_currency($value);
                    $points = go_return_points($value);
                    $badge_count = go_return_badge_count($value);
                    go_get_rank($value);
                    global $current_rank;
                    echo "<tr id='user_{$value}'>\n\t\t\t\t\t\t\t<td><input class='go_checkbox' type='checkbox' name='go_selected' value='{$value}'/></td>\n\t\t\t\t\t\t\t<td><span><a href='#' onclick='go_admin_bar_stats_page_button(&quot;{$value}&quot;);'>{$user_login}</a></td>\n\t\t\t\t\t\t\t<td>{$class_a[$class_a_choice]}</td>\n\t\t\t\t\t\t\t<td><a href='{$user_url}' target='_blank'>{$user_last_name}, {$user_first_name}</a></td>\n\t\t\t\t\t\t\t<td>{$user_display}</td>\n\t\t\t\t\t\t\t<td>{$current_rank}</td>\n\t\t\t\t\t\t\t" . (go_return_options('go_focus_switch') == 'On' ? "<td><select class='go_focus' onchange='go_user_focus_change(&quot;{$value}&quot;, this);'>{$focuses_list}</select</td>" : "") . "\n\t\t\t\t\t\t\t<td class='user_points'>{$points}</td>\n\t\t\t\t\t\t\t<td class='user_currency'>{$currency}</td>\n\t\t\t\t\t\t\t<td class='user_bonus_currency'>{$bonus_currency}</td>\n\t\t\t\t\t\t\t<td class='user_penalty'>{$penalty}</td>\n\t\t\t\t\t\t\t<td class='user_badge_count'>{$badge_count}</td>\n\t\t\t\t\t\t  </tr>";
                }
            }
        }
    }
    die;
}
Exemple #3
0
function go_admin_bar_stats()
{
    global $wpdb;
    $table_name_go = $wpdb->prefix . "go";
    if ($_POST['uid']) {
        $current_user = get_userdata($_POST['uid']);
    } else {
        $current_user = wp_get_current_user();
    }
    ?>
<input type="hidden" id="go_stats_hidden_input" value="<?php 
    echo $_POST['uid'];
    ?>
"/><?php 
    $user_fullname = $current_user->first_name . ' ' . $current_user->last_name;
    $user_login = $current_user->user_login;
    $user_display_name = $current_user->display_name;
    $user_id = $current_user->ID;
    $user_website = $current_user->user_url;
    $current_user_id = $current_user->ID;
    $user_avatar = get_avatar($current_user_id, 161);
    // option names
    $points_name = go_return_options('go_points_name');
    $currency_name = go_return_options('go_currency_name');
    $bonus_currency_name = go_return_options('go_bonus_currency_name');
    $penalty_name = go_return_options('go_penalty_name');
    $minutes_name = go_return_options('go_minutes_name');
    // user pnc
    go_get_rank($current_user_id);
    $current_points = go_return_points($current_user_id);
    $current_currency = go_return_currency($current_user_id);
    $current_bonus_currency = go_return_bonus_currency($current_user_id);
    $current_penalty = go_return_penalty($current_user_id);
    $current_minutes = go_return_minutes($current_user_id);
    global $current_rank;
    global $current_rank_points;
    global $next_rank;
    global $next_rank_points;
    $display_current_rank_points = $current_points - $current_rank_points;
    $display_next_rank_points = $next_rank_points - $current_rank_points;
    $percentage_of_level = $display_current_rank_points / $display_next_rank_points * 100;
    ?>
	<div id='go_stats_lay'>
		<div id='go_stats_gravatar'><?php 
    echo $user_avatar;
    ?>
</div>
		<div id='go_stats_header'>
			<div id='go_stats_user_info'>
				<?php 
    echo "{$user_fullname}<br/>{$user_login}<br/><a href='{$user_website}' target='_blank'>{$user_display_name}</a><br/><div id='go_stats_user_points'><span id='go_stats_user_points_value'>{$current_points}</span> {$points_name}</div><div id='go_stats_user_currency'><span id='go_stats_user_currency_value'>{$current_currency}</span> {$currency_name}</div><div id='go_stats_user_bonus_currency'><span id='go_stats_user_bonus_currency_value'>{$current_bonus_currency}</span> {$bonus_currency_name}</div>{$current_penalty} {$penalty_name}<br/>{$current_minutes} {$minutes_name}";
    ?>
			</div>
			<div id='go_stats_user_rank'><?php 
    echo $current_rank;
    ?>
</div>
			<div id='go_stats_user_progress'>
				<div id="go_stats_progress_text_wrap">
					<div id='go_stats_progress_text'><?php 
    echo "<span id='go_stats_user_progress_top_value'>{$display_current_rank_points}</span>/<span id='go_stats_user_progress_bottom_value'>{$display_next_rank_points}</span>";
    ?>
</div>
				</div>
				<div id='go_stats_progress_fill' style='width: <?php 
    echo $percentage_of_level;
    ?>
%;<?php 
    $color = barColor($current_bonus_currency);
    echo "background-color: {$color}";
    if ($percentage_of_level >= 98) {
        echo "border-radius: 15px";
    }
    ?>
'></div></div>
			<div id='go_stats_user_tabs'>
            <!--
				<a href='javascript:;' id="go_stats_body_progress" class='go_stats_body_selectors' tab='progress'>
					WEEKLY PROGRESS
				</a> | 
            -->
            	<?php 
    $is_admin = current_user_can('manage_options');
    if ($is_admin) {
        ?>
               		<a href='javascript:;' id='go_stats_admin_help' class='go_stats_body_selectors' tab='help'>
                    	HELP
                    </a> |
                <?php 
    }
    ?>
				<a href='javascript:;' id="go_stats_body_tasks" class='go_stats_body_selectors' tab='tasks'>
					<?php 
    echo strtoupper(go_return_options('go_tasks_plural_name'));
    ?>
				</a> | 
				<a href='javascript:;' id="go_stats_body_items" class='go_stats_body_selectors' tab='items'>
					<?php 
    echo strtoupper(go_return_options('go_inventory_name'));
    ?>
				</a> | 
				<a href='javascript:;' id="go_stats_body_rewards" class='go_stats_body_selectors' tab='rewards'>
					REWARDS
				</a> | 
				<a href='javascript:;' id="go_stats_body_minutes" class='go_stats_body_selectors' tab='minutes'>
					<?php 
    echo strtoupper($minutes_name);
    ?>
				</a> |
				<a href='javascript:;' id="go_stats_body_penalties" class='go_stats_body_selectors' tab='penalties'>
					<?php 
    echo strtoupper($penalty_name);
    ?>
				</a> | 
				<a href='javascript:;' id="go_stats_body_badges" class='go_stats_body_selectors' tab='badges'>
					<?php 
    echo strtoupper(go_return_options('go_badges_name'));
    ?>
				</a> | 
				<a href='javascript:;' id="go_stats_body_leaderboard" class='go_stats_body_selectors' tab='leaderboard'>
					<?php 
    echo strtoupper(go_return_options('go_leaderboard_name'));
    ?>
				</a>
			</div>
		</div>
		<div id='go_stats_body'></div>
	</div>
	<?php 
    die;
}
Exemple #4
0
function go_update_ranks($user_id, $total_points)
{
    global $wpdb;
    global $current_rank;
    go_get_rank($user_id);
    global $current_rank_points;
    global $next_rank;
    global $next_rank_points;
    global $current_points;
    $ranks = get_option('go_ranks');
    $name_array = $ranks['name'];
    $points_array = $ranks['points'];
    if ($next_rank != '') {
        if ($total_points >= $next_rank_points) {
            while (current($points_array) != $next_rank_points) {
                next($points_array);
            }
            while ($total_points >= current($points_array)) {
                $current_key = key($points_array);
                $new_rank = $name_array[$current_key];
                $new_rank_points = $points_array[$current_key];
                $new_next_rank = $name_array[$current_key + 1];
                $new_next_rank_points = $points_array[$current_key + 1];
                if ($ranks['badges'][$current_key]) {
                    $badge_id = $ranks['badges'][$current_key];
                    do_shortcode("[go_award_badge id='{$badge_id}' repeat='off' uid='{$user_id}']");
                }
                next($points_array);
            }
            $new_rank = array(array($new_rank, $new_rank_points), array($new_next_rank, $new_next_rank_points));
            $update = true;
        }
        if (!empty($points_array)) {
            reset($points_array);
        }
        if ($total_points < $current_rank_points) {
            while (current($points_array) != $current_rank_points) {
                next($points_array);
            }
            while ($total_points < current($points_array)) {
                $current_key = key($points_array);
                $new_rank = $name_array[$current_key - 1];
                $new_rank_points = $points_array[$current_key - 1];
                $new_next_rank = $name_array[$current_key];
                $new_next_rank_points = $points_array[$current_key];
                if ($ranks['badges'][$current_key]) {
                    go_remove_badge($user_id, $ranks['badges'][$current_key]);
                }
                prev($points_array);
            }
            $new_rank = array(array($new_rank, $new_rank_points), array($new_next_rank, $new_next_rank_points));
            $update = true;
        }
    }
    if ($update) {
        update_user_meta($user_id, 'go_rank', $new_rank);
        go_get_rank($user_id);
        global $current_rank;
        global $current_rank_points;
        global $next_rank;
        global $next_rank_points;
        global $counter;
        $counter++;
        $space = $counter * 85;
        echo '
		<div id="go_notification_level" class="go_notification" style="top: ' . ($space - 17) . 'px; color: #FFD700; width: 300px; height: 81.6px; font-size: 52px;"> ' . $current_rank . '!</div>
		<script type="text/javascript" language="javascript">
			go_notification(3000, jQuery("#go_notification_level"));
			jQuery("#go_admin_bar_rank").html("' . $current_rank . '");
		</script>';
    }
}
Exemple #5
0
function go_get_level_percentage($user_id)
{
    global $wpdb;
    $current_points = go_return_points($user_id);
    go_get_rank($user_id);
    global $current_currency;
    global $current_rank;
    global $next_rank_points;
    global $current_rank_points;
    $dom = $next_rank_points - $current_rank_points;
    if ($dom <= 0) {
        $dom = 1;
    }
    $percentage = ($current_points - $current_rank_points) / $dom * 100;
    if ($percentage <= 0) {
        $percentage = 0;
    } else {
        if ($percentage >= 100) {
            $percentage = 100;
        }
    }
    return $percentage;
}