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.

597 lines
25 KiB

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