Merge pull request #312 from bjrambo/pr/document-update-log

게시글 수정내역을 저장하도록 개선
This commit is contained in:
BJRambo 2016-03-04 17:08:04 +09:00
commit 3341037724
18 changed files with 350 additions and 9 deletions

View file

@ -106,6 +106,11 @@ class boardController extends board
}
}
if($this->module_info->update_log == 'Y')
{
$obj->update_log_setting = 'Y';
}
// update the document if it is existed
if($is_update)
{
@ -146,12 +151,14 @@ class boardController extends board
$obj->last_update = $obj->regdate = date('YmdHis');
$obj->update_order = $obj->list_order = (getNextSequence() * -1);
}
$obj->reason_update = escape($obj->reason_update);
$output = $oDocumentController->updateDocument($oDocument, $obj);
$msg_code = 'success_updated';
// insert a new document otherwise
} else {
}
else
{
$output = $oDocumentController->insertDocument($obj, $bAnonymous);
$msg_code = 'success_registed';
$obj->document_srl = $output->get('document_srl');

View file

@ -333,6 +333,8 @@ class boardView extends board
}
}
Context::set('update_view', $this->grant->update_view);
// setup the document oject on context
$oDocument->add('module_srl', $this->module_srl);
Context::set('oDocument', $oDocument);
@ -1140,6 +1142,44 @@ class boardView extends board
$this->setTemplateFile('message');
}
function dispBoardUpdateLog()
{
$oDocumentModel = getModel('document');
$document_srl = Context::get('document_srl');
if($this->grant->update_view !== true)
{
return new Object(-1, 'msg_not_permitted');
}
$updatelog = $oDocumentModel->getDocumentUpdateLog($document_srl);
Context::set('total_count', $updatelog->page_navigation->total_count);
Context::set('total_page', $updatelog->page_navigation->total_page);
Context::set('page', $updatelog->page);
Context::set('page_navigation', $updatelog->page_navigation);
Context::set('updatelog', $updatelog);
$this->setTemplateFile('update_list');
}
function dispBoardUpdateLogView()
{
$oDocumentModel = getModel('document');
$update_id = Context::get('update_id');
if($this->grant->update_view !== true)
{
return new Object(-1, 'msg_not_permitted');
}
$update_log = $oDocumentModel->getUpdateLog($update_id);
$extra_vars = unserialize($update_log->extra_vars);
Context::set('extra_vars', $extra_vars);
Context::set('update_log', $update_log);
$this->setTemplateFile('update_view');
}
/**
* @brief the method for displaying the warning messages
* display an error message if it has not a special design

View file

@ -21,6 +21,9 @@
<title xml:lang="zh-TW">檢視</title>
<title xml:lang="tr">görüş</title>
</grant>
<grant name="update_view" default="guest">
<title xml:lang="ko">수정내역 조회</title>
</grant>
<grant name="write_document" default="guest">
<title xml:lang="ko">글 작성</title>
<title xml:lang="zh-CN">发表新主题</title>
@ -63,6 +66,7 @@
<action name="dispBoardCategoryList" type="view" />
<action name="dispBoardContentCommentList" type="view" />
<action name="dispBoardContentFileList" type="view" />
<action name="dispBoardUpdateLog" type="view" />
<action name="dispBoardTagList" type="view" />
<action name="dispBoardWrite" type="view" standalone="false" />
@ -73,6 +77,7 @@
<action name="dispBoardDeleteComment" type="view" standalone="false" />
<action name="dispBoardDeleteTrackback" type="view" standalone="false" />
<action name="dispBoardMessage" type="view" />
<action name="dispBoardUpdateLogView" type="view" />
<action name="procBoardInsertDocument" type="controller" ruleset="insertDocument" standalone="false" />
<action name="procBoardDeleteDocument" type="controller" standalone="false" />

View file

@ -14,6 +14,8 @@ $lang->consultation = '상담 기능';
$lang->secret = '비밀글 기능';
$lang->thisissecret = '비밀글입니다.';
$lang->admin_mail = '관리자 메일';
$lang->update_log = '게시글 수정 내역';
$lang->last_updater = '수정한사람';
$lang->cmd_board_list = '게시판 목록';
$lang->cmd_module_config = '게시판 공통 설정';
$lang->cmd_board_info = '게시판 정보';
@ -31,6 +33,7 @@ $lang->about_admin_mail = '글이나 댓글이 등록될때 등록된 메일주
$lang->about_list_config = '게시판의 목록형식 사용시 원하는 항목들로 배치를 할 수 있습니다. 단 스킨에서 지원하지 않는 경우 불가능합니다. 대상항목/ 표시항목의 항목을 더블클릭하면 추가/ 제거가 됩니다.';
$lang->about_use_status = '글 작성 시 선택할 수 있는 상태를 지정해주세요.';
$lang->about_protect_comment = '댓글의 댓글이 있을경우 해당댓글을 삭제 및 수정을 할 수 없도록 합니다.';
$lang->about_update_log = '게시글을 수정할 경우 수정한 내역을 저장하도록 합니다.';
$lang->msg_not_enough_point = '포인트가 부족합니다';
$lang->write_comment = '댓글 쓰기';
$lang->msg_not_allow_comment = '해당 글의 댓글 쓰기가 잠겨있습니다.';
@ -52,4 +55,8 @@ $lang->msg_admin_comment_no_modify = '최고관리자의 댓글을 수정할 권
$lang->msg_board_delete_protect_comment = '댓글이 작성된 댓글의 글을 삭제할 수 없습니다.';
$lang->msg_board_update_protect_comment = '댓글이 작성된 댓글의 글을 수정할 수 없습니다.';
$lang->msg_protect_regdate_document = '%s일 이전의 게시글은 수정 또는 삭제 할 수 없습니다.';
$lang->msg_protect_regdate_comment = '%s일 이전의 댓글은 수정 또는 삭제 할 수 없습니다.';
$lang->msg_protect_regdate_comment = '%s일 이전의 댓글은 수정 또는 삭제 할 수 없습니다.';
$lang->msg_dont_have_update_log = '업데이트 로그가 기록되어 있지 않은 게시글입니다.';
$lang->original_letter = '원본글';
$lang->msg_warning_update_log = '<span class="x_label x_label-important">주의!</span> 사용시 디비가 많이 늘어날 수 있습니다.';
$lang->reason_update = '수정한 이유';

View file

@ -114,7 +114,8 @@
<img cond="$oDocument->getProfileImage()" src="{$oDocument->getProfileImage()}" alt="Profile" class="pf" />
<div cond="$oDocument->getSignature()" class="tx">{$oDocument->getSignature()}</div>
</div>
<div class="btnArea">
<div class="btnArea">
<a cond="$update_view" class="btn" href="{getUrl('act','dispBoardUpdateLog','document_srl',$oDocument->document_srl,'comment_srl','')}"><i class="xi-list-ul"></i>{$lang->update_log}</a>
<a cond="$oDocument->isEditable()" class="btn" href="{getUrl('act','dispBoardWrite','document_srl',$oDocument->document_srl,'comment_srl','')}"><i class="xi-eraser"></i>{$lang->cmd_modify}</a>
<a cond="$oDocument->isEditable()" class="btn" href="{getUrl('act','dispBoardDelete','document_srl',$oDocument->document_srl,'comment_srl','')}"><i class="xi-trash"></i>{$lang->cmd_delete}</a>
<span class="etc">

View file

@ -263,6 +263,16 @@
right:0;
border-radius: 0 2px 2px 0;
}
.update-log {
width:100%;
border-bottom:1px solid #dbdbdb;
margin: 5px auto 5px auto;
padding:5px;
}
/* Board Write */
/* write_form.html */
@ -463,6 +473,9 @@
white-space: nowrap;
color : #666;
}
.update-log .read_header .meta {
border-bottom:0;
}
.read_header .meta > span { margin-left: 8px ;}
.read_header .meta > span:first-child {margin-left:0;}
.read_header .meta:after {

View file

@ -0,0 +1,42 @@
<include target="_header.html" />
<div class="board_list" id="board_list">
<table width="100%" border="1" cellspacing="0" summary="List of Articles">
<thead>
<tr>
<th scope="col" class="title"><span>{$lang->title}</span></th>
<th scope="col"><span>{$lang->writer}</span></th>
<th scope="col"><span>{$lang->last_updater}</span></th>
<th scope="col"><span>{$lang->last_post}</span></th>
</tr>
</thead>
<tbody cond="$updatelog->data">
<tr loop="$updatelog->data=>$val">
<td class="title">
<a href="{getUrl('', 'mid', $mid, 'act', 'dispBoardUpdateLogView', 'update_id', $val->update_id)}">{$val->title}</a>
</td>
<td class="author">
{$val->update_nick_name}
</td>
<td class="author">
{$val->nick_name}
</td>
<td class="time">
{zdate($val->regdate, 'Y.m.d H:i:s')}
</td>
</tr>
</tbody>
<tbody cond="!$updatelog->data">
<tr>
<td colspan="4" style="text-align: center">{$lang->msg_dont_have_update_log}</td>
</tr>
</tbody>
</table>
</div>
<div class="pagination pagination-centered">
<a href="{getUrl('page','','module_srl','')}" class="direction">&laquo; {$lang->first_page}</a>
<!--@while($page_no = $page_navigation->getNextPage())-->
<strong cond="$page==$page_no">{$page_no}</strong>
<a cond="$page!=$page_no" href="{getUrl('page',$page_no,'module_srl','')}">{$page_no}</a>
<!--@end-->
<a href="{getUrl('page',$page_navigation->last_page,'module_srl','')}" class="direction">{$lang->last_page} &raquo;</a>
</div>

View file

@ -0,0 +1,29 @@
<include target="_header.html" />
<div class="update-log">
<div class="board_read" >
<!-- READ HEADER -->
<div class="read_header">
<h1>
<a href="{getUrl('category',$update_log->category_srl, 'document_srl', '')}" class="category" cond="$module_info->use_category=='Y' && $update_log->category_srl">{$category_list[$update_log->category_srl]->title}</a>
<a>{$update_log->title}</a>
</h1>
<p class="meta">
<span class="time">
<i class="xi-time"></i> {zdate($update_log->regdate,'Y.m.d H:i:s')}
</span>
</p>
</div>
<!-- READ BODY -->
<div class="read_body">
{$update_log->content}
</div>
<p loop="$extra_vars=>$key=>$val">
{$key} : {$val}
</p>
<p>
{$lang->reason_update} :
{$update_log->reason_update}
</p>
<!-- /READ BODY -->
</div>
</div>

View file

@ -43,6 +43,7 @@
<input type="checkbox" name="notify_message" class="iCheck" value="Y" checked="checked"|cond="$oDocument->useNotify()" id="notify_message" />
<label for="notify_message">{$lang->notify}</label>
</block>
<!--@if(is_array($status_list))-->
<!--@foreach($status_list AS $key=>$value)-->
<input type="radio" name="status" value="{$key}" id="{$key}" <!--@if($oDocument->get('status') == $key || ($key == 'PUBLIC' && !$document_srl))-->checked="checked"<!--@end--> />
@ -66,7 +67,11 @@
<span class="item">
<label for="tags" class="iLabel">{$lang->tag}: {$lang->about_tag}</label>
<input type="text" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="iText" style="width:300px" title="Tag" />
</span>
</span>
<span class="item" cond="$oDocument->get('document_srl') && $module_info->update_log == 'Y'">
<label for="reason_update" class="iLabel">{$lang->reason_update}</label>
<input type="text" name="reason_update" id="reason_update" value="" class="iText" style="width:300px" title="reason update" />
</span>
</div>
<div class="btnArea">
<block cond="!$oDocument->isExists() || $oDocument->get('status') == 'TEMP'">

View file

@ -199,6 +199,13 @@
<label class="x_inline" for="consultation"><input type="checkbox" name="consultation" id="consultation" value="Y" checked="checked"|cond="$module_info->consultation == 'Y'" /> {$lang->about_consultation}</label>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->update_log}</label>
<div class="x_controls">
<label class="x_inline" for="update_log"><input type="checkbox" name="update_log" id="update_log" value="Y" checked="checked"|cond="$module_info->update_log == 'Y'" /> {$lang->about_update_log}</label>
<p>{$lang->msg_warning_update_log}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->protect_content}</label>
<div class="x_controls">

