Skip to content

Commit

Permalink
1.1.9
Browse files Browse the repository at this point in the history
Lock by category
  • Loading branch information
eballarin committed Jan 15, 2014
1 parent 5e2edb1 commit 1619913
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 58 deletions.
5 changes: 4 additions & 1 deletion game-on.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Authors: Semar Yousif, Vincent Astolfi, Ezio Ballarin, Forest Hoffman
Contributors: Isaac Canada
Author URI: http://maclab.guhsd.net/
Version: 1.1.8
Version: 1.1.9
*/
include('go_datatable.php');
include('types/types.php');
Expand Down Expand Up @@ -41,6 +41,7 @@
add_action('go_return_currency','go_return_currency');
add_action('go_return_points','go_return_points');
add_action('go_return_minutes','go_return_minutes');
add_action('go_display_user_focuses', 'go_display_user_focuses');
add_action('admin_menu', 'go_ranks');
add_action('admin_menu', 'go_clipboard');
add_action('admin_menu', 'go_mail');
Expand All @@ -56,6 +57,7 @@
add_action('admin_bar_init','go_global_defaults');
add_action('admin_bar_init','go_global_info');
add_action('go_get_all_ranks','go_get_all_ranks');
add_action('go_get_all_focuses', 'go_get_all_focuses');
add_action('wp_ajax_unlock_stage', 'unlock_stage');
add_action('wp_ajax_task_change_stage','task_change_stage');
add_action('admin_bar_init', 'go_admin_bar');
Expand All @@ -69,6 +71,7 @@
add_action('wp_ajax_go_admin_bar_stats','go_admin_bar_stats');
add_action('wp_ajax_go_class_a_save','go_class_a_save');
add_action('wp_ajax_go_class_b_save','go_class_b_save');
add_action('wp_ajax_go_focus_save','go_focus_save');
add_action('wp_ajax_go_stats_task_list','go_stats_task_list');
add_action('wp_ajax_go_stats_points','go_stats_points');
add_action('wp_ajax_go_stats_currency','go_stats_currency');
Expand Down
9 changes: 8 additions & 1 deletion go_clipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function go_clipboard_menu() {
<th class="header" style="width:10%;"><a href="#" >Name</a></th>
<th class="header" style="width:10%;""><a href="#" >Gamertag</a></th>
<th class="header" style="width:8%;"><a href="#" >Rank</a></th>
<th class="header" style="width:8%;"><a href="#" ><?php echo go_return_options('go_focus_name'); ?></a></th>
<th class="header" style="width:6%;"><a href="#" ><?php echo go_return_options('go_currency_name'); ?></a></th>
<th class="header" style="width:8%;"><a href="#">Minutes</a></th>
<th class="header" style="width:5%;" align="center"><a href="#"><?php echo go_return_options('go_points_name'); ?></a></th>
Expand Down Expand Up @@ -99,6 +100,11 @@ function go_clipboard_intable(){
FROM ".$table_name_user_meta."
WHERE meta_key = 'wp_capabilities'
AND meta_value LIKE '%subscriber%'");
$focuses = get_option('go_focus');
$focuses_list = '';
foreach($focuses as $focus){
$focuses_list .= '<option name="'.$focus.'" value="'.$focus.'">'.$focus.'</option>';
}
foreach($uid as $id){
foreach($id as $value){
$class_a = get_user_meta($value, 'go_classifications',true);
Expand All @@ -110,6 +116,7 @@ function go_clipboard_intable(){
$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);
$infractions = go_return_infractions($value);
$minutes = go_return_minutes($value);
$currency = go_return_currency($value);
Expand All @@ -121,7 +128,7 @@ function go_clipboard_intable(){
$third_stage = (int)$wpdb->get_var("select count(*) from ".$table_name_go." where uid = $value and status = 3");
$fourth_stage = (int)$wpdb->get_var("select count(*) from ".$table_name_go." where uid = $value and status = 4");

echo '<tr><td><input class="go_checkbox" type="checkbox" name="go_selected" value="'.$value.'"></td><td><span><a href="#" onclick="go_admin_bar_stats_page_button('.$value.'); " >'.$user_login.'</a></td><td>'.$class_a[$class_a_choice].'</td><td><a href="'.$user_url.'" target="_blank">'.$user_last_name.', '.$user_first_name.'</a></td><td>'.$user_display.'</td><td>'.$current_rank.'</td><td>'.$currency.'</td><td>'.$minutes.'</td><td>'.$points.'</td><td>'.$infractions.'</td><td>'.$first_stage.'</td><td>'.$second_stage.'</td><td>'.$third_stage.'</td><td>'.$fourth_stage.'</td></tr>';
echo '<tr><td><input class="go_checkbox" type="checkbox" name="go_selected" value="'.$value.'"></td><td><span><a href="#" onclick="go_admin_bar_stats_page_button('.$value.'); " >'.$user_login.'</a></td><td>'.$class_a[$class_a_choice].'</td><td><a href="'.$user_url.'" target="_blank">'.$user_last_name.', '.$user_first_name.'</a></td><td>'.$user_display.'</td><td>'.$current_rank.'</td><td><select id="go_focus" onchange="go_user_focus_change('.$value.', this);"><option name="'.$user_focuses.'" value="'.$user_focuses.'">'.$user_focuses.' </option>'.$focuses_list.'</select></td><td>'.$currency.'</td><td>'.$minutes.'</td><td>'.$points.'</td><td>'.$infractions.'</td><td>'.$first_stage.'</td><td>'.$second_stage.'</td><td>'.$third_stage.'</td><td>'.$fourth_stage.'</td></tr>';

}}}}
die();
Expand Down
5 changes: 4 additions & 1 deletion go_datatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ function go_install_data(){
'go_infractions_name'=>'Infractions',
'go_max_infractions'=> 3,
'go_multiplier_rounding'=>'a:9:{i:0;s:1:"3";i:1;s:1:"3";i:2;s:1:"3";i:3;s:1:"3";i:4;s:1:"2";i:5;s:1:"2";i:6;s:1:"2";i:7;s:1:"2";i:8;s:1:"2";}',
'go_minutes_color_limit'=>'-900,-600,-300,0'
'go_minutes_color_limit'=>'-900,-600,-300,0',
'go_focus_name' => 'Focus',
'go_focus_switch'=>'Off',
'go_focus'=>''
);
foreach($options_array as $key => $value){
add_option( $key, $value );
Expand Down
2 changes: 1 addition & 1 deletion go_definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function go_define_options(){
global $wpdb;
$file_name = $real_file = plugin_dir_path( __FILE__ ) . '/' . 'go_definitions.php';
$array = explode(',','go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name, go_max_infractions, go_infractions_name, go_multiplier,go_multiplier_switch,go_multiplier_rounding,go_minutes_color_limit');
$array = explode(',','go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name, go_max_infractions, go_infractions_name, go_multiplier,go_multiplier_switch,go_multiplier_rounding,go_minutes_color_limit,go_focus_switch,go_focus_name');
foreach($array as $key=>$value){
$value = trim($value);
$content = get_option($value);
Expand Down
153 changes: 124 additions & 29 deletions go_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ function game_on_options() {
<?php
echo go_sub_option( 'class_a_name', 'The name of the first classification. Such as Period or Color.','Classification A Name', 'go_class_a_name','go_class_a_name', 'What would you like to call the first classification?');
echo go_sub_option( 'class_b_name', 'The name of the second classification. Such as Computer or Skill.','Classification B Name', 'go_class_b_name','go_class_b_name', 'What would you like to call the second classification?');
?> </div>
?>

</div>
<div class="opt-box">
<div class="pa">
<h4> A </h4>
Expand Down Expand Up @@ -184,9 +186,38 @@ function game_on_options() {
</ul>
<button type="button" style="width:100%;" onclick="go_class_b_new_input();" id="go_class_b_add_input" value="New" >New</button>
<button type="button" style="width:100%;" onclick="go_class_b_save();" id="go_class_b_add_input" value="Save Classifications" >Save</button>
</div></div>

</div>
</div>

<div class="opt-box">
<h3> Focuses </h3>
<?php echo go_sub_option( 'focus_name', 'The name of focuses such as \'Career\' or \'Pathway\' ', 'Focus Name', 'go_focus_name','go_focus_name', 'What would you like to call focuses?');?>
</div>

<div class="opt-box">
<div class="pa">
<?php go_opt_help('focus_explanation', 'The switch to turn focuses on and off. Focuses are the areas of interest or study that users choose. Focuses can be purchased via store items.'); ?>
<strong><?php echo 'Turn focuses on or off: ';?> </strong><br />
On:<input type="radio" <?php if(go_return_options('go_focus_switch') == 'On'){echo 'checked="checked"';} ?> name="go_focus_switch" size="45" value="On" style="margin-left: 5px;width: 20px;" /><br />
Off:<input type="radio" <?php if(go_return_options('go_focus_switch') == 'Off'){echo 'checked="checked"';} ?>name="go_focus_switch" size="45" value="Off" style="margin-left: 5px;width: 20px;" /><br />
<strong><?php echo 'List of focuses: '; ?></strong><br />
<i>Note: Clicking save will add these values as task categories</i>
<ul id="sortable_focus">
<?php
$focus = get_option('go_focus');
if($focus){
foreach($focus as $key=>$value){
?>
<li class="ui-state-default" class="go_list"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><input id="go_focus" type="text" value="<?php echo $value; ?>"/></li>
<?php
}
}
?>
</ul>
<button type="button" style="width:100%;" onclick="go_focus_new_input();" id="go_focus_add_input" value="New" >New</button>
<button type="button" style="width:100%;" onclick="go_focus_save();" id="go_focus_add_input" value="Save Classifications" >Save</button>
</div>
</div>

<div class="opt-box">
<h3> Presets </h3> </div>
Expand Down Expand Up @@ -228,7 +259,7 @@ function game_on_options() {

<span class="opt-inp"><input type="submit" name="Submit" value="Save Options" /> </span>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name,go_max_infractions,go_infractions_name,go_minutes_color_limit,go_multiplier,go_multiplier_switch,go_multiplier_rounding" />
<input type="hidden" name="page_options" value="go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name,go_max_infractions,go_infractions_name,go_minutes_color_limit,go_multiplier,go_multiplier_switch,go_multiplier_rounding,go_focus_switch,go_focus_name" />
</form>

<script type="text/javascript">
Expand Down Expand Up @@ -278,6 +309,64 @@ function go_class_b_save(){
die();
}

function go_focus_save(){
global $wpdb;
$array = $_POST['focus_array'];
$terms = $wpdb->get_results("SELECT * FROM $wpdb->terms", ARRAY_A);
$term_names = array();

foreach($array as $key=>$value){
if ($value == ''){
unset($array[$key]);
}
if(!term_exists($value, 'task_focus_categories')){
wp_insert_term($value, 'task_focus_categories');
}
}

foreach($terms as $term){
if($term['name'] != 'Uncategorized'){
array_push($term_names, $term['name']);
}
}
$delete_terms = array_diff($term_names, $array);
foreach($delete_terms as $term){
$term_id = $wpdb->get_var("SELECT `term_id` FROM $wpdb->terms WHERE `name`='".$term."'");
wp_delete_term($term_id, 'task_focus_categories');
}
update_option('go_focus',$array);
$focus = get_option('go_focus',false);
if($focus){
foreach($focus as $key=>$value){
?>
<li class="ui-state-default" class="go_list"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><input id="go_focus" type="text" value="<?php echo $value; ?>"/></li>
<?php
}
}
die();
}

function go_get_all_focuses() {
if(get_option('go_focus')){
$all_focuses = get_option('go_focus');
}
$all_focuses_sorted = array();
if($all_focuses){
foreach($all_focuses as $focus ) {
$all_focuses_sorted[] = array('name' => $focus , 'value' => $focus);
}
}
return $all_focuses_sorted;
}

add_action('wp_ajax_go_new_user_focus', 'go_new_user_focus');
function go_new_user_focus(){
$new_user_focus = $_POST['new_user_focus'];
$user_id = $_POST['user_id'];
update_user_meta($user_id, 'go_focus', $new_user_focus);
die();
}

function go_presets_reset(){
global $wpdb;
if(!empty($_POST['presets'])){
Expand Down Expand Up @@ -354,25 +443,31 @@ function go_extra_profile_fields( $user ) { ?>
</tr> <?php }} ?> </tbody>
<tr>
<td><button onclick="go_add_class();" type="button">+</button></td>
</tr>

</table>
<script type="text/javascript" language="javascript">
function go_add_class(){
var ajaxurl = "<?php global $wpdb;
echo admin_url( 'admin-ajax.php' ) ; ?>";
jQuery.ajax({
type: "post",url: ajaxurl,data: {
action: 'go_user_option_add',
go_clipboard_class_a_choice: jQuery('#go_clipboard_class_a_choice').val()},
success: function(html){
jQuery('#go_user_form_table_body').append(html);
<?php
if(get_option('go_focus_switch', true) == 'On'){
?>
<h3>User <?php echo go_return_options('go_focus_name');?></h3>
<?php
echo go_display_user_focuses($user->ID);
}
});
?>
<script type="text/javascript" language="javascript">
function go_add_class(){
var ajaxurl = "<?php global $wpdb;
echo admin_url( 'admin-ajax.php' ) ; ?>";
jQuery.ajax({
type: "post",
url: ajaxurl,
data: {
action: 'go_user_option_add',
go_clipboard_class_a_choice: jQuery('#go_clipboard_class_a_choice').val()
},
success: function(html){
jQuery('#go_user_form_table_body').append(html);
}
});
}



</script>
<?php

Expand Down Expand Up @@ -425,16 +520,16 @@ function go_user_option_add(){

function go_save_extra_profile_fields( $user_id ) {

if(isset($_POST['class_a_user'])){
foreach($_POST['class_a_user'] as $key=>$value){
if($value != 'go_remove'){
$class_a = $value;
$class_b = $_POST['class_b_user'][$key];
$class[$class_a] = $class_b;
if(isset($_POST['class_a_user'])){
foreach($_POST['class_a_user'] as $key=>$value){
if($value != 'go_remove'){
$class_a = $value;
$class_b = $_POST['class_b_user'][$key];
$class[$class_a] = $class_b;
}
}
update_user_meta( $user_id, 'go_classifications', $class );
}
update_user_meta( $user_id, 'go_classifications', $class );
}
}

function go_return_presets_options(){
Expand All @@ -454,7 +549,7 @@ function go_return_presets_options(){
function go_update_globals(){
global $wpdb;
$file_name = $real_file = plugin_dir_path( __FILE__ ) . '/' . 'go_definitions.php';
$array = explode(',','go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name, go_max_infractions,go_infractions_name, go_multiplier,go_multiplier_switch,go_multiplier_rounding,go_minutes_color_limit');
$array = explode(',','go_tasks_name,go_tasks_plural_name,go_currency_name,go_points_name,go_first_stage_name,go_second_stage_name,go_second_stage_button,go_third_stage_name,go_third_stage_button,go_fourth_stage_name,go_fourth_stage_button,go_currency_prefix,go_currency_suffix, go_points_prefix, go_points_suffix, go_admin_bar_add_switch, go_repeat_button, go_class_a_name, go_class_b_name, go_max_infractions,go_infractions_name, go_multiplier,go_multiplier_switch,go_multiplier_rounding,go_minutes_color_limit,go_focus_switch,go_focus_name');
foreach($array as $key=>$value){
$value = trim($value);
$content = get_option($value);
Expand Down
14 changes: 14 additions & 0 deletions go_returns.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,19 @@ function go_display_currency($currency){
$suffix = go_return_options('go_currency_suffix');
return $prefix.$currency.$suffix;
}
function go_display_user_focuses($user_id){

if(get_user_meta($user_id, 'go_focus',true)){
if(!is_array(get_user_meta($user_id, 'go_focus',true))){
$valueu = get_user_meta($user_id, 'go_focus',true);
}else{
$valueu = implode(', ',get_user_meta($user_id, 'go_focus', true));
}
} else{
$valueu = 'No '.go_return_options('go_focus_name');
}

return $valueu;
}

?>
12 changes: 12 additions & 0 deletions scripts/go_clipboard.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions scripts/go_periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ function go_class_b_save(){
});
}

jQuery('#sortable_focus').sortable({axis:"y"});
function go_focus_new_input(){
jQuery('#sortable_focus').append(' <li class="ui-state-default" class="go_list"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><input id="go_focus" type="text" value=""/></li>');
}
function go_focus_save(){
var values = jQuery("input[id='go_focus']").map(function(){return jQuery(this).val();}).get();
jQuery.ajax({
type: "post",
url: MyAjax.ajaxurl,
data: {
action: 'go_focus_save',
focus_array: values
},
success: function(html){
jQuery('#sortable_focus').html(html);
}
});
}

jQuery('#sortable_go_presets').sortable({axis:"y"});

Expand Down
12 changes: 12 additions & 0 deletions types/store/includes/lightbox/buy-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ function go_buy_item(){
$req_currency = $custom_fields['go_mta_store_currency'][0];
$req_time = $custom_fields['go_mta_store_time'][0];
$req_rank = $custom_fields['go_mta_store_rank'][0];

if($custom_fields['go_mta_focus_item_switch'][0] && $custom_fields['go_mta_focuses'][0]){
$item_focus_switch = true;
$item_focus = $custom_fields['go_mta_focuses'][0];
}

if($custom_fields['go_mta_store_itemURL'][0] && $custom_fields['go_mta_store_itemURL'][0] != ''){
$item_url = $custom_fields['go_mta_store_itemURL'][0];
}

$repeat = 'on';
$user_points = go_return_points($user_ID);
$user_currency = go_return_currency($user_ID);
Expand Down Expand Up @@ -67,6 +74,11 @@ function go_buy_item(){
}

if ($points_re == true && $currency_re == true && $time_re == true && $rank_re == true) {
if($item_focus_switch && $item_focus){
$user_focuses = (array) get_user_meta($user_ID, 'go_focus', true);
$user_focuses[] = $item_focus;
update_user_meta($user_ID, 'go_focus', $user_focuses);
}
go_add_post($user_ID, $the_id, -1, -$req_points, -$req_currency, $page_id, $repeat);
if($item_url){
$item_hyperlink = '<a target="_blank" href="'.$item_url.'">Grab your loot!</a>';
Expand Down
Loading

0 comments on commit 1619913

Please sign in to comment.