Initial commit as of 2018-10-16
This commit is contained in:
369
application/controllers/admin/Blog.php
Normal file
369
application/controllers/admin/Blog.php
Normal file
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Blog extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('BlogModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$posts = $this->BlogModel->getPostList(false);
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
||||
$this->load->view('admin/blog_posts', ['posts' => $posts]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function tags() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
redirect(base_url('login'));
|
||||
}
|
||||
|
||||
$tags = $this->BlogModel->getAllTags();
|
||||
$tags = $this->BlogModel->mergeTagInfo($tags);
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Tags']);
|
||||
$this->load->view('admin/blog_tags', ['tags' => $tags]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => 'all-blog-tags.js']);
|
||||
}
|
||||
|
||||
public function sendEdit()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID == -2) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentID = $this->input->post('contentID');
|
||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
||||
|
||||
$translationID = $this->input->post('translationID');
|
||||
$translationID = is_numeric($translationID) && is_int(intval($translationID)) ? intval($translationID) : -2;
|
||||
|
||||
$postImage = $this->input->post('postImage');
|
||||
$postTitle = $this->input->post('postTitle');
|
||||
$postDescription = $this->input->post('postDescription');
|
||||
$postContent = $this->input->post('postContent');
|
||||
|
||||
$postPublishDate = $this->input->post('postPublishDate');
|
||||
$postPublishDate = date("Y-m-d H:i:s", strtotime($postPublishDate));
|
||||
|
||||
$postUrl = $this->input->post('postUrl');
|
||||
$postCategory = $this->input->post('postCategory');
|
||||
$postTags = $this->input->post('postTags');
|
||||
|
||||
$postLang = $this->input->post('postLanguage');
|
||||
$postLang = $postLang !== NULL ? $postLang : 'de';
|
||||
|
||||
if(strlen($postUrl) == 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
|
||||
exit;
|
||||
}
|
||||
if(strlen($postUrl) < 4) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL ist zu kurz. Sie muss mindestens 4 Zeichen umfassen, um eine eindeutige Zuordnung zu ermöglichen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($postID == -1 || $translationID == -1) { // Create new blog post
|
||||
if ($postID == -1) {
|
||||
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
|
||||
|
||||
if($this->BlogModel->postUrlExisting($postUrl)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$translationID = $this->BlogModel->createNewTranslation($postID, $postLang);
|
||||
}
|
||||
|
||||
if ($contentID < 0) {
|
||||
$contentID = $this->BlogModel->createNewContentDraft($postID);
|
||||
}
|
||||
|
||||
$this->BlogModel->updatePostDraft($postID, $postUrl, $postCategory, $postPublishDate, $postImage);
|
||||
$this->BlogModel->updateContentDraft($contentID, $postContent, $postLang);
|
||||
$this->BlogModel->updateTranslation($translationID, $postTitle, $postDescription);
|
||||
|
||||
if(!empty($postTags)) {
|
||||
$this->BlogModel->deleteAllPostTags($postID);
|
||||
foreach ($postTags as $postTag) {
|
||||
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
|
||||
$this->BlogModel->addPostTagByID($postID, $tagID);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'contentID' => $contentID, 'translationID' => $translationID]);
|
||||
}
|
||||
|
||||
public function publishPost()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID < 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentIDs = $this->input->post('contentIDs');
|
||||
$contentPublished = FALSE;
|
||||
foreach ($contentIDs as $lang => $contentID) {
|
||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
||||
|
||||
if($contentID < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->BlogModel->publishContentDraft($_SESSION['user']['ID'], $contentID, $postID, $lang);
|
||||
$contentPublished = TRUE;
|
||||
}
|
||||
|
||||
if (!$contentPublished) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Content-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->BlogModel->publishPostDraft($postID);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich veröffentlicht.']);
|
||||
}
|
||||
|
||||
public function getTranslations()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID < 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translations = $this->BlogModel->getPostTranslations($postID);
|
||||
echo json_encode(['status' => 'success', 'translations' => $translations]);
|
||||
}
|
||||
|
||||
public function getPost() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postData = $this->BlogModel->getPostDataByID($postID);
|
||||
|
||||
if(empty($postData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
$contentID = intval($this->input->post('contentID'));
|
||||
$language = $this->input->post('lang');
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!is_numeric($contentID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentData = $this->BlogModel->getContentDataByID($postID, $contentID, $language);
|
||||
|
||||
if(empty($contentData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'contentData' => $contentData[0]]);
|
||||
}
|
||||
|
||||
public function getTranslationData() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
$translationID = intval($this->input->post('translationID'));
|
||||
$language = $this->input->post('lang');
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!is_numeric($translationID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translationData = $this->BlogModel->getTranslationDataByID($postID, $translationID, $language);
|
||||
|
||||
if(empty($translationData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'translationData' => $translationData[0]]);
|
||||
}
|
||||
|
||||
public function getPostTags() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postTags = $this->BlogModel->getTags($postID);
|
||||
|
||||
echo json_encode(['success' => true, 'tags' => $postTags]);
|
||||
}
|
||||
|
||||
public function edit($postID = -1, $lang = "de")
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
|
||||
$translations = ['de' => -1];
|
||||
$contents = ['de' => -1];
|
||||
|
||||
if(!$postID != -1) {
|
||||
if($this->BlogModel->postIDExisting($postID)) {
|
||||
$postTranslations = $this->BlogModel->getPostTranslationIDs($postID);
|
||||
foreach ($postTranslations as $postTranslation) {
|
||||
$translations[$postTranslation['language']] = $postTranslation['postTranslationID'];
|
||||
}
|
||||
|
||||
$postContents = $this->BlogModel->getPostContentIDs($postID);
|
||||
foreach ($postContents as $postContent) {
|
||||
$contents[$postContent['language']] = $postContent['contentID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$categories = $this->BlogModel->getCategories();
|
||||
$this->load->view('admin/sidebar', ['title' => 'Blog-Post erstellen', 'additionalStyles' => ['lib/medium-editor.min.css', 'lib/default.min.css', 'lib/medium-editor-insert-plugin.min.css']]);
|
||||
$this->load->view('admin/blog_edit', ['categories' => $categories, 'postID' => $postID, 'contents' => $contents, 'translations' => $translations, 'postLanguage' => $lang]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => 'lib/medium-editor.min.js,lib/handlebars.runtime-v4.0.10.js,lib/jquery-sortable.min.js,lib/jquery.ui.widget.js,lib/jquery.iframe-transport.js,lib/jquery.fileupload.js,lib/medium-editor-insert-plugin.min.js,lib/autolist.min.js,lib/highlight.pack.js,lib/quill.min.js,blog-edit.js']);
|
||||
}
|
||||
|
||||
public function history($postID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
if ($postID === NULL) redirect(base_url('admin/blog'));
|
||||
|
||||
$content['de'] = $this->BlogModel->getAllContentVersions($postID, 'de');
|
||||
$content['en'] = $this->BlogModel->getAllContentVersions($postID, 'en');
|
||||
$content['fr'] = $this->BlogModel->getAllContentVersions($postID, 'fr');
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Geschichte']);
|
||||
$this->load->view('admin/blog_history', ['content' => $content]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function new_category()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] !== 'admin') redirect(base_url('login'));
|
||||
$name = filter_input(INPUT_POST, "name");
|
||||
$display_name = filter_input(INPUT_POST, "display_name");
|
||||
if ($name !== NULL && $display_name !== NULL) {
|
||||
$category = $this->BlogModel->getCategoryIDAfterInsert($name, $display_name);
|
||||
echo $category;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
echo $this->BlogModel->deletePost($id);
|
||||
}
|
||||
|
||||
public function deleteFinally()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->BlogModel->deletePostFinally($id);
|
||||
}
|
||||
|
||||
public function restore()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
echo $this->BlogModel->restorePost($id);
|
||||
}
|
||||
|
||||
public function trashbin()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$posts = $this->BlogModel->getPostList(true);
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
||||
$this->load->view('admin/blog_posts', ['posts' => $posts, 'trashbin' => true]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function tagsList()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo '{"type":"error", "message":"<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden <i>Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontakformular.</i>"}';
|
||||
header("Content-Type: application/json");
|
||||
exit;
|
||||
}
|
||||
echo json_encode($this->BlogModel->getAllTags());
|
||||
header("Content-Type: application/json");
|
||||
}
|
||||
}
|
24
application/controllers/admin/Calendar.php
Normal file
24
application/controllers/admin/Calendar.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Calendar extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('adminModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$this->load->view('admin/sidebar', ['title' => 'Dashboard']);
|
||||
$this->load->view('admin/calendar');
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
$events = $this->adminModel->getCalendarEvents();
|
||||
|
||||
echo json_encode($events);
|
||||
}
|
||||
}
|
18
application/controllers/admin/Contact.php
Normal file
18
application/controllers/admin/Contact.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Contact extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Kontakt-Nachrichten']);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
17
application/controllers/admin/Dashboard.php
Normal file
17
application/controllers/admin/Dashboard.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Dashboard extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$this->load->view('admin/sidebar', ['title' => 'Dashboard']);
|
||||
$this->load->view('admin/dashboard');
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
74
application/controllers/admin/Downloads.php
Normal file
74
application/controllers/admin/Downloads.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Downloads extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('downloadsModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$downloads = $this->downloadsModel->getDownloads();
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Downloads']);
|
||||
$this->load->view('admin/downloads', ['downloads' => $downloads]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function edit($id = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$edit = $id === NULL ? false : true;
|
||||
$p = $this->input->post(['title', 'description', 'descriptionEnglish', 'image', 'url', 'datetime']);
|
||||
|
||||
if ($edit) {
|
||||
if ($this->downloadsModel->checkIfExists($id)) {
|
||||
$downloadContent = $this->downloadsModel->getDownload($id);
|
||||
} else {
|
||||
redirect(base_url('admin/downloads/edit'));
|
||||
}
|
||||
|
||||
if ($p['title'] != NULL && $p['description'] != NULL && $p['datetime'] != NULL && $p['url'] !== NULL) {
|
||||
$imgurl = '/assets/images/placeholder.jpg';
|
||||
if (isset($_FILES['downloadImage']) && $_FILES['downloadImage']['size'] > 0) {
|
||||
$fileName = $_FILES['downloadImage']['name'];
|
||||
$tmpName = $_FILES['downloadImage']['tmp_name'];
|
||||
$fileSize = $_FILES['downloadImage']['size'];
|
||||
$fileType = $_FILES['downloadImage']['type'];
|
||||
unset($_FILES['downloadImage']);
|
||||
|
||||
$imgurl = $this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
|
||||
}
|
||||
$this->downloadsModel->addNewDownload($p['datetime'], $p['title'], $p['description'], $p['descriptionEnglish'], $imgurl, $p['url']);
|
||||
redirect(base_url('admin/downloads/edit/' . $id));
|
||||
}
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Download-Eintrag bearbeiten']);
|
||||
$this->load->view('admin/download_edit', ['edit' => $edit, 'content' => $downloadContent]);
|
||||
$this->load->view('admin/footer');
|
||||
} else {
|
||||
if ($p['title'] != NULL && $p['description'] != NULL && $p['datetime'] != NULL && isset($_FILES['downloadImage']) && $_FILES['downloadImage']['size'] > 0 && $p['url'] !== NULL) {
|
||||
$fileName = $_FILES['downloadImage']['name'];
|
||||
$tmpName = $_FILES['downloadImage']['tmp_name'];
|
||||
$fileSize = $_FILES['downloadImage']['size'];
|
||||
$fileType = $_FILES['downloadImage']['type'];
|
||||
|
||||
$imgurl = $this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
|
||||
unset($_FILES['downloadImage']);
|
||||
|
||||
$this->downloadsModel->addNewDownload($p['datetime'], $p['title'], $p['description'], $p['descriptionEnglish'], $imgurl, $p['url']);
|
||||
redirect(base_url('admin/downloads/edit'));
|
||||
}
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Download-Eintrag erstellen']);
|
||||
$this->load->view('admin/download_edit', ['edit' => $edit]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
67
application/controllers/admin/Feedback.php
Normal file
67
application/controllers/admin/Feedback.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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.']);
|
||||
}
|
||||
}
|
||||
}
|
74
application/controllers/admin/Files.php
Normal file
74
application/controllers/admin/Files.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Files extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if(isset($_FILES['fileUpload'])) {
|
||||
$fileName = $_FILES['fileUpload']['name'];
|
||||
$tmpName = $_FILES['fileUpload']['tmp_name'];
|
||||
$fileSize = $_FILES['fileUpload']['size'];
|
||||
$fileType = $_FILES['fileUpload']['type'];
|
||||
|
||||
$this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
|
||||
|
||||
unset($_FILES['fileUpload']);
|
||||
|
||||
redirect(base_url('admin/files'));
|
||||
}
|
||||
|
||||
|
||||
$files = $this->FileModel->getFileList();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Dateien', 'additionalStyles' => ['lib/jquery.fileupload.css', 'lib/jquery.fileupload-ui.css']]);
|
||||
$this->load->view('admin/files', ['files' => $files]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/jquery.ui.widget.js', 'lib/jquery.iframe-transport.js', 'lib/jquery.fileupload.js', 'lib/jquery.fileupload-process.js', 'lib/jquery.fileupload-image.js', 'lib/jquery.fileupload-audio.js', 'lib/jquery.fileupload-video.js', 'lib/jquery.fileupload-validate.js', 'lib/jquery.fileupload-ui.js']]);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->FileModel->delete($id);
|
||||
}
|
||||
|
||||
public function uploadImage()
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden. Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontaktformular.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!isset($_POST['image']) || !isset($_POST['name']) || !isset($_POST['type']) || !isset($_POST['size'])) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '<b>Fehler beim Upload!</b> Das hochgeladene Bild enthält fehlerhafte Informationen.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$image = str_replace(' ', '+', $_POST['image']);
|
||||
$image = substr($image, strpos($image, ',') + 1);
|
||||
$image = base64_decode($image);
|
||||
|
||||
$fileUrl = $this->FileModel->uploadFileByContent($image, $_POST['name'], $_POST['type'], $_POST['size']);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => '<b>Bild erfolgreich hochgeladen!</b>',
|
||||
'url' => $fileUrl
|
||||
]);
|
||||
}
|
||||
}
|
109
application/controllers/admin/Projects.php
Normal file
109
application/controllers/admin/Projects.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Projects extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ProjectsModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$entries = $this->ProjectsModel->getEntries('all');
|
||||
$categories = $this->ProjectsModel->getCategories('all');
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Projekte verwalten']);
|
||||
$this->load->view('admin/projects', ['entries' => $entries, 'categories' => $categories]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function edit($id = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$edit = $id === NULL ? false : true;
|
||||
$content = null;
|
||||
$projectCategories = [];
|
||||
|
||||
if ($edit) {
|
||||
if ($this->ProjectsModel->checkIfExists($id)) {
|
||||
$content = $this->ProjectsModel->getEntry($id)[0];
|
||||
$projectCategories = $this->ProjectsModel->getEntryCategories($id);
|
||||
} else {
|
||||
redirect(base_url('admin/projects/edit'));
|
||||
}
|
||||
}
|
||||
|
||||
$categories = $this->ProjectsModel->getCategories();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Projekt erstellen', 'additionalStyles' => ['lib/content-tools/content-tools.min.css', 'project-edit.css']]);
|
||||
$this->load->view('admin/project_edit', ['edit' => -1, 'categories' => $categories, 'content' => $content, 'pCategories' => $projectCategories]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/content-tools/content-tools.min.js', 'project-edit.js']]);
|
||||
}
|
||||
|
||||
public function sendEdit()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um Projekte zu erstellen bzw. bearbeiten.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translations = [];
|
||||
$translations['de']['title'] = $this->input->post('titleDE');
|
||||
$translations['de']['description'] = $this->input->post('headlineDE');
|
||||
$translations['de']['content'] = $this->input->post('contentDE');
|
||||
|
||||
$url = $this->input->post('url');
|
||||
|
||||
$download['available'] = $this->input->post('isDownloadable') == 'on' ? true : false;
|
||||
$download['link'] = $this->input->post('downloadLink');
|
||||
$download['name'] = $this->input->post('downloadLinkName');
|
||||
|
||||
$openSource['available'] = $this->input->post('isOpenSource') == 'on' ? true : false;
|
||||
$openSource['link'] = $this->input->post('openSourceLink');
|
||||
$openSource['name'] = $this->input->post('openSourceLinkName');
|
||||
|
||||
$customLink['link'] = $this->input->post('customLink');
|
||||
$customLink['name'] = $this->input->post('customLinkName');
|
||||
|
||||
$categories = $this->input->post('categories');
|
||||
$date = date('Y-m-d H:i:s', strtotime($this->input->post('date')));
|
||||
$image = $this->input->post('image');
|
||||
|
||||
$editingID = $this->input->post('editingID');
|
||||
|
||||
if($editingID == '-1' && $this->ProjectsModel->checkIfNameExists($url)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene URL ist bereits vergeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($editingID == '-1' || !$this->ProjectsModel->checkIfExists($editingID)) {
|
||||
$editingID = $this->ProjectsModel->createNewProjectDraft();
|
||||
}
|
||||
|
||||
$this->ProjectsModel->updateProject($editingID, $translations, $url, $download, $openSource, $customLink, $date, $image);
|
||||
$this->ProjectsModel->updateCategories($editingID, $categories);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Das Projekt wurde erfolgreich gespeichert.', 'id' => $editingID]);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->ProjectsModel->delete($id);
|
||||
}
|
||||
|
||||
public function delete_category()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->ProjectsModel->deleteCategory($id);
|
||||
}
|
||||
}
|
49
application/controllers/admin/Redirects.php
Normal file
49
application/controllers/admin/Redirects.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Redirects extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('RedirectModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$redirects = $this->RedirectModel->getItems();
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Weiterleitungen']);
|
||||
$this->load->view('admin/redirects', ['redirects' => $redirects]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['redirects.js']]);
|
||||
}
|
||||
|
||||
public function addRedirect() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$id = $this->input->post('redirectID');
|
||||
$name = $this->input->post('redirectName');
|
||||
$url = $this->input->post('redirectUrl');
|
||||
|
||||
if(isset($name) && isset($url)) {
|
||||
if(isset($id)) {
|
||||
$this->RedirectModel->editRedirect($id, $url, $name);
|
||||
} else {
|
||||
$this->RedirectModel->insertRedirect($url, $name);
|
||||
}
|
||||
}
|
||||
|
||||
redirect(base_url('admin/redirects'));
|
||||
}
|
||||
|
||||
public function removeRedirect($id = null) {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if($id != null) {
|
||||
$this->RedirectModel->removeRedirect($id);
|
||||
}
|
||||
|
||||
redirect(base_url('admin/redirects'));
|
||||
}
|
||||
}
|
84
application/controllers/admin/Users.php
Normal file
84
application/controllers/admin/Users.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Users extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$usersData = $this->UserModel->getUserList(50, 0);
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Nutzer']);
|
||||
$this->load->view('admin/users', ['users' => $usersData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function details($userID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if ($userID == NULL) redirect(base_url('admin/users'));
|
||||
|
||||
$userData = $this->UserModel->getUserByID($userID);
|
||||
|
||||
if ($userData == null) redirect(base_url('admin/users'));
|
||||
$userData = $userData[0];
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Details - ' . $userData['displayname']]);
|
||||
$this->load->view('admin/user_details', ['user' => $userData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function settings($userID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if ($userID == NULL) redirect(base_url('admin/users'));
|
||||
|
||||
$userData = $this->UserModel->getUserByID($userID);
|
||||
|
||||
if ($userData == null) redirect(base_url('admin/users'));
|
||||
$userData = $userData[0];
|
||||
|
||||
if (isset($_POST['rank'])) {
|
||||
$rank = intval($_POST['rank']);
|
||||
if (($rank < 1) || ($rank > 3 && $rank < 6) || $rank > 10) {
|
||||
redirect(base_url(uri_string()));
|
||||
}
|
||||
// Add entry to history
|
||||
$historyData = [
|
||||
'ID' => $userID,
|
||||
'username' => $userData['username'],
|
||||
'displayname' => $userData['displayname'],
|
||||
'email' => $userData['email'],
|
||||
'rank' => $userData['rank'],
|
||||
'profile_picture' => $userData['profile_picture'],
|
||||
'header_image' => $userData['header_image'],
|
||||
'social_networks' => $userData['social_networks'],
|
||||
'showAds' => $userData['showAds'],
|
||||
'about' => $userData['about'],
|
||||
'language' => $userData['language'],
|
||||
'country' => $userData['country'],
|
||||
'gender' => $userData['gender'],
|
||||
'receiveEmails' => $userData['receiveEmails'],
|
||||
'receiveNewsletter' => $userData['receiveNewsletter']
|
||||
];
|
||||
$this->UserModel->insertIntoHistory($historyData);
|
||||
// Update profile
|
||||
$this->UserModel->updateProfile(['rank' => $rank], $userID);
|
||||
redirect(base_url(uri_string()));
|
||||
}
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Nutzer-Einstellungen - ' . $userData['displayname']]);
|
||||
$this->load->view('admin/user_settings', ['user' => $userData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user