Skip to content

Commit

Permalink
fix #2104 첨부 파일 목록을 가져올 때 호환성 문제 고침
Browse files Browse the repository at this point in the history
  • Loading branch information
bnu committed Jun 8, 2017
1 parent ce63e02 commit b6b1112
Showing 1 changed file with 37 additions and 41 deletions.
78 changes: 37 additions & 41 deletions modules/file/file.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,42 @@ function getFileList()

if($upload_target_srl)
{
$oDocumentModel = getModel('document');
$oCommentModel = getModel('comment');
$logged_info = Context::get('logged_info');

$oDocument = $oDocumentModel->getDocument($upload_target_srl);

// comment 권한 확인
if(!$oDocument->isExists())
{
$oComment = $oCommentModel->getComment($upload_target_srl);
if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted())
{
return new Object(-1, 'msg_not_permitted');
}

$oDocument = $oDocumentModel->getDocument($oComment->get('document_srl'));
}

// document 권한 확인
if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted())
{
return new Object(-1, 'msg_not_permitted');
}

// 모듈 권한 확인
if($oDocument->isExists())
{
$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info);
if(!$grant->access)
{
return new Object(-1, 'msg_not_permitted');
}
}

$tmp_files = $this->getFiles($upload_target_srl);
if($tmp_files instanceof Object && !$tmp_files->toBool()) return $tmp_files;
if(!$tmp_files) $tmp_files = array();

foreach($tmp_files as $file_info)
{
Expand Down Expand Up @@ -218,60 +252,22 @@ function getFile($file_srl, $columnList = array())
*/
function getFiles($upload_target_srl, $columnList = array(), $sortIndex = 'file_srl', $ckValid = false)
{
$oModuleModel = getModel('module');
$oDocumentModel = getModel('document');
$oCommentModel = getModel('comment');
$logged_info = Context::get('logged_info');

$oDocument = $oDocumentModel->getDocument($upload_target_srl);

// comment 권한 확인
if(!$oDocument->isExists())
{
$oComment = $oCommentModel->getComment($upload_target_srl);
if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted())
{
return $this->stop('msg_not_permitted');
}

$oDocument = $oDocumentModel->getDocument($oComment->get('document_srl'));
}

// document 권한 확인
if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted())
{
return $this->stop('msg_not_permitted');
}

// 모듈 권한 확인
if($oDocument->isExists())
{
$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info);
if(!$grant->access)
{
return $this->stop('msg_not_permitted');
}
}

$args = new stdClass();
$args->upload_target_srl = $upload_target_srl;
$args->sort_index = $sortIndex;
if($ckValid) $args->isvalid = 'Y';
$output = executeQuery('file.getFiles', $args, $columnList);
$output = executeQueryArray('file.getFiles', $args, $columnList);
if(!$output->data) return;

$file_list = $output->data;

if($file_list && !is_array($file_list)) $file_list = array($file_list);

$file_count = count($file_list);
for($i=0;$i<$file_count;$i++)
foreach ($file_list as &$file)
{
$file = $file_list[$i];
$file->source_filename = stripslashes($file->source_filename);
$file->source_filename = htmlspecialchars($file->source_filename);
$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
$file_list[$i] = $file;
}

return $file_list;
Expand Down

0 comments on commit b6b1112

Please sign in to comment.