Database refactoring and improving blog comments, blog post history and more
This commit is contained in:
@@ -71,10 +71,10 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
$postUUID = $this->input->post('postUUID');
|
||||
$hashID = $this->input->post('postUUID');
|
||||
|
||||
$isLiked = $this->PostsModel->addPostLikeByUUID($postUUID, $_SESSION['user']['ID']);
|
||||
$likeCount = $this->PostsModel->getPostLikeCountByUUID($postUUID);
|
||||
$isLiked = $this->PostsModel->addPostLikeByHashID($hashID, $_SESSION['user']['ID']);
|
||||
$likeCount = $this->PostsModel->getPostLikeCountByHashID($hashID);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
@@ -115,7 +115,7 @@
|
||||
$users = $this->UserModel->searchUsers($query, $rank, $country, $lang, $userAmount, $userOffset);
|
||||
|
||||
if (!empty($users)) {
|
||||
if($offset == 0) {
|
||||
if ($offset == 0) {
|
||||
echo '<h2>Nutzer (' . sizeof($users) . ')</h2>';
|
||||
}
|
||||
|
||||
@@ -142,7 +142,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvailableCountries() {
|
||||
public function getAvailableCountries()
|
||||
{
|
||||
$countries = $this->UserModel->getAvailableCountries();
|
||||
|
||||
foreach ($countries as $i => $country) {
|
||||
@@ -153,7 +154,8 @@
|
||||
echo json_encode(['countries' => $countries]);
|
||||
}
|
||||
|
||||
public function getAvailableLanguages() {
|
||||
public function getAvailableLanguages()
|
||||
{
|
||||
$languages = $this->UserModel->getAvailableLanguages();
|
||||
|
||||
foreach ($languages as $i => $language) {
|
||||
@@ -164,54 +166,69 @@
|
||||
echo json_encode(['languages' => $languages]);
|
||||
}
|
||||
|
||||
public function getReportModal() {
|
||||
public function getReportModal()
|
||||
{
|
||||
$this->load->view('network/posts/report_modal');
|
||||
}
|
||||
|
||||
public function reportPost() {
|
||||
public function reportPost()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
$uuid = $this->input->post('uuid');
|
||||
$hashID = $this->input->post('hashID');
|
||||
|
||||
if ($hashID == NULL) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reason = $this->input->post('reason');
|
||||
$reasonText = $this->input->post('explanation');
|
||||
|
||||
if($reason == '') {
|
||||
if ($reason == '') {
|
||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen Grund für deine Meldung aus.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$allowedReasons = ['hatespeech', 'racism', 'terrorism', 'abuse', 'violence', 'copyright', 'spam', 'technical-issue'];
|
||||
|
||||
if(!array_search($reason, $allowedReasons)) {
|
||||
if (!array_search($reason, $allowedReasons)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen standardmäßig vorhandenen und validen Grund für die Meldung aus.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$this->PostsModel->isUUIDValid($uuid)) {
|
||||
if (!$this->PostsModel->isHashIDValid($hashID)) {
|
||||
echo json_encode(['success' => true, 'message' => 'Der ausgewählte Post ist nicht (mehr) vorhanden. Sollte es sich hierbei um ein Irrtum handeln, verfasse bitte über den Button unten rechts ein Feedback.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->PostsModel->reportPost($uuid, $reason, $reasonText);
|
||||
$this->PostsModel->reportPost($hashID, $reason, $reasonText);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Vielen Dank für das Melden dieses Posts. Wir werden schnellstmöglich angemessene Aktionen unternehmen.']);
|
||||
}
|
||||
|
||||
public function getDeleteModal() {
|
||||
public function getDeleteModal()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if(!isset($_SESSION['user'])) {
|
||||
if (!isset($_SESSION['user'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$uuid = $this->input->post('uuid');
|
||||
$post = $this->PostsModel->getPostByUUID($uuid);
|
||||
$hashID = $this->input->post('hashID');
|
||||
|
||||
if(empty($post)) {
|
||||
if ($hashID == NULL) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
|
||||
$post = $this->PostsModel->getPostByHashID($hashID);
|
||||
|
||||
if (empty($post)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($post[0]['userID'] != $_SESSION['user']['ID']) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
||||
exit;
|
||||
}
|
||||
@@ -222,27 +239,34 @@
|
||||
echo json_encode(['success' => true, 'title' => 'Post löschen', 'body' => $body]);
|
||||
}
|
||||
|
||||
public function deletePost() {
|
||||
public function deletePost()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if(!isset($_SESSION['user'])) {
|
||||
if (!isset($_SESSION['user'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$uuid = $this->input->post('uuid');
|
||||
$post = $this->PostsModel->getPostByUUID($uuid);
|
||||
$hashID = $this->input->post('hashID');
|
||||
|
||||
if(empty($post)) {
|
||||
if ($hashID == NULL) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
|
||||
$post = $this->PostsModel->getPostByHashID($hashID);
|
||||
|
||||
if (empty($post)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($post[0]['userID'] != $_SESSION['user']['ID']) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->PostsModel->deletePost($_SESSION['user']['ID'], $uuid);
|
||||
$this->PostsModel->deletePost($_SESSION['user']['ID'], $hashID);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich gelöscht.']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user