| 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 |
} |