bugfix remove starter, return to shiai modal after add starter, startertype info in startertable and shiai modal
This commit is contained in:
@@ -16,12 +16,10 @@ dbConnector::connect(
|
||||
|
||||
participo::authentificate();
|
||||
|
||||
$eventId = $_POST['eventId'] ?? null;
|
||||
$starterId = $_POST['userId'] ?? null;
|
||||
|
||||
$starterId = $_POST['starterId'] ?? null;
|
||||
$returnToUrl = $_POST['returnToUrl'] ?? 'participo/';
|
||||
|
||||
$starter = new Starter(null, $eventId, null, $starterId);
|
||||
$starter = Starter::loadFromDb($starterId);
|
||||
$starter->removeFromDb();
|
||||
|
||||
header('Location: ' . urldecode($returnToUrl), true, 301);
|
||||
|
||||
@@ -38,6 +38,8 @@ class dbConnector
|
||||
if (empty($someOptions['dontFetch'])) {
|
||||
$someOptions['dontFetch'] = false;
|
||||
}
|
||||
|
||||
$ignoreErrors = $someOptions['ignoreErrors'] ?? false;
|
||||
|
||||
/// @toDo: Bisher wird nur die Rückgabe konvertiert. Eigentlich muss
|
||||
/// doch auch die Eingabe konvertiert werden. Aber das jetzt
|
||||
@@ -63,7 +65,7 @@ class dbConnector
|
||||
);
|
||||
}
|
||||
$pdoResult = $pdoStatement->execute();
|
||||
if (!$pdoResult) {
|
||||
if (!$ignoreErrors && !$pdoResult) {
|
||||
echo("Error during dbQuery!\n");
|
||||
echo("DB-Error:\n");
|
||||
var_dump(self::$db->errorInfo());
|
||||
|
||||
@@ -150,7 +150,7 @@ class Event
|
||||
$kids = participo::getKids();
|
||||
$modal .= '<div class="row">';
|
||||
foreach ($kids as $k) {
|
||||
$modal .= $this->getHtmlAddStarterForm($k);
|
||||
$modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl'=>'/participo/events#' . $this->id]);
|
||||
}
|
||||
$modal .= '</div>';
|
||||
$modal .=
|
||||
@@ -174,7 +174,7 @@ class Event
|
||||
foreach ($listOfStarter as $start) {
|
||||
$startingUser = $start->loadStarter();
|
||||
$starterList .= '<div class="col s12 m6"><div class="row valign-wrapper">'
|
||||
. '<div class="col s6">' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ':</div>'
|
||||
. '<div class="col s6">' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ' ('.StartingType::$AsString[$start->getTypeId()].'):</div>'
|
||||
. '<div class="col s6">' . $start->getHtmlFormRemove() . '</div>'
|
||||
. '</div></div>';
|
||||
}
|
||||
@@ -236,34 +236,16 @@ class Event
|
||||
return dbConnector::query($query, $params);
|
||||
}
|
||||
|
||||
// @todo docu
|
||||
public function getHtmlRemoveStarterForm($starterId)
|
||||
public function getHtmlAddStarterForm($user, $options = [])
|
||||
{
|
||||
$html = self::getHtmlRemoveStarterFromEventForm($this->id, $starterId);
|
||||
}
|
||||
$returnToUrl = $options['returnToUrl'] ?? urlencode(getCurPagesUrl());
|
||||
|
||||
// returns html code for a button to remove the user from an event
|
||||
public static function getHtmlRemoveStarterFromEventForm($eventId, $userId, $class = null)
|
||||
{
|
||||
$form =
|
||||
'<form ' . (isset($class) ? ('class="' . $class . '"') : '') . ' action="api.starter.remove.php" method="post">'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $eventId . '">'
|
||||
. '<input type="hidden" name="userId" id="userId" value="' . $userId . '">'
|
||||
. '<button class="btn red" type="submit" name="submit">austragen</button>'
|
||||
. '</form>';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getHtmlAddStarterForm($user)
|
||||
{
|
||||
$key = isset($_SESSION['apiKey']) ? $_SESSION['apiKey'] : null;
|
||||
$form =
|
||||
'<form class="card col s12 m6" action="api.starter.add.php" method="post">'
|
||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $this->id . '">'
|
||||
. '<input type="hidden" name="userId" id="userId" value="' . $user->getId() . '">'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . $returnToUrl . '" >'
|
||||
. '<div class="input-field">'
|
||||
. '<select id="selectTypeForm" name="type">'
|
||||
. '<option value="1" selected="">als Starter</option>'
|
||||
|
||||
@@ -527,8 +527,7 @@ function getCurPagesUrl()
|
||||
return $pageURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* space saving way to put a date
|
||||
/** space saving way to put a date
|
||||
*
|
||||
* @param [DateTime] $date
|
||||
* @return string html tag containing the date
|
||||
|
||||
@@ -202,7 +202,7 @@ class Starter
|
||||
if ($today > $eventDeadline) {
|
||||
return self::getHtmlModalToLate($this->id);
|
||||
}
|
||||
return self::getHtmlFormRemoveStarterFromEvent($this->id, $this->eventId, $class);
|
||||
return self::getHtmlFormRemoveStarterFromEvent($this->getId(), $class);
|
||||
}
|
||||
|
||||
// inject html code of table with coming starts for the session user
|
||||
@@ -212,7 +212,7 @@ class Starter
|
||||
echo(self::getHtmlTableComingStarts($userId));
|
||||
}
|
||||
|
||||
// Member
|
||||
// member variables
|
||||
// - static member
|
||||
/** Name of the table with all the starts
|
||||
*
|
||||
@@ -338,8 +338,9 @@ class Starter
|
||||
':typeId' => ['value' => $typeId, 'data_type' => PDO::PARAM_INT],
|
||||
':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT]
|
||||
];
|
||||
|
||||
$response = dbConnector::query($query, $params);
|
||||
// @todo remove ignoreErrors again
|
||||
// @todo Inserting-Starter-Statement returns false on execution: Why? It seems to succeed!
|
||||
$response = dbConnector::query($query, $params, ['ignoreErrors'=>true]);
|
||||
return dbConnector::getLastInsertId();
|
||||
}
|
||||
|
||||
@@ -405,7 +406,7 @@ class Starter
|
||||
private static function getHtmlTable($starts)
|
||||
{
|
||||
$html = '<table>'
|
||||
. '<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th><th></th></tr></thead>'
|
||||
. '<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th><th></th><th></th></tr></thead>'
|
||||
. '<tbody>';
|
||||
foreach ($starts as $start) {
|
||||
$today = new DateTime();
|
||||
@@ -421,6 +422,7 @@ class Starter
|
||||
. '<td>' . getHtmlSquareDate($eventDate) . '</td>'
|
||||
. '<td>' . $shiai->getHtmlName() . '</td>'
|
||||
. '<td>' . $startingUser->getName() . ', ' . $startingUser->getFirstName() . '</td>'
|
||||
. '<td>' . StartingType::$AsString[$start->getTypeId()] . '</td>'
|
||||
. '<td>' . $start->getHtmlFormRemove() . '</td>'
|
||||
. '</tr>';
|
||||
}
|
||||
@@ -430,7 +432,7 @@ class Starter
|
||||
|
||||
private static function getHtmlModalToLate($startId, $caption = 'Austragen')
|
||||
{
|
||||
$modal = $html = '<a class="btn grey waves-effect waves-light modal-trigger" href="#modal-remove-starter-' . $startId . '">' . $caption . '</a>'
|
||||
$modal = '<a class="btn grey waves-effect waves-light modal-trigger" href="#modal-remove-starter-' . $startId . '">' . $caption . '</a>'
|
||||
. '<div id="modal-remove-starter-' . $startId . '" class="modal">'
|
||||
. '<div class="modal-content">'
|
||||
. '<p>Das Fenster zum Ein- und Austragen ist bereits geschlossen.</p>'
|
||||
@@ -443,13 +445,13 @@ class Starter
|
||||
return $modal;
|
||||
}
|
||||
|
||||
private static function getHtmlFormRemoveStarterFromEvent($starterId, $eventId, $class = null)
|
||||
private static function getHtmlFormRemoveStarterFromEvent($starterId, $class = null)
|
||||
{
|
||||
$returnToUrl = urlencode(getCurPagesUrl());
|
||||
$form =
|
||||
'<form ' . (isset($class) ? ('class="' . $class . '"') : '') . ' action="api.starter.remove.php" method="post">'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $eventId . '">'
|
||||
. '<input type="hidden" name="userId" id="userId" value="' . $starterId . '">'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . $returnToUrl . '" >'
|
||||
. '<input type="hidden" name="starterId" id="starterId" value="' . $starterId . '">'
|
||||
. '<button class="btn red" type="submit" name="submit">austragen</button>'
|
||||
. '</form>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user