Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Sort parameters

givanze7af5105ed00
diff --git a/admin/component/orders.php b/admin/component/orders.php
index b574353..a4d5b83 100755
--- a/admin/component/orders.php
+++ b/admin/component/orders.php
@@ -29,17 +29,19 @@ use Vvveb\System\Images;
class Orders extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 10,
- 'language_id' => NULL,
- 'site_id' => NULL,
- 'user_id' => NULL,
- 'email' => NULL,
- 'phone_number' => NULL,
- 'search' => NULL,
- 'id_manufacturer' => NULL,
- 'order_status' => NULL,
- 'order_status_id' => NULL,
+ 'start' => 0,
+ 'limit' => 10,
+ 'language_id' => NULL,
+ 'site_id' => NULL,
+ 'user_id' => NULL,
+ 'email' => NULL,
+ 'phone_number' => NULL,
+ 'search' => NULL,
+ 'id_manufacturer' => NULL,
+ 'order_status' => NULL,
+ 'order_status_id' => NULL,
+ 'order_by' => NULL,
+ 'direction' => ['url', 'asc', 'desc'],
];
public $options = [];
@@ -49,6 +51,16 @@ class Orders extends ComponentBase {
$results = $orders->getAll($this->options);
+ if (isset($this->options['order_by']) &&
+ ! in_array($this->options['order_by'], ['order_id', 'customer_order_id', 'order_status_id', 'created_at'])) {
+ unset($this->options['order_by']);
+ }
+
+ if (isset($this->options['direction']) &&
+ ! in_array($this->options['direction'], ['asc', 'desc'])) {
+ unset($this->options['direction']);
+ }
+
if ($results['order']) {
$currency = Currency::getInstance();
diff --git a/admin/component/users.php b/admin/component/users.php
index c63419f..33f52d2 100755
--- a/admin/component/users.php
+++ b/admin/component/users.php
@@ -29,12 +29,13 @@ use Vvveb\System\Images;
class Users extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 10,
- 'site_id' => null,
- 'user_id' => 'url',
- 'user' => ['url', 'price asc'],
- 'id' => NULL,
+ 'start' => 0,
+ 'limit' => 10,
+ 'site_id' => null,
+ 'user_id' => 'url',
+ 'user' => ['url', 'price asc'],
+ 'order_by' => NULL,
+ 'direction' => ['url', 'asc', 'desc'],
];
public $options = [];
@@ -44,6 +45,16 @@ class Users extends ComponentBase {
$results = $users->getAll($this->options);
+ if (isset($this->options['order_by']) &&
+ ! in_array($this->options['order_by'], ['user_id', 'created_at', 'email', 'username'])) {
+ unset($this->options['order_by']);
+ }
+
+ if (isset($this->options['direction']) &&
+ ! in_array($this->options['direction'], ['asc', 'desc'])) {
+ unset($this->options['direction']);
+ }
+
if (isset($results['user'])) {
foreach ($results['user'] as $id => &$user) {
if (isset($user['images'])) {