mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Clean up trash handling logic
This commit is contained in:
parent
10123a86a8
commit
565cfad15f
4 changed files with 25 additions and 61 deletions
|
|
@ -1365,16 +1365,16 @@ class CommentController extends Comment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDB = DB::getInstance();
|
|
||||||
$oDB->begin();
|
|
||||||
|
|
||||||
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
|
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
|
||||||
$oTrashVO = new TrashVO();
|
$oTrashVO = new TrashVO();
|
||||||
$oTrashVO->setTrashSrl(getNextSequence());
|
$oTrashVO->setTrashSrl(getNextSequence());
|
||||||
$oTrashVO->setTitle(mb_substr($oComment->getContentText(100), 0, 250, 'UTF-8'));
|
$oTrashVO->setTitle(mb_substr($oComment->getContentText(100), 0, 250, 'UTF-8'));
|
||||||
$oTrashVO->setOriginModule('comment');
|
$oTrashVO->setOriginModule('comment');
|
||||||
$oTrashVO->setSerializedObject(serialize($oComment->variables));
|
$oTrashVO->setSerializedObject(serialize($oComment->variables));
|
||||||
$oTrashVO->setDescription($obj->description);
|
$oTrashVO->setDescription($obj->description ?? '');
|
||||||
|
|
||||||
|
$oDB = DB::getInstance();
|
||||||
|
$oDB->begin();
|
||||||
|
|
||||||
$oTrashAdminController = getAdminController('trash');
|
$oTrashAdminController = getAdminController('trash');
|
||||||
$output = $oTrashAdminController->insertTrash($oTrashVO);
|
$output = $oTrashAdminController->insertTrash($oTrashVO);
|
||||||
|
|
@ -1437,7 +1437,6 @@ class CommentController extends Comment
|
||||||
Rhymix\Framework\Storage::deleteDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($obj->comment_srl, 3)));
|
Rhymix\Framework\Storage::deleteDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($obj->comment_srl, 3)));
|
||||||
|
|
||||||
$output->add('document_srl', $oComment->document_srl);
|
$output->add('document_srl', $oComment->document_srl);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1362,11 +1362,7 @@ class DocumentController extends Document
|
||||||
*/
|
*/
|
||||||
function moveDocumentToTrash($obj)
|
function moveDocumentToTrash($obj)
|
||||||
{
|
{
|
||||||
$trash_args = new stdClass();
|
// Check the document and grants
|
||||||
// Get trash_srl if a given trash_srl doesn't exist
|
|
||||||
if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
|
|
||||||
else $trash_args->trash_srl = $obj->trash_srl;
|
|
||||||
// Get its module_srl which the document belongs to
|
|
||||||
$oDocument = DocumentModel::getDocument($obj->document_srl);
|
$oDocument = DocumentModel::getDocument($obj->document_srl);
|
||||||
if(!$oDocument->isExists())
|
if(!$oDocument->isExists())
|
||||||
{
|
{
|
||||||
|
|
@ -1384,48 +1380,23 @@ class DocumentController extends Document
|
||||||
return new BaseObject(-1, 'msg_admin_document_no_move_to_trash');
|
return new BaseObject(-1, 'msg_admin_document_no_move_to_trash');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($oDocument->get('module_srl') == 0)
|
||||||
$trash_args->module_srl = $oDocument->get('module_srl');
|
|
||||||
$obj->module_srl = $oDocument->get('module_srl');
|
|
||||||
// Cannot throw data from the trash to the trash
|
|
||||||
if($trash_args->module_srl == 0)
|
|
||||||
{
|
{
|
||||||
return new BaseObject(-1, 'Cannot throw data from the trash to the trash');
|
return new BaseObject(-1, 'Cannot throw data from the trash to the trash');
|
||||||
}
|
}
|
||||||
// Data setting
|
|
||||||
$trash_args->document_srl = $obj->document_srl;
|
|
||||||
$trash_args->description = $obj->description;
|
|
||||||
// Insert member's information only if the member is logged-in and not manually registered.
|
|
||||||
if($this->user->isMember())
|
|
||||||
{
|
|
||||||
$trash_args->member_srl = $this->user->member_srl;
|
|
||||||
$trash_args->user_id = htmlspecialchars_decode($this->user->user_id);
|
|
||||||
$trash_args->user_name = htmlspecialchars_decode($this->user->user_name);
|
|
||||||
$trash_args->nick_name = htmlspecialchars_decode($this->user->nick_name);
|
|
||||||
}
|
|
||||||
// Date setting for updating documents
|
|
||||||
$document_args = new stdClass;
|
|
||||||
$document_args->module_srl = 0;
|
|
||||||
$document_args->document_srl = $obj->document_srl;
|
|
||||||
|
|
||||||
// begin transaction
|
// Create trash object.
|
||||||
$oDB = DB::getInstance();
|
|
||||||
$oDB->begin();
|
|
||||||
|
|
||||||
/*$output = executeQuery('document.insertTrash', $trash_args);
|
|
||||||
if (!$output->toBool()) {
|
|
||||||
$oDB->rollback();
|
|
||||||
return $output;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// new trash module
|
|
||||||
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
|
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
|
||||||
$oTrashVO = new TrashVO();
|
$oTrashVO = new TrashVO();
|
||||||
$oTrashVO->setTrashSrl(getNextSequence());
|
$oTrashVO->setTrashSrl(getNextSequence());
|
||||||
$oTrashVO->setTitle($oDocument->variables['title']);
|
$oTrashVO->setTitle($oDocument->variables['title']);
|
||||||
$oTrashVO->setOriginModule('document');
|
$oTrashVO->setOriginModule('document');
|
||||||
$oTrashVO->setSerializedObject(serialize($oDocument->variables));
|
$oTrashVO->setSerializedObject(serialize($oDocument->variables));
|
||||||
$oTrashVO->setDescription($obj->description);
|
$oTrashVO->setDescription($obj->description ?? '');
|
||||||
|
|
||||||
|
// begin transaction
|
||||||
|
$oDB = DB::getInstance();
|
||||||
|
$oDB->begin();
|
||||||
|
|
||||||
$oTrashAdminController = getAdminController('trash');
|
$oTrashAdminController = getAdminController('trash');
|
||||||
$output = $oTrashAdminController->insertTrash($oTrashVO);
|
$output = $oTrashAdminController->insertTrash($oTrashVO);
|
||||||
|
|
@ -1435,24 +1406,18 @@ class DocumentController extends Document
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = executeQuery('document.deleteDocument', $trash_args);
|
$output = executeQuery('document.deleteDocument', ['document_srl' => $oDocument->document_srl]);
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
{
|
{
|
||||||
$oDB->rollback();
|
$oDB->rollback();
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*$output = executeQuery('document.updateDocument', $document_args);
|
|
||||||
if (!$output->toBool()) {
|
|
||||||
$oDB->rollback();
|
|
||||||
return $output;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// update category
|
// update category
|
||||||
if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
|
if ($oDocument->get('category_srl'))
|
||||||
|
{
|
||||||
// remove thumbnails
|
$this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
|
||||||
Rhymix\Framework\Storage::deleteDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
|
}
|
||||||
|
|
||||||
// Set the attachment to be invalid state
|
// Set the attachment to be invalid state
|
||||||
if($oDocument->hasUploadedFiles())
|
if($oDocument->hasUploadedFiles())
|
||||||
|
|
@ -1474,6 +1439,9 @@ class DocumentController extends Document
|
||||||
// commit
|
// commit
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
|
// remove thumbnails
|
||||||
|
Rhymix\Framework\Storage::deleteDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
|
||||||
|
|
||||||
// Clear cache
|
// Clear cache
|
||||||
self::clearDocumentCache($oDocument->document_srl);
|
self::clearDocumentCache($oDocument->document_srl);
|
||||||
return $output;
|
return $output;
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ class TrashVO
|
||||||
}
|
}
|
||||||
function getTitle()
|
function getTitle()
|
||||||
{
|
{
|
||||||
if(empty($this->title)) return $lang->untitle;
|
if(empty($this->title)) return lang('untitle');
|
||||||
return htmlspecialchars($this->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
return escape($this->title, false);
|
||||||
}
|
}
|
||||||
function setTitle($title)
|
function setTitle($title)
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +90,7 @@ class TrashVO
|
||||||
}
|
}
|
||||||
function getNickName()
|
function getNickName()
|
||||||
{
|
{
|
||||||
return htmlspecialchars($this->nickName, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
return escape($this->nickName, false);
|
||||||
}
|
}
|
||||||
function setNickName($nickName)
|
function setNickName($nickName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,13 @@ class trashAdminController extends trash
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* object insert to trash
|
* object insert to trash
|
||||||
* @param TrashVO $obj
|
* @param TrashVO $oTrashVO
|
||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
function insertTrash($obj)
|
function insertTrash($oTrashVO)
|
||||||
{
|
{
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
|
||||||
$oTrashVO = new TrashVO();
|
|
||||||
$oTrashVO = &$obj;
|
|
||||||
|
|
||||||
if(!$oTrashVO->getTrashSrl()) $oTrashVO->setTrashSrl(getNextSequence());
|
if(!$oTrashVO->getTrashSrl()) $oTrashVO->setTrashSrl(getNextSequence());
|
||||||
if(!is_string($oTrashVO->getSerializedObject())) $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject()));
|
if(!is_string($oTrashVO->getSerializedObject())) $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject()));
|
||||||
$oTrashVO->setIpaddress(\RX_CLIENT_IP);
|
$oTrashVO->setIpaddress(\RX_CLIENT_IP);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue