mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 13:32:16 +09:00
issue 2662 comment
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12238 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
71361410b6
commit
7eaa7bb8f9
6 changed files with 2109 additions and 1955 deletions
|
|
@ -7,13 +7,14 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class commentAdminController extends comment {
|
||||
|
||||
class commentAdminController extends comment
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,7 +123,8 @@
|
|||
$document_author_email = $oDocument->variables['email_address'];
|
||||
|
||||
//mail to author of thread - START
|
||||
if($document_author_email != $comment->email_address && $logged_info->email_address != $document_author_email) {
|
||||
if($document_author_email != $comment->email_address && $logged_info->email_address != $document_author_email)
|
||||
{
|
||||
$oMail->setReceiptor($document_author_email, $document_author_email);
|
||||
$oMail->send();
|
||||
$already_sent[] = $document_author_email;
|
||||
|
|
@ -133,10 +135,12 @@
|
|||
if($module_info->admin_mail)
|
||||
{
|
||||
$target_mail = explode(',',$module_info->admin_mail);
|
||||
for($i=0;$i<count($target_mail);$i++) {
|
||||
for($i=0;$i<count($target_mail);$i++)
|
||||
{
|
||||
$email_address = trim($target_mail[$i]);
|
||||
if(!$email_address) continue;
|
||||
if($author_email != $email_address) {
|
||||
if($author_email != $email_address)
|
||||
{
|
||||
$oMail->setReceiptor($email_address, $email_address);
|
||||
$oMail->send();
|
||||
}
|
||||
|
|
@ -150,14 +154,14 @@
|
|||
// call a trigger for calling "send mail to subscribers" (for moment just for forum)
|
||||
ModuleHandler::triggerCall("comment.procCommentAdminChangeStatus","after",$comment_srl_list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the selected comment from the administrator page
|
||||
* @return void
|
||||
*/
|
||||
function procCommentAdminDeleteChecked() {
|
||||
function procCommentAdminDeleteChecked()
|
||||
{
|
||||
$isTrash = Context::get('is_trash');
|
||||
|
||||
// Error display if none is selected
|
||||
|
|
@ -177,7 +181,8 @@
|
|||
$message_content = Context::get('message_content');
|
||||
if($message_content) $message_content = nl2br($message_content);
|
||||
|
||||
if($message_content) {
|
||||
if($message_content)
|
||||
{
|
||||
$oCommunicationController = &getController('communication');
|
||||
$oCommentModel = &getModel('comment');
|
||||
|
||||
|
|
@ -186,7 +191,8 @@
|
|||
$title = cut_str($message_content,10,'...');
|
||||
$sender_member_srl = $logged_info->member_srl;
|
||||
|
||||
for($i=0;$i<$comment_count;$i++) {
|
||||
for($i=0;$i<$comment_count;$i++)
|
||||
{
|
||||
$comment_srl = $comment_srl_list[$i];
|
||||
$oComment = $oCommentModel->getComment($comment_srl, true);
|
||||
|
||||
|
|
@ -204,7 +210,8 @@
|
|||
|
||||
$deleted_count = 0;
|
||||
// Delete the comment posting
|
||||
for($i=0;$i<$comment_count;$i++) {
|
||||
for($i=0;$i<$comment_count;$i++)
|
||||
{
|
||||
$comment_srl = trim($comment_srl_list[$i]);
|
||||
if(!$comment_srl) continue;
|
||||
|
||||
|
|
@ -259,7 +266,8 @@
|
|||
$oTrashVO->setSerializedObject(serialize($oComment->variables));
|
||||
|
||||
$output = $oTrashAdminController->insertTrash($oTrashVO);
|
||||
if (!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -271,10 +279,12 @@
|
|||
* Cancel the blacklist of abused comments reported by other users
|
||||
* @return void|object
|
||||
*/
|
||||
function procCommentAdminCancelDeclare() {
|
||||
function procCommentAdminCancelDeclare()
|
||||
{
|
||||
$comment_srl = trim(Context::get('comment_srl'));
|
||||
|
||||
if($comment_srl) {
|
||||
if($comment_srl)
|
||||
{
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQuery('comment.deleteDeclaredComments', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
|
@ -309,7 +319,8 @@
|
|||
* Delete all comments of the specific module
|
||||
* @return object
|
||||
*/
|
||||
function deleteModuleComments($module_srl) {
|
||||
function deleteModuleComments($module_srl)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('comment.deleteModuleComments', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
|
@ -373,4 +384,5 @@
|
|||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.admin.controller.php */
|
||||
/* Location: ./modules/comment/comment.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -7,19 +7,22 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class commentAdminView extends comment {
|
||||
class commentAdminView extends comment
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the list(for administrators)
|
||||
* @return void
|
||||
*/
|
||||
function dispCommentAdminList() {
|
||||
function dispCommentAdminList()
|
||||
{
|
||||
// option to get a list
|
||||
$args->page = Context::get('page'); // /< Page
|
||||
$args->list_count = 30; // / the number of postings to appear on a single page
|
||||
|
|
@ -68,7 +71,8 @@
|
|||
* Show the blacklist of comments in the admin page
|
||||
* @return void
|
||||
*/
|
||||
function dispCommentAdminDeclared() {
|
||||
function dispCommentAdminDeclared()
|
||||
{
|
||||
// option to get a blacklist
|
||||
$args->page = Context::get('page'); // /< Page
|
||||
$args->list_count = 30; // /< the number of comment postings to appear on a single page
|
||||
|
|
@ -81,10 +85,12 @@
|
|||
$declared_output = executeQuery('comment.getDeclaredList', $args);
|
||||
$oCommentModel = &getModel('comment');
|
||||
|
||||
if($declared_output->data && count($declared_output->data)) {
|
||||
if($declared_output->data && count($declared_output->data))
|
||||
{
|
||||
$comment_list = array();
|
||||
|
||||
foreach($declared_output->data as $key => $comment) {
|
||||
foreach($declared_output->data as $key => $comment)
|
||||
{
|
||||
$comment_list[$key] = new commentItem();
|
||||
$comment_list[$key]->setAttribute($comment);
|
||||
}
|
||||
|
|
@ -105,4 +111,5 @@
|
|||
$this->setTemplateFile('declared_list');
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.admin.view.php */
|
||||
/* Location: ./modules/comment/comment.admin.view.php */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
require_once(_XE_PATH_.'modules/comment/comment.item.php');
|
||||
|
||||
/**
|
||||
* comment
|
||||
* comment module's high class
|
||||
|
|
@ -9,12 +8,14 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class comment extends ModuleObject {
|
||||
class comment extends ModuleObject
|
||||
{
|
||||
/**
|
||||
* Implemented if additional tasks are required when installing
|
||||
* @return Object
|
||||
*/
|
||||
function moduleInstall() {
|
||||
function moduleInstall()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// register the action forward (for using on the admin mode)
|
||||
|
|
@ -42,7 +43,8 @@
|
|||
* Method to check if installation is succeeded
|
||||
* @return bool
|
||||
*/
|
||||
function checkUpdate() {
|
||||
function checkUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
|
||||
|
|
@ -80,7 +82,8 @@
|
|||
* Execute update
|
||||
* @return Object
|
||||
*/
|
||||
function moduleUpdate() {
|
||||
function moduleUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
|
|
@ -91,19 +94,22 @@
|
|||
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
|
||||
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
|
||||
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
|
||||
if(!$oDB->isColumnExists("comments","voted_count")) {
|
||||
if(!$oDB->isColumnExists("comments","voted_count"))
|
||||
{
|
||||
$oDB->addColumn("comments","voted_count", "number","11");
|
||||
$oDB->addIndex("comments","idx_voted_count", array("voted_count"));
|
||||
}
|
||||
|
||||
if(!$oDB->isColumnExists("comments","notify_message")) {
|
||||
if(!$oDB->isColumnExists("comments","notify_message"))
|
||||
{
|
||||
$oDB->addColumn("comments","notify_message", "char","1");
|
||||
}
|
||||
// 2008. 02. 22 add comment setting when a new module added
|
||||
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
|
||||
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
|
||||
// 2008. 05. 14 add a column for blamed count
|
||||
if(!$oDB->isColumnExists("comments", "blamed_count")) {
|
||||
if(!$oDB->isColumnExists("comments", "blamed_count"))
|
||||
{
|
||||
$oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, true);
|
||||
$oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count'));
|
||||
}
|
||||
|
|
@ -111,6 +117,7 @@
|
|||
$oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, true);
|
||||
|
||||
if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
|
||||
{
|
||||
$oDB->addIndex
|
||||
(
|
||||
"comments",
|
||||
|
|
@ -118,12 +125,15 @@
|
|||
array("module_srl", "list_order"),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
//2012. 02. 24 add comment published status column and index
|
||||
if(!$oDB->isColumnExists("comments", "status")) {
|
||||
if(!$oDB->isColumnExists("comments", "status"))
|
||||
{
|
||||
$oDB->addColumn("comments", "status", "number", 1, 1, true);
|
||||
}
|
||||
if(!$oDB->isIndexExists("comments", "idx_status"))
|
||||
{
|
||||
$oDB->addIndex
|
||||
(
|
||||
"comments",
|
||||
|
|
@ -131,6 +141,7 @@
|
|||
array("status", "comment_srl", "module_srl", "document_srl"),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
|
||||
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
|
||||
|
|
@ -145,7 +156,9 @@
|
|||
* Regenerate cache file
|
||||
* @return void
|
||||
*/
|
||||
function recompileCache() {
|
||||
function recompileCache()
|
||||
{
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.class.php */
|
||||
/* Location: ./modules/comment/comment.class.php */
|
||||
|
|
|
|||
|
|
@ -7,19 +7,22 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class commentController extends comment {
|
||||
class commentController extends comment
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to handle recommendation votes on comments (Up)
|
||||
* @return Object
|
||||
*/
|
||||
function procCommentVoteUp() {
|
||||
function procCommentVoteUp()
|
||||
{
|
||||
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$comment_srl = Context::get('target_srl');
|
||||
|
|
@ -42,7 +45,8 @@
|
|||
* Action to handle recommendation votes on comments (Down)
|
||||
* @return Object
|
||||
*/
|
||||
function procCommentVoteDown() {
|
||||
function procCommentVoteDown()
|
||||
{
|
||||
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$comment_srl = Context::get('target_srl');
|
||||
|
|
@ -65,7 +69,8 @@
|
|||
* Action to be called when a comment posting is reported
|
||||
* @return void|Object
|
||||
*/
|
||||
function procCommentDeclare() {
|
||||
function procCommentDeclare()
|
||||
{
|
||||
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
$comment_srl = Context::get('target_srl');
|
||||
|
|
@ -78,7 +83,8 @@
|
|||
* Trigger to delete its comments together with document deleted
|
||||
* @return Object
|
||||
*/
|
||||
function triggerDeleteDocumentComments(&$obj) {
|
||||
function triggerDeleteDocumentComments(&$obj)
|
||||
{
|
||||
$document_srl = $obj->document_srl;
|
||||
if(!$document_srl) return new Object();
|
||||
|
||||
|
|
@ -89,7 +95,8 @@
|
|||
* Trigger to delete corresponding comments when deleting a module
|
||||
* @return object
|
||||
*/
|
||||
function triggerDeleteModuleComments(&$obj) {
|
||||
function triggerDeleteModuleComments(&$obj)
|
||||
{
|
||||
$module_srl = $obj->module_srl;
|
||||
if(!$module_srl) return new Object();
|
||||
|
||||
|
|
@ -102,7 +109,8 @@
|
|||
* available only in the current connection of the session value
|
||||
* @return void
|
||||
*/
|
||||
function addGrant($comment_srl) {
|
||||
function addGrant($comment_srl)
|
||||
{
|
||||
$_SESSION['own_comment'][$comment_srl] = true;
|
||||
}
|
||||
|
||||
|
|
@ -136,8 +144,8 @@
|
|||
* @param bool $manual_inserted
|
||||
* @return object
|
||||
*/
|
||||
function insertComment($obj, $manual_inserted = false) {
|
||||
|
||||
function insertComment($obj, $manual_inserted = false)
|
||||
{
|
||||
// check if comment's module is using comment validation and set the publish status to 0 (false)
|
||||
// for inserting query, otherwise default is 1 (true - means comment is published)
|
||||
$using_validation = $this->isModuleUsingPublishValidation($obj->module_srl);
|
||||
|
|
@ -183,7 +191,8 @@
|
|||
// even for manual_inserted if password exists, md5 it.
|
||||
if($obj->password) $obj->password = md5($obj->password);
|
||||
// get the original posting
|
||||
if(!$manual_inserted) {
|
||||
if(!$manual_inserted)
|
||||
{
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
|
||||
if($document_srl != $oDocument->document_srl) return new Object(-1,'msg_invalid_document');
|
||||
|
|
@ -191,7 +200,8 @@
|
|||
|
||||
if($obj->homepage && !preg_match('/^[a-z]+:\/\//i',$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
|
||||
// input the member's information if logged-in
|
||||
if(Context::get('is_logged')) {
|
||||
if(Context::get('is_logged'))
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
$obj->member_srl = $logged_info->member_srl;
|
||||
$obj->user_id = $logged_info->user_id;
|
||||
|
|
@ -233,11 +243,14 @@
|
|||
$list_args->module_srl = $obj->module_srl;
|
||||
$list_args->regdate = $obj->regdate;
|
||||
// If parent comment doesn't exist, set data directly
|
||||
if(!$obj->parent_srl) {
|
||||
if(!$obj->parent_srl)
|
||||
{
|
||||
$list_args->head = $list_args->arrange = $obj->comment_srl;
|
||||
$list_args->depth = 0;
|
||||
// If parent comment exists, get information of the parent comment
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// get information of the parent comment posting
|
||||
$parent_args->comment_srl = $obj->parent_srl;
|
||||
$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
|
||||
|
|
@ -248,20 +261,26 @@
|
|||
$list_args->head = $parent->head;
|
||||
$list_args->depth = $parent->depth+1;
|
||||
// if the depth of comments is less than 2, execute insert.
|
||||
if($list_args->depth<2) {
|
||||
if($list_args->depth<2)
|
||||
{
|
||||
$list_args->arrange = $obj->comment_srl;
|
||||
// if the depth of comments is greater than 2, execute update.
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the top listed comment among those in lower depth and same head with parent's.
|
||||
$p_args->head = $parent->head;
|
||||
$p_args->arrange = $parent->arrange;
|
||||
$p_args->depth = $parent->depth;
|
||||
$output = executeQuery('comment.getCommentParentNextSibling', $p_args);
|
||||
|
||||
if($output->data->arrange) {
|
||||
if($output->data->arrange)
|
||||
{
|
||||
$list_args->arrange = $output->data->arrange;
|
||||
$output = executeQuery('comment.updateCommentListArrange', $list_args);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$list_args->arrange = $obj->comment_srl;
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +291,8 @@
|
|||
if(!$output->toBool()) return $output;
|
||||
// insert comment
|
||||
$output = executeQuery('comment.insertComment', $obj);
|
||||
if(!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -297,7 +317,8 @@
|
|||
// grant autority of the comment
|
||||
$this->addGrant($obj->comment_srl);
|
||||
// call a trigger(after)
|
||||
if($output->toBool()) {
|
||||
if($output->toBool())
|
||||
{
|
||||
$trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
|
||||
if(!$trigger_output->toBool()) {
|
||||
$oDB->rollback();
|
||||
|
|
@ -308,13 +329,16 @@
|
|||
// commit
|
||||
$oDB->commit();
|
||||
|
||||
if(!$manual_inserted) {
|
||||
if(!$manual_inserted)
|
||||
{
|
||||
// send a message if notify_message option in enabled in the original article
|
||||
$oDocument->notify(Context::getLang('comment'), $obj->content);
|
||||
// send a message if notify_message option in enabled in the original comment
|
||||
if($obj->parent_srl) {
|
||||
if($obj->parent_srl)
|
||||
{
|
||||
$oParent = $oCommentModel->getComment($obj->parent_srl);
|
||||
if ($oParent->get('member_srl') != $oDocument->get('member_srl')) {
|
||||
if($oParent->get('member_srl') != $oDocument->get('member_srl'))
|
||||
{
|
||||
$oParent->notify(Context::getLang('comment'), $obj->content);
|
||||
}
|
||||
}
|
||||
|
|
@ -322,7 +346,6 @@
|
|||
|
||||
$this->sendEmailToAdminAfterInsertComment($obj);
|
||||
|
||||
|
||||
$output->add('comment_srl', $obj->comment_srl);
|
||||
//remove from cache
|
||||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
|
|
@ -455,14 +478,14 @@
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fix the comment
|
||||
* @param object $obj
|
||||
* @param bool $is_admin
|
||||
* @return object
|
||||
*/
|
||||
function updateComment($obj, $is_admin = false) {
|
||||
function updateComment($obj, $is_admin = false)
|
||||
{
|
||||
$obj->__isupdate = true;
|
||||
// call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
|
||||
|
|
@ -471,7 +494,8 @@
|
|||
$oCommentModel = &getModel('comment');
|
||||
// get the original data
|
||||
$source_obj = $oCommentModel->getComment($obj->comment_srl);
|
||||
if(!$source_obj->getMemberSrl()) {
|
||||
if(!$source_obj->getMemberSrl())
|
||||
{
|
||||
$obj->member_srl = $source_obj->get('member_srl');
|
||||
$obj->user_name = $source_obj->get('user_name');
|
||||
$obj->nick_name = $source_obj->get('nick_name');
|
||||
|
|
@ -484,9 +508,11 @@
|
|||
if($obj->password) $obj->password = md5($obj->password);
|
||||
if($obj->homepage && !preg_match('/^[a-z]+:\/\//i',$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
|
||||
// set modifier's information if logged-in and posting author and modifier are matched.
|
||||
if(Context::get('is_logged')) {
|
||||
if(Context::get('is_logged'))
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($source_obj->member_srl == $logged_info->member_srl) {
|
||||
if($source_obj->member_srl == $logged_info->member_srl)
|
||||
{
|
||||
$obj->member_srl = $logged_info->member_srl;
|
||||
$obj->user_name = $logged_info->user_name;
|
||||
$obj->nick_name = $logged_info->nick_name;
|
||||
|
|
@ -495,7 +521,8 @@
|
|||
}
|
||||
}
|
||||
// if nick_name of the logged-in author doesn't exist
|
||||
if($source_obj->get('member_srl')&& !$obj->nick_name) {
|
||||
if($source_obj->get('member_srl')&& !$obj->nick_name)
|
||||
{
|
||||
$obj->member_srl = $source_obj->get('member_srl');
|
||||
$obj->user_name = $source_obj->get('user_name');
|
||||
$obj->nick_name = $source_obj->get('nick_name');
|
||||
|
|
@ -503,7 +530,6 @@
|
|||
$obj->homepage = $source_obj->get('homepage');
|
||||
}
|
||||
|
||||
|
||||
if(!$obj->content) $obj->content = $source_obj->get('content');
|
||||
// remove XE's wn tags from contents
|
||||
$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
|
||||
|
|
@ -515,14 +541,17 @@
|
|||
$oDB->begin();
|
||||
// Update
|
||||
$output = executeQuery('comment.updateComment', $obj);
|
||||
if(!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
// call a trigger (after)
|
||||
if($output->toBool()) {
|
||||
if($output->toBool())
|
||||
{
|
||||
$trigger_output = ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);
|
||||
if(!$trigger_output->toBool()) {
|
||||
if(!$trigger_output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $trigger_output;
|
||||
}
|
||||
|
|
@ -549,7 +578,8 @@
|
|||
* @param bool $isMoveToTrash
|
||||
* @return object
|
||||
*/
|
||||
function deleteComment($comment_srl, $is_admin = false, $isMoveToTrash = false) {
|
||||
function deleteComment($comment_srl, $is_admin = false, $isMoveToTrash = false)
|
||||
{
|
||||
// create the comment model object
|
||||
$oCommentModel = &getModel('comment');
|
||||
// check if comment already exists
|
||||
|
|
@ -610,7 +640,8 @@
|
|||
// Delete
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQuery('comment.deleteComment', $args);
|
||||
if(!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -622,14 +653,17 @@
|
|||
$oDocumentController = &getController('document');
|
||||
// update comment count of the article posting
|
||||
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false);
|
||||
if(!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
// call a trigger (after)
|
||||
if($output->toBool()) {
|
||||
if($output->toBool())
|
||||
{
|
||||
$trigger_output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
|
||||
if(!$trigger_output->toBool()) {
|
||||
if(!$trigger_output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $trigger_output;
|
||||
}
|
||||
|
|
@ -671,7 +705,8 @@
|
|||
* @param int $document_srl
|
||||
* @return object
|
||||
*/
|
||||
function deleteComments($document_srl, $obj = NULL) {
|
||||
function deleteComments($document_srl, $obj = NULL)
|
||||
{
|
||||
// create the document model object
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oCommentModel = &getModel('comment');
|
||||
|
|
@ -690,9 +725,11 @@
|
|||
// get a list of comments and then execute a trigger(way to reduce the processing cost for delete all)
|
||||
$args->document_srl = $document_srl;
|
||||
$comments = executeQueryArray('comment.getAllComments',$args);
|
||||
if($comments->data) {
|
||||
if($comments->data)
|
||||
{
|
||||
$commentSrlList = array();
|
||||
foreach($comments->data as $key => $comment) {
|
||||
foreach($comments->data as $key => $comment)
|
||||
{
|
||||
array_push($commentSrlList, $comment->comment_srl);
|
||||
// call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
|
||||
|
|
@ -755,11 +792,15 @@
|
|||
* @param int $point
|
||||
* @return Object
|
||||
*/
|
||||
function updateVotedCount($comment_srl, $point = 1) {
|
||||
if($point > 0) {
|
||||
function updateVotedCount($comment_srl, $point = 1)
|
||||
{
|
||||
if($point > 0)
|
||||
{
|
||||
$failed_voted = 'failed_voted';
|
||||
$success_message = 'success_voted';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$failed_voted = 'failed_blamed';
|
||||
$success_message = 'success_blamed';
|
||||
}
|
||||
|
|
@ -770,31 +811,38 @@
|
|||
$oCommentModel = &getModel('comment');
|
||||
$oComment = $oCommentModel->getComment($comment_srl, false, false);
|
||||
// invalid vote if both ip addresses between author's and the current user are same.
|
||||
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
|
||||
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
||||
{
|
||||
$_SESSION['voted_comment'][$comment_srl] = true;
|
||||
return new Object(-1, $failed_voted);
|
||||
}
|
||||
// if the comment author is a member
|
||||
if($oComment->get('member_srl')) {
|
||||
if($oComment->get('member_srl'))
|
||||
{
|
||||
// create the member model object
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
// session registered if the author information matches to the current logged-in user's.
|
||||
if($member_srl && $member_srl == $oComment->get('member_srl')) {
|
||||
if($member_srl && $member_srl == $oComment->get('member_srl'))
|
||||
{
|
||||
$_SESSION['voted_comment'][$comment_srl] = true;
|
||||
return new Object(-1, $failed_voted);
|
||||
}
|
||||
}
|
||||
// If logged-in, use the member_srl. otherwise use the ipaddress.
|
||||
if($member_srl) {
|
||||
if($member_srl)
|
||||
{
|
||||
$args->member_srl = $member_srl;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQuery('comment.getCommentVotedLogInfo', $args);
|
||||
// session registered if log info contains recommendation vote log.
|
||||
if($output->data->count) {
|
||||
if($output->data->count)
|
||||
{
|
||||
$_SESSION['voted_comment'][$comment_srl] = true;
|
||||
return new Object(-1, $failed_voted);
|
||||
}
|
||||
|
|
@ -804,10 +852,13 @@
|
|||
$oDB->begin();
|
||||
|
||||
// update the number of votes
|
||||
if($point < 0) {
|
||||
if($point < 0)
|
||||
{
|
||||
$args->blamed_count = $oComment->get('blamed_count') + $point;
|
||||
$output = executeQuery('comment.updateBlamedCount', $args);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->voted_count = $oComment->get('voted_count') + $point;
|
||||
$output = executeQuery('comment.updateVotedCount', $args);
|
||||
}
|
||||
|
|
@ -843,7 +894,8 @@
|
|||
* @param $comment_srl
|
||||
* @return void
|
||||
*/
|
||||
function declaredComment($comment_srl) {
|
||||
function declaredComment($comment_srl)
|
||||
{
|
||||
// Fail if session information already has a reported document
|
||||
if($_SESSION['declared_comment'][$comment_srl]) return new Object(-1, 'failed_declared');
|
||||
// check if already reported
|
||||
|
|
@ -854,31 +906,38 @@
|
|||
$oCommentModel = &getModel('comment');
|
||||
$oComment = $oCommentModel->getComment($comment_srl, false, false);
|
||||
// failed if both ip addresses between author's and the current user are same.
|
||||
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
|
||||
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
|
||||
{
|
||||
$_SESSION['declared_comment'][$comment_srl] = true;
|
||||
return new Object(-1, 'failed_declared');
|
||||
}
|
||||
// if the comment author is a member
|
||||
if($oComment->get('member_srl')) {
|
||||
if($oComment->get('member_srl'))
|
||||
{
|
||||
// create the member model object
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
// session registered if the author information matches to the current logged-in user's.
|
||||
if($member_srl && $member_srl == $oComment->get('member_srl')) {
|
||||
if($member_srl && $member_srl == $oComment->get('member_srl'))
|
||||
{
|
||||
$_SESSION['declared_comment'][$comment_srl] = true;
|
||||
return new Object(-1, 'failed_declared');
|
||||
}
|
||||
}
|
||||
// If logged-in, use the member_srl. otherwise use the ipaddress.
|
||||
if($member_srl) {
|
||||
if($member_srl)
|
||||
{
|
||||
$args->member_srl = $member_srl;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$args->comment_srl = $comment_srl;
|
||||
$log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
|
||||
// session registered if log info contains report log.
|
||||
if($log_output->data->count) {
|
||||
if($log_output->data->count)
|
||||
{
|
||||
$_SESSION['declared_comment'][$comment_srl] = true;
|
||||
return new Object(-1, 'failed_declared');
|
||||
}
|
||||
|
|
@ -902,7 +961,8 @@
|
|||
* @param strgin $target
|
||||
* @return void
|
||||
*/
|
||||
function addCommentPopupMenu($url, $str, $icon = '', $target = 'self') {
|
||||
function addCommentPopupMenu($url, $str, $icon = '', $target = 'self')
|
||||
{
|
||||
$comment_popup_menu_list = Context::get('comment_popup_menu_list');
|
||||
if(!is_array($comment_popup_menu_list)) $comment_popup_menu_list = array();
|
||||
|
||||
|
|
@ -919,7 +979,8 @@
|
|||
* Save the comment extension form for each module
|
||||
* @return void
|
||||
*/
|
||||
function procCommentInsertModuleConfig() {
|
||||
function procCommentInsertModuleConfig()
|
||||
{
|
||||
$module_srl = Context::get('target_module_srl');
|
||||
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
|
||||
else $module_srl = array($module_srl);
|
||||
|
|
@ -936,7 +997,8 @@
|
|||
$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;$i<count($module_srl);$i++) {
|
||||
for($i=0;$i<count($module_srl);$i++)
|
||||
{
|
||||
$srl = trim($module_srl[$i]);
|
||||
if(!$srl) continue;
|
||||
$output = $this->setCommentModuleConfig($srl,$comment_config);
|
||||
|
|
@ -955,7 +1017,8 @@
|
|||
* @param object $comment_config
|
||||
* @return Object
|
||||
*/
|
||||
function setCommentModuleConfig($srl, $comment_config){
|
||||
function setCommentModuleConfig($srl, $comment_config)
|
||||
{
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertModulePartConfig('comment',$srl,$comment_config);
|
||||
return new Object();
|
||||
|
|
@ -971,7 +1034,8 @@
|
|||
$commentSrls = Context::get('comment_srls');
|
||||
if($commentSrls) $commentSrlList = explode(',', $commentSrls);
|
||||
|
||||
if(count($commentSrlList) > 0) {
|
||||
if(count($commentSrlList) > 0)
|
||||
{
|
||||
$oCommentModel = &getModel('comment');
|
||||
$commentList = $oCommentModel->getComments($commentSrlList);
|
||||
|
||||
|
|
@ -1008,4 +1072,5 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.controller.php */
|
||||
/* Location: ./modules/comment/comment.controller.php */
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class commentModel extends comment {
|
||||
class commentModel extends comment
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -20,7 +22,8 @@
|
|||
* Print, scrap, vote-up(recommen), vote-down(non-recommend), report features added
|
||||
* @return void
|
||||
*/
|
||||
function getCommentMenu() {
|
||||
function getCommentMenu()
|
||||
{
|
||||
// get the post's id number and the current login information
|
||||
$comment_srl = Context::get('target_srl');
|
||||
$mid = Context::get('cur_mid');
|
||||
|
|
@ -34,8 +37,8 @@
|
|||
|
||||
$oCommentController = &getController('comment');
|
||||
// feature that only member can do
|
||||
if($logged_info->member_srl) {
|
||||
|
||||
if($logged_info->member_srl)
|
||||
{
|
||||
$oCommentModel = &getModel('comment');
|
||||
$columnList = array('comment_srl', 'module_srl', 'member_srl', 'ipaddress');
|
||||
$oComment = $oCommentModel->getComment($comment_srl, false, $columnList);
|
||||
|
|
@ -44,12 +47,14 @@
|
|||
|
||||
$oModuleModel = &getModel('module');
|
||||
$comment_config = $oModuleModel->getModulePartConfig('document',$module_srl);
|
||||
if($comment_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl){
|
||||
if($comment_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl)
|
||||
{
|
||||
// Add a vote-up button for positive feedback
|
||||
$url = sprintf("doCallModuleAction('comment','procCommentVoteUp','%s')", $comment_srl);
|
||||
$oCommentController->addCommentPopupMenu($url,'cmd_vote','','javascript');
|
||||
}
|
||||
if($comment_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl){
|
||||
if($comment_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl)
|
||||
{
|
||||
// Add a vote-down button for negative feedback
|
||||
$url = sprintf("doCallModuleAction('comment','procCommentVoteDown','%s')", $comment_srl);
|
||||
$oCommentController->addCommentPopupMenu($url,'cmd_vote_down','','javascript');
|
||||
|
|
@ -62,11 +67,13 @@
|
|||
// call a trigger (after)
|
||||
ModuleHandler::triggerCall('comment.getCommentMenu', 'after', $menu_list);
|
||||
// find a comment by IP matching if an administrator.
|
||||
if($logged_info->is_admin == 'Y') {
|
||||
if($logged_info->is_admin == 'Y')
|
||||
{
|
||||
$oCommentModel = &getModel('comment');
|
||||
$oComment = $oCommentModel->getComment($comment_srl);
|
||||
|
||||
if($oComment->isExists()) {
|
||||
if($oComment->isExists())
|
||||
{
|
||||
// Find a post of the corresponding ip address
|
||||
$url = getUrl('','module','admin','act','dispCommentAdminList','search_target','ipaddress','search_keyword',$oComment->getIpAddress());
|
||||
$oCommentController->addCommentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress');
|
||||
|
|
@ -78,21 +85,22 @@
|
|||
// Changing a language of pop-up menu
|
||||
$menus = Context::get('comment_popup_menu_list');
|
||||
$menus_count = count($menus);
|
||||
for($i=0;$i<$menus_count;$i++) {
|
||||
for($i=0;$i<$menus_count;$i++)
|
||||
{
|
||||
$menus[$i]->str = Context::getLang($menus[$i]->str);
|
||||
}
|
||||
// get a list of final organized pop-up menus
|
||||
$this->add('menus', $menus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if you have a permission to comment_srl
|
||||
* use only session information
|
||||
* @param int $comment_srl
|
||||
* @return bool
|
||||
*/
|
||||
function isGranted($comment_srl) {
|
||||
function isGranted($comment_srl)
|
||||
{
|
||||
return $_SESSION['own_comment'][$comment_srl];
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +109,8 @@
|
|||
* @param int $comment_srl
|
||||
* @return int
|
||||
*/
|
||||
function getChildCommentCount($comment_srl) {
|
||||
function getChildCommentCount($comment_srl)
|
||||
{
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQuery('comment.getChildCommentCount', $args);
|
||||
return (int)$output->data->count;
|
||||
|
|
@ -112,7 +121,8 @@
|
|||
* @param int $comment_srl
|
||||
* @return int
|
||||
*/
|
||||
function getChildComments($comment_srl) {
|
||||
function getChildComments($comment_srl)
|
||||
{
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQueryArray('comment.getChildComments', $args);
|
||||
return $output->data;
|
||||
|
|
@ -125,7 +135,8 @@
|
|||
* @param array $columnList
|
||||
* @return commentItem
|
||||
*/
|
||||
function getComment($comment_srl=0, $is_admin = false, $columnList = array()) {
|
||||
function getComment($comment_srl=0, $is_admin = false, $columnList = array())
|
||||
{
|
||||
$oComment = new commentItem($comment_srl, $columnList);
|
||||
if($is_admin) $oComment->setGrant();
|
||||
|
||||
|
|
@ -138,7 +149,8 @@
|
|||
* @param array $columnList
|
||||
* @return array
|
||||
*/
|
||||
function getComments($comment_srl_list, $columnList = array()) {
|
||||
function getComments($comment_srl_list, $columnList = array())
|
||||
{
|
||||
if(is_array($comment_srl_list)) $comment_srls = implode(',',$comment_srl_list);
|
||||
// fetch from a database
|
||||
$args->comment_srls = $comment_srls;
|
||||
|
|
@ -149,7 +161,8 @@
|
|||
if(!is_array($comment_list)) $comment_list = array($comment_list);
|
||||
|
||||
$comment_count = count($comment_list);
|
||||
foreach($comment_list as $key => $attribute) {
|
||||
foreach($comment_list as $key => $attribute)
|
||||
{
|
||||
if(!$attribute->comment_srl) continue;
|
||||
$oComment = null;
|
||||
$oComment = new commentItem();
|
||||
|
|
@ -166,7 +179,8 @@
|
|||
* @param int $document_srl
|
||||
* @return int
|
||||
*/
|
||||
function getCommentCount($document_srl) {
|
||||
function getCommentCount($document_srl)
|
||||
{
|
||||
$args->document_srl = $document_srl;
|
||||
|
||||
// get the number of comments on the document module
|
||||
|
|
@ -196,7 +210,8 @@
|
|||
* @param array $moduleSrlList
|
||||
* @return int
|
||||
*/
|
||||
function getCommentCountByDate($date = '', $moduleSrlList = array()) {
|
||||
function getCommentCountByDate($date = '', $moduleSrlList = array())
|
||||
{
|
||||
if($date) $args->regDate = date('Ymd', strtotime($date));
|
||||
if(count($moduleSrlList)>0) $args->module_srl = $moduleSrlList;
|
||||
|
||||
|
|
@ -212,7 +227,8 @@
|
|||
* @param bool $published
|
||||
* @return int
|
||||
*/
|
||||
function getCommentAllCount($module_srl,$published=null) {
|
||||
function getCommentAllCount($module_srl,$published=null)
|
||||
{
|
||||
$args->module_srl = $module_srl;
|
||||
|
||||
if(is_null($published))
|
||||
|
|
@ -270,8 +286,10 @@
|
|||
* @param array $columnList
|
||||
* @return array
|
||||
*/
|
||||
function getNewestCommentList($obj, $columnList = array()) {
|
||||
if($obj->mid) {
|
||||
function getNewestCommentList($obj, $columnList = array())
|
||||
{
|
||||
if($obj->mid)
|
||||
{
|
||||
$oModuleModel = &getModel('module');
|
||||
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
|
||||
unset($obj->mid);
|
||||
|
|
@ -282,7 +300,8 @@
|
|||
$args->list_count = $obj->list_count;
|
||||
// cache controll
|
||||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport()){
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$object_key = 'object_newest_comment_list:'.$obj->module_srl;
|
||||
$cache_key = $oCacheHandler->getGroupKey('newestCommentsList', $object_key);
|
||||
$output = $oCacheHandler->get($cache_key);
|
||||
|
|
@ -308,10 +327,12 @@
|
|||
if(!$output->toBool()) return $output;
|
||||
|
||||
$comment_list = $output->data;
|
||||
if($comment_list) {
|
||||
if($comment_list)
|
||||
{
|
||||
if(!is_array($comment_list)) $comment_list = array($comment_list);
|
||||
$comment_count = count($comment_list);
|
||||
foreach($comment_list as $key => $attribute) {
|
||||
foreach($comment_list as $key => $attribute)
|
||||
{
|
||||
if(!$attribute->comment_srl) continue;
|
||||
$oComment = null;
|
||||
$oComment = new commentItem();
|
||||
|
|
@ -332,16 +353,19 @@
|
|||
* @param int $count
|
||||
* @return object
|
||||
*/
|
||||
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) {
|
||||
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0)
|
||||
{
|
||||
if(!isset($document_srl)) return;
|
||||
// cache controll
|
||||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport()){
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$object_key = 'object:'.$document_srl.'_'.$page.'_'.($is_admin ? 'Y' : 'N') .'_' . $count;
|
||||
$cache_key = $oCacheHandler->getGroupKey('commentList_' . $document_srl, $object_key);
|
||||
$output = $oCacheHandler->get($cache_key);
|
||||
}
|
||||
if(!$output){
|
||||
if(!$output)
|
||||
{
|
||||
// get the number of comments on the document module
|
||||
$oDocumentModel = &getModel('document');
|
||||
$columnList = array('document_srl', 'module_srl', 'comment_count');
|
||||
|
|
@ -353,11 +377,14 @@
|
|||
// get a list of comments
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
|
||||
if(!$count) {
|
||||
if(!$count)
|
||||
{
|
||||
$comment_config = $this->getCommentConfig($module_srl);
|
||||
$comment_count = $comment_config->comment_count;
|
||||
if(!$comment_count) $comment_count = 50;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$comment_count = $count;
|
||||
}
|
||||
// get a very last page if no page exists
|
||||
|
|
@ -381,14 +408,14 @@
|
|||
// return if an error occurs in the query results
|
||||
if(!$output->toBool()) return;
|
||||
// insert data into CommentPageList table if the number of results is different from stored comments
|
||||
if(!$output->data) {
|
||||
if(!$output->data)
|
||||
{
|
||||
$this->fixCommentList($oDocument->get('module_srl'), $document_srl);
|
||||
$output = executeQueryArray('comment.getCommentPageList', $args);
|
||||
if(!$output->toBool()) return;
|
||||
}
|
||||
//insert in cache
|
||||
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
@ -401,7 +428,8 @@
|
|||
* @param int $document_srl
|
||||
* @return void
|
||||
*/
|
||||
function fixCommentList($module_srl, $document_srl) {
|
||||
function fixCommentList($module_srl, $document_srl)
|
||||
{
|
||||
// create a lock file to prevent repeated work when performing a batch job
|
||||
$lock_file = "./files/cache/tmp/lock.".$document_srl;
|
||||
if(file_exists($lock_file) && filemtime($lock_file)+60*60*10<time()) return;
|
||||
|
|
@ -423,23 +451,29 @@
|
|||
// get the log-in information for logged-in users
|
||||
$logged_info = Context::get('logged_info');
|
||||
// generate a hierarchical structure of comments for loop
|
||||
for($i=$comment_count-1;$i>=0;$i--) {
|
||||
for($i=$comment_count-1;$i>=0;$i--)
|
||||
{
|
||||
$comment_srl = $source_list[$i]->comment_srl;
|
||||
$parent_srl = $source_list[$i]->parent_srl;
|
||||
if(!$comment_srl) continue;
|
||||
// generate a list
|
||||
$list[$comment_srl] = $source_list[$i];
|
||||
|
||||
if($parent_srl) {
|
||||
if($parent_srl)
|
||||
{
|
||||
$list[$parent_srl]->child[] = &$list[$comment_srl];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$root->child[] = &$list[$comment_srl];
|
||||
}
|
||||
}
|
||||
$this->_arrangeComment($comment_list, $root->child, 0, null);
|
||||
// insert values to the database
|
||||
if(count($comment_list)) {
|
||||
foreach($comment_list as $comment_srl => $item) {
|
||||
if(count($comment_list))
|
||||
{
|
||||
foreach($comment_list as $comment_srl => $item)
|
||||
{
|
||||
$comment_args = null;
|
||||
$comment_args->comment_srl = $comment_srl;
|
||||
$comment_args->document_srl = $document_srl;
|
||||
|
|
@ -464,20 +498,24 @@
|
|||
* @param object $parent
|
||||
* @return void
|
||||
*/
|
||||
function _arrangeComment(&$comment_list, $list, $depth, $parent = null) {
|
||||
function _arrangeComment(&$comment_list, $list, $depth, $parent = null)
|
||||
{
|
||||
if(!count($list)) return;
|
||||
foreach($list as $key => $val) {
|
||||
|
||||
foreach($list as $key => $val)
|
||||
{
|
||||
if($parent) $val->head = $parent->head;
|
||||
else $val->head = $val->comment_srl;
|
||||
$val->arrange = count($comment_list)+1;
|
||||
|
||||
if($val->child) {
|
||||
if($val->child)
|
||||
{
|
||||
$val->depth = $depth;
|
||||
$comment_list[$val->comment_srl] = $val;
|
||||
$this->_arrangeComment($comment_list,$val->child,$depth+1, $val);
|
||||
unset($val->child);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$val->depth = $depth;
|
||||
$comment_list[$val->comment_srl] = $val;
|
||||
}
|
||||
|
|
@ -490,7 +528,8 @@
|
|||
* @param array $columnList
|
||||
* @return object
|
||||
*/
|
||||
function getTotalCommentList($obj, $columnList = array()) {
|
||||
function getTotalCommentList($obj, $columnList = array())
|
||||
{
|
||||
$query_id = 'comment.getTotalCommentList';
|
||||
// Variables
|
||||
$args->sort_index = 'list_order';
|
||||
|
|
@ -511,8 +550,10 @@
|
|||
// 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'));
|
||||
if($search_target && $search_keyword) {
|
||||
switch($search_target) {
|
||||
if($search_target && $search_keyword)
|
||||
{
|
||||
switch($search_target)
|
||||
{
|
||||
case 'content' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_content = $search_keyword;
|
||||
|
|
@ -573,7 +614,8 @@
|
|||
$output = executeQueryArray($query_id, $args, $columnList);
|
||||
// return when no result or error occurance
|
||||
if(!$output->toBool()||!count($output->data)) return $output;
|
||||
foreach($output->data as $key => $val) {
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
unset($_oComment);
|
||||
$_oComment = new CommentItem(0);
|
||||
$_oComment->setAttribute($val);
|
||||
|
|
@ -588,7 +630,8 @@
|
|||
* @param object $obj
|
||||
* @return int
|
||||
*/
|
||||
function getTotalCommentCount($obj) {
|
||||
function getTotalCommentCount($obj)
|
||||
{
|
||||
$query_id = 'comment.getTotalCommentCountByGroupStatus';
|
||||
// Variables
|
||||
$args->s_module_srl = $obj->module_srl;
|
||||
|
|
@ -596,8 +639,10 @@
|
|||
// 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'));
|
||||
if($search_target && $search_keyword) {
|
||||
switch($search_target) {
|
||||
if($search_target && $search_keyword)
|
||||
{
|
||||
switch($search_target)
|
||||
{
|
||||
case 'content' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_content = $search_keyword;
|
||||
|
|
@ -652,7 +697,8 @@
|
|||
* @param int $module_srl
|
||||
* @return object
|
||||
*/
|
||||
function getCommentConfig($module_srl) {
|
||||
function getCommentConfig($module_srl)
|
||||
{
|
||||
$oModuleModel = &getModel('module');
|
||||
$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl);
|
||||
if(!isset($comment_config->comment_count)) $comment_config->comment_count = 50;
|
||||
|
|
@ -678,10 +724,13 @@
|
|||
|
||||
$oModuleModel = &getModel('module');
|
||||
$comment_config = $oModuleModel->getModulePartConfig('comment',$module_srl);
|
||||
if($point == -1){
|
||||
if($point == -1)
|
||||
{
|
||||
if($comment_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request');
|
||||
$args->below_point = 0;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
if($comment_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request');
|
||||
$args->more_point = 0;
|
||||
}
|
||||
|
|
@ -691,8 +740,10 @@
|
|||
if(!$output->toBool()) return $output;
|
||||
|
||||
$oMemberModel = &getModel('member');
|
||||
if($output->data){
|
||||
foreach($output->data as $k => $d){
|
||||
if($output->data)
|
||||
{
|
||||
foreach($output->data as $k => $d)
|
||||
{
|
||||
$profile_image = $oMemberModel->getProfileImage($d->member_srl);
|
||||
$output->data[$k]->src = $profile_image->src;
|
||||
}
|
||||
|
|
@ -713,4 +764,5 @@
|
|||
else return $lang->secret_name_list;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.model.php */
|
||||
/* Location: ./modules/comment/comment.model.php */
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@
|
|||
* @package /modules/comment
|
||||
* @version 0.1
|
||||
*/
|
||||
class commentView extends comment {
|
||||
class commentView extends comment
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -20,11 +22,13 @@
|
|||
* @param string $obj
|
||||
* @return string
|
||||
*/
|
||||
function triggerDispCommentAdditionSetup(&$obj) {
|
||||
function triggerDispCommentAdditionSetup(&$obj)
|
||||
{
|
||||
$current_module_srl = Context::get('module_srl');
|
||||
$current_module_srls = Context::get('module_srls');
|
||||
|
||||
if(!$current_module_srl && !$current_module_srls) {
|
||||
if(!$current_module_srl && !$current_module_srls)
|
||||
{
|
||||
// get information of the selected module
|
||||
$current_module_info = Context::get('current_module_info');
|
||||
$current_module_srl = $current_module_info->module_srl;
|
||||
|
|
@ -46,4 +50,5 @@
|
|||
return new Object();
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file comment.view.php */
|
||||
/* Location: ./modules/comment/comment.view.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue