PluginProbe
MyRewards / trunk
MyRewards vtrunk
5.7.8 5.7.7 5.7.6 trunk 1.2.2 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.1 2.2.0 2.3.0 2.4.0 2.4.1 2.5.0 2.6.4 2.6.6 3.0.0.0 3.1.0 3.1.2 3.1.2.1 3.10.4 3.10.9 All 165 releases
woorewards / include / pointsflow / methods / sumo.php

sumo.php in MyRewards trunk, at include/pointsflow/methods/sumo.php

31 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace LWS\WOOREWARDS\PointsFlow\Methods;
3
4 // don't call the file directly
5 if( !defined( 'ABSPATH' ) ) exit();
6
7 /** Get the total points for users.
8 * @warning Sumo support float values,
9 * that will be rounded (floor) at import in MyRewards (points are integer). */
10 class Sumo extends \LWS\WOOREWARDS\PointsFlow\ExportMethod
11 {
12 /** @return (array) the json that will be send,
13 * An array with each entries as {email, points} */
14 public function export($value, $arg)
15 {
16 global $wpdb;
17 $table = $wpdb->prefix . 'rspointexpiry';
18 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- third-party table name
19 $results = $wpdb->get_results("SELECT u.user_email as `email`, SUM((sumo.earnedpoints-sumo.usedpoints)) as `points` FROM {$table} as sumo INNER JOIN {$wpdb->users} as u ON u.ID=sumo.userid WHERE sumo.expiredpoints IN(0) GROUP BY sumo.userid");
20 if ($wpdb->last_error) {
21 \wp_die("SUMO must be installed and active", 410);
22 }
23 return $results;
24 }
25
26 /** @return (string) human readable name */
27 public function getTitle()
28 {
29 return __("Sumo", 'woorewards-lite');
30 }
31 }