diff --git a/modules/comment/comment.admin.controller.php b/modules/comment/comment.admin.controller.php index 430605ab5..d986da04c 100644 --- a/modules/comment/comment.admin.controller.php +++ b/modules/comment/comment.admin.controller.php @@ -13,6 +13,88 @@ function init() { } + function procCommentAdminChangePublishedStatusChecked() + { + $will_publish = Context::get('will_publish'); + + // Error display if none is selected + $cart = Context::get('cart'); + if(!$cart) + { + return $this->stop('msg_cart_is_null'); + } + if(!is_array($cart)) + { + $comment_srl_list= explode('|@|', $cart); + } + else + { + $comment_srl_list = $cart; + } + $comment_count = count($comment_srl_list); + // begin transaction + + // for message send - start + $message_content = Context::get('message_content'); + if($message_content) $message_content = nl2br($message_content); + + if($message_content) { + $oCommunicationController = &getController('communication'); + $oCommentModel = &getModel('comment'); + + $logged_info = Context::get('logged_info'); + + $title = cut_str($message_content,10,'...'); + $sender_member_srl = $logged_info->member_srl; + + for($i=0;$i<$comment_count;$i++) { + $comment_srl = $comment_srl_list[$i]; + $oComment = $oCommentModel->getComment($comment_srl, true); + + if(!$oComment->get('member_srl') || $oComment->get('member_srl')==$sender_member_srl) continue; + + $content = sprintf("
%s

%s
",$message_content, $oComment->getContentText(20)); + + $oCommunicationController->sendMessage($sender_member_srl, $oComment->get('member_srl'), $title, $content, false); + } + } + // for message send - end + + $args->status = $will_publish; + $args->comment_srls_list = $comment_srl_list; + $output = executeQuery('comment.updatePublishedStatus', $args); + if(!$output->toBool()) return $output; + + //update comment count for document + $updated_documents_arr = array(); + // create the controller object of the document + $oDocumentController = &getController('document'); + // create the comment model object + $oCommentModel = &getModel('comment'); + for($i=0;$i<$comment_count;$i++) + { + $comment_srl = $comment_srl_list[$i]; + // check if comment already exists + $comment = $oCommentModel->getComment($comment_srl); + if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); + $document_srl = $comment->document_srl; + if (!in_array($document_srl,$updated_documents_arr)) + { + $updated_documents_arr[] = $document_srl; + // update the number of comments + $comment_count = $oCommentModel->getCommentCount($document_srl); + // update comment count of the article posting + $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false); + } + } + + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', ''); + header('location:'.$returnUrl); + return; + } + } + /** * @brief Delete the selected comment from the administrator page **/ diff --git a/modules/comment/comment.admin.view.php b/modules/comment/comment.admin.view.php index 8dc146f48..16d64b6bd 100644 --- a/modules/comment/comment.admin.view.php +++ b/modules/comment/comment.admin.view.php @@ -25,18 +25,35 @@ $args->sort_index = 'list_order'; // /< Sorting values $args->module_srl = Context::get('module_srl'); - + /* + $search_target = Context::get('search_target'); + $search_keyword = Context::get('search_keyword'); + if ($search_target == 'is_published' && $search_keyword == 'Y') + { + $args->status = 1; + } + if ($search_target == 'is_published' && $search_keyword == 'N') + { + $args->status = 0; + } + */ + // get a list by using comment->getCommentList. $oCommentModel = &getModel('comment'); $secretNameList = $oCommentModel->getSecretNameList(); - $columnList = array('comment_srl', 'document_srl', 'is_secret', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress'); + $columnList = array('comment_srl', 'document_srl', 'is_secret', 'status', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress'); $output = $oCommentModel->getTotalCommentList($args, $columnList); - + + $oCommentModel = &getModel("comment"); + $modules = $oCommentModel->getDistinctModules(); + $modules_list = $modules; + // set values in the return object of comment_model:: getTotalCommentList() in order to use a template. Context::set('total_count', $output->total_count); Context::set('total_page', $output->total_page); Context::set('page', $output->page); Context::set('comment_list', $output->data); + Context::set('modules_list', $modules_list); Context::set('page_navigation', $output->page_navigation); Context::set('secret_name_list', $secretNameList); // set the template diff --git a/modules/comment/comment.class.php b/modules/comment/comment.class.php index 7300a3645..6fa2ab9e7 100644 --- a/modules/comment/comment.class.php +++ b/modules/comment/comment.class.php @@ -57,7 +57,16 @@ if (!$oDB->isIndexExists("comments", "idx_module_list_order")) return true; - + //2012. 02. 24 add comment published status column and index + if(!$oDB->isColumnExists("comments", "status")) + { + return true; + } + if (!$oDB->isIndexExists("comments", "idx_status")) + { + return true; + } + return false; } @@ -93,7 +102,7 @@ } if(!$oDB->isColumnExists("comment_voted_log", "point")) $oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, true); - + if (!$oDB->isIndexExists("comments", "idx_module_list_order")) $oDB->addIndex ( @@ -103,6 +112,19 @@ true ); + //2012. 02. 24 add comment published status column and index + if(!$oDB->isColumnExists("comments", "status")) { + $oDB->addColumn("comments", "status", "number", 1, 1, true); + } + if (!$oDB->isIndexExists("comments", "idx_status")) + $oDB->addIndex + ( + "comments", + "idx_status", + array("status", "comment_srl", "module_srl", "document_srl"), + true + ); + return new Object(0, 'success_updated'); } diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 86411ee96..f2dbba63c 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -98,11 +98,62 @@ $_SESSION['own_comment'][$comment_srl] = true; } + /** + *@brief Check if module is using comment validation system + * @param number $document_srl + * @return boolean + */ + function isModuleUsingPublishValidation($document_srl=null, $module_srl=null) + { + $oModuleModel = &getModel('module'); + if(!is_null($document_srl)) + { + $module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl); + } + if(!is_null($module_srl)) + { + $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); + } + $module_part_config = $oModuleModel->getModulePartConfig('comment',$module_info->module_srl); + $use_validation = false; + if (isset($module_part_config->use_comment_validation) && $module_part_config->use_comment_validation == "Y") + { + $use_validation = true; + } + return $use_validation; + } + /** * @brief Enter comments **/ function insertComment($obj, $manual_inserted = false) { - $obj->__isupdate = false; + + // check if comment's module is using comment validation and set the publish status to 0 (false) + // for inserting query, otherwhise default is 1 (true - means comment is published) + $using_validation = $this->isModuleUsingPublishValidation($obj->document_srl); + if(Context::get('is_logged')) + { + $logged_info = Context::get('logged_info'); + if ($logged_info->is_admin == 'Y') + { + $is_admin = true; + } + else + { + $is_admin = false; + } + } + + if (!$using_validation || $is_admin) + { + $obj->status = 1; + } + else + { + $obj->status = 0; + } + + $obj->__isupdate = false; // call a trigger (before) $output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj); if(!$output->toBool()) return $output; @@ -195,7 +246,7 @@ } } - + $output = executeQuery('comment.insertCommentList', $list_args); if(!$output->toBool()) return $output; // insert comment @@ -211,7 +262,10 @@ // create the controller object of the document $oDocumentController = &getController('document'); // Update the number of comments in the post - $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, true); + if (!$using_validation || $is_admin) + { + $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, true); + } // grant autority of the comment $this->addGrant($obj->comment_srl); // call a trigger(after) @@ -636,7 +690,10 @@ $comment_config->use_vote_down = Context::get('use_vote_down'); if(!$comment_config->use_vote_down) $comment_config->use_vote_down = 'Y'; - + + $comment_config->use_comment_validation = Context::get('use_comment_validation'); + if(!$comment_config->use_comment_validation) $comment_config->use_comment_validation = 'N'; + for($i=0;$icomment_srls = $comment_srls; - $output = executeQuery('comment.getComments', $args, $columnList); + $output = executeQuery('comment.getComments', $args, $columnList); if(!$output->toBool()) return; $comment_list = $output->data; if(!$comment_list) return; @@ -143,6 +143,15 @@ **/ function getCommentCount($document_srl) { $args->document_srl = $document_srl; + + //check if module is using validation system + $oCommentController = &getController('comment'); + $using_validation = $oCommentController->isModuleUsingPublishValidation($document_srl); + if($using_validation) + { + $args->status = 1; + } + $output = executeQuery('comment.getCommentCount', $args); $total_count = $output->data->count; return (int)$total_count; @@ -164,14 +173,49 @@ /** * @brief get the total number of comments in corresponding with module_srl. **/ - function getCommentAllCount($module_srl) { + function getCommentAllCount($module_srl,$published=null) { $args->module_srl = $module_srl; + + if(is_null($published)) + { + // check if module is using comment validation system + $oCommentController = &getController("comment"); + $is_using_validation = $oCommentController->isModuleUsingPublishValidation(null,$module_srl); + if($is_using_validation) + { + $args->status = 1; + } + } + else + { + if ($published) + { + $args->status = 1; + } + else + { + $args->status = 0; + } + } $output = executeQuery('comment.getCommentCount', $args); $total_count = $output->data->count; return (int)$total_count; } + function getDistinctModules() + { + $output = executeQuery('comment.getDistinctModules'); + $module_srls = $output->data; + $oModuleModel = &getModel('module'); + $result = array(); + foreach($module_srls as $module) + { + $module_info = $oModuleModel->getModuleInfoByModuleSrl($module->module_srl); + $result[$module->module_srl] = $module_info->mid; + } + return $result; + } /** * @brief get the comment in corresponding with mid. @@ -195,6 +239,17 @@ $output = $oCacheHandler->get($cache_key); } if(!$output){ + + if(strpos($args->module_srl,",")===false) + { + // check if module is using comment validation system + $oCommentController = &getController("comment"); + $is_using_validation = $oCommentController->isModuleUsingPublishValidation(null,$obj->module_srl); + if($is_using_validation) + { + $args->status = 1; + } + } $output = executeQuery('comment.getNewestCommentList', $args, $columnList); if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output); } @@ -255,6 +310,16 @@ $args->list_count = $comment_count; $args->page = $page; $args->page_count = 10; + + //check if module is using validation system + $oCommentController = &getController('comment'); + $using_validation = $oCommentController->isModuleUsingPublishValidation($document_srl); + if($using_validation) + { + $args->status = 1; + } + + $output = executeQueryArray('comment.getCommentPageList', $args); // return if an error occurs in the query results if(!$output->toBool()) return; @@ -366,6 +431,15 @@ $args->page_count = $obj->page_count?$obj->page_count:10; $args->s_module_srl = $obj->module_srl; $args->exclude_module_srl = $obj->exclude_module_srl; + + // check if module is using comment validation system + $oCommentController = &getController("comment"); + $is_using_validation = $oCommentController->isModuleUsingPublishValidation(null,$obj->module_srl); + if ($is_using_validation) + { + $args->s_is_published = 1; + } + // Search options $search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target')); $search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword')); @@ -408,7 +482,20 @@ break; case 'is_secret' : $args->s_is_secret= $search_keyword; + break; + case 'is_published' : + if($search_keyword == 'Y') + { + $args->s_is_published = 1; + } + if($search_keyword == 'N') + { + $args->s_is_published = 0; + } break; + case 'module': + $args->s_module_srl = (int)$search_keyword; + break; case 'member_srl' : $args->{"s_".$search_target} = (int)$search_keyword; break; diff --git a/modules/comment/conf/module.xml b/modules/comment/conf/module.xml index 7d2270d7f..99cdcb480 100644 --- a/modules/comment/conf/module.xml +++ b/modules/comment/conf/module.xml @@ -15,7 +15,9 @@ - + + + diff --git a/modules/comment/lang/lang.xml b/modules/comment/lang/lang.xml index 1f95135e0..34126b3de 100644 --- a/modules/comment/lang/lang.xml +++ b/modules/comment/lang/lang.xml @@ -248,6 +248,14 @@ + + + + + + + + @@ -260,4 +268,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/comment/queries/getCommentCount.xml b/modules/comment/queries/getCommentCount.xml index 5d96a887f..6a64300df 100644 --- a/modules/comment/queries/getCommentCount.xml +++ b/modules/comment/queries/getCommentCount.xml @@ -6,7 +6,8 @@ - + + diff --git a/modules/comment/queries/getCommentPageList.xml b/modules/comment/queries/getCommentPageList.xml index 5a43a9320..eb0f747e2 100644 --- a/modules/comment/queries/getCommentPageList.xml +++ b/modules/comment/queries/getCommentPageList.xml @@ -8,12 +8,14 @@ - + + + diff --git a/modules/comment/queries/getDistinctModules.xml b/modules/comment/queries/getDistinctModules.xml new file mode 100644 index 000000000..803de7cea --- /dev/null +++ b/modules/comment/queries/getDistinctModules.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/comment/queries/getNewestCommentList.xml b/modules/comment/queries/getNewestCommentList.xml index 4d1acb679..d477b2a40 100644 --- a/modules/comment/queries/getNewestCommentList.xml +++ b/modules/comment/queries/getNewestCommentList.xml @@ -6,9 +6,11 @@ - + + + diff --git a/modules/comment/queries/getTotalCommentList.xml b/modules/comment/queries/getTotalCommentList.xml index 6c5da970b..3a201e9e6 100644 --- a/modules/comment/queries/getTotalCommentList.xml +++ b/modules/comment/queries/getTotalCommentList.xml @@ -9,6 +9,7 @@ + diff --git a/modules/comment/queries/insertComment.xml b/modules/comment/queries/insertComment.xml index 0e2c25277..5389c1939 100644 --- a/modules/comment/queries/insertComment.xml +++ b/modules/comment/queries/insertComment.xml @@ -24,5 +24,6 @@ + diff --git a/modules/comment/queries/updatePublishedStatus.xml b/modules/comment/queries/updatePublishedStatus.xml new file mode 100644 index 000000000..e1602d469 --- /dev/null +++ b/modules/comment/queries/updatePublishedStatus.xml @@ -0,0 +1,12 @@ + + +
+ + + + + + + + + diff --git a/modules/comment/schemas/comments.xml b/modules/comment/schemas/comments.xml index 8b6898180..7acecd447 100644 --- a/modules/comment/schemas/comments.xml +++ b/modules/comment/schemas/comments.xml @@ -20,4 +20,5 @@ +
diff --git a/modules/comment/tpl/comment_list.html b/modules/comment/tpl/comment_list.html index 6456e9e70..648758bfa 100644 --- a/modules/comment/tpl/comment_list.html +++ b/modules/comment/tpl/comment_list.html @@ -11,9 +11,18 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';

{$lang->comment}

+ @@ -48,6 +62,7 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}'; + @@ -61,6 +76,7 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}'; + @@ -77,6 +93,7 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}'; +

