63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
class Users extends CI_Controller{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
checkLogin();
|
|
isViewPermitted();
|
|
$this->load->model('MUsers');
|
|
}
|
|
public function index(){
|
|
$data['Users']=$this->MUsers->getUsers();
|
|
loadView('users/view',$data);
|
|
}
|
|
|
|
public function add(){
|
|
$privilege=$_POST;
|
|
array_splice($privilege, 0, 3);
|
|
if (isset($_POST['user_name'])){
|
|
$inputArray=array(
|
|
'user_name'=>$_POST['user_name'],
|
|
'user_password'=>$_POST['user_password'],
|
|
'user_email'=>$_POST['user_email'],
|
|
'user_privilege'=>json_encode($privilege),
|
|
'status'=>2
|
|
);
|
|
$this->MUsers->addUser($inputArray);
|
|
redirect('users');
|
|
}
|
|
$data['Users']=$this->MUsers->getUsers();
|
|
//pre($data);die;
|
|
loadView('users/add',$data);
|
|
}
|
|
|
|
function edit($id){
|
|
$privilege=$_POST;
|
|
array_splice($privilege, 0, 3);
|
|
if (isset($_POST['user_name'])){
|
|
$inputArray=array(
|
|
'user_name'=>$_POST['user_name'],
|
|
'user_password'=>$_POST['user_password'],
|
|
'user_email'=>$_POST['user_email'],
|
|
'user_privilege'=>json_encode($privilege),
|
|
);
|
|
$this->MUsers->UpdateUser($inputArray,$id);
|
|
redirect('users');
|
|
}
|
|
$data['User']=$this->MUsers->getUsers();
|
|
$data['Users']=$this->MUsers->getUserById($id);
|
|
//pre($data);die;
|
|
loadView('users/edit',$data);
|
|
}
|
|
|
|
function delete($id){
|
|
$this->MUsers->deleteuser($id);
|
|
redirect('users');
|
|
$data['Users']=$this->MUsers->getUserById($id);
|
|
loadView('users/delete',$data);
|
|
}
|
|
|
|
|
|
|
|
|
|
} |