You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

592 lines
25 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Board extends WB_Controller
  4. {
  5. /**
  6. * 게시판 목록
  7. */
  8. public function lists()
  9. {
  10. // 메타태그 설정
  11. $this->site->meta_title = "게시판 관리";
  12. // 레이아웃 & 뷰파일 설정
  13. $this->theme = "admin";
  14. $this->view = "board/lists";
  15. $this->active = "board/lists";
  16. }
  17. /**
  18. * 게시판 등록/수정
  19. * @param string $brd_key
  20. */
  21. public function form($brd_key="")
  22. {
  23. $this->load->model('board_model');
  24. $this->load->library('form_validation');
  25. $this->form_validation->set_rules('brd_key','게시판 고유 키',"required|trim|min_length[3]|max_length[20]". (empty($brd_key)?"|callback_brd_key_check":""));
  26. if( $this->form_validation->run() != FALSE )
  27. {
  28. $data['brd_key'] = $this->input->post('brd_key', TRUE);
  29. $data['brd_title'] = $this->input->post('brd_title', TRUE);
  30. $data['brd_title_m'] = $this->input->post('brd_title_m', TRUE);
  31. $data['brd_keywords'] = $this->input->post('brd_keywords', TRUE);
  32. $data['brd_description'] = $this->input->post('brd_description', TRUE);
  33. $data['brd_skin_l'] = $this->input->post('brd_skin_l', TRUE);
  34. $data['brd_skin_l_m'] = $this->input->post('brd_skin_l_m', TRUE);
  35. $data['brd_skin_w'] = $this->input->post('brd_skin_w', TRUE);
  36. $data['brd_skin_w_m'] = $this->input->post('brd_skin_w_m', TRUE);
  37. $data['brd_skin_v'] = $this->input->post('brd_skin_v', TRUE);
  38. $data['brd_skin_v_m'] = $this->input->post('brd_skin_v_m', TRUE);
  39. $data['brd_skin_c'] = $this->input->post('brd_skin_c', TRUE);
  40. $data['brd_skin_c_m'] = $this->input->post('brd_skin_c_m', TRUE);
  41. $data['brd_search'] = $this->input->post('brd_search', TRUE, "N");
  42. $data['brd_sort'] = $this->input->post('brd_sort', TRUE);
  43. $data['brd_use_category'] = $this->input->post('brd_use_category', TRUE, "N");
  44. $data['brd_lv_list'] = $this->input->post('brd_lv_list', TRUE);
  45. $data['brd_lv_read'] = $this->input->post('brd_lv_read', TRUE);
  46. $data['brd_lv_write'] = $this->input->post('brd_lv_write', TRUE);
  47. $data['brd_lv_reply'] = $this->input->post('brd_lv_reply', TRUE);
  48. $data['brd_lv_comment'] = $this->input->post('brd_lv_comment', TRUE);
  49. $data['brd_lv_download'] = $this->input->post('brd_lv_download', TRUE);
  50. $data['brd_lv_upload'] = $this->input->post('brd_lv_upload', TRUE);
  51. $data['brd_use_list_thumbnail'] = $this->input->post('brd_use_list_thumbnail', TRUE);
  52. $data['brd_use_list_file'] = $this->input->post('brd_use_list_file', TRUE);
  53. $data['brd_use_view_list'] = $this->input->post('brd_use_view_list', TRUE);
  54. $data['brd_thumb_width'] = $this->input->post('brd_thumb_width', TRUE);
  55. $data['brd_thumb_height'] = $this->input->post('brd_thumb_height', TRUE);
  56. $data['brd_time_new'] = $this->input->post('brd_time_new', TRUE);
  57. $data['brd_hit_count'] = $this->input->post('brd_hit_count', TRUE);
  58. $data['brd_page_limit'] = $this->input->post('brd_page_limit', TRUE);
  59. $data['brd_page_rows'] = $this->input->post('brd_page_rows', TRUE);
  60. $data['brd_page_rows_m'] = $this->input->post('brd_page_rows_m', TRUE);
  61. $data['brd_fixed_num'] = $this->input->post('brd_fixed_num', TRUE);
  62. $data['brd_fixed_num_m'] = $this->input->post('brd_fixed_num_m', TRUE);
  63. $data['brd_display_time'] = $this->input->post('brd_display_time', TRUE);
  64. $data['brd_use_anonymous'] = $this->input->post('brd_use_anonymous', TRUE);
  65. $data['brd_use_secret'] = $this->input->post('brd_use_secret', TRUE);
  66. $data['brd_use_reply'] = $this->input->post('brd_use_reply', TRUE);
  67. $data['brd_use_comment'] = $this->input->post('brd_use_comment', TRUE);
  68. $data['brd_use_wysiwyg'] = $this->input->post('brd_use_wysiwyg', TRUE);
  69. $data['brd_use_attach'] = $this->input->post('brd_use_attach', TRUE);
  70. $data['brd_use_assign'] = $this->input->post('brd_use_assign', TRUE, 'N') == 'Y' ? 'Y' : 'N';
  71. $data['brd_point_read'] = $this->input->post('brd_point_read', TRUE);
  72. $data['brd_point_write'] = $this->input->post('brd_point_write', TRUE);
  73. $data['brd_point_comment'] = $this->input->post('brd_point_comment', TRUE);
  74. $data['brd_point_download'] = $this->input->post('brd_point_download', TRUE);
  75. $data['brd_point_reply'] = $this->input->post('brd_point_reply', TRUE);
  76. $data['brd_use_total_rss'] = $this->input->post('brd_use_total_rss', TRUE);
  77. $data['brd_use_rss'] = $this->input->post('brd_use_rss', TRUE);
  78. $data['brd_use_sitemap'] = $this->input->post('brd_use_sitemap', TRUE);
  79. if(empty($brd_key))
  80. {
  81. $tmp = (int)$this->db->select_max('brd_sort',"max")->from('board')->get()->row(0)->max;
  82. $data['brd_sort'] = $tmp +1;
  83. $data['brd_count_post'] = 0;
  84. if( $this->db->insert('board', $data) )
  85. {
  86. alert('게시판 생성이 완료되었습니다.',base_url('/admin/board/lists'));
  87. exit;
  88. }
  89. }
  90. else
  91. {
  92. $this->db->where('brd_key', $brd_key);
  93. if( $this->db->update('board', $data) ) {
  94. $this->board_model->delete_cache($brd_key);
  95. alert('게시판 정보 수정이 완료되었습니다.',base_url('/admin/board/lists'));
  96. exit;
  97. }
  98. }
  99. alert('DB입력도중 오류가 발생하였습니다.');
  100. exit;
  101. }
  102. else
  103. {
  104. $this->data['view'] = (empty($brd_key)) ? array() : $this->board_model->get_board($brd_key, TRUE);
  105. $this->data['brd_key'] = $brd_key;
  106. $this->data['skin_list_l'] = get_skin_list('board/list');
  107. $this->data['skin_list_w'] = get_skin_list('board/write');
  108. $this->data['skin_list_v'] = get_skin_list('board/view');
  109. $this->data['skin_list_c'] = get_skin_list('board/comment');
  110. // 메타태그 설정
  111. $this->site->meta_title = "게시판 관리";
  112. // 레이아웃 & 뷰파일 설정
  113. $this->theme = "admin";
  114. $this->view = "board/form";
  115. $this->active = "board/lists";
  116. }
  117. }
  118. /**
  119. * 게시판 삭제
  120. */
  121. public function remove($brd_key)
  122. {
  123. if(empty($brd_key))
  124. {
  125. alert('잘못된 접근입니다.');
  126. exit;
  127. }
  128. $this->db->where('brd_key', $brd_key)->delete('board');
  129. alert('게시판이 삭제되었습니다.');
  130. exit;
  131. }
  132. /**
  133. * 게시판 복사
  134. */
  135. public function board_copy($brd_key)
  136. {
  137. $this->load->model('board_model');
  138. $this->load->library('form_validation');
  139. $this->form_validation->set_rules('original', "원본 게시판", "required|trim");
  140. $this->form_validation->set_rules('brd_key','게시판 고유 키',"required|trim|min_length[3]|max_length[20]|callback_brd_key_check");
  141. if( $this->form_validation->run() != FALSE )
  142. {
  143. $data = $this->board_model->get_board( $this->input->post('original', TRUE) , TRUE);
  144. if(! $data || !isset($data['brd_key']) || !$data['brd_key'])
  145. {
  146. alert_modal_close('원본 게시판 설정을 찾을수 없습니다.');
  147. exit;
  148. }
  149. $data['brd_key'] = $this->input->post('brd_key', TRUE);
  150. $data['brd_title'] = $this->input->post('brd_title', TRUE);
  151. $data['brd_title_m'] = "";
  152. $tmp = (int)$this->db->select_max('brd_sort',"max")->from('board')->get()->row(0)->max;
  153. $data['brd_sort'] = $tmp +1;
  154. $data['brd_count_post'] = 0;
  155. $this->db->insert('board', $data);
  156. alert_modal_close('게시판 복사가 완료되었습니다.');
  157. exit;
  158. }
  159. else
  160. {
  161. $this->data['view'] = $this->board_model->get_board($brd_key, TRUE);
  162. if(! $this->data['view'] || !isset($this->data['view']['brd_key']) || ! $this->data['view']['brd_key'])
  163. {
  164. alert_modal_close('원본 게시판 설정을 찾을수 없습니다.');
  165. exit;
  166. }
  167. $this->data['brd_key'] = $brd_key;
  168. $this->data['skin_list'] = get_skin_list('board');
  169. $this->theme = "admin";
  170. $this->theme_file = "iframe";
  171. $this->view = "board/board_copy";
  172. }
  173. }
  174. /**
  175. * 게시판 중복여부 확인
  176. */
  177. function brd_key_check($str)
  178. {
  179. $this->load->model('board_model');
  180. if(! preg_match("/^[a-z][a-z0-9_]{2,19}$/", $str))
  181. {
  182. $this->form_validation->set_message('brd_key_check', "게시판 고유키는 영어 소문자로 시작하는 3~20 글자로 영어와 숫자만 사용가능합니다. : {$str}");
  183. return FALSE;
  184. }
  185. if( $board = $this->board_model->get_board($str, TRUE) ) {
  186. $this->form_validation->set_message('brd_key_check', "이미 사용중인 {field} 입니다 : {$str}");
  187. return FALSE;
  188. }
  189. return TRUE;
  190. }
  191. /**
  192. * 게시판 카테고리 관리
  193. * @param string $brd_key
  194. */
  195. function category($brd_key="")
  196. {
  197. $this->load->model('board_model');
  198. if(empty($brd_key))
  199. {
  200. alert('잘못된 접근입니다.');
  201. exit;
  202. }
  203. $this->data['board'] = $this->board_model->get_board($brd_key, FALSE);
  204. if( $this->data['board']['brd_use_category'] != 'Y' )
  205. {
  206. alert('게시판 카테고리 사용설정이 되어있지 않습니다.');
  207. exit;
  208. }
  209. // 메타태그 설정
  210. $this->site->meta_title = "게시판 관리";
  211. // 레이아웃 & 뷰파일 설정
  212. $this->theme = "admin";
  213. $this->view = "board/category";
  214. $this->active = "board/lists";
  215. }
  216. /**
  217. * 카테고리 등록/수정
  218. */
  219. function category_form()
  220. {
  221. $this->load->library('form_validation');
  222. $this->load->model('board_model');
  223. $this->form_validation->set_rules('brd_key', "게시판 고유키","required|trim");
  224. $this->form_validation->set_rules('bca_name', "카테고리 이름","required|trim");
  225. if( $this->form_validation->run() != FALSE )
  226. {
  227. $data['bca_idx'] = $this->input->post('bca_idx', TRUE);
  228. $data['bca_parent'] = $this->input->post('bca_parent', TRUE);
  229. $data['brd_key'] = $this->input->post('brd_key', TRUE);
  230. $data['bca_name'] = $this->input->post('bca_name', TRUE);
  231. if( empty($data['bca_idx']) )
  232. {
  233. $tmp = (int)$this->db->select_max('bca_sort','max')->where('brd_key',$data['brd_key'])->where('bca_parent', $data['bca_parent'])->get('board_category')->row(0)->max;
  234. $data['bca_sort'] = $tmp+1;
  235. if( $this->db->insert("board_category", $data) )
  236. {
  237. $this->board_model->delete_cache($data['brd_key']);
  238. alert_modal_close('새로운 카테고리가 추가되었습니다.');
  239. exit;
  240. }
  241. }
  242. else
  243. {
  244. $this->db->where('bca_idx', $data['bca_idx']);
  245. $this->db->where('bca_parent', $data['bca_parent']);
  246. $this->db->where('brd_key', $data['brd_key']);
  247. $this->db->set('bca_name', $data['bca_name']);
  248. if( $this->db->update('board_category') )
  249. {
  250. $this->board_model->delete_cache($data['brd_key']);
  251. alert_modal_close('카테고리 이름을 변경하었습니다.');
  252. exit;
  253. }
  254. }
  255. alert('DB 입력에 실패하였습니다');
  256. exit;
  257. }
  258. else
  259. {
  260. $this->data['brd_key'] = $this->input->get('brd_key', TRUE);
  261. $this->data['bca_parent'] = $this->input->get('bca_parent', TRUE);
  262. $this->data['bca_idx'] = $this->input->get('bca_idx', TRUE);
  263. $this->data['view'] = empty($this->data['bca_idx']) ? array() : $this->board_model->get_category($this->data['bca_idx']);
  264. $this->theme = "admin";
  265. $this->theme_file = "iframe";
  266. $this->view = "board/category_form";
  267. }
  268. }
  269. function board_common($brd_key)
  270. {
  271. $this->load->model('board_model');
  272. $this->data['board'] = $this->board_model->get_board($brd_key, FALSE);
  273. if(empty($this->data['board']) OR ! isset($this->data['board']['brd_key']) )
  274. {
  275. alert('존재하지 않는 게시판 또는 삭제된 게시판입니다.');
  276. exit;
  277. }
  278. $this->param['page'] = $this->data['page'] = (int)$this->input->get('page', TRUE) >= 1 ? $this->input->get('page', TRUE) : 1;
  279. $this->param['scol'] = $this->data['scol'] = $this->input->get('scol', TRUE);
  280. $this->param['stxt'] = $this->data['stxt'] = $this->input->get('stxt', TRUE);
  281. $this->param['category'] = $this->data['category'] = $this->input->get('category', TRUE);
  282. $this->data['use_wysiwyg'] = ($this->data['board']['brd_use_wysiwyg'] == 'Y');
  283. $this->data['use_secret'] = ($this->member->is_login() && $this->data['board']['brd_use_secret'] == 'Y');
  284. $this->data['use_notice'] = TRUE;
  285. $this->data['use_category'] = (($this->data['board']['brd_use_category'] == 'Y') && (count($this->data['board']['category']) > 0));
  286. $this->data['use_attach'] = ($this->data['board']['brd_use_attach'] == 'Y');
  287. }
  288. /**
  289. * 게시판 목록
  290. */
  291. function posts($brd_key)
  292. {
  293. $this->board_common($brd_key);
  294. $this->data['list'] = $this->board_model->post_list($this->data['board'], $this->param);
  295. $paging['page'] = $this->param['page'];
  296. $paging['page_rows'] = 20;
  297. $paging['total_rows'] = $this->data['list']['total_count'];
  298. $this->load->library('paging', $paging);
  299. $this->data['pagination'] = $this->paging->create();
  300. $this->active = "board/" . $brd_key;
  301. $this->theme = "admin";
  302. $this->view = "board/posts";
  303. }
  304. function read($brd_key, $post_idx="")
  305. {
  306. $this->board_common($brd_key);
  307. $this->data['view'] = $this->board_model->get_post($brd_key, $post_idx, FALSE);
  308. $this->active = "board/" . $brd_key;
  309. $this->theme = "admin";
  310. $this->view = "board/read";
  311. }
  312. function write($brd_key, $post_idx="")
  313. {
  314. $this->load->library('form_validation');
  315. $this->board_common($brd_key);
  316. $this->form_validation->set_rules('post_title', langs('게시판/form/post_title') ,'required|trim');
  317. $this->form_validation->set_rules('post_content', langs('게시판/form/post_content'),'required|trim');
  318. if( $this->form_validation->run() != FALSE)
  319. {
  320. $this->load->library('upload');
  321. // 받아온 값을 정리한다.
  322. $data['post_title'] = $this->input->post('post_title', TRUE);
  323. $data['bca_idx'] = (int) $this->input->post('bca_idx', TRUE);
  324. $data['post_parent'] = $this->input->post('post_parent', TRUE, 0);
  325. $data['post_secret'] = $this->input->post('post_secret', TRUE, 'N') == 'Y' ? "Y":'N';
  326. $data['post_content'] = $this->input->post('post_content', FALSE);
  327. $data['brd_key'] = $brd_key;
  328. $data['post_modtime'] = date('Y-m-d H:i:s');
  329. $data['post_html'] = $this->data['use_wysiwyg'] ? 'Y' : 'N';
  330. $data['post_notice'] = $this->input->post('post_notice', TRUE) == 'Y' ? 'Y' : 'N';
  331. $data['post_ip'] = ip2long( $this->input->ip_address() );
  332. $data['post_mobile'] = $this->site->viewmode == DEVICE_MOBILE ? 'Y' : 'N';
  333. $data['post_keywords'] = $this->input->post('post_keywords', TRUE);
  334. for($i=1; $i<=9; $i++)
  335. {
  336. $data['post_ext'.$i] = $this->input->post('post_ext'.$i, TRUE,'');
  337. }
  338. $parent = array();
  339. if(! empty( $data['post_parent'] ) )
  340. {
  341. $parent = $this->board_model->get_post($brd_key, $data['post_parent'], FALSE);
  342. }
  343. // 게시판 설정을 이용해서 값 정리
  344. if( $this->data['board']['brd_use_secret'] == 'N' ) $data['post_secret'] = 'N';
  345. else if ( $this->data['board']['brd_use_secret'] == 'A' ) $data['post_secret'] = 'Y';
  346. // 답글인경우 원글이 비밀글이면 답글도 비밀글
  347. else if ( ! empty($data['post_parent']) && $parent['post_secret'] == 'Y' ) $data['post_secret'] = 'Y';
  348. // 파일 업로드가 있다면
  349. if( isset($_FILES) && isset($_FILES['userfile']) && count($_FILES['userfile']) > 0 )
  350. {
  351. $dir_path = DIR_UPLOAD . "/board/{$brd_key}/".date('Y')."/".date('m');
  352. make_dir($dir_path,FALSE);
  353. $upload_config['upload_path'] = "./".$dir_path;
  354. $upload_config['file_ext_tolower'] = TRUE;
  355. $upload_config['allowed_types'] = FILE_UPLOAD_ALLOW;
  356. $upload_config['encrypt_name'] = TRUE;
  357. $this->load->library("upload", $upload_config);
  358. $this->data['upload_array'] = array();
  359. // FOR문으로 업로드하기 위해 돌리기
  360. $files = NULL;
  361. foreach ($_FILES['userfile'] as $key => $value) {
  362. foreach ($value as $noKey => $noValue) {
  363. $files[$noKey][$key] = $noValue;
  364. }
  365. }
  366. unset($_FILES);
  367. // FOR 문 돌면서 정리
  368. foreach ($files as $file) {
  369. $_FILES['userfile'] = $file;
  370. $this->upload->initialize($upload_config);
  371. if( ! isset($_FILES['userfile']['tmp_name']) OR ! $_FILES['userfile']['tmp_name']) continue;
  372. if (! $this->upload->do_upload('userfile') )
  373. {
  374. alert('파일 업로드에 실패하였습니다.\\n'.$this->upload->display_errors(' ',' '));
  375. exit;
  376. }
  377. else
  378. {
  379. $filedata = $this->upload->data();
  380. $this->data['upload_array'][] = array(
  381. "att_target_type" => 'BOARD',
  382. "att_origin" => $filedata['orig_name'],
  383. "att_filepath" => $dir_path . "/" . $filedata['file_name'],
  384. "att_downloads" => 0,
  385. "att_filesize" => $filedata['file_size'] * 1024,
  386. "att_width" => $filedata['image_width'] ? $filedata['image_width'] : 0,
  387. "att_height" => $filedata['image_height'] ? $filedata['image_height'] : 0,
  388. "att_ext" => $filedata['file_ext'],
  389. "att_is_image" => ($filedata['is_image'] == 1) ? 'Y' : 'N',
  390. "reg_user" => $this->member->is_login(),
  391. "reg_datetime" => date('Y-m-d H:i:s')
  392. );
  393. }
  394. }
  395. }
  396. // 첨부파일 삭제가 있다면 삭제한다.
  397. $del_file = $this->input->post("del_file", TRUE);
  398. if( $del_file && count($del_file) > 0 )
  399. {
  400. foreach($del_file as $att_idx) {
  401. $this->board_model->attach_remove($att_idx);
  402. }
  403. }
  404. // 수정이냐 신규냐에 따라 값 설정
  405. if( empty($post_idx) )
  406. {
  407. $data['mem_userid'] = $this->member->info('userid');
  408. $data['mem_nickname'] = $this->member->info('nickname');
  409. $data['mem_password'] = $this->member->info('password');
  410. $data['post_regtime'] = date('Y-m-d H:i:s');
  411. $data['post_status'] = 'Y';
  412. $data['post_count_comment'] = 0;
  413. $data['post_hit'] = 0;
  414. // 답글인경우
  415. if(! empty($data['post_parent']))
  416. {
  417. if( strlen($parent['post_reply']) >= 10 )
  418. {
  419. alert('더 이상 답변하실 수 없습니다.\\n답변은 10단계 까지만 가능합니다.');
  420. exit;
  421. }
  422. $reply_len = strlen($parent['post_reply']) + 1;
  423. $begin_reply_char = 'A';
  424. $end_reply_char = 'Z';
  425. $reply_number = +1;
  426. $reply_char = "";
  427. $this->db->select("MAX(SUBSTRING(post_reply, {$reply_len}, 1)) AS reply")->from('board_post')->where('post_num', $parent['post_num'])->where('brd_key', $brd_key)->where("SUBSTRING(post_reply, {$reply_len}, 1) <>", '');
  428. if($parent['post_reply']) $this->db->like('post_reply', $parent['post_reply'],'after');
  429. $row = $this->db->get()->row_array();
  430. if(! $row['reply']) {
  431. $reply_char = $begin_reply_char;
  432. }
  433. else if ($row['reply'] == $end_reply_char) {
  434. alert("더 이상 답변하실 수 없습니다.\\n답변은 26개 까지만 가능합니다.");
  435. exit;
  436. }
  437. else {
  438. $reply_char = chr(ord($row['reply']) + $reply_number);
  439. }
  440. $data['post_reply'] = $parent['post_reply'] . $reply_char;
  441. // 답변의 원글이 비밀글이라면, 비밀번호는 원글과 동일하게 넣는다.
  442. if( $parent['post_secret'] == 'Y' ) {
  443. $data['mem_password'] = $parent['mem_password'];
  444. }
  445. $data['post_num'] = $parent['post_num'];
  446. }
  447. else {
  448. $tmp = (int)$this->db->select_max('post_num','max')->from('board_post')->where('brd_key',$brd_key)->get()->row(0)->max;
  449. $data['post_reply'] = "";
  450. $data['post_num'] = $tmp+1;
  451. }
  452. if(! $this->db->insert('board_post', $data) )
  453. {
  454. alert(langs('게시판/msg/write_failed'));
  455. exit;
  456. }
  457. $post_idx = $this->db->insert_id();
  458. }
  459. else {
  460. $this->db->where('brd_key', $brd_key);
  461. $this->db->where('post_idx', $post_idx);
  462. if(! $this->db->update('board_post', $data))
  463. {
  464. alert(langs('게시판/msg/write_failed'));
  465. exit;
  466. }
  467. }
  468. // 업로드된 데이타가 있을경우에 DB에 기록
  469. if(isset($this->data['upload_array']) && count($this->data['upload_array']) >0 )
  470. {
  471. foreach($this->data['upload_array'] as &$arr) {
  472. $arr['att_target'] = $post_idx;
  473. }
  474. $this->db->insert_batch("attach", $this->data['upload_array']);
  475. }
  476. alert(langs('게시판/msg/write_success'), base_url("admin/board/read/{$brd_key}/{$post_idx}"));
  477. exit;
  478. }
  479. else {
  480. // 수정일경우를 대비해서 글 고유 pk 넘김
  481. $this->data['post_idx'] = (int)$post_idx;
  482. $this->data['post_parent'] = $this->input->get('post_parent', TRUE);
  483. $this->data['view'] = empty($post_idx) ? array() : $this->board_model->get_post($brd_key, $post_idx, FALSE);
  484. $this->data['parent'] = empty($this->data['post_parent']) ? array() : $this->board_model->get_post($brd_key, $this->data['post_parent'], FALSE);
  485. if( $this->data['post_idx'] && (! $this->data['view'] OR ! isset($this->data['view']['post_idx']) OR !$this->data['view']['post_idx'] ) )
  486. {
  487. alert('잘못된 접근입니다.');
  488. exit;
  489. }
  490. $hidden = array();
  491. // 답글작성일경우 부모 번호 넘겨주기
  492. if($this->data['post_parent']) {
  493. $hidden['post_parent'] = $this->data['post_parent'];
  494. $this->data['view']['post_title'] = "RE : ". $this->data['parent']['post_title'];
  495. }
  496. $write_url = base_url("admin/board/write/{$brd_key}" . ($post_idx ? '/'.$post_idx : ''), SSL_VERFIY ? "https":'http');
  497. $this->data['form_open'] = form_open_multipart($write_url, array("autocomplete"=>"off"), $hidden);
  498. $this->data['form_close'] = form_close();
  499. // 레이아웃 & 뷰파일 설정
  500. $this->active = "board/".$brd_key;
  501. $this->theme = "admin";
  502. $this->view = "board/write";
  503. }
  504. }
  505. }