diff --git a/app/Controllers/Admin/Cloudflare/AccountController.php b/app/Controllers/Admin/Cloudflare/AccountController.php index f3e9664..e546b8e 100644 --- a/app/Controllers/Admin/Cloudflare/AccountController.php +++ b/app/Controllers/Admin/Cloudflare/AccountController.php @@ -61,7 +61,7 @@ class AccountController extends CloudflareController $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); - $this->batchjob_fields = ['type', 'status']; + $this->batchjob_fields = []; return $this->list_procedure(); } // Download diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index e109900..2e90b03 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -71,7 +71,7 @@ class UserController extends AdminController private function init(string $action): void { $this->action = $action; - $this->fields = ['id', 'passwd', $this->getModel()::TITLE, 'email', 'mobile', 'role']; + $this->fields = ['id', 'passwd', 'confirmpassword', $this->getModel()::TITLE, 'email', 'mobile', 'role']; $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = ['role', 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); diff --git a/app/Helpers/Cloudflare/AccountHelper.php b/app/Helpers/Cloudflare/AccountHelper.php index cb66d86..5476603 100644 --- a/app/Helpers/Cloudflare/AccountHelper.php +++ b/app/Helpers/Cloudflare/AccountHelper.php @@ -88,6 +88,10 @@ class AccountHelper extends CommonHelper ] ) . " {$value}"; break; + case 'type': + case 'status': + $value = $viewDatas['field_options'][$field][$value]; + break; default: $value = parent::getFieldView($field, $viewDatas, $extras); break; @@ -106,6 +110,9 @@ class AccountHelper extends CommonHelper case 'delete': $action = ""; break; + case 'batchjob': + $action = ""; + break; } return $action; } diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index d41ab3a..68462ba 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -266,7 +266,7 @@ abstract class CommonHelper "name" => "batchjob_uids[]", "value" => $pk, "class" => "batchjobuids_checkboxs", - "checked" => in_array($pk, old("batchjob_uids", [])) + "checked" => in_array($pk, old("batchjob_uids[]", [])) ]); $action = $checkbox . $this->getListButtonLink( current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(), @@ -283,6 +283,12 @@ abstract class CommonHelper $extras ); break; + case 'batchjob': + $action = form_submit("batchjob_submit", '일괄처리', [ + "class" => "btn btn-outline btn-warning", + "onclick" => "return submitBatchJob()" + ]); + break; } return $action; } diff --git a/app/Models/Cloudflare/ZoneModel.php b/app/Models/Cloudflare/ZoneModel.php index c84dfe9..c510ed8 100644 --- a/app/Models/Cloudflare/ZoneModel.php +++ b/app/Models/Cloudflare/ZoneModel.php @@ -2,9 +2,9 @@ namespace App\Models\Cloudflare; -use App\Models\CommonModel; -use App\Entities\Cloudflare\ZoneEntity; use App\Entities\Cloudflare\AccountEntity; +use App\Entities\Cloudflare\ZoneEntity; +use App\Models\CommonModel; class ZoneModel extends CommonModel { @@ -103,7 +103,9 @@ class ZoneModel extends CommonModel //List 검색용 public function setList_WordFilter(string $word, $field = null): void { - //Join을 해서 Record의 content(IP검색)을 하기위함 + //Record의 content(IP검색)을 하기위함 + //Join 방식사용 + $this->select(self::TABLE . '.*')->distinct(); $this->join(RecordModel::TABLE, sprintf( "%s.%s=%s.%s", self::TABLE, @@ -113,8 +115,12 @@ class ZoneModel extends CommonModel )); parent::setList_WordFilter($word, $field); $this->orLike(RecordModel::TABLE . '.content', $word, 'both'); - // $subquery = $this->db->table(RecordModel::TABLE)->select(RecordModel::PARENT)->like('content', $word, 'both'); - // $this->orWhereIn(self::PK, $subquery); + //Subquery 방식사용 + // $recordModel = new RecordModel(); + // $recordModel->like(RecordModel::TABLE . '.content', $word, 'both'); + // $zone_uids = $recordModel->select(RecordModel::PARENT)->findAll(); + // $zone_uids = array_column($zone_uids, RecordModel::PARENT); + // $this->orWhereIn(self::TABLE . '.' . self::PK, array_values($zone_uids)); } public function setList_OrderBy(string $order = ""): void { diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index b977f5b..4fc2ea1 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -80,15 +80,6 @@ abstract class CommonModel extends Model case $this->getTitleField(): $rule = "required|string"; break; - case "passwd": - $rule = $action == "create" ? "required" : "if_exist" . "|trim|string"; - break; - case "confirmpassword": - $rule = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]"; - break; - case "email": - $rule = "if_exist|trim|valid_email"; - break; case 'image': $rule = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; @@ -135,7 +126,7 @@ abstract class CommonModel extends Model return $this->asObject($this->returnType)->findAll(); } //create , modify 직전 작업용 작업 - final protected function convertEntityData(string $field, array $formDatas): mixed + protected function convertEntityData(string $field, array $formDatas): mixed { switch ($field) { case $this->getPKField(): @@ -154,13 +145,7 @@ abstract class CommonModel extends Model $value = $formDatas[$field]; } break; - case "passwd": - $value = password_hash($formDatas[$field], PASSWORD_DEFAULT); - break; - case "confirmpassword": - $value = password_hash($formDatas[$field], PASSWORD_DEFAULT); - break; - case "content": + case "editor": //content등 textarea를 사용한 Field $value = htmlentities($formDatas[$field], ENT_QUOTES); break; default: @@ -192,7 +177,7 @@ abstract class CommonModel extends Model { //Field에 맞는 Validation Rule 재정의 $this->setValidationRules($this->getFieldRules('create', $this->allowedFields)); - //저장하기 전에 데이터 값 변경이 필요한 Field + //저장하기 전에 데이터 값 변경이 필요한 Field foreach (array_keys($formDatas) as $field) { $entity->$field = $this->convertEntityData($field, $formDatas); } @@ -209,7 +194,7 @@ abstract class CommonModel extends Model { //Field에 맞는 Validation Rule 재정의 $this->setValidationRules($this->getFieldRules('modify', $this->allowedFields)); - //저장하기 전에 데이터 값 변경이 필요한 Field + //저장하기 전에 데이터 값 변경이 필요한 Field foreach (array_keys($formDatas) as $field) { $entity->$field = $this->convertEntityData($field, $formDatas); } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 65f84a2..de31937 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -40,19 +40,39 @@ class UserModel extends CommonModel $rule = "required|trim|min_length[4]|max_length[20]"; $rule .= $action == "create" ? "|is_unique[{$this->table}.{$field}]" : ""; break; + case "passwd": + $rule = "required|trim|string"; + break; + case "confirmpassword": + $rule = "required|trim|string|matches[passwd]"; + break; case "email": - $rule = "if_exist|trim|valid_email"; + $rule = "required|trim|valid_email"; break; case "role": $rule = "required|trim|string"; break; - case "passwd": default: $rule = parent::getFieldRule($action, $field); break; } return $rule; } + protected function convertEntityData(string $field, array $formDatas): mixed + { + switch ($field) { + case "passwd": + $value = password_hash($formDatas[$field], PASSWORD_DEFAULT); + break; + case "confirmpassword": + $value = password_hash($formDatas[$field], PASSWORD_DEFAULT); + break; + default: + $value = parent::convertEntityData($field, $formDatas); + break; + } + return $value; + } public function getEntityByPK(string $uid): null|UserEntity { diff --git a/app/Views/admin/create.php b/app/Views/admin/create.php index 508b096..66c39bf 100644 --- a/app/Views/admin/create.php +++ b/app/Views/admin/create.php @@ -1,24 +1,26 @@ extend("layouts/{$viewDatas['layout']}/{$viewDatas['action_form']}") ?> section('content') ?> - + - - - +
+
+ + + + + + + + - - - - - - - -
getFieldLabel($field, $viewDatas) ?> + getFieldForm($field, old($field), $viewDatas) ?> +
+
getFieldLabel($field, $viewDatas) ?> - getFieldForm($field, old($field), $viewDatas) ?> -
+
+ "btn btn-outline btn-primary")); ?>
- "btn btn-outline btn-primary")); ?> -
- + + + endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index c044508..6a153c9 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -1,7 +1,7 @@ extend("layouts/{$viewDatas['layout']}") ?> section('content') ?> - + "get")) ?>