diff --git a/modules/board/board.admin.controller.php b/modules/board/board.admin.controller.php index 30ee3ddea..b6faf4e0a 100644 --- a/modules/board/board.admin.controller.php +++ b/modules/board/board.admin.controller.php @@ -14,7 +14,7 @@ class boardAdminController extends board { **/ function init() { - + } /** @@ -37,7 +37,7 @@ class boardAdminController extends board { { $module_info = ModuleModel::getModuleInfoByModuleSrl($args->module_srl); } - + // setup extra_order_target $extra_order_target = array(); if($args->module_srl) @@ -77,10 +77,10 @@ class boardAdminController extends board { $args->protect_admin_content_delete = 'N'; } } - + if(!in_array($args->order_target,$this->order_target) && !array_key_exists($args->order_target, $extra_order_target)) $args->order_target = 'list_order'; if(!in_array($args->order_type, array('asc', 'desc'))) $args->order_type = 'asc'; - + $args->skip_bottom_list_days = max(0, intval($args->skip_bottom_list_days)); $args->browser_title = trim(utf8_normalize_spaces($args->browser_title)); $args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : ''; @@ -91,7 +91,7 @@ class boardAdminController extends board { { unset($args->module_srl); } - + // preserve existing config if ($args->module_srl) { @@ -209,25 +209,25 @@ class boardAdminController extends board { $include_modules = array_map('intval', $vars->include_modules ?: []); $include_days = max(0, floatval($vars->include_days)); $include_notice = $vars->include_notice === 'Y' ? 'Y' : 'N'; - + $module_info = ModuleModel::getModuleInfoByModuleSrl($module_srl); if (!$module_info) { throw new Rhymix\Framework\Exceptions\TargetNotFound; } - + $module_info->include_modules = implode(',', array_filter($include_modules, function($item) { return $item > 0; })); $module_info->include_days = floatval(number_format($include_days, 2, '.', '')); $module_info->include_notice = $include_notice; - + $output = getController('module')->updateModule($module_info); if (!$output->toBool()) { return $output; } - + $this->setMessage('success_updated'); if (Context::get('success_return_url')) { diff --git a/modules/board/board.admin.view.php b/modules/board/board.admin.view.php index 8074390ec..2f45b976b 100644 --- a/modules/board/board.admin.view.php +++ b/modules/board/board.admin.view.php @@ -213,7 +213,7 @@ class boardAdminView extends board { $args->list_count = 1000; $output = executeQueryArray('board.getBoardList', $args, ['module_srl', 'mid', 'browser_title']); Context::set('board_list', $output->data); - + // setup the template file $this->setTemplateFile('addition_setup'); } diff --git a/modules/board/board.api.php b/modules/board/board.api.php index 49eb68310..fed18f707 100644 --- a/modules/board/board.api.php +++ b/modules/board/board.api.php @@ -103,7 +103,7 @@ class boardAPI extends board /** * Apply _arrangeContent to a list of documents. - * + * * @param array $content_list * @param object $grant * @return array @@ -120,7 +120,7 @@ class boardAPI extends board /** * Clean up document info so that only some fields are exposed. - * + * * @param object $content * @param object $grant * @return stdClass @@ -162,7 +162,7 @@ class boardAPI extends board /** * Clean up comment info so that only some fields are exposed. - * + * * @param array $comment_list * @return array */ @@ -190,7 +190,7 @@ class boardAPI extends board /** * Clean up file info so that only some fields are exposed. - * + * * @param array $file_list * @return array */ @@ -211,7 +211,7 @@ class boardAPI extends board /** * Clean up extra vars so that only some fields are exposed. - * + * * @param array $extra_var_list * @return array */ diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index 86ed1f08e..6bd316b04 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -15,7 +15,7 @@ class boardController extends board function init() { } - + /** * @brief insert document **/ @@ -26,12 +26,12 @@ class boardController extends board { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // setup variables $obj = Context::getRequestVars(); $obj->module_srl = $this->module_srl; $obj->commentStatus = $obj->comment_status; - + // Remove disallowed Unicode symbols. if ($this->module_info->filter_specialchars !== 'N') { @@ -48,20 +48,20 @@ class boardController extends board $obj->tags = utf8_clean($obj->tags); } } - + // Return error if content is empty. if (is_empty_html_content($obj->content)) { throw new Rhymix\Framework\Exception('msg_empty_content'); } - + // Return error if content is too large. $document_length_limit = ($this->module_info->document_length_limit ?: 1024) * 1024; if (strlen($obj->content) > $document_length_limit && !$this->grant->manager) { throw new Rhymix\Framework\Exception('msg_content_too_long'); } - + // unset document style if not manager if(!$this->grant->manager) { @@ -73,12 +73,12 @@ class boardController extends board { $obj->is_admin = 'Y'; } - + $oDocumentController = getController('document'); - + $secret_status = DocumentModel::getConfigStatus('secret'); $use_status = explode('|@|', $this->module_info->use_status); - + // Set status if(($obj->is_secret == 'Y' || $obj->status == $secret_status) && is_array($use_status) && in_array($secret_status, $use_status)) { @@ -89,16 +89,16 @@ class boardController extends board unset($obj->is_secret); $obj->status = DocumentModel::getConfigStatus('public'); } - + // Set update log if($this->module_info->update_log == 'Y') { $obj->update_log_setting = 'Y'; } - + $manual = false; $logged_info = Context::get('logged_info'); - + $oDocument = DocumentModel::getDocument($obj->document_srl); // Set anonymous information when insert mode or status is temp @@ -108,17 +108,17 @@ class boardController extends board { $obj->document_srl = getNextSequence(); } - + $manual = true; $anonymous_name = $this->module_info->anonymous_name ?: 'anonymous'; $anonymous_name = $this->createAnonymousName($anonymous_name, $logged_info->member_srl, $obj->document_srl); $this->module_info->admin_mail = ''; - + $obj->notify_message = 'N'; $obj->email_address = $obj->homepage = $obj->user_id = ''; $obj->user_name = $obj->nick_name = $anonymous_name; } - + // Update if the document already exists. if($oDocument->isExists()) { @@ -126,7 +126,7 @@ class boardController extends board { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // Protect admin document if ($this->module_info->protect_admin_content_update !== 'N') { @@ -136,7 +136,7 @@ class boardController extends board throw new Rhymix\Framework\Exception('msg_admin_document_no_modify'); } } - + // if document status is temp if($oDocument->get('status') == DocumentModel::getConfigStatus('temp')) { @@ -146,7 +146,7 @@ class boardController extends board $obj->member_srl = abs($oDocument->get('member_srl')) * -1; $oDocument->add('member_srl', $obj->member_srl); } - + // Update list order, date $obj->last_update = $obj->regdate = date('YmdHis'); $obj->update_order = $obj->list_order = (getNextSequence() * -1); @@ -161,7 +161,7 @@ class boardController extends board throw new Rhymix\Framework\Exception('msg_protect_update_content'); } } - + // Protect document by date if($this->module_info->protect_document_regdate > 0 && !$this->grant->manager) { @@ -170,7 +170,7 @@ class boardController extends board throw new Rhymix\Framework\Exception(sprintf(lang('msg_protect_regdate_document'), $this->module_info->protect_document_regdate)); } } - + // Preserve module_srl if the document belongs to a module that is included in this board if ($oDocument->get('module_srl') != $obj->module_srl && in_array($oDocument->get('module_srl'), explode(',', $this->module_info->include_modules ?: ''))) { @@ -181,7 +181,7 @@ class boardController extends board { $obj->module_srl = $oDocument->get('module_srl'); } - + // notice & document style same as before if not manager if(!$this->grant->manager) { @@ -189,13 +189,13 @@ class boardController extends board $obj->title_color = $oDocument->get('title_color'); $obj->title_bold = $oDocument->get('title_bold'); } - + $obj->reason_update = escape($obj->reason_update); } - + // Update $output = $oDocumentController->updateDocument($oDocument, $obj, $manual); - + $msg_code = 'success_updated'; } // Insert a new document. @@ -206,29 +206,29 @@ class boardController extends board { $obj->member_srl = $logged_info->member_srl * -1; } - + // Update list order if document_srl is already assigned if ($obj->document_srl) { $obj->update_order = $obj->list_order = (getNextSequence() * -1); } - + // Insert $output = $oDocumentController->insertDocument($obj, $manual, false, $obj->document_srl ? false : true); - + if ($output->toBool()) { // Set grant for the new document. $oDocument = DocumentModel::getDocument($output->get('document_srl')); $oDocument->setGrantForSession(); - + // send an email to admin user if ($this->module_info->admin_mail && config('mail.default_from')) { $browser_title = Context::replaceUserLang($this->module_info->browser_title); $mail_title = sprintf(lang('msg_document_notify_mail'), $browser_title, cut_str($obj->title, 20, '...')); $mail_content = sprintf("From : %s
\r\n%s", getFullUrl('', 'document_srl', $output->get('document_srl')), getFullUrl('', 'document_srl', $output->get('document_srl')), $obj->content); - + $oMail = new \Rhymix\Framework\Mail(); $oMail->setSubject($mail_title); $oMail->setBody($mail_content); @@ -242,21 +242,21 @@ class boardController extends board $oMail->send(); } } - + $msg_code = 'success_registed'; } - + // if there is an error if(!$output->toBool()) { return $output; } - + // return the results $this->add('mid', Context::get('mid')); $this->add('document_srl', $output->get('document_srl')); $this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'document_srl', $output->get('document_srl'))); - + // alert a message $this->setMessage($msg_code); } @@ -325,7 +325,7 @@ class boardController extends board { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // check protect content if($this->module_info->protect_content == 'Y' || $this->module_info->protect_delete_content == 'Y') { @@ -415,7 +415,7 @@ class boardController extends board $obj->content = utf8_clean($obj->content); } } - + // Return error if content is empty. if (is_empty_html_content($obj->content)) { @@ -428,7 +428,7 @@ class boardController extends board { throw new Rhymix\Framework\Exception('msg_content_too_long'); } - + if(!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC'; if(!is_array($this->module_info->use_status)) { @@ -453,7 +453,7 @@ class boardController extends board } $obj->module_srl = $oDocument->get('module_srl'); - + // For anonymous use, remove writer's information and notifying information if($this->module_info->use_anonymous == 'Y' && (!$this->grant->manager || ($this->module_info->anonymous_except_admin ?? 'N') !== 'Y')) { @@ -505,7 +505,7 @@ class boardController extends board { // Update document last_update info? $update_document = $this->module_info->update_order_on_comment === 'N' ? false : true; - + // Parent exists. if($obj->parent_srl) { @@ -592,7 +592,7 @@ class boardController extends board { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $childs = null; if($this->module_info->protect_delete_comment === 'Y' && $this->grant->manager == false) { @@ -602,7 +602,7 @@ class boardController extends board throw new Rhymix\Framework\Exception('msg_board_delete_protect_comment'); } } - + if ($this->module_info->protect_admin_content_delete !== 'N' && $this->user->is_admin !== 'Y') { $member_info = MemberModel::getMemberInfo($comment->get('member_srl')); @@ -760,7 +760,7 @@ class boardController extends board { return; } - + // get the module information $module_info = ModuleModel::getModuleInfoByMid($mid); if (!$module_info || !isset($module_info->module) || $module_info->module !== 'board') @@ -774,14 +774,14 @@ class boardController extends board return; } } - + $url = getUrl('', 'mid', $mid, 'member_srl', $obj->member_srl); getController('member')->addMemberPopupMenu($url, 'cmd_view_own_document', '', 'self', 'board_own_document'); } - + /** * Create an anonymous nickname. - * + * * @param string $format * @param int $member_srl * @param int $document_srl @@ -800,10 +800,10 @@ class boardController extends board } }, $format); } - + /** * Subroutine for hashing anonymous nickname. - * + * * @param string $content * @param int $digits * @return string diff --git a/modules/board/board.view.php b/modules/board/board.view.php index c7c27bb22..49b320d28 100644 --- a/modules/board/board.view.php +++ b/modules/board/board.view.php @@ -370,7 +370,7 @@ class boardView extends board // Check if a permission for file download is granted // Get configurations (using module model object) $file_module_config = ModuleModel::getModulePartConfig('file',$this->module_srl); - + $downloadGrantCount = 0; if(is_array($file_module_config->download_grant)) { @@ -384,7 +384,7 @@ class boardView extends board { throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); } - + $logged_info = Context::get('logged_info'); if($logged_info->is_admin != 'Y') { @@ -470,7 +470,7 @@ class boardView extends board } $output = DocumentModel::getNoticeList($args, $this->columnList); $notice_list = $output->data ?? []; - + $this->_fillModuleTitles($notice_list); Context::set('notice_list', $notice_list); } @@ -507,7 +507,7 @@ class boardView extends board $args->search_target = Context::get('search_target'); $args->search_keyword = Context::get('search_keyword'); } - + if(!$search_option = Context::get('search_option')) { $search_option = $this->search_option; @@ -516,13 +516,13 @@ class boardView extends board { $args->search_target = ''; } - + // set member_srl for view particular member's document if($this->module_info->use_anonymous !== 'Y') { $args->member_srl = abs(Context::get('member_srl') ?? 0) ?: null; } - + // if the category is enabled, then get the category if($this->module_info->use_category=='Y') { @@ -603,12 +603,12 @@ class boardView extends board public function _fillModuleTitles(&$document_list) { static $map = null; - + if (!$document_list) { return; } - + if ($this->include_modules) { if ($map === null) @@ -655,17 +655,17 @@ class boardView extends board 'regdate', 'last_update', 'last_updater', 'ipaddress', 'list_order', 'update_order', 'allow_trackback', 'notify_message', 'status', 'comment_status', ); - + // List of columns that should always be selected $defaultColumnList = array( 'document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice', 'title', 'title_bold', 'title_color', 'member_srl', 'nick_name', 'tags', 'extra_vars', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'last_update', ); - + // List of columns selected by the user $selectedColumnList = array_keys($this->listConfig); - + // Return all columns for some legacy skins if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog') { @@ -682,12 +682,12 @@ class boardView extends board { $selectedColumnList[] = 'last_updater'; } - + // Remove duplicates and/or invalid column names $selectedColumnList = array_intersect($selectedColumnList, $allColumnList); $this->columnList = array_unique(array_merge($defaultColumnList, $selectedColumnList)); } - + // add table name foreach($this->columnList as $no => $value) { @@ -756,19 +756,19 @@ class boardView extends board { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + if($this->grant->view == false || ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read)) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $oDocument = DocumentModel::getDocument($document_srl); if(!$oDocument->isExists()) { throw new Rhymix\Framework\Exceptions\TargetNotFound; } Context::set('oDocument', $oDocument); - + $this->setLayoutPath('./common/tpl'); $this->setLayoutFile('default_layout'); $this->setTemplateFile('comment.html'); @@ -819,7 +819,7 @@ class boardView extends board if($is_granted) $category_list[$category_srl] = $category; } } - + // check if at least one category is granted $grant_exists = false; foreach ($category_list as $category) @@ -866,7 +866,7 @@ class boardView extends board throw new Rhymix\Framework\Exception('msg_protect_update_content'); } } - + if ($this->module_info->protect_admin_content_update !== 'N') { $member_info = MemberModel::getMemberInfo($oDocument->get('member_srl')); @@ -894,7 +894,7 @@ class boardView extends board { $pointForInsert = 0; } - + if($pointForInsert < 0) { if(!$this->user->isMember()) @@ -1195,7 +1195,7 @@ class boardView extends board throw new Rhymix\Framework\Exception('msg_admin_comment_no_modify'); } } - + // setup the comment variables on context Context::set('oSourceComment', CommentModel::getComment()); Context::set('oComment', $oComment); @@ -1256,7 +1256,7 @@ class boardView extends board throw new Rhymix\Framework\Exception('msg_admin_comment_no_delete'); } } - + // if the comment is not existed, then back to the board content page if(!$oComment->isExists() ) { @@ -1321,7 +1321,7 @@ class boardView extends board { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $document_srl = Context::get('document_srl'); if(!$document_srl) { @@ -1333,7 +1333,7 @@ class boardView extends board { return $updatelog; } - + Context::set('total_count', $updatelog->page_navigation->total_count); Context::set('total_page', $updatelog->page_navigation->total_page); Context::set('page', $updatelog->page); @@ -1440,7 +1440,7 @@ class boardView extends board Context::set('blame_member_info', $blame_member_infos); $this->setTemplateFile('vote_log'); } - + /** * Default 404 Handler. */ @@ -1451,7 +1451,7 @@ class boardView extends board /** * Display an error page. - * + * * @param string $msg_code * @param int $http_code * @return void @@ -1470,9 +1470,9 @@ class boardView extends board /** * Display an alert window on top of the page. - * + * * @deprecated - * + * * @param string $msg_code * @param int $http_code * @return void diff --git a/modules/board/board.wap.php b/modules/board/board.wap.php index 10d06f85f..ffdfe29e8 100644 --- a/modules/board/board.wap.php +++ b/modules/board/board.wap.php @@ -1,138 +1,138 @@ - */ - -/** - * @class boardWAP - * @author NAVER (developers@xpressengine.com) - * @brief board module WAP class - **/ - -class boardWAP extends board -{ - /** - * @brief wap procedure method - **/ - function procWAP(&$oMobile) - { - // check grant - if(!$this->grant->list || $this->module_info->consultation == 'Y') - { - return $oMobile->setContent(lang('msg_not_permitted')); - } - - // generate document model object - $oDocumentModel = getModel('document'); - - // if the doument is existed - $document_srl = Context::get('document_srl'); - if($document_srl) - { - $oDocument = $oDocumentModel->getDocument($document_srl); - if($oDocument->isExists()) - { - // check the grant - if(!$this->grant->view) - { - return $oMobile->setContent(lang('msg_not_permitted')); - } - - // setup the browser title - Context::setBrowserTitle($oDocument->getTitleText()); - - // if the act is display comment list - if($this->act=='dispBoardContentCommentList') - { - - $oCommentModel = getModel('comment'); - $output = $oCommentModel->getCommentList($oDocument->document_srl, 0, false, $oDocument->getCommentCount()); - - $content = ''; - if(count($output->data)) - { - foreach($output->data as $key => $val) - { - $oComment = new commentItem(); - $oComment->setAttribute($val); - - if(!$oComment->isAccessible()) continue; - - $content .= "".$oComment->getNickName()." (".$oComment->getRegdate("Y-m-d").")
\r\n".$oComment->getContent(false,false)."
\r\n"; - } - } - - // setup mobile contents - $oMobile->setContent( $content ); - - // setup upper URL - $oMobile->setUpperUrl( getUrl('act',''), lang('cmd_go_upper') ); - - // display the document if the act is not display the comment list - } else { - - // setup contents (strip all html tags) - $content = strip_tags(str_replace('

','
   ',$oDocument->getContent(false,false,false)),'
'); - - - // setup content information(include the comments link) - $content = lang('replies').' : '.$oDocument->getCommentCount().'
'."\r\n".$content; - $content = ''.$oDocument->getNickName().' ('.$oDocument->getRegdate("Y-m-d").")
\r\n".$content; - - // setup mobile contents - $oMobile->setContent( $content ); - - // setup upper URL - $oMobile->setUpperUrl( getUrl('document_srl',''), lang('cmd_list') ); - - } - - return; - } - } - - // board index - $args = new stdClass; - $args->module_srl = $this->module_srl; - $args->page = Context::get('page');; - $args->list_count = 9; - $args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order'; - $args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc'; - $output = $oDocumentModel->getDocumentList($args, $this->except_notice); - $document_list = $output->data; - $page_navigation = $output->page_navigation; - - $childs = array(); - if($document_list && count($document_list)) - { - foreach($document_list as $key => $val) - { - $href = getUrl('mid',$_GET['mid'],'document_srl',$val->document_srl); - $obj = null; - $obj['href'] = $val->getPermanentUrl(); - - $title = htmlspecialchars($val->getTitleText()); - if($val->getCommentCount()) $title .= ' ['.$val->getCommentCount().']'; - $obj['link'] = $obj['text'] = '['.$val->getNickName().'] '.$title; - $childs[] = $obj; - } - $oMobile->setChilds($childs); - } - - $totalPage = $page_navigation->last_page; - $page = (int)Context::get('page'); - if(!$page) $page = 1; - - // next/prevUrl specification - if($page > 1) - { - $oMobile->setPrevUrl(getUrl('mid',$_GET['mid'],'page',$page-1), sprintf('%s (%d/%d)', lang('cmd_prev'), $page-1, $totalPage)); - } - - if($page < $totalPage) - { - $oMobile->setNextUrl(getUrl('mid',$_GET['mid'],'page',$page+1), sprintf('%s (%d/%d)', lang('cmd_next'), $page+1, $totalPage)); - } - - $oMobile->mobilePage = $page; - $oMobile->totalPage = $totalPage; - } -} + */ + +/** + * @class boardWAP + * @author NAVER (developers@xpressengine.com) + * @brief board module WAP class + **/ + +class boardWAP extends board +{ + /** + * @brief wap procedure method + **/ + function procWAP(&$oMobile) + { + // check grant + if(!$this->grant->list || $this->module_info->consultation == 'Y') + { + return $oMobile->setContent(lang('msg_not_permitted')); + } + + // generate document model object + $oDocumentModel = getModel('document'); + + // if the doument is existed + $document_srl = Context::get('document_srl'); + if($document_srl) + { + $oDocument = $oDocumentModel->getDocument($document_srl); + if($oDocument->isExists()) + { + // check the grant + if(!$this->grant->view) + { + return $oMobile->setContent(lang('msg_not_permitted')); + } + + // setup the browser title + Context::setBrowserTitle($oDocument->getTitleText()); + + // if the act is display comment list + if($this->act=='dispBoardContentCommentList') + { + + $oCommentModel = getModel('comment'); + $output = $oCommentModel->getCommentList($oDocument->document_srl, 0, false, $oDocument->getCommentCount()); + + $content = ''; + if(count($output->data)) + { + foreach($output->data as $key => $val) + { + $oComment = new commentItem(); + $oComment->setAttribute($val); + + if(!$oComment->isAccessible()) continue; + + $content .= "".$oComment->getNickName()." (".$oComment->getRegdate("Y-m-d").")
\r\n".$oComment->getContent(false,false)."
\r\n"; + } + } + + // setup mobile contents + $oMobile->setContent( $content ); + + // setup upper URL + $oMobile->setUpperUrl( getUrl('act',''), lang('cmd_go_upper') ); + + // display the document if the act is not display the comment list + } else { + + // setup contents (strip all html tags) + $content = strip_tags(str_replace('

','
   ',$oDocument->getContent(false,false,false)),'
'); + + + // setup content information(include the comments link) + $content = lang('replies').' : '.$oDocument->getCommentCount().'
'."\r\n".$content; + $content = ''.$oDocument->getNickName().' ('.$oDocument->getRegdate("Y-m-d").")
\r\n".$content; + + // setup mobile contents + $oMobile->setContent( $content ); + + // setup upper URL + $oMobile->setUpperUrl( getUrl('document_srl',''), lang('cmd_list') ); + + } + + return; + } + } + + // board index + $args = new stdClass; + $args->module_srl = $this->module_srl; + $args->page = Context::get('page');; + $args->list_count = 9; + $args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order'; + $args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc'; + $output = $oDocumentModel->getDocumentList($args, $this->except_notice); + $document_list = $output->data; + $page_navigation = $output->page_navigation; + + $childs = array(); + if($document_list && count($document_list)) + { + foreach($document_list as $key => $val) + { + $href = getUrl('mid',$_GET['mid'],'document_srl',$val->document_srl); + $obj = null; + $obj['href'] = $val->getPermanentUrl(); + + $title = htmlspecialchars($val->getTitleText()); + if($val->getCommentCount()) $title .= ' ['.$val->getCommentCount().']'; + $obj['link'] = $obj['text'] = '['.$val->getNickName().'] '.$title; + $childs[] = $obj; + } + $oMobile->setChilds($childs); + } + + $totalPage = $page_navigation->last_page; + $page = (int)Context::get('page'); + if(!$page) $page = 1; + + // next/prevUrl specification + if($page > 1) + { + $oMobile->setPrevUrl(getUrl('mid',$_GET['mid'],'page',$page-1), sprintf('%s (%d/%d)', lang('cmd_prev'), $page-1, $totalPage)); + } + + if($page < $totalPage) + { + $oMobile->setNextUrl(getUrl('mid',$_GET['mid'],'page',$page+1), sprintf('%s (%d/%d)', lang('cmd_next'), $page+1, $totalPage)); + } + + $oMobile->mobilePage = $page; + $oMobile->totalPage = $totalPage; + } +} diff --git a/modules/comment/comment.admin.controller.php b/modules/comment/comment.admin.controller.php index 8baab9f4e..38702809a 100644 --- a/modules/comment/comment.admin.controller.php +++ b/modules/comment/comment.admin.controller.php @@ -215,7 +215,7 @@ class CommentAdminController extends Comment $deleted_count = 0; $module_infos = []; - + // Delete the comment posting for($i = 0; $i < $comment_count; $i++) { @@ -230,13 +230,13 @@ class CommentAdminController extends Comment { continue; } - + $module_srl = $comment->get('module_srl'); if (!isset($module_infos[$module_srl])) { $module_infos[$module_srl] = ModuleModel::getModuleInfoByModuleSrl($module_srl)->comment_delete_message ?? ''; } - + if($module_infos[$module_srl] === 'yes') { $output = $oCommentController->updateCommentByDelete($comment, true); @@ -257,7 +257,7 @@ class CommentAdminController extends Comment { $output = $oCommentController->deleteComment($comment_srl, true, toBool($isTrash)); } - + if(!$output->toBool() && $output->error !== -2) { $oDB->rollback(); @@ -276,7 +276,7 @@ class CommentAdminController extends Comment $deleted_count++; } - + $oDB->commit(); $msgCode = ''; @@ -357,7 +357,7 @@ class CommentAdminController extends Comment $oDB->rollback(); return $output; } - + $obj = new stdClass; $obj->comment_srl = $oComment->get('comment_srl'); $obj->module_srl = $oComment->get('module_srl'); @@ -482,7 +482,7 @@ class CommentAdminController extends Comment { $originObject = (object) $originObject; } - + $oCommentController = getController('comment'); $oCommentModel = getModel('comment'); diff --git a/modules/comment/comment.admin.view.php b/modules/comment/comment.admin.view.php index f7f6eac6f..a332bc085 100644 --- a/modules/comment/comment.admin.view.php +++ b/modules/comment/comment.admin.view.php @@ -49,7 +49,7 @@ class CommentAdminView extends Comment } */ - // get a list by using comment->getCommentList. + // get a list by using comment->getCommentList. $oCommentModel = getModel('comment'); $secretNameList = $oCommentModel->getSecretNameList(); $output = $oCommentModel->getTotalCommentList($args); @@ -89,7 +89,7 @@ class CommentAdminView extends Comment } } Context::set('module_list', $module_list); - + // Get anonymous nicknames $anonymous_member_srls = array(); foreach($output->data as $val) @@ -114,11 +114,11 @@ class CommentAdminView extends Comment } } Context::set('member_nick_name', $member_nick_neme); - + $security = new Security(); $security->encodeHTML('search_target', 'search_keyword'); - // set the template + // set the template $this->setTemplatePath($this->module_path . 'tpl'); $this->setTemplateFile('comment_list'); } @@ -135,7 +135,7 @@ class CommentAdminView extends Comment $args->list_count = 30; // /< the number of comment postings to appear on a single page $args->page_count = 10; // /< the number of pages to appear on the page navigation $args->order_type = 'desc'; // /< sorted value - + // select sort method $sort_index = Context::get('sort_index'); if (!in_array($sort_index, array('declared_latest', 'declared_count', 'regdate'))) @@ -143,7 +143,7 @@ class CommentAdminView extends Comment $sort_index = 'declared_latest'; } Context::set('sort_index', $sort_index); - + // get latest declared list if ($sort_index === 'declared_latest') { diff --git a/modules/comment/comment.class.php b/modules/comment/comment.class.php index 0ff599d9e..73bcc2635 100644 --- a/modules/comment/comment.class.php +++ b/modules/comment/comment.class.php @@ -63,7 +63,7 @@ class Comment extends ModuleObject return TRUE; } - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) { return TRUE; @@ -85,7 +85,7 @@ class Comment extends ModuleObject { return true; } - + // 2018.01.24 Improve mass file deletion if(!ModuleModel::getTrigger('document.moveDocumentModule', 'comment', 'controller', 'triggerMoveDocument', 'after')) { @@ -95,7 +95,7 @@ class Comment extends ModuleObject { return true; } - + return false; } @@ -107,7 +107,7 @@ class Comment extends ModuleObject { $oDB = DB::getInstance(); $oModuleController = getController('module'); - + // 2007. 10. 17 add a trigger to delete comments together with posting deleted if(!ModuleModel::getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) { @@ -128,7 +128,7 @@ class Comment extends ModuleObject $oDB->addIndex("comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE); } - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) { $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'); @@ -144,13 +144,13 @@ class Comment extends ModuleObject { $oDB->addIndex('comments', 'idx_parent_srl', array('parent_srl')); } - + // 2017.12.21 Add an index for nick_name if(!$oDB->isIndexExists('comments', 'idx_nick_name')) { $oDB->addIndex('comments', 'idx_nick_name', array('nick_name')); } - + // 2018.01.24 Improve mass file deletion if(!ModuleModel::getTrigger('document.moveDocumentModule', 'comment', 'controller', 'triggerMoveDocument', 'after')) { @@ -168,7 +168,7 @@ class Comment extends ModuleObject */ function recompileCache() { - + } } diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index c8598f1d5..d7a1e54ce 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -88,7 +88,7 @@ class CommentController extends Comment { throw new Rhymix\Framework\Exception('failed_voted_canceled'); } - + $point = 1; $output = $this->updateVotedCountCancel($comment_srl, $oComment, $point); @@ -167,7 +167,7 @@ class CommentController extends Comment { throw new Rhymix\Framework\Exception('failed_blamed_canceled'); } - + $point = -1; $output = $this->updateVotedCountCancel($comment_srl, $oComment, $point); @@ -183,7 +183,7 @@ class CommentController extends Comment { return new BaseObject(-1, $point > 0 ? 'failed_voted_canceled' : 'failed_blamed_canceled'); } - + // Check if the current user has voted previously. $args = new stdClass; $args->comment_srl = $comment_srl; @@ -243,10 +243,10 @@ class CommentController extends Comment //session reset unset($_SESSION['voted_comment'][$comment_srl]); - + // Call a trigger (after) ModuleHandler::triggerCall('comment.updateVotedCountCancel', 'after', $trigger_obj); - + $oDB->commit(); return $output; } @@ -276,7 +276,7 @@ class CommentController extends Comment { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // if an user select message from options, message would be the option. $message_option = strval(Context::get('message_option')); $improper_comment_reasons = lang('improper_comment_reasons'); @@ -460,7 +460,7 @@ class CommentController extends Comment // Remove manual member info to prevent forgery. This variable can be set by triggers only. unset($obj->manual_member_info); - + // Sanitize variables $obj->comment_srl = intval($obj->comment_srl); $obj->module_srl = intval($obj->module_srl); @@ -468,7 +468,7 @@ class CommentController extends Comment $obj->parent_srl = intval($obj->parent_srl); $obj->uploaded_count = FileModel::getFilesCount($obj->comment_srl); - + // call a trigger (before) $output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj); if(!$output->toBool()) @@ -537,7 +537,7 @@ class CommentController extends Comment { $obj->comment_srl = getNextSequence(); } - elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) + elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) { return new BaseObject(-1, 'msg_not_permitted'); } @@ -553,13 +553,13 @@ class CommentController extends Comment { return new BaseObject(-1, 'msg_empty_content'); } - + // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted || isset($obj->allow_html) || isset($obj->use_html)) { $obj->content = getModel('editor')->converter($obj, 'comment'); } - + if(!$obj->regdate) { $obj->regdate = date("YmdHis"); @@ -659,7 +659,7 @@ class CommentController extends Comment $oDB->rollback(); return $output; } - + // create the controller object of the document $oDocumentController = getController('document'); @@ -684,7 +684,7 @@ class CommentController extends Comment { $obj->updated_file_count = 0; } - + // call a trigger(after) ModuleHandler::triggerCall('comment.insertComment', 'after', $obj); @@ -722,8 +722,8 @@ class CommentController extends Comment /** * Send email to module's admins after a new comment was interted successfully - * if Comments Approval System is used - * @param object $obj + * if Comments Approval System is used + * @param object $obj * @return void */ function sendEmailToAdminAfterInsertComment($obj) @@ -836,7 +836,7 @@ class CommentController extends Comment // Remove manual member info to prevent forgery. This variable can be set by triggers only. unset($obj->manual_member_info); - + // Sanitize variables $obj->comment_srl = intval($obj->comment_srl); $obj->module_srl = intval($obj->module_srl); @@ -844,7 +844,7 @@ class CommentController extends Comment $obj->parent_srl = intval($obj->parent_srl); $obj->uploaded_count = FileModel::getFilesCount($obj->comment_srl); - + // call a trigger (before) $output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj); if(!$output->toBool()) @@ -874,7 +874,7 @@ class CommentController extends Comment $obj->password = MemberModel::hashPassword($obj->password); } - if($obj->homepage) + if($obj->homepage) { $obj->homepage = escape($obj->homepage); if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) @@ -919,13 +919,13 @@ class CommentController extends Comment { return new BaseObject(-1, 'msg_empty_content'); } - + // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated || isset($obj->allow_html) || isset($obj->use_html)) { $obj->content = getModel('editor')->converter($obj, 'comment'); } - + // remove iframe and script if not a top administrator on the session if($logged_info->is_admin != 'Y') { @@ -983,7 +983,7 @@ class CommentController extends Comment { return new BaseObject(-1, 'msg_invalid_request'); } - + // check if comment exists and permission is granted $comment = CommentModel::getComment($obj->comment_srl); if(!$comment->isExists()) @@ -994,7 +994,7 @@ class CommentController extends Comment { return new BaseObject(-1, 'msg_not_permitted'); } - + // call a trigger (before) $output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment); if(!$output->toBool()) @@ -1017,7 +1017,7 @@ class CommentController extends Comment // Begin transaction $oDB = DB::getInstance(); $oDB->begin(); - + // Update $obj->member_srl = 0; unset($obj->last_update); @@ -1109,7 +1109,7 @@ class CommentController extends Comment { // check if comment already exists $comment = CommentModel::getComment($comment_srl); - + if(!$comment->isExists()) { return new BaseObject(-2, 'msg_not_founded'); @@ -1231,8 +1231,8 @@ class CommentController extends Comment { $this->_deleteDeclaredComments($args); $this->_deleteVotedComments($args); - } - else + } + else { $args = new stdClass(); $args->upload_target_srl = $comment_srl; @@ -1268,10 +1268,10 @@ class CommentController extends Comment { return new BaseObject(-1, 'msg_not_permitted'); } - + $logged_info = Context::get('logged_info'); $module_info = ModuleModel::getModuleInfo($oComment->get('module_srl')); - + if ($module_info->protect_admin_content_delete !== 'N' && $logged_info->is_admin !== 'Y') { $member_info = MemberModel::getMemberInfo($oComment->get('member_srl')); @@ -1608,15 +1608,15 @@ class CommentController extends Comment { return $output; } - + $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; $declare_message = trim(htmlspecialchars($declare_message)); - + $trigger_obj = new stdClass(); $trigger_obj->comment_srl = $comment_srl; $trigger_obj->declared_count = $declared_count; $trigger_obj->declare_message = $declare_message; - + // Call a trigger (before) $trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj); if(!$trigger_output->toBool()) @@ -1636,7 +1636,7 @@ class CommentController extends Comment // Get currently logged in user. $member_srl = intval($this->user->member_srl); - + // if the comment author is a member if($oComment->get('member_srl')) { @@ -1665,12 +1665,12 @@ class CommentController extends Comment $_SESSION['declared_comment'][$comment_srl] = FALSE; return new BaseObject(-1, 'failed_declared'); } - + // Fill in remaining information for logging. $args->member_srl = $member_srl; $args->ipaddress = \RX_CLIENT_IP; $args->declare_message = $declare_message; - + // begin transaction $oDB = DB::getInstance(); $oDB->begin(); @@ -1757,7 +1757,7 @@ class CommentController extends Comment { return new BaseObject(-1, 'failed_declared_cancel'); } - + // Get the original document $oComment = CommentModel::getComment($comment_srl); @@ -1796,7 +1796,7 @@ class CommentController extends Comment { return $trigger_output; } - + if ($declared_count > 1) { $output = executeQuery('comment.updateDeclaredCommentCancel', $args); @@ -1810,14 +1810,14 @@ class CommentController extends Comment $oDB->rollback(); return $output; } - + $output = executeQuery('comment.deleteDeclaredCommentLog', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } - + $message_targets = array(); $module_srl = $oComment->get('module_srl'); $comment_config = ModuleModel::getModulePartConfig('comment', $module_srl); @@ -1897,19 +1897,19 @@ class CommentController extends Comment foreach ($target_module_srl as $srl) { if (!$srl) continue; - + $module_info = ModuleModel::getModuleInfoByModuleSrl($srl); if (!$module_info->module_srl) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $module_grant = ModuleModel::getGrant($module_info, $logged_info); if (!$module_grant->manager) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $module_srl[] = $srl; } @@ -2019,19 +2019,19 @@ class CommentController extends Comment $this->add('comment_list', $commentList); } - + function triggerMoveDocument($obj) { executeQuery('comment.updateCommentModule', $obj); executeQuery('comment.updateCommentListModule', $obj); } - + function triggerAddCopyDocument(&$obj) { $args = new stdClass; $args->document_srls = $obj->source->document_srl; $comment_list = executeQueryArray('comment.getCommentsByDocumentSrls', $args)->data; - + $copied_comments = array(); foreach($comment_list as $comment) { @@ -2040,24 +2040,24 @@ class CommentController extends Comment $copy->module_srl = $obj->copied->module_srl; $copy->document_srl = $obj->copied->document_srl; $copy->parent_srl = $comment->parent_srl ? $copied_comments[$comment->parent_srl] : 0; - + // call a trigger (add) $args = new stdClass; $args->source = $comment; $args->copied = $copy; ModuleHandler::triggerCall('comment.copyCommentByDocument', 'add', $args); - + // insert a copied comment $this->insertComment($copy, true); - + $copied_comments[$comment->comment_srl] = $copy->comment_srl; } - + // update $obj->copied->last_updater = $copy->nick_name; $obj->copied->comment_count = count($copied_comments); } - + function triggerCopyModule(&$obj) { $commentConfig = ModuleModel::getModulePartConfig('comment', $obj->originModuleSrl); diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index 438893e63..00395f1c1 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -93,24 +93,24 @@ class CommentItem extends BaseObject { return (bool) ($this->comment_srl); } - + function isGranted() { if(!$this->isExists()) { return false; } - + if (isset($_SESSION['granted_comment'][$this->comment_srl])) { return true; } - + if ($this->grant_cache !== null) { return $this->grant_cache; } - + $logged_info = Context::get('logged_info'); if (!$logged_info->member_srl) { @@ -124,30 +124,30 @@ class CommentItem extends BaseObject { return $this->grant_cache = true; } - + $grant = ModuleModel::getGrant(ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); if ($grant->manager) { return $this->grant_cache = true; } - + return $this->grant_cache = false; } - + function setGrant() { $this->grant_cache = true; } - + function setGrantForSession() { $_SESSION['granted_comment'][$this->comment_srl] = true; $this->setGrant(); } - + /** * Return the status code. - * + * * @return string */ public function getStatus() @@ -170,7 +170,7 @@ class CommentItem extends BaseObject /** * Return the status in human-readable text. - * + * * @return string */ public function getStatusText() @@ -193,7 +193,7 @@ class CommentItem extends BaseObject { return false; } - + if ($strict) { $module_info = ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')); @@ -207,34 +207,34 @@ class CommentItem extends BaseObject return false; } } - + if (isset($_SESSION['accessible'][$this->comment_srl]) && $_SESSION['accessible'][$this->comment_srl] === $this->get('last_update')) { return true; } - + if ($this->get('status') == RX_STATUS_PUBLIC && $this->get('is_secret') !== 'Y') { $this->setAccessible(); return true; } - + if ($this->isGranted()) { $this->setAccessible(); return true; } - + $oDocument = DocumentModel::getDocument($this->get('document_srl')); if ($oDocument->isGranted()) { $this->setAccessible(); return true; } - + return false; } - + function setAccessible() { if(Context::getSessionStatus()) @@ -242,27 +242,27 @@ class CommentItem extends BaseObject $_SESSION['accessible'][$this->comment_srl] = $this->get('last_update'); } } - + function isEditable() { return !$this->get('member_srl') || $this->isGranted(); } - + function isSecret() { return $this->get('status') == RX_STATUS_SECRET || $this->get('is_secret') == 'Y'; } - + function isDeleted() { return $this->get('status') == RX_STATUS_DELETED || $this->get('status') == RX_STATUS_DELETED_BY_ADMIN; } - + function isDeletedByAdmin() { return $this->get('status') == RX_STATUS_DELETED_BY_ADMIN; } - + function useNotify() { return $this->get('notify_message') == 'Y'; @@ -280,7 +280,7 @@ class CommentItem extends BaseObject return; } - // pass if the author is not logged-in user + // pass if the author is not logged-in user if(!$this->get('member_srl')) { return; @@ -293,7 +293,7 @@ class CommentItem extends BaseObject return; } - // get where the comment belongs to + // get where the comment belongs to $oDocument = DocumentModel::getDocument($this->get('document_srl')); // Variables @@ -422,7 +422,7 @@ class CommentItem extends BaseObject { return $_SESSION['declared_comment'][$this->comment_srl]; } - + $args = new stdClass(); if ($logged_info->member_srl) { @@ -439,7 +439,7 @@ class CommentItem extends BaseObject { return $_SESSION['declared_comment'][$this->comment_srl] = $declared_count; } - + return false; } @@ -461,7 +461,7 @@ class CommentItem extends BaseObject { $content = $this->get('content'); } - + $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); if($strlen) { @@ -492,7 +492,7 @@ class CommentItem extends BaseObject { $content = $this->get('content'); } - + if($strlen) { $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); @@ -568,16 +568,16 @@ class CommentItem extends BaseObject { // Remove tags $content = strip_tags($this->getContent(false, false)); - + // Convert temporarily html entity for truncate $content = html_entity_decode($content, ENT_QUOTES); - + // Replace all whitespaces to single space $content = utf8_trim(utf8_normalize_spaces($content)); - + // Truncate string $content = cut_str($content, $str_size, $tail); - + return escape($content); } @@ -633,7 +633,7 @@ class CommentItem extends BaseObject { return false; } - + return $this->get('uploaded_count') ? TRUE : FALSE; } @@ -643,12 +643,12 @@ class CommentItem extends BaseObject { return; } - + if(!$this->get('uploaded_count')) { return; } - + $file_list = FileModel::getFiles($this->comment_srl, array(), 'file_srl', TRUE); return $file_list; } @@ -755,7 +755,7 @@ class CommentItem extends BaseObject { $config->thumbnail_quality = 75; } - + // If signiture height setting is omitted, create a square if(!is_int($width)) { @@ -799,7 +799,7 @@ class CommentItem extends BaseObject { return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file)); } - + // return false if neigher attached file nor image; if(!$this->get('uploaded_count') && !preg_match("!get('content'))) { @@ -846,7 +846,7 @@ class CommentItem extends BaseObject } } - // get an image file from the doc content if no file attached. + // get an image file from the doc content if no file attached. if(!$source_file && $config->thumbnail_target !== 'attachment') { $external_image_min_width = min(100, round($trigger_obj->width * 0.3)); diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index d2886998e..0fbabdabc 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -375,9 +375,9 @@ class CommentModel extends Comment /** * Get the module info without duplication - * + * * @deprecated - * + * * @return array */ public static function getDistinctModules() @@ -573,7 +573,7 @@ class CommentModel extends Comment { return $trigger_output; } - + // If an alternate output is set, use it instead of running the default queries if (isset($args->use_alternate_output) && $args->use_alternate_output instanceof BaseObject) { @@ -587,7 +587,7 @@ class CommentModel extends Comment { return; } - + // insert data into CommentPageList table if the number of results is different from stored comments if(!$output->data) { @@ -605,7 +605,7 @@ class CommentModel extends Comment ModuleHandler::triggerCall('comment.getCommentList', 'after', $output); return $output; } - + /** * Find out which page a comment is on * @param int $document_srl @@ -623,14 +623,14 @@ class CommentModel extends Comment { return 0; } - + // return if no comment exists $document_comment_count = $oDocument->getCommentCount(); if($document_comment_count < 1) { return 0; } - + // Get the comment count per page if(!$count) { @@ -642,14 +642,14 @@ class CommentModel extends Comment { $comment_count = $count; } - + // Get the number of pages $total_pages = max(1, ceil($document_comment_count / $comment_count)); if ($total_pages == 1) { return 1; } - + // Find out which page the comment is on $args = new stdClass(); $args->document_srl = $document_srl; @@ -961,7 +961,7 @@ class CommentModel extends Comment { return $output; } - + // If an alternate output is set, use it instead of running the default queries if (isset($args->use_alternate_output) && $args->use_alternate_output instanceof BaseObject) { @@ -972,7 +972,7 @@ class CommentModel extends Comment { $output = executeQueryArray($query_id, $args, $columnList); } - + // return when no result or error occurance if(!$output->toBool() || !count($output->data)) { @@ -1132,7 +1132,7 @@ class CommentModel extends Comment return $comment_config; } - + /** * Return a list of voting member * @return void diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index 1a2e0b6f0..866469964 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -43,7 +43,7 @@ class DocumentAdminController extends Document $this->setMessage(sprintf(lang('msg_checked_document_is_deleted'), $document_count) ); } - + /** * Save the default settings of the document module * @return object @@ -56,7 +56,7 @@ class DocumentAdminController extends Document $config->view_count_option = Context::get('view_count_option'); $config->icons = Context::get('icons'); $config->micons = Context::get('micons'); - + // Get icon skin type $config->icons_type = 'gif'; $config->micons_type = 'gif'; @@ -364,7 +364,7 @@ class DocumentAdminController extends Document $oDocumentController->moveDocumentToTrash($args); $returnUrl = Context::get('success_return_url'); - if(!$returnUrl) + if(!$returnUrl) { $arrUrl = parse_url(Context::get('cur_url')); $query = ""; @@ -424,7 +424,7 @@ class DocumentAdminController extends Document $trash_srl = Context::get('trash_srl'); $this->restoreTrash($trash_srl); } - + /** * Move module of the documents * @param array $document_srl_list @@ -443,17 +443,17 @@ class DocumentAdminController extends Document $document_srl_list = array_map('trim', explode(',', $document_srl_list)); } $document_srl_list = array_map('intval', $document_srl_list); - + $obj = new stdClass; $obj->document_srls = $document_srl_list; $obj->list_count = count($document_srl_list); $obj->document_list = executeQueryArray('document.getDocuments', $obj)->data; $obj->module_srl = $target_module_srl; $obj->category_srl = $target_category_srl; - + $oDB = DB::getInstance(); $oDB->begin(); - + // call a trigger (before) $output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $obj); if(!$output->toBool()) @@ -461,10 +461,10 @@ class DocumentAdminController extends Document $oDB->rollback(); return $output; } - + $origin_category = array(); $oDocumentController = getController('document'); - + foreach($obj->document_list as $document) { // if the target module is different @@ -472,16 +472,16 @@ class DocumentAdminController extends Document { $oDocumentController->deleteDocumentAliasByDocument($document->document_srl); } - + // if the target category is different if($document->category_srl != $obj->category_srl && $document->category_srl) { $origin_category[$document->category_srl] = $document->module_srl; } - + $oDocumentController->insertDocumentUpdateLog($document); } - + // update documents $output = executeQuery('document.updateDocumentsModule', $obj); if(!$output->toBool()) @@ -489,7 +489,7 @@ class DocumentAdminController extends Document $oDB->rollback(); return $output; } - + // update extra vars $output = executeQuery('document.updateDocumentExtraVarsModule', $obj); if(!$output->toBool()) @@ -497,10 +497,10 @@ class DocumentAdminController extends Document $oDB->rollback(); return $output; } - + // call a trigger (after) ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $obj); - + // update category count foreach($origin_category as $category_srl => $module_srl) { @@ -510,15 +510,15 @@ class DocumentAdminController extends Document { $oDocumentController->updateCategoryCount($obj->module_srl, $obj->category_srl); } - + $oDB->commit(); - + // remove from cache foreach($obj->document_list as $document) { DocumentController::clearDocumentCache($document->document_srl); } - + return new BaseObject(); } @@ -540,17 +540,17 @@ class DocumentAdminController extends Document $document_srl_list = array_map('trim', explode(',', $document_srl_list)); } $document_srl_list = array_map('intval', $document_srl_list); - + $obj = new stdClass; $obj->document_srls = $document_srl_list; $obj->list_count = count($document_srl_list); $obj->document_list = executeQueryArray('document.getDocuments', $obj)->data; $obj->module_srl = $target_module_srl; $obj->category_srl = $target_category_srl; - + $oDB = DB::getInstance(); $oDB->begin(); - + // call a trigger (before) $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $obj); if(!$output->toBool()) @@ -558,10 +558,10 @@ class DocumentAdminController extends Document $oDB->rollback(); return $output; } - + $oDocumentController = getController('document'); $extra_vars_list = getModel('document')->getDocumentExtraVarsFromDB($document_srl_list)->data; - + $extra_vars = array(); foreach($extra_vars_list as $extra) { @@ -569,10 +569,10 @@ class DocumentAdminController extends Document { $extra_vars[$extra->document_srl] = array(); } - + $extra_vars[$extra->document_srl][] = $extra; } - + $copied_srls = array(); foreach($obj->document_list as $document) { @@ -583,13 +583,13 @@ class DocumentAdminController extends Document $copy->comment_count = 0; $copy->trackback_count = 0; $copy->password_is_hashed = true; - + // call a trigger (add) $args = new stdClass; $args->source = $document; $args->copied = $copy; ModuleHandler::triggerCall('document.copyDocumentModule', 'add', $args); - + // insert a copied document $output = $oDocumentController->insertDocument($copy, true, true); if(!$output->toBool()) @@ -597,7 +597,7 @@ class DocumentAdminController extends Document $oDB->rollback(); return $output; } - + // insert copied extra vars of the document if(isset($extra_vars[$document->document_srl])) { @@ -606,22 +606,22 @@ class DocumentAdminController extends Document $oDocumentController->insertDocumentExtraVar($copy->module_srl, $copy->document_srl, $extra->var_idx, $extra->value, $extra->eid, $extra->lang_code); } } - + $copied_srls[$document->document_srl] = $copy->document_srl; } - + // call a trigger (after) $obj->copied_srls = $copied_srls; ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $obj); - + $oDB->commit(); - + // return copied document_srls $output = new BaseObject(); $output->add('copied_srls', $copied_srls); return $output; } - + /** * Delete all documents of the module * @param int $module_srl @@ -633,23 +633,23 @@ class DocumentAdminController extends Document $args->list_count = 0; $args->module_srl = intval($module_srl); $document_list = executeQueryArray('document.getDocumentList', $args, array('document_srl'))->data; - + // delete documents $output = executeQuery('document.deleteModuleDocument', $args); if(!$output->toBool()) { return $output; } - + // remove from cache foreach ($document_list as $document) { DocumentController::clearDocumentCache($document->document_srl); } - + return new BaseObject(); } - + /** * Restore document from trash module, called by trash module * This method is passived diff --git a/modules/document/document.admin.view.php b/modules/document/document.admin.view.php index 0ac300dd1..55f557e63 100644 --- a/modules/document/document.admin.view.php +++ b/modules/document/document.admin.view.php @@ -40,7 +40,7 @@ class DocumentAdminView extends Document $args->page = Context::get('page'); // /< Page $args->list_count = 30; // /< the number of posts to display on a single page $args->page_count = 5; // /< the number of pages that appear in the page navigation - + $args->search_target = Context::get('search_target'); // /< search (title, contents ...) $args->search_keyword = Context::get('search_keyword'); // /< keyword to search if ($args->search_target === 'member_srl') @@ -56,7 +56,7 @@ class DocumentAdminView extends Document $args->sort_index = 'list_order'; // /< sorting value $args->module_srl = Context::get('module_srl'); $args->statusList = array($this->getConfigStatus('public'), $this->getConfigStatus('secret'), $this->getConfigStatus('temp')); - + // get a list $oDocumentModel = getModel('document'); $columnList = array('document_srl', 'module_srl', 'category_srl', 'member_srl', 'title', 'nick_name', 'comment_count', 'trackback_count', 'readed_count', 'voted_count', 'blamed_count', 'regdate', 'ipaddress', 'status'); @@ -104,7 +104,7 @@ class DocumentAdminView extends Document } } Context::set('module_list', $module_list); - + // Get anonymous nicknames $anonymous_member_srls = array(); $member_nick_name = array(); @@ -176,7 +176,7 @@ class DocumentAdminView extends Document $args->list_count = 20; // /< the number of posts to display on a single page $args->page_count = 10; // /< the number of pages that appear in the page navigation $args->order_type = strtolower(Context::get('order_type')) === 'asc' ? 'asc' : 'desc'; - + // select sort method $sort_index = Context::get('sort_index'); if (!in_array($sort_index, array('declared_latest', 'declared_count', 'regdate'))) @@ -184,7 +184,7 @@ class DocumentAdminView extends Document $sort_index = 'declared_latest'; } Context::set('sort_index', $sort_index); - + // get latest declared list if ($sort_index === 'declared_latest') { @@ -325,7 +325,7 @@ class DocumentAdminView extends Document } else { - $aliases = $output->data; + $aliases = $output->data; } Context::set('aliases', $aliases); diff --git a/modules/document/document.class.php b/modules/document/document.class.php index 6769e2da4..d35e437c5 100644 --- a/modules/document/document.class.php +++ b/modules/document/document.class.php @@ -20,10 +20,10 @@ class Document extends ModuleObject /** * List of status texts supported by Rhymix. - * + * * Also see status constants in common/constants.php * and integer status codes used in the comment module. - * + * * @var array */ public static $statusList = array( @@ -107,10 +107,10 @@ class Document extends ModuleObject // 2011. 10. 25 status index check if(!$oDB->isIndexExists("documents", "idx_module_status")) return true; - // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied + // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true; - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true; // 2016. 1. 27: Add a column(declare_message) for report @@ -121,13 +121,13 @@ class Document extends ModuleObject // 2019. 3. 07 #1146 if(!$oDB->isColumnExists('document_update_log', 'reason_update')) return true; - + // 2017.12.21 Add an index for nick_name if(!$oDB->isIndexExists('documents', 'idx_nick_name')) return true; - + // 2018.01.24 Improve mass file deletion if(!ModuleModel::getTrigger('file.deleteFile', 'document', 'controller', 'triggerAfterDeleteFile', 'after')) return true; - + return false; } @@ -217,13 +217,13 @@ class Document extends ModuleObject $oDB->addIndex("documents", "idx_module_status", array("module_srl","status")); } - // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied + // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) { $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'); } - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!ModuleModel::getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) { $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'); @@ -241,19 +241,19 @@ class Document extends ModuleObject $oDB->addColumn('document_update_log', 'is_admin', 'varchar', 1); $oDB->addIndex('document_update_log', 'idx_is_admin', array('is_admin')); } - + // 2019. 3. 07 #1146 if(!$oDB->isColumnExists('document_update_log', 'reason_update')) { $oDB->addColumn('document_update_log', 'reason_update', 'text', '', null, false, 'extra_vars'); } - + // 2017.12.21 Add an index for nick_name if(!$oDB->isIndexExists('documents', 'idx_nick_name')) { $oDB->addIndex('documents', 'idx_nick_name', array('nick_name')); } - + // 2018.01.24 Improve mass file deletion if(!ModuleModel::getTrigger('file.deleteFile', 'document', 'controller', 'triggerAfterDeleteFile', 'after')) { diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index e755cd4c4..a67d1b8b5 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -29,7 +29,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $module_info = $this->module_info; if(!$module_info->module_srl) { @@ -42,7 +42,7 @@ class DocumentController extends Document throw new Rhymix\Framework\Exceptions\NotPermitted; } } - + $oDocument = DocumentModel::getDocument($document_srl, false, false); if(!$oDocument->isExists()) { @@ -75,7 +75,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $module_info = $this->module_info; if(!$module_info->module_srl) { @@ -106,7 +106,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exception('failed_voted_canceled'); } - + $point = 1; $output = $this->updateVotedCountCancel($document_srl, $oDocument, $point); if(!$output->toBool()) @@ -171,7 +171,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exceptions\FeatureDisabled; } - + $point = -1; $output = $this->updateVotedCount($document_srl, $point); if(!$output->toBool()) @@ -214,7 +214,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exception('failed_blamed_canceled'); } - + $point = -1; $output = $this->updateVotedCountCancel($document_srl, $oDocument, $point); if(!$output->toBool()) @@ -254,14 +254,14 @@ class DocumentController extends Document $args->ipaddress = \RX_CLIENT_IP; } $output = executeQuery('document.getDocumentVotedLogInfo', $args); - + if(!$output->data->count) { return new BaseObject(-1, $point > 0 ? 'failed_voted_canceled' : 'failed_blamed_canceled'); } $point = $output->data->point; - + // Call a trigger (before) $trigger_obj = new stdClass; $trigger_obj->member_srl = $oDocument->get('member_srl'); @@ -277,11 +277,11 @@ class DocumentController extends Document { return $trigger_output; } - + // begin transaction $oDB = DB::getInstance(); $oDB->begin(); - + if($point != 0) { $args = new stdClass(); @@ -306,9 +306,9 @@ class DocumentController extends Document // Call a trigger (after) ModuleHandler::triggerCall('document.updateVotedCountCancel', 'after', $trigger_obj); - + $oDB->commit(); - + return $output; } @@ -403,7 +403,7 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $oDocument = DocumentModel::getDocument($document_srl); if (!$oDocument || !$oDocument->isExists()) { @@ -413,14 +413,14 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exceptions\TargetNotFound; } - + $output = $this->deleteDocument($document_srl); if ($output instanceof BaseObject && !$output->toBool()) { return $output; } } - + /** * Delete alias when module deleted * @param int $module_srl @@ -521,13 +521,13 @@ class DocumentController extends Document // begin transaction $oDB = DB::getInstance(); $oDB->begin(); - + // List variables if($obj->comment_status) $obj->commentStatus = $obj->comment_status; if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; - if($obj->homepage) + if($obj->homepage) { $obj->homepage = escape($obj->homepage); if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) @@ -535,17 +535,17 @@ class DocumentController extends Document $obj->homepage = 'http://'.$obj->homepage; } } - + if($obj->notify_message != 'Y') $obj->notify_message = 'N'; if(!$obj->email_address) $obj->email_address = ''; if(!$isRestore) $obj->ipaddress = \RX_CLIENT_IP; $obj->isRestore = $isRestore ? true : false; - + // Sanitize variables $obj->document_srl = intval($obj->document_srl); $obj->category_srl = intval($obj->category_srl); $obj->module_srl = intval($obj->module_srl); - + // Default Status if($obj->status) { @@ -558,14 +558,14 @@ class DocumentController extends Document { $this->_checkDocumentStatusForOldVersion($obj); } - + // can modify regdate only manager $grant = Context::get('grant'); if(!$grant->manager) { unset($obj->regdate); } - + // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid if (!isset($obj->extra_vars)) { @@ -586,7 +586,7 @@ class DocumentController extends Document unset($obj->manual_member_info); $obj->uploaded_count = FileModel::getFilesCount($obj->document_srl); - + // Call a trigger (before) $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); if(!$output->toBool()) @@ -665,7 +665,7 @@ class DocumentController extends Document { $obj->content = getModel('editor')->converter($obj, 'document'); } - + // Remove iframe and script if not a top adminisrator in the session. if($logged_info->is_admin != 'Y') { @@ -680,7 +680,7 @@ class DocumentController extends Document $obj->content = utf8_mbencode($obj->content); $obj->lang_code = Context::getLangType(); - + // Insert data into the DB $output = executeQuery('document.insertDocument', $obj); if(!$output->toBool()) @@ -718,10 +718,10 @@ class DocumentController extends Document $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); } } - + // Update the category if the category_srl exists. if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); - + // Call a trigger (after) if($obj->update_log_setting === 'Y') { @@ -741,7 +741,7 @@ class DocumentController extends Document $oDB->rollback(); return $attachOutput; } - + $obj->updated_file_count = $attachOutput->get('updated_file_count'); ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); @@ -772,17 +772,17 @@ class DocumentController extends Document { return new BaseObject(-1, 'msg_security_violation'); } - + if(!$source_obj->document_srl || !$obj->document_srl) { return new BaseObject(-1, 'msg_invalied_request'); } - + // Sanitize variables $obj->document_srl = intval($obj->document_srl); $obj->category_srl = intval($obj->category_srl); $obj->module_srl = intval($obj->module_srl); - + // Default Status if($obj->status) { @@ -790,7 +790,7 @@ class DocumentController extends Document { $obj->status = $this->getDefaultStatus(); } - + // Do not update to temp document (point problem) if($obj->status == $this->getConfigStatus('temp')) { @@ -801,12 +801,12 @@ class DocumentController extends Document { $this->_checkDocumentStatusForOldVersion($obj); } - + // Remove manual member info to prevent forgery. This variable can be set by triggers only. unset($obj->manual_member_info); $obj->uploaded_count = FileModel::getFilesCount($obj->document_srl); - + // Call a trigger (before) $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); if(!$output->toBool()) @@ -817,9 +817,9 @@ class DocumentController extends Document // begin transaction $oDB = &DB::getInstance(); $oDB->begin(); - + if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); - + $document_config = ModuleModel::getModulePartConfig('document', $obj->module_srl); if(!$document_config) { @@ -829,7 +829,7 @@ class DocumentController extends Document $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; $logged_info = Context::get('logged_info'); - + if($bUseHistory) { $args = new stdClass; @@ -861,16 +861,16 @@ class DocumentController extends Document $obj->homepage = 'http://'.$obj->homepage; } } - + if($obj->notify_message != 'Y') $obj->notify_message = 'N'; - + // can modify regdate only manager $grant = Context::get('grant'); if(!$grant->manager) { unset($obj->regdate); } - + // Serialize the $extra_vars if (isset($obj->extra_vars) && !is_string($obj->extra_vars)) { @@ -952,7 +952,7 @@ class DocumentController extends Document { $obj->content = getModel('editor')->converter($obj, 'document'); } - + // Remove iframe and script if not a top adminisrator in the session. if($logged_info->is_admin != 'Y') { @@ -1069,7 +1069,7 @@ class DocumentController extends Document return $attachOutput; } $obj->updated_file_count = $attachOutput->get('updated_file_count'); - + // Call a trigger (after) ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); @@ -1080,7 +1080,7 @@ class DocumentController extends Document Rhymix\Framework\Storage::deleteDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); $output->add('document_srl',$obj->document_srl); - + //remove from cache self::clearDocumentCache($obj->document_srl); return $output; @@ -1195,7 +1195,7 @@ class DocumentController extends Document $trigger_obj = $oDocument->getObjectVars(); $trigger_obj->isEmptyTrash = $isEmptyTrash ? true : false; ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); - + // declared document, log delete $this->_deleteDeclaredDocuments($args); $this->_deleteDocumentReadedLog($args); @@ -1356,7 +1356,7 @@ class DocumentController extends Document $args->isvalid = 'N'; executeQuery('file.updateFileValid', $args); } - + // Call a trigger (after) $obj->module_srl = $oDocument->get('module_srl'); $obj->member_srl = $oDocument->get('member_srl'); @@ -1384,7 +1384,7 @@ class DocumentController extends Document { return false; } - + // Get the view count option, and use the default if the value is empty or invalid. $valid_options = array( 'all' => true, @@ -1392,7 +1392,7 @@ class DocumentController extends Document 'once' => true, 'none' => true, ); - + $config = DocumentModel::getDocumentConfig(); if (!isset($config->view_count_option) || !isset($valid_options[$config->view_count_option])) { @@ -1404,12 +1404,12 @@ class DocumentController extends Document { return false; } - + // Get document and user information. $document_srl = $oDocument->document_srl; $member_srl = $oDocument->get('member_srl'); $logged_info = Context::get('logged_info'); - + // Option 'some': only count once per session. if ($config->view_count_option != 'all' && isset($_SESSION['readed_document'][$document_srl])) { @@ -1428,7 +1428,7 @@ class DocumentController extends Document } return false; } - + // Pass if the author's member_srl is the same as the visitor's. if($member_srl && $logged_info && $logged_info->member_srl && $logged_info->member_srl == $member_srl) { @@ -1440,7 +1440,7 @@ class DocumentController extends Document // Call a trigger when the read count is updated (before) $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); if(!$trigger_output->toBool()) return $trigger_output; - + // Update read counts $oDB = DB::getInstance(); $oDB->begin(); @@ -1453,7 +1453,7 @@ class DocumentController extends Document $oDB->commit(); // Register session - if(!isset($_SESSION['readed_document'][$document_srl]) && Context::getSessionStatus()) + if(!isset($_SESSION['readed_document'][$document_srl]) && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; } @@ -1577,7 +1577,7 @@ class DocumentController extends Document { return new BaseObject(-1, 'msg_invalid_request'); } - + if (is_int($idx_or_eid) || ctype_digit($idx_or_eid)) { if (!$eid) @@ -1598,7 +1598,7 @@ class DocumentController extends Document return new BaseObject(-1, 'Invalid eid: ' . $eid); } } - + $obj = new stdClass; $obj->module_srl = $module_srl; $obj->document_srl = $document_srl; @@ -1626,7 +1626,7 @@ class DocumentController extends Document { return new BaseObject(-1, 'msg_invalid_request'); } - + if (is_int($idx_or_eid) || ctype_digit($idx_or_eid)) { if (!$eid) @@ -1647,7 +1647,7 @@ class DocumentController extends Document return new BaseObject(-1, 'Invalid eid: ' . $eid); } } - + $obj = new stdClass; $obj->module_srl = $module_srl; $obj->document_srl = $document_srl; @@ -1658,21 +1658,21 @@ class DocumentController extends Document $oDB = DB::getInstance(); $oDB->begin(); - + $output = self::deleteDocumentExtraVars($module_srl, $document_srl, $idx_or_eid, $lang_code, $eid); if (!$output->toBool()) { $oDB->rollback(); return $output; } - + $output = self::insertDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid, $lang_code); if (!$output->toBool()) { $oDB->rollback(); return $output; } - + $oDB->commit(); return $output; } @@ -1782,7 +1782,7 @@ class DocumentController extends Document { return $trigger_output; } - + // begin transaction $oDB = DB::getInstance(); $oDB->begin(); @@ -1806,7 +1806,7 @@ class DocumentController extends Document // Leave in the session information $_SESSION['voted_document'][$document_srl] = $trigger_obj->point; - + // Leave logs $args->point = $trigger_obj->point; $output = executeQuery('document.insertDocumentVotedLog', $args); @@ -1815,7 +1815,7 @@ class DocumentController extends Document $oDB->rollback(); return $output; } - + // Call a trigger (after) ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj); @@ -1836,7 +1836,7 @@ class DocumentController extends Document $output->setMessage('success_blamed'); $output->add('blamed_count', $trigger_obj->after_point); } - + return $output; } @@ -1862,10 +1862,10 @@ class DocumentController extends Document { return $output; } - + $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; $declare_message = trim(htmlspecialchars($declare_message)); - + $trigger_obj = new stdClass(); $trigger_obj->document_srl = $document_srl; $trigger_obj->declared_count = $declared_count; @@ -1890,7 +1890,7 @@ class DocumentController extends Document // Get currently logged in user. $member_srl = $this->user->member_srl; - + // Check if document's author is a member. if($oDocument->get('member_srl')) { @@ -1919,12 +1919,12 @@ class DocumentController extends Document $_SESSION['declared_document'][$document_srl] = false; return new BaseObject(-1, 'failed_declared'); } - + // Fill in remaining information for logging. $args->member_srl = $member_srl; $args->ipaddress = \RX_CLIENT_IP; $args->declare_message = $declare_message; - + // begin transaction $oDB = DB::getInstance(); $oDB->begin(); @@ -1954,7 +1954,7 @@ class DocumentController extends Document } $this->add('declared_count', $declared_count + 1); - + // Send message to admin $message_targets = array(); $module_srl = $oDocument->get('module_srl'); @@ -2011,7 +2011,7 @@ class DocumentController extends Document { return new BaseObject(-1, 'failed_declared_cancel'); } - + // Get the original document $oDocument = DocumentModel::getDocument($document_srl, false, false); @@ -2034,7 +2034,7 @@ class DocumentController extends Document unset($_SESSION['declared_document'][$document_srl]); return new BaseObject(-1, 'failed_declared_cancel'); } - + // Get current declared count $args = new stdClass(); $args->document_srl = $document_srl; @@ -2050,7 +2050,7 @@ class DocumentController extends Document { return $trigger_output; } - + if($declared_count > 1) { $output = executeQuery('document.updateDeclaredDocumentCancel', $args); @@ -2064,14 +2064,14 @@ class DocumentController extends Document $oDB->rollback(); return $output; } - + $output = executeQuery('document.deleteDeclaredDocumentLog', $args); if(!$output->toBool()) { $oDB->rollback(); return $output; } - + $message_targets = array(); $module_srl = $oDocument->get('module_srl'); $document_config = ModuleModel::getModulePartConfig('document', $module_srl); @@ -2101,7 +2101,7 @@ class DocumentController extends Document $oCommunicationController->sendMessage($this->user->member_srl, $target_member_srl, $message_title, $message_content, false. null, false); } } - + $oDB->commit(); $trigger_obj->declared_count = $declared_count - 1; @@ -2258,7 +2258,7 @@ class DocumentController extends Document if(!$output->toBool()) return $output; $this->makeCategoryFile($category_info->module_srl); - + // remove cache $page = 0; while(true) @@ -3022,7 +3022,7 @@ class DocumentController extends Document { @set_time_limit(0); $logged_info = Context::get('logged_info'); - + $obj = new stdClass; $obj->type = Context::get('type'); $obj->document_list = array(); @@ -3032,7 +3032,7 @@ class DocumentController extends Document $obj->manager_message = Context::get('message_content') ? nl2br(escape(strip_tags(Context::get('message_content')))) : ''; $obj->send_message = $obj->manager_message || Context::get('send_default_message') == 'Y'; $obj->return_message = ''; - + // Check permission of target module if($obj->target_module_srl) { @@ -3047,7 +3047,7 @@ class DocumentController extends Document throw new Rhymix\Framework\Exceptions\NotPermitted; } } - + // Set Cart $cart = Context::get('cart'); if(!is_array($cart)) @@ -3055,21 +3055,21 @@ class DocumentController extends Document $cart = explode('|@|', $cart); } $obj->document_srl_list = array_unique(array_map('intval', $cart)); - + // Set document list $obj->document_list = DocumentModel::getDocuments($obj->document_srl_list, false, false); if(empty($obj->document_list)) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + // Call a trigger (before) $output = ModuleHandler::triggerCall('document.manage', 'before', $obj); if(!$output->toBool()) { return $output; } - + $oController = getAdminController('document'); if($obj->type == 'move') { @@ -3077,13 +3077,13 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exception('fail_to_move'); } - + $output = $oController->moveDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl); if(!$output->toBool()) { return $output; } - + $obj->return_message = 'success_moved'; } else if($obj->type == 'copy') @@ -3092,13 +3092,13 @@ class DocumentController extends Document { throw new Rhymix\Framework\Exception('fail_to_move'); } - + $output = $oController->copyDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl); if(!$output->toBool()) { return $output; } - + $obj->return_message = 'success_copied'; } else if($obj->type == 'delete') @@ -3112,14 +3112,14 @@ class DocumentController extends Document $obj->return_message = $output->getMessage(); } } - + $obj->return_message = $obj->return_message ?: 'success_deleted'; } else if($obj->type == 'trash') { $args = new stdClass; $args->description = $obj->manager_message; - + foreach ($obj->document_list as $document_srl => $oDocument) { $args->document_srl = $document_srl; @@ -3130,7 +3130,7 @@ class DocumentController extends Document $obj->return_message = $output->getMessage(); } } - + $obj->return_message = $obj->return_message ?: 'success_trashed'; } else if($obj->type == 'cancelDeclare') @@ -3142,17 +3142,17 @@ class DocumentController extends Document { return $output; } - + $obj->return_message = 'success_declare_canceled'; } else { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + // Call a trigger (after) ModuleHandler::triggerCall('document.manage', 'after', $obj); - + // Send a message $actions = lang('default_message_verbs'); if(isset($actions[$obj->type]) && $obj->send_message) @@ -3166,7 +3166,7 @@ class DocumentController extends Document

Content; $document_item = '
  • %2$s
  • '; - + // Set recipient $recipients = array(); foreach ($obj->document_list as $document_srl => $oDocument) @@ -3175,15 +3175,15 @@ Content; { continue; } - + if(!isset($recipients[$member_srl])) { $recipients[$member_srl] = array(); } - + $recipients[$member_srl][] = sprintf($document_item, $oDocument->getPermanentUrl(), $oDocument->getTitleText()); } - + // Send $oCommunicationController = getController('communication'); foreach ($recipients as $member_srl => $items) @@ -3191,9 +3191,9 @@ Content; $oCommunicationController->sendMessage($this->user->member_srl, $member_srl, $title, sprintf($content, implode('', $items)), true, null, false); } } - + $_SESSION['document_management'] = array(); - + $this->setMessage($obj->return_message); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList')); } @@ -3211,19 +3211,19 @@ Content; foreach ($target_module_srl as $srl) { if (!$srl) continue; - + $module_info = ModuleModel::getModuleInfoByModuleSrl($srl); if (!$module_info->module_srl) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $module_grant = ModuleModel::getGrant($module_info, $logged_info); if (!$module_grant->manager) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $module_srl[] = $srl; } @@ -3246,7 +3246,7 @@ Content; { $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); } - + $this->setError(-1); $this->setMessage('success_updated', 'info'); @@ -3264,11 +3264,11 @@ Content; { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $obj = Context::getRequestVars(); $obj->module_srl = $this->module_srl; $obj->status = $this->getConfigStatus('temp'); - + // unset document style if not manager if(!$this->grant->manager) { @@ -3276,9 +3276,9 @@ Content; unset($obj->title_color); unset($obj->title_bold); } - + $oDocument = DocumentModel::getDocument($obj->document_srl); - + // Update if already exists if($oDocument->isExists()) { @@ -3286,22 +3286,22 @@ Content; { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + if($oDocument->get('status') != $this->getConfigStatus('temp')) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + $output = $this->updateDocument($oDocument, $obj); } // Otherwise, get a new else { $output = $this->insertDocument($obj); - + $oDocument = DocumentModel::getDocument($output->get('document_srl')); } - + // Set the attachment to be invalid state if($oDocument->hasUploadedFiles()) { @@ -3310,7 +3310,7 @@ Content; $args->upload_target_srl = $oDocument->document_srl; executeQuery('file.updateFileValid', $args); } - + $this->setMessage('success_saved'); $this->add('document_srl', $output->get('document_srl')); } @@ -3325,7 +3325,7 @@ Content; { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $documentSrls = Context::get('document_srls'); if($documentSrls) $documentSrlList = explode(',', $documentSrls); @@ -3346,7 +3346,7 @@ Content; /** * Clear document cache - * + * * @param int $document_srl * @param string $type */ @@ -3365,7 +3365,7 @@ Content; unset($GLOBALS['RX_DOCUMENT_LANG'][$document_srl]); } } - + /** * For old version, comment allow status check. * @param object $obj @@ -3399,35 +3399,35 @@ Content; } } } - + public function updateUploaedCount($document_srl_list) { if(!is_array($document_srl_list)) { $document_srl_list = array($document_srl_list); } - + if(empty($document_srl_list)) { return; } - + $document_srl_list = array_unique($document_srl_list); - + foreach($document_srl_list as $document_srl) { if(!$document_srl = (int) $document_srl) { continue; } - + $args = new stdClass; $args->document_srl = $document_srl; $args->uploaded_count = FileModel::getFilesCount($document_srl); executeQuery('document.updateUploadedCount', $args); } } - + function triggerAfterDeleteFile($file) { $oDocument = DocumentModel::getDocument($file->upload_target_srl, false, false); @@ -3435,10 +3435,10 @@ Content; { return; } - + $this->updateUploaedCount($file->upload_target_srl); } - + /** * Copy extra keys when module copied * @param object $obj diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 129c8a2dd..f1d313501 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -92,11 +92,11 @@ class DocumentItem extends BaseObject { return; } - + $document_item = false; $columnList = array(); $reload_counts = true; - + if ($this->columnList === false) { $reload_counts = false; @@ -145,7 +145,7 @@ class DocumentItem extends BaseObject $this->document_srl = null; return; } - + $this->document_srl = $attribute->document_srl; $this->lang_code = $attribute->lang_code ?? null; $this->adds($attribute); @@ -154,22 +154,22 @@ class DocumentItem extends BaseObject $this->add('apparent_module_srl', $attribute->module_srl); $this->add('origin_module_srl', $attribute->module_srl); } - + // set XE_DOCUMENT_LIST $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this; - + // set tags if($this->get('tags')) { $this->add('tag_list', $this->getTags()); } - + // set extra vars if($load_extra_vars) { DocumentModel::setToAllDocumentExtraVars(); } - + // set content in user language if(isset($GLOBALS['RX_DOCUMENT_LANG'][$this->document_srl]['title'])) { @@ -185,24 +185,24 @@ class DocumentItem extends BaseObject { return (bool) ($this->document_srl); } - + function isGranted() { if(!$this->isExists()) { return false; } - + if (isset($_SESSION['granted_document'][$this->document_srl])) { return true; } - + if ($this->grant_cache !== null) { return $this->grant_cache; } - + $logged_info = Context::get('logged_info'); if (!$logged_info || !$logged_info->member_srl) { @@ -216,34 +216,34 @@ class DocumentItem extends BaseObject { return $this->grant_cache = true; } - + $grant = ModuleModel::getGrant(ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); if ($grant->manager) { return $this->grant_cache = true; } - + return $this->grant_cache = false; } - + function setGrant() { $this->grant_cache = true; } - + function setGrantForSession() { $_SESSION['granted_document'][$this->document_srl] = true; $this->setGrant(); } - + function isAccessible($strict = false) { if(!$this->isExists()) { return false; } - + if ($strict) { $module_info = ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')); @@ -257,28 +257,28 @@ class DocumentItem extends BaseObject return false; } } - + if (isset($_SESSION['accessible'][$this->document_srl]) && $_SESSION['accessible'][$this->document_srl] === $this->get('last_update')) { return true; } - + $status_list = DocumentModel::getStatusList(); if ($this->get('status') === $status_list['public']) { $this->setAccessible(); return true; } - + if ($this->isGranted()) { $this->setAccessible(); return true; } - + return false; } - + function setAccessible() { if(Context::getSessionStatus()) @@ -286,7 +286,7 @@ class DocumentItem extends BaseObject $_SESSION['accessible'][$this->document_srl] = $this->get('last_update'); } } - + function allowComment() { // init write, document is not exists. so allow comment status is true @@ -294,7 +294,7 @@ class DocumentItem extends BaseObject { return true; } - + return (bool) ($this->get('comment_status') == 'ALLOW'); } @@ -303,7 +303,7 @@ class DocumentItem extends BaseObject static $allow_trackback_status = null; if(is_null($allow_trackback_status)) { - + // Check the tarckback module exist if(!getClass('trackback')) { @@ -313,12 +313,12 @@ class DocumentItem extends BaseObject { // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. $trackback_config = ModuleModel::getModuleConfig('trackback'); - + if(!$trackback_config) { $trackback_config = new stdClass(); } - + if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; else @@ -340,7 +340,7 @@ class DocumentItem extends BaseObject { return false; } - + return (bool) ($this->get('comment_status') != 'ALLOW'); } @@ -348,29 +348,29 @@ class DocumentItem extends BaseObject { return (bool) (!$this->get('member_srl') || $this->isGranted()); } - + function isSecret() { return (bool) ($this->get('status') == DocumentModel::getConfigStatus('secret')); } - + function isNotice() { return (bool) ($this->get('is_notice') === 'Y' || $this->get('is_notice') === 'A'); } - + function useNotify() { return (bool) ($this->get('notify_message') == 'Y'); } - + function doCart() { if(!$this->isExists()) { return false; } - + $this->isCarted() ? $this->removeCart() : $this->addCart(); } @@ -411,18 +411,18 @@ class DocumentItem extends BaseObject { return; } - + // Return if the currently logged-in user is an author $logged_info = Context::get('logged_info'); if($logged_info->member_srl == $this->get('member_srl')) { return; } - + // List variables $title = ($type ? sprintf('[%s] ', $type) : '') . cut_str(strip_tags($content), 10, '...'); $content = sprintf('%s

    from : %s',$content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl)); - + // Send a message $sender_member_srl = $logged_info->member_srl ?: $this->get('member_srl'); getController('communication')->sendMessage($sender_member_srl, $this->get('member_srl'), $title, $content, false, null, false); @@ -439,7 +439,7 @@ class DocumentItem extends BaseObject { return $this->get('ipaddress'); } - + return '*' . strstr($this->get('ipaddress') ?? '', '.'); } @@ -454,12 +454,12 @@ class DocumentItem extends BaseObject { return; } - + if(!preg_match('@^[a-z]+://@i', $url)) { $url = 'http://' . $url; } - + return escape($url, false); } @@ -494,7 +494,7 @@ class DocumentItem extends BaseObject { return; } - + return $cut_size ? cut_str($this->get('title'), $cut_size, $tail) : $this->get('title'); } @@ -514,7 +514,7 @@ class DocumentItem extends BaseObject { return $_SESSION['voted_document'][$this->document_srl]; } - + $logged_info = Context::get('logged_info'); if(!$logged_info->member_srl) { @@ -554,7 +554,7 @@ class DocumentItem extends BaseObject { return false; } - + $logged_info = Context::get('logged_info'); if(!$logged_info->member_srl) { @@ -565,7 +565,7 @@ class DocumentItem extends BaseObject { return $_SESSION['declared_document'][$this->document_srl]; } - + $args = new stdClass(); if($logged_info->member_srl) { @@ -582,7 +582,7 @@ class DocumentItem extends BaseObject { return $_SESSION['declared_document'][$this->document_srl] = $declaredCount; } - + return false; } @@ -592,10 +592,10 @@ class DocumentItem extends BaseObject { return false; } - + $title = escape($this->getTitleText($cut_size, $tail), false); $this->add('title_color', trim($this->get('title_color') ?? '')); - + $attrs = array(); if($this->get('title_bold') == 'Y') { @@ -609,7 +609,7 @@ class DocumentItem extends BaseObject { return sprintf('%s', implode(';', $attrs), $title); } - + return $title; } @@ -619,19 +619,19 @@ class DocumentItem extends BaseObject { return; } - + if(!$this->isAccessible()) { return lang('msg_is_secret'); } - + $content = $this->get('content'); $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); if($strlen) { $content = cut_str($content, $strlen, '...'); } - + return escape($content); } @@ -641,12 +641,12 @@ class DocumentItem extends BaseObject { return; } - + if(!$this->isAccessible()) { return lang('msg_is_secret'); } - + $content = $this->get('content'); $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); $content = preg_replace_callback('/]*>/is', array($this, '_addAllowScriptAccess'), $content); @@ -655,7 +655,7 @@ class DocumentItem extends BaseObject $content = trim(utf8_normalize_spaces(html_entity_decode(strip_tags($content)))); $content = cut_str($content, $strlen, '...'); } - + return escape($content); } @@ -708,18 +708,18 @@ class DocumentItem extends BaseObject { return; } - + if(!$this->isAccessible()) { return lang('msg_is_secret'); } - + $content = $this->get('content'); if(!$stripEmbedTagException) { stripEmbedTagForAdmin($content, $this->get('member_srl')); } - + // Define a link if using a rewrite module if(Context::isAllowRewrite()) { @@ -761,7 +761,7 @@ class DocumentItem extends BaseObject { $content = preg_replace_callback('/]+)>/i',array($this,'replaceResourceRealPath'), $content); } - + return $content; } @@ -779,31 +779,31 @@ class DocumentItem extends BaseObject { return; } - + $content = $this->getContent($add_popup_menu, $add_content_info, $resource_realpath, $add_xe_content_class); $content = getController('editor')->transComponent($content); - + return $content; } - + function getSummary($str_size = 50, $tail = '...') { // Remove tags $content = $this->getContent(false, false); $content = strip_tags(preg_replace('!<(style|script)\b.+?!is', '', $content)); - + // Convert temporarily html entity for truncate $content = html_entity_decode($content, ENT_QUOTES); - + // Replace all whitespaces to single space $content = utf8_trim(utf8_normalize_spaces($content)); - + // Truncate string $content = cut_str($content, $str_size, $tail); - + return escape($content); } - + function getRegdate($format = 'Y.m.d H:i:s', $conversion = true) { return zdate($this->get('regdate'), $format, $conversion); @@ -854,9 +854,9 @@ class DocumentItem extends BaseObject */ public function getTrackbackUrl() { - + } - + public function getUrl() { return getFullUrl('', 'mid', $this->getApparentMid(), 'document_srl', $this->get('document_srl')); @@ -868,14 +868,14 @@ class DocumentItem extends BaseObject $tag_list = array_filter($tag_list, function($str) { return $str !== ''; }); return array_unique($tag_list); } - + public function getHashtags() { preg_match_all('/(?get('content')), $hashtags); $hashtags[1] = array_map(function($str) { return escape($str, false); }, $hashtags[1]); return array_unique($hashtags[1]); } - + /** * Update readed count * @return void @@ -911,35 +911,35 @@ class DocumentItem extends BaseObject return DocumentModel::getExtraVars($module_srl, $this->document_srl); } - + function getExtraEids() { if($this->extra_eids) { return $this->extra_eids; } - + $extra_vars = $this->getExtraVars(); foreach($extra_vars as $idx => $key) { $this->extra_eids[$key->eid] = $key; } - + return $this->extra_eids; } - + function getExtraValue($idx) { $extra_vars = $this->getExtraVars(); return isset($extra_vars[$idx]) ? $extra_vars[$idx]->getValue() : ''; } - + function getExtraValueHTML($idx) { $extra_vars = $this->getExtraVars(); return isset($extra_vars[$idx]) ? $extra_vars[$idx]->getValueHTML() : ''; } - + function getExtraEidValue($eid) { $extra_eids = $this->getExtraEids(); @@ -951,7 +951,7 @@ class DocumentItem extends BaseObject $extra_eids = $this->getExtraEids(); return isset($extra_eids[$eid]) ? $extra_eids[$eid]->getValueHTML() : ''; } - + function getExtraVarsValue($key) { $extra_vals = unserialize($this->get('extra_vars')); @@ -969,12 +969,12 @@ class DocumentItem extends BaseObject { return; } - + if(!$this->isAccessible()) { return; } - + // cpage is a number of comment pages $cpageStr = sprintf('%d_cpage', $this->document_srl); $cpage = Context::get($cpageStr); @@ -994,7 +994,7 @@ class DocumentItem extends BaseObject // Get a list of comments $output = CommentModel::getCommentList($this->document_srl, $cpage); if(!$output->toBool() || !count($output->data)) return; - + // Create commentItem object from a comment list // If admin priviledge is granted on parent posts, you can read its child posts. $accessible = array(); @@ -1016,7 +1016,7 @@ class DocumentItem extends BaseObject } $comment_list[$val->comment_srl] = $oCommentItem; } - + // Cache the vote log for all comments. $logged_info = Context::get('logged_info'); if ($logged_info->member_srl) @@ -1048,12 +1048,12 @@ class DocumentItem extends BaseObject } } } - + // Variable setting to be displayed on the skin Context::set($cpageStr, $output->page_navigation->cur_page); Context::set('cpage', $output->page_navigation->cur_page); if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; - + // Call trigger (after) $output = ModuleHandler::triggerCall('document.getComments', 'after', $comment_list); @@ -1107,7 +1107,7 @@ class DocumentItem extends BaseObject { $config->thumbnail_quality = 75; } - + // If not specify its height, create a square if(!is_int($width)) { @@ -1117,7 +1117,7 @@ class DocumentItem extends BaseObject { $height = $width; } - + // Define thumbnail information $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); @@ -1137,7 +1137,7 @@ class DocumentItem extends BaseObject return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file)); } } - + // Call trigger for custom thumbnails. $trigger_obj = (object)[ 'document_srl' => $this->document_srl, 'width' => $width, 'height' => $height, @@ -1150,7 +1150,7 @@ class DocumentItem extends BaseObject { return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file)); } - + // Get content if it does not exist. if($this->get('content')) { @@ -1163,7 +1163,7 @@ class DocumentItem extends BaseObject $output = executeQuery('document.getDocument', $args); $content = $output->data->content; } - + // Return false if neither attachement nor image files in the document if(!$this->get('uploaded_count') && !preg_match("!width, $trigger_obj->height, $trigger_obj->image_type, $trigger_obj->type, $trigger_obj->quality); @@ -1343,7 +1343,7 @@ class DocumentItem extends BaseObject /** * Return the status code. - * + * * @return string */ function getStatus() @@ -1354,7 +1354,7 @@ class DocumentItem extends BaseObject /** * Return the status in human-readable text. - * + * * @return string */ function getStatusText() @@ -1406,7 +1406,7 @@ class DocumentItem extends BaseObject $iconSkin = 'default'; $iconType = 'gif'; } - + $path = sprintf('%s%s', \RX_BASEURL, "modules/document/tpl/icons/$iconSkin/"); $buff = array(); foreach($icons as $icon) @@ -1422,12 +1422,12 @@ class DocumentItem extends BaseObject { return false; } - + if(!$this->isAccessible()) { return false; } - + return $this->get('uploaded_count')? true : false; } @@ -1437,22 +1437,22 @@ class DocumentItem extends BaseObject { return; } - + if(!$this->isAccessible()) { return; } - + if(!$this->get('uploaded_count')) { return; - } - + } + if(!isset($this->uploadedFiles[$sortIndex])) { $this->uploadedFiles[$sortIndex] = FileModel::getFiles($this->document_srl, array(), $sortIndex, true); } - + return $this->uploadedFiles[$sortIndex]; } @@ -1478,12 +1478,12 @@ class DocumentItem extends BaseObject { return false; } - + if(!$this->isAccessible()) { return false; } - + return true; } @@ -1577,7 +1577,7 @@ class DocumentItem extends BaseObject /** * Returns the apparent mid. - * + * * @return string */ function getApparentMid() @@ -1587,7 +1587,7 @@ class DocumentItem extends BaseObject /** * Returns the true mid. - * + * * @return string */ function getDocumentMid() diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 1b2b7bb3a..74babbc4c 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -29,7 +29,7 @@ class DocumentModel extends Document { return $_SESSION['granted_document'][$document_srl]; } - + /** * Return document extra information from database * @param array $document_srls @@ -41,7 +41,7 @@ class DocumentModel extends Document $args->document_srl = $document_srls; return executeQueryArray('document.getDocumentExtraVars', $args); } - + /** * Extra variables for each article will not be processed bulk select and apply the macro city * @return void @@ -54,10 +54,10 @@ class DocumentModel extends Document { return; } - + static $checked = array(); static $module_extra_keys = array(); - + // check documents $document_srls = array(); foreach($_document_list as $document_srl => $oDocument) @@ -66,16 +66,16 @@ class DocumentModel extends Document { continue; } - + $checked[$document_srl] = true; $document_srls[] = $document_srl; } - + if(!$document_srls) { return; } - + // get extra values of documents $extra_values = array(); $output = self::getDocumentExtraVarsFromDB($document_srls); @@ -85,10 +85,10 @@ class DocumentModel extends Document { continue; } - + $extra_values[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); } - + // set extra variables and document language $user_lang_code = Context::getLangType(); foreach($document_srls as $document_srl) @@ -97,7 +97,7 @@ class DocumentModel extends Document $module_srl = $oDocument->get('module_srl'); $document_lang_code = $oDocument->get('lang_code'); $document_extra_values = $extra_values[$document_srl] ?? []; - + // set XE_EXTRA_VARS if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) { @@ -106,7 +106,7 @@ class DocumentModel extends Document { $module_extra_keys[$module_srl] = self::getExtraKeys($module_srl); } - + // set extra variables of the document if($module_extra_keys[$module_srl]) { @@ -114,7 +114,7 @@ class DocumentModel extends Document foreach($module_extra_keys[$module_srl] as $idx => $key) { $document_extra_vars[$idx] = clone($key); - + // set variable value in user language if(isset($document_extra_values[$idx][$user_lang_code])) { @@ -125,11 +125,11 @@ class DocumentModel extends Document $document_extra_vars[$idx]->setValue($document_extra_values[$idx][$document_lang_code]); } } - + $GLOBALS['XE_EXTRA_VARS'][$document_srl] = $document_extra_vars; } } - + // set RX_DOCUMENT_LANG if(!isset($GLOBALS['RX_DOCUMENT_LANG'][$document_srl]) && $document_lang_code !== $user_lang_code) { @@ -174,7 +174,7 @@ class DocumentModel extends Document trigger_error('Called DocumentModel::getDocument() with $is_admin = true', \E_USER_WARNING); $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); } - + return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; } @@ -202,7 +202,7 @@ class DocumentModel extends Document $args->list_count = is_array($document_srls) ? count($document_srls) : 1; $args->order_type = 'asc'; $output = executeQueryArray('document.getDocuments', $args, $columnList); - + $documents = array(); foreach($output->data as $attribute) { @@ -216,15 +216,15 @@ class DocumentModel extends Document trigger_error('Called DocumentModel::getDocuments() with $is_admin = true', \E_USER_WARNING); $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]->setGrant(); } - + $documents[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]; } - + if($load_extra_vars) { self::setToAllDocumentExtraVars(); } - + return $documents; } @@ -243,7 +243,7 @@ class DocumentModel extends Document $obj->isExtraVars = $sort_check->isExtraVars; $obj->except_notice = $except_notice; $obj->columnList = $columnList; - + // Call trigger (before) // This trigger can be used to set an alternative output using a different search method unset($obj->use_alternate_output); @@ -252,7 +252,7 @@ class DocumentModel extends Document { return $output; } - + // If an alternate output is set, use it instead of running the default queries if (isset($obj->use_alternate_output) && $obj->use_alternate_output instanceof BaseObject) { @@ -264,13 +264,13 @@ class DocumentModel extends Document self::_setSearchOption($obj, $args, $query_id, $use_division); $output = executeQueryArray($query_id, $args, $args->columnList); } - + // Return if no result or an error occurs if(!$output->toBool() || !$result = $output->data) { return $output; } - + $output->data = array(); foreach($result as $key => $attribute) { @@ -281,12 +281,12 @@ class DocumentModel extends Document } $output->data[$key] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]; } - + if($load_extra_vars) { self::setToAllDocumentExtraVars(); } - + // Call trigger (after) // This trigger can be used to modify search results ModuleHandler::triggerCall('document.getDocumentList', 'after', $output); @@ -324,12 +324,12 @@ class DocumentModel extends Document { $output = executeQueryArray('document.getNoticeList', $args, $columnList); } - + if(!$output->toBool() || !$result = $output->data) { return $output; } - + $output->data = array(); foreach($result as $attribute) { @@ -338,10 +338,10 @@ class DocumentModel extends Document $oDocument = new documentItem(); $oDocument->setAttribute($attribute, false); } - + $output->data[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]; } - + self::setToAllDocumentExtraVars(); // Call trigger (after) @@ -446,15 +446,15 @@ class DocumentModel extends Document { return array(); } - + ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); - + return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; } /** * Get var_idx of extra variable from its eid - * + * * @param int $module_srl * @param string $eid * @return int|false @@ -475,7 +475,7 @@ class DocumentModel extends Document /** * Get eid of extra variable from its var_idx - * + * * @param int $module_srl * @param int $idx * @return string|false @@ -493,7 +493,7 @@ class DocumentModel extends Document return false; } } - + /** * Show pop-up menu of the selected posts * Printing, scrap, recommendations and negative, reported the Add Features @@ -1281,7 +1281,7 @@ class DocumentModel extends Document return $list; } } - + /** * Setting sort index * @param object $obj @@ -1293,34 +1293,34 @@ class DocumentModel extends Document $args = new stdClass; $args->sort_index = $obj->sort_index ?? null; $args->isExtraVars = false; - + // check it's default sort $default_sort = array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl'); if(in_array($args->sort_index, $default_sort)) { return $args; } - + // check it can use extra variable if(!$load_extra_vars || !$extra_keys = self::getExtraKeys($obj->module_srl ?? 0)) { $args->sort_index = 'list_order'; return $args; } - + $eids = array(); foreach($extra_keys as $idx => $key) { $eids[] = $key->eid; } - + // check it exists in extra keys of the module if(!in_array($args->sort_index, $eids)) { $args->sort_index = 'list_order'; return $args; } - + $args->isExtraVars = true; return $args; } @@ -1361,13 +1361,13 @@ class DocumentModel extends Document $args->s_is_notice = ($searchOpt->except_notice ?? false) ? 'N' : null; $args->statusList = $searchOpt->statusList ?? array(self::getConfigStatus('public'), self::getConfigStatus('secret')); $args->columnList = $searchOpt->columnList ?? array(); - + // get directly module_srl by mid if(isset($searchOpt->mid) && $searchOpt->mid) { $args->module_srl = ModuleModel::getModuleSrlByMid($searchOpt->mid); } - + // add subcategories if(isset($args->category_srl) && $args->category_srl) { @@ -1379,13 +1379,13 @@ class DocumentModel extends Document $args->category_srl = $categories; } } - + // default $query_id = null; $use_division = false; $search_target = $searchOpt->search_target ?? null; $search_keyword = trim($searchOpt->search_keyword ?? '') ?: null; - + // search if($search_target && $search_keyword) { @@ -1463,7 +1463,7 @@ class DocumentModel extends Document } break; } - + // exclude secret documents in searching if current user does not have privilege if(!isset($args->member_srl) || !$args->member_srl || !Context::get('is_logged') || $args->member_srl !== Context::get('logged_info')->member_srl) { @@ -1475,7 +1475,7 @@ class DocumentModel extends Document } } } - + // set query if(!$query_id) { @@ -1499,12 +1499,12 @@ class DocumentModel extends Document $query_id = 'document.getDocumentList'; } } - // other queries not support to sort extra variable + // other queries not support to sort extra variable elseif($searchOpt->isExtraVars) { $args->sort_index = 'list_order'; } - + // division search by 5,000 if($use_division) { @@ -1512,18 +1512,18 @@ class DocumentModel extends Document $args->sort_index = 'list_order'; $args->division = (int)Context::get('division'); $args->last_division = (int)Context::get('last_division'); - + $division_args = new stdClass; $division_args->module_srl = $args->module_srl; $division_args->exclude_module_srl = $args->exclude_module_srl; - + // get start point of first division if(Context::get('division') === null) { $division_output = executeQuery('document.getDocumentDivision', $division_args)->data; $args->division = $division_output ? $division_output->list_order : 0; } - + // get end point of the division if(Context::get('last_division') === null && $args->division) { @@ -1532,11 +1532,11 @@ class DocumentModel extends Document $division_output = executeQuery('document.getDocumentDivision', $division_args)->data; $args->last_division = $division_output ? $division_output->list_order : 0; } - + Context::set('division', $args->division); Context::set('last_division', $args->last_division); } - + // add default prefix if($args->sort_index && strpos($args->sort_index, '.') === false) { @@ -1581,11 +1581,11 @@ class DocumentModel extends Document $args->list_count = $count; $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); $document_list = $output->data; - + if(!$document_list) return array(); if(!is_array($document_list)) $document_list = array($document_list); - return $document_list; + return $document_list; } public static function getDocumentUpdateLog($document_srl) diff --git a/modules/document/document.view.php b/modules/document/document.view.php index 8bf60cb6f..34c072bae 100644 --- a/modules/document/document.view.php +++ b/modules/document/document.view.php @@ -53,15 +53,15 @@ class DocumentView extends Document if(!checkCSRF()) { throw new Rhymix\Framework\Exceptions\SecurityViolation; - } - + } + $content = Context::get('content'); - + if(Context::get('logged_info')->is_admin != 'Y') { $content = removeHackTag($content); } - + // Editor converter $obj = new stdClass; $obj->content = $content; @@ -69,7 +69,7 @@ class DocumentView extends Document $content = getModel('editor')->converter($obj, 'document'); $content = sprintf('
    %s
    ', Context::get('logged_info')->member_srl, $content); Context::set('content', $content); - + $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('preview_page'); Context::set('layout', 'none'); @@ -107,7 +107,7 @@ class DocumentView extends Document // Set target module info $target_mid = Context::getRequestVars()->mid ?? ''; $module_srl = intval(Context::get('module_srl')); - + // if target mid is provided if($target_mid && $target_mid === Context::get('mid')) { @@ -134,7 +134,7 @@ class DocumentView extends Document $module_info = ModuleModel::getModuleInfoByModuleSrl($module_srl); $module_srl = $module_info ? $module_info->module_srl : 0; } - + Context::set('module_srl', $module_srl); Context::set('mid', $module_info ? $module_info->mid : ''); Context::set('browser_title', $module_info ? $module_info->browser_title : ''); diff --git a/modules/file/file.admin.controller.php b/modules/file/file.admin.controller.php index 35e27367c..1b290e10e 100644 --- a/modules/file/file.admin.controller.php +++ b/modules/file/file.admin.controller.php @@ -47,9 +47,9 @@ class FileAdminController extends File $oFileController->deleteFile($file_srl); } - + $this->setMessage(sprintf(lang('msg_checked_file_is_deleted'), $file_count)); - + $redirect_url = $_SERVER['HTTP_REFERER'] ?? ''; if (!$redirect_url || !Rhymix\Framework\URL::isInternalURL($redirect_url)) { @@ -94,7 +94,7 @@ class FileAdminController extends File $config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg'; $config->ffprobe_command = escape(utf8_trim(Context::get('ffprobe_command'))) ?: '/usr/bin/ffprobe'; } - + // Check maximum file size if (PHP_INT_SIZE < 8) { @@ -103,7 +103,7 @@ class FileAdminController extends File throw new Rhymix\Framework\Exception('msg_32bit_max_2047mb'); } } - + // Simplify allowed_filetypes $config->allowed_extensions = strtr(strtolower(trim($config->allowed_filetypes)), array('*.' => '', ';' => ',')); if ($config->allowed_extensions) @@ -120,7 +120,7 @@ class FileAdminController extends File $config->allowed_extensions = array(); $config->allowed_filetypes = '*.*'; } - + // Save and redirect $output = getController('module')->insertModuleConfig('file', $config); $returnUrl = Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminUploadConfig'); @@ -142,7 +142,7 @@ class FileAdminController extends File $config->allow_multimedia_direct_download = Context::get('allow_multimedia_direct_download') === 'Y' ? 'Y' : 'N'; $config->download_short_url = Context::get('download_short_url') === 'Y' ? 'Y' : 'N'; $config->inline_download_format = array_map('utf8_trim', Context::get('inline_download_format') ?: []); - + // Save and redirect $output = getController('module')->insertModuleConfig('file', $config); $returnUrl = Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminDownloadConfig'); @@ -159,7 +159,7 @@ class FileAdminController extends File // Update configuration $config = getModel('module')->getModuleConfig('file') ?: new stdClass; $config->save_changelog = Context::get('save_changelog') === 'Y' ? 'Y' : 'N'; - + // Save and redirect $output = getController('module')->insertModuleConfig('file', $config); $returnUrl = Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminOtherConfig'); @@ -174,7 +174,7 @@ class FileAdminController extends File function procFileAdminInsertModuleConfig() { $config = new stdClass; - + // Default if(!Context::get('use_default_file_config')) { @@ -182,7 +182,7 @@ class FileAdminController extends File $config->allowed_filesize = Context::get('allowed_filesize'); $config->allowed_attach_size = Context::get('allowed_attach_size'); $config->allowed_filetypes = Context::get('allowed_filetypes'); - + // Check maximum file size if (PHP_INT_SIZE < 8) { @@ -191,7 +191,7 @@ class FileAdminController extends File throw new Rhymix\Framework\Exception('msg_32bit_max_2047mb'); } } - + // Simplify allowed_filetypes $config->allowed_extensions = strtr(strtolower(trim($config->allowed_filetypes)), array('*.' => '', ';' => ',')); if ($config->allowed_extensions) @@ -209,7 +209,7 @@ class FileAdminController extends File $config->allowed_filetypes = '*.*'; } } - + // Image if(!Context::get('use_image_default_file_config')) { @@ -227,7 +227,7 @@ class FileAdminController extends File $config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false; $config->image_remove_exif_data = Context::get('image_remove_exif_data') === 'Y' ? true : false; } - + // Video if(!Context::get('use_video_default_file_config')) { @@ -235,11 +235,11 @@ class FileAdminController extends File $config->video_thumbnail = Context::get('video_thumbnail') === 'Y' ? true : false; $config->video_mp4_gif_time = intval(Context::get('video_mp4_gif_time')); } - + // Set download groups $download_grant = Context::get('download_grant'); $config->download_grant = is_array($download_grant) ? array_values($download_grant) : array($download_grant); - + // Update $oModuleController = getController('module'); foreach(explode(',', Context::get('target_module_srl')) as $module_srl) @@ -250,7 +250,7 @@ class FileAdminController extends File return $output; } } - + $this->setError(-1); $this->setMessage('success_updated', 'info'); $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent')); diff --git a/modules/file/file.admin.model.php b/modules/file/file.admin.model.php index 1f724979b..a33989d58 100644 --- a/modules/file/file.admin.model.php +++ b/modules/file/file.admin.model.php @@ -55,7 +55,7 @@ class FileAdminModel extends File * - isvaild * - regdate * - ipaddress - * + * * * * @param object $obj Search options @@ -72,13 +72,13 @@ class FileAdminModel extends File { $args->isvalid = $obj->isvalid; } - + // Set multimedia/common file if(isset($obj->direct_download) && in_array($obj->direct_download, ['Y', 'N'])) { $args->direct_download = $obj->direct_download; } - + // Set variables $args->sort_index = $obj->sort_index ?? null; $args->order_type = $obj->order_type ?? 'desc'; @@ -97,7 +97,7 @@ class FileAdminModel extends File { $output = executeQueryArray('file.getFileList', $args, $columnList); } - + // Return if no result or an error occurs if(!$output->toBool() || !count($output->data)) { diff --git a/modules/file/file.admin.view.php b/modules/file/file.admin.view.php index 9fdc63497..8d133297f 100644 --- a/modules/file/file.admin.view.php +++ b/modules/file/file.admin.view.php @@ -34,7 +34,7 @@ class FileAdminView extends File // Get a list $oFileAdminModel = getAdminModel('file'); $output = $oFileAdminModel->getFileList($args); - + // Get the document for looping a list if($output->data) { @@ -60,7 +60,7 @@ class FileAdminView extends File // Find and update if upload_target_type doesn't exist if(!$file->upload_target_type) { - // Pass if upload_target_type is already found + // Pass if upload_target_type is already found if(isset($document_list[$target_srl])) { $file->upload_target_type = 'doc'; @@ -223,7 +223,7 @@ class FileAdminView extends File $config = $oFileModel->getFileConfig(); Context::set('config', $config); Context::set('is_ffmpeg', function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command)); - + // Set a template file $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('upload_config'); @@ -239,7 +239,7 @@ class FileAdminView extends File $oFileModel = getModel('file'); $config = $oFileModel->getFileConfig(); Context::set('config',$config); - + // Set a template file $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('download_config'); @@ -255,7 +255,7 @@ class FileAdminView extends File $oFileModel = getModel('file'); $config = $oFileModel->getFileConfig(); Context::set('config',$config); - + // Set a template file $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('other_config'); diff --git a/modules/file/file.class.php b/modules/file/file.class.php index c8f9e7796..9674137f3 100644 --- a/modules/file/file.class.php +++ b/modules/file/file.class.php @@ -15,11 +15,11 @@ class File extends ModuleObject { // Register action forward (to use in administrator mode) $oModuleController = getController('module'); - + // Generate a directory for the file module FileHandler::makeDir('./files/attach/images'); FileHandler::makeDir('./files/attach/binaries'); - + // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after'); $oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after'); @@ -45,12 +45,12 @@ class File extends ModuleObject if($oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true; if($oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before')) return true; if($oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true; - + if($oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true; if($oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true; if($oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true; if($oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true; - + // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after')) return true; if(!$oModuleModel->getTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after')) return true; @@ -63,11 +63,11 @@ class File extends ModuleObject // A column to determine a target type if(!$oDB->isColumnExists('files', 'upload_target_type')) return true; - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) return true; if(!$oDB->isColumnExists('files', 'cover_image')) return true; - + if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after')) { return true; @@ -165,7 +165,7 @@ class File extends ModuleObject { $oModuleController->deleteTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after'); } - + // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after')) $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after'); @@ -184,14 +184,14 @@ class File extends ModuleObject // A column to determine a target type if(!$oDB->isColumnExists('files', 'upload_target_type')) $oDB->addColumn('files', 'upload_target_type', 'char', '3'); - // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied + // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) { $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after'); } if(!$oDB->isColumnExists('files', 'cover_image')) $oDB->addColumn('files', 'cover_image', 'char', '1', 'N'); - + if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after')) { $oModuleController->insertTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after'); diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index b89d16cf6..26bf3ed29 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -34,13 +34,13 @@ class FileController extends File // Basic variables setting $editor_sequence = Context::get('editor_sequence'); $module_srl = $this->module_srl; - + // Exit a session if there is neither upload permission nor information if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // Get upload_target_srl $upload_target_srl = intval(Context::get('uploadTargetSrl')) ?: intval(Context::get('upload_target_srl')); if (!$upload_target_srl) @@ -52,7 +52,7 @@ class FileController extends File $upload_target_srl = getNextSequence(); $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl; } - + // Handle chunking if (preg_match('!^bytes (\d+)-(\d+)/(\d+)$!', $_SERVER['HTTP_CONTENT_RANGE'], $matches)) { @@ -66,7 +66,7 @@ class FileController extends File } $this->add('chunk_current_size', $chunk_size); $this->add('chunk_uploaded_size', $chunk_start); - + // Check existing chunks $temp_key = hash_hmac('sha1', sprintf('%d:%d:%d:%s:%s', $editor_sequence, $upload_target_srl, $module_srl, $file_info['name'], session_id()), config('crypto.authentication_key')); $temp_filename = RX_BASEDIR . 'files/attach/chunks/' . $temp_key; @@ -82,7 +82,7 @@ class FileController extends File $this->add('chunk_status', 12); throw new Rhymix\Framework\Exception('msg_upload_invalid_chunk'); } - + // Check size limit $is_admin = (Context::get('logged_info')->is_admin === 'Y'); if (!$is_admin) @@ -102,7 +102,7 @@ class FileController extends File throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } } - + // Append to chunk $fp = fopen($file_info['tmp_name'], 'r'); $success = Rhymix\Framework\Storage::write($temp_filename, $fp, 'a'); @@ -135,14 +135,14 @@ class FileController extends File { $this->add('chunk_status', -1); } - + // Save the file $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); if($output->error != '0') { throw new Rhymix\Framework\Exception($output->message); } - + // Create the response Context::setResponseMethod('JSON'); $this->add('file_srl', $output->get('file_srl')); @@ -303,7 +303,7 @@ class FileController extends File { throw new Rhymix\Framework\Exceptions\TargetNotFound('msg_file_not_found'); } - + // Not allow the file outlink $file_module_config = FileModel::getFileConfig($file_obj->module_srl); if($file_module_config->allow_outlink == 'N' && $_SERVER["HTTP_REFERER"]) @@ -355,13 +355,13 @@ class FileController extends File throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_allowed_outlink'); } } - + // Check if the file is downloadable if(!FileModel::isDownloadable($file_obj)) { throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); } - + // Call a trigger (before) $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); if(!$output->toBool()) @@ -389,7 +389,7 @@ class FileController extends File $file_key_data = sprintf('%d:%d:%s:%s', $file_obj->file_srl, $file_key_timestamp, $file_obj->uploaded_filename, \RX_CLIENT_IP); $file_key_sig = \Rhymix\Framework\Security::createSignature($file_key_data); $file_key = dechex($file_key_timestamp) . $file_key_sig; - + // Use short URL or long URL if ($file_module_config->download_short_url === 'Y' && config('use_rewrite')) { @@ -399,7 +399,7 @@ class FileController extends File { $url = getNotEncodedUrl('', 'module', 'file', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key, 'force_download', Context::get('force_download') === 'Y' ? 'Y' : null); } - + header('X-Robots-Tag: noindex'); header('Location: ' . $url); Context::close(); @@ -412,7 +412,7 @@ class FileController extends File $file_srl = Context::get('file_srl'); $file_key = Context::get('file_key'); $filename_arg = Context::get('filename'); - + $columnList = array('source_filename', 'uploaded_filename', 'file_size'); $file_obj = FileModel::getFile($file_srl, $columnList); $file_config = FileModel::getFileConfig($file_obj->module_srl ?: null); @@ -435,13 +435,13 @@ class FileController extends File { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - + // Check filename if given if ($filename_arg !== null && $filename_arg !== $filename) { throw new Rhymix\Framework\Exceptions\TargetNotFound('msg_file_not_found'); } - + // Check if file exists $uploaded_filename = $file_obj->uploaded_filename; if(!file_exists($uploaded_filename)) @@ -453,7 +453,7 @@ class FileController extends File if(isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim(trim($_SERVER['HTTP_IF_NONE_MATCH']), '\'"') === $etag) { header('HTTP/1.1 304 Not Modified'); - exit(); + exit(); } // If client sent an If-Modified-Since header with a recent modification date, do not download again @@ -532,19 +532,19 @@ class FileController extends File { $download_type = 'attachment'; } - + // Clear buffer while(ob_get_level()) ob_end_clean(); - + // Set filename headers header('Content-Type: ' . $mime_type); header('Content-Disposition: ' . $download_type . $filename_param); - + // Set cache headers header('Cache-Control: private; max-age=3600'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Pragma: '); - + // Set other headers header('Content-Length: ' . $range_length); header('Accept-Ranges: bytes'); @@ -610,13 +610,13 @@ class FileController extends File { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $logged_info = Context::get('logged_info'); if($logged_info->is_admin !== 'Y' && !ModuleModel::isSiteAdmin($logged_info)) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + $fileSrls = Context::get('file_srls'); if($fileSrls) $fileSrlList = explode(',', $fileSrls); @@ -692,7 +692,7 @@ class FileController extends File { $module_srl = $obj->module_srl; if(!$module_srl) return; - + return $this->deleteModuleFiles($module_srl); } @@ -723,7 +723,7 @@ class FileController extends File } $_SESSION['upload_info'][$editor_sequence]->enabled = true; $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl; - + return $editor_sequence; } @@ -788,13 +788,13 @@ class FileController extends File $trigger_obj->upload_target_srl = $upload_target_srl; $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); if(!$output->toBool()) return $output; - + // A workaround for Firefox upload bug if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) { $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); } - + // Set base information $file_info['name'] = Rhymix\Framework\Filters\FilenameFilter::clean($file_info['name']); $file_info['type'] = $file_info['original_type'] = Rhymix\Framework\MIME::getContentType($file_info['tmp_name']); @@ -804,7 +804,7 @@ class FileController extends File $file_info['duration'] = null; $file_info['thumbnail'] = null; $file_info['converted'] = false; - + // Correct extension if($file_info['extension']) { @@ -818,10 +818,10 @@ class FileController extends File } } } - + // Get file module configuration $config = FileModel::getFileConfig($module_srl); - + // Check file extension if(!$manual_insert && !$this->user->isAdmin()) { @@ -830,7 +830,7 @@ class FileController extends File throw new Rhymix\Framework\Exception('msg_not_allowed_filetype'); } } - + // Adjust if(!$manual_insert) { @@ -839,14 +839,14 @@ class FileController extends File { $file_info = $this->adjustUploadedImage($file_info, $config); } - + // video if(in_array($file_info['extension'], ['mp4', 'webm', 'ogv'])) { $file_info = $this->adjustUploadedVideo($file_info, $config); } } - + // Check file size if(!$manual_insert && !$this->user->isAdmin()) { @@ -857,7 +857,7 @@ class FileController extends File { throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } - + $size_args = new stdClass; $size_args->upload_target_srl = $upload_target_srl; $output = executeQuery('file.getAttachedFileSize', $size_args); @@ -866,7 +866,7 @@ class FileController extends File throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } } - + $args = new stdClass; $args->file_srl = getNextSequence(); $args->regdate = date('YmdHis'); @@ -880,20 +880,20 @@ class FileController extends File $args->width = $file_info['width']; $args->height = $file_info['height']; $args->duration = $file_info['duration']; - + // Set original type $args->original_type = null; if($file_info['type'] !== $file_info['original_type']) { $args->original_type = $file_info['original_type']; } - + // Add changed extension if($file_info['extension'] && $file_info['extension'] !== $file_info['original_extension']) { $args->source_filename .= '.' . $file_info['extension']; } - + // Set storage path by checking if the attachement is an image or other kinds of file if($direct = Rhymix\Framework\Filters\FilenameFilter::isDirectDownload($args->source_filename)) { @@ -903,7 +903,7 @@ class FileController extends File { $storage_path = $this->getStoragePath('binaries', $args->file_srl, $module_srl, $upload_target_srl, $args->regdate); } - + if($config->allow_multimedia_direct_download !== 'N') { $args->direct_download = $direct ? 'Y' : 'N'; @@ -912,13 +912,13 @@ class FileController extends File { $args->direct_download = Rhymix\Framework\Filters\FilenameFilter::isDirectDownload($args->source_filename, false) ? 'Y' : 'N'; } - + // Create a directory if(!Rhymix\Framework\Storage::isDirectory($storage_path) && !Rhymix\Framework\Storage::createDirectory($storage_path)) { throw new Rhymix\Framework\Exception('msg_not_permitted_create'); } - + // Set move type and uploaded filename $move_type = $manual_insert ? 'copy' : ''; if($file_info['converted'] || starts_with(RX_BASEDIR . 'files/attach/chunks/', $file_info['tmp_name'])) @@ -931,7 +931,7 @@ class FileController extends File { $uploaded_filename = $storage_path . Rhymix\Framework\Security::getRandom(32, 'hex') . $extension; } - + // Move the uploaded file if(!Rhymix\Framework\Storage::moveUploadedFile($file_info['tmp_name'], $uploaded_filename, $move_type)) { @@ -939,7 +939,7 @@ class FileController extends File } $args->uploaded_filename = './' . substr($uploaded_filename, strlen(RX_BASEDIR)); $args->file_size = @filesize($uploaded_filename); - + // Move the generated thumbnail image if($file_info['thumbnail']) { @@ -953,10 +953,10 @@ class FileController extends File $args->thumbnail_filename = './' . substr($thumbnail_filename, strlen(RX_BASEDIR)); } } - + $oDB = DB::getInstance(); $oDB->begin(); - + // Insert file information $output = executeQuery('file.insertFile', $args); if(!$output->toBool()) @@ -965,7 +965,7 @@ class FileController extends File $this->deleteFile(array($args)); return $output; } - + // Insert changelog if($config->save_changelog === 'Y') { @@ -983,14 +983,14 @@ class FileController extends File return $output; } } - + $oDB->commit(); - + // Call a trigger (after) ModuleHandler::triggerCall('file.insertFile', 'after', $args); - + $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; - + $output->add('file_srl', $args->file_srl); $output->add('file_size', $args->file_size); $output->add('sid', $args->sid); @@ -1000,10 +1000,10 @@ class FileController extends File $output->add('uploaded_filename', $args->uploaded_filename); $output->add('thumbnail_filename', $args->thumbnail_filename); $output->add('original_type', $args->original_type); - + return $output; } - + /** * Adjust uploaded image */ @@ -1014,11 +1014,11 @@ class FileController extends File { return $file_info; } - + // Set image size $file_info['width'] = $image_info['width']; $file_info['height'] = $image_info['height']; - + // Set base information $force = false; $adjusted = [ @@ -1029,7 +1029,7 @@ class FileController extends File 'rotate' => 0, ]; $is_animated = Rhymix\Framework\Image::isAnimatedGIF($file_info['tmp_name']); - + // Adjust image type if ($config->image_autoconv['gif2mp4'] && $is_animated && function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command)) { @@ -1047,7 +1047,7 @@ class FileController extends File { $adjusted['type'] = 'jpg'; } - + // Adjust image rotation if ($config->image_autorotate && $image_info['type'] === 'jpg') { @@ -1062,7 +1062,7 @@ class FileController extends File $adjusted['rotate'] = $rotate; } } - + // Adjust image size if ($config->max_image_size_action && ($config->max_image_width || $config->max_image_height) && (!$this->user->isAdmin() || $config->max_image_size_admin === 'Y')) { @@ -1081,7 +1081,7 @@ class FileController extends File $resize_height = $config->max_image_height; $exceeded++; } - + if ($exceeded) { // Block upload @@ -1101,7 +1101,7 @@ class FileController extends File } throw new Rhymix\Framework\Exception($message); } - + $adjusted['width'] = (int)$resize_width; $adjusted['height'] = (int)$resize_height; if (!$is_animated && $adjusted['type'] === $image_info['type'] && $config->max_image_size_same_format !== 'Y') @@ -1110,7 +1110,7 @@ class FileController extends File } } } - + // Set force for remove EXIF data if($config->image_remove_exif_data && $image_info['type'] === 'jpg' && function_exists('exif_read_data')) { @@ -1123,7 +1123,7 @@ class FileController extends File $force = true; } } - + // Convert image if adjusted if ( $force || @@ -1134,13 +1134,13 @@ class FileController extends File ) { $output_name = $file_info['tmp_name'] . '.converted.' . $adjusted['type']; - + // Generate an output file if ($adjusted['type'] === 'mp4') { $adjusted['width'] -= $adjusted['width'] % 2; $adjusted['height'] -= $adjusted['height'] % 2; - + // Convert using ffmpeg $command = \RX_WINDOWS ? escapeshellarg($config->ffmpeg_command) : $config->ffmpeg_command; $command .= ' -nostdin -i ' . escapeshellarg($file_info['tmp_name']); @@ -1149,7 +1149,7 @@ class FileController extends File $command .= ' ' . escapeshellarg($output_name); @exec($command, $output, $return_var); $result = $return_var === 0 ? true : false; - + // Generate a thumbnail image if ($result) { @@ -1164,7 +1164,7 @@ class FileController extends File { $result = FileHandler::createImageFile($file_info['tmp_name'], $output_name, $adjusted['width'], $adjusted['height'], $adjusted['type'], 'fill', $adjusted['quality'], $adjusted['rotate']); } - + // Change to information in the output file if ($result) { @@ -1177,10 +1177,10 @@ class FileController extends File $file_info['converted'] = true; } } - + return $file_info; } - + /** * Adjust uploaded video */ @@ -1190,7 +1190,7 @@ class FileController extends File { return $file_info; } - + // Analyze video file $command = \RX_WINDOWS ? escapeshellarg($config->ffprobe_command) : $config->ffprobe_command; $command .= ' -v quiet -print_format json -show_streams'; @@ -1200,7 +1200,7 @@ class FileController extends File { return $file_info; } - + // Get stream information $stream_info = []; foreach ($output['streams'] as $info) @@ -1211,12 +1211,12 @@ class FileController extends File { return $file_info; } - + // Set video size $file_info['width'] = (int)$stream_info['video']['width']; $file_info['height'] = (int)$stream_info['video']['height']; $file_info['duration'] = (int)$stream_info['video']['duration']; - + // MP4 if ($file_info['extension'] === 'mp4') { @@ -1226,7 +1226,7 @@ class FileController extends File $file_info['original_type'] = 'image/gif'; } } - + // Generate a thumbnail image if ($config->video_thumbnail) { @@ -1240,10 +1240,10 @@ class FileController extends File $file_info['thumbnail'] = $thumbnail_name; } } - + return $file_info; } - + /** * Delete the attachment * @@ -1277,16 +1277,16 @@ class FileController extends File { $file_list = explode(',', $file_list); } - + if(empty($file_list)) { return new BaseObject(); } - + $config = FileModel::getFileConfig(); $oDB = DB::getInstance(); $oDB->begin(); - + foreach($file_list as $file) { if(!is_object($file)) @@ -1297,16 +1297,16 @@ class FileController extends File } $file = FileModel::getFile($file_srl); } - + if(empty($file->file_srl)) { continue; } - + // Call a trigger (before) $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $file); if(!$output->toBool()) return $output; - + // Remove from the DB $output = executeQuery('file.deleteFile', $file); if(!$output->toBool()) @@ -1314,7 +1314,7 @@ class FileController extends File $oDB->rollback(); return $output; } - + if($config->save_changelog === 'Y') { $clargs = new stdClass; @@ -1329,16 +1329,16 @@ class FileController extends File return $output; } } - + // If successfully deleted, remove the file Rhymix\Framework\Storage::delete(FileHandler::getRealPath($file->uploaded_filename)); - + // Call a trigger (after) ModuleHandler::triggerCall('file.deleteFile', 'after', $file); - + // Remove empty directories Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->uploaded_filename)), true); - + // Remove thumbnail if ($file->thumbnail_filename) { @@ -1346,11 +1346,11 @@ class FileController extends File Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->thumbnail_filename)), true); } } - + $oDB->commit(); return new BaseObject(); } - + /** * Delete all attachments of a particular document * @@ -1361,17 +1361,17 @@ class FileController extends File { // Get a list of attachements $file_list = FileModel::getFiles($upload_target_srl); - + // Success returned if no attachement exists if(empty($file_list)) { return new BaseObject(); } - + // Delete the file return $this->deleteFile($file_list); } - + /** * Delete the attachment of a particular module * @@ -1388,11 +1388,11 @@ class FileController extends File { return $output; } - + // Delete the file return $this->deleteFile($file_list); } - + /** * Move an attachement to the other document * @@ -1413,11 +1413,11 @@ class FileController extends File $config = FileModel::getFileConfig($module_srl); $oDB = DB::getInstance(); $oDB->begin(); - + foreach($file_list as $i => $file_info) { $old_file = $file_info->uploaded_filename; - + // Determine the file path by checking if the file is an image or other kinds if (Rhymix\Framework\Filters\FilenameFilter::isDirectDownload($file_info->source_filename)) { @@ -1432,19 +1432,19 @@ class FileController extends File $random_filename = basename($file_info->uploaded_filename) ?: Rhymix\Framework\Security::getRandom(32, 'hex'); $new_file = $path . $random_filename; } - + // Pass if a target document to move is same if($old_file === $new_file) continue; - + // Create a directory FileHandler::makeDir($path); - + // Move the file FileHandler::rename($old_file, $new_file); - + // Delete old path Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($old_file)), true); - + // Update DB information $args = new stdClass; $args->file_srl = $file_info->file_srl; @@ -1452,7 +1452,7 @@ class FileController extends File $args->module_srl = $file_info->module_srl; $args->upload_target_srl = $target_srl; $output = executeQuery('file.updateFile', $args); - + if($config->save_changelog === 'Y') { $clargs = new stdClass; @@ -1469,18 +1469,18 @@ class FileController extends File } } } - + $oDB->commit(); return new BaseObject(); } - + function copyFile($source_file, $module_srl, $upload_target_srl, &$content = null) { $file_info = array(); $file_info['name'] = $source_file->source_filename; $file_info['tmp_name'] = $source_file->uploaded_filename; $copied_file = $this->insertFile($file_info, $module_srl, $upload_target_srl, 0, true); - + if($content) { // if image/video files @@ -1497,23 +1497,23 @@ class FileController extends File $content = str_replace('sid=' . $source_file->sid, 'sid=' . $copied_file->get('sid'), $content); } } - + return $copied_file; } - + function copyFiles($source_file_list, $module_srl, $upload_target_srl, &$content = null) { if(!is_array($source_file_list)) { $source_file_list = FileModel::getFiles($source_file_list, array(), 'file_srl', true); } - + foreach($source_file_list as $source_file) { $this->copyFile($source_file, $module_srl, $upload_target_srl, $content); } } - + public function procFileSetCoverImage() { $vars = Context::getRequestVars(); @@ -1535,7 +1535,7 @@ class FileController extends File $oDB = &DB::getInstance(); $oDB->begin(); - + $args->cover_image = 'N'; $output = executeQuery('file.updateClearCoverImage', $args); if(!$output->toBool()) @@ -1565,10 +1565,10 @@ class FileController extends File $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3)); Filehandler::removeFilesInDir($thumbnail_path); } - + /** * Determine storage path based on file.folder_structure configuration. - * + * * @param string $file_type images or binary * @param int $file_srl * @param int $module_srl @@ -1584,13 +1584,13 @@ class FileController extends File $module_srl = intval($module_srl); $upload_target_srl = $upload_target_srl ?: $file_srl; $regdate = $regdate ?: date('YmdHis'); - + // 시스템 설정 참고 (기존 사용자는 1, 신규 설치시 2가 기본값임) $folder_structure = config('file.folder_structure'); - + // 기본 경로 지정 $prefix = $absolute_path ? \RX_BASEDIR : './'; - + // 2: 년월일 단위로 정리 if ($folder_structure == 2) { @@ -1603,7 +1603,7 @@ class FileController extends File return sprintf('%sfiles/attach/%s/%d/%s', $prefix, $file_type, $module_srl, $components); } } - + /** * Find the attachment where a key is upload_target_srl and then return java script code * @@ -1616,34 +1616,34 @@ class FileController extends File { return; } - + function triggerMoveDocument($obj) { $obj->upload_target_srls = $obj->document_srls; executeQuery('file.updateFileModule', $obj); executeQuery('file.updateFileModuleComment', $obj); } - + function triggerAddCopyDocument(&$obj) { if(!$obj->source->uploaded_count) { return; } - + $this->copyFiles($obj->source->document_srl, $obj->copied->module_srl, $obj->copied->document_srl, $obj->copied->content); } - + function triggerAddCopyCommentByDocument(&$obj) { if(!$obj->source->uploaded_count) { return; } - + $this->copyFiles($obj->source->comment_srl, $obj->copied->module_srl, $obj->copied->comment_srl, $obj->copied->content); } - + function triggerCopyModule(&$obj) { $fileConfig = ModuleModel::getModulePartConfig('file', $obj->originModuleSrl); diff --git a/modules/file/file.model.php b/modules/file/file.model.php index 9a5828e6e..2f1f95d00 100644 --- a/modules/file/file.model.php +++ b/modules/file/file.model.php @@ -32,12 +32,12 @@ class FileModel extends File { $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; } - + // Get uploaded files if($upload_target_srl) { $oDocument = DocumentModel::getDocument($upload_target_srl); - + // Check permissions of the comment if(!$oDocument->isExists()) { @@ -51,13 +51,13 @@ class FileModel extends File $oDocument = DocumentModel::getDocument($oComment->get('document_srl')); } } - + // Check permissions of the document if($oDocument->isExists() && !$oDocument->isAccessible()) { throw new Rhymix\Framework\Exceptions\NotPermitted; } - + // Check permissions of the module if($module_srl = isset($oComment) ? $oComment->get('module_srl') : $oDocument->get('module_srl')) { @@ -72,7 +72,7 @@ class FileModel extends File throw new Rhymix\Framework\Exceptions\NotPermitted; } } - + // Set file list foreach(self::getFiles($upload_target_srl) as $file_info) { @@ -94,18 +94,18 @@ class FileModel extends File { $obj->download_url = self::getDirectFileUrl($file_info->download_url); } - + $file_list[] = $obj; $attached_size += $file_info->file_size; } } - + // Set output $this->add('files', $file_list); $this->add('attached_size', FileHandler::filesize($attached_size)); $this->add('editor_sequence', $editor_sequence); $this->add('upload_target_srl', $upload_target_srl); - + // Set upload config $upload_config = self::getUploadConfig(); if($this->user->isAdmin()) @@ -120,13 +120,13 @@ class FileModel extends File $this->add('allowed_attach_size', FileHandler::filesize($upload_config->allowed_attach_size * 1024 * 1024)); $this->add('allowed_extensions', $upload_config->allowed_extensions); } - + // for compatibility $this->add('allowed_filetypes', $upload_config->allowed_filetypes); $this->add('upload_status', self::getUploadStatus($attached_size)); $this->add('left_size', $upload_config->allowed_attach_size * 1024 * 1024 - $attached_size); } - + /** * Check if the file is downloadable * @@ -144,13 +144,13 @@ class FileModel extends File { return true; } - + // Check the validity if($file_info->isvalid !== 'Y') { return false; } - + // Check download groups $config = self::getFileConfig($file_info->module_srl); if($config->download_groups) @@ -177,10 +177,10 @@ class FileModel extends File return false; } } - + return true; } - + /** * Check if the file is deletable * @@ -202,7 +202,7 @@ class FileModel extends File { return true; } - + // Check permissions of the module $module_info = ModuleModel::getModuleInfoByModuleSrl($file_info->module_srl); if(empty($module_info->module_srl)) @@ -214,24 +214,24 @@ class FileModel extends File { return true; } - + // Check permissions of the document $oDocument = DocumentModel::getDocument($file_info->upload_target_srl); if($oDocument->isExists() && $oDocument->isGranted()) { return true; } - + // Check permissions of the comment $oComment = CommentModel::getComment($file_info->upload_target_srl); if($oComment->isExists() && $oComment->isGranted()) { return true; } - + return false; } - + /** * Return number of attachments which belongs to a specific document * @@ -266,7 +266,7 @@ class FileModel extends File return sprintf('index.php?module=%s&act=%s&file_srl=%s&sid=%s', 'file', 'procFileDownload', $file_srl, $sid); } } - + /** * Return direct download file url * @@ -277,7 +277,7 @@ class FileModel extends File { return \RX_BASEURL . ltrim($path, './'); } - + /** * Get file configurations * @@ -296,7 +296,7 @@ class FileModel extends File $config->$key = $value; } } - + // Default setting if not exists $config->allowed_filesize = $config->allowed_filesize ?? '2'; $config->allowed_attach_size = $config->allowed_attach_size ?? '3'; @@ -310,7 +310,7 @@ class FileModel extends File $config->video_mp4_gif_time = $config->video_mp4_gif_time ?? 0; $config->ffmpeg_command = $config->ffmpeg_command ?? '/usr/bin/ffmpeg'; $config->ffprobe_command = $config->ffprobe_command ?? '/usr/bin/ffprobe'; - + // Set allowed_extensions if(!isset($config->allowed_extensions)) { @@ -323,10 +323,10 @@ class FileModel extends File }, explode(';', $config->allowed_filetypes)); } } - + // Set download_groups $config->download_groups = is_array($config->download_grant) ? array_filter($config->download_grant) : []; - + return $config; } @@ -388,7 +388,7 @@ class FileModel extends File { return array(); } - + $fileList = array(); foreach ($output->data as $file) { @@ -435,7 +435,7 @@ class FileModel extends File { $allowed_filesize = min($file_config->allowed_filesize * 1024 * 1024, FileHandler::returnBytes(ini_get('upload_max_filesize')), FileHandler::returnBytes(ini_get('post_max_size'))); } - + // Display upload status $upload_status = sprintf( '%s : %s/ %s
    %s : %s (%s : %s)', @@ -452,7 +452,7 @@ class FileModel extends File /** * method for compatibility - * + * * @deprecated */ public static function getFileModuleConfig($module_srl) @@ -462,7 +462,7 @@ class FileModel extends File /** * method for compatibility - * + * * @deprecated */ public static function getFileGrant($file_info, $member_info) diff --git a/modules/file/file.view.php b/modules/file/file.view.php index 44d69ecf9..8aeb3f296 100644 --- a/modules/file/file.view.php +++ b/modules/file/file.view.php @@ -33,16 +33,16 @@ class FileView extends File return; } } - + // Get file configurations of the module $config = FileModel::getFileConfig($current_module_srl); Context::set('config', $config); Context::set('is_ffmpeg', function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command)); - + // Get a permission for group setting $group_list = MemberModel::getGroups(); Context::set('group_list', $group_list); - + // Set a template file $oTemplate = TemplateHandler::getInstance(); $tpl = $oTemplate->compile($this->module_path . 'tpl', 'file_module_config');