Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/controllers/admin/Feedback.php

67 lines
2.1 KiB
PHP
Raw Normal View History

2018-10-16 16:28:42 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Feedback extends MY_Controller
2018-10-16 16:28:42 +00:00
{
public function __construct()
{
parent::__construct();
$this->load->model('MessageModel', '', TRUE);
}
public function index() {
$this->neededPermission('feedback.receive');
2018-10-16 16:28:42 +00:00
$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) {
$this->neededPermission('feedback.reply');
2018-10-16 16:28:42 +00:00
if($id != null) {
$this->MessageModel->setFeedbackSupporter($id, $_SESSION['user']['ID'], $state);
}
redirect(base_url('admin/feedback'));
}
public function change($id) {
$this->neededPermission('feedback.reply');
2018-10-16 16:28:42 +00:00
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 (!$this->hasPermission('feedback.reply')) {
2018-10-16 16:28:42 +00:00
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.']);
}
}
}