From 79985d0282df2f8436150ab325930c49ffa0e2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Thu, 3 Aug 2023 17:40:47 +0900 Subject: [PATCH] servermgrv2 init... --- app/Config/Constants.php | 11 +-- app/Config/Routes.php | 10 +-- app/Controllers/BaseController.php | 3 + app/Controllers/Front/BoardController.php | 63 ++++++++++++++++++ app/Filters/AuthFilter.php | 7 +- app/Helpers/BoardConfig_helper.php | 21 ++++-- app/Helpers/Board_helper.php | 8 +-- app/Helpers/Common_helper.php | 74 +++++++++++++++++++++ app/Helpers/UserSNS_helper.php | 10 +-- app/Helpers/User_helper.php | 16 ++--- app/Language/ko/Board.php | 2 +- app/Language/ko/BoardConfig.php | 20 ++++-- app/Language/ko/User.php | 8 ++- app/Models/BaseModel.php | 2 +- app/Models/BoardConfigModel.php | 20 +++++- app/Models/BoardModel.php | 2 +- app/Models/UserModel.php | 16 +++++ app/Views/front/board/index.php | 2 +- app/Views/layouts/admin/left_menu/board.php | 2 +- app/Views/templates/admin/header.php | 2 +- app/Views/templates/front/header.php | 2 +- 21 files changed, 241 insertions(+), 60 deletions(-) create mode 100644 app/Controllers/Front/BoardController.php diff --git a/app/Config/Constants.php b/app/Config/Constants.php index d3303f0..6ce8761 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -167,15 +167,6 @@ define('AUTH_ADAPTERS', [ 'TOKEN_NAME' => getenv('auth.google.client.token_name') ?: "access_token", ], ]); -//등급 관련 -define('FORM_OPTIONS', [ - 'ROLE' => [ - 'guest' => '비회원', 'user' => '일반회원', 'vip' => 'VIP회원', - 'bronze' => '일반판매자', 'silver' => '고급판매자', 'gold' => '파워리셀러', - 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터", - ], - 'STATUS' => ["use" => "사용", "unuse" => "사용않함",], -]); //Upload , Download 관련 define('PATHS', [ @@ -205,7 +196,7 @@ define('ICONS', [ define('CLASS_ICONS', [ 'USER' => '', 'USERSNS' => '', - 'BOARD_CONFIG' => '', + 'BOARDCONFIG' => '', 'BOARD' => '', 'CATEGORY' => '', 'PRODUCT' => '', diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1f05cb0..a47bd6c 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -39,14 +39,14 @@ $routes->get('/login', 'AuthController::login'); $routes->post('/signup', 'AuthController::signup/local'); $routes->get('/signup/(:alpha)', 'AuthController::signup/$1'); $routes->get('/logout', 'AuthController::logout'); -$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) { - $routes->post('addCart', 'CartController::addCart'); - $routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1'); +$routes->group('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) { + $routes->post('addCart', 'EcommerceController::addCart'); + $routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1'); });; $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) { }); // authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함 -$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:master,director,cloudflare,manager'], static function ($routes) { +$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) { $routes->get('/', 'Home::index'); $routes->group('user', static function ($routes) { $routes->get('', 'UserController::index'); @@ -93,7 +93,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2'); $routes->post('batchjob', 'BoardController::batchjob'); - $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); + $routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 4917950..e06d471 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -61,6 +61,9 @@ abstract class BaseController extends Controller $this->_session = \Config\Services::session(); $this->_viewDatas['layout'] = LAYOUTS['empty']; $this->_viewDatas['session'] = $this->_session; + $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); + $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_model->getClassName())]; + helper($this->_model->getClassName()); } abstract public function getFields(string $action): array; diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php new file mode 100644 index 0000000..4743f87 --- /dev/null +++ b/app/Controllers/Front/BoardController.php @@ -0,0 +1,63 @@ +_model = new BoardModel($this->getFields()); + parent::initController($request, $response, $logger); + $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); + $this->_viewPath .= strtolower($this->_model->getClassName()); + helper($this->_model->getClassName()); + } + + public function getFields(string $action = ""): array + { + $fields = ["board_config_uid", 'title', "board_file", "passwd", "content"]; + switch ($action) { + case "index": + case "excel": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at"]; + break; + case "view": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at", "content"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["board_config_uid", "user_uid"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } + //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; + case 'board_file': + $this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity); + break; + default: + return parent::getFieldFormData($field, $entity); + break; + } + return $this->_viewDatas['fieldDatas']; + } +} diff --git a/app/Filters/AuthFilter.php b/app/Filters/AuthFilter.php index 983b284..e76c6da 100644 --- a/app/Filters/AuthFilter.php +++ b/app/Filters/AuthFilter.php @@ -2,9 +2,9 @@ namespace App\Filters; +use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Filters\FilterInterface; class AuthFilter implements FilterInterface { @@ -28,9 +28,8 @@ class AuthFilter implements FilterInterface // 로그인을 했으면 if (session()->get(SESSION_NAMES['ISLOGIN'])) { $auth = session()->get(SESSION_NAMES['AUTH']); - // dd($auth); - // 회원 ROLE이 필요ROLE 목록에 존재하지 않으면(ACL) - if (!in_array($auth[AUTH_FIELDS['ROLE']], $arguments)) { + // 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL) + if (!in_array($arguments[0], explode(DEFAULTS['DELIMITER_ROLE'], $auth[AUTH_FIELDS['ROLE']]))) { return redirect()->to('/login')->with( 'return_message', sprintf( diff --git a/app/Helpers/BoardConfig_helper.php b/app/Helpers/BoardConfig_helper.php index 6b43c33..11b677d 100644 --- a/app/Helpers/BoardConfig_helper.php +++ b/app/Helpers/BoardConfig_helper.php @@ -23,16 +23,16 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions, case 'isupload': case 'isdownload': $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + // return form_multiselect($field, $fieldFormOptions[$field], $value, [...$attributes]); // foreach ($fieldFormOptions[$field] as $key => $label) { // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : explode(DEFAULTS['DELIMITER_ROLE'], $value)), $attributes) . $label; // } // return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -70,7 +70,7 @@ function getFieldView_BoardConfigHelper($field, $entity, array $fieldFilters, ar return anchor(current_url() . '/view/' . $entity->getPrimaryKey(), $value, [...$attributes, "target" => "_self"]); break; case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'updated_at': case 'created_at': @@ -90,6 +90,15 @@ function getFieldFilter_BoardConfigHelper($field, $value, array $fieldFormOption { $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { + case 'isaccess': + case 'isread': + case 'iswrite': + case 'isreply': + case 'isupload': + case 'isdownload': + $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + break; default: return getFieldForm_BoardConfigHelper($field, $value, $fieldFormOptions, $attributes); break; @@ -108,7 +117,7 @@ function getFieldIndex_Row_BoardConfigHelper($field, $entity, array $fieldFilter { switch ($field) { default: - return getFieldView_BoardConfigHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldView_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // @@ -121,7 +130,7 @@ function getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, array $field $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field); return getFieldForm_BoardConfigHelper($field, $entity->$field, $fieldFormOptions, $attributes); } - return getFieldIndex_Row_BoardConfigHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldIndex_Row_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // \ No newline at end of file diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php index c34a3e2..aa8e1ae 100644 --- a/app/Helpers/Board_helper.php +++ b/app/Helpers/Board_helper.php @@ -18,11 +18,11 @@ function getFieldForm_BoardHelper($field, $value, array $fieldFormOptions, array case "board_config_uid": case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Board.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Board.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -120,7 +120,7 @@ function getFieldIndex_Row_BoardHelper($field, $entity, array $fieldFilters, $fi { switch ($field) { default: - return getFieldView_BoardHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldView_BoardHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // @@ -133,7 +133,7 @@ function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $fieldFilter $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field); return getFieldForm_BoardHelper($field, $entity->$field, $fieldFormOptions, $attributes); } - return getFieldIndex_Row_BoardHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldIndex_Row_BoardHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // \ No newline at end of file diff --git a/app/Helpers/Common_helper.php b/app/Helpers/Common_helper.php index 7d9e746..a759c0f 100644 --- a/app/Helpers/Common_helper.php +++ b/app/Helpers/Common_helper.php @@ -152,3 +152,77 @@ function imageSubmit_CommonHelper(string $src, array $attributes = []) ...$attributes, ]); } + +// STATUS가 use가 아닐때 option을 disabled되게 하기위함 (override form_dropdown) +function form_dropdown_test($data = '', $options = [], $selected = [], $extra = ''): string +{ + $defaults = []; + if (is_array($data)) { + if (isset($data['selected'])) { + $selected = $data['selected']; + unset($data['selected']); // select tags don't have a selected attribute + } + if (isset($data['options'])) { + $options = $data['options']; + unset($data['options']); // select tags don't use an options attribute + } + } else { + $defaults = ['name' => $data]; + } + + if (!is_array($selected)) { + $selected = [$selected]; + } + if (!is_array($options)) { + $options = [$options]; + } + + // If no selected state was submitted we will attempt to set it automatically + if (empty($selected)) { + if (is_array($data)) { + if (isset($data['name'], $_POST[$data['name']])) { + $selected = [$_POST[$data['name']]]; + } + } elseif (isset($_POST[$data])) { + $selected = [$_POST[$data]]; + } + } + + // Standardize selected as strings, like the option keys will be + foreach ($selected as $key => $item) { + $selected[$key] = (string) $item; + } + + $extra = stringify_attributes($extra); + $multiple = (count($selected) > 1 && stripos($extra, 'multiple') === false) ? ' multiple="multiple"' : ''; + $form = '\n"; +} diff --git a/app/Helpers/UserSNS_helper.php b/app/Helpers/UserSNS_helper.php index 1b88279..5f35544 100644 --- a/app/Helpers/UserSNS_helper.php +++ b/app/Helpers/UserSNS_helper.php @@ -18,11 +18,11 @@ function getFieldForm_UserSNSHelper($field, $value, array $fieldFormOptions, arr switch ($field) { case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("UserSNS.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("UserSNS.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -56,7 +56,7 @@ function getFieldView_UserSNSHelper($field, $entity, array $fieldFilters, array return anchor(current_url() . '/view/' . $entity->getPrimaryKey(), $value, [...$attributes, "target" => "_self"]); break; case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'content': return html_entity_decode($value); @@ -93,7 +93,7 @@ function getFieldIndex_Row_UserSNSHelper($field, $entity, array $fieldFilters, $ { switch ($field) { default: - return getFieldView_UserSNSHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldView_UserSNSHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // @@ -106,7 +106,7 @@ function getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, array $fieldFilt $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field); return getFieldForm_UserSNSHelper($field, $entity->$field, $fieldFormOptions, $attributes); } - return getFieldIndex_Row_UserSNSHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldIndex_Row_UserSNSHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // \ No newline at end of file diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 62de186..2bfa7fd 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -18,16 +18,16 @@ function getFieldForm_UserHelper($field, $value, array $fieldFormOptions, array switch ($field) { case 'role': // $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - // return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + // return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + // return form_multiselect($field, $fieldFormOptions[$field], $value, [...$attributes]); foreach ($fieldFormOptions[$field] as $key => $label) { $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : explode(DEFAULTS['DELIMITER_ROLE'], $value)), $attributes) . $label; } return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -64,14 +64,14 @@ function getFieldView_UserHelper($field, $entity, array $fieldFilters, array $fi return anchor(current_url() . '/view/' . $entity->getPrimaryKey(), $value, [...$attributes, "target" => "_self"]); break; case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'updated_at': case 'created_at': return $value ? str_split($value, 10)[0] : ""; break; case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'content': return html_entity_decode($value); @@ -88,7 +88,7 @@ function getFieldFilter_UserHelper($field, $value, array $fieldFormOptions, arra switch ($field) { case 'role': $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; default: return getFieldForm_UserHelper($field, $value, $fieldFormOptions, $attributes); @@ -108,7 +108,7 @@ function getFieldIndex_Row_UserHelper($field, $entity, array $fieldFilters, $fie { switch ($field) { default: - return getFieldView_UserHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldView_UserHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // @@ -121,7 +121,7 @@ function getFieldIndex_Row_UserHelper_Admin($field, $entity, array $fieldFilters $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field); return getFieldForm_UserHelper($field, $entity->$field, $fieldFormOptions, $attributes); } - return getFieldIndex_Row_UserHelper($field, $entity, $fieldFormOptions, $attributes); + return getFieldIndex_Row_UserHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes); break; } } // \ No newline at end of file diff --git a/app/Language/ko/Board.php b/app/Language/ko/Board.php index a08d63d..1f82e4c 100644 --- a/app/Language/ko/Board.php +++ b/app/Language/ko/Board.php @@ -18,5 +18,5 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일" ], - "STATUS" => FORM_OPTIONS['STATUS'], + 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'], ]; diff --git a/app/Language/ko/BoardConfig.php b/app/Language/ko/BoardConfig.php index 6d49c20..f7fad60 100644 --- a/app/Language/ko/BoardConfig.php +++ b/app/Language/ko/BoardConfig.php @@ -1,4 +1,9 @@ '일반회원', 'vip' => 'VIP회원', + 'bronze' => '일반판매자', 'silver' => '고급판매자', 'gold' => '파워리셀러', + 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터", +]; return [ 'title' => "게시판설정 정보", 'label' => [ @@ -16,11 +21,12 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일" ], - "ISACCESS" => FORM_OPTIONS['ROLE'], - "ISREAD" => FORM_OPTIONS['ROLE'], - "ISWRITE" => FORM_OPTIONS['ROLE'], - "ISREPLY" => FORM_OPTIONS['ROLE'], - "ISUPLOAD" => FORM_OPTIONS['ROLE'], - "ISDOWNLOAD" => FORM_OPTIONS['ROLE'], - "STATUS" => FORM_OPTIONS['STATUS'], + "ISACCESS" => $roles, + "ISREAD" => $roles, + "ISWRITE" => $roles, + "ISREPLY" => $roles, + "ISUPLOAD" => $roles, + "ISDOWNLOAD" => $roles, + "STATUS" => $roles, + 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'], ]; diff --git a/app/Language/ko/User.php b/app/Language/ko/User.php index c54c9ba..857209b 100644 --- a/app/Language/ko/User.php +++ b/app/Language/ko/User.php @@ -13,6 +13,10 @@ return [ 'updated_at' => '수정일', 'created_at' => '작성일' ], - 'ROLE' => FORM_OPTIONS['ROLE'], - 'STATUS' => FORM_OPTIONS['STATUS'], + 'ROLE' => [ + 'user' => '일반회원', 'vip' => 'VIP회원', + 'bronze' => '일반판매자', 'silver' => '고급판매자', 'gold' => '파워리셀러', + 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터", + ], + 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'], ]; diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 64051aa..3ca3e65 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -142,7 +142,7 @@ abstract class BaseModel extends Model switch ($field) { case 'user_uid': if (is_null($this->_user_options)) { - $userModel = new UserModel([$this->getPrimaryKey(), $this->getTitleField()]); + $userModel = new UserModel(); $this->_user_options = $userModel->getOptions(); } $options = $this->_user_options; diff --git a/app/Models/BoardConfigModel.php b/app/Models/BoardConfigModel.php index ddbda28..c5f146a 100644 --- a/app/Models/BoardConfigModel.php +++ b/app/Models/BoardConfigModel.php @@ -42,6 +42,7 @@ class BoardConfigModel extends BaseModel case "isdownload": //아래 Rule은 입력시에는 되는데 수정시에는 않됨 이유를 ? // $rules[$field] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user,guest]"; + //아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음 $rules[$field] = "required"; break; default: @@ -50,11 +51,21 @@ class BoardConfigModel extends BaseModel } return $rules; } - public function getEntity($conditions): BoardConfigEntity + //Form 선택용 Options Data용 + public function getOptions_TEST(array $conditions = array(), $options = array()): array { - return parent::getEntity($conditions); + foreach ($this->getEntitys($conditions) as $entity) { + // STATUS가 use가 아닐때 option을 disabled되게 하기위함 + if ($entity->getStatus() != DEFAULTS['STATUS']) { + $options[$entity->getPrimaryKey() . "\" disabled=\"disabled"] = $entity->getTitle(); + } else { + $options[$entity->getPrimaryKey()] = $entity->getTitle(); + } + } + return $options; } + //Field별 Form Option용 protected function changeFormData(string $action, string $field, array $formDatas, $entity) { switch ($field) { @@ -81,6 +92,11 @@ class BoardConfigModel extends BaseModel } return $entity; } + + public function getEntity($conditions): BoardConfigEntity + { + return parent::getEntity($conditions); + } public function create(array $formDatas): BoardConfigEntity { return $this->create_process(new BoardConfigEntity(), $formDatas); diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index de21620..4238360 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -56,7 +56,7 @@ class BoardModel extends BaseHierarchyModel switch ($field) { case 'board_config_uid': if (is_null($this->_boardconfig_options)) { - $boardConfigModel = new BoardConfigModel([$this->getPrimaryKey(), $this->getTitleField()]); + $boardConfigModel = new BoardConfigModel(); $this->_boardconfig_options = $boardConfigModel->getOptions(); } $options = $this->_boardconfig_options; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 9b98489..0793a37 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -45,6 +45,7 @@ class UserModel extends BaseModel case "role": //아래 Rule은 입력시에는 되는데 수정시에는 않됨 이유를 ? // $rules[$field] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user]"; + //아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음 $rules[$field] = "required"; break; default: @@ -53,10 +54,25 @@ class UserModel extends BaseModel } return $rules; } + //Form 선택용 Options Data용 + public function getOptions_TEST(array $conditions = array(), $options = array()): array + { + foreach ($this->getEntitys($conditions) as $entity) { + // STATUS가 use가 아닐때 option을 disabled되게 하기위함 + if ($entity->getStatus() != DEFAULTS['STATUS']) { + $options[$entity->getPrimaryKey() . "\" disabled=\"disabled"] = $entity->getTitle(); + } else { + $options[$entity->getPrimaryKey()] = $entity->getTitle(); + } + } + return $options; + } + public function getEntity($conditions): UserEntity { return parent::getEntity($conditions); } + protected function changeFormData(string $action, string $field, array $formDatas, $entity) { switch ($field) { diff --git a/app/Views/front/board/index.php b/app/Views/front/board/index.php index 5637821..be236f7 100644 --- a/app/Views/front/board/index.php +++ b/app/Views/front/board/index.php @@ -25,7 +25,7 @@ - + diff --git a/app/Views/layouts/admin/left_menu/board.php b/app/Views/layouts/admin/left_menu/board.php index 2ad1fda..59867bb 100644 --- a/app/Views/layouts/admin/left_menu/board.php +++ b/app/Views/layouts/admin/left_menu/board.php @@ -4,7 +4,7 @@

게시글 관리

diff --git a/app/Views/templates/admin/header.php b/app/Views/templates/admin/header.php index edb803d..a74b247 100644 --- a/app/Views/templates/admin/header.php +++ b/app/Views/templates/admin/header.php @@ -1,3 +1,3 @@
-

+

\ No newline at end of file diff --git a/app/Views/templates/front/header.php b/app/Views/templates/front/header.php index edb803d..a74b247 100644 --- a/app/Views/templates/front/header.php +++ b/app/Views/templates/front/header.php @@ -1,3 +1,3 @@
-

+

\ No newline at end of file