summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-06-28 19:48:22 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-28 23:23:47 +0200
commite8325b65bb4f33205f5d5093e7d19fd3c5a3eea9 (patch)
tree6a993dd6b9e91e9b3d32d0026132d0be5a4f409e /web/lib
parent15fe99402ff4e9f3275f367e823d0f8edcd8b9a5 (diff)
downloadaurweb-e8325b65bb4f33205f5d5093e7d19fd3c5a3eea9.tar.xz
aurjson: Pass http_data array to all functions
This is a preparatory patch that simplifies adding more arguments to the parse functions Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aurjson.class.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 2ba92b7..1069e78 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -84,7 +84,7 @@ class AurJSON {
$this->dbh = DB::connect();
$type = str_replace('-', '_', $http_data['type']);
- $json = call_user_func(array(&$this, $type), $http_data['arg']);
+ $json = call_user_func(array(&$this, $type), $http_data);
$etag = md5($json);
header("Etag: \"$etag\"");
@@ -290,7 +290,8 @@ class AurJSON {
*
* @return mixed An array containing 'ids' and 'names'.
*/
- private function parse_multiinfo_args($args) {
+ private function parse_multiinfo_args($http_data) {
+ $args = $http_data['arg'];
if (!is_array($args)) {
$args = array($args);
}
@@ -318,7 +319,9 @@ class AurJSON {
*
* @return mixed Returns an array of package matches.
*/
- private function search($keyword_string) {
+ private function search($http_data) {
+ $keyword_string = $http_data['arg'];
+
if (strlen($keyword_string) < 2) {
return $this->json_error('Query arg too small');
}
@@ -338,7 +341,8 @@ class AurJSON {
*
* @return mixed Returns an array of value data containing the package data
*/
- private function info($pqdata) {
+ private function info($http_data) {
+ $pqdata = $http_data['arg'];
if (is_numeric($pqdata)) {
$where_condition = "Packages.ID = $pqdata";
} else {
@@ -355,7 +359,8 @@ class AurJSON {
*
* @return mixed Returns an array of results containing the package data
*/
- private function multiinfo($pqdata) {
+ private function multiinfo($http_data) {
+ $pqdata = $http_data['arg'];
$args = $this->parse_multiinfo_args($pqdata);
$ids = $args['ids'];
$names = $args['names'];
@@ -391,7 +396,8 @@ class AurJSON {
*
* @return mixed Returns an array of value data containing the package data
*/
- private function msearch($maintainer) {
+ private function msearch($http_data) {
+ $maintainer = $http_data['arg'];
$maintainer = $this->dbh->quote($maintainer);
$where_condition = "Users.Username = $maintainer ";
@@ -406,7 +412,8 @@ class AurJSON {
*
* @return string The JSON formatted response data.
*/
- private function suggest($search) {
+ private function suggest($http_data) {
+ $search = $http_data['arg'];
$query = "SELECT Packages.Name FROM Packages ";
$query.= "LEFT JOIN PackageBases ";
$query.= "ON PackageBases.ID = Packages.PackageBaseID ";
@@ -432,7 +439,8 @@ class AurJSON {
*
* @return string The JSON formatted response data.
*/
- private function suggest_pkgbase($search) {
+ private function suggest_pkgbase($http_data) {
+ $search = $http_data['arg'];
$query = "SELECT Name FROM PackageBases WHERE Name LIKE ";
$query.= $this->dbh->quote(addcslashes($search, '%_') . '%');
$query.= " AND PackageBases.PackagerUID IS NOT NULL ";