SHARE
TWEET

Untitled

a guest Aug 12th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cp_donatePoints($uid1, $uid2, $points) {
  2.     $points = (int)$points;
  3.     if ($points < 1) {
  4.         return(__('Error: You must donate at least 1 point!','cp'));
  5.     }
  6.     if (cp_getPoints($uid1) < $points) {
  7.         return(__('Error: Insufficient points to donate!','cp'));
  8.     }
  9.    
  10.     global $wpdb, $bp;
  11.     //969 = lottery2 613 = lottery
  12.     $cp_bp_lottery_results = $wpdb->get_var("SELECT COUNT(*) FROM ".CPDB." WHERE uid='613' AND source = ".$bp->loggedin_user->id);
  13.     $cp_bp_lottery2_results = $wpdb->get_var("SELECT COUNT(*) FROM ".CPDB." WHERE uid='969' AND source = ".$bp->loggedin_user->id);
  14.    
  15.     //Turn this locked donation on or off 10 means it's on. Anything other than 10 means it's donation as normal. CubePoints BuddyPress - Points Leaderboard: Value
  16.     if (get_option('bp_leaderboard_cp_bp') == 10) {
  17.    
  18.         // Set Donation Ammounts
  19.         /* if ($points == 150 OR $points == 250 OR $points == 50 OR $points == 100) { */
  20.         if ($points == 150) {
  21.             // Can Only Donate to these user IDs!
  22.             if ($uid2 == 613 OR $uid2 == 969 OR $uid2 == 887){
  23.                
  24.                 if ($uid2 == 613) { // # is the lottery limit. Do one less than the limit for example if the limit is 4 put in 3 as limit
  25.                     if ($cp_bp_lottery_results > 6) {
  26.                         return(__('Error: You have reached the maximum amount of entries for this contest.','cp'));
  27.                     }
  28.                 }
  29.                 if ($uid2 == 969) { // # is the lottery limit. Do one less than the limit for example if the limit is 4 put in 3 as limit
  30.                     if ($cp_bp_lottery2_results > 6) {
  31.                         return(__('Error: You have reached the maximum amount of entries for this contest.','cp'));
  32.                     }
  33.                 }              
  34.                
  35.             cp_alterPoints($uid1, -$points);
  36.             cp_alterPoints($uid2, $points);
  37.             //log
  38.             cp_log('donate',$uid1,-$points,$uid2);
  39.             cp_log('donate',$uid2,$points,$uid1);
  40.             $user_info = get_userdata($uid2);
  41.             } else {
  42.                 return(__('Error: You cannot donate to this user!','cp'));
  43.             }
  44.            
  45.         } else {
  46.             return(__('Error: You did not donate the correct amount','cp'));
  47.         }
  48.     // This will run it the cp bp leaderboard is anything other than 10    
  49.     } else {
  50.             cp_alterPoints($uid1, -$points);
  51.             cp_alterPoints($uid2, $points);
  52.             //log
  53.             cp_log('donate',$uid1,-$points,$uid2);
  54.             cp_log('donate',$uid2,$points,$uid1);
  55.             $user_info = get_userdata($uid2);      
  56.     }      
  57.     // END Donation Limit
  58.    
  59.     return sprintf(__("%s have been donated to %s",'cp'),cp_formatPoints($points),$user_info->user_login) . '.';
  60. }
RAW Paste Data
Top