92 lines
2.9 KiB
PHP
92 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Front;
|
|
|
|
use App\Models\UserModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class UserController extends FrontController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->_model = new UserModel();
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewPath .= strtolower($this->_model->getClassName());
|
|
}
|
|
|
|
//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'];
|
|
}
|
|
|
|
public function getFields(string $action = ""): array
|
|
{
|
|
$fields = ["id", "passwd", 'name', "email", "phone", "mobile",];
|
|
switch ($action) {
|
|
case "index":
|
|
case "excel":
|
|
return ["id", 'name', "email", "phone", "mobile", 'created_at'];
|
|
break;
|
|
case "view":
|
|
return ["id", 'name', "email", "phone", "mobile", 'updated_at', 'created_at'];
|
|
break;
|
|
default:
|
|
return $fields;
|
|
break;
|
|
}
|
|
}
|
|
public function getFieldFilters(): array
|
|
{
|
|
return [];
|
|
}
|
|
public function getFieldBatchFilters(): array
|
|
{
|
|
return parent::getFieldBatchFilters();
|
|
}
|
|
//권한체크
|
|
protected function isRole($action, $entity = null)
|
|
{
|
|
$this->_category = $this->request->getVar('category') ?: $entity->category_uid;
|
|
parent::isRole($action, $entity);
|
|
}
|
|
//Update관련
|
|
protected function update_form_process($entity)
|
|
{
|
|
//권한체크
|
|
$this->isRole('update');
|
|
$entity = parent::update_form_process($entity);
|
|
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
|
'category' => $this->_category
|
|
]];
|
|
return $entity;
|
|
}
|
|
//Index관련
|
|
protected function index_process()
|
|
{
|
|
//권한체크
|
|
$this->isRole('index');
|
|
parent::index_process();
|
|
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
|
'category' => $this->_category
|
|
]];
|
|
}
|
|
//사용자 UID 조건추가
|
|
protected function index_setCondition()
|
|
{
|
|
$this->_model->where("uid", $this->_viewDatas['auth'][AUTH_FIELDS['ID']]);
|
|
parent::index_setCondition();
|
|
}
|
|
}
|