diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-10-09 17:35:29 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-10-09 17:35:51 +0200 |
commit | 1f6237ffa73f1cc931ec7cb2abbdd6ff54e1581a (patch) | |
tree | 600826edd167b0ae4edd38f0c5316272658b5a9c /web/lib/aurjson.class.php | |
parent | 9d8345d4e09a16f0d4067638560e2e8318727d03 (diff) | |
download | aur-1f6237ffa73f1cc931ec7cb2abbdd6ff54e1581a.tar.gz aur-1f6237ffa73f1cc931ec7cb2abbdd6ff54e1581a.tar.xz |
aurjson: Rename the search_by parameter to "by"
This parameter is only supported by the search command. We do not need
to repeat ourselves.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/aurjson.class.php')
-rw-r--r-- | web/lib/aurjson.class.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 2bf2e7a3..15482327 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -86,8 +86,12 @@ class AurJSON { if (!in_array($http_data['type'], self::$exposed_methods)) { return $this->json_error('Incorrect request type specified.'); } - if (isset($http_data['search_by']) && !in_array($http_data['search_by'], self::$exposed_fields)) { - return $this->json_error('Incorrect search_by field specified.'); + + if (isset($http_data['search_by']) && !isset($http_data['by'])) { + $http_data['by'] = $http_data['search_by']; + } + if (isset($http_data['by']) && !in_array($http_data['by'], self::$exposed_fields)) { + return $this->json_error('Incorrect by field specified.'); } $this->dbh = DB::connect(); @@ -362,8 +366,8 @@ class AurJSON { private function search($http_data) { $keyword_string = $http_data['arg']; - if (isset($http_data['search_by'])) { - $search_by = $http_data['search_by']; + if (isset($http_data['by'])) { + $search_by = $http_data['by']; } else { $search_by = 'name-desc'; } @@ -455,7 +459,7 @@ class AurJSON { * @return mixed Returns an array of value data containing the package data */ private function msearch($http_data) { - $http_data['search_by'] = 'maintainer'; + $http_data['by'] = 'maintainer'; return $this->search($http_data); } |