Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23321f90c2 | |||
| 90c6f67c24 | |||
| 7e2b29bfb0 | |||
| cd6aa80f59 | |||
| d5fdc9383f | |||
| 53865efc78 | |||
| 8cbd442371 | |||
| f54cf58dc2 | |||
| ede8e1cb21 | |||
| aaff15ee8c | |||
| bb7c85d770 | |||
| b7160f4df6 | |||
| a6b57bc352 | |||
| 3c14df129d | |||
| 198fefbdf5 | |||
| 135bd7b9cd | |||
| 4cd0383322 |
@@ -53,9 +53,8 @@ if (!isset($_SESSION["user"])) {
|
|||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
|
|||||||
+13
-13
@@ -58,28 +58,27 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "not_found_article"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der zu bearbeitende Artikel wurde nicht gefunden. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
if (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
||||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_title']);
|
echo htmlspecialchars($_SESSION['old_title']);
|
||||||
unset($_SESSION['old_title']);
|
unset($_SESSION['old_title']);
|
||||||
|
}elseif (isset($title) && !empty($title)){
|
||||||
|
echo htmlspecialchars($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>"
|
?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php
|
|
||||||
if (isset($content) && !empty($content)){echo htmlspecialchars($content);
|
|
||||||
}elseif (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_content']);
|
|
||||||
unset($_SESSION['old_content']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
@@ -138,10 +137,11 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
|
if (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
||||||
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_tags']);
|
echo htmlspecialchars($_SESSION['old_tags']);
|
||||||
unset($_SESSION['old_tags']);
|
unset($_SESSION['old_tags']);
|
||||||
|
} elseif (isset($tags) && !empty($tags)){
|
||||||
|
echo htmlspecialchars($tags);
|
||||||
}
|
}
|
||||||
?>"
|
?>"
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
|
|
||||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}else{
|
}else{
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
@@ -33,31 +33,31 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
// -------------------------------- Validierung der Daten: -------------------------
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
if (!articleAuthorValidator($author)) {
|
if (!articleAuthorValidator($author)) {
|
||||||
$_SESSION["message"] = "author_not_valid";
|
$_SESSION["message"] = "author_not_valid";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
if (!articleTitleValidator($title)) {
|
||||||
$_SESSION["message"] = "invalid_title";
|
$_SESSION["message"] = "invalid_title";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
if (!articleContentValidator($content)) {
|
||||||
$_SESSION["message"] = "invalid_content";
|
$_SESSION["message"] = "invalid_content";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
if (!articleCategoryValidator($category)) {
|
||||||
$_SESSION["message"] = "invalid_category";
|
$_SESSION["message"] = "invalid_category";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
if (!articleTagValidator($tags)) {
|
||||||
$_SESSION["message"] = "invalid_tags";
|
$_SESSION["message"] = "invalid_tags";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$cleanedTags = [];
|
$cleanedTags = [];
|
||||||
@@ -83,7 +83,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$articleManager->updateArticle($id ,$article, $author);
|
$articleManager->updateArticle($id ,$article, $author);
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = $e->getMessage();
|
$_SESSION["message"] = $e->getMessage();
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$_SESSION["message"] = "article_updated";
|
$_SESSION["message"] = "article_updated";
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
public function updateArticle($id, $article, $author)
|
public function updateArticle($id, $article, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
throw new InternalServerErrorException("internal_error");
|
throw new NotFoundException("not_found_article");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechtigungsprüfung:
|
// Berechtigungsprüfung:
|
||||||
@@ -208,7 +208,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filteredArticles;
|
return $filteredArticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticlesByCategory($category)
|
public function getArticlesByCategory($category)
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ class LocalUserManager implements UserManagerDAO {
|
|||||||
/**
|
/**
|
||||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
*
|
*
|
||||||
|
* TODO: wenn ein Benutzer gelöscht wird, sollten dann auch seine Beiträge gelöscht werden?
|
||||||
|
*
|
||||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
|||||||
Reference in New Issue
Block a user