67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
|
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class Feedback extends CI_Controller
|
||
|
{
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
$this->load->model('MessageModel', '', TRUE);
|
||
|
}
|
||
|
|
||
|
public function index() {
|
||
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||
|
|
||
|
$feedback = $this->MessageModel->getFeedbackMessages();
|
||
|
|
||
|
$this->load->view('admin/sidebar', ['title' => 'Feedback-Nachrichten']);
|
||
|
$this->load->view('admin/feedback', ['feedback' => $feedback]);
|
||
|
$this->load->view('admin/footer', ['additionalScripts' => 'feedback.js']);
|
||
|
}
|
||
|
|
||
|
public function takeover($id = null, $state = 1) {
|
||
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||
|
|
||
|
if($id != null) {
|
||
|
$this->MessageModel->setFeedbackSupporter($id, $_SESSION['user']['ID'], $state);
|
||
|
}
|
||
|
|
||
|
redirect(base_url('admin/feedback'));
|
||
|
}
|
||
|
|
||
|
public function change($id) {
|
||
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||
|
|
||
|
if($id != null) {
|
||
|
$newStatus = $this->input->post('feedbackState');
|
||
|
|
||
|
$this->MessageModel->updateState($id, $_SESSION['user']['ID'], $newStatus);
|
||
|
}
|
||
|
|
||
|
redirect(base_url('admin/feedback'));
|
||
|
}
|
||
|
|
||
|
public function archive() {
|
||
|
// header('Content-Type: application/json');
|
||
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) {
|
||
|
echo json_encode(['type' => 'error', 'message' => 'Du musst eingeloggt sein, um Feedbacks zu beantworten.']);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$feedbackID = intval($this->input->post('id'));
|
||
|
|
||
|
if(!is_numeric($feedbackID)) {
|
||
|
echo json_encode(['type' => 'error', 'message' => 'Die angegebene Feedback-ID ist ungültig.']);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$successful = $this->MessageModel->archiveFeedback($feedbackID);
|
||
|
|
||
|
if($successful) {
|
||
|
echo json_encode(['type' => 'success', 'message' => 'Das Feedback wurde erfolgreich gelöscht.']);
|
||
|
} else {
|
||
|
echo json_encode(['type' => 'error', 'message' => 'Das Feedback muss vor dem Löschen zuerst bearbeitet und geschlossen werden.']);
|
||
|
}
|
||
|
}
|
||
|
}
|