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.

285 lines
11 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
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
7 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 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. public function __construct()
  6. {
  7. parent::__construct();
  8. $this->theme = 'admin';
  9. $this->load->library('boardlib');
  10. }
  11. /******************************************************************************************************
  12. * 게시판 목록
  13. ******************************************************************************************************/
  14. public function lists()
  15. {
  16. // 메타태그 설정
  17. $this->site->meta_title = "게시판 관리";
  18. // 레이아웃 & 뷰파일 설정
  19. $this->view = $this->active = "board/lists";
  20. }
  21. /**
  22. * 게시판 등록/수정
  23. * @param string $brd_key
  24. */
  25. public function form($brd_key="")
  26. {
  27. $this->load->library('form_validation');
  28. $this->form_validation->set_rules('brd_key','게시판 고유 키',"required|trim|min_length[3]|max_length[20]". (empty($brd_key)?"|callback_brd_key_check":""));
  29. if( $this->form_validation->run() != FALSE )
  30. {
  31. $data['brd_key'] = $this->input->post('brd_key', TRUE);
  32. $data['brd_type'] = $this->input->post('brd_type',TRUE,'list');
  33. $data['brd_title'] = $this->input->post('brd_title', TRUE,'');
  34. $data['brd_keywords'] = $this->input->post('brd_keywords', TRUE);
  35. $data['brd_description'] = $this->input->post('brd_description', TRUE);
  36. $data['brd_skin_l'] = $this->input->post('brd_skin_l', TRUE);
  37. $data['brd_skin_l_m'] = $this->input->post('brd_skin_l_m', TRUE);
  38. $data['brd_skin_w'] = $this->input->post('brd_skin_w', TRUE);
  39. $data['brd_skin_w_m'] = $this->input->post('brd_skin_w_m', TRUE);
  40. $data['brd_skin_v'] = $this->input->post('brd_skin_v', TRUE);
  41. $data['brd_skin_v_m'] = $this->input->post('brd_skin_v_m', TRUE);
  42. $data['brd_skin_c'] = $this->input->post('brd_skin_c', TRUE);
  43. $data['brd_skin_c_m'] = $this->input->post('brd_skin_c_m', TRUE);
  44. $data['brd_use_category'] = $this->input->post('brd_use_category', TRUE, "N");
  45. $data['brd_category'] = rtrim(trim($this->input->post('brd_category', TRUE, '')), ';');
  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_page_limit'] = $this->input->post('brd_page_limit', TRUE);
  53. $data['brd_page_rows'] = $this->input->post('brd_page_rows', TRUE);
  54. $data['brd_page_rows_m'] = $this->input->post('brd_page_rows_m', TRUE);
  55. $data['brd_fixed_num'] = $this->input->post('brd_fixed_num', TRUE);
  56. $data['brd_fixed_num_m'] = $this->input->post('brd_fixed_num_m', TRUE);
  57. $data['brd_display_time'] = $this->input->post('brd_display_time', TRUE);
  58. $data['brd_use_anonymous'] = $this->input->post('brd_use_anonymous', TRUE);
  59. $data['brd_use_secret'] = $this->input->post('brd_use_secret', TRUE);
  60. $data['brd_use_reply'] = $this->input->post('brd_use_reply', TRUE);
  61. $data['brd_use_comment'] = $this->input->post('brd_use_comment', TRUE);
  62. $data['brd_point_read'] = $this->input->post('brd_point_read', TRUE, 0);
  63. $data['brd_point_write'] = $this->input->post('brd_point_write', TRUE, 0);
  64. $data['brd_point_comment'] = $this->input->post('brd_point_comment', TRUE, 0);
  65. $data['brd_point_download'] = $this->input->post('brd_point_download', TRUE, 0);
  66. $data['brd_point_reply'] = $this->input->post('brd_point_reply', TRUE, 0);
  67. $data['brd_point_read_flag'] = $this->input->post('brd_point_read_flag', TRUE, -1);
  68. $data['brd_point_write_flag'] = $this->input->post('brd_point_write_flag', TRUE, 1);
  69. $data['brd_point_comment_flag'] = $this->input->post('brd_point_comment_flag', TRUE, 1);
  70. $data['brd_point_download_flag'] = $this->input->post('brd_point_download_flag', TRUE, -1);
  71. $data['brd_point_reply_flag'] = $this->input->post('brd_point_reply_flag', TRUE, 1);
  72. $data['upd_user'] = $this->member->is_login();
  73. $data['upd_datetime'] = date('Y-m-d H:i:s');
  74. if(empty($brd_key))
  75. {
  76. $data['reg_user'] = $data['upd_user'];
  77. $data['reg_datetime'] = $data['upd_datetime'];
  78. $data['brd_count_post'] = 0;
  79. if( $this->db->insert('board', $data) )
  80. {
  81. alert_modal_close('게시판 생성이 완료되었습니다.');
  82. exit;
  83. }
  84. }
  85. else
  86. {
  87. $this->db->where('brd_key', $brd_key);
  88. if( $this->db->update('board', $data) ) {
  89. $this->boardlib->delete_cache($brd_key);
  90. alert_modal_close('게시판 정보 수정이 완료되었습니다.');
  91. exit;
  92. }
  93. }
  94. alert('DB입력도중 오류가 발생하였습니다.');
  95. exit;
  96. }
  97. else
  98. {
  99. $this->data['view'] = (empty($brd_key)) ? array() : $this->boardlib->get($brd_key, TRUE);
  100. $this->data['brd_key'] = $brd_key;
  101. $this->data['skin_list_l'] = get_skin_list('board/list');
  102. $this->data['skin_list_w'] = get_skin_list('board/write');
  103. $this->data['skin_list_v'] = get_skin_list('board/view');
  104. $this->data['skin_list_c'] = get_skin_list('board/comment');
  105. // 메타태그 설정
  106. $this->site->meta_title = "게시판 관리";
  107. // 레이아웃 & 뷰파일 설정
  108. $this->view = "board/form";
  109. $this->theme_file = 'iframe';
  110. }
  111. }
  112. /**
  113. * 게시판 삭제
  114. */
  115. public function remove($brd_key)
  116. {
  117. if(empty($brd_key))
  118. {
  119. alert('잘못된 접근입니다.');
  120. exit;
  121. }
  122. $this->db->where('brd_key', $brd_key)->delete('board');
  123. alert('게시판이 삭제되었습니다.');
  124. exit;
  125. }
  126. /**
  127. * 게시판 복사
  128. */
  129. public function board_copy($brd_key)
  130. {
  131. $this->load->library('form_validation');
  132. $this->form_validation->set_rules('original', "원본 게시판", "required|trim");
  133. $this->form_validation->set_rules('brd_key','게시판 고유 키',"required|trim|min_length[3]|max_length[20]|callback_brd_key_check");
  134. if( $this->form_validation->run() != FALSE )
  135. {
  136. $data = $this->boardlib->get( $this->input->post('original', TRUE) , TRUE);
  137. if(! $data || !isset($data['brd_key']) || !$data['brd_key'])
  138. {
  139. alert_modal_close('원본 게시판 설정을 찾을수 없습니다.');
  140. exit;
  141. }
  142. $data['brd_key'] = $this->input->post('brd_key', TRUE);
  143. $data['brd_title'] = $this->input->post('brd_title', TRUE);
  144. $data['brd_count_post'] = 0;
  145. $data['upd_user'] = $data['reg_user'] = $this->member->is_login();
  146. $data['upd_datetime'] = $data['reg_datetime'] = date('Y-m-d H:i:s');
  147. $this->db->insert('board', $data);
  148. alert_modal_close('게시판 복사가 완료되었습니다.');
  149. exit;
  150. }
  151. else
  152. {
  153. $this->data['view'] = $this->boardlib->get($brd_key, TRUE);
  154. if(! $this->data['view'] || !isset($this->data['view']['brd_key']) || ! $this->data['view']['brd_key'])
  155. {
  156. alert_modal_close('원본 게시판 설정을 찾을수 없습니다.');
  157. exit;
  158. }
  159. $this->data['brd_key'] = $brd_key;
  160. $this->data['skin_list'] = get_skin_list('board');
  161. $this->theme = "admin";
  162. $this->theme_file = "iframe";
  163. $this->view = "board/board_copy";
  164. }
  165. }
  166. /**
  167. * 게시판 중복여부 확인
  168. */
  169. function brd_key_check($str)
  170. {
  171. if(! preg_match("/^[a-z][a-z0-9_]{2,19}$/", $str))
  172. {
  173. $this->form_validation->set_message('brd_key_check', "게시판 고유키는 영어 소문자로 시작하는 3~20 글자로 영어와 숫자만 사용가능합니다. : {$str}");
  174. return FALSE;
  175. }
  176. if( $board = $this->boardlib->get($str, TRUE) ) {
  177. $this->form_validation->set_message('brd_key_check', "이미 사용중인 {field} 입니다 : {$str}");
  178. return FALSE;
  179. }
  180. return TRUE;
  181. }
  182. /**
  183. * 게시판 목록
  184. */
  185. function posts($brd_key)
  186. {
  187. $this->boardlib->common_data($brd_key);
  188. $this->data['list'] = $this->boardlib->post_list($this->data['board'], $this->param);
  189. $paging['page'] = $this->param['page'];
  190. $paging['page_rows'] = $this->data['board']['brd_page_rows'];
  191. $paging['total_rows'] = $this->data['list']['total_count'];
  192. $this->load->library('paging', $paging);
  193. $this->data['pagination'] = $this->paging->create();
  194. $this->active = "board/" . $brd_key;
  195. $this->theme = "admin";
  196. $this->view = "board/posts";
  197. }
  198. /**
  199. * 게시글 읽기
  200. */
  201. function read($brd_key, $post_idx="")
  202. {
  203. $this->boardlib->common_data($brd_key);
  204. $this->boardlib->read_process($brd_key, $post_idx);
  205. $this->theme = "admin";
  206. }
  207. /**
  208. * 게시글 작성/수정
  209. */
  210. function write($brd_key, $post_idx="")
  211. {
  212. $this->boardlib->common_data($brd_key);
  213. $this->boardlib->write_process($brd_key, $post_idx);
  214. }
  215. /**
  216. * 댓글 작성/수정 처리부분
  217. */
  218. function comment($brd_key, $post_idx)
  219. {
  220. $this->boardlib->common_data($brd_key);
  221. $this->boardlib->comment_process($brd_key, $post_idx);
  222. }
  223. /**
  224. * 댓글 작성/수정
  225. */
  226. function comment_modify($cmt_idx="")
  227. {
  228. if( ! $comment = $this->db->where('cmt_idx', $cmt_idx)->where('cmt_status', 'Y')->get('board_comment')->row_array() )
  229. {
  230. alert_close(langs('게시판/msg/invalid_comment'));
  231. exit;
  232. }
  233. $this->boardlib->common_data($comment['brd_key']);
  234. $this->boardlib->comment_modify_form($cmt_idx,$comment);
  235. }
  236. /**
  237. * 댓글 삭제
  238. * @param $brd_key
  239. * @param $post_idx
  240. * @param $cmt_idx
  241. */
  242. public function comment_delete($brd_key, $post_idx, $cmt_idx)
  243. {
  244. $this->boardlib->common_data($brd_key);
  245. $this->boardlib->comment_delete_process($brd_key, $post_idx, $cmt_idx);
  246. }
  247. }