mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-01-26 03:04:00 +00:00
List and show user details, new model User
This commit is contained in:
@@ -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
|
||||
|
||||
20
application/models/user_model.php
Normal file
20
application/models/user_model.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User model that we use to control our users
|
||||
*/
|
||||
class User_model extends MY_Model
|
||||
{
|
||||
public $before_create = array( 'timestamps' );
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function timestamps($ecard)
|
||||
{
|
||||
$ecard['created_at'] = $ecard['updated_at'] = date('Y-m-d H:i:s');
|
||||
return $ecard;
|
||||
}
|
||||
}
|
||||
84
application/views/yllapito/users_listall.php
Normal file
84
application/views/yllapito/users_listall.php
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="large-12 small-12 columns">
|
||||
<div class="panel">
|
||||
|
||||
<h2>Kaikki käyttäjät</h2>
|
||||
|
||||
<?php
|
||||
if (empty($user)) {
|
||||
$user = new stdClass();
|
||||
}
|
||||
|
||||
if ($user->can_seeusers == 'no') { ?>
|
||||
<div data-alert class="alert-box error">
|
||||
Sinulla ei ole oikeutta käyttäjien listaamiseen.
|
||||
</div>
|
||||
<?php
|
||||
} else { ?>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nimi</th>
|
||||
<th>Tunnus lisätty</th>
|
||||
<th>Edellinen kirjautuminen</th>
|
||||
<th>Julkaisu</th>
|
||||
<th>Näkee jäsenet</th>
|
||||
<th>Hallitsee jäseniä</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (empty($users)) {
|
||||
$users = array();
|
||||
} else {
|
||||
|
||||
$ok = site_url('assets/img/ok.png');
|
||||
$no = site_url('assets/img/no.png');
|
||||
$now = time();
|
||||
|
||||
foreach ($users as $usr) {
|
||||
|
||||
// Set images accordingly permissions
|
||||
$queue = ($usr->can_approve == "yes") ? img($ok, true) : img($no, true);
|
||||
$seeusr = ($usr->can_seeusers == "yes") ? img($ok, true) : img($no, true);
|
||||
$modusr = ($usr->can_modusers == "yes") ? img($ok, true) : img($no, true);
|
||||
|
||||
$name = $usr->firstname. " ". $usr->lastname;
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo lnk("yllapito/users/show/". $usr->id, $name); ?><br>
|
||||
<small><?php echo $usr->username; ?></small>
|
||||
</td>
|
||||
<td><?php
|
||||
echo $usr->created_at; ?><br><small><?php
|
||||
echo timespan(strtotime($usr->created_at), $now);
|
||||
?></small></td>
|
||||
<td><?php
|
||||
echo $usr->last_login;
|
||||
?><br><small><?php
|
||||
echo timespan(strtotime($usr->last_login), $now);
|
||||
?></small></td>
|
||||
<td><?php echo $queue; ?></td>
|
||||
<td><?php echo $seeusr; ?></td>
|
||||
<td><?php echo $modusr; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
37
application/views/yllapito/users_show.php
Normal file
37
application/views/yllapito/users_show.php
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
<?php
|
||||
if (empty($userdata)) {
|
||||
$userdata = array();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="large-12 small-12 columns">
|
||||
<div class="panel">
|
||||
|
||||
<?php
|
||||
if ($user->can_seeusers == "no") {
|
||||
?>
|
||||
<div data-alert class="alert-box error">
|
||||
Sinulla ei ole oikeutta käyttäjien listaamiseen.
|
||||
</div>
|
||||
<?php echo lnk("yllapito/users", "Takaisin"); ?>
|
||||
<?php
|
||||
} elseif (empty($userdata) || ! is_object($userdata)) {
|
||||
?>
|
||||
<h2>Käyttäjää tunnisteella #<?php echo $userid; ?> ei löydetty</h2>
|
||||
<?php echo lnk("yllapito/users", "Takaisin"); ?>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<h2>Käyttäjä #<?php echo $userdata->id; ?></h2>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
BIN
assets/img/no.png
Executable file
BIN
assets/img/no.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 172 B |
BIN
assets/img/ok.png
Executable file
BIN
assets/img/ok.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 236 B |
Reference in New Issue
Block a user