Fix empty values being set to 0 when module point config is modified

This commit is contained in:
Kijin Sung 2025-09-04 21:31:09 +09:00
parent 4a84f52edb
commit 5f8586ec8f
2 changed files with 64 additions and 38 deletions

View file

@ -231,32 +231,59 @@ class PointAdminController extends Point
function procPointAdminInsertPointModuleConfig()
{
$module_srl = Context::get('target_module_srl');
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
if (!$module_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
// In case of batch configuration of several modules
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
else $module_srl = array($module_srl);
if (preg_match('/^([0-9,]+)$/',$module_srl))
{
$module_srl = explode(',',$module_srl);
}
else
{
$module_srl = array($module_srl);
}
// Save configurations
$oModuleController = getController('module');
for($i=0;$i<count($module_srl);$i++)
{
$srl = trim($module_srl[$i]);
if(!$srl) continue;
unset($config);
$config['insert_document'] = (int)Context::get('insert_document');
$config['insert_comment'] = (int)Context::get('insert_comment');
$config['upload_file'] = (int)Context::get('upload_file');
$config['download_file'] = (int)Context::get('download_file');
$config['read_document'] = (int)Context::get('read_document');
$config['voter'] = (int)Context::get('voter');
$config['blamer'] = (int)Context::get('blamer');
$config['voter_comment'] = (int)Context::get('voter_comment');
$config['blamer_comment'] = (int)Context::get('blamer_comment');
$config['download_file_author'] = (int)Context::get('download_file_author');
$config['read_document_author'] = (int)Context::get('read_document_author');
$config['voted'] = (int)Context::get('voted');
$config['blamed'] = (int)Context::get('blamed');
$config['voted_comment'] = (int)Context::get('voted_comment');
$config['blamed_comment'] = (int)Context::get('blamed_comment');
$srl = trim($module_srl[$i] ?? '');
if (!$srl)
{
continue;
}
$config = [];
$keys = [
'insert_document',
'insert_comment',
'upload_file',
'download_file',
'read_document',
'voter',
'blamer',
'voter_comment',
'blamer_comment',
'download_file_author',
'read_document_author',
'voted',
'blamed',
'voted_comment',
'blamed_comment'
];
foreach ($keys as $key)
{
$value = trim(Context::get($key) ?? '');
if ($value !== '')
{
$config[$key] = (int)$value;
}
}
$oModuleController->insertModulePartConfig('point', $srl, $config);
}

View file

@ -1,101 +1,100 @@
<load target="js/point_admin.js" />
<section class="section">
<h1>{$lang->point}</h1>
<form action="./" method="post" id="fo_point" class="x_form-horizontal">
<input type="hidden" name="module" value="point" />
<input type="hidden" name="act" value="procPointAdminInsertPointModuleConfig" />
<input type="hidden" name="target_module_srl" value="{$module_config['module_srl']?$module_config['module_srl']:$module_srls}" />
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
<div class="x_control-group">
<label for="insert_document" class="x_control-label">{$lang->point_insert_document}</label>
<div class="x_controls">
<input type="number" name="insert_document" id="insert_document" value="{$module_config['insert_document'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="insert_document" id="insert_document" value="{$module_config['insert_document'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="insert_comment" class="x_control-label">{$lang->point_insert_comment}</label>
<div class="x_controls">
<input type="number" name="insert_comment" id="insert_comment" value="{$module_config['insert_comment'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="insert_comment" id="insert_comment" value="{$module_config['insert_comment'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="upload_file" class="x_control-label">{$lang->point_upload_file}</label>
<div class="x_controls">
<input type="number" name="upload_file" id="upload_file" value="{$module_config['upload_file'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="upload_file" id="upload_file" value="{$module_config['upload_file'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="download_file" class="x_control-label">{$lang->point_download_file}</label>
<div class="x_controls">
<input type="number" name="download_file" id="download_file" value="{$module_config['download_file'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="download_file" id="download_file" value="{$module_config['download_file'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="read_document" class="x_control-label">{$lang->point_read_document}</label>
<div class="x_controls">
<input type="number" name="read_document" id="read_document" value="{$module_config['read_document'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="read_document" id="read_document" value="{$module_config['read_document'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="voter" class="x_control-label">{$lang->point_voter}</label>
<div class="x_controls">
<input type="number" name="voter" id="voter" value="{$module_config['voter'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="voter" id="voter" value="{$module_config['voter'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="blamer" class="x_control-label">{$lang->point_blamer}</label>
<div class="x_controls">
<input type="number" name="blamer" id="blamer" value="{$module_config['blamer'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="blamer" id="blamer" value="{$module_config['blamer'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="voter_comment" class="x_control-label">{$lang->point_voter_comment}</label>
<div class="x_controls">
<input type="number" name="voter_comment" id="voter_comment" value="{$module_config['voter_comment'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="voter_comment" id="voter_comment" value="{$module_config['voter_comment'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="blamer_comment" class="x_control-label">{$lang->point_blamer_comment}</label>
<div class="x_controls">
<input type="number" name="blamer_comment" id="blamer_comment" value="{$module_config['blamer_comment'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="blamer_comment" id="blamer_comment" value="{$module_config['blamer_comment'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="download_file_author" class="x_control-label">{$lang->point_download_file_author}</label>
<div class="x_controls">
<input type="number" name="download_file_author" id="download_file_author" value="{$module_config['download_file_author'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="download_file_author" id="download_file_author" value="{$module_config['download_file_author'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="read_document_author" class="x_control-label">{$lang->point_read_document_author}</label>
<div class="x_controls">
<input type="number" name="read_document_author" id="read_document_author" value="{$module_config['read_document_author'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="read_document_author" id="read_document_author" value="{$module_config['read_document_author'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="voted" class="x_control-label">{$lang->point_voted}</label>
<div class="x_controls">
<input type="number" name="voted" id="voted" value="{$module_config['voted'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="voted" id="voted" value="{$module_config['voted'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="blamed" class="x_control-label">{$lang->point_blamed}</label>
<div class="x_controls">
<input type="number" name="blamed" id="blamed" value="{$module_config['blamed'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="blamed" id="blamed" value="{$module_config['blamed'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="voted_comment" class="x_control-label">{$lang->point_voted_comment}</label>
<div class="x_controls">
<input type="number" name="voted_comment" id="voted_comment" value="{$module_config['voted_comment'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="voted_comment" id="voted_comment" value="{$module_config['voted_comment'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_control-group">
<label for="blamed_comment" class="x_control-label">{$lang->point_blamed_comment}</label>
<div class="x_controls">
<input type="number" name="blamed_comment" id="blamed_comment" value="{$module_config['blamed_comment'] ?? null}" /> {$module_config['point_name']}
<input type="number" name="blamed_comment" id="blamed_comment" value="{$module_config['blamed_comment'] ?? ''}" /> {$module_config['point_name']}
</div>
</div>
<div class="x_clearfix btnArea">