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/Users.php

84 lines
3.2 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 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');
}
}