{$lang->comment_manager}

@@ -90,6 +107,7 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}'; + @@ -101,6 +119,14 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';

+ + + + + + + +
diff --git a/modules/comment/tpl/comment_module_config.html b/modules/comment/tpl/comment_module_config.html index b6b2e6443..43b1ace04 100644 --- a/modules/comment/tpl/comment_module_config.html +++ b/modules/comment/tpl/comment_module_config.html @@ -32,6 +32,16 @@ + + + +
@@ -23,6 +32,10 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}'; {$secret_name_list['N']} {$secret_name_list['Y']} + + {$published_name_list['N']} + + {$published_name_list['Y']} ({number_format($total_count)})
@@ -37,6 +50,7 @@ xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';
{$lang->date} {$lang->ipaddress} {$lang->status}{$lang->published}
{$lang->date} {$lang->ipaddress} {$lang->status}{$lang->published}
{(zdate($val->regdate,"Y-m-d\nH:i:s"))} {$val->ipaddress} {$secret_name_list['Y']}{$secret_name_list['N']}{$lang->published_name_list['Y']}{$lang->published_name_list['N']}
{$lang->comment} {$lang->writer} {$lang->status}{$lang->published}
+ +

{$lang->about_comment_validation}

+
diff --git a/modules/comment/tpl/js/comment_admin.js b/modules/comment/tpl/js/comment_admin.js index d83f7cd72..e5d3cc294 100644 --- a/modules/comment/tpl/js/comment_admin.js +++ b/modules/comment/tpl/js/comment_admin.js @@ -40,7 +40,7 @@ function completeGetCommentList(ret_obj, response_tags) { var htmlListBuffer = ''; var statusNameList = {"N":"Public", "Y":"Secret"}; - + var publishedStatusList = {0:'Unpublished', 1:'Published'}; if(ret_obj['comment_list'] == null) { htmlListBuffer = '' + @@ -58,6 +58,7 @@ function completeGetCommentList(ret_obj, response_tags) ''+ objComment.content +'' + ''+ objComment.nick_name +'' + ''+ statusNameList[objComment.is_secret] +'' + + ''+ publishedStatusList[objComment.status] +'' + '' + ''; } @@ -66,6 +67,16 @@ function completeGetCommentList(ret_obj, response_tags) jQuery('#commentManageListTable>tbody').html(htmlListBuffer); } +function doChangePublishedStatus(new_status) +{ + container_div = jQuery("#listManager"); + var act = container_div.find("input[name=act]"); + var will_publish = container_div.find("input[name=will_publish]"); + var action = "procCommentAdminChangePublishedStatusChecked"; + will_publish.val(new_status); + act.val(action); +} + function checkSearch(form) { if(form.search_target.value == '') diff --git a/modules/document/document.item.php b/modules/document/document.item.php index e0d807cf4..4e774948d 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -534,6 +534,7 @@ // Create commentItem object from a comment list // If admin priviledge is granted on parent posts, you can read its child posts. $accessible = array(); + $comment_list = array(); foreach($output->data as $key => $val) { $oCommentItem = new commentItem(); $oCommentItem->setAttribute($val); @@ -845,5 +846,23 @@ } return false; } + + public function getTranslationLangCodes() + { + $obj->document_srl = $this->document_srl; + // -2 is an index for content. We are interested if content has other translations. + $obj->var_idx = -2; + $output = executeQueryArray('document.getDocumentTranslationLangCodes', $obj); + + if (!$output->data) + { + $output->data = array(); + } + // add original page's lang code as well + $origLangCode->lang_code = $this->getLangCode(); + $output->data[] = $origLangCode; + + return $output->data; + } } ?> diff --git a/modules/document/queries/getDocumentTranslationLangCodes.xml b/modules/document/queries/getDocumentTranslationLangCodes.xml new file mode 100644 index 000000000..c3c6fb763 --- /dev/null +++ b/modules/document/queries/getDocumentTranslationLangCodes.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/modules/point/queries/getCommentPoint.xml b/modules/point/queries/getCommentPoint.xml index e74f85e06..7073d4361 100644 --- a/modules/point/queries/getCommentPoint.xml +++ b/modules/point/queries/getCommentPoint.xml @@ -3,7 +3,8 @@
- + +
diff --git a/modules/point/queries/getCommentUsers.xml b/modules/point/queries/getCommentUsers.xml index 203319e5d..6b0828f79 100644 --- a/modules/point/queries/getCommentUsers.xml +++ b/modules/point/queries/getCommentUsers.xml @@ -7,7 +7,8 @@ - + +