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:
ovclas 2012-11-16 01:30:37 +00:00
parent 71361410b6
commit 7eaa7bb8f9
6 changed files with 2109 additions and 1955 deletions

View file

@ -1,25 +1,26 @@
<?php <?php
/**
* commentAdminController class
* admin controller class of the comment module
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/
class commentAdminController extends comment
{
/** /**
* commentAdminController class * Initialization
* admin controller class of the comment module * @return void
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/ */
class commentAdminController extends comment { function init()
{
}
/**
* Initialization
* @return void
*/
function init() {
}
/** /**
* Modify comment(s) status to publish/unpublish if calling module is using Comment Approval System * Modify comment(s) status to publish/unpublish if calling module is using Comment Approval System
* @return void * @return void
*/ */
function procCommentAdminChangePublishedStatusChecked() function procCommentAdminChangePublishedStatusChecked()
{ // Error display if none is selected { // Error display if none is selected
$cart = Context::get('cart'); $cart = Context::get('cart');
@ -31,17 +32,17 @@
{ {
$comment_srl_list = $cart; $comment_srl_list = $cart;
} }
$this->procCommentAdminChangeStatus(); $this->procCommentAdminChangeStatus();
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', ''); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', '');
$this->setRedirectUrl($returnUrl); $this->setRedirectUrl($returnUrl);
} }
/** /**
* Change comment status * Change comment status
* @return void|object * @return void|object
*/ */
function procCommentAdminChangeStatus() function procCommentAdminChangeStatus()
{ {
$will_publish = Context::get('will_publish'); $will_publish = Context::get('will_publish');
@ -89,7 +90,7 @@
$comment = $oCommentModel->getComment($comment_srl); $comment = $oCommentModel->getComment($comment_srl);
if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request');
$document_srl = $comment->document_srl; $document_srl = $comment->document_srl;
if (!in_array($document_srl,$updated_documents_arr)) if(!in_array($document_srl,$updated_documents_arr))
{ {
$updated_documents_arr[] = $document_srl; $updated_documents_arr[] = $document_srl;
// update the number of comments // update the number of comments
@ -115,17 +116,18 @@
<br />Comment content: <br />Comment content:
".$comment->content." ".$comment->content."
<br /> <br />
"; ";
$oMail->setContent($mail_content); $oMail->setContent($mail_content);
$oMail->setSender($logged_info->user_name, $logged_info->email_address); $oMail->setSender($logged_info->user_name, $logged_info->email_address);
$document_author_email = $oDocument->variables['email_address']; $document_author_email = $oDocument->variables['email_address'];
//mail to author of thread - START //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(); $oMail->setReceiptor($document_author_email, $document_author_email);
$already_sent[] = $document_author_email; $oMail->send();
$already_sent[] = $document_author_email;
} }
//mail to author of thread - STOP //mail to author of thread - STOP
@ -133,10 +135,12 @@
if($module_info->admin_mail) if($module_info->admin_mail)
{ {
$target_mail = explode(',',$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]); $email_address = trim($target_mail[$i]);
if(!$email_address) continue; if(!$email_address) continue;
if($author_email != $email_address) { if($author_email != $email_address)
{
$oMail->setReceiptor($email_address, $email_address); $oMail->setReceiptor($email_address, $email_address);
$oMail->send(); $oMail->send();
} }
@ -150,227 +154,235 @@
// call a trigger for calling "send mail to subscribers" (for moment just for forum) // call a trigger for calling "send mail to subscribers" (for moment just for forum)
ModuleHandler::triggerCall("comment.procCommentAdminChangeStatus","after",$comment_srl_list); ModuleHandler::triggerCall("comment.procCommentAdminChangeStatus","after",$comment_srl_list);
} }
} }
/**
* Delete the selected comment from the administrator page
* @return void
*/
function procCommentAdminDeleteChecked() {
$isTrash = Context::get('is_trash');
// Error display if none is selected /**
$cart = Context::get('cart'); * Delete the selected comment from the administrator page
if(!$cart) return $this->stop('msg_cart_is_null'); * @return void
if(!is_array($cart)) $comment_srl_list= explode('|@|', $cart); */
else $comment_srl_list = $cart; function procCommentAdminDeleteChecked()
$comment_count = count($comment_srl_list); {
if(!$comment_count) return $this->stop('msg_cart_is_null'); $isTrash = Context::get('is_trash');
$oCommentController = &getController('comment'); // Error display if none is selected
// begin transaction $cart = Context::get('cart');
$oDB = &DB::getInstance(); if(!$cart) return $this->stop('msg_cart_is_null');
$oDB->begin(); if(!is_array($cart)) $comment_srl_list= explode('|@|', $cart);
else $comment_srl_list = $cart;
$comment_count = count($comment_srl_list);
if(!$comment_count) return $this->stop('msg_cart_is_null');
// for message send - start $oCommentController = &getController('comment');
$message_content = Context::get('message_content'); // begin transaction
if($message_content) $message_content = nl2br($message_content); $oDB = &DB::getInstance();
$oDB->begin();
if($message_content) { // for message send - start
$oCommunicationController = &getController('communication'); $message_content = Context::get('message_content');
$oCommentModel = &getModel('comment'); if($message_content) $message_content = nl2br($message_content);
$logged_info = Context::get('logged_info'); if($message_content)
{
$oCommunicationController = &getController('communication');
$oCommentModel = &getModel('comment');
$title = cut_str($message_content,10,'...'); $logged_info = Context::get('logged_info');
$sender_member_srl = $logged_info->member_srl;
for($i=0;$i<$comment_count;$i++) { $title = cut_str($message_content,10,'...');
$comment_srl = $comment_srl_list[$i]; $sender_member_srl = $logged_info->member_srl;
$oComment = $oCommentModel->getComment($comment_srl, true);
if(!$oComment->get('member_srl') || $oComment->get('member_srl')==$sender_member_srl) continue; for($i=0;$i<$comment_count;$i++)
{
$comment_srl = $comment_srl_list[$i];
$oComment = $oCommentModel->getComment($comment_srl, true);
$content = sprintf("<div>%s</div><hr /><div style=\"font-weight:bold\">%s</div>",$message_content, $oComment->getContentText(20)); if(!$oComment->get('member_srl') || $oComment->get('member_srl')==$sender_member_srl) continue;
$oCommunicationController->sendMessage($sender_member_srl, $oComment->get('member_srl'), $title, $content, false); $content = sprintf("<div>%s</div><hr /><div style=\"font-weight:bold\">%s</div>",$message_content, $oComment->getContentText(20));
}
$oCommunicationController->sendMessage($sender_member_srl, $oComment->get('member_srl'), $title, $content, false);
} }
// for message send - end }
// for message send - end
// comment into trash // comment into trash
if($isTrash == 'true') $this->_moveCommentToTrash($comment_srl_list, $oCommentController, $oDB); if($isTrash == 'true') $this->_moveCommentToTrash($comment_srl_list, $oCommentController, $oDB);
$deleted_count = 0; $deleted_count = 0;
// Delete the comment posting // 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; $comment_srl = trim($comment_srl_list[$i]);
if(!$comment_srl) continue;
$output = $oCommentController->deleteComment($comment_srl, true, $isTrash); $output = $oCommentController->deleteComment($comment_srl, true, $isTrash);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$deleted_count ++;
}
$oDB->commit();
$msgCode = '';
if($isTrash == 'true') $msgCode = 'success_trashed';
else $msgCode = 'success_deleted';
//$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
$this->setMessage($msgCode, 'info');
//set url params
$search_keyword = Context::get('search_keyword');
$search_target = Context::get('search_target');
$page = Context::get('page');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', $search_keyword, 'search_target', $search_target,'page',$page);
$this->setRedirectUrl($returnUrl);
}
/**
* comment move to trash
* @return void|object
*/
function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB)
{
require_once(_XE_PATH_.'modules/trash/model/TrashVO.php');
if(is_array($commentSrlList))
{
$logged_info = Context::get('logged_info');
$oCommentModel = &getModel('comment');
$commentItemList = $oCommentModel->getComments($commentSrlList);
$oTrashAdminController = &getAdminController('trash');
foreach($commentItemList AS $key=>$oComment)
{
$oTrashVO = new TrashVO();
$oTrashVO->setTrashSrl(getNextSequence());
$oTrashVO->setTitle(trim(strip_tags($oComment->variables['content'])));
$oTrashVO->setOriginModule('comment');
$oTrashVO->setSerializedObject(serialize($oComment->variables));
$output = $oTrashAdminController->insertTrash($oTrashVO);
if(!$output->toBool()) if(!$output->toBool())
{ {
$oDB->rollback(); $oDB->rollback();
return $output; return $output;
} }
$deleted_count ++;
} }
}
}
$oDB->commit(); /**
* Cancel the blacklist of abused comments reported by other users
* @return void|object
*/
function procCommentAdminCancelDeclare()
{
$comment_srl = trim(Context::get('comment_srl'));
$msgCode = ''; if($comment_srl)
if($isTrash == 'true') $msgCode = 'success_trashed';
else $msgCode = 'success_deleted';
//$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
$this->setMessage($msgCode, 'info');
//set url params
$search_keyword = Context::get('search_keyword');
$search_target = Context::get('search_target');
$page = Context::get('page');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', $search_keyword, 'search_target', $search_target,'page',$page);
$this->setRedirectUrl($returnUrl);
}
/**
* comment move to trash
* @return void|object
*/
function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB)
{ {
require_once(_XE_PATH_.'modules/trash/model/TrashVO.php'); $args->comment_srl = $comment_srl;
$output = executeQuery('comment.deleteDeclaredComments', $args);
if(!$output->toBool()) return $output;
}
}
if(is_array($commentSrlList)) /**
* Comment add to _SESSION
* @return void
*/
function procCommentAdminAddCart()
{
$comment_srl = (int)Context::get('comment_srl');
$oCommentModel = &getModel('comment');
$columnList = array('comment_srl');
$commentSrlList = array($comment_srl);
$output = $oCommentModel->getComments($commentSrlList);
if(is_array($output))
{
foreach($output AS $key=>$value)
{ {
$logged_info = Context::get('logged_info'); if($_SESSION['comment_management'][$key]) unset($_SESSION['comment_management'][$key]);
$oCommentModel = &getModel('comment'); else $_SESSION['comment_management'][$key] = true;
$commentItemList = $oCommentModel->getComments($commentSrlList);
$oTrashAdminController = &getAdminController('trash');
foreach($commentItemList AS $key=>$oComment)
{
$oTrashVO = new TrashVO();
$oTrashVO->setTrashSrl(getNextSequence());
$oTrashVO->setTitle(trim(strip_tags($oComment->variables['content'])));
$oTrashVO->setOriginModule('comment');
$oTrashVO->setSerializedObject(serialize($oComment->variables));
$output = $oTrashAdminController->insertTrash($oTrashVO);
if (!$output->toBool()) {
$oDB->rollback();
return $output;
}
}
} }
} }
}
/** /**
* Cancel the blacklist of abused comments reported by other users * Delete all comments of the specific module
* @return void|object * @return object
*/ */
function procCommentAdminCancelDeclare() { function deleteModuleComments($module_srl)
$comment_srl = trim(Context::get('comment_srl')); {
$args->module_srl = $module_srl;
$output = executeQuery('comment.deleteModuleComments', $args);
if(!$output->toBool()) return $output;
if($comment_srl) { $output = executeQuery('comment.deleteModuleCommentsList', $args);
$args->comment_srl = $comment_srl;
$output = executeQuery('comment.deleteDeclaredComments', $args);
if(!$output->toBool()) return $output;
}
}
/** //remove from cache
* Comment add to _SESSION $oCacheHandler = &CacheHandler::getInstance('object');
* @return void if($oCacheHandler->isSupport())
*/
function procCommentAdminAddCart()
{ {
$comment_srl = (int)Context::get('comment_srl'); // Invalidate newest comments. Per document cache is invalidated inside document admin controller.
$oCacheHandler->invalidateGroupKey('newestCommentsList');
$oCommentModel = &getModel('comment');
$columnList = array('comment_srl');
$commentSrlList = array($comment_srl);
$output = $oCommentModel->getComments($commentSrlList);
if(is_array($output))
{
foreach($output AS $key=>$value)
{
if($_SESSION['comment_management'][$key]) unset($_SESSION['comment_management'][$key]);
else $_SESSION['comment_management'][$key] = true;
}
}
} }
return $output;
}
/** /**
* Delete all comments of the specific module * Restore comment from trash module, called by trash module
* @return object * this method is passived
*/ * @return object
function deleteModuleComments($module_srl) { */
$args->module_srl = $module_srl; function restoreTrash($originObject)
$output = executeQuery('comment.deleteModuleComments', $args); {
if(!$output->toBool()) return $output; if(is_array($originObject)) $originObject = (object)$originObject;
$output = executeQuery('comment.deleteModuleCommentsList', $args); $obj->document_srl = $originObject->document_srl;
$obj->comment_srl = $originObject->comment_srl;
$obj->parent_srl = $originObject->parent_srl;
$obj->content = $originObject->content;
$obj->password = $originObject->password;
$obj->nick_name = $originObject->nick_name;
$obj->member_srl = $originObject->member_srl;
$obj->email_address = $originObject->email_address;
$obj->homepage = $originObject->homepage;
$obj->is_secret = $originObject->is_secret;
$obj->notify_message = $originObject->notify_message;
$obj->module_srl = $originObject->module_srl;
//remove from cache $oCommentController = &getController('comment');
$oCacheHandler = &CacheHandler::getInstance('object'); $output = $oCommentController->insertComment($obj);
if($oCacheHandler->isSupport())
{
// Invalidate newest comments. Per document cache is invalidated inside document admin controller.
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;
}
/** return $output;
* Restore comment from trash module, called by trash module }
* this method is passived
* @return object
*/
function restoreTrash($originObject)
{
if(is_array($originObject)) $originObject = (object)$originObject;
$obj->document_srl = $originObject->document_srl; /**
$obj->comment_srl = $originObject->comment_srl; * Empty comment in trash, called by trash module
$obj->parent_srl = $originObject->parent_srl; * this method is passived
$obj->content = $originObject->content; * @return object
$obj->password = $originObject->password; */
$obj->nick_name = $originObject->nick_name; function emptyTrash($originObject)
$obj->member_srl = $originObject->member_srl; {
$obj->email_address = $originObject->email_address; $originObject = unserialize($originObject);
$obj->homepage = $originObject->homepage; if(is_array($originObject)) $originObject = (object) $originObject;
$obj->is_secret = $originObject->is_secret;
$obj->notify_message = $originObject->notify_message;
$obj->module_srl = $originObject->module_srl;
$oCommentController = &getController('comment'); $oComment = new commentItem();
$output = $oCommentController->insertComment($obj); $oComment->setAttribute($originObject);
return $output; //already comment deleted, therefore only comment log delete
} $oCommentController = &getController('comment');
$output = $oCommentController->deleteCommentLog($oComment->get('comment_srl'));
/** return $output;
* Empty comment in trash, called by trash module }
* this method is passived }
* @return object /* End of file comment.admin.controller.php */
*/ /* Location: ./modules/comment/comment.admin.controller.php */
function emptyTrash($originObject)
{
$originObject = unserialize($originObject);
if(is_array($originObject)) $originObject = (object) $originObject;
$oComment = new commentItem();
$oComment->setAttribute($originObject);
//already comment deleted, therefore only comment log delete
$oCommentController = &getController('comment');
$output = $oCommentController->deleteCommentLog($oComment->get('comment_srl'));
return $output;
}
}
?>

View file

@ -1,108 +1,115 @@
<?php <?php
/**
* commentAdminView class
* admin view class of the comment module
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/
class commentAdminView extends comment
{
/** /**
* commentAdminView class * Initialization
* admin view class of the comment module * @return void
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/ */
class commentAdminView extends comment { function init()
/** {
* Initialization }
* @return void
/**
* Display the list(for administrators)
* @return void
*/
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
$args->page_count = 5; // / the number of pages to appear on the page navigation
$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;
}
*/ */
function init() {
}
/** // get a list by using comment->getCommentList.
* Display the list(for administrators) $oCommentModel = &getModel('comment');
* @return void $secretNameList = $oCommentModel->getSecretNameList();
*/ $columnList = array('comment_srl', 'document_srl', 'is_secret', 'status', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress', 'voted_count', 'blamed_count');
function dispCommentAdminList() { $output = $oCommentModel->getTotalCommentList($args, $columnList);
// 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
$args->page_count = 5; // / the number of pages to appear on the page navigation
$args->sort_index = 'list_order'; // /< Sorting values $oCommentModel = &getModel("comment");
$modules = $oCommentModel->getDistinctModules();
$modules_list = $modules;
$args->module_srl = Context::get('module_srl'); // set values in the return object of comment_model:: getTotalCommentList() in order to use a template.
/* Context::set('total_count', $output->total_count);
$search_target = Context::get('search_target'); Context::set('total_page', $output->total_page);
$search_keyword = Context::get('search_keyword'); Context::set('page', $output->page);
if ($search_target == 'is_published' && $search_keyword == 'Y') 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
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('comment_list');
}
/**
* Show the blacklist of comments in the admin page
* @return void
*/
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
$args->page_count = 10; // /< the number of pages to appear on the page navigation
$args->sort_index = 'comment_declared.declared_count'; // /< sorting values
$args->order_type = 'desc'; // /< sorted value
// get a list
$declared_output = executeQuery('comment.getDeclaredList', $args);
$oCommentModel = &getModel('comment');
if($declared_output->data && count($declared_output->data))
{
$comment_list = array();
foreach($declared_output->data as $key => $comment)
{ {
$args->status = 1; $comment_list[$key] = new commentItem();
$comment_list[$key]->setAttribute($comment);
} }
if ($search_target == 'is_published' && $search_keyword == 'N') $declared_output->data = $comment_list;
{ }
$args->status = 0;
}
*/
// get a list by using comment->getCommentList.
$oCommentModel = &getModel('comment');
$secretNameList = $oCommentModel->getSecretNameList();
$columnList = array('comment_srl', 'document_srl', 'is_secret', 'status', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress', 'voted_count', 'blamed_count');
$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
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('comment_list');
}
/** $secretNameList = $oCommentModel->getSecretNameList();
* Show the blacklist of comments in the admin page
* @return void
*/
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
$args->page_count = 10; // /< the number of pages to appear on the page navigation
$args->sort_index = 'comment_declared.declared_count'; // /< sorting values // set values in the return object of comment_model:: getCommentList() in order to use a template.
$args->order_type = 'desc'; // /< sorted value Context::set('total_count', $declared_output->total_count);
Context::set('total_page', $declared_output->total_page);
// get a list Context::set('page', $declared_output->page);
$declared_output = executeQuery('comment.getDeclaredList', $args); Context::set('comment_list', $declared_output->data);
$oCommentModel = &getModel('comment'); Context::set('page_navigation', $declared_output->page_navigation);
Context::set('secret_name_list', $secretNameList);
if($declared_output->data && count($declared_output->data)) { // set the template
$comment_list = array(); $this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('declared_list');
foreach($declared_output->data as $key => $comment) { }
$comment_list[$key] = new commentItem(); }
$comment_list[$key]->setAttribute($comment); /* End of file comment.admin.view.php */
} /* Location: ./modules/comment/comment.admin.view.php */
$declared_output->data = $comment_list;
}
$secretNameList = $oCommentModel->getSecretNameList();
// set values in the return object of comment_model:: getCommentList() in order to use 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('comment_list', $declared_output->data);
Context::set('page_navigation', $declared_output->page_navigation);
Context::set('secret_name_list', $secretNameList);
// set the template
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('declared_list');
}
}
?>

View file

@ -1,151 +1,164 @@
<?php <?php
require_once(_XE_PATH_.'modules/comment/comment.item.php'); require_once(_XE_PATH_.'modules/comment/comment.item.php');
/**
* comment
* comment module's high class
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/
class comment extends ModuleObject
{
/**
* Implemented if additional tasks are required when installing
* @return Object
*/
function moduleInstall()
{
$oDB = &DB::getInstance();
// register the action forward (for using on the admin mode)
$oModuleController = &getController('module');
$oDB->addIndex
(
"comments",
"idx_module_list_order",
array("module_srl", "list_order"),
true
);
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2008. 02. 22 add comment setting when a new module added
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
return new Object();
}
/** /**
* comment * Method to check if installation is succeeded
* comment module's high class * @return bool
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/ */
class comment extends ModuleObject { function checkUpdate()
/** {
* Implemented if additional tasks are required when installing $oDB = &DB::getInstance();
* @return Object $oModuleModel = &getModel('module');
*/ // 2007. 10. 17 add a trigger to delete comments together with posting deleted
function moduleInstall() { if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) return true;
$oDB = &DB::getInstance(); // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) return true;
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments","voted_count")) return true;
if(!$oDB->isColumnExists("comments","notify_message")) return true;
// 2008. 02. 22 add comment setting when a new module added
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) return true;
// 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) return true;
if(!$oDB->isColumnExists("comment_voted_log", "point")) return true;
// register the action forward (for using on the admin mode) if (!$oDB->isIndexExists("comments", "idx_module_list_order"))
$oModuleController = &getController('module'); 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;
}
$oDB->addIndex // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
( if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) return true;
"comments",
"idx_module_list_order",
array("module_srl", "list_order"),
true
);
// 2007. 10. 17 add a trigger to delete comments together with posting deleted return false;
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); }
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2008. 02. 22 add comment setting when a new module added
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
return new Object(); /**
} * Execute update
* @return Object
*/
function moduleUpdate()
{
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
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"))
{
$oDB->addColumn("comments","voted_count", "number","11");
$oDB->addIndex("comments","idx_voted_count", array("voted_count"));
}
/** if(!$oDB->isColumnExists("comments","notify_message"))
* Method to check if installation is succeeded {
* @return bool $oDB->addColumn("comments","notify_message", "char","1");
*/ }
function checkUpdate() { // 2008. 02. 22 add comment setting when a new module added
$oDB = &DB::getInstance(); if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
$oModuleModel = &getModel('module'); $oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
// 2007. 10. 17 add a trigger to delete comments together with posting deleted // 2008. 05. 14 add a column for blamed count
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) return true; if(!$oDB->isColumnExists("comments", "blamed_count"))
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted {
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) return true; $oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, true);
// 2007. 10. 23 add a column for recommendation votes or notification of the comments $oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count'));
if(!$oDB->isColumnExists("comments","voted_count")) return true; }
if(!$oDB->isColumnExists("comments","notify_message")) return true; if(!$oDB->isColumnExists("comment_voted_log", "point"))
// 2008. 02. 22 add comment setting when a new module added $oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, true);
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) return true;
// 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) return true;
if(!$oDB->isColumnExists("comment_voted_log", "point")) return true;
if (!$oDB->isIndexExists("comments", "idx_module_list_order")) if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
return true; {
//2012. 02. 24 add comment published status column and index $oDB->addIndex
if(!$oDB->isColumnExists("comments", "status")) (
{ "comments",
return true; "idx_module_list_order",
} array("module_srl", "list_order"),
if (!$oDB->isIndexExists("comments", "idx_status")) true
{ );
return true; }
}
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied //2012. 02. 24 add comment published status column and index
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) return true; 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 false; // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
} if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
{
$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after');
}
/** return new Object(0, 'success_updated');
* Execute update }
* @return Object
*/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
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")) {
$oDB->addColumn("comments","voted_count", "number","11");
$oDB->addIndex("comments","idx_voted_count", array("voted_count"));
}
if(!$oDB->isColumnExists("comments","notify_message")) { /**
$oDB->addColumn("comments","notify_message", "char","1"); * Regenerate cache file
} * @return void
// 2008. 02. 22 add comment setting when a new module added */
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) function recompileCache()
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'); {
// 2008. 05. 14 add a column for blamed count }
if(!$oDB->isColumnExists("comments", "blamed_count")) { }
$oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, true); /* End of file comment.class.php */
$oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count')); /* Location: ./modules/comment/comment.class.php */
}
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
(
"comments",
"idx_module_list_order",
array("module_srl", "list_order"),
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
);
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
{
$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after');
}
return new Object(0, 'success_updated');
}
/**
* Regenerate cache file
* @return void
*/
function recompileCache() {
}
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,49 +1,54 @@
<?php <?php
/**
* commentView class
* comment module's view class
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/
class commentView extends comment
{
/** /**
* commentView class * Initialization
* comment module's view class * @return void
*
* @author NHN (developers@xpressengine.com)
* @package /modules/comment
* @version 0.1
*/ */
class commentView extends comment { function init()
/** {
* Initialization }
* @return void
*/
function init() {
}
/** /**
* Add a form fot comment setting on the additional setting of module * Add a form fot comment setting on the additional setting of module
* @param string $obj * @param string $obj
* @return string * @return string
*/ */
function triggerDispCommentAdditionSetup(&$obj) { function triggerDispCommentAdditionSetup(&$obj)
$current_module_srl = Context::get('module_srl'); {
$current_module_srls = Context::get('module_srls'); $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'); // get information of the selected module
$current_module_srl = $current_module_info->module_srl; $current_module_info = Context::get('current_module_info');
if(!$current_module_srl) return new Object(); $current_module_srl = $current_module_info->module_srl;
} if(!$current_module_srl) return new Object();
// get the comment configuration }
$oCommentModel = &getModel('comment'); // get the comment configuration
$comment_config = $oCommentModel->getCommentConfig($current_module_srl); $oCommentModel = &getModel('comment');
Context::set('comment_config', $comment_config); $comment_config = $oCommentModel->getCommentConfig($current_module_srl);
// get a group list Context::set('comment_config', $comment_config);
$oMemberModel = &getModel('member'); // get a group list
$group_list = $oMemberModel->getGroups(); $oMemberModel = &getModel('member');
Context::set('group_list', $group_list); $group_list = $oMemberModel->getGroups();
// Set a template file Context::set('group_list', $group_list);
$oTemplate = &TemplateHandler::getInstance(); // Set a template file
$tpl = $oTemplate->compile($this->module_path.'tpl', 'comment_module_config'); $oTemplate = &TemplateHandler::getInstance();
$obj .= $tpl; $tpl = $oTemplate->compile($this->module_path.'tpl', 'comment_module_config');
$obj .= $tpl;
return new Object(); return new Object();
} }
} }
?> /* End of file comment.view.php */
/* Location: ./modules/comment/comment.view.php */