diff --git a/application/controllers/yllapito.php b/application/controllers/yllapito.php index 5be014a..fe37f36 100644 --- a/application/controllers/yllapito.php +++ b/application/controllers/yllapito.php @@ -9,8 +9,11 @@ class Yllapito extends CI_Controller { parent::__construct(); $this->load->model('ecard_model', 'ecard'); + $this->load->model('user_model', 'users'); $this->load->model('erkanaauth_model', 'erkana'); + $this->load->helper('date'); + $this->user = $this->erkana->getUser(); if (!empty($this->user)) { @@ -120,6 +123,48 @@ class Yllapito extends CI_Controller $this->load->view('_footer', $data); } + public function users($section = 'listall', $user_id = null, $action = null) + { + if (empty($this->user)) { + redirect("/yllapito/kirjaudu"); + } + + $data = array( + 'page_title' => array( 'Ystäväkylä eKortti' ), + 'page_classes' => array( 'frontpage' ), + 'user' => $this->user, + 'count' => $this->card_count, + 'messages' => $this->session->flashdata('messages') + ); + $page_title = array(); + + switch ($section) { + case 'modify': + if ($action == "delete" && is_numeric($user_id)) { + $this->user->delete($user_id); + } + redirect("yllapito/users"); + break; + case 'show': + $data['userid'] = $user_id; + $data['userdata'] = $this->users->get($user_id); + $page_title = array("Tiedot", "Käyttäjät"); + break; + default: + $data['users'] = $this->users->get_all(); + $page_title = array("Listaa kaikki", "Käyttäjät"); + break; + } + + + $data['page_title'] = array_merge($page_title, $data['page_title']); + $page = 'yllapito/users_'.$section; + + $this->load->view('_header', $data); + $this->load->view($page, $data); + $this->load->view('_footer', $data); + } + public function kirjaudu() { // POST diff --git a/application/models/user_model.php b/application/models/user_model.php new file mode 100644 index 0000000..f1b76e5 --- /dev/null +++ b/application/models/user_model.php @@ -0,0 +1,20 @@ + +
| Nimi | +Tunnus lisätty | +Edellinen kirjautuminen | +Julkaisu | +Näkee jäsenet | +Hallitsee jäseniä | +
|---|---|---|---|---|---|
| id, $name); ?> + username; ?> + |
+ created_at; ?> created_at), $now); + ?> |
+ last_login;
+ ?> last_login), $now); + ?> |
+ + | + | + |