AdminForm in UserAccountPage gemergt
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Blog\Controller;
|
||||
|
||||
use Blog\Model\AdminModel;
|
||||
|
||||
class AdminController
|
||||
{
|
||||
protected $view;
|
||||
private $db;
|
||||
private $validData = array();
|
||||
private $errors = array();
|
||||
private $labels = array(
|
||||
"name" => "Name*",
|
||||
"preis" => "€ Preis*",
|
||||
"dauer" => "Dauer* (Stunden)",
|
||||
"rabatt" => "Rabatt",
|
||||
"kategorie" => "Kategorie",
|
||||
"|" => "",
|
||||
"stadt" => "Stadt*",
|
||||
"strasse" => "Straße und Nummer*",
|
||||
"plz" => "PLZ*",
|
||||
"|" => "",
|
||||
"beschreibung" => "Beschreibung");
|
||||
|
||||
|
||||
public function __construct($view)
|
||||
{
|
||||
$this->db = new AdminModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showAdminForm()
|
||||
{
|
||||
$this->view->setVars([
|
||||
'labels' => $this->labels,
|
||||
'validData' => $this->validData,
|
||||
'errors' => $this->errors
|
||||
]);
|
||||
}
|
||||
|
||||
public function showConfirmation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function validateForm(){
|
||||
foreach ($this->labels as $index => $value) {
|
||||
if (strpos($value, "*") !== false && (!isset($_POST[$index]) || empty($_POST[$index]))) {
|
||||
$this->errors[$index] = "Bitte " . $value . " eingeben";
|
||||
} else {
|
||||
$this->validData[$index] = $_POST[$index] === '' ? null : $_POST[$index];
|
||||
}
|
||||
}
|
||||
if (count($this->errors) > 0) {
|
||||
$this->view->setDoMethodName("showAdminForm");
|
||||
$this->showAdminForm();
|
||||
} else {
|
||||
if ($this->db->writeNewCourse($this->validData, $_SESSION["user_id"])) {
|
||||
$this->view->setDoMethodName("showConfirmation");
|
||||
$this->showConfirmation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -32,6 +32,21 @@ class UserController{
|
||||
'password' => 'Passwort*',
|
||||
];
|
||||
|
||||
private $kursValidData = array();
|
||||
private $kursErrors = array();
|
||||
private $kursLabels = array(
|
||||
"name" => "Name*",
|
||||
"preis" => "€ Preis*",
|
||||
"dauer" => "Dauer* (Stunden)",
|
||||
"rabatt" => "Rabatt",
|
||||
"kategorie" => "Kategorie",
|
||||
"1" => "|",
|
||||
"stadt" => "Stadt*",
|
||||
"strasse" => "Straße und Nummer*",
|
||||
"plz" => "PLZ*",
|
||||
"2" => "|",
|
||||
"beschreibung" => "Beschreibung");
|
||||
|
||||
public function __construct($view){
|
||||
$this->db = new UserModel();
|
||||
$this->view = $view;
|
||||
@@ -99,6 +114,28 @@ class UserController{
|
||||
}
|
||||
}
|
||||
|
||||
public function validateKursForm(){
|
||||
foreach ($this->kursLabels as $index => $value) {
|
||||
if($value === "|") continue;
|
||||
if (strpos($value, "*") !== false && (!isset($_POST[$index]) || empty($_POST[$index]))) {
|
||||
$this->kursErrors[$index] = "Bitte " . $value . " eingeben";
|
||||
} else {
|
||||
$this->kursValidData[$index] = $_POST[$index] === '' ? null : $_POST[$index];
|
||||
}
|
||||
}
|
||||
if (count($this->errors) > 0) {
|
||||
$this->view->setDoMethodName("showUserAccountPage");
|
||||
$this->showUserAccountPage();
|
||||
} else {
|
||||
if ($this->db->writeNewCourse($this->kursValidData, $_SESSION["user_id"])) {
|
||||
$this->view->setDoMethodName("showNewKursConfirmation");
|
||||
$this->showConfirmation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function showConfirmation(){}
|
||||
|
||||
public function showUserLoginConfirmation(){
|
||||
$userId = $this->getCurrentUserId();
|
||||
$user = null;
|
||||
@@ -172,7 +209,11 @@ class UserController{
|
||||
}
|
||||
|
||||
public function showUserAccountPage (){
|
||||
|
||||
$this->view->setVars([
|
||||
'labels' => $this->kursLabels,
|
||||
'errors' => $this->kursErrors,
|
||||
'validData' => $this->kursValidData
|
||||
]);
|
||||
}
|
||||
|
||||
public function showUserDeleteConfirmation(){
|
||||
|
||||
Reference in New Issue
Block a user