mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-25 03:31:13 +00:00
76 lines
2.2 KiB
PHP
76 lines
2.2 KiB
PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Club extends CI_Controller
|
|
{
|
|
|
|
/**
|
|
* @var array $permissions
|
|
*/
|
|
private $permissions = [
|
|
9 => "Officer",
|
|
3 => "Member",
|
|
];
|
|
|
|
public function index()
|
|
{
|
|
// nothing to display
|
|
redirect('dashboard');
|
|
}
|
|
|
|
public function permissions($club_id) {
|
|
|
|
$this->load->model('user_model');
|
|
$this->load->model('club_model');
|
|
$this->load->library('form_validation');
|
|
|
|
$cid = $this->security->xss_clean($club_id);
|
|
$club = $this->user_model->get_by_id($cid)->row();
|
|
|
|
if (!is_numeric($cid)) {
|
|
$this->session->set_flashdata('error', __("Invalid User ID!"));
|
|
redirect('user');
|
|
}
|
|
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $cid)) {
|
|
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
|
redirect('dashboard');
|
|
}
|
|
if ($club->clubstation != 1) {
|
|
$this->session->set_flashdata('error', __("This user is not a club station."));
|
|
redirect('user');
|
|
}
|
|
|
|
$data['page_title'] = __("Club Permissions");
|
|
$data['club'] = $club;
|
|
$data['club_members'] = $this->club_model->get_club_members($cid);
|
|
$data['users'] = $this->user_model->users();
|
|
$data['permissions'] = $this->permissions;
|
|
|
|
$this->load->view('interface_assets/header', $data);
|
|
$this->load->view('club/permissions');
|
|
$this->load->view('interface_assets/footer');
|
|
}
|
|
|
|
public function alter_member() {
|
|
|
|
$this->load->model('user_model');
|
|
$this->load->model('club_model');
|
|
|
|
$club_id = $this->input->post('club_id', true);
|
|
$user_id = $this->input->post('user_id', true);
|
|
$p_level = $this->input->post('permission', true);
|
|
|
|
if (!is_numeric($club_id)) {
|
|
$this->session->set_flashdata('error', __("Invalid Club ID!"));
|
|
redirect('dashboard');
|
|
}
|
|
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $club_id)) {
|
|
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
|
redirect('dashboard');
|
|
}
|
|
|
|
$this->club_model->add_member($club_id, $user_id, $p_level);
|
|
$this->session->set_flashdata('message', __("User added to club."));
|
|
redirect('club/permissions/'.$club_id);
|
|
}
|
|
|
|
} |