2021-10-30 19:02:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class News extends MO_Controller
|
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
public function index($page = 1)
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$this->check_login()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->load->model('news_model');
|
|
|
|
|
|
|
|
$data['admin'] = false;
|
|
|
|
|
|
|
|
if ($this->userlevel > 3) {
|
|
|
|
$data['admin'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['news'] = $this->news_model->get_news($page);
|
|
|
|
|
|
|
|
$this->headers();
|
|
|
|
$this->load->view('news/news', $data);
|
|
|
|
$this->footer();
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
public function add()
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
if ($this->userlevel < 3) {
|
|
|
|
show_404();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('text', 'Text', 'required');
|
|
|
|
|
|
|
|
if (!$this->form_validation->run()) {
|
|
|
|
$this->load->helper(array('form', 'url'));
|
|
|
|
|
|
|
|
$this->headers();
|
|
|
|
$this->load->view('news/add');
|
|
|
|
$this->footer();
|
|
|
|
} else {
|
|
|
|
$this->load->model('news_model');
|
|
|
|
|
|
|
|
if ($this->news_model->add_news($this->input->post('text'), $this->username)) {
|
|
|
|
$this->load->view('news/add_success');
|
|
|
|
} else {
|
|
|
|
$this->load->view('db_error');
|
|
|
|
}
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
2021-11-14 11:02:22 +01:00
|
|
|
|
|
|
|
public function delete($nid)
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$this->userlevel < 3) {
|
|
|
|
show_404();
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//nowhitesp
|