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.

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