This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
board.view.php
960 lines (817 loc) · 25.8 KB
/
board.view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class boardView
* @author NAVER (developers@xpressengine.com)
* @brief board module View class
**/
class boardView extends board
{
var $listConfig;
var $columnList;
/**
* @brief initialization
* board module can be used in either normal mode or admin mode.\n
**/
function init()
{
$oSecurity = new Security();
$oSecurity->encodeHTML('document_srl', 'comment_srl', 'vid', 'mid', 'page', 'category', 'search_target', 'search_keyword', 'sort_index', 'order_type', 'trackback_srl');
/**
* setup the module general information
**/
if($this->module_info->list_count)
{
$this->list_count = $this->module_info->list_count;
}
if($this->module_info->search_list_count)
{
$this->search_list_count = $this->module_info->search_list_count;
}
if($this->module_info->page_count)
{
$this->page_count = $this->module_info->page_count;
}
$this->except_notice = $this->module_info->except_notice == 'N' ? FALSE : TRUE;
// $this->_getStatusNameListecret option backward compatibility
$oDocumentModel = getModel('document');
$statusList = $this->_getStatusNameList($oDocumentModel);
if(isset($statusList['SECRET']))
{
$this->module_info->secret = 'Y';
}
// use_category <=1.5.x, hide_category >=1.7.x
$count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl));
if($count_category && ($this->module_info->hide_category != 'Y' || $this->module_info->use_category != 'N'))
{
$this->module_info->hide_category = 'N';
$this->module_info->use_category = 'Y';
}
else
{
$this->module_info->hide_category = 'Y';
$this->module_info->use_category = 'N';
}
/**
* check the consultation function, if the user is admin then swich off consultation function
* if the user is not logged, then disppear write document/write comment./ view document
**/
if($this->module_info->consultation == 'Y' && !$this->grant->manager)
{
$this->consultation = TRUE;
if(!Context::get('is_logged'))
{
$this->grant->list = FALSE;
$this->grant->write_document = FALSE;
$this->grant->write_comment = FALSE;
$this->grant->view = FALSE;
}
}
else
{
$this->consultation = FALSE;
}
/**
* setup the template path based on the skin
* the default skin is default
**/
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
if(!is_dir($template_path)||!$this->module_info->skin)
{
$this->module_info->skin = 'default';
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
}
$this->setTemplatePath($template_path);
/**
* use context::set to setup extra variables
**/
$oDocumentModel = getModel('document');
$extra_keys = $oDocumentModel->getExtraKeys($this->module_info->module_srl);
Context::set('extra_keys', $extra_keys);
/**
* add extra variables to order(sorting) target
**/
if (is_array($extra_keys))
{
foreach($extra_keys as $val)
{
$this->order_target[] = $val->eid;
}
}
/**
* load javascript, JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'input_password.xml');
Context::addJsFile($this->module_path.'tpl/js/board.js');
// remove [document_srl]_cpage from get_vars
$args = Context::getRequestVars();
foreach($args as $name => $value)
{
if(preg_match('/[0-9]+_cpage/', $name))
{
Context::set($name, '', TRUE);
Context::set($name, $value);
}
}
}
/**
* @brief display board contents
**/
function dispBoardContent()
{
/**
* check the access grant (all the grant has been set by the module object)
**/
if(!$this->grant->access || !$this->grant->list)
{
return $this->dispBoardMessage('msg_not_permitted');
}
/**
* display the category list, and then setup the category list on context
**/
$this->dispBoardCategoryList();
/**
* display the search options on the screen
* add extra vaiables to the search options
**/
// use search options on the template (the search options key has been declared, based on the language selected)
foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
$extra_keys = Context::get('extra_keys');
if($extra_keys)
{
foreach($extra_keys as $key => $val)
{
if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
}
}
Context::set('search_option', $search_option);
$oDocumentModel = getModel('document');
$statusNameList = $this->_getStatusNameList($oDocumentModel);
if(count($statusNameList) > 0)
{
Context::set('status_list', $statusNameList);
}
// display the board content
$this->dispBoardContentView();
// list config, columnList setting
$oBoardModel = getModel('board');
$this->listConfig = $oBoardModel->getListConfig($this->module_info->module_srl);
$this->_makeListColumnList();
// display the notice list
$this->dispBoardNoticeList();
// list
$this->dispBoardContentList();
/**
* add javascript filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'search.xml');
$oSecurity = new Security();
$oSecurity->encodeHTML('search_option.');
// setup the tmeplate file
$this->setTemplateFile('list');
}
/**
* @brief display the category list
**/
function dispBoardCategoryList(){
// check if the use_category option is enabled
if($this->module_info->use_category=='Y')
{
$oDocumentModel = getModel('document');
Context::set('category_list', $oDocumentModel->getCategoryList($this->module_srl));
$oSecurity = new Security();
$oSecurity->encodeHTML('category_list.', 'category_list.childs.');
}
}
/**
* @brief display the board conent view
**/
function dispBoardContentView(){
// get the variable value
$document_srl = Context::get('document_srl');
$page = Context::get('page');
// generate document model object
$oDocumentModel = getModel('document');
/**
* if the document exists, then get the document information
**/
if($document_srl)
{
$oDocument = $oDocumentModel->getDocument($document_srl, false, true);
// if the document is existed
if($oDocument->isExists())
{
// if the module srl is not consistent
if($oDocument->get('module_srl')!=$this->module_info->module_srl )
{
return $this->stop('msg_invalid_request');
}
// check the manage grant
if($this->grant->manager) $oDocument->setGrant();
// if the consultation function is enabled, and the document is not a notice
if($this->consultation && !$oDocument->isNotice())
{
$logged_info = Context::get('logged_info');
if($oDocument->get('member_srl')!=$logged_info->member_srl)
{
$oDocument = $oDocumentModel->getDocument(0);
}
}
}
else
{
// if the document is not existed, then alert a warning message
Context::set('document_srl','',true);
$this->alertMessage('msg_not_founded');
}
/**
* if the document is not existed, get an empty document
**/
}
else
{
$oDocument = $oDocumentModel->getDocument(0);
}
/**
*check the document view grant
**/
if($oDocument->isExists())
{
if(!$this->grant->view && !$oDocument->isGranted())
{
$oDocument = $oDocumentModel->getDocument(0);
Context::set('document_srl','',true);
$this->alertMessage('msg_not_permitted');
}
else
{
// add the document title to the browser
Context::addBrowserTitle($oDocument->getTitleText());
// update the document view count (if the document is not secret)
if(!$oDocument->isSecret() || $oDocument->isGranted())
{
$oDocument->updateReadedCount();
}
// disappear the document if it is secret
if($oDocument->isSecret() && !$oDocument->isGranted())
{
$oDocument->add('content',Context::getLang('thisissecret'));
}
}
}
// setup the document oject on context
$oDocument->add('module_srl', $this->module_srl);
Context::set('oDocument', $oDocument);
/**
* add javascript filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
// return new Object();
}
/**
* @brief display the document file list (can be used by API)
**/
function dispBoardContentFileList(){
$oDocumentModel = getModel('document');
$document_srl = Context::get('document_srl');
$oDocument = $oDocumentModel->getDocument($document_srl);
Context::set('file_list',$oDocument->getUploadedFiles());
$oSecurity = new Security();
$oSecurity->encodeHTML('file_list..source_filename');
}
/**
* @brief display the document comment list (can be used by API)
**/
function dispBoardContentCommentList(){
$oDocumentModel = getModel('document');
$document_srl = Context::get('document_srl');
$oDocument = $oDocumentModel->getDocument($document_srl);
$comment_list = $oDocument->getComments();
// setup the comment list
if(is_array($comment_list))
{
foreach($comment_list as $key => $val)
{
if(!$val->isAccessible())
{
$val->add('content',Context::getLang('thisissecret'));
}
}
}
Context::set('comment_list',$comment_list);
}
/**
* @brief display notice list (can be used by API)
**/
function dispBoardNoticeList(){
$oDocumentModel = getModel('document');
$args = new stdClass();
$args->module_srl = $this->module_srl;
$notice_output = $oDocumentModel->getNoticeList($args, $this->columnList);
Context::set('notice_list', $notice_output->data);
}
/**
* @brief display board content list
**/
function dispBoardContentList(){
// check the grant
if(!$this->grant->list)
{
Context::set('document_list', array());
Context::set('total_count', 0);
Context::set('total_page', 1);
Context::set('page', 1);
Context::set('page_navigation', new PageHandler(0,0,1,10));
return;
}
$oDocumentModel = getModel('document');
// setup module_srl/page number/ list number/ page count
$args = new stdClass();
$args->module_srl = $this->module_srl;
$args->page = Context::get('page');
$args->list_count = $this->list_count;
$args->page_count = $this->page_count;
// get the search target and keyword
$args->search_target = Context::get('search_target');
$args->search_keyword = Context::get('search_keyword');
// if the category is enabled, then get the category
if($this->module_info->use_category=='Y')
{
$args->category_srl = Context::get('category');
}
// setup the sort index and order index
$args->sort_index = Context::get('sort_index');
$args->order_type = Context::get('order_type');
if(!in_array($args->sort_index, $this->order_target))
{
$args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order';
}
if(!in_array($args->order_type, array('asc','desc')))
{
$args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc';
}
// set the current page of documents
$_get = $_GET;
if(!$args->page && ($_GET['document_srl'] || $_GET['entry']))
{
$oDocument = $oDocumentModel->getDocument(Context::get('document_srl'));
if($oDocument->isExists() && !$oDocument->isNotice())
{
$page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $page);
$args->page = $page;
}
}
// setup the list count to be serach list count, if the category or search keyword has been set
if($args->category_srl || $args->search_keyword)
{
$args->list_count = $this->search_list_count;
}
// if the consultation function is enabled, the get the logged user information
if($this->consultation)
{
$logged_info = Context::get('logged_info');
$args->member_srl = $logged_info->member_srl;
}
// setup the list config variable on context
Context::set('list_config', $this->listConfig);
// setup document list variables on context
$output = $oDocumentModel->getDocumentList($args, $this->except_notice, TRUE, $this->columnList);
Context::set('document_list', $output->data);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_navigation', $output->page_navigation);
}
function _makeListColumnList()
{
$configColumList = array_keys($this->listConfig);
$tableColumnList = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice',
'title', 'title_bold', 'title_color', 'content', 'readed_count', 'voted_count',
'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'password', 'user_id',
'user_name', 'nick_name', 'member_srl', 'email_address', 'homepage', 'tags', 'extra_vars',
'regdate', 'last_update', 'last_updater', 'ipaddress', 'list_order', 'update_order',
'allow_trackback', 'notify_message', 'status', 'comment_status');
$this->columnList = array_intersect($configColumList, $tableColumnList);
if(in_array('summary', $configColumList)) array_push($this->columnList, 'content');
// default column list add
$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');
//TODO guestbook, blog style supports legacy codes.
if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog')
{
$defaultColumn = $tableColumnList;
}
if (in_array('last_post', $configColumList)){
array_push($this->columnList, 'last_updater');
}
// add is_notice
if ($this->except_notice)
{
array_push($this->columnList, 'is_notice');
}
$this->columnList = array_unique(array_merge($this->columnList, $defaultColumn));
// add table name
foreach($this->columnList as $no => $value)
{
$this->columnList[$no] = 'documents.' . $value;
}
}
/**
* @brief display tag list
**/
function dispBoardTagList()
{
// check if there is not grant fot view list, then alert an warning message
if(!$this->grant->list)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// generate the tag module model object
$oTagModel = getModel('tag');
$obj = new stdClass;
$obj->mid = $this->module_info->mid;
$obj->list_count = 10000;
$output = $oTagModel->getTagList($obj);
// automatically order
if(count($output->data))
{
$numbers = array_keys($output->data);
shuffle($numbers);
if(count($output->data))
{
foreach($numbers as $k => $v)
{
$tag_list[] = $output->data[$v];
}
}
}
Context::set('tag_list', $tag_list);
$oSecurity = new Security();
$oSecurity->encodeHTML('tag_list.');
$this->setTemplateFile('tag_list');
}
/**
* @brief display document write form
**/
function dispBoardWrite()
{
// check grant
if(!$this->grant->write_document)
{
return $this->dispBoardMessage('msg_not_permitted');
}
$oDocumentModel = getModel('document');
/**
* check if the category option is enabled not not
**/
if($this->module_info->use_category=='Y')
{
// get the user group information
if(Context::get('is_logged'))
{
$logged_info = Context::get('logged_info');
$group_srls = array_keys($logged_info->group_list);
}
else
{
$group_srls = array();
}
$group_srls_count = count($group_srls);
// check the grant after obtained the category list
$normal_category_list = $oDocumentModel->getCategoryList($this->module_srl);
if(count($normal_category_list))
{
foreach($normal_category_list as $category_srl => $category)
{
$is_granted = TRUE;
if($category->group_srls)
{
$category_group_srls = explode(',',$category->group_srls);
$is_granted = FALSE;
if(count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE;
}
if($is_granted) $category_list[$category_srl] = $category;
}
}
Context::set('category_list', $category_list);
}
// GET parameter document_srl from request
$document_srl = Context::get('document_srl');
$oDocument = $oDocumentModel->getDocument(0, $this->grant->manager);
$oDocument->setDocument($document_srl);
if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE;
$oDocument->add('module_srl', $this->module_srl);
if($oDocument->isExists() && $this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
{
return new Object(-1, 'msg_protect_content');
}
// if the document is not granted, then back to the password input form
$oModuleModel = getModel('module');
if($oDocument->isExists()&&!$oDocument->isGranted())
{
return $this->setTemplateFile('input_password_form');
}
if(!$oDocument->isExists())
{
$point_config = $oModuleModel->getModulePartConfig('point',$this->module_srl);
$logged_info = Context::get('logged_info');
$oPointModel = getModel('point');
$pointForInsert = $point_config["insert_document"];
if($pointForInsert < 0)
{
if( !$logged_info )
{
return $this->dispBoardMessage('msg_not_permitted');
}
else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
{
return $this->dispBoardMessage('msg_not_enough_point');
}
}
}
if(!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus());
$statusList = $this->_getStatusNameList($oDocumentModel);
if(count($statusList) > 0) Context::set('status_list', $statusList);
// get Document status config value
Context::set('document_srl',$document_srl);
Context::set('oDocument', $oDocument);
// apply xml_js_filter on header
$oDocumentController = getController('document');
$oDocumentController->addXmlJsFilter($this->module_info->module_srl);
// if the document exists, then setup extra variabels on context
if($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars());
/**
* add JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
$oSecurity = new Security();
$oSecurity->encodeHTML('category_list.text', 'category_list.title');
$this->setTemplateFile('write_form');
}
function _getStatusNameList(&$oDocumentModel)
{
$resultList = array();
if(!empty($this->module_info->use_status))
{
$statusNameList = $oDocumentModel->getStatusNameList();
$statusList = explode('|@|', $this->module_info->use_status);
if(is_array($statusList))
{
foreach($statusList as $key => $value)
{
$resultList[$value] = $statusNameList[$value];
}
}
}
return $resultList;
}
/**
* @brief display board module deletion form
**/
function dispBoardDelete()
{
// check grant
if(!$this->grant->write_document)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// get the document_srl from request
$document_srl = Context::get('document_srl');
// if document exists, get the document information
if($document_srl)
{
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
}
// if the document is not existed, then back to the board content page
if(!$oDocument->isExists())
{
return $this->dispBoardContent();
}
// if the document is not granted, then back to the password input form
if(!$oDocument->isGranted())
{
return $this->setTemplateFile('input_password_form');
}
if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
{
return $this->dispBoardMessage('msg_protect_content');
}
Context::set('oDocument',$oDocument);
/**
* add JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_document.xml');
$this->setTemplateFile('delete_form');
}
/**
* @brief display comment wirte form
**/
function dispBoardWriteComment()
{
$document_srl = Context::get('document_srl');
// check grant
if(!$this->grant->write_comment)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// get the document information
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists())
{
return $this->dispBoardMessage('msg_invalid_request');
}
// Check allow comment
if(!$oDocument->allowComment())
{
return $this->dispBoardMessage('msg_not_allow_comment');
}
// obtain the comment (create an empty comment document for comment_form usage)
$oCommentModel = getModel('comment');
$oSourceComment = $oComment = $oCommentModel->getComment(0);
$oComment->add('document_srl', $document_srl);
$oComment->add('module_srl', $this->module_srl);
// setup document variables on context
Context::set('oDocument',$oDocument);
Context::set('oSourceComment',$oSourceComment);
Context::set('oComment',$oComment);
/**
* add JS filter
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
/**
* @brief display comment replies page
**/
function dispBoardReplyComment()
{
// check grant
if(!$this->grant->write_comment)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// get the parent comment ID
$parent_srl = Context::get('comment_srl');
// if the parent comment is not existed
if(!$parent_srl)
{
return new Object(-1, 'msg_invalid_request');
}
// get the comment
$oCommentModel = getModel('comment');
$oSourceComment = $oCommentModel->getComment($parent_srl, $this->grant->manager);
// if the comment is not existed, opoup an error message
if(!$oSourceComment->isExists())
{
return $this->dispBoardMessage('msg_invalid_request');
}
if(Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl'))
{
return $this->dispBoardMessage('msg_invalid_request');
}
// Check allow comment
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($oSourceComment->get('document_srl'));
if(!$oDocument->allowComment())
{
return $this->dispBoardMessage('msg_not_allow_comment');
}
// get the comment information
$oComment = $oCommentModel->getComment();
$oComment->add('parent_srl', $parent_srl);
$oComment->add('document_srl', $oSourceComment->get('document_srl'));
// setup comment variables
Context::set('oSourceComment',$oSourceComment);
Context::set('oComment',$oComment);
Context::set('module_srl',$this->module_info->module_srl);
/**
* add JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
/**
* @brief display the comment modification from
**/
function dispBoardModifyComment()
{
// check grant
if(!$this->grant->write_comment)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// get the document_srl and comment_srl
$document_srl = Context::get('document_srl');
$comment_srl = Context::get('comment_srl');
// if the comment is not existed
if(!$comment_srl)
{
return new Object(-1, 'msg_invalid_request');
}
// get comment information
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
// if the comment is not exited, alert an error message
if(!$oComment->isExists())
{
return $this->dispBoardMessage('msg_invalid_request');
}
// if the comment is not granted, then back to the password input form
if(!$oComment->isGranted())
{
return $this->setTemplateFile('input_password_form');
}
// setup the comment variables on context
Context::set('oSourceComment', $oCommentModel->getComment());
Context::set('oComment', $oComment);
/**
* add JS fitlers
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_comment.xml');
$this->setTemplateFile('comment_form');
}
/**
* @brief display the delete comment form
**/
function dispBoardDeleteComment()
{
// check grant
if(!$this->grant->write_comment)
{
return $this->dispBoardMessage('msg_not_permitted');
}
// get the comment_srl to be deleted
$comment_srl = Context::get('comment_srl');
// if the comment exists, then get the comment information
if($comment_srl)
{
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
}
// if the comment is not existed, then back to the board content page
if(!$oComment->isExists() )
{
return $this->dispBoardContent();
}
// if the comment is not granted, then back to the password input form
if(!$oComment->isGranted())
{
return $this->setTemplateFile('input_password_form');
}
Context::set('oComment',$oComment);
/**
* add JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_comment.xml');
$this->setTemplateFile('delete_comment_form');
}
/**
* @brief display the delete trackback form
**/
function dispBoardDeleteTrackback()
{
$oTrackbackModel = getModel('trackback');
if(!$oTrackbackModel)
{
return;
}
// get the trackback_srl
$trackback_srl = Context::get('trackback_srl');
// get the trackback data
$columnList = array('trackback_srl');
$output = $oTrackbackModel->getTrackback($trackback_srl, $columnList);
$trackback = $output->data;
// if no trackback, then display the board content
if(!$trackback)
{
return $this->dispBoardContent();
}
//Context::set('trackback',$trackback); //perhaps trackback variables not use in UI
/**
* add JS filters
**/
Context::addJsFilter($this->module_path.'tpl/filter', 'delete_trackback.xml');
$this->setTemplateFile('delete_trackback_form');
}
/**
* @brief display board message
**/
function dispBoardMessage($msg_code)
{
$msg = Context::getLang($msg_code);
if(!$msg) $msg = $msg_code;
Context::set('message', $msg);
$this->setTemplateFile('message');
}
/**
* @brief the method for displaying the warning messages
* display an error message if it has not a special design
**/
function alertMessage($message)
{
$script = sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message));
Context::addHtmlFooter( $script );
}
}