From 9ab62485a63e6838b6e4236a1b262af9848c64e5 Mon Sep 17 00:00:00 2001 From: marko Date: Sun, 24 Dec 2023 15:34:07 +0100 Subject: [PATCH] api endpoint returns actives parents by default --- homepage/participo/api/users.php | 15 ++++++++++++++- homepage/participo/testApi.py | 5 +++-- homepage/participo/wk.api.php | 1 - 3 files changed, 17 insertions(+), 4 deletions(-) mode change 100644 => 100755 homepage/participo/testApi.py diff --git a/homepage/participo/api/users.php b/homepage/participo/api/users.php index c81cb29..ffeb110 100644 --- a/homepage/participo/api/users.php +++ b/homepage/participo/api/users.php @@ -27,9 +27,22 @@ if (!$allowKey || !$allowKey->isValidFor('api')) { die(json_encode(['success' => false])); } -$wkSqlQuery = 'SELECT * FROM `wettkampfkalender` WHERE `Datum` >= CURDATE();'; +$wkSqlQuery = "SELECT DISTINCT" + ." `wkParticipo_Users`.* " + ." FROM `wkParticipo_Users`" + ." JOIN `vormundschaft`" + ." ON `wkParticipo_Users`.`id` =`vormundschaft`.`userId`" + ." JOIN `wkParticipo_user<=>userAttributes`" + ." ON `wkParticipo_user<=>userAttributes`.`userId` = `vormundschaft`.`kidId`" + ." WHERE `wkParticipo_user<=>userAttributes`.`attributeId` = 4" + ." ORDER BY `wkParticipo_Users`.`id` ASC;"; + $wkSqlResponse = dbConnector::query($wkSqlQuery); +foreach( $wkSqlResponse as &$user){ + $user['eMail'] = explode(",", $user['eMail']); +} + header('Access-Control-Allow-Headers: *'); header('Access-Control-Allow-Origin: *'); diff --git a/homepage/participo/testApi.py b/homepage/participo/testApi.py old mode 100644 new mode 100755 index 1b37554..5ef39d2 --- a/homepage/participo/testApi.py +++ b/homepage/participo/testApi.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python + from http import client import logging import json @@ -27,7 +29,6 @@ try: print(json.dumps(json.loads(body),indent=2)) except: print(f"failed to parse to json") - print(body - ) + print(body) connection.close() diff --git a/homepage/participo/wk.api.php b/homepage/participo/wk.api.php index 2c307eb..3afe702 100644 --- a/homepage/participo/wk.api.php +++ b/homepage/participo/wk.api.php @@ -13,7 +13,6 @@ $db = dbConnector::connect( $cwsvJudoConfig['db']['user'], $cwsvJudoConfig['db']['password'] ); -// echo($db); $wkSqlQuery = 'SELECT * FROM `wettkampfkalender` WHERE `Datum` >= CURDATE();'; $wkSqlResponse = dbConnector::query($wkSqlQuery);