From: Mikael Nordfeldth Date: Wed, 18 Feb 2015 10:13:10 +0000 (+0100) Subject: Directory group search code cleanup X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=52e0ce8b064735a44a8d0297cc5ced01e7c3db0b;p=quix0rs-gnu-social.git Directory group search code cleanup --- diff --git a/plugins/Directory/actions/groupdirectory.php b/plugins/Directory/actions/groupdirectory.php index 496f035570..1abf4144b1 100644 --- a/plugins/Directory/actions/groupdirectory.php +++ b/plugins/Directory/actions/groupdirectory.php @@ -302,7 +302,7 @@ class GroupdirectoryAction extends Action $offset = ($this->page-1) * PROFILES_PER_PAGE; $limit = PROFILES_PER_PAGE + 1; - if (isset($this->q)) { + if (!empty($this->q)) { // Disable this to get global group searches $group->joinAdd(array('id', 'local_group:group_id')); @@ -312,19 +312,15 @@ class GroupdirectoryAction extends Action $group->whereAdd("LOWER({$group->__table}.{$where}) LIKE LOWER('%".$group->escape($this->q)."%')", 'OR'); } - $order = 'user_group.created ASC'; - - if ($this->sort == 'nickname') { - if ($this->reverse) { - $order = 'user_group.nickname DESC'; - } else { - $order = 'user_group.nickname ASC'; - } - } else { - if ($this->reverse) { - $order = 'user_group.created DESC'; - } - } + $order = "{$group->__table}.created ASC"; + + if ($this->sort == 'nickname') { + $order = $this->reverse + ? "{$group->__table}.nickname DESC" + : "{$group->__table}.nickname ASC"; + } elseif ($this->reverse) { + $order = "{$group->__table}.created DESC"; + } $group->orderBy($order); $group->limit($offset, $limit);