Merge pull request #365 from bjrambo/pr/taeyeon0309-1

업데이트로그를 활용하여 수정하는 기능 추가.
This commit is contained in:
BJRambo 2016-03-14 22:32:34 +09:00
commit ae22067208
15 changed files with 132 additions and 3 deletions

View file

@ -50,6 +50,10 @@ class boardController extends board
unset($obj->title_color);
unset($obj->title_bold);
}
else
{
$obj->is_admin = 'Y';
}
// generate document module model object
$oDocumentModel = getModel('document');
@ -211,6 +215,48 @@ class boardController extends board
$this->setMessage($msg_code);
}
function procBoardRevertDocument()
{
$update_id = Context::get('update_id');
$logged_info = Context::get('logged_info');
if(!$update_id)
{
return new Object(-1, 'msg_no_update_id');
}
$oDocumentModel = getModel('document');
$oDocumentController = getController('document');
$update_log = $oDocumentModel->getUpdateLog($update_id);
if($logged_info->is_admin != 'Y')
{
$Exists_log = $oDocumentModel->getUpdateLogAdminisExists($update_log->document_srl);
if($Exists_log === true)
{
return new Object(-1, 'msg_admin_update_log');
}
}
if(!$update_log)
{
return new Object(-1, 'msg_no_update_log');
}
$oDocument = $oDocumentModel->getDocument($update_log->document_srl);
$obj = new stdClass();
$obj->title = $update_log->title;
$obj->document_srl = $update_log->document_srl;
$obj->title_bold = $update_log->title_bold;
$obj->title_color = $update_log->title_color;
$obj->content = $update_log->content;
$obj->update_log_setting = 'Y';
$obj->reason_update = lang('board.revert_reason_update');
$output = $oDocumentController->updateDocument($oDocument, $obj);
$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'),'act', '', 'document_srl', $update_log->document_srl));
$this->add('mid', Context::get('mid'));
$this->add('document_srl', $update_log->document_srl);
}
/**
* @brief delete the document
**/

View file

@ -1174,6 +1174,8 @@ class boardView extends board
$update_log = $oDocumentModel->getUpdateLog($update_id);
$extra_vars = unserialize($update_log->extra_vars);
Context::addJsFilter($this->module_path.'tpl/filter', 'update.xml');
Context::set('extra_vars', $extra_vars);
Context::set('update_log', $update_log);

View file

@ -80,6 +80,7 @@
<action name="dispBoardUpdateLogView" type="view" />
<action name="procBoardInsertDocument" type="controller" ruleset="insertDocument" standalone="false" />
<action name="procBoardRevertDocument" type="controller" />
<action name="procBoardDeleteDocument" type="controller" standalone="false" />
<action name="procBoardVoteDocument" type="controller" standalone="false" />
<action name="procBoardInsertComment" type="controller" standalone="false" />

View file

@ -60,3 +60,10 @@ $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 = '수정한 이유';
$lang->msg_no_update_id = '업데이트 고유 번호는 필수입니다.';
$lang->msg_no_update_log = '업데이트 로그가 존재하지 않습니다.';
$lang->cmd_modify_by_update_log = '이 로그로 게시물을 수정하기';
$lang->msg_admin_update_log = '관리자가 수정한 적이 있는 게시물입니다. 관리자에게 문의하세요.';
$lang->msg_update_log_revert = '정말로 이 버전으로 되돌리시겠습니까?';
$lang->write_admin = '관리자작성';
$lang->revert_reason_update = '이 버전으로 되돌림';

View file

@ -455,6 +455,13 @@
text-overflow: ellipsis;
color: #555;
}
.read_header h1 span.is_admin {
font-size: 15px;
font-weight: normal;
line-height:15px;
color:#FF6C00;
}
.read_header h1 a {
text-decoration: none;
color: #444;

View file

@ -15,10 +15,10 @@
<a href="{getUrl('', 'mid', $mid, 'act', 'dispBoardUpdateLogView', 'update_id', $val->update_id)}">{$val->title}</a>
</td>
<td class="author">
{$val->update_nick_name}
{$val->nick_name}
</td>
<td class="author">
{$val->nick_name}
{$val->update_nick_name}
</td>
<td class="time">
{zdate($val->regdate, 'Y.m.d H:i:s')}
@ -40,3 +40,4 @@
<!--@end-->
<a href="{getUrl('page',$page_navigation->last_page,'module_srl','')}" class="direction">{$lang->last_page} &raquo;</a>
</div>
<include target="_footer.html" />

View file

@ -5,7 +5,7 @@
<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>
<a>{$update_log->title}</a> <span class="is_admin" cond="$update_log->is_admin == 'Y'">{$lang->write_admin}</span>
</h1>
<p class="meta">
<span class="time">
@ -26,4 +26,12 @@
</p>
<!-- /READ BODY -->
</div>
<form action="./" method="post" onsubmit="if(!confirm('{$lang->msg_update_log_revert}')) return false; return procFilter(this, window.update)" cond="$update_log->is_admin !== 'Y' && $logged_info->is_admin !=='Y' || $logged_info->is_admin === 'Y'">
<input type="hidden" name="module" value="board" />
<input type="hidden" name="act" value="procBoardUpdateDocument" />
<input type="hidden" name="update_id" value="{$update_log->update_id}" />
<button class="btn" type="submit">{$lang->cmd_modify_by_update_log}</button>
</form>
</div>
<include target="_footer.html" />

View file

@ -0,0 +1,7 @@
<filter name="update" module="board" act="procBoardRevertDocument">
<form>
<node target="nick_name" required="true" maxlength="20"/>
<node target="title" required="true" minlength="1" maxlength="250" />
<node target="content" required="true" />
</form>
</filter>

View file

@ -127,6 +127,9 @@ class document extends ModuleObject
// 2016. 1. 27: Add a column(declare_message) for report
if(!$oDB->isColumnExists("document_declared_log","declare_message")) return true;
// 2016. 3. 14 Add a column(document_upate_log) for admin
if(!$oDB->isColumnExists('document_update_log', 'is_admin')) return true;
return false;
}
@ -328,6 +331,13 @@ class document extends ModuleObject
$oDB->addColumn('document_declared_log',"declare_message","text");
}
// 2016. 3. 14 Add a column(document_update_log) for admin
if(!$oDB->isColumnExists('document_update_log', 'is_admin'))
{
$oDB->addColumn('document_update_log', 'is_admin', 'varchar', 1);
$oDB->addIndex('document_update_log', 'idx_is_admin', array('is_admin'));
}
return new Object(0,'success_updated');
}

View file

@ -476,6 +476,7 @@ class documentController extends document
{
$obj->extra_vars = serialize($extra_vars);
$update_output = $this->insertDocumentUpdateLog($obj);
if(!$update_output->toBool())
{
$oDB->rollback();
@ -749,6 +750,10 @@ class documentController extends document
if($obj->update_log_setting === 'Y')
{
$obj->extra_vars = serialize($extra_vars);
if($this->grant->manager)
{
$obj->is_admin = 'Y';
}
$update_output = $this->insertDocumentUpdateLog($obj, $source_obj);
if(!$update_output->toBool())
{
@ -816,6 +821,7 @@ class documentController extends document
$update_args->tags = $obj->tags;
$update_args->extra_vars = $obj->extra_vars;
$update_args->reason_update = $obj->reason_update;
$update_args->is_admin = $obj->is_admin;
$update_output = executeQuery('document.insertDocumentUpdateLog', $update_args);
return $update_output;

View file

@ -1567,6 +1567,25 @@ class documentModel extends document
return $updage_log;
}
function getUpdateLogAdminisExists($document_srl = null)
{
if($document_srl == null)
{
return;
}
$args = new stdClass();
$args->document_srl = $document_srl;
$args->is_admin = 'Y';
$output = executeQuery('document.getUpdateLogAdminisExists', $args);
if($output->data->count > 0)
{
return true;
}
return false;
}
}
/* End of file document.model.php */
/* Location: ./modules/document/document.model.php */

View file

@ -9,6 +9,7 @@
<column name="title" />
<column name="module_srl" />
<column name="update_id" />
<column name="update_member_srl" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />

View file

@ -0,0 +1,12 @@
<query id="getUpdateLog" action="select">
<tables>
<table name="document_update_log" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="is_admin" var="is_admin" pipe="and" />
</conditions>
</query>

View file

@ -18,5 +18,6 @@
<column name="extra_vars" var="extra_vars" />
<column name="reason_update" var="reason_update" />
<column name="regdate" var="regdate" default="curdate()" />
<column name="is_admin" var="is_admin" />
</columns>
</query>

View file

@ -15,4 +15,5 @@
<column name="tags" type="text" />
<column name="extra_vars" type="text" />
<column name="reason_update" type="text" />
<column name="is_admin" type="varchar" size="1" index="idx_is_admin" />
</table>