mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Allow point reversion policies to be customized for each module
This commit is contained in:
parent
5f8586ec8f
commit
7a6400f39d
4 changed files with 43 additions and 13 deletions
|
|
@ -257,7 +257,7 @@ class PointAdminController extends Point
|
|||
}
|
||||
|
||||
$config = [];
|
||||
$keys = [
|
||||
$numeric_keys = [
|
||||
'insert_document',
|
||||
'insert_comment',
|
||||
'upload_file',
|
||||
|
|
@ -274,8 +274,13 @@ class PointAdminController extends Point
|
|||
'voted_comment',
|
||||
'blamed_comment'
|
||||
];
|
||||
$boolean_keys = [
|
||||
'insert_document_revert_on_delete',
|
||||
'insert_comment_revert_on_delete',
|
||||
'upload_file_revert_on_delete'
|
||||
];
|
||||
|
||||
foreach ($keys as $key)
|
||||
foreach ($numeric_keys as $key)
|
||||
{
|
||||
$value = trim(Context::get($key) ?? '');
|
||||
if ($value !== '')
|
||||
|
|
@ -283,6 +288,14 @@ class PointAdminController extends Point
|
|||
$config[$key] = (int)$value;
|
||||
}
|
||||
}
|
||||
foreach ($boolean_keys as $key)
|
||||
{
|
||||
$value = trim(Context::get($key) ?? '');
|
||||
if ($value !== '')
|
||||
{
|
||||
$config[$key] = ($value === 'Y');
|
||||
}
|
||||
}
|
||||
|
||||
$oModuleController->insertModulePartConfig('point', $srl, $config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ class PointController extends Point
|
|||
}
|
||||
|
||||
// Return if disabled
|
||||
$config = $this->getConfig();
|
||||
if ($config->insert_document_revert_on_delete === false)
|
||||
$revert = PointModel::getModulePointConfig($module_srl, 'insert_document_revert_on_delete');
|
||||
if ($revert === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -319,8 +319,8 @@ class PointController extends Point
|
|||
}
|
||||
|
||||
// Return if disabled
|
||||
$config = $this->getConfig();
|
||||
if ($config->insert_comment_revert_on_delete === false)
|
||||
$revert = PointModel::getModulePointConfig($module_srl, 'insert_comment_revert_on_delete');
|
||||
if ($revert === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -333,6 +333,7 @@ class PointController extends Point
|
|||
}
|
||||
|
||||
// Abort if the document is older than a configured limit.
|
||||
$config = $this->getConfig();
|
||||
$time_limit = $config->insert_comment_limit ?: $config->no_point_date;
|
||||
if ($time_limit > 0 && ztime($oDocument->get('regdate')) < RX_TIME - ($time_limit * 86400))
|
||||
{
|
||||
|
|
@ -381,14 +382,12 @@ class PointController extends Point
|
|||
}
|
||||
|
||||
// Return if disabled
|
||||
$config = $this->getConfig();
|
||||
if ($config->upload_file_revert_on_delete === false)
|
||||
$revert = PointModel::getModulePointConfig($module_srl, 'upload_file_revert_on_delete');
|
||||
if ($revert === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the points of the member
|
||||
|
||||
// Subtract points for the file.
|
||||
$diff = PointModel::getModulePointConfig($module_srl, 'upload_file');
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ class PointModel extends Point
|
|||
*
|
||||
* @param int $module_srl
|
||||
* @param string $config_key
|
||||
* @return int
|
||||
* @return int|bool
|
||||
*/
|
||||
public static function getModulePointConfig($module_srl, $config_key)
|
||||
{
|
||||
|
|
@ -306,10 +306,10 @@ class PointModel extends Point
|
|||
else
|
||||
{
|
||||
$default_config = self::getConfig();
|
||||
$point = $default_config->{$config_key};
|
||||
$point = $default_config->{$config_key} ?? 0;
|
||||
}
|
||||
|
||||
return intval($point);
|
||||
return is_bool($point) ? $point : intval($point);
|
||||
}
|
||||
}
|
||||
/* End of file point.model.php */
|
||||
|
|
|
|||
|
|
@ -11,18 +11,36 @@
|
|||
<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'] ?? ''}" /> {$module_config['point_name']}
|
||||
{$lang->cmd_point_revert_on_delete}
|
||||
<select name="insert_document_revert_on_delete">
|
||||
<option value="" selected="selected"|cond="!isset($module_config['insert_document_revert_on_delete'])">{$lang->default_value}</option>
|
||||
<option value="Y" selected="selected"|cond="($module_config['insert_document_revert_on_delete'] ?? null) === true">{$lang->cmd_yes}</option>
|
||||
<option value="N" selected="selected"|cond="($module_config['insert_document_revert_on_delete'] ?? null) === false">{$lang->cmd_no}</option>
|
||||
</select>
|
||||
</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'] ?? ''}" /> {$module_config['point_name']}
|
||||
{$lang->cmd_point_revert_on_delete}
|
||||
<select name="insert_comment_revert_on_delete">
|
||||
<option value="" selected="selected"|cond="!isset($module_config['insert_comment_revert_on_delete'])">{$lang->default_value}</option>
|
||||
<option value="Y" selected="selected"|cond="($module_config['insert_comment_revert_on_delete'] ?? null) === true">{$lang->cmd_yes}</option>
|
||||
<option value="N" selected="selected"|cond="($module_config['insert_comment_revert_on_delete'] ?? null) === false">{$lang->cmd_no}</option>
|
||||
</select>
|
||||
</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'] ?? ''}" /> {$module_config['point_name']}
|
||||
{$lang->cmd_point_revert_on_delete}
|
||||
<select name="upload_file_revert_on_delete">
|
||||
<option value="" selected="selected"|cond="!isset($module_config['upload_file_revert_on_delete'])">{$lang->default_value}</option>
|
||||
<option value="Y" selected="selected"|cond="($module_config['upload_file_revert_on_delete'] ?? null) === true">{$lang->cmd_yes}</option>
|
||||
<option value="N" selected="selected"|cond="($module_config['upload_file_revert_on_delete'] ?? null) === false">{$lang->cmd_no}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue