Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cp_donatePoints($uid1, $uid2, $points) {
- $points = (int)$points;
- if ($points < 1) {
- return(__('Error: You must donate at least 1 point!','cp'));
- }
- if (cp_getPoints($uid1) < $points) {
- return(__('Error: Insufficient points to donate!','cp'));
- }
- global $wpdb, $bp;
- //969 = lottery2 613 = lottery
- $cp_bp_lottery_results = $wpdb->get_var("SELECT COUNT(*) FROM ".CPDB." WHERE uid='613' AND source = ".$bp->loggedin_user->id);
- $cp_bp_lottery2_results = $wpdb->get_var("SELECT COUNT(*) FROM ".CPDB." WHERE uid='969' AND source = ".$bp->loggedin_user->id);
- //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
- if (get_option('bp_leaderboard_cp_bp') == 10) {
- // Set Donation Ammounts
- /* if ($points == 150 OR $points == 250 OR $points == 50 OR $points == 100) { */
- if ($points == 150) {
- // Can Only Donate to these user IDs!
- if ($uid2 == 613 OR $uid2 == 969 OR $uid2 == 887){
- 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
- if ($cp_bp_lottery_results > 6) {
- return(__('Error: You have reached the maximum amount of entries for this contest.','cp'));
- }
- }
- 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
- if ($cp_bp_lottery2_results > 6) {
- return(__('Error: You have reached the maximum amount of entries for this contest.','cp'));
- }
- }
- cp_alterPoints($uid1, -$points);
- cp_alterPoints($uid2, $points);
- //log
- cp_log('donate',$uid1,-$points,$uid2);
- cp_log('donate',$uid2,$points,$uid1);
- $user_info = get_userdata($uid2);
- } else {
- return(__('Error: You cannot donate to this user!','cp'));
- }
- } else {
- return(__('Error: You did not donate the correct amount','cp'));
- }
- // This will run it the cp bp leaderboard is anything other than 10
- } else {
- cp_alterPoints($uid1, -$points);
- cp_alterPoints($uid2, $points);
- //log
- cp_log('donate',$uid1,-$points,$uid2);
- cp_log('donate',$uid2,$points,$uid1);
- $user_info = get_userdata($uid2);
- }
- // END Donation Limit
- return sprintf(__("%s have been donated to %s",'cp'),cp_formatPoints($points),$user_info->user_login) . '.';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement