issue 46 apply server side validator in file module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8503 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-06-17 01:22:41 +00:00
parent a64ab93dc1
commit 3216c884a1
6 changed files with 46 additions and 21 deletions

View file

@ -11,8 +11,8 @@
<action name="procFileImageResize" type="controller" standalone="true" />
<action name="procFileDelete" type="controller" standalone="true" />
<action name="procFileDownload" type="controller" standalone="true" />
<action name="procFileAdminDeleteChecked" type="controller" standalone="true" />
<action name="procFileAdminInsertConfig" type="controller" standalone="true" />
<action name="procFileAdminInsertModuleConfig" type="controller" standalone="true" />
<action name="procFileAdminDeleteChecked" type="controller" standalone="true" ruleset="deleteChecked" />
<action name="procFileAdminInsertConfig" type="controller" standalone="true" ruleset="insertConfig" />
<action name="procFileAdminInsertModuleConfig" type="controller" standalone="true" ruleset="fileModuleConfig" />
</actions>
</module>

View file

@ -53,7 +53,8 @@
// An error appears if no document is selected
$cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
$file_srl_list= explode('|@|', $cart);
if(!is_array($cart)) $file_srl_list= explode('|@|', $cart);
else $file_srl_list = $cart;
$file_count = count($file_srl_list);
if(!$file_count) return $this->stop('msg_cart_is_null');
@ -67,6 +68,11 @@
}
$this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) );
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList');
header('location:'.$returnUrl);
return;
}
}
/**
@ -76,13 +82,18 @@
// Get configurations (using module model object)
$config->allowed_filesize = Context::get('allowed_filesize');
$config->allowed_attach_size = Context::get('allowed_attach_size');
$config->allowed_filetypes = Context::get('allowed_filetypes');
$config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes'));
$config->allow_outlink = Context::get('allow_outlink');
$config->allow_outlink_format = Context::get('allow_outlink_format');
$config->allow_outlink_site = Context::get('allow_outlink_site');
// Create module Controller object
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('file',$config);
if($output->toBool() && !in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig');
header('location:'.$returnUrl);
return;
}
return $output;
}
@ -96,16 +107,17 @@
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
else $module_srl = array($module_srl);
$download_grant = trim(Context::get('download_grant'));
$download_grant = Context::get('download_grant');
$file_config->allow_outlink = Context::get('allow_outlink');
$file_config->allow_outlink_format = Context::get('allow_outlink_format');
$file_config->allow_outlink_site = Context::get('allow_outlink_site');
$file_config->allowed_filesize = Context::get('allowed_filesize');
$file_config->allowed_attach_size = Context::get('allowed_attach_size');
$file_config->allowed_filetypes = Context::get('allowed_filetypes');
if($download_grant) $file_config->download_grant = explode('|@|',$download_grant);
else $file_config->download_grant = array();
$file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes'));
if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant);
else $file_config->download_grant = $download_grant;
//관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas
$userFileAllowSize = $this->_changeBytes($file_config->allowed_filesize.'M');
@ -126,6 +138,11 @@
$this->setError(-1);
$this->setMessage('success_updated');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent');
header('location:'.$returnUrl);
return;
}
}
/**

View file

@ -129,10 +129,13 @@
$doc_srls_count = count($doc_srls);
if($doc_srls_count) {
$document_output = $oDocumentModel->getDocuments($doc_srls);
if(is_array($document_output))
{
foreach($document_output as $document) {
$document_list[$document->document_srl] = $document;
}
}
}
// Module List
$mod_srls_count = count($mod_srls);
if($mod_srls_count) {

View file

@ -1,7 +1,9 @@
<!--#include("header.html")-->
<!--%import("filter/insert_config.xml")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_config)">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="insertConfig" action="./" method="post">
<input type="hidden" name="act" value="procFileAdminInsertConfig" />
<table cellspacing="0" class="rowTable">
<tr class="row2">
<th scope="col"><div>{$lang->allow_outlink}</div></th>
@ -55,4 +57,4 @@
</th>
</tr>
</table>
</form>
</form>

View file

@ -1,10 +1,10 @@
<!--%import("filter/delete_checked.xml")-->
<!--%import("css/file_list.css")-->
<!--#include("header.html")-->
<!-- 검색 -->
<div class="fl">
<form action="./" method="get" class="adminSearch">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="deleteChecked" action="./" method="get" class="adminSearch">
<input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="{$act}" />
<input type="hidden" name="module_srl" value="{$module_srl}" />
@ -29,7 +29,9 @@
</form>
</div>
<form id="fo_list" action="./" method="get" onsubmit="return procFilter(this, delete_checked)">
<!--form id="fo_list" action="./" method="get" onsubmit="return procFilter(this, delete_checked)"-->
<form id="fo_list" action="./" method="post">
<input type="hidden" name="act" value="procFileAdminDeleteChecked" />
<input type="hidden" name="page" value="{$page}" />
<!-- 모듈 선택 -->
@ -91,7 +93,7 @@
<tr>
<td class="tCenter number">{$no}</td>
<td class="tCenter"><input type="checkbox" name="cart" value="{$val->file_srl}" /></td>
<td class="tCenter"><input type="checkbox" name="cart[]" value="{$val->file_srl}" /></td>
<td class="wide"><a href="{$val->download_url}" class="red">{htmlspecialchars($val->source_filename)}</a></td>
<td class="number tRight">{FileHandler::filesize($val->file_size)}</td>
<td class="tCenter">

View file

@ -1,5 +1,6 @@
<!--%import("filter/insert_file_module_config.xml")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_file_module_config)">
<form ruleset="fileModuleConfig" action="./" method="post">
<input type="hidden" name="act" value="procFileAdminInsertModuleConfig" />
<input type="hidden" name="success_return_url" value="{getUrl('', 'module', $module, 'act', $act, 'module_srl', $module_srl)}" />
<input type="hidden" name="target_module_srl" value="{$module_info->module_srl?$module_info->module_srl:$module_srls}" />
<h4 class="xeAdmin">{$lang->file}</h4>
@ -30,7 +31,7 @@
<th scope="col"><div>{$lang->enable_download_group}</div></th>
<td>
<!--@foreach($group_list as $k => $v)-->
<input type="checkbox" class="checkbox" name="download_grant" value="{$v->group_srl}" id="grant_{$key}_{$v->group_srl}" <!--@if(in_array($v->group_srl, $file_config->download_grant))-->checked="checked"<!--@end-->/>
<input type="checkbox" class="checkbox" name="download_grant[]" value="{$v->group_srl}" id="grant_{$key}_{$v->group_srl}" <!--@if(in_array($v->group_srl, $file_config->download_grant))-->checked="checked"<!--@end-->/>
<label for="grant_{$key}_{$v->group_srl}">{$v->title}</label>
&nbsp;
<!--@end-->