diff --git a/.gitignore b/.gitignore index 213c049..7904fcf 100644 --- a/.gitignore +++ b/.gitignore @@ -133,4 +133,7 @@ nb-configuration.xml #mapurl 결과물 public/mapurl/index.html -public/uploads/* \ No newline at end of file + +#upload 파일 +public/uploads/* +public/upload_images/* \ No newline at end of file diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 99bf708..5101cd8 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -99,7 +99,7 @@ define('LAYOUTS', [ 'stylesheets' => [ '', '', - '', + '', ], 'javascripts' => [ '', @@ -115,7 +115,7 @@ define('LAYOUTS', [ '', '', '', - '', + '', ], 'javascripts' => [ '', @@ -135,7 +135,7 @@ define('LAYOUTS', [ '', '', '', - '', + '', ], 'javascripts' => [ '', @@ -161,7 +161,7 @@ define('CATEGORY_ROLE_FIELDS', [ 'WRITE' => 'iswrite', 'REPLY' => 'isreply', 'UPLOAD' => 'isupload', - 'DOWNLOAD' => 'isdownload', + 'DONWLOAD' => 'isdownload', ]); //인증 관련 @@ -183,7 +183,7 @@ define('AUTH_ADAPTERS', [ define('PATHS', [ 'EXCEL' => WRITEPATH . "excel/", 'UPLOAD' => WRITEPATH . "uploads/", - 'UPLOAD_PHOTO' => FCPATH . 'upload_images/', + 'UPLOAD_IMAGE' => FCPATH . 'upload_images/', 'DOWNLOAD' => WRITEPATH . "download/", 'API' => WRITEPATH . "api/", ]); diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 77bb67d..c2289ff 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -42,7 +42,7 @@ $routes->get('/logout', 'AuthController::logout'); $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'); @@ -53,16 +53,16 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->post('update/(:uuid)', 'UserController::update/$1'); $routes->get('view/(:uuid)', 'UserController::view/$1'); $routes->get('delete/(:uuid)', 'UserController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2'); - $routes->post('batchjob', 'UserController::batchjob'); + $routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']); + $routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']); }); $routes->group('usersns', static function ($routes) { $routes->get('', 'UserSNSController::index'); $routes->get('excel', 'UserSNSController::excel'); $routes->get('view/(:num)', 'UserSNSController::view/$1'); - $routes->get('delete/(:num)', 'UserSNSController::delete/$1'); - $routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2'); - $routes->post('batchjob', 'UserSNSController::batchjob'); + $routes->get('delete/(:num)', 'UserSNSController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2', ['filter' => 'authFilter:master']); + $routes->post('batchjob', 'UserSNSController::batchjob', ['filter' => 'authFilter:master']); }); $routes->group('category', static function ($routes) { $routes->get('', 'CategoryController::index'); @@ -95,7 +95,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { - $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static function ($routes) { + $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) { $routes->get('update/(:uuid)', 'UserController::update_form/$1'); $routes->post('update/(:uuid)', 'UserController::update/R1'); $routes->get('view/(:uuid)', 'UserController::view/$1'); @@ -110,7 +110,7 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('view/(:num)', 'BoardController::view/$1'); $routes->get('reply/(:num)', 'BoardController::reply_form/$1'); $routes->post('reply/(:num)', 'BoardController::reply/$1'); - $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('delete/(:num)', 'BoardController::delete/$1'); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); }); diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php index a3f1b89..86d5791 100644 --- a/app/Controllers/Admin/BoardController.php +++ b/app/Controllers/Admin/BoardController.php @@ -6,9 +6,11 @@ use App\Models\BoardModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Controllers\Trait\UpDownloadTrait; class BoardController extends AdminController { + use UpDownloadTrait; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { $this->_model = new BoardModel(); diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index e19a9cc..cd5d1aa 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -21,8 +21,12 @@ class UserController extends AdminController { switch ($field) { case 'passwd': - $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field); - $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword'); + $passwd = $this->request->getVar($field) ?: false; + $confirmpassword = $this->request->getVar('confirmpassword') ?: false; + if ($passwd && $confirmpassword) { + $this->_viewDatas['fieldDatas'][$field] = $passwd; + $this->_viewDatas['fieldDatas']['confirmpassword'] = $confirmpassword; + } break; default: return parent::getFieldFormData($field, $entity); @@ -62,6 +66,7 @@ class UserController extends AdminController foreach ($this->_viewDatas['fieldRules'] as $field => $rule) { switch ($field) { case 'role': + //checkbox형태로 들어오면 $fieldDatas['role']가 array이기때문에 $rules[$field . '.*'] = $rule; break; default: @@ -69,14 +74,6 @@ class UserController extends AdminController break; } } - //fieldData Rule 검사 - if (!$this->validate($rules)) { - throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors())); - } - //fieldData 적용 - $this->_viewDatas['fieldDatas'] = array(); - foreach ($this->_viewDatas['fields'] as $field) { - $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field); - } + parent::insert_validate(); } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 0695a87..198829e 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -5,7 +5,6 @@ namespace App\Controllers; use CodeIgniter\Controller; use CodeIgniter\HTTP\CLIRequest; -use CodeIgniter\HTTP\Files\UploadedFile; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -37,7 +36,7 @@ abstract class BaseController extends Controller * * @var array */ - protected $helpers = ['Common', 'Base']; + protected $helpers = ['Common']; /** * Be sure to declare properties for any property fetch you initialized. @@ -94,58 +93,6 @@ abstract class BaseController extends Controller return $this->_viewDatas['fieldDatas']; } - //Upload FIle관련 - private function upload_file_process(UploadedFile $upfile) - { - $fileName = null; - if ($upfile->isValid() && !$upfile->hasMoved()) { - $originName = $upfile->getName(); - $upfile->move(PATHS['UPLOAD'], $upfile->getRandomName()); - //move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요 - $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $upfile->getName(); - } - return $fileName; - } - private function upload_image_process(UploadedFile $upfile, $sizeX = 100, $sizeY = 100) - { - //참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/ - $fileName = null; - if ($upfile->isValid() && !$upfile->hasMoved()) { - $originName = $upfile->getName(); - $fileName = $upfile->getRandomName(); - $image = \Config\Services::image(); - $image->withFile($upfile) - ->resize($sizeX, $sizeY, true, 'height') - ->save(PATHS['UPLOAD_PHOTO'] . $fileName); - $upfile->move(PATHS['UPLOAD_PHOTO'], "original_" . $fileName); - $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $fileName; - } - return $fileName; - } - protected function upload_file_procedure(string $field) - { - return $this->upload_file_process($this->request->getFile($field)); - } - protected function upload_photo_procedure(string $field, $sizeX = 100, $sizeY = 100) - { - return $this->upload_image_process($this->request->getFile($field), $sizeX, $sizeY); - } - protected function upload_multiple_file_process(string $field): array - { - //Multiple파일의경우 html에서는 필드명[]를 넣어야하며 - //rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함 - $fileNames = array(); - if ($upfiles = $this->request->getFiles()) { - foreach ($upfiles[$field] as $upfile) { - if ($upfile->isValid() && !$upfile->hasMoved()) { - $fileName = $this->upload_file_process($upfile); - array_push($this->_viewDatas['fieldDatas'][$field], $fileName); - } - } - } - return $fileNames; - } - //초기화 final public function init(string $action, $fields = null) { @@ -259,10 +206,13 @@ abstract class BaseController extends Controller $this->_viewDatas['fieldDatas'] = array(); foreach ($this->_viewDatas['fields'] as $field) { $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity); - log_message( - "info", - "{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field]) - ); + //보안문제,사용자정보의 update시 암호를 변경하지 않느경우를 위해 + if ($field != 'passwd') { + log_message( + "info", + "{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field]) + ); + } } } protected function update_process($entity) @@ -635,11 +585,11 @@ abstract class BaseController extends Controller throw new \Exception("첨부파일이 확인되지 않습니다."); } $entity = $this->download_process($entity); - list($origin_filename, $filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); - if (is_file(WRITEPATH . PATHS['UPLOAD'] . "/" . $origin_filename)) { - throw new \Exception("파일이 확인되지 않습니다."); + list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); + if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) { + throw new \Exception("파일이 확인되지 않습니다.\n" . PATHS['UPLOAD'] . "/" . $uploaded_filename); } - return $this->response->download(WRITEPATH . PATHS['UPLOAD'] . "/" . $filename, null)->setFileName(date("YmdHms") . '_' . $origin_filename); + return $this->response->download(PATHS['UPLOAD'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename); } catch (\Exception $e) { return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage()); } diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index 4fb5895..a3b02e5 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -9,17 +9,15 @@ use Psr\Log\LoggerInterface; class BoardController extends FrontController { - public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { $this->_model = new BoardModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); } - public function getFields(string $action = ""): array { - $fields = ['title', "board_file", "passwd", "content"]; + $fields = ['title', "passwd", "content"]; switch ($action) { case "index": case "excel": @@ -49,9 +47,6 @@ class BoardController extends FrontController $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->upload_file_procedure($field); - break; default: return parent::getFieldFormData($field, $entity); break; @@ -136,7 +131,7 @@ class BoardController extends FrontController public function download_process($entity) { //권한체크 - $this->isRole('download'); - return $entity; + $this->isRole('download', $entity); + return parent::download_process($entity); } } diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index c4acb33..c39edc3 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -55,6 +55,12 @@ abstract class FrontController extends BaseController $this->_viewDatas['category'], $category_field, )) { + echo var_export($this->_viewDatas['currentRoles'], true); + echo "
"; + echo var_export($this->_viewDatas['category'], true); + echo "
"; + echo "field->", $action . ":" . $category_field; + exit; throw new \Exception("고객님은 " . lang($this->getCategoryModel()->getClassName() . ".label." . $category_field) . "이 없습니다."); } } diff --git a/app/Controllers/Trait/UpDownloadTrait.php b/app/Controllers/Trait/UpDownloadTrait.php new file mode 100644 index 0000000..982265d --- /dev/null +++ b/app/Controllers/Trait/UpDownloadTrait.php @@ -0,0 +1,85 @@ +isValid() && !$upfile->hasMoved()) { + $filename = $upfile->getName(); + $uploaded_filename = $upfile->getRandomName(); + $upfile->move(PATHS['UPLOAD'], $uploaded_filename); + //move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요 + $uploaded_filename = $upfile->getName(); + } + return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename; + } + public function upload_file_procedure(string $field): string + { + return $this->upload_file_process($this->request->getFile($field)); + } + public function upload_multiple_file_procedure(string $field): array + { + //Multiple파일의경우 html에서는 필드명[]를 넣어야하며 + //rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함 + $files = array(); + if ($upfiles = $this->request->getFiles()) { + foreach ($upfiles[$field] as $upfile) { + if ($upfile->isValid() && !$upfile->hasMoved()) { + array_push($files, $this->upload_file_process($upfile)); + } + } + } + return $files; + } + + private function image_resize_process(UploadedFile $upfile, $uploaded_filename, $x = 25, $y = 25) + { + $image = \Config\Services::image(); + $image->withFile($upfile) + ->resize($x, $y, true, 'height') + ->save(PATHS['UPLOAD_IMAGE'] . $uploaded_filename); + } + private function upload_image_process(UploadedFile $upfile): string + { + //참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/ + $filename = null; + $uploaded_filename = null; + if ($upfile->isValid() && !$upfile->hasMoved()) { + $filename = $upfile->getName(); + $uploaded_filename = $upfile->getRandomName(); + $this->image_resize_process($upfile, "small_" . $uploaded_filename); + $this->image_resize_process($upfile, "middle_" . $uploaded_filename, 50, 50); + $this->image_resize_process($upfile, "large_" . $uploaded_filename, 100, 100); + $upfile->move(PATHS['UPLOAD_IMAGE'], $uploaded_filename); + //move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요 + $uploaded_filename = $upfile->getName(); + } + return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename; + } + + public function upload_image_procedure(string $field): string + { + return $this->upload_image_process($this->request->getFile($field)); + } + public function upload_multiple_image_procedure(string $field): array + { + //Multiple파일의경우 html에서는 필드명[]를 넣어야하며 + //rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함 + $filenames = array(); + if ($upfiles = $this->request->getFiles()) { + foreach ($upfiles[$field] as $upfile) { + if ($upfile->isValid() && !$upfile->hasMoved()) { + array_push($files, $this->upload_image_process($upfile)); + } + } + } + return $filenames; + } +} diff --git a/app/Entities/BaseEntity.php b/app/Entities/BaseEntity.php index deab2a9..f3f4b05 100644 --- a/app/Entities/BaseEntity.php +++ b/app/Entities/BaseEntity.php @@ -8,5 +8,4 @@ abstract class BaseEntity extends Entity { abstract public function getPrimaryKey(); abstract public function getTitle(): string; - abstract public function getStatus(): string; } diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index 4dd4f26..a459f73 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -39,4 +39,12 @@ class BoardEntity extends BaseHierarchyEntity { return $this->attributes['view_cnt']; } + public function getBoardFile() + { + return $this->attributes['board_file']; + } + public function getBoardFileName() + { + return explode(DEFAULTS['DELIMITER_FILE'], $this->getBoardFile())[1]; + } } diff --git a/app/Entities/CategoryEntity.php b/app/Entities/CategoryEntity.php index 3941df8..8f92b43 100644 --- a/app/Entities/CategoryEntity.php +++ b/app/Entities/CategoryEntity.php @@ -2,6 +2,8 @@ namespace App\Entities; +use App\Entities\Trait\HierarchyTrait; + class CategoryEntity extends BaseHierarchyEntity { protected $datamap = []; diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php index 5e46a53..b0abf09 100644 --- a/app/Helpers/Board_helper.php +++ b/app/Helpers/Board_helper.php @@ -64,13 +64,14 @@ function getFieldView_BoardHelper($field, $entity, array $viewDatas) $value = $entity->$field ?: DEFAULTS['EMPTY']; switch ($field) { case 'category_uid': - $categorys = array(); - foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depth) { - foreach ($category_2depth as $key => $label) { - $categorys[$key] = $label; + foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depths) { + foreach ($category_2depths as $key => $label) { + if ($key == $value) { + return $label; + } } } - return $categorys[$value]; + return $value; break; case 'title': case 'name': diff --git a/app/Helpers/UserSNS_helper.php b/app/Helpers/UserSNS_helper.php index 5053ccb..9a45ba5 100644 --- a/app/Helpers/UserSNS_helper.php +++ b/app/Helpers/UserSNS_helper.php @@ -133,7 +133,7 @@ function getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, array $viewDatas $field, $field ); - return getFieldForm_UserSNSHelper($field, $entity->field, $viewDatas, $attributes); + return getFieldForm_UserSNSHelper($field, $entity->$field, $viewDatas, $attributes); } return getFieldView_UserSNSHelper($field, $entity, $viewDatas); break; diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 2771da9..0d62bff 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -21,7 +21,17 @@ function getFieldForm_UserHelper($field, $value, array $viewDatas, array $attrib // return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]); // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) { - $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label; + $checkboxs[] = form_checkbox( + "{$field}[]", + $key, + in_array( + $key, + is_array($value) ? $value : explode( + DEFAULTS["DELIMITER_ROLE"], + $value + ) + ) + ) . $label; } return implode(" ", $checkboxs); break; @@ -139,7 +149,7 @@ function getFieldIndex_Row_UserHelper_Admin($field, $entity, array $viewDatas): $field, $field ); - return getFieldForm_UserHelper($field, $entity->field, $viewDatas, $attributes); + return getFieldForm_UserHelper($field, $entity->$field, $viewDatas, $attributes); } return getFieldView_UserHelper($field, $entity, $viewDatas); break; diff --git a/app/Libraries/Adapter/Auth/LocalAdapter.php b/app/Libraries/Adapter/Auth/LocalAdapter.php index 6e8089e..a4d3f62 100644 --- a/app/Libraries/Adapter/Auth/LocalAdapter.php +++ b/app/Libraries/Adapter/Auth/LocalAdapter.php @@ -21,7 +21,7 @@ class LocalAdapter extends Adapter if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) { throw new \Exception("ID 나 암호의 값이 없습니다."); } - $entity = $this->getUserModel()->getEntity(['id' => $formDatas['id']]); + $entity = $this->getUserModel()->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]); if (!password_verify($formDatas['passwd'], $entity->passwd)) { throw new \Exception("암호가 맞지않습니다."); } diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 4983985..1a14ba6 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -67,7 +67,7 @@ abstract class BaseModel extends Model abstract public function getTitleField(): string; public function getEntity($conditions): BaseEntity { - return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다.\n" . var_export($conditions, true)); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function getEntitys(array $conditions = array()): array { @@ -94,9 +94,6 @@ abstract class BaseModel extends Model case "view_cnt": $rules[$field] = "if_exist|numeric"; break; - case "upload_file": //uploaded[{$field}] == requried와 같은의미 - $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},100]|max_dims[{$field},1024,768]"; - break; case "updated_at": case "created_at": case "deleted_at": @@ -194,7 +191,7 @@ abstract class BaseModel extends Model } break; case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가 - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { //관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용 $entity->$field = $formDatas[$field]; } elseif ($action == 'create' && $this->_session->get(SESSION_NAMES["ISLOGIN"])) { @@ -204,19 +201,17 @@ abstract class BaseModel extends Model } break; case "passwd": - // echo var_export($this->validationRules, true); - // exit; - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = password_hash($formDatas[$field], PASSWORD_DEFAULT); } break; case "content": - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = htmlentities($formDatas[$field]); } break; default: - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = $formDatas[$field]; } break; diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index cbf1cc6..a3164fb 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -39,7 +39,7 @@ class BoardModel extends BaseHierarchyModel $rules[$field] = "required|string"; break; case "board_file": //uploaded[{$field}] == requried와 같은의미 - $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},100]|max_dims[{$field},1024,768]"; + $rules[$field] = "if_exist|string"; break; case "view_cnt": $rules[$field] = "if_exist|numeric"; diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 4a715bf..50b7108 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -75,13 +75,13 @@ class CategoryModel extends BaseHierarchyModel case "isreply": case "isupload": case "isdownload": - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; } break; case "head": case "tail": - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = htmlentities($formDatas[$field]); } break; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index c41b5a5..9990dd1 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -31,9 +31,10 @@ class UserModel extends BaseModel $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; break; case "passwd": - $rules[$field] = "required|trim|string"; + $rules[$field] = "if_exist|trim|string"; if ($action != "") { - $rules["confirmpassword"] = "required|trim|string|matches[passwd]"; + $rules[$field] = $action == "insert" ? "required|trim|string" : "if_exist|trim|string"; + $rules["confirmpassword"] = $action == "insert" ? "required|trim|string|matches[passwd]" : "if_exist|trim|string|matches[passwd]"; } break; case $this->getTitleField(): @@ -54,20 +55,6 @@ 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); @@ -77,13 +64,13 @@ class UserModel extends BaseModel { switch ($field) { case "role": - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; } break; case "head": case "tail": - if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { + if (array_key_exists($field, $formDatas)) { $entity->$field = htmlentities($formDatas[$field]); } break; diff --git a/app/Views/admin/board/index.php b/app/Views/admin/board/index.php index 92f4da4..71fa1cc 100644 --- a/app/Views/admin/board/index.php +++ b/app/Views/admin/board/index.php @@ -11,25 +11,29 @@ - - - - - - - - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - + + + + + - - + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + +
번호작업
- "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
번호작업
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
- endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/board/reply.php b/app/Views/admin/board/reply.php index 9f7367c..a1fd37c 100644 --- a/app/Views/admin/board/reply.php +++ b/app/Views/admin/board/reply.php @@ -16,6 +16,6 @@ "btn btn-outline btn-primary")); ?> + - endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/board/update.php b/app/Views/admin/board/update.php index 9f7367c..a1fd37c 100644 --- a/app/Views/admin/board/update.php +++ b/app/Views/admin/board/update.php @@ -16,6 +16,6 @@ "btn btn-outline btn-primary")); ?> + - endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/category/index.php b/app/Views/admin/category/index.php index cda9ce7..3e7174f 100644 --- a/app/Views/admin/category/index.php +++ b/app/Views/admin/category/index.php @@ -11,25 +11,29 @@ - - - - - - - - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - + + + + + - - + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + +
번호작업
- "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
번호작업
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
- endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/category/reply.php b/app/Views/admin/category/reply.php index 0a4f0fd..fa34d5a 100644 --- a/app/Views/admin/category/reply.php +++ b/app/Views/admin/category/reply.php @@ -16,6 +16,6 @@ "btn btn-outline btn-primary")); ?> + - endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/category/update.php b/app/Views/admin/category/update.php index 0a4f0fd..fa34d5a 100644 --- a/app/Views/admin/category/update.php +++ b/app/Views/admin/category/update.php @@ -16,6 +16,6 @@ "btn btn-outline btn-primary")); ?> + - endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/user/index.php b/app/Views/admin/user/index.php index 3b0b431..08f0d4a 100644 --- a/app/Views/admin/user/index.php +++ b/app/Views/admin/user/index.php @@ -11,25 +11,29 @@ - - - - - - - - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - + + + + + - - + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + +
번호작업
- "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
번호작업
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
- endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/user/update.php b/app/Views/admin/user/update.php index 62b90d4..8ae37e6 100644 --- a/app/Views/admin/user/update.php +++ b/app/Views/admin/user/update.php @@ -16,6 +16,6 @@ "btn btn-outline btn-primary")); ?> + - endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/usersns/index.php b/app/Views/admin/usersns/index.php index 5f5d99d..e5b096e 100644 --- a/app/Views/admin/usersns/index.php +++ b/app/Views/admin/usersns/index.php @@ -11,25 +11,29 @@ - - - - - - - - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - + + + + + - - + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + +
번호작업
- "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
번호작업
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
- - - - - - - - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - + + + + + - - + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + +
번호작업
- - getUser_Uid() == $viewDatas['auth'][AUTH_FIELDS['ID']]) : ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - - - - - - getUser_Uid() == $viewDatas['auth'][AUTH_FIELDS['ID']]) : ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> - -
번호작업
+ + getUser_Uid() == $viewDatas['auth'][AUTH_FIELDS['ID']]) : ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + + + + + + getUser_Uid() == $viewDatas['auth'][AUTH_FIELDS['ID']]) : ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> + +