allow to re-upload textures which were setted to private

This commit is contained in:
printempw 2016-09-30 16:31:45 +08:00
parent ee4cbd2092
commit 975e34db95
2 changed files with 14 additions and 10 deletions

View File

@ -151,10 +151,10 @@ class SkinlibController extends Controller
if (!$results->isEmpty()) { if (!$results->isEmpty()) {
foreach ($results as $result) { foreach ($results as $result) {
if ($result->type == $t->type) { // if the texture already uploaded was setted to private,
return json([ // then allow to re-upload it.
'errno' => 0, if ($result->type == $t->type && $result->public == "1") {
'msg' => trans('skinlib.upload.repeated'), return json(trans('skinlib.upload.repeated'), 0, [
'tid' => $result->tid 'tid' => $result->tid
]); ]);
} }
@ -166,9 +166,7 @@ class SkinlibController extends Controller
$this->user->setScore($cost, 'minus'); $this->user->setScore($cost, 'minus');
if ($this->user->closet->add($t->tid, $t->name)) { if ($this->user->closet->add($t->tid, $t->name)) {
return json([ return json(trans('skinlib.upload.success', ['name' => $request->input('name')]), 0, [
'errno' => 0,
'msg' => trans('skinlib.upload.success', ['name' => $request->input('name')]),
'tid' => $t->tid 'tid' => $t->tid
]); ]);
} }

View File

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Arr;
if (! function_exists('get_real_ip')) { if (! function_exists('get_real_ip')) {
@ -70,15 +71,20 @@ if (! function_exists('json')) {
function json() function json()
{ {
@header('Content-type: application/json; charset=utf-8');
$args = func_get_args(); $args = func_get_args();
if (count($args) == 1 && is_array($args[0])) { if (count($args) == 1 && is_array($args[0])) {
return Response::json($args[0]); return Response::json($args[0]);
} elseif(count($args) == 2) { } elseif (count($args) == 3 && is_array($args[2])) {
return Response::json([ // the third argument is array of extra fields
return Response::json(array_merge([
'errno' => $args[1], 'errno' => $args[1],
'msg' => $args[0] 'msg' => $args[0]
], $args[2]));
} else {
return Response::json([
'errno' => Arr::get($args, 1, 1),
'msg' => $args[0]
]); ]);
} }
} }