#19745697 trash module makem

document, comment module modify, because object in to trash and trash restore to object feature


git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8388 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-05-23 04:48:43 +00:00
parent 9e04e84a65
commit 8f3df45a2a
30 changed files with 949 additions and 34 deletions

View file

@ -17,6 +17,8 @@
* @brief Delete the selected comment from the administrator page
**/
function procCommentAdminDeleteChecked() {
$isTrash = Context::get('is_trash');
// Error display if none is selected
$cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
@ -24,23 +26,65 @@
$comment_count = count($comment_srl_list);
if(!$comment_count) return $this->stop('msg_cart_is_null');
$oCommentController = &getController('comment');
$oCommentController = &getController('comment');
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
$deleted_count = 0;
// Delete the comment posting
for($i=0;$i<$comment_count;$i++) {
$comment_srl = trim($comment_srl_list[$i]);
if(!$comment_srl) continue;
// comment into trash
if($isTrash == 'true') $this->_moveCommentToTrash($comment_srl_list, &$oCommentController, &$oDB);
$output = $oCommentController->deleteComment($comment_srl, true);
if(!$output->toBool()) continue;
$deleted_count = 0;
// Delete the comment posting
for($i=0;$i<$comment_count;$i++) {
$comment_srl = trim($comment_srl_list[$i]);
if(!$comment_srl) continue;
$deleted_count ++;
}
$output = $oCommentController->deleteComment($comment_srl, true, $isTrash);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$deleted_count ++;
}
$oDB->commit();
$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
}
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);
$oTrashController = &getController('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));
$oTrashVO->setIpaddress($_SERVER['REMOTE_ADDR']);
$oTrashVO->setRemoverSrl($logged_info->member_srl);
$oTrashVO->setRegdate(date('YmdHis'));
$output = $oTrashController->insertTrash($oTrashVO);
if (!$output->toBool()) {
$oDB->rollback();
return $output;
}
}
}
}
/**
* @brief cancel the blacklist of abused comments reported by other users
**/
@ -66,5 +110,49 @@
return $output;
}
/**
* @brief restore comment from trash module, called by trash module
* this method is passived
**/
function restoreTrash($originObject)
{
if(is_array($originObject)) $originObject = (object)$originObject;
$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;
$oCommentController = &getController('comment');
$output = $oCommentController->insertComment($obj);
return $output;
}
/**
* @brief empty comment in trash, called by trash module
* this method is passived
**/
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

@ -322,7 +322,7 @@
/**
* @brief Delete comment
**/
function deleteComment($comment_srl, $is_admin = false) {
function deleteComment($comment_srl, $is_admin = false, $isMoveToTrash = false) {
// create the comment model object
$oCommentModel = &getModel('comment');
// check if comment already exists
@ -369,8 +369,11 @@
}
}
$this->_deleteDeclaredComments($args);
$this->_deleteVotedComments($args);
if(!$isMoveToTrash)
{
$this->_deleteDeclaredComments($args);
$this->_deleteVotedComments($args);
}
// commit
$oDB->commit();
@ -379,6 +382,15 @@
return $output;
}
/**
* @brief remove all comment relation log
**/
function deleteCommentLog()
{
$this->_deleteDeclaredComments($args);
$this->_deleteVotedComments($args);
}
/**
* @brief remove all comments of the article
**/

View file

@ -9,6 +9,7 @@
$lang->comment_list = '댓글 목록';
$lang->cmd_toggle_checked_comment = '선택항목 반전';
$lang->cmd_delete_checked_comment = '선택항목 삭제';
$lang->cmd_trash = '휴지통으로 이동';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = '삭제할 글을 선택해주세요.';

View file

@ -23,11 +23,13 @@
<form id="fo_list" action="./" method="get" onsubmit="return procFilter(this, delete_checked)">
<input type="hidden" name="page" value="{$page}" />
<input type="hidden" name="is_trash" value="false" />
<!-- 모듈 선택 -->
<div class="fr">
<a href="{getUrl('','module','module','act','dispModuleSelectList','id','target_module','type','single')}" onclick="popopen(this.href,'ModuleSelect');return false;" class="button green"><span>{$lang->cmd_find_module}</span></a>
<span class="button red"><input type="submit" value="{$lang->cmd_delete_checked_comment}" /></span>
<span class="button red"><input type="submit" name="delete" value="{$lang->cmd_delete_checked_comment}" onclick="this.form.is_trash.value=false" /></span>
<span class="button red"><input type="submit" name="trash" value="{$lang->cmd_trash}" onclick="this.form.is_trash.value=true" /></span>
</div>
<!-- 목록 -->

View file

@ -3,6 +3,7 @@
<form id="fo_list" action="./" method="get" onsubmit="return procFilter(this, delete_checked)">
<input type="hidden" name="page" value="{$page}" />
<input type="hidden" name="is_trash" value="false" />
<!-- 목록 -->
<table cellspacing="0" class="crossTable">
@ -33,7 +34,8 @@
<a href="#" onclick="doCancelDeclare();return false;" class="button strong black"><span>{$lang->cmd_cancel_declare}</span></a>
<a href="javascript:XE.checkboxToggleAll({ checked:true })" class="button"><span>{$lang->cmd_select_all}</span></a>
<a href="javascript:XE.checkboxToggleAll()" class="button"><span>{$lang->cmd_reverse_all}</span></a>
<span class="button"><input type="submit" value="{$lang->cmd_delete_checked_comment}" /></span>
<span class="button"><input type="submit" value="{$lang->cmd_delete_checked_comment}" onclick="this.form.is_trash.value=false" /></span>
<span class="button"><input type="submit" name="trash" value="{$lang->cmd_trash}" onclick="this.form.is_trash.value=true" /></span>
</th>
</tr>
</tbody>