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

@ -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>