cfmgrv4 init...2

This commit is contained in:
최준흠 2024-10-14 12:49:43 +09:00
parent 98dce63599
commit bceadee030
4 changed files with 20 additions and 26 deletions

View File

@ -332,15 +332,11 @@ abstract class MVController extends CommonController
//Sorting 처리 //Sorting 처리
$this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY']; $this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY'];
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY']; $this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
$this->getModel()->setList_OrderBy( if ($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY']) {
$this->order_field !== DEFAULTS['EMPTY'] && $this->getModel()->setList_OrderBy("{$this->order_field} {$this->order_value}");
$this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : "" }
);
if ($this->page) { if ($this->page) {
$this->getModel()->limit( $this->getModel()->limit($this->per_page, $this->page * $this->per_page - $this->per_page);
$this->per_page,
$this->page * $this->per_page - $this->per_page
);
} }
$entitys = $this->getModel()->select($this->getModel()->getTable() . '.*')->findAll(); $entitys = $this->getModel()->select($this->getModel()->getTable() . '.*')->findAll();
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
@ -359,7 +355,7 @@ abstract class MVController extends CommonController
//모델 처리 //모델 처리
$this->entitys = $this->list_entitys_process(); $this->entitys = $this->list_entitys_process();
// 현재 URL을 스택에 저장 // 현재 URL을 스택에 저장
$this->myauth->pushCurrentUrl(current_url() . $this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""); $this->myauth->pushCurrentUrl($this->request->getUri()->getPath());
return view( return view(
$this->view_path . "index", $this->view_path . "index",
['viewDatas' => $this->getViewDatas()] ['viewDatas' => $this->getViewDatas()]

View File

@ -30,14 +30,12 @@ class AuthFilter implements FilterInterface
// log_message("debug", var_export($arguments, true)); // log_message("debug", var_export($arguments, true));
// 로그인 않했으면 // 로그인 않했으면
if (!$auth->isLoggedIn()) { if (!$auth->isLoggedIn()) {
$currentURL = current_url(); $auth->pushCurrentUrl($request->getUri()->getPath());
$queryString = $request->getUri()->getQuery();
$auth->pushCurrentUrl($queryString ? "{$currentURL}?{$queryString}" : $currentURL);
return redirect()->to(URLS['LOGIN'])->with('error', '로그인을하셔야합니다.'); return redirect()->to(URLS['LOGIN'])->with('error', '로그인을하셔야합니다.');
} }
//User Role 비교 // 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL) //User Role 비교 // 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL)
if (!$auth->isAccessRole($arguments[0])) { if (!$auth->isAccessRole($arguments[0])) {
$auth->popPreviousUrl(); // dd($auth->popPreviousUrl());
return redirect()->back()->with( return redirect()->back()->with(
'error', 'error',
"회원[{$auth->getAuthInfo('name')}]님은 접속에 필요한 권한{$arguments[0]}이 없습니다. " "회원[{$auth->getAuthInfo('name')}]님은 접속에 필요한 권한{$arguments[0]}이 없습니다. "

View File

@ -4,9 +4,7 @@ namespace App\Helpers;
abstract class CommonHelper abstract class CommonHelper
{ {
protected function __construct() protected function __construct() {}
{
}
final public function getRandomString($length = 10, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") final public function getRandomString($length = 10, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
{ {
return substr(str_shuffle($characters), 0, $length); return substr(str_shuffle($characters), 0, $length);
@ -208,9 +206,11 @@ abstract class CommonHelper
if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) { if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"]; $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
} }
$viewDatas['uri']->addQuery('order_field', $field); $query = $viewDatas['uri']->getQuery(['except' => ['order_field', 'order_value']]);
$viewDatas['uri']->addQuery('order_value', $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC"); $query .= empty($query) ? "?" : "&";
$label = anchor(current_url() . ($viewDatas['uri']->getQuery() ? "?" . $viewDatas['uri']->getQuery() : ""), $label); $query .= "order_field={$field}&order_value=";
$query .= isset($viewDatas['order_value']) && $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
$label = anchor(current_url() . $query, $label);
break; break;
} }
return $label; return $label;

View File

@ -4,6 +4,7 @@ namespace App\Libraries\MyAuth;
use App\Entities\UserEntity; use App\Entities\UserEntity;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\Session\Session; use CodeIgniter\Session\Session;
// 참고:https://github.com/SyntaxPhoenix/iloclient // 참고:https://github.com/SyntaxPhoenix/iloclient
class MyAuth extends CommonLibrary class MyAuth extends CommonLibrary
@ -43,16 +44,15 @@ class MyAuth extends CommonLibrary
final public function pushCurrentUrl(string $url): void final public function pushCurrentUrl(string $url): void
{ {
$urlStack = $this->getSession()->get('url_stack') ?? []; $this->getSession()->set('url_stack', $url);
$urlStack[] = $url;
$this->getSession()->set('url_stack', $urlStack);
} }
final public function popPreviousUrl() final public function popPreviousUrl(): string
{ {
$urlStack = $this->getSession()->get('url_stack') ?? []; $url = $this->getSession()->get('url_stack') ?? "";
if (!empty($urlStack)) { if (!empty($url)) {
return array_pop($urlStack); $this->pushCurrentUrl("");
return $url;
} }
return '/'; // 기본 URL return '/'; // 기본 URL
} }