XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
board.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
9 class boardView extends board
10 {
13 
18  function init()
19  {
20  $oSecurity = new Security();
21  $oSecurity->encodeHTML('document_srl', 'comment_srl', 'vid', 'mid', 'page', 'category', 'search_target', 'search_keyword', 'sort_index', 'order_type', 'trackback_srl');
22 
26  if($this->module_info->list_count)
27  {
28  $this->list_count = $this->module_info->list_count;
29  }
30  if($this->module_info->search_list_count)
31  {
32  $this->search_list_count = $this->module_info->search_list_count;
33  }
34  if($this->module_info->page_count)
35  {
36  $this->page_count = $this->module_info->page_count;
37  }
38  $this->except_notice = $this->module_info->except_notice == 'N' ? FALSE : TRUE;
39 
40  // $this->_getStatusNameListecret option backward compatibility
41  $oDocumentModel = getModel('document');
42 
43  $statusList = $this->_getStatusNameList($oDocumentModel);
44  if(isset($statusList['SECRET']))
45  {
46  $this->module_info->secret = 'Y';
47  }
48 
49  // use_category <=1.5.x, hide_category >=1.7.x
50  $count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl));
51  if($count_category)
52  {
53  if($this->module_info->hide_category)
54  {
55  $this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y';
56  }
57  else if($this->module_info->use_category)
58  {
59  $this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y';
60  }
61  else
62  {
63  $this->module_info->hide_category = 'N';
64  $this->module_info->use_category = 'Y';
65  }
66  }
67  else
68  {
69  $this->module_info->hide_category = 'Y';
70  $this->module_info->use_category = 'N';
71  }
72 
77  if($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read)
78  {
79  $this->consultation = TRUE;
80  if(!Context::get('is_logged'))
81  {
82  $this->grant->list = FALSE;
83  $this->grant->write_document = FALSE;
84  $this->grant->write_comment = FALSE;
85  $this->grant->view = FALSE;
86  }
87  }
88  else
89  {
90  $this->consultation = FALSE;
91  }
92 
97  $template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
98  if(!is_dir($template_path)||!$this->module_info->skin)
99  {
100  $this->module_info->skin = 'default';
101  $template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
102  }
104 
108  $oDocumentModel = getModel('document');
109  $extra_keys = $oDocumentModel->getExtraKeys($this->module_info->module_srl);
110  Context::set('extra_keys', $extra_keys);
111 
115  if (is_array($extra_keys))
116  {
117  foreach($extra_keys as $val)
118  {
119  $this->order_target[] = $val->eid;
120  }
121  }
125  Context::addJsFilter($this->module_path.'tpl/filter', 'input_password.xml');
126  Context::addJsFile($this->module_path.'tpl/js/board.js');
127 
128  // remove [document_srl]_cpage from get_vars
130  foreach($args as $name => $value)
131  {
132  if(preg_match('/[0-9]+_cpage/', $name))
133  {
134  Context::set($name, '', TRUE);
135  Context::set($name, $value);
136  }
137  }
138  }
139 
143  function dispBoardContent()
144  {
148  if(!$this->grant->access || !$this->grant->list)
149  {
150  return $this->dispBoardMessage('msg_not_permitted');
151  }
152 
156  $this->dispBoardCategoryList();
157 
162  // use search options on the template (the search options key has been declared, based on the language selected)
163  foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
164  $extra_keys = Context::get('extra_keys');
165  if($extra_keys)
166  {
167  foreach($extra_keys as $key => $val)
168  {
169  if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
170  }
171  }
172  // remove a search option that is not public in member config
173  $memberConfig = getModel('module')->getModuleConfig('member');
174  foreach($memberConfig->signupForm as $signupFormElement)
175  {
176  if(in_array($signupFormElement->title, $search_option))
177  {
178  if($signupFormElement->isPublic == 'N')
179  unset($search_option[$signupFormElement->name]);
180  }
181  }
182  Context::set('search_option', $search_option);
183 
184  $oDocumentModel = getModel('document');
185  $statusNameList = $this->_getStatusNameList($oDocumentModel);
186  if(count($statusNameList) > 0)
187  {
188  Context::set('status_list', $statusNameList);
189  }
190 
191  // display the board content
192  $this->dispBoardContentView();
193 
194  // list config, columnList setting
195  $oBoardModel = getModel('board');
196  $this->listConfig = $oBoardModel->getListConfig($this->module_info->module_srl);
197  if(!$this->listConfig) $this->listConfig = array();
198  $this->_makeListColumnList();
199 
200  // display the notice list
201  $this->dispBoardNoticeList();
202 
203  // list
204  $this->dispBoardContentList();
205 
209  Context::addJsFilter($this->module_path.'tpl/filter', 'search.xml');
210 
211  $oSecurity = new Security();
212  $oSecurity->encodeHTML('search_option.');
213 
214  // setup the tmeplate file
215  $this->setTemplateFile('list');
216  }
217 
222  // check if the use_category option is enabled
223  if($this->module_info->use_category=='Y')
224  {
225  // check the grant
226  if(!$this->grant->list)
227  {
228  Context::set('category_list', array());
229  return;
230  }
231 
232  $oDocumentModel = getModel('document');
233  Context::set('category_list', $oDocumentModel->getCategoryList($this->module_srl));
234 
235  $oSecurity = new Security();
236  $oSecurity->encodeHTML('category_list.', 'category_list.childs.');
237  }
238  }
239 
244  // get the variable value
245  $document_srl = Context::get('document_srl');
246  $page = Context::get('page');
247 
248  // generate document model object
249  $oDocumentModel = getModel('document');
250 
254  if($document_srl)
255  {
256  $oDocument = $oDocumentModel->getDocument($document_srl, false, true);
257 
258  // if the document is existed
259  if($oDocument->isExists())
260  {
261  // if the module srl is not consistent
262  if($oDocument->get('module_srl')!=$this->module_info->module_srl )
263  {
264  return $this->stop('msg_invalid_request');
265  }
266 
267  // check the manage grant
268  if($this->grant->manager) $oDocument->setGrant();
269 
270  // if the consultation function is enabled, and the document is not a notice
271  if($this->consultation && !$oDocument->isNotice())
272  {
273  $logged_info = Context::get('logged_info');
274  if(abs($oDocument->get('member_srl')) != $logged_info->member_srl)
275  {
276  $oDocument = $oDocumentModel->getDocument(0);
277  }
278  }
279 
280  // if the document is TEMP saved, check Grant
281  if($oDocument->getStatus() == 'TEMP')
282  {
283  if(!$oDocument->isGranted())
284  {
285  $oDocument = $oDocumentModel->getDocument(0);
286  }
287  }
288 
289  }
290  else
291  {
292  // if the document is not existed, then alert a warning message
293  Context::set('document_srl','',true);
294  $this->alertMessage('msg_not_founded');
295  }
296 
300  }
301  else
302  {
303  $oDocument = $oDocumentModel->getDocument(0);
304  }
305 
309  if($oDocument->isExists())
310  {
311  if(!$this->grant->view && !$oDocument->isGranted())
312  {
313  $oDocument = $oDocumentModel->getDocument(0);
314  Context::set('document_srl','',true);
315  $this->alertMessage('msg_not_permitted');
316  }
317  else
318  {
319  // add the document title to the browser
320  Context::addBrowserTitle($oDocument->getTitleText());
321 
322  // update the document view count (if the document is not secret)
323  if(!$oDocument->isSecret() || $oDocument->isGranted())
324  {
325  $oDocument->updateReadedCount();
326  }
327 
328  // disappear the document if it is secret
329  if($oDocument->isSecret() && !$oDocument->isGranted())
330  {
331  $oDocument->add('content',Context::getLang('thisissecret'));
332  }
333  }
334  }
335 
336  // setup the document oject on context
337  $oDocument->add('module_srl', $this->module_srl);
338  Context::set('oDocument', $oDocument);
339 
343  Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
344 
345 // return new BaseObject();
346  }
347 
355  if(!$this->grant->access)
356  {
357  return $this->dispBoardMessage('msg_not_permitted');
358  }
359 
360  // check document view grant
361  $this->dispBoardContentView();
362 
363  // Check if a permission for file download is granted
364  // Get configurations (using module model object)
365  $oModuleModel = getModel('module');
366  $file_module_config = $oModuleModel->getModulePartConfig('file',$this->module_srl);
367 
368  $downloadGrantCount = 0;
369  if(is_array($file_module_config->download_grant))
370  {
371  foreach($file_module_config->download_grant AS $value)
372  if($value) $downloadGrantCount++;
373  }
374 
375  if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
376  {
377  if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
378  $logged_info = Context::get('logged_info');
379  if($logged_info->is_admin != 'Y')
380  {
381  $oModuleModel =& getModel('module');
382  $columnList = array('module_srl', 'site_srl');
383  $module_info = $oModuleModel->getModuleInfoByModuleSrl($this->module_srl, $columnList);
384 
385  if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
386  {
387  $oMemberModel =& getModel('member');
388  $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
389 
390  $is_permitted = false;
391  for($i=0;$i<count($file_module_config->download_grant);$i++)
392  {
393  $group_srl = $file_module_config->download_grant[$i];
394  if($member_groups[$group_srl])
395  {
396  $is_permitted = true;
397  break;
398  }
399  }
400  if(!$is_permitted) return $this->stop('msg_not_permitted_download');
401  }
402  }
403  }
404 
405  $oDocumentModel = getModel('document');
406  $document_srl = Context::get('document_srl');
407  $oDocument = $oDocumentModel->getDocument($document_srl);
408  Context::set('oDocument', $oDocument);
409  Context::set('file_list',$oDocument->getUploadedFiles());
410 
411  $oSecurity = new Security();
412  $oSecurity->encodeHTML('file_list..source_filename');
413  }
414 
419  // check document view grant
420  $this->dispBoardContentView();
421 
422  $oDocumentModel = getModel('document');
423  $document_srl = Context::get('document_srl');
424  $oDocument = $oDocumentModel->getDocument($document_srl);
425  $comment_list = $oDocument->getComments();
426 
427  // setup the comment list
428  if(is_array($comment_list))
429  {
430  foreach($comment_list as $key => $val)
431  {
432  if(!$val->isAccessible())
433  {
434  $val->add('content',Context::getLang('thisissecret'));
435  }
436  }
437  }
438  Context::set('comment_list',$comment_list);
439 
440  }
441 
446  // check the grant
447  if(!$this->grant->list)
448  {
449  Context::set('notice_list', array());
450  return;
451  }
452 
453  $oDocumentModel = getModel('document');
454  $args = new stdClass();
455  $args->module_srl = $this->module_srl;
456  $notice_output = $oDocumentModel->getNoticeList($args, $this->columnList);
457  Context::set('notice_list', $notice_output->data);
458  }
459 
464  // check the grant
465  if(!$this->grant->list)
466  {
467  Context::set('document_list', array());
468  Context::set('total_count', 0);
469  Context::set('total_page', 1);
470  Context::set('page', 1);
471  Context::set('page_navigation', new PageHandler(0,0,1,10));
472  return;
473  }
474 
475  $oDocumentModel = getModel('document');
476 
477  // setup module_srl/page number/ list number/ page count
478  $args = new stdClass();
479  $args->module_srl = $this->module_srl;
480  $args->page = Context::get('page');
481  $args->list_count = $this->list_count;
482  $args->page_count = $this->page_count;
483 
484  // get the search target and keyword
485  $args->search_target = Context::get('search_target');
486  $args->search_keyword = Context::get('search_keyword');
487 
488  $search_option = Context::get('search_option');
489  if($search_option==FALSE)
490  {
492  }
493  if(isset($search_option[$args->search_target])==FALSE)
494  {
495  $args->search_target = '';
496  }
497 
498  // if the category is enabled, then get the category
499  if($this->module_info->use_category=='Y')
500  {
501  $args->category_srl = Context::get('category');
502  }
503 
504  // setup the sort index and order index
505  $args->sort_index = Context::get('sort_index');
506  $args->order_type = Context::get('order_type');
507  if(!in_array($args->sort_index, $this->order_target))
508  {
509  $args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order';
510  }
511  if(!in_array($args->order_type, array('asc','desc')))
512  {
513  $args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc';
514  }
515 
516  // set the current page of documents
517  $document_srl = Context::get('document_srl');
518  if(!$args->page && $document_srl)
519  {
520  $oDocument = $oDocumentModel->getDocument($document_srl);
521  if($oDocument->isExists() && !$oDocument->isNotice())
522  {
523  $page = $oDocumentModel->getDocumentPage($oDocument, $args);
524  Context::set('page', $page);
525  $args->page = $page;
526  }
527  }
528 
529  // setup the list count to be serach list count, if the category or search keyword has been set
530  if($args->category_srl || $args->search_keyword)
531  {
532  $args->list_count = $this->search_list_count;
533  }
534 
535  // if the consultation function is enabled, the get the logged user information
536  if($this->consultation)
537  {
538  $logged_info = Context::get('logged_info');
539  $args->member_srl = $logged_info->member_srl;
540 
541  if($this->module_info->use_anonymous === 'Y')
542  {
543  unset($args->member_srl);
544  $args->member_srls = $logged_info->member_srl . ',' . $logged_info->member_srl * -1;
545  }
546  }
547 
548  // setup the list config variable on context
549  Context::set('list_config', $this->listConfig);
550  // setup document list variables on context
551  $output = $oDocumentModel->getDocumentList($args, $this->except_notice, TRUE, $this->columnList);
552  Context::set('document_list', $output->data);
553  Context::set('total_count', $output->total_count);
554  Context::set('total_page', $output->total_page);
555  Context::set('page', $output->page);
556  Context::set('page_navigation', $output->page_navigation);
557  }
558 
560  {
561  $configColumList = array_keys($this->listConfig);
562  $tableColumnList = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice',
563  'title', 'title_bold', 'title_color', 'content', 'readed_count', 'voted_count',
564  'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'password', 'user_id',
565  'user_name', 'nick_name', 'member_srl', 'email_address', 'homepage', 'tags', 'extra_vars',
566  'regdate', 'last_update', 'last_updater', 'ipaddress', 'list_order', 'update_order',
567  'allow_trackback', 'notify_message', 'status', 'comment_status');
568  $this->columnList = array_intersect($configColumList, $tableColumnList);
569 
570  if(in_array('summary', $configColumList)) array_push($this->columnList, 'content');
571 
572  // default column list add
573  $defaultColumn = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'member_srl', 'last_update', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'title_bold', 'title_color');
574 
575  //TODO guestbook, blog style supports legacy codes.
576  if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog')
577  {
578  $defaultColumn = $tableColumnList;
579  }
580 
581  if (in_array('last_post', $configColumList)){
582  array_push($this->columnList, 'last_updater');
583  }
584 
585  // add is_notice
586  if ($this->except_notice)
587  {
588  array_push($this->columnList, 'is_notice');
589  }
590  $this->columnList = array_unique(array_merge($this->columnList, $defaultColumn));
591 
592  // add table name
593  foreach($this->columnList as $no => $value)
594  {
595  $this->columnList[$no] = 'documents.' . $value;
596  }
597  }
598 
602  function dispBoardTagList()
603  {
604  // check if there is not grant fot view list, then alert an warning message
605  if(!$this->grant->list)
606  {
607  return $this->dispBoardMessage('msg_not_permitted');
608  }
609 
610  // generate the tag module model object
611  $oTagModel = getModel('tag');
612 
613  $obj = new stdClass;
614  $obj->mid = $this->module_info->mid;
615  $obj->list_count = 10000;
616  $output = $oTagModel->getTagList($obj);
617 
618  // automatically order
619  if(count($output->data))
620  {
621  $numbers = array_keys($output->data);
622  shuffle($numbers);
623 
624  if(count($output->data))
625  {
626  foreach($numbers as $k => $v)
627  {
628  $tag_list[] = $output->data[$v];
629  }
630  }
631  }
632 
633  Context::set('tag_list', $tag_list);
634 
635  $oSecurity = new Security();
636  $oSecurity->encodeHTML('tag_list.');
637 
638  $this->setTemplateFile('tag_list');
639  }
640 
644  function dispBoardWrite()
645  {
646  // check grant
647  if(!$this->grant->write_document)
648  {
649  return $this->dispBoardMessage('msg_not_permitted');
650  }
651 
652  $oDocumentModel = getModel('document');
653 
657  if($this->module_info->use_category=='Y')
658  {
659  // get the user group information
660  if(Context::get('is_logged'))
661  {
662  $logged_info = Context::get('logged_info');
663  $group_srls = array_keys($logged_info->group_list);
664  }
665  else
666  {
667  $group_srls = array();
668  }
669  $group_srls_count = count($group_srls);
670 
671  // check the grant after obtained the category list
672  $normal_category_list = $oDocumentModel->getCategoryList($this->module_srl);
673  if(count($normal_category_list))
674  {
675  foreach($normal_category_list as $category_srl => $category)
676  {
677  $is_granted = TRUE;
678  if($category->group_srls)
679  {
680  $category_group_srls = explode(',',$category->group_srls);
681  $is_granted = FALSE;
682  if(count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE;
683 
684  }
685  if($is_granted) $category_list[$category_srl] = $category;
686  }
687  }
688  Context::set('category_list', $category_list);
689  }
690 
691  // GET parameter document_srl from request
692  $document_srl = Context::get('document_srl');
693  $oDocument = $oDocumentModel->getDocument(0, $this->grant->manager);
694  $oDocument->setDocument($document_srl);
695 
696  if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE;
697  $oDocument->add('module_srl', $this->module_srl);
698 
699  if($oDocument->isExists() && $this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
700  {
701  return new BaseObject(-1, 'msg_protect_content');
702  }
703 
704  // if the document is not granted, then back to the password input form
705  $oModuleModel = getModel('module');
706  if($oDocument->isExists()&&!$oDocument->isGranted())
707  {
708  return $this->setTemplateFile('input_password_form');
709  }
710 
711  if(!$oDocument->isExists())
712  {
713  $point_config = $oModuleModel->getModulePartConfig('point',$this->module_srl);
714  $logged_info = Context::get('logged_info');
715  $oPointModel = getModel('point');
716  $pointForInsert = $point_config["insert_document"];
717  if($pointForInsert < 0)
718  {
719  if( !$logged_info )
720  {
721  return $this->dispBoardMessage('msg_not_permitted');
722  }
723  else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
724  {
725  return $this->dispBoardMessage('msg_not_enough_point');
726  }
727  }
728  }
729  if(!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus());
730 
731  $statusList = $this->_getStatusNameList($oDocumentModel);
732  if(count($statusList) > 0) Context::set('status_list', $statusList);
733 
734  // get Document status config value
735  Context::set('document_srl',$document_srl);
736  Context::set('oDocument', $oDocument);
737 
738  // apply xml_js_filter on header
739  $oDocumentController = getController('document');
740  $oDocumentController->addXmlJsFilter($this->module_info->module_srl);
741 
742  // if the document exists, then setup extra variabels on context
743  if($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars());
744 
748  if(Context::get('logged_info')->is_admin=='Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml');
749  else Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
750 
751  $oSecurity = new Security();
752  $oSecurity->encodeHTML('category_list.text', 'category_list.title');
753 
754  $this->setTemplateFile('write_form');
755  }
756 
758  {
759  $resultList = array();
760  if(!empty($this->module_info->use_status))
761  {
762  $statusNameList = $oDocumentModel->getStatusNameList();
763  $statusList = explode('|@|', $this->module_info->use_status);
764 
765  if(is_array($statusList))
766  {
767  foreach($statusList as $key => $value)
768  {
769  $resultList[$value] = $statusNameList[$value];
770  }
771  }
772  }
773  return $resultList;
774  }
775 
779  function dispBoardDelete()
780  {
781  // check grant
782  if(!$this->grant->write_document)
783  {
784  return $this->dispBoardMessage('msg_not_permitted');
785  }
786 
787  // get the document_srl from request
788  $document_srl = Context::get('document_srl');
789 
790  // if document exists, get the document information
791  if($document_srl)
792  {
793  $oDocumentModel = getModel('document');
794  $oDocument = $oDocumentModel->getDocument($document_srl);
795  }
796 
797  // if the document is not existed, then back to the board content page
798  if(!$oDocument || !$oDocument->isExists())
799  {
800  return $this->dispBoardContent();
801  }
802 
803  // if the document is not granted, then back to the password input form
804  if(!$oDocument->isGranted())
805  {
806  return $this->setTemplateFile('input_password_form');
807  }
808 
809  if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
810  {
811  return $this->dispBoardMessage('msg_protect_content');
812  }
813 
814  Context::set('oDocument',$oDocument);
815 
819  Context::addJsFilter($this->module_path.'tpl/filter', 'delete_document.xml');
820 
821  $this->setTemplateFile('delete_form');
822  }
823 
828  {
829  $document_srl = Context::get('document_srl');
830 
831  // check grant
832  if(!$this->grant->write_comment)
833  {
834  return $this->dispBoardMessage('msg_not_permitted');
835  }
836 
837  // get the document information
838  $oDocumentModel = getModel('document');
839  $oDocument = $oDocumentModel->getDocument($document_srl);
840  if(!$oDocument->isExists())
841  {
842  return $this->dispBoardMessage('msg_invalid_request');
843  }
844 
845  // Check allow comment
846  if(!$oDocument->allowComment())
847  {
848  return $this->dispBoardMessage('msg_not_allow_comment');
849  }
850 
851  // obtain the comment (create an empty comment document for comment_form usage)
852  $oCommentModel = getModel('comment');
853  $oSourceComment = $oComment = $oCommentModel->getComment(0);
854  $oComment->add('document_srl', $document_srl);
855  $oComment->add('module_srl', $this->module_srl);
856 
857  // setup document variables on context
858  Context::set('oDocument',$oDocument);
859  Context::set('oSourceComment',$oSourceComment);
860  Context::set('oComment',$oComment);
861 
865  Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
866 
867  $this->setTemplateFile('comment_form');
868  }
869 
874  {
875  // check grant
876  if(!$this->grant->write_comment)
877  {
878  return $this->dispBoardMessage('msg_not_permitted');
879  }
880 
881  // get the parent comment ID
882  $parent_srl = Context::get('comment_srl');
883 
884  // if the parent comment is not existed
885  if(!$parent_srl)
886  {
887  return new BaseObject(-1, 'msg_invalid_request');
888  }
889 
890  // get the comment
891  $oCommentModel = getModel('comment');
892  $oSourceComment = $oCommentModel->getComment($parent_srl, $this->grant->manager);
893 
894  // if the comment is not existed, opoup an error message
895  if(!$oSourceComment->isExists())
896  {
897  return $this->dispBoardMessage('msg_invalid_request');
898  }
899  if(Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl'))
900  {
901  return $this->dispBoardMessage('msg_invalid_request');
902  }
903 
904  // Check allow comment
905  $oDocumentModel = getModel('document');
906  $oDocument = $oDocumentModel->getDocument($oSourceComment->get('document_srl'));
907  if(!$oDocument->allowComment())
908  {
909  return $this->dispBoardMessage('msg_not_allow_comment');
910  }
911 
912  // get the comment information
913  $oComment = $oCommentModel->getComment();
914  $oComment->add('parent_srl', $parent_srl);
915  $oComment->add('document_srl', $oSourceComment->get('document_srl'));
916 
917  // setup comment variables
918  Context::set('oSourceComment',$oSourceComment);
919  Context::set('oComment',$oComment);
920  Context::set('module_srl',$this->module_info->module_srl);
921 
925  Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
926 
927  $this->setTemplateFile('comment_form');
928  }
929 
934  {
935  // check grant
936  if(!$this->grant->write_comment)
937  {
938  return $this->dispBoardMessage('msg_not_permitted');
939  }
940 
941  // get the document_srl and comment_srl
942  $document_srl = Context::get('document_srl');
943  $comment_srl = Context::get('comment_srl');
944 
945  // if the comment is not existed
946  if(!$comment_srl)
947  {
948  return new BaseObject(-1, 'msg_invalid_request');
949  }
950 
951  // get comment information
952  $oCommentModel = getModel('comment');
953  $oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
954 
955  // if the comment is not exited, alert an error message
956  if(!$oComment->isExists())
957  {
958  return $this->dispBoardMessage('msg_invalid_request');
959  }
960 
961  // if the comment is not granted, then back to the password input form
962  if(!$oComment->isGranted())
963  {
964  return $this->setTemplateFile('input_password_form');
965  }
966 
967  // setup the comment variables on context
968  Context::set('oSourceComment', $oCommentModel->getComment());
969  Context::set('oComment', $oComment);
970 
974  Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
975 
976  $this->setTemplateFile('comment_form');
977  }
978 
983  {
984  // check grant
985  if(!$this->grant->write_comment)
986  {
987  return $this->dispBoardMessage('msg_not_permitted');
988  }
989 
990  // get the comment_srl to be deleted
991  $comment_srl = Context::get('comment_srl');
992 
993  // if the comment exists, then get the comment information
994  if($comment_srl)
995  {
996  $oCommentModel = getModel('comment');
997  $oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
998  }
999 
1000  // if the comment is not existed, then back to the board content page
1001  if(!$oComment->isExists() )
1002  {
1003  return $this->dispBoardContent();
1004  }
1005 
1006  // if the comment is not granted, then back to the password input form
1007  if(!$oComment->isGranted())
1008  {
1009  return $this->setTemplateFile('input_password_form');
1010  }
1011 
1012  Context::set('oComment',$oComment);
1013 
1017  Context::addJsFilter($this->module_path.'tpl/filter', 'delete_comment.xml');
1018 
1019  $this->setTemplateFile('delete_comment_form');
1020  }
1021 
1026  {
1027  $oTrackbackModel = getModel('trackback');
1028 
1029  if(!$oTrackbackModel)
1030  {
1031  return;
1032  }
1033 
1034  // get the trackback_srl
1035  $trackback_srl = Context::get('trackback_srl');
1036 
1037  // get the trackback data
1038  $columnList = array('trackback_srl');
1039  $output = $oTrackbackModel->getTrackback($trackback_srl, $columnList);
1040  $trackback = $output->data;
1041 
1042  // if no trackback, then display the board content
1043  if(!$trackback)
1044  {
1045  return $this->dispBoardContent();
1046  }
1047 
1048  //Context::set('trackback',$trackback); //perhaps trackback variables not use in UI
1049 
1053  Context::addJsFilter($this->module_path.'tpl/filter', 'delete_trackback.xml');
1054 
1055  $this->setTemplateFile('delete_trackback_form');
1056  }
1057 
1061  function dispBoardMessage($msg_code)
1062  {
1063  $msg = Context::getLang($msg_code);
1064  if(!$msg) $msg = $msg_code;
1065  Context::set('message', $msg);
1066  $this->setTemplateFile('message');
1067  }
1068 
1074  {
1075  $script = sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message));
1076  Context::addHtmlFooter( $script );
1077  }
1078 
1079 }
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
dispBoardModifyComment()
display the comment modification from
Definition: board.view.php:933
$obj
Definition: ko.install.php:262
$search_option
검색 옵션
Definition: board.class.php:12
dispBoardContent()
display board contents
Definition: board.view.php:143
$template_path
a path of directory where template files reside
$output
Definition: ko.install.php:193
dispBoardNoticeList()
display notice list (can be used by API)
Definition: board.view.php:445
dispBoardContentList()
display board content list
Definition: board.view.php:463
_getStatusNameList(&$oDocumentModel)
Definition: board.view.php:757
$category_list
category list
Definition: board.class.php:19
alertMessage($message)
the method for displaying the warning messages display an error message if it has not a special desig...
board module View class
Definition: board.view.php:9
set($key, $val, $set_to_get_vars=0)
dispBoardTagList()
display tag list
Definition: board.view.php:602
dispBoardWriteComment()
display comment wirte form
Definition: board.view.php:827
dispBoardWrite()
display document write form
Definition: board.view.php:644
$module_srl
integer value to represent a run-time instance of Module (XE Module)
dispBoardDelete()
display board module deletion form
Definition: board.view.php:779
$args
Definition: ko.install.php:185
$module_info
an object containing the module information
$page_count
page number
Definition: board.class.php:18
dispBoardDeleteComment()
display the delete comment form
Definition: board.view.php:982
$document_srl
Definition: ko.install.php:279
addJsFile($file, $optimized=FALSE, $targetie= '', $index=0, $type= 'head', $isRuleset=FALSE, $autoPath=null)
addBrowserTitle($site_title)
init()
initialization board module can be used in either normal mode or admin mode.
Definition: board.view.php:18
$oDocumentModel
Definition: ko.install.php:259
dispBoardContentCommentList()
display the document comment list (can be used by API)
Definition: board.view.php:418
getLang($code)
dispBoardReplyComment()
display comment replies page
Definition: board.view.php:873
$oDocumentController
Definition: ko.install.php:260
$obj module_srl
Definition: ko.install.php:270
$list_count
the number of documents displayed in a page
Definition: board.class.php:17
getModel($module_name)
Definition: func.inc.php:145
dispBoardCategoryList()
display the category list
Definition: board.view.php:221
addJsFilter($path, $filename)
dispBoardContentView()
display the board conent view
Definition: board.view.php:243
board module high class
Definition: board.class.php:10
addHtmlFooter($footer)
dispBoardContentFileList()
display the document file list (can be used by API)
Definition: board.view.php:351
dispBoardDeleteTrackback()
display the delete trackback form
dispBoardMessage($msg_code)
display board message
_makeListColumnList()
Definition: board.view.php:559