View file

@ -145,11 +145,20 @@ class documentAdminController extends document
$obj->module_srl = $module_srl;
$obj->category_srl = $category_srl;
$output = executeQuery('document.updateDocumentModule', $obj);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
else
{
$update_output = $oDocumentController->insertDocumentUpdateLog($obj);
if(!$update_output->toBool())
{
$oDB->rollback();
return $update_output;
}
}
//Move a module of the extra vars
$output = executeQuery('document.moveDocumentExtraVars', $obj);
if(!$output->toBool()) {

View file

@ -439,6 +439,7 @@ class documentController extends document
return $output;
}
// Insert extra variables if the document successfully inserted.
$extra_vars = array();
$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
if(count($extra_keys))
{
@ -449,13 +450,20 @@ class documentController extends document
{
$tmp = $obj->{'extra_vars'.$idx};
if(is_array($tmp))
{
$value = implode('|@|', $tmp);
}
else
{
$value = trim($tmp);
}
}
else if(isset($obj->{$extra_item->name}))
{
$value = trim($obj->{$extra_item->name});
}
else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
if($value == NULL) continue;
$extra_vars[$extra_item->name] = $value;
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
}
}
@ -464,6 +472,16 @@ class documentController extends document
// Call a trigger (after)
if($output->toBool())
{
if($obj->update_log_setting === 'Y')
{
$obj->extra_vars = serialize($extra_vars);
$update_output = $this->insertDocumentUpdateLog($obj);
if(!$update_output->toBool())
{
$oDB->rollback();
return $update_output;
}
}
$trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
if(!$trigger_output->toBool())
{
@ -686,7 +704,9 @@ class documentController extends document
$oDB->rollback();
return $output;
}
// Remove all extra variables
$extra_vars = array();
if(Context::get('act')!='procFileDelete')
{
$this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType());
@ -707,6 +727,7 @@ class documentController extends document
}
else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
if($value == NULL) continue;
$extra_vars[$extra_item->name] = $value;
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
}
}
@ -723,6 +744,16 @@ class documentController extends document
// Call a trigger (after)
if($output->toBool())
{
if($obj->update_log_setting === 'Y')
{
$obj->extra_vars = serialize($extra_vars);
$update_output = $this->insertDocumentUpdateLog($obj, $source_obj);
if(!$update_output->toBool())
{
$oDB->rollback();
return $update_output;
}
}
$trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
if(!$trigger_output->toBool())
{
@ -749,6 +780,45 @@ class documentController extends document
return $output;
}
function insertDocumentUpdateLog($obj, $source_obj = null)
{
$update_args = new stdClass();
$logged_info = Context::get('logged_info');
if($source_obj === null)
{
$update_args->category_srl = $obj->category_srl;
$update_args->module_srl = $obj->module_srl;
$update_args->nick_name = $obj->nick_name;
}
else
{
if($obj->category_srl)
{
$update_args->category_srl = $obj->category_srl;
}
else
{
$update_args->category_srl = $source_obj->get('category_srl');
}
$update_args->module_srl = $source_obj->get('module_srl');
$update_args->nick_name = $source_obj->get('nick_name');
}
$update_args->document_srl = $obj->document_srl;
$update_args->update_member_srl = $logged_info->member_srl;
$update_args->title = $obj->title;
$update_args->title_bold = $obj->title_bold;
$update_args->title_color = $obj->title_color;
$update_args->content = $obj->content;
$update_args->update_nick_name = $logged_info->nick_name;
$update_args->tags = $obj->tags;
$update_args->extra_vars = $obj->extra_vars;
$update_args->reason_update = $obj->reason_update;
$update_output = executeQuery('document.insertDocumentUpdateLog', $update_args);
return $update_output;
}
/**
* Deleting Documents
* @param int $document_srl
@ -832,6 +902,7 @@ class documentController extends document
$this->_deleteDeclaredDocuments($args);
$this->_deleteDocumentReadedLog($args);
$this->_deleteDocumentVotedLog($args);
$this->_deleteDocumentUpdateLog($args);
// Remove the thumbnail file
FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3)));
@ -881,6 +952,11 @@ class documentController extends document
executeQuery('document.deleteDocumentVotedLog', $documentSrls);
}
function _deleteDocumentUpdateLog($document_srl)
{
executeQuery('document.deleteDocumentUpdateLog', $document_srl);
}
/**
* Move the doc into the trash
* @param object $obj

View file

@ -1548,6 +1548,25 @@ class documentModel extends document
return $document_list;
}
function getDocumentUpdateLog($document_srl)
{
$args = new stdClass();
$args->document_srl = $document_srl;
$output = executeQueryArray('document.getDocumentUpdateLog', $args);
return $output;
}
function getUpdateLog($update_id)
{
$args = new stdClass();
$args->update_id = $update_id;
$output = exeCuteQuery('document.getUpdateLog', $args);
$updage_log = $output->data;
return $updage_log;
}
}
/* End of file document.model.php */
/* Location: ./modules/document/document.model.php */

View file

@ -0,0 +1,8 @@
<query id="deleteDocumentUpdateLog" action="delete">
<tables>
<table name="document_update_log" />
</tables>
<conditions>
<condition operation="in" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,22 @@
<query id="getDocumentUpdateLog" action="select">
<tables>
<table name="document_update_log" />
</tables>
<columns>
<column name="nick_name" />
<column name="update_nick_name" />
<column name="regdate" />
<column name="title" />
<column name="module_srl" />
<column name="update_id" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
</conditions>
<navigation>
<index var="sort_index" default="update_id" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -0,0 +1,11 @@
<query id="getUpdateLog" action="select">
<tables>
<table name="document_update_log" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="update_id" var="update_id" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,22 @@
<query id="insertDocumentUpdateLog" action="insert">
<tables>
<table name="document_update_log" />
</tables>
<columns>
<column name="document_srl" var="document_srl" filter="number" notnull="notnull" />
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
<column name="update_member_srl" var="update_member_srl" filter="number" />
<column name="category_srl" var="category_srl" filter="number" />
<column name="ipaddress" var="ipaddress" default="ipaddress()" />
<column name="nick_name" var="nick_name" notnull="notnull" />
<column name="title" var="title" notnull="notnull" />
<column name="title_bold" var="title_bold" />
<column name="title_color" var="title_color" />
<column name="content" var="content" notnull="notnull" />
<column name="update_nick_name" var="update_nick_name" notnull="notnull" />
<column name="tags" var="tags" />
<column name="extra_vars" var="extra_vars" />
<column name="reason_update" var="reason_update" />
<column name="regdate" var="regdate" default="curdate()" />
</columns>
</query>

View file

@ -0,0 +1,18 @@
<table name="document_update_log">
<column name="update_id" type="number" size="11" notnull="notnull" auto_increment="auto_increment" primary_key="primary_key" />
<column name="document_srl" type="number" size="11" notnull="notnull" index="idx_document_srl" />
<column name="update_member_srl" type="number" size="11" notnull="notnull" />
<column name="module_srl" type="number" size="11" notnull="notnull" />
<column name="category_srl" type="number" size="11" />
<column name="ipaddress" type="varchar" size="128" notnull="notnull" index="idx_ipaddress" />
<column name="nick_name" type="varchar" size="80" notnull="notnull" />
<column name="regdate" type="date" index="idx_regdate" />
<column name="title" type="varchar" size="250" />
<column name="title_bold" type="char" size="1" default="N" notnull="notnull" />
<column name="title_color" type="varchar" size="7" />
<column name="content" type="bigtext" notnull="notnull" />
<column name="update_nick_name" type="varchar" size="80" />
<column name="tags" type="text" />
<column name="extra_vars" type="text" />
<column name="reason_update" type="text" />
</table>