From 4bbd91bd3c831671cd36f001bda1c08ed46da395 Mon Sep 17 00:00:00 2001 From: MinSoo Kim Date: Fri, 29 Jan 2016 01:22:09 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=8B=A0=EA=B3=A0?= =?UTF-8?q?=EC=8B=9C=20=EC=8B=A0=EA=B3=A0=20=EC=9D=B4=EC=9C=A0=EB=A5=BC=20?= =?UTF-8?q?=EC=A0=81=EC=9D=84=20=EC=88=98=20=EC=9E=88=EA=B2=8C=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 댓글에도 신고 이유를 적을 수 있다. - 코드 정리 --- modules/comment/comment.admin.view.php | 44 ++++++++++++ modules/comment/comment.class.php | 12 ++++ modules/comment/comment.controller.php | 28 +++++++- modules/comment/comment.model.php | 4 +- modules/comment/comment.view.php | 38 ++++++++++ modules/comment/conf/module.xml | 10 ++- modules/comment/lang/lang.xml | 50 +++++++++++++ .../queries/getDeclaredLogByCommentSrl.xml | 17 +++++ .../queries/insertCommentDeclaredLog.xml | 19 ++--- .../comment/schemas/comment_declared_log.xml | 9 +-- modules/comment/tpl/css/declare_comment.css | 19 +++++ modules/comment/tpl/declare_comment.html | 55 ++++++++++++++ modules/comment/tpl/declared_list.html | 2 +- modules/comment/tpl/declared_log.html | 71 +++++++++++++++++++ modules/document/document.admin.view.php | 4 +- modules/document/document.controller.php | 53 ++++++++++---- modules/document/document.view.php | 17 +++-- modules/document/lang/lang.xml | 4 +- 18 files changed, 415 insertions(+), 41 deletions(-) create mode 100644 modules/comment/queries/getDeclaredLogByCommentSrl.xml create mode 100644 modules/comment/tpl/css/declare_comment.css create mode 100644 modules/comment/tpl/declare_comment.html create mode 100644 modules/comment/tpl/declared_log.html diff --git a/modules/comment/comment.admin.view.php b/modules/comment/comment.admin.view.php index 3cb165997..0ea4d7bb3 100644 --- a/modules/comment/comment.admin.view.php +++ b/modules/comment/comment.admin.view.php @@ -140,6 +140,50 @@ class commentAdminView extends comment $this->setTemplateFile('declared_list'); } + /** + * Display a reported comment and log of reporting + * @return void + */ + function dispCommentAdminDeclaredLogByCommentSrl() + { + // option for a list + $args = new stdClass; + $args->page = Context::get('page'); // /< Page + $args->list_count = 30; // /< the number of posts to display on a single page + $args->page_count = 10; // /< the number of pages that appear in the page navigation + $args->comment_srl = intval(Context::get('target_srl')); + + + // get Status name list + $oCommentModel = getModel('comment'); + $oMemberModel = getModel('member'); + $oComment = $oCommentModel->getComment($args->comment_srl); + + $declared_output = executeQuery('comment.getDeclaredLogByCommentSrl', $args); + if($declared_output->data && count($declared_output->data)) + { + $reporter_list = array(); + + foreach($declared_output->data as $key => $log) + { + $reporter_list[$log->member_srl] = $oMemberModel->getMemberInfoByMemberSrl($log->member_srl); + } + } + + // Set values of document_model::getDocumentList() objects for a template + Context::set('total_count', $declared_output->total_count); + Context::set('total_page', $declared_output->total_page); + Context::set('page', $declared_output->page); + Context::set('declare_log', $declared_output->data); + Context::set('reporter_list', $reporter_list); + Context::set('declared_comment', $oComment); + Context::set('page_navigation', $declared_output->page_navigation); + + // Set the template + $this->setLayoutFile('popup_layout'); + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('declared_log'); + } } /* End of file comment.admin.view.php */ /* Location: ./modules/comment/comment.admin.view.php */ diff --git a/modules/comment/comment.class.php b/modules/comment/comment.class.php index 808130b15..494512bd8 100644 --- a/modules/comment/comment.class.php +++ b/modules/comment/comment.class.php @@ -101,6 +101,12 @@ class comment extends ModuleObject return TRUE; } + // 2016. 1. 29: Add a column(declare_message) for report + if(!$oDB->isColumnExists("comment_declared_log","declare_message")) + { + return true; + } + return FALSE; } @@ -175,6 +181,12 @@ class comment extends ModuleObject $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'); } + // 2016. 1. 29: Add a column(declare_message) for report + if(!$oDB->isColumnExists("comment_declared_log","declare_message")) + { + $oDB->addColumn('comment_declared_log',"declare_message","text"); + } + return new Object(0, 'success_updated'); } diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 7d62bce1d..8157d1a2d 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -205,7 +205,19 @@ class commentController extends comment return new Object(-1, 'msg_invalid_request'); } - return $this->declaredComment($comment_srl); + // if an user select message from options, message would be the option. + $message_option = strval(Context::get('message_option')); + $improper_comment_reasons = Context::getLang('improper_comment_reasons'); + $declare_message = ($message_option !== 'others' && isset($improper_comment_reasons[$message_option]))? + $improper_comment_reasons[$message_option] : trim(Context::get('declare_message')); + + // if there is return url, set that. + if(Context::get('success_return_url')) + { + $this->setRedirectUrl(Context::get('success_return_url')); + } + + return $this->declaredComment($comment_srl, $declare_message); } /** @@ -1304,9 +1316,10 @@ class commentController extends comment /** * Report a blamed comment * @param $comment_srl + * @param string $declare_message * @return void */ - function declaredComment($comment_srl) + function declaredComment($comment_srl, $declare_message) { // Fail if session information already has a reported document if($_SESSION['declared_comment'][$comment_srl]) @@ -1322,6 +1335,7 @@ class commentController extends comment { return $output; } + $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; $trigger_obj = new stdClass(); @@ -1370,7 +1384,9 @@ class commentController extends comment { $args->ipaddress = $_SERVER['REMOTE_ADDR']; } + $args->comment_srl = $comment_srl; + $args->declare_message = trim(htmlspecialchars($declare_message)); $log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args); // session registered if log info contains report log. @@ -1402,6 +1418,13 @@ class commentController extends comment // leave the log $output = executeQuery('comment.insertCommentDeclaredLog', $args); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + + $this->add('declared_count', $declared_count + 1); // Call a trigger (after) $trigger_obj->declared_count = $declared_count + 1; @@ -1412,6 +1435,7 @@ class commentController extends comment return $trigger_output; } + // commit $oDB->commit(); // leave into the session information diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 01a483738..09ca6be0f 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -69,8 +69,8 @@ class commentModel extends comment } // Add the report feature against abused posts - $url = sprintf("doCallModuleAction('comment','procCommentDeclare','%s')", $comment_srl); - $oCommentController->addCommentPopupMenu($url, 'cmd_declare', '', 'javascript'); + $url = getUrl('', 'act', 'dispCommentDeclare', 'target_srl', $comment_srl); + $oCommentController->addCommentPopupMenu($url, 'cmd_declare', '', 'popup'); } // call a trigger (after) diff --git a/modules/comment/comment.view.php b/modules/comment/comment.view.php index 0e2cb92aa..5f59da78f 100644 --- a/modules/comment/comment.view.php +++ b/modules/comment/comment.view.php @@ -60,6 +60,44 @@ class commentView extends comment return new Object(); } + /** + * Report an improper comment + * @return void + */ + function dispCommentDeclare() + { + $this->setLayoutFile('popup_layout'); + $comment_srl = Context::get('target_srl'); + + $oMemberModel = getModel('member'); + // A message appears if the user is not logged-in + if(!$oMemberModel->isLogged()) + { + return $this->stop('msg_not_logged'); + } + + // Create the comment object. + $oCommentModel = getModel('comment'); + // Creates an object for displaying the selected comment + $oComment = $oCommentModel->getComment($comment_srl); + if(!$oComment->isExists()) + { + return new Object(-1,'msg_invalid_request'); + } + // Check permissions + if(!$oComment->isAccessible()) + { + return new Object(-1,'msg_not_permitted'); + } + + // Browser title settings + Context::set('target_comment', $oComment); + + Context::set('target_srl', $comment_srl); + + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('declare_comment'); + } } /* End of file comment.view.php */ /* Location: ./modules/comment/comment.view.php */ diff --git a/modules/comment/conf/module.xml b/modules/comment/conf/module.xml index d13854c26..9ea9f287c 100644 --- a/modules/comment/conf/module.xml +++ b/modules/comment/conf/module.xml @@ -1,4 +1,4 @@ - + @@ -8,17 +8,25 @@ + + + + + + + + diff --git a/modules/comment/lang/lang.xml b/modules/comment/lang/lang.xml index ed45f3151..6fe6ea89d 100644 --- a/modules/comment/lang/lang.xml +++ b/modules/comment/lang/lang.xml @@ -324,4 +324,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/comment/queries/getDeclaredLogByCommentSrl.xml b/modules/comment/queries/getDeclaredLogByCommentSrl.xml new file mode 100644 index 000000000..ae8a13bb3 --- /dev/null +++ b/modules/comment/queries/getDeclaredLogByCommentSrl.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/modules/comment/queries/insertCommentDeclaredLog.xml b/modules/comment/queries/insertCommentDeclaredLog.xml index 07510dd0c..f2ceba3c7 100644 --- a/modules/comment/queries/insertCommentDeclaredLog.xml +++ b/modules/comment/queries/insertCommentDeclaredLog.xml @@ -1,11 +1,12 @@ - -
- - - - - - - + +
+ + + + + + + + diff --git a/modules/comment/schemas/comment_declared_log.xml b/modules/comment/schemas/comment_declared_log.xml index bf1f4a7d7..2d9df72a5 100644 --- a/modules/comment/schemas/comment_declared_log.xml +++ b/modules/comment/schemas/comment_declared_log.xml @@ -1,6 +1,7 @@
- - - - + + + + +
diff --git a/modules/comment/tpl/css/declare_comment.css b/modules/comment/tpl/css/declare_comment.css new file mode 100644 index 000000000..5e6e52041 --- /dev/null +++ b/modules/comment/tpl/css/declare_comment.css @@ -0,0 +1,19 @@ +@charset "UTF-8"; +div.xe_mobile { + display:none!important; +} +section.declare_comment{ + display:block; +} +section.declare_comment label{ + font-weight: bold; +} +section.declare_comment select,section.declare_comment textarea{ + box-sizing:border-box; + height:auto; + width: 100%; + padding:7px; + font-size: 11pt; + line-height: normal; + display:block; +} \ No newline at end of file diff --git a/modules/comment/tpl/declare_comment.html b/modules/comment/tpl/declare_comment.html new file mode 100644 index 000000000..f5f4e1dba --- /dev/null +++ b/modules/comment/tpl/declare_comment.html @@ -0,0 +1,55 @@ +{@Context::addMetaTag('viewport', 'width=device-width, user-scalable=no', FALSE);} + +
+

{$XE_VALIDATOR_MESSAGE}

+
+
+

{$lang->improper_comment_declare}

+
+ + + + + +
+
+

{$lang->replies}

+

{$target_comment->getSummary(200)}

+
+
+ +
+ + +

{$lang->about_improper_comment_declare}

+

+
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/modules/comment/tpl/declared_list.html b/modules/comment/tpl/declared_list.html index 34aa58508..14a3a0b2f 100644 --- a/modules/comment/tpl/declared_list.html +++ b/modules/comment/tpl/declared_list.html @@ -45,7 +45,7 @@ {$oComment->getSummary(100)} {$oComment->getNickName()} {$oComment->getRegdate("Y-m-d")} - {$oComment->get('declared_count')} + {$oComment->get('declared_count')} ({$lang->improper_comment_declare_reason}) {$oComment->get('ipaddress')} diff --git a/modules/comment/tpl/declared_log.html b/modules/comment/tpl/declared_log.html new file mode 100644 index 000000000..b5cfa6257 --- /dev/null +++ b/modules/comment/tpl/declared_log.html @@ -0,0 +1,71 @@ +

{$lang->improper_comment_declare}

+
+

{$XE_VALIDATOR_MESSAGE}

+
+
+ + +
+
+

{$lang->replies}

+

{$declared_comment->getSummary(200)}

+
{$declared_comment->getNickName()}
+
+
+

{$lang->improper_comment_declare_reason}

+ + + + + + + + + + + + + + + +
{$lang->declaring_user}{$lang->improper_comment_declare_reason}{$lang->date}
{$reporter_list[$log->member_srl]->nick_name} ({$log->ipaddress}){$log->declare_message}{date('Y-m-d H:i:s', strtotime($log->regdate))}
+
+ +
+ + + + + + + +
diff --git a/modules/document/document.admin.view.php b/modules/document/document.admin.view.php index 4be7e52b5..5351aed4c 100644 --- a/modules/document/document.admin.view.php +++ b/modules/document/document.admin.view.php @@ -162,7 +162,7 @@ class documentAdminView extends document } /** - * Display a report list on the admin page + * Display a reported post and log of reporting * @return void */ function dispDocumentAdminDeclaredLogByDocumentSrl() @@ -178,7 +178,6 @@ class documentAdminView extends document // get Status name list $oDocumentModel = getModel('document'); $oMemberModel = getModel('member'); - $statusNameList = $oDocumentModel->getStatusNameList(); $oDocument = $oDocumentModel->getDocument($args->document_srl); $declared_output = executeQuery('document.getDeclaredLogByDocumentSrl', $args); @@ -200,7 +199,6 @@ class documentAdminView extends document Context::set('reporter_list', $reporter_list); Context::set('declared_document', $oDocument); Context::set('page_navigation', $declared_output->page_navigation); - Context::set('status_name_list', $statusNameList); // Set the template $this->setLayoutFile('popup_layout'); diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index f0c35ee0f..7864248a5 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -192,15 +192,24 @@ class documentController extends document */ function procDocumentDeclare() { - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + if(!Context::get('is_logged')) + { + return new Object(-1, 'msg_not_logged'); + } + $document_srl = intval(Context::get('target_srl')); + if(!$document_srl) + { + return new Object(-1, 'msg_invalid_request'); + } + + // if an user select message from options, message would be the option. + $message_option = strval(Context::get('message_option')); $improper_document_reasons = Context::getLang('improper_document_reasons'); + $declare_message = ($message_option !== 'others' && isset($improper_document_reasons[$message_option]))? + $improper_document_reasons[$message_option] : trim(Context::get('declare_message')); - $document_srl = Context::get('target_srl'); - $message_option = Context::get('message_option'); - $declare_message = ($message_option !== 'others' && isset($improper_document_reasons[$message_option]))? $improper_document_reasons[$message_option] : Context::get('declare_message'); - if(!$document_srl) return new Object(-1, 'msg_invalid_request'); - + // if there is return url, set that. if(Context::get('success_return_url')) { $this->setRedirectUrl(Context::get('success_return_url')); @@ -1374,13 +1383,19 @@ class documentController extends document function declaredDocument($document_srl, $declare_message = '') { // Fail if session information already has a reported document - if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); + if($_SESSION['declared_document'][$document_srl]) + { + return new Object(-1, 'failed_declared'); + } // Check if previously reported $args = new stdClass(); $args->document_srl = $document_srl; $output = executeQuery('document.getDeclaredDocument', $args); - if(!$output->toBool()) return $output; + if(!$output->toBool()) + { + return $output; + } $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; @@ -1400,7 +1415,8 @@ class documentController extends document $oDocument = $oDocumentModel->getDocument($document_srl, false, false); // Pass if the author's IP address is as same as visitor's. - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { + if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) + { $_SESSION['declared_document'][$document_srl] = true; return new Object(-1, 'failed_declared'); } @@ -1446,9 +1462,20 @@ class documentController extends document $oDB->begin(); // Add the declared document - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); - else $output = executeQuery('document.insertDeclaredDocument', $args); - if(!$output->toBool()) return $output; + if($declared_count > 0) + { + $output = executeQuery('document.updateDeclaredDocument', $args); + } + else + { + $output = executeQuery('document.insertDeclaredDocument', $args); + } + + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } // Leave logs $output = executeQuery('document.insertDocumentDeclaredLog', $args); @@ -1458,7 +1485,7 @@ class documentController extends document return $output; } - $this->add('declared_count', $declared_count+1); + $this->add('declared_count', $declared_count + 1); // Call a trigger (after) $trigger_obj->declared_count = $declared_count + 1; diff --git a/modules/document/document.view.php b/modules/document/document.view.php index e18170a8a..f7a0e447b 100644 --- a/modules/document/document.view.php +++ b/modules/document/document.view.php @@ -176,7 +176,7 @@ class documentView extends document } /** - * Document temp saved list + * Report an improper post * @return void */ function dispDocumentDeclare() @@ -186,15 +186,24 @@ class documentView extends document $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) + { + return $this->stop('msg_not_logged'); + } // Create the document object. If the document module of basic data structures, write it all works .. -_-; $oDocumentModel = getModel('document'); // Creates an object for displaying the selected document $oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager, FALSE); - if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); + if(!$oDocument->isExists()) + { + return new Object(-1,'msg_invalid_request'); + } // Check permissions - if(!$oDocument->isAccessible()) return new Object(-1,'msg_not_permitted'); + if(!$oDocument->isAccessible()) + { + return new Object(-1,'msg_not_permitted'); + } // Browser title settings Context::set('target_document', $oDocument); diff --git a/modules/document/lang/lang.xml b/modules/document/lang/lang.xml index 6c397c3a8..0bb0d2924 100644 --- a/modules/document/lang/lang.xml +++ b/modules/document/lang/lang.xml @@ -1012,7 +1012,7 @@ - - + +