kopia lustrzana https://github.com/magicbug/Cloudlog
More user changes. 'user/add' now implemented.
rodzic
7c76e0b37f
commit
c2a7e45ca5
|
@ -15,6 +15,12 @@ $config['auth_table'] = "users";
|
||||||
// Minimum user level required
|
// Minimum user level required
|
||||||
// 0 = anonymous, 1 = viewer, 2 = editor, 3 = api user, 99 = owner
|
// 0 = anonymous, 1 = viewer, 2 = editor, 3 = api user, 99 = owner
|
||||||
$config['auth_mode'] = "0";
|
$config['auth_mode'] = "0";
|
||||||
|
// User levels
|
||||||
|
$config['auth_level'][0] = "Anonymous";
|
||||||
|
$config['auth_level'][1] = "Viewer";
|
||||||
|
$config['auth_level'][2] = "Editor";
|
||||||
|
$config['auth_level'][3] = "API User";
|
||||||
|
$config['auth_level'][99] = "Administrator";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -14,42 +14,48 @@ class User extends CI_Controller {
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
function add() {
|
function add() {
|
||||||
|
$this->load->model('user_model');
|
||||||
$this->load->model('note');
|
|
||||||
|
|
||||||
$this->load->library('form_validation');
|
$this->load->library('form_validation');
|
||||||
|
|
||||||
$this->form_validation->set_rules('title', 'Note Title', 'required');
|
$this->form_validation->set_rules('user_name', 'Username', 'required');
|
||||||
$this->form_validation->set_rules('content', 'Content', 'required');
|
$this->form_validation->set_rules('user_email', 'E-mail', 'required');
|
||||||
|
$this->form_validation->set_rules('user_password', 'Password', 'required');
|
||||||
|
$this->form_validation->set_rules('user_type', 'Type', 'required');
|
||||||
|
|
||||||
if ($this->form_validation->run() == FALSE)
|
if ($this->form_validation->run() == FALSE)
|
||||||
{
|
{
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('notes/add');
|
if($this->input->post('user_name'))
|
||||||
|
{
|
||||||
|
$data['user_name'] = $this->input->post('user_name');
|
||||||
|
$data['user_email'] = $this->input->post('user_email');
|
||||||
|
$data['user_password'] = $this->input->post('user_password');
|
||||||
|
$data['user_type'] = $this->input->post('user_type');
|
||||||
|
$this->load->view('user/add', $data);
|
||||||
|
} else {
|
||||||
|
$this->load->view('user/add');
|
||||||
|
}
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->note->add();
|
if($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'))) {
|
||||||
|
$this->session->set_flashdata('notice', 'User '.$this->input->post('user_name').' added');
|
||||||
redirect('notes');
|
redirect('user');
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
function view($id) {
|
|
||||||
$this->load->model('note');
|
|
||||||
|
|
||||||
$data['note'] = $this->note->view($id);
|
|
||||||
|
|
||||||
// Display
|
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('notes/view',$data);
|
$this->session->set_flashdata('notice', 'Problem adding user');
|
||||||
|
$data['user_name'] = $this->input->post('user_name');
|
||||||
|
$data['user_email'] = $this->input->post('user_email');
|
||||||
|
$data['user_password'] = $this->input->post('user_password');
|
||||||
|
$data['user_type'] = $this->input->post('user_type');
|
||||||
|
$this->load->view('user/add', $data);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function edit() {
|
function edit() {
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
|
|
|
@ -25,7 +25,7 @@ class User_Model extends CI_Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists($username) {
|
function exists($username) {
|
||||||
if($this->get($username)->results()->num_rows == 0) {
|
if($this->get($username)->num_rows == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -41,7 +41,7 @@ class User_Model extends CI_Model {
|
||||||
'user_type' => $type
|
'user_type' => $type
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->db->insert($this->config->item('auth_table'));
|
$this->db->insert($this->config->item('auth_table'), $data);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<h2>Add user</h2>
|
||||||
|
<div class="wrap_content user">
|
||||||
|
<?php echo validation_errors(); ?>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo site_url('user/add'); ?>" name="users">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Username</td>
|
||||||
|
<td><input type="text" name="user_name" value="<?php if(isset($user_name)) { echo $user_name; } ?>" /></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>E-mail</td>
|
||||||
|
<td><input type="text" name="user_email" value="<?php if(isset($user_email)) { echo $user_email; } ?>" /></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Password</td>
|
||||||
|
<td><input type="password" name="user_password" value="<?php if(isset($user_password)) { echo $user_password; } ?>" /></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Type</td>
|
||||||
|
<td><select name="user_type">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$levels = $this->config->item('auth_level');
|
||||||
|
while (list($key, $val) = each($levels)) {
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $key; ?>" <?php if(isset($user_type)) { if($user_type == $key) { echo "selected=\"selected\""; } } ?>><?php echo $val; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
|
||||||
|
<div><input type="submit" value="Submit" /></div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Password</td>
|
<td>Password</td>
|
||||||
<td><input type="text" name="user_password" /><br><div class="small">Leave blank to keep existing password</div></td>
|
<td><input type="password" name="user_password" /><br><div class="small">Leave blank to keep existing password</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -50,4 +50,5 @@
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; } ?>
|
<?php $i++; } ?>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="controls"><a href="<?php echo site_url('user/add'); ?>">Add user</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Ładowanie…
Reference in New Issue