49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?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'));
|
|
}
|
|
} |