mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-18 13:54:01 +08:00
add option for returning score when deleting textures
This commit is contained in:
parent
2ee71b6d98
commit
af48273465
@ -27,7 +27,30 @@ class AdminController extends Controller
|
||||
|
||||
public function score()
|
||||
{
|
||||
return view('admin.score');
|
||||
$rate = Option::form('rate', '积分换算', function($form)
|
||||
{
|
||||
$form->group('score_per_storage', '存储', function($group) {
|
||||
$group->text('score_per_storage');
|
||||
$group->addon('积分 = 1 KB');
|
||||
});
|
||||
|
||||
$form->group('private_score_per_storage', '私密材质存储', function($group) {
|
||||
$group->text('private_score_per_storage');
|
||||
$group->addon('积分 = 1 KB');
|
||||
})->hint('上传私密材质将消耗更多积分');
|
||||
|
||||
$form->checkbox('return_score', '积分返还', '用户删除角色/材质时返还积分');
|
||||
|
||||
$form->group('score_per_player', '角色', function($group) {
|
||||
$group->text('score_per_player');
|
||||
$group->addon('积分 = 一个角色');
|
||||
});
|
||||
|
||||
$form->text('user_initial_score', '新用户默认积分');
|
||||
|
||||
})->handle();
|
||||
|
||||
return view('admin.score', compact('rate'));
|
||||
}
|
||||
|
||||
public function options()
|
||||
|
@ -87,6 +87,8 @@ class PlayerController extends Controller
|
||||
Event::fire(new PlayerWillBeDeleted($this->player));
|
||||
|
||||
if ($this->player->delete()) {
|
||||
|
||||
if (option('return_score'))
|
||||
$this->user->setScore(Option::get('score_per_player'), 'plus');
|
||||
|
||||
Event::fire(new PlayerWasDeleted($player_name));
|
||||
|
@ -194,7 +194,9 @@ class SkinlibController extends Controller
|
||||
if (Texture::where('hash', $result['hash'])->count() == 1)
|
||||
Storage::delete($result['hash']);
|
||||
|
||||
if (option('return_score')) {
|
||||
$this->user->setScore($result->size * Option::get('score_per_storage'), 'plus');
|
||||
}
|
||||
|
||||
if ($result->delete())
|
||||
return json(trans('skinlib.delete.success'), 0);
|
||||
|
@ -114,7 +114,7 @@ class OptionForm
|
||||
if (Str::is('*[*]', $item->id))
|
||||
continue;
|
||||
|
||||
if ($_POST[$item->id] != option($item->id)) {
|
||||
if ($_POST[$item->id] != option($item->id, null, false)) {
|
||||
Option::set($item->id, $_POST[$item->id]);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ if (! function_exists('bs_nickname')) {
|
||||
|
||||
if (! function_exists('option')) {
|
||||
|
||||
function option($key = null, $default = null)
|
||||
function option($key = null, $default = null, $bool = true)
|
||||
{
|
||||
$options = app('options');
|
||||
|
||||
@ -210,7 +210,7 @@ if (! function_exists('option')) {
|
||||
return $options->save();
|
||||
}
|
||||
|
||||
return $options->get($key);
|
||||
return $options->get($key, $default, $bool);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-29 11:53:11
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-12-16 22:14:18
|
||||
* @Last Modified time: 2016-12-21 22:49:31
|
||||
*/
|
||||
|
||||
return [
|
||||
@ -25,6 +25,7 @@ return [
|
||||
'sign_score' => '10,100',
|
||||
'score_per_storage' => '1',
|
||||
'private_score_per_storage' => '10',
|
||||
'return_score' => '1',
|
||||
'score_per_player' => '100',
|
||||
'sign_after_zero' => '0',
|
||||
'version' => '',
|
||||
|
@ -18,71 +18,7 @@
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">积分换算</h3>
|
||||
</div><!-- /.box-header -->
|
||||
<form method="post">
|
||||
<input type="hidden" name="option" value="rate">
|
||||
<div class="box-body">
|
||||
<?php
|
||||
if (isset($_POST['option']) && ($_POST['option'] == "rate")) {
|
||||
foreach ($_POST as $key => $value) {
|
||||
if ($key != "option" && $key != "submit")
|
||||
Option::set($key, $value);
|
||||
}
|
||||
echo '<div class="callout callout-success">设置已保存。</div>';
|
||||
} ?>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key">存储</td>
|
||||
<td class="value">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="score_per_storage" value="{{ option('score_per_storage') }}">
|
||||
<span class="input-group-addon">积分 = 1 KB</span>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="key">私密材质存储
|
||||
<i class="fa fa-question-circle" title="上传私密材质将消耗更多积分" data-toggle="tooltip" data-placement="top"></i>
|
||||
</td>
|
||||
<td class="value">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="private_score_per_storage" value="{{ option('private_score_per_storage') }}">
|
||||
<span class="input-group-addon">积分 = 1 KB</span>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="key">角色</td>
|
||||
<td class="value">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="score_per_player" value="{{ option('score_per_player') }}">
|
||||
<span class="input-group-addon">积分 = 一个角色</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="key">新用户默认积分</td>
|
||||
<td class="value">
|
||||
<input type="text" class="form-control" name="user_initial_score" value="{{ option('user_initial_score') }}">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<button type="submit" name="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{!! $rate->render() !!}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
|
Loading…
Reference in New Issue
Block a user