mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
Fix setting existing texture to be private
This commit is contained in:
parent
8b002ab157
commit
98ff895d3b
@ -8,6 +8,8 @@ use Option;
|
||||
use Storage;
|
||||
use Session;
|
||||
use App\Models\User;
|
||||
use App\Models\Closet;
|
||||
use App\Models\Player;
|
||||
use App\Models\Texture;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@ -205,6 +207,8 @@ class SkinlibController extends Controller
|
||||
public function privacy(Request $request)
|
||||
{
|
||||
$t = Texture::find($request->input('tid'));
|
||||
$type = $t->type;
|
||||
$uid = session('uid');
|
||||
|
||||
if (!$t)
|
||||
return json(trans('skinlib.non-existent'), 1);
|
||||
@ -212,6 +216,16 @@ class SkinlibController extends Controller
|
||||
if ($t->uploader != $this->user->uid && !$this->user->isAdmin())
|
||||
return json(trans('skinlib.no-permission'), 1);
|
||||
|
||||
foreach (Player::where("tid_$type", $t->tid)->where('uid', '<>', $uid)->get() as $player) {
|
||||
$player->setTexture(["tid_$type" => 0]);
|
||||
}
|
||||
|
||||
foreach (Closet::all() as $closet) {
|
||||
if ($closet->uid != $uid && $closet->has($t->tid)) {
|
||||
$closet->remove($t->tid);
|
||||
}
|
||||
}
|
||||
|
||||
if ($t->setPrivacy(!$t->public)) {
|
||||
return json([
|
||||
'errno' => 0,
|
||||
|
@ -238,4 +238,18 @@ class Closet
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all closets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
$result = [];
|
||||
foreach (DB::table('closets')->lists('uid') as $uid) {
|
||||
$result[] = new Closet($uid);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user