-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserController.php
executable file
·90 lines (81 loc) · 2.17 KB
/
UserController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php namespace Clips\Web\Controllers; in_array(__FILE__, get_included_files()) or exit("No direct script access allowed");
use Clips\Controller;
/**
* Auto generated controller by Scaffold for table users.
*
* @author Jack
* @version 1.0
* @date Mon Mar 30 19:39:09 2015
*
* @Clips\Widget({"html", "lang", "adminlte", "navigation"})
* @Clips\Model({ "user", "role" });
* @Clips\DataGenerator()
*/
class UserController extends Controller {
/**
* @Clips\Widgets\DataTable("user")
* @Clips\Actions("user")
*/
public function index() {
$this->title("User List", true);
return $this->render('admin/user/index');
}
/**
* @Clips\Form("user_edit")
* @Clips\Actions("user")
*/
public function show($id) {
$this->title("User Details for user $id", true);
$data = $this->user->load($id);
$this->formData("user_edit", $data);
$args = array('groups' => $this->group->get());
$args['data'] = $data;
$args['id'] = $id;
return $this->render('user/show', $args);
}
/**
* @Clips\Actions("user")
*/
public function create() {
$this->title("Create User", true);
return $this->render('user/create', array('roles' => $this->role->get()));
}
/**
* @Clips\Form("admin/user/create")
*/
public function create_form() {
$this->user->insert($this->user->cleanFields('users', $this->post()));
return $this->redirect(\Clips\site_url('user/index'));
}
/**
* @Clips\Form("user_edit")
* @Clips\Actions("user")
*/
public function edit($id) {
$this->title("Edit User for user $id", true);
$data = $this->user->load($id);
$this->formData("user_edit", $data);
return $this->render('user/edit', array('groups' => $this->group->get()));
}
/**
* @Clips\Form("user_edit")
*/
public function edit_form() {
$data = $this->user->cleanFields('users', $this->post());
$result = $this->user->update((Object)$data);
if ($result) {
return $this->redirect(\Clips\site_url("user/index"));
} else {
$this->error('Error in updating user.', 'update');
}
}
public function delete($id = null) {
if($id) {
$this->user->delete($id);
}
else {
$this->user->delete($this->post('ids'));
}
return $this->redirect(\Clips\site_url('user/index'));
}
}