vhost init...2

This commit is contained in:
최준흠 2024-05-07 19:39:52 +09:00
parent d7c3c48c11
commit ce8c0bf720
4 changed files with 26 additions and 18 deletions

View File

@ -47,6 +47,8 @@ class BoardController extends FrontController
//Insert관련
protected function insert_form_process()
{
//Category 확인
$this->checkCategory();
//권한체크
$this->isRole('isaccess');
parent::insert_form_process();
@ -60,6 +62,8 @@ class BoardController extends FrontController
//Update관련
protected function update_form_process($entity)
{
//Category 확인
$this->checkCategory();
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 수정을 시도방지용
if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid != $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
@ -77,6 +81,8 @@ class BoardController extends FrontController
//Reply관련($entity는 부모의것임을 주의)
protected function reply_form_process($entity)
{
//Category 확인
$this->checkCategory();
//권한체크
$this->isRole('isreply');
return parent::reply_form_process($entity);
@ -93,6 +99,8 @@ class BoardController extends FrontController
//View관련
protected function view_process($entity)
{
//Category 확인
$this->checkCategory();
//권한체크
$this->isRole('view');
//조회수 올리기
@ -102,6 +110,8 @@ class BoardController extends FrontController
//Index관련
protected function index_process()
{
//Category 확인
$this->checkCategory();
//권한체크
$this->isRole('index');
parent::index_process();
@ -109,7 +119,7 @@ class BoardController extends FrontController
//Category 및 Status 조건추가
protected function index_setCondition()
{
$this->_model->where("category_uid", $this->getCurrentCategory()->getPrimaryKey());
$this->_model->where("category_uid", $this->_viewDatas['currentCategory']->getPrimaryKey());
$this->_model->where("status", DEFAULTS['STATUS']);
parent::index_setCondition();
}

View File

@ -3,7 +3,6 @@
namespace App\Controllers\Front;
use App\Controllers\BaseController;
use App\Entities\CategoryEntity;
use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@ -12,7 +11,6 @@ use Psr\Log\LoggerInterface;
abstract class FrontController extends BaseController
{
private $_categoryModel = null;
private $_currentCategory = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -22,24 +20,12 @@ abstract class FrontController extends BaseController
$this->_viewDatas['title'] = '사용자화면';
$this->_viewDatas['class_icon'] = '';
$this->_viewDatas['menus'] = $this->getCategoryModel()->getMenus();
$this->_viewDatas['category'] = false;
}
final protected function getCategoryModel(): CategoryModel
{
return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel();
}
final protected function getCurrentCategory(): CategoryEntity
{
if ($this->_currentCategory === null) {
$this->_viewDatas['category'] = $this->request->getVar('category');
$this->_viewDatas['category'] ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
$this->_currentCategory = $this->_viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']]);
//$this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]);
}
return $this->_currentCategory;
}
//권한체크
protected function isRole($action)
{
@ -66,7 +52,7 @@ abstract class FrontController extends BaseController
//사용자가 Category에서 해당 게시판의 해당권한이 있는지 확인
if (!isRole_CommonHelper(
$this->_viewDatas['currentRoles'],
$this->getCurrentCategory(),
$this->_viewDatas['currentCategory'],
$category_field,
)) {
// echo var_export($this->_viewDatas['currentRoles'], true);
@ -78,4 +64,14 @@ abstract class FrontController extends BaseController
throw new \Exception("고객님은 " . lang("Category.label." . $category_field) . "이 없습니다.");
}
}
final protected function checkCategory()
{
//Category 확인
$this->_viewDatas['category'] = $this->request->getVar('category');
if (!$this->_viewDatas['category']) {
throw new \Exception("분류코드가 지정되지 않았습니다.");
}
$this->_viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']]);
}
}

View File

@ -47,6 +47,8 @@ class SitepageController extends FrontController
//Index관련
protected function index_process()
{
//Category 확인
$this->checkCategory();
//권한체크
$this->isRole('index');
return parent::index_process();
@ -54,7 +56,7 @@ class SitepageController extends FrontController
//Category 및 Status 조건추가
protected function index_setCondition()
{
$this->_model->where("category_uid", $this->getCurrentCategory()->getPrimaryKey());
$this->_model->where("category_uid", $this->_viewDatas['currentCategory']->getPrimaryKey());
$this->_model->where("status", DEFAULTS['STATUS']);
parent::index_setCondition();
}

View File

@ -4,7 +4,7 @@
<?= ICONS['LOGIN'] ?><?= $viewDatas['session']->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['TITLE']] ?>
</a>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="/front/user/update/<?= $viewDatas['session']->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']] . '?category=12' ?>"><?= ICONS['SETUP'] ?>수정</a></li>
<li><a class="dropdown-item" href="/front/user/update/<?= $viewDatas['session']->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']] . '?category=userinfo' ?>"><?= ICONS['SETUP'] ?>수정</a></li>
<li>
<hr class="dropdown-divider">
</li>