From 9561998b23cd866d9088216d18472ea96ecb00a4 Mon Sep 17 00:00:00 2001 From: samerton Date: Fri, 5 Aug 2022 17:42:37 +0100 Subject: [PATCH] Remove usage of deprecated queries class --- upload/modules/Tebex/module.php | 2 +- .../Tebex/widgets/LatestPurchasesWidget.php | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/upload/modules/Tebex/module.php b/upload/modules/Tebex/module.php index eba3f0d..8d4269e 100644 --- a/upload/modules/Tebex/module.php +++ b/upload/modules/Tebex/module.php @@ -19,7 +19,7 @@ public function __construct($language, $buycraft_language, $pages, $cache){ $name = 'Tebex'; $author = 'Samerton'; - $module_version = '1.2.2'; + $module_version = '1.2.3'; $nameless_version = '2.0.0-pr13'; parent::__construct($this, $name, $author, $module_version, $nameless_version); diff --git a/upload/modules/Tebex/widgets/LatestPurchasesWidget.php b/upload/modules/Tebex/widgets/LatestPurchasesWidget.php index d2bd9ec..f60aa4f 100644 --- a/upload/modules/Tebex/widgets/LatestPurchasesWidget.php +++ b/upload/modules/Tebex/widgets/LatestPurchasesWidget.php @@ -2,11 +2,11 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr6 + * NamelessMC version 2.0.0-pr13 * * License: MIT * - * Store latest purchases widget + * Tebex latest purchases widget */ class LatestPurchasesWidget extends WidgetBase { private Cache $_cache; @@ -37,26 +37,25 @@ public function __construct(Cache $cache, Smarty $smarty, Language $language, La public function initialise(): void { // Generate HTML code for widget $this->_cache->setCache('buycraft_data'); - $queries = new Queries(); - if($this->_cache->isCached('latest_purchases')){ + if ($this->_cache->isCached('latest_purchases')) { $latest_purchases = $this->_cache->retrieve('latest_purchases'); } else { - if($this->_cache->isCached('purchase_limit')){ + if ($this->_cache->isCached('purchase_limit')) { $purchase_limit = intval($this->_cache->retrieve('purchase_limit')); } else { $purchase_limit = 10; } - $latest_purchases_query = $queries->orderAll('buycraft_payments', '`date`', 'DESC LIMIT ' . $purchase_limit); - $latest_purchases = array(); + $latest_purchases_query = DB::getInstance()->query('SELECT * FROM nl2_buycraft_payments ORDER BY `date` DESC LIMIT ' . $purchase_limit); + $latest_purchases = []; - if (count($latest_purchases_query)) { + if ($latest_purchases_query->count()) { $timeago = new TimeAgo(TIMEZONE); $purchase_users = []; - foreach ($latest_purchases_query as $purchase) { + foreach ($latest_purchases_query->results() as $purchase) { if (isset($purchase_users[$purchase->player_uuid])) { [$user_id, $style, $username] = $purchase_users[$purchase->player_uuid]; } else {