function lhg_hardware_scans_points_shortcode($attr) { global $lang; global $donation; $start = $attr['start']; $end = $attr['end']; $start_timestamp = strtotime($start); $end_timestamp = strtotime($enddate); if ($start == "") { $start_timestamp = cp_StartOfQuarter(); } if ($end == "") { $end_timestamp = time(); } # $total_points = 0; # collects all points collected in this time frame $donation_points = array(); # collects all points per donation target in this time frame # # donation points by hardware scans # $points_scan = lhg_points_from_hwscans($start_timestamp, $end_timestamp); foreach ($points_scan as $key => $points) { #error_log("Pts: $points -> $key"); $total_points += $points; $donation_points[$key] += $points; } # sort by points arsort($points_scan); $distri = lhg_get_distribution_array(); $logo = $distri[$distri_name]["logo"]; foreach ($points_scan as $key => $points) { $distri_name = lhg_get_distri_name($donation[$key]["Name"]); $logo = $distri[$distri_name]["logo"]; $url = $distri[$distri_name]["url"]; $scan_output .= '<div class="donations-short-user-list"> <div class="donations-short-user-list-avatar">' . '<a href="' . $url . '">' . "<img src=\"" . $logo . "\" width=45px></a>\n </div>\n\n " . '<div class="donations-short-user-list-text"> <center> <a href="' . $url . '">' . $donation[$key]["Name"] . "</a><br><b>{$points} points</b>\n \t</center>\n </div>\n\n </div>"; } return $scan_output; }
function lhg_return_donation_targets() { # returns two arrays # 1 ... name of company/organization to which donation will go # 2 ... amount of points for this company/organization # 3 ... number of users that donated to this company/organization global $donation; # returns collected points of ongoing quarter list($donation_target_sums, $donation_target_users) = lhg_return_donation_results(false, false); $j = 0; foreach ($donation_target_sums as $key => $points) { $donation_targets[$j] = $donation[$key]["Name"]; $donation_points[$j] = $points; $donation_users[$j] = $donation_target_users[$key]; $j++; } # also include points from hardware scans $start_timestamp = cp_StartOfQuarter(); $points_scan = lhg_points_from_hwscans($start_timestamp, time()); foreach ($points_scan as $key => $points) { #error_log("Pts: $points -> $key"); $total_points += $points; $donation_points[$key] += $points; $donation_targets[$j] = $donation[$key]["Name"]; $donation_points[$j] = $points; $donation_users[$j] = 0; $j++; } return array($donation_targets, $donation_points, $donation_users); }
function widget($args, $instance) { global $region; global $top_users; global $donation; global $txt_cp_title; global $txt_cp_karma; global $txt_cp_points; global $txt_cp_donates_to; global $txt_cp_longtext; global $txt_cp_language; # How many users to show for ongoing quarter $max_users_to_show = 5; $langurl = lhg_get_lang_url_from_region($region); extract($args, EXTR_SKIP); echo $before_widget; //$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $title = '<i class="icon-trophy menucolor"></i> ' . $txt_cp_title; if (!empty($title)) { echo $before_title . $title . $after_title; } //set default values if ($instance['num'] == '' || $instance['num'] == 0) { $instance['num'] = 1; } if ($instance['text'] == '') { $instance['text'] = '%user% (%points%)'; } # Show table of top users of ongoing Quarter list($list_uid, $list_points) = cp_getAllQuarterlyPoints(); #print "<br>Users:"; #var_dump($list_uid); $i = 0; if (sizeof($list_uid) > 0) { print '<table id="quarterly-points-table"> <tr id="quarterly-points-header-row"> <td class="qrtly-1" id="quarterly-points-1">Quarterly Points</td> <td class="qrtly-2" id="quarterly-points-2"></td> <td class="qrtly-3" id="quarterly-points-3">Username</td> <td class="qrtly-4" id="quarterly-points-3">Details</td> <td class="qrtly-5" id="quarterly-points-3">Total Points</td> </tr> '; } if (sizeof($list_uid) > 0) { foreach ($list_uid as $uid) { $user = get_userdata($uid); $name = $user->first_name . " " . $user->last_name; $points = $list_points[$i]; $avatar = get_avatar($uid, 40); $user_language_txt = lhg_get_locale_from_id($uid); $user_language_flag = lhg_show_flag_by_lang($user_language_txt); $total_karma = cp_getPoints($uid); //$num_com * 3 + $num_art * 50; //registration date $regdate = date("d. M Y", strtotime(get_userdata($uid)->user_registered)); //donates to $donation_target = get_user_meta($uid, 'user_donation_target', true); if ($donation_target == "") { $donation_target = 1; } //print_r($y); //if ($langurl != "") $langurl = "/".$langurl; #print "Name: ".$user->user_nicename." ($uid) - $points<br>"; echo '<tr> <td class="qrtly-1" > <div class="userlist-place-quarter">' . $points . ' ' . $txt_cp_points . ' </div> </td> <td class="quartery-points-avatar qrtly-2"> <a href="./hardware-profile/user' . $uid . '" class="recent-comments"> <div class="userlist-avatar">' . $avatar . ' </div> </a> </td> <td class="qrtly-3"> <div class="userlist-displayname"> <a href="./hardware-profile/user' . $uid . '" class="recent-comments">'; echo $user->user_nicename . ' </a> </div> </td> <td class="qrtly-4"> <div class="quarterly-points-userlist-details"> ' . $txt_cp_donates_to . ': ' . $donation[$donation_target]["Name"] . '<br> ' . $txt_cp_language . ': ' . $user_language_flag . ' </div> </td> <td class="qrtly-5"> <div class="quartly-points-totalpoints"> ' . $txt_cp_karma . ': ' . $total_karma . ' ' . $txt_cp_points . '<br> </div> </td> '; print "</tr>"; $i++; if ($i > $max_users_to_show - 1) { break; } } } if (sizeof($list_uid) > 0) { print "</table>"; } /* $top = cp_getAllPoints($instance['num'],get_option('cp_topfilter')); do_action('cp_topUsersWidget_before'); echo apply_filters('cp_topUsersWidget_before','<div class="userlist-all"><ul class="bwp-rc-ulist">'); $line = str_replace('%style%', $instance['style'], $line); foreach($top as $x=>$y){ $i++; $uid = $y['id']; $user = get_userdata($y['id']); $name = $user->first_name." ".$user->last_name; $string = str_replace('%string%', '', $instance['text']); $string = str_replace('%string%',$string,$line); $string = apply_filters('cp_displayUserInfo',$string,$y,$x+1); //Flag $user_language_txt = lhg_get_locale_from_id ( $uid ); $user_language_flag= lhg_show_flag_by_lang ( $user_language_txt ); //registration date $regdate = date("d. M Y", strtotime(get_userdata( $uid ) -> user_registered ) ); //donates to $donation_target = get_user_meta($uid,'user_donation_target',true); if ($donation_target == "") $donation_target = 1; $avatar = get_avatar($uid, 40); //print_r($y); //if ($langurl != "") $langurl = "/".$langurl; global $txt_cp_karma; global $txt_cp_points; global $txt_cp_donates_to; global $txt_cp_longtext; global $txt_cp_language; echo ' <a href="./hardware-profile/user'.$uid.'" class="recent-comments"> <div class="comment-box"> <div class="userlist-avatar">'. $avatar.' </div> <div class="userlist-name"> <div class="userlist-place">'. $i.'. </div> <div class="userlist-displayname">'; //if ($name == " ") { echo $y['display_name']; //}else{ // echo $name; //}; echo ' </div> <!-- div class="userlist-flag">'. $user_language_flag.' </div --> </div> <div class="userlist-details"> '.$txt_cp_karma.': '.$y['points'].' '.$txt_cp_points.'<br> '.$txt_cp_donates_to.': '.$donation[$donation_target]["Name"].'<br> '.$txt_cp_language.': '.$user_language_flag.' </div> </div> </a>'; // Registered since: '.$regdate.'<br> $top_users[$i]["ID"]=$uid; $top_users[$i]["Karma"]=$y['points']; $top_users[$i]["DisplayName"]=$y['display_name']; // echo $string; } echo apply_filters('cp_topUsersWidget_after','</ul></div>'); $topvotes = lhg_voted_donation(); $most_voted = lhg_most_voted ($topvotes); $most_voted_percent = lhg_most_voted_percent ($topvotes); //$most_voted = 2; // echo "TV: $topvotes"; */ global $donation_total; /* Former donation code echo ' <div class="userlist-chart">'.$txt_cp_longtext.': <b>'. $donation_total.' €</b> '.do_shortcode('[highchart-quarterly] '); */ echo 'Donations:<br>' . do_shortcode('[highchart_quarterly]'); $startQrt = cp_StartOfQuarter(); $endQrt = cp_EndOfQuarter(); #print "Range: ".date('jS \of F Y h:i:s A',$startQrt)." to ".date('jS \of F Y h:i:s A',$endQrt); // Currently, '.$most_voted_percent.'% of all users vote for "'.$donation[$most_voted]["Name"].'". //$topvo // echo '</div>'; //end of userlist all do_action('cp_topUsersWidget_after'); echo $after_widget; }