diff --git a/homepage/participo/api.starter.remove.php b/homepage/participo/api.starter.remove.php index bc6130a..6087eae 100644 --- a/homepage/participo/api.starter.remove.php +++ b/homepage/participo/api.starter.remove.php @@ -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); diff --git a/homepage/participo/lib/participoLib/dbConnector.php b/homepage/participo/lib/participoLib/dbConnector.php index 1c3bb2e..63bfe9c 100644 --- a/homepage/participo/lib/participoLib/dbConnector.php +++ b/homepage/participo/lib/participoLib/dbConnector.php @@ -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()); diff --git a/homepage/participo/lib/participoLib/event.php b/homepage/participo/lib/participoLib/event.php index 5c2cb5a..dfa52a2 100644 --- a/homepage/participo/lib/participoLib/event.php +++ b/homepage/participo/lib/participoLib/event.php @@ -150,7 +150,7 @@ class Event $kids = participo::getKids(); $modal .= '
'; foreach ($kids as $k) { - $modal .= $this->getHtmlAddStarterForm($k); + $modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl'=>'/participo/events#' . $this->id]); } $modal .= '
'; $modal .= @@ -174,7 +174,7 @@ class Event foreach ($listOfStarter as $start) { $startingUser = $start->loadStarter(); $starterList .= '
' - . '
' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ':
' + . '
' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ' ('.StartingType::$AsString[$start->getTypeId()].'):
' . '
' . $start->getHtmlFormRemove() . '
' . '
'; } @@ -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 = - '
' - . '' - . '' - . '' - . '' - . '
'; - - return $form; - } - - public function getHtmlAddStarterForm($user) - { $key = isset($_SESSION['apiKey']) ? $_SESSION['apiKey'] : null; $form = '
' . '' . '' - . '' + . '' . '
' . '' - . '' - . '' + . '' + . '' . '' . '';