103 lines
3.8 KiB
PHP
103 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Models\UserModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class UserController extends \App\Controllers\Admin\AdminController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->_className .= '/User';
|
|
$this->_model = new UserModel();
|
|
|
|
$this->_defines = [];
|
|
$this->_defines['insert'] = [];
|
|
$this->_defines['insert']['fields'] = ['id', 'passwd', 'confirmpassword', 'name', 'email', 'role', 'status'];
|
|
$this->_defines['insert']['fieldRules'] = $this->_model->getFieldRules($this->_defines['insert']['fields']);
|
|
$this->_defines['insert']['fieldFilters'] = $this->_model->getFieldFilters();
|
|
$this->_defines['update'] = [];
|
|
$this->_defines['update']['fields'] = ['passwd', 'confirmpassword', 'name', 'email', 'role', 'status'];
|
|
$this->_defines['update']['fieldRules'] = $this->_model->getFieldRules($this->_defines['update']['fields']);
|
|
$this->_defines['update']['fieldFilters'] = $this->_model->getFieldFilters();
|
|
$this->_defines['view'] = [];
|
|
$this->_defines['view']['fields'] = ['updated_at', 'created_at'];
|
|
$this->_defines['view']['fieldRules'] = $this->_model->getFieldRules($this->_defines['view']['fields']);
|
|
$this->_defines['view']['fieldFilters'] = $this->_model->getFieldFilters();
|
|
$this->_defines['index'] = [];
|
|
$this->_defines['index']['fields'] = [...$this->_model->getFields(), 'created_at'];
|
|
$this->_defines['index']['fieldFilters'] = $this->_model->getFieldFilters();
|
|
$this->_defines['index']['batchjobFilters'] = ['status'];
|
|
$this->_defines['excel'] = [];
|
|
$this->_defines['excel']['fields'] = $this->_defines['index']['fields'];
|
|
$this->_defines['excel']['fieldFilters'] = $this->_model->getFieldFilters();
|
|
|
|
helper($this->_className);
|
|
$this->_viewPath = strtolower($this->_className);
|
|
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
|
$this->_viewDatas['className'] = $this->_className;
|
|
}
|
|
|
|
//Field별 Form Datas 처리용
|
|
protected function getFieldFormData(string $field, $entity = null): array
|
|
{
|
|
switch ($field) {
|
|
case 'passwd':
|
|
$this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
|
|
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
|
break;
|
|
default:
|
|
return parent::getFieldFormData($field, $entity);
|
|
break;
|
|
}
|
|
return $this->_viewDatas['fieldDatas'];
|
|
}
|
|
|
|
////Action 모음
|
|
//Insert관련
|
|
final public function insert()
|
|
{
|
|
$this->_defines[__FUNCTION__]['fieldRules']['id'] .= '|is_unique[tw_user.id]';
|
|
return $this->insert_procedure();
|
|
}
|
|
//Update관련
|
|
final public function update($uid)
|
|
{
|
|
return $this->update_procedure($uid);
|
|
}
|
|
//Toggle관련
|
|
final public function toggle($uid, string $field)
|
|
{
|
|
return $this->toggle_procedure($uid, $field);
|
|
}
|
|
//Batchjob 관련
|
|
final public function batchjob()
|
|
{
|
|
return $this->batchjob_procedure();
|
|
}
|
|
//Delete 관련
|
|
final public function delete($uid)
|
|
{
|
|
return $this->delete_procedure($uid);
|
|
}
|
|
//View 관련
|
|
final public function view($uid)
|
|
{
|
|
return $this->view_procedure($uid);
|
|
}
|
|
//Index 관련
|
|
final public function index()
|
|
{
|
|
return $this->index_procedure();
|
|
}
|
|
//Excel 관련
|
|
final public function excel()
|
|
{
|
|
return $this->excel_procedure();
|
|
}
|
|
}
|