Skip to content

Commit

Permalink
댓글 관리자 승인 기능 추가.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbs9456 committed Feb 3, 2023
1 parent 2366f3f commit d2b41e8
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 67 deletions.
9 changes: 8 additions & 1 deletion plugins/kboard-comments/class/KBComment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public function isEditor(){
public function isReader(){
if($this->uid){
$board = $this->getBoard();
if($board->meta->comment_permit && $this->status == 'pending_approval'){
return false;
}

if($board->isAdmin()){
// 게시판 관리자 허용
return true;
Expand Down Expand Up @@ -360,7 +364,10 @@ public function getUserDisplay($user_display=''){

$board = $this->getBoard();
if($board->meta->comments_username_masking){
$user_display = sprintf('%s %s', get_avatar($this->getUserID(), 24, '', $this->getObfuscateName()), $this->getObfuscateName());
$user_display = sprintf('%s %s', get_avatar($this->getUserID(), 24, '', $this->getObfuscateName()), $this->getObfuscateName());
}
if($board->meta->comment_permit && $this->status == 'pending_approval'){
$user_display = '승인 대기중';
}
$user_display = apply_filters('kboard_user_display', $user_display, $user_id, $user_name, $type, $builder);
}
Expand Down
31 changes: 27 additions & 4 deletions plugins/kboard-comments/class/KBCommentController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(){
case 'kboard_comment_update': add_action('wp_loaded', array($this, 'update')); break;
}

add_action('wp_ajax_kboard_comments_list_update', array($this, 'comments_list_update'));
add_action('wp_ajax_kboard_comment_like', array($this, 'commentLike'));
add_action('wp_ajax_nopriv_kboard_comment_like', array($this, 'commentLike'));
add_action('wp_ajax_kboard_comment_unlike', array($this, 'commentUnlike'));
Expand Down Expand Up @@ -251,6 +252,10 @@ public function insert(){
}
}

if($board->meta->comment_permit){
$status = 'pending_approval';
}

$comment_list = new KBCommentList($content_uid);
$comment_list->board = $board;
$comment_uid = $comment_list->add($parent_uid, $member_uid, $member_display, $content, $status, $password);
Expand Down Expand Up @@ -405,14 +410,14 @@ public function update(){
}

$_POST = stripslashes_deep($_POST);

$content = isset($_POST['content'])?$_POST['content']:'';
$comment_content = isset($_POST['comment_content'])?$_POST['comment_content']:'';
$content = $content?$content:$comment_content;

$uid = isset($_GET['uid'])?intval($_GET['uid']):'';
$password = isset($_POST['password'])?sanitize_text_field($_POST['password']):'';

if(!$uid){
die("<script>alert('".__('uid is required.', 'kboard-comments')."');history.go(-1);</script>");
}
Expand All @@ -422,11 +427,11 @@ public function update(){
else if(!is_user_logged_in() && !$password){
die("<script>alert('".__('Please log in to continue.', 'kboard-comments')."');history.go(-1);</script>");
}

$comment = new KBComment();
$comment->initWithUID($uid);
$board = $comment->getBoard();

if(!$comment->isEditor() && $comment->password != $password){
die("<script>alert('".__('You do not have permission.', 'kboard-comments')."');history.go(-1);</script>");
}
Expand Down Expand Up @@ -468,6 +473,24 @@ public function update(){
exit;
}

/**
* 댓글 정보 업데이트
*/
public function comments_list_update(){
if(current_user_can('manage_kboard')){
$status = isset($_POST['status']) ? $_POST['status'] : array();
if($status){
foreach($status as $uid=>$status){
$comment = new KBComment();
$comment->initWithUID($uid);
$comment->status = $status;
$comment->update();
}
}
}
exit;
}

/**
* 댓글 좋아요
*/
Expand Down
33 changes: 29 additions & 4 deletions plugins/kboard-comments/class/KBCommentListTable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public function no_items(){

public function get_columns(){
return array(
'cb' => '<input type="checkbox">',
'board_name' => __('Forum', 'kboard-comments'),
'cb' => '<input type="checkbox">',
'board_name' => __('Forum', 'kboard-comments'),
'user_display' => __('Name', 'kboard-comments'),
'content' => __('Content', 'kboard-comments'),
'date' => __('Date', 'kboard-comments')
'content' => __('Content', 'kboard-comments'),
'status' => __('Status', 'kboard-comments'),
'date' => __('Date', 'kboard-comments')
);
}

Expand All @@ -61,6 +62,22 @@ function get_bulk_actions(){
);
}

public function display_tablenav($which){ ?>
<div class="tablenav <?php echo esc_attr($which)?>">
<div class="alignleft actions bulkactions"><?php $this->bulk_actions($which)?></div>
<?php if($which=='top'):?>
<div class="alignleft actions">
<span class="spinner"></span>
</div>
<?php endif?>
<?php
$this->extra_tablenav($which);
$this->pagination($which);
?>
<br class="clear">
</div>
<?php }

public function display_rows(){
foreach($this->items as $item){
$this->single_row($item);
Expand All @@ -70,6 +87,7 @@ public function display_rows(){
public function single_row($item){
$board = new KBoard();
$board->initWithContentUID($item->content_uid);
$selected = $item->status == 'pending_approval' ? 'selected' : '';

$edit_url = admin_url("admin.php?page=kboard_list&board_id={$board->id}");

Expand Down Expand Up @@ -97,6 +115,13 @@ public function single_row($item){
echo $item->content.'<div class="kboard-comments-open"><a href="'.$this->url->getDocumentRedirect($item->content_uid).'" class="button button-small" titlt="'.__('Open', 'kboard-comments').'" onclick="window.open(this.href);return false;">'.__('Open', 'kboard-comments').'</a></div>';
echo '</td>';

echo '<td class="kboard-comments-list-date" data-colname="'.__('Date', 'kboard-comments').'">';
echo '<select name="status['.$item->uid.']" onchange="kboard_comment_list_update()">';
echo '<option value="">발행됨</option>';
echo '<option value="pending_approval" '.$selected.'>승인 대기중</option>';
echo '</select>';
echo '</td>';

echo '<td class="kboard-comments-list-date" data-colname="'.__('Date', 'kboard-comments').'">';
echo date('Y-m-d H:i:s', strtotime($item->created));
echo '</td>';
Expand Down
Binary file modified plugins/kboard-comments/languages/kboard-comments-ko_KR.mo
Binary file not shown.
131 changes: 79 additions & 52 deletions plugins/kboard-comments/languages/kboard-comments-ko_KR.po
Original file line number Diff line number Diff line change
@@ -1,109 +1,114 @@
msgid ""
msgstr ""
"Project-Id-Version: KBoard-comments\n"
"POT-Creation-Date: 2021-02-16 19:17+0900\n"
"PO-Revision-Date: 2021-02-16 19:17+0900\n"
"Last-Translator: Cosmosfarm <[email protected]>\n"
"Project-Id-Version: KBoard : 댓글\n"
"POT-Creation-Date: 2023-02-03 16:15+0900\n"
"PO-Revision-Date: 2023-02-03 16:15+0900\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ko_KR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"X-Poedit-KeywordsList: _;__;gettext;gettext_noop\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 2.2\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
"X-Poedit-WPHeader: index.php\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: ../kboard\n"
"X-Poedit-SearchPathExcluded-0: *.js\n"

#: class/KBComment.class.php:229
#: class/KBComment.class.php:233
msgid "Deleted comment increment points"
msgstr "댓글삭제 증가 포인트"

#: class/KBComment.class.php:241
#: class/KBComment.class.php:245
msgid "Deleted comment decrease points"
msgstr "댓글삭제 감소 포인트"

#: class/KBCommentController.class.php:44
#: class/KBCommentController.class.php:334
#: class/KBCommentController.class.php:395
#: class/KBCommentController.class.php:48
#: class/KBCommentController.class.php:345
#: class/KBCommentController.class.php:409
msgid "This page is restricted from external access."
msgstr "이 페이지는 외부에서의 접근을 제한하고 있습니다."

#: class/KBCommentController.class.php:86
#: class/KBCommentController.class.php:89
#: class/KBCommentController.class.php:92
#: class/KBCommentController.class.php:168
#: class/KBCommentController.class.php:324
#: class/KBCommentController.class.php:352
#: class/KBCommentController.class.php:356
#: class/KBCommentController.class.php:361
#: class/KBCommentController.class.php:366
#: class/KBCommentController.class.php:422
#: class/KBCommentController.class.php:426
#: class/KBCommentController.class.php:431
#: class/KBCommentController.class.php:90
#: class/KBCommentController.class.php:93
#: class/KBCommentController.class.php:96
#: class/KBCommentController.class.php:172
#: class/KBCommentController.class.php:332
#: class/KBCommentController.class.php:363
#: class/KBCommentController.class.php:367
#: class/KBCommentController.class.php:372
#: class/KBCommentController.class.php:377
#: class/KBCommentController.class.php:436
#: class/KBCommentController.class.php:496
#: class/KBCommentController.class.php:534 class/KBCommentTemplate.class.php:34
#: class/KBCommentController.class.php:440
#: class/KBCommentController.class.php:445
#: class/KBCommentController.class.php:450
#: class/KBCommentController.class.php:529
#: class/KBCommentController.class.php:567 class/KBCommentTemplate.class.php:34
#: class/KBCommentTemplate.class.php:88 class/KBCommentTemplate.class.php:107
msgid "You do not have permission."
msgstr "권한이 없습니다."

#: class/KBCommentController.class.php:95 index.php:149
#: class/KBCommentController.class.php:99 index.php:149
msgid "Please enter the author."
msgstr "작성자명을 입력해주세요."

#: class/KBCommentController.class.php:98 index.php:150 template/confirm.php:36
#: class/KBCommentController.class.php:102 index.php:150
#: template/confirm.php:36
msgid "Please enter the password."
msgstr "비밀번호를 입력해주세요."

#: class/KBCommentController.class.php:101
#: class/KBCommentController.class.php:411 index.php:152 template/edit.php:37
#: class/KBCommentController.class.php:105
#: class/KBCommentController.class.php:425 index.php:152 template/edit.php:37
msgid "Please enter the content."
msgstr "내용을 입력해주세요."

#: class/KBCommentController.class.php:104
#: class/KBCommentController.class.php:108
msgid "content_uid is required."
msgstr "content_uid는 필수입니다."

#: class/KBCommentController.class.php:123
#: class/KBCommentController.class.php:143
#: class/KBCommentController.class.php:127
#: class/KBCommentController.class.php:147
#, php-format
msgid "%s is not available."
msgstr "%s는 사용할 수 없습니다."

#: class/KBCommentController.class.php:160
#: class/KBCommentController.class.php:164
msgid "CAPTCHA is invalid."
msgstr "CAPTCHA가 올바르지 않습니다."

#: class/KBCommentController.class.php:173
#: class/KBCommentController.class.php:177
msgid "You have not enough points."
msgstr "포인트가 부족합니다."

#: class/KBCommentController.class.php:179
#: class/KBCommentController.class.php:183
msgid "Writing comment decrease points"
msgstr "댓글쓰기 감소 포인트"

#: class/KBCommentController.class.php:303
#: class/KBCommentController.class.php:311
msgid "Writing comment increase points"
msgstr "댓글쓰기 증가 포인트"

#: class/KBCommentController.class.php:341
#: class/KBCommentController.class.php:408 class/KBCommentTemplate.class.php:24
#: class/KBCommentController.class.php:352
#: class/KBCommentController.class.php:422 class/KBCommentTemplate.class.php:24
#: class/KBCommentTemplate.class.php:78
msgid "uid is required."
msgstr "uid는 필수입니다."

#: class/KBCommentController.class.php:344
#: class/KBCommentController.class.php:414
#: class/KBCommentController.class.php:492
#: class/KBCommentController.class.php:530
#: class/KBCommentController.class.php:355
#: class/KBCommentController.class.php:428
#: class/KBCommentController.class.php:525
#: class/KBCommentController.class.php:563
msgid "Please log in to continue."
msgstr "로그인 하셔야 사용할 수 있습니다."

#: class/KBCommentController.class.php:488
#: class/KBCommentController.class.php:526
#: class/KBCommentController.class.php:521
#: class/KBCommentController.class.php:559
msgid "You have already voted."
msgstr "이미 투표했습니다."

Expand All @@ -115,38 +120,44 @@ msgstr "댓글이 없습니다."
msgid "Forum"
msgstr "게시판"

#: class/KBCommentListTable.class.php:52 class/KBCommentListTable.class.php:87
#: class/KBCommentListTable.class.php:52 class/KBCommentListTable.class.php:105
#: index.php:155
msgid "Name"
msgstr "이름"

#: class/KBCommentListTable.class.php:53 class/KBCommentListTable.class.php:96
#: class/KBCommentListTable.class.php:53 class/KBCommentListTable.class.php:114
#: pages/comments_list.php:17
msgid "Content"
msgstr "내용"

#: class/KBCommentListTable.class.php:54 class/KBCommentListTable.class.php:100
#: class/KBCommentListTable.class.php:54
msgid "Status"
msgstr "상태"

#: class/KBCommentListTable.class.php:55 class/KBCommentListTable.class.php:118
#: class/KBCommentListTable.class.php:125
msgid "Date"
msgstr "작성일"

#: class/KBCommentListTable.class.php:60 skin/default/list-template.php:35
#: class/KBCommentListTable.class.php:61 skin/default/list-template.php:35
#: skin/default/list-template.php:38
msgid "Delete"
msgstr "삭제"

#: class/KBCommentListTable.class.php:82 skin/default/list-template.php:36
#: class/KBCommentListTable.class.php:100 skin/default/list-template.php:36
#: skin/default/list-template.php:39
msgid "Edit"
msgstr "편집"

#: class/KBCommentListTable.class.php:97
#: class/KBCommentListTable.class.php:115
msgid "Open"
msgstr "페이지 열기"

#: class/KBCommentTemplate.class.php:31 class/KBCommentTemplate.class.php:85
msgid "Comment does not exist."
msgstr "댓글이 존재하지 않습니다."

#. Plugin Name of the plugin/theme
#: index.php:16
msgid "KBoard : 댓글"
msgstr "KBoard : 댓글"
Expand Down Expand Up @@ -340,6 +351,22 @@ msgstr "비밀번호 확인"
msgid "Edit content"
msgstr "내용 편집"

#. Plugin URI of the plugin/theme
msgid "https://www.cosmosfarm.com/products/kboard"
msgstr ""

#. Description of the plugin/theme
msgid "워드프레스 KBoard 댓글 플러그인 입니다."
msgstr ""

#. Author of the plugin/theme
msgid "코스모스팜 - Cosmosfarm"
msgstr ""

#. Author URI of the plugin/theme
msgid "https://www.cosmosfarm.com/"
msgstr ""

#~ msgid "Please Log in to continue."
#~ msgstr "로그인 하셔야 사용할 수 있습니다."

Expand Down
Loading

0 comments on commit d2b41e8

Please sign in to comment.