summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-10-10 07:38:22 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-11-24 13:44:37 (GMT)
commitbb52739dce13d471ebaf4a8b906b4ef2d598a526 (patch)
tree95f4eb5522d6103f7e0caa1d2280d03b74b74766
parenta0dc9c8fcf9cfb1118f3b84043d708238b1c5b05 (diff)
downloadkolab-wap-bb52739dce13d471ebaf4a8b906b4ef2d598a526.tar.gz
Slice page from list result after sorting and ordering, small code improvementskolab-webadmin-3.1.3
-rw-r--r--lib/Auth/LDAP.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 6d13a6c..bf02ba1 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1304,21 +1304,18 @@ class LDAP extends Net_LDAP3 {
}
if (!empty($params) && is_array($params)) {
- if (array_key_exists('sort_by', $params)) {
+ if (!empty($params['sort_by'])) {
$this->sort_result_key = $params['sort_by'];
uasort($entries, array($this, 'sort_result'));
}
- if (array_key_exists('page_size', $params) && array_key_exists('page', $params)) {
- if ($result->count() > $params['page_size']) {
- $entries = array_slice($entries, (($params['page'] - 1) * $params['page_size']), $params['page_size'], true);
- }
-
+ if (!empty($params['sort_order']) && $params['sort_order'] == "DESC") {
+ $entries = array_reverse($entries, true);
}
- if (array_key_exists('sort_order', $params) && !empty($params['sort_order'])) {
- if ($params['sort_order'] == "DESC") {
- $entries = array_reverse($entries, true);
+ if (!empty($params['page_size']) && !empty($params['page'])) {
+ if ($result->count() > $params['page_size']) {
+ $entries = array_slice($entries, (($params['page'] - 1) * $params['page_size']), $params['page_size'], true);
}
}
}