mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Clean up article page edit method #2458
This commit is contained in:
parent
63e2e9c681
commit
3fd2fad70e
2 changed files with 41 additions and 29 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
<grants>
|
<grants>
|
||||||
<grant name="modify" default="manager">
|
<grant name="modify" default="manager">
|
||||||
<title xml:lang="ko">페이지 수정</title>
|
<title xml:lang="ko">페이지 수정</title>
|
||||||
<title xml:lang="en">page modify</title>
|
<title xml:lang="en">Edit Page</title>
|
||||||
</grant>
|
</grant>
|
||||||
</grants>
|
</grants>
|
||||||
<actions>
|
<actions>
|
||||||
|
|
|
||||||
|
|
@ -309,15 +309,10 @@ class PageAdminController extends Page
|
||||||
|
|
||||||
function procPageAdminArticleDocumentInsert()
|
function procPageAdminArticleDocumentInsert()
|
||||||
{
|
{
|
||||||
$oDocumentModel = getModel('document');
|
// Check privileges
|
||||||
$oDocumentController = getController('document');
|
|
||||||
|
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
$grant = ModuleModel::getGrant($this->module_info, $logged_info);
|
||||||
$oModuleModel = getModel('module');
|
if(!$grant->manager && !$grant->modify)
|
||||||
$grant = $oModuleModel->getGrant($this->module_info, $logged_info);
|
|
||||||
|
|
||||||
if(!$grant->manager)
|
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||||
}
|
}
|
||||||
|
|
@ -326,43 +321,60 @@ class PageAdminController extends Page
|
||||||
$obj->module_srl = $this->module_info->module_srl;
|
$obj->module_srl = $this->module_info->module_srl;
|
||||||
$obj->is_notice = 'N';
|
$obj->is_notice = 'N';
|
||||||
|
|
||||||
settype($obj->title, "string");
|
// If the tile is empty, extract string from the contents.
|
||||||
if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
|
$obj->title = escape($obj->title, false);
|
||||||
//그래도 없으면 Untitled
|
if ($obj->title === '')
|
||||||
if($obj->title == '') $obj->title = 'Untitled';
|
{
|
||||||
|
$obj->title = escape(cut_str(trim(utf8_normalize_spaces(strip_tags($obj->content))), 20, '...'), false);
|
||||||
|
}
|
||||||
|
if ($obj->title === '')
|
||||||
|
{
|
||||||
|
$obj->title = 'Untitled';
|
||||||
|
}
|
||||||
|
|
||||||
$document_srl = $obj->document_srl;
|
// Check original document
|
||||||
|
$oDocument = DocumentModel::getDocument($obj->document_srl);
|
||||||
|
if ($oDocument->isExists() && $oDocument->get('module_srl') != $this->module_info->module_srl)
|
||||||
|
{
|
||||||
|
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||||
|
}
|
||||||
|
|
||||||
// 이미 존재하는 글인지 체크
|
// Insert or update document
|
||||||
$oDocument = $oDocumentModel->getDocument($obj->document_srl);
|
$oDocumentController = DocumentController::getInstance();
|
||||||
|
if ($oDocument->isExists())
|
||||||
$bAnonymous = false;
|
|
||||||
$target = ($obj->isMobile == 'Y') ? 'mdocument_srl' : 'document_srl';
|
|
||||||
|
|
||||||
// 이미 존재하는 경우 수정
|
|
||||||
if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
|
|
||||||
{
|
{
|
||||||
$output = $oDocumentController->updateDocument($oDocument, $obj);
|
$output = $oDocumentController->updateDocument($oDocument, $obj);
|
||||||
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
$msg_code = 'success_updated';
|
$msg_code = 'success_updated';
|
||||||
|
$document_srl = $obj->document_srl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 그렇지 않으면 신규 등록
|
$output = $oDocumentController->insertDocument($obj);
|
||||||
$output = $oDocumentController->insertDocument($obj, $bAnonymous);
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
$msg_code = 'success_registed';
|
$msg_code = 'success_registed';
|
||||||
$document_srl = $output->get('document_srl');
|
$document_srl = $output->get('document_srl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update module info
|
||||||
|
$target = ($obj->isMobile == 'Y') ? 'mdocument_srl' : 'document_srl';
|
||||||
if(!isset($this->module_info->{$target}) || (isset($this->module_info->{$target}) && $this->module_info->{$target} !== $document_srl))
|
if(!isset($this->module_info->{$target}) || (isset($this->module_info->{$target}) && $this->module_info->{$target} !== $document_srl))
|
||||||
{
|
{
|
||||||
$oModuleController = getController('module');
|
|
||||||
$this->module_info->{$target} = $document_srl;
|
$this->module_info->{$target} = $document_srl;
|
||||||
$oModuleController->updateModule($this->module_info);
|
$oModuleController = ModuleController::getInstance();
|
||||||
|
$output = $oModuleController->updateModule($this->module_info);
|
||||||
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 오류 발생시 멈춤
|
|
||||||
if(!$output->toBool()) return $output;
|
|
||||||
|
|
||||||
// 결과를 리턴
|
// 결과를 리턴
|
||||||
$this->add('mid', Context::get('mid'));
|
$this->add('mid', Context::get('mid'));
|
||||||
$this->add('document_srl', $output->get('document_srl'));
|
$this->add('document_srl', $output->get('document_srl'));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue