WIP: posting shiai to the wkKalendar via api
This commit is contained in:
@@ -55,7 +55,7 @@ class participo
|
||||
/** lazy loading of the session user */
|
||||
public static function sessionUser(bool $forceLoading = true)
|
||||
{
|
||||
if (is_null($sessionUser) || $forceLoading) {
|
||||
if (is_null(self::$sessionUser) || $forceLoading) {
|
||||
self::$sessionUser = User::loadFromDb(self::getSessionUserId());
|
||||
}
|
||||
return self::$sessionUser;
|
||||
|
||||
@@ -21,10 +21,10 @@ class Shiai
|
||||
*/
|
||||
private static $tableName = "wettkampfkalender";
|
||||
|
||||
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl)
|
||||
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl=null, $promoImgUrl=null)
|
||||
{
|
||||
//! @todo input validation and sanitation
|
||||
$this->id = (int) $id;
|
||||
$this->id = filterId($id);
|
||||
$this->date = DateTime::createFromFormat('Y-m-d', $date);
|
||||
$this->name = $name;
|
||||
$this->ageclasses = $ageclasses ? self::akListString2jgArray($ageclasses) : null;
|
||||
@@ -35,6 +35,32 @@ class Shiai
|
||||
$this->promoImgUrl = $promoImgUrl;
|
||||
}
|
||||
|
||||
public static function fromArray(array $shiai){
|
||||
$id = $shiai['id'] ?? null;
|
||||
$date = $shiai['date'] ?? null;
|
||||
$name = $shiai['name'] ?? null;
|
||||
$ageclasses = $shiai['ageclasses'] ?? null;
|
||||
$place = $shiai['place'] ?? null;
|
||||
$announcementUrl = $shiai['announcementUrl'] ?? null;
|
||||
$routeUrl = $shiai['routeUrl'] ?? null;
|
||||
// gallery stuff removed for now
|
||||
|
||||
return new Shiai($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl);
|
||||
}
|
||||
|
||||
public function asArray(){
|
||||
return [
|
||||
'id'=>$this->id,
|
||||
'date'=>$this->date->format('Y-m-d'),
|
||||
'name'=>$this->name,
|
||||
// @todo at least in theory this should again hold age categories
|
||||
'ageclasses'=>implode(" ", $this->ageclasses),
|
||||
'place'=>$this->place,
|
||||
'announcementUrl'=>$this->announcementUrl,
|
||||
'routeUrl'=>$this->announcementUrl
|
||||
];
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
|
||||
@@ -75,6 +75,26 @@ class User
|
||||
return dbConnector::getLastInsertId();
|
||||
}
|
||||
|
||||
public static function dbSelectWithAttribute(int $attributeId)
|
||||
{
|
||||
$query =
|
||||
"SELECT DISTINCT" .
|
||||
" `wkParticipo_Users`.* " .
|
||||
" FROM `wkParticipo_Users`" .
|
||||
" JOIN `wkParticipo_user<=>userAttributes`" .
|
||||
" ON `wkParticipo_user<=>userAttributes`.`userId` = `wkParticipo_Users`.`id`" .
|
||||
" WHERE `wkParticipo_user<=>userAttributes`.`attributeId` = :attributeId".
|
||||
" ORDER BY `wkParticipo_Users`.`id` ASC;";
|
||||
|
||||
$params = [
|
||||
':attributeId' => ['value' => $attributeId, 'data_type' => PDO::PARAM_INT]
|
||||
];
|
||||
|
||||
$response = dbConnector::query($query, $params);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/** Name of the table with all the Users
|
||||
*
|
||||
* @var string
|
||||
|
||||
Reference in New Issue
Block a user