SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | /** | |
| 3 | - | * CubePoints admin page: manage |
| 3 | + | * CubePoints admin page: managerep |
| 4 | */ | |
| 5 | ||
| 6 | - | function cp_admin_manage() |
| 6 | + | function cp_admin_manage_rep() |
| 7 | {
| |
| 8 | ||
| 9 | ?> | |
| 10 | ||
| 11 | <div class="wrap"> | |
| 12 | - | <h2>CubePoints - <?php _e('Manage', 'cp'); ?></h2>
|
| 12 | + | <h2>CubePoints - <?php _e('Manage Reputation', 'cp'); ?></h2>
|
| 13 | - | <?php _e('Manage the points of your users.', 'cp'); ?><br /><br />
|
| 13 | + | <?php _e('Manage the Reputation of your users.', 'cp'); ?><br /><br />
|
| 14 | <div class="updated" id="cp_manage_updated" style="display: none;"></div> | |
| 15 | <?php | |
| 16 | global $wpdb; | |
| 17 | $results = $wpdb->get_results("SELECT * FROM `".$wpdb->users."` ORDER BY user_login ASC");
| |
| 18 | ?> | |
| 19 | ||
| 20 | <table id="cp_manage_table" class="widefat datatables"> | |
| 21 | - | <thead><tr><th scope="col" width="35"></th><th scope="col"><?php _e('User','cp'); ?></th><th scope="col" width="120"><?php _e('Points','cp'); ?></th><th scope="col" width="180"><?php _e('Update','cp'); ?></th></tr></thead>
|
| 21 | + | <thead><tr><th scope="col" width="35"></th><th scope="col"><?php _e('User','cp'); ?></th><th scope="col" width="120"><?php _e('Reputation','cp'); ?></th><th scope="col" width="180"><?php _e('Update','cp'); ?></th></tr></thead>
|
| 22 | - | <tfoot><tr><th scope="col"></th><th scope="col"><?php _e('User','cp'); ?></th><th scope="col"><?php _e('Points','cp'); ?></th><th scope="col"><?php _e('Update','cp'); ?></th></tr></tfoot>
|
| 22 | + | <tfoot><tr><th scope="col"></th><th scope="col"><?php _e('User','cp'); ?></th><th scope="col"><?php _e('Reputation','cp'); ?></th><th scope="col"><?php _e('Update','cp'); ?></th></tr></tfoot>
|
| 23 | ||
| 24 | <?php | |
| 25 | foreach($results as $result){
| |
| 26 | $user = get_userdata($result->ID); | |
| 27 | $username = $user->user_login; | |
| 28 | $user_nicename = $user->display_name; | |
| 29 | $gravatar = get_avatar( $result->ID , $size = '32' ); | |
| 30 | ?> | |
| 31 | <tr> | |
| 32 | <td> | |
| 33 | <?php echo $gravatar; ?> | |
| 34 | </td> | |
| 35 | <td title="<?php echo $user_nicename ?>"> | |
| 36 | <strong><?php echo $username; ?></strong><br /><i><?php echo $user->user_email; ?></i> | |
| 37 | </td> | |
| 38 | <td class="cp_manage_form_points"> | |
| 39 | - | <span id="cp_manage_form_points_<?php echo $result->ID; ?>"><?php cp_displayPoints($result->ID); ?></span> |
| 39 | + | <span id="cp_manage_form_points_<?php echo $result->ID; ?>"><?php cp_displayReputation($result->ID); ?></span> |
| 40 | </td> | |
| 41 | <td class="cp_manage_form_update"> | |
| 42 | <form method="post" name="cp_manage_form_<?php echo $result->ID; ?>" id="cp_manage_form_<?php echo $result->ID; ?>"> | |
| 43 | <input type="hidden" name="cp_manage_form_id" value="<?php echo $result->ID; ?>" /> | |
| 44 | - | <input type="text" name="cp_manage_form_points" value="<?php echo cp_getPoints($result->ID); ?>" /> |
| 44 | + | <input type="text" name="cp_manage_form_points" value="<?php echo cp_getReputation($result->ID); ?>" /> |
| 45 | <input type="submit" value="<?php _e('Update', 'cp'); ?>" />
| |
| 46 | <img src="<?php echo WP_PLUGIN_URL.'/'.str_replace(basename(__FILE__),"",plugin_basename(__FILE__)). 'assets/load.gif'; ?>" style="display: none;" /> | |
| 47 | </form> | |
| 48 | </td> | |
| 49 | </tr> | |
| 50 | <?php | |
| 51 | } | |
| 52 | ?> | |
| 53 | </table> | |
| 54 | ||
| 55 | </div> | |
| 56 | ||
| 57 | <script type="text/javascript"> | |
| 58 | jQuery(document).ready(function() {
| |
| 59 | ||
| 60 | jQuery(".cp_manage_form_update form").submit(function() {
| |
| 61 | user_id = jQuery(this).children('input[name=cp_manage_form_id]').val();
| |
| 62 | points = jQuery(this).children('input[name=cp_manage_form_points]').val();
| |
| 63 | submit = jQuery(this).children('input[type=submit]');
| |
| 64 | loadImg = jQuery(this).children('img');
| |
| 65 | ||
| 66 | jQuery(".cp_manage_form_update form").children('input').attr('disabled', true);
| |
| 67 | submit.hide(); | |
| 68 | loadImg.css('display', 'inline-block');
| |
| 69 | jQuery(this).children('input[name=cp_manage_form_points]').attr('readonly', true);
| |
| 70 | jQuery('#cp_manage_form_points_'+user_id).hide(100);
| |
| 71 | ||
| 72 | jQuery.post( | |
| 73 | '<?php echo bloginfo('url').'/wp-admin/admin-ajax.php'; ?>',
| |
| 74 | {
| |
| 75 | action: 'cp_manage_form_submit', | |
| 76 | user_id: user_id, | |
| 77 | points: points | |
| 78 | }, | |
| 79 | function(data,status){
| |
| 80 | if(status!='success'){
| |
| 81 | message = '<?php _e('Connection problem. Please check that you are connected to the internet.', 'cp'); ?>';
| |
| 82 | } else if(data.error!='ok') {
| |
| 83 | message = data.error; | |
| 84 | } else {
| |
| 85 | jQuery("#cp_manage_form_points_"+user_id).html(data.points_formatted);
| |
| 86 | jQuery("#cp_manage_form_points_"+user_id).show(100);
| |
| 87 | jQuery('#cp_manage_form_'+data.user_id).children('input[name=cp_manage_form_points]').val(data.points);
| |
| 88 | jQuery('#cp_manage_form_'+data.user_id).children('input[name=cp_manage_form_points]').removeAttr('readonly');
| |
| 89 | - | message = '<?php _e("Points updated for", 'cp'); ?>' + ' "' + data.username + '"';
|
| 89 | + | message = '<?php _e("Reputation updated for", 'cp'); ?>' + ' "' + data.username + '"';
|
| 90 | } | |
| 91 | jQuery("#cp_manage_updated").html('<p><strong>'+message+'</strong></p>');
| |
| 92 | jQuery("#cp_manage_updated").show(100);
| |
| 93 | loadImg.hide(); | |
| 94 | submit.show(); | |
| 95 | jQuery(".cp_manage_form_update form").children('input').removeAttr('disabled');
| |
| 96 | }, | |
| 97 | "json" | |
| 98 | ); | |
| 99 | return false; | |
| 100 | }); | |
| 101 | ||
| 102 | jQuery('#cp_manage_table').dataTable({
| |
| 103 | "bStateSave": true, | |
| 104 | "bSort": false, | |
| 105 | "aoColumns": [ { "bSearchable": false },{},{},{ "bSearchable": false } ]
| |
| 106 | }); | |
| 107 | ||
| 108 | }); | |
| 109 | ||
| 110 | </script> | |
| 111 | ||
| 112 | - | <?php do_action('cp_admin_manage'); ?>
|
| 112 | + | <?php do_action('cp_admin_manage_rep'); ?>
|
| 113 | ||
| 114 | <?php | |
| 115 | } | |
| 116 | ?> |