From aa49a5fb42f994342ea335d2b418dca84299d1b5 Mon Sep 17 00:00:00 2001 From: KodeStar Date: Fri, 25 Nov 2022 23:21:45 +0000 Subject: [PATCH] Fixes #371 Tagged items when pinning/unpinning (#1036) --- app/Http/Controllers/ItemController.php | 57 ++++++++++++++----------- config/app.php | 2 +- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index c0d555b1..691bb9d9 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -106,12 +106,20 @@ class ItemController extends Controller $item->pinned = $new; $item->save(); if ($ajax) { - if (is_numeric($tag) && $tag > 0) { - $item = Item::whereId($tag)->first(); - $data['apps'] = $item->children()->pinned()->orderBy('order', 'asc')->get(); - } else { - $data['apps'] = Item::pinned()->orderBy('order', 'asc')->get(); + + $item = Item::whereId($tag)->first(); + + $data['apps'] = new \Illuminate\Database\Eloquent\Collection; + + if ((int)$tag === 0) { + $tags = Item::where('type', 1)->pinned()->orderBy('order', 'asc')->get(); + $data['apps'] = $data['apps']->merge($tags); } + + $apps = $item->children()->pinned()->orderBy('order', 'asc')->get(); + $data['apps'] = $data['apps']->merge($apps); + + $data['ajax'] = true; return view('sortable', $data); @@ -200,10 +208,10 @@ class ItemController extends Controller 'icon' => $path, ]); } elseif (strpos($request->input('icon'), 'http') === 0) { - $options=array( - "ssl"=>array( - "verify_peer"=>false, - "verify_peer_name"=>false, + $options = array( + "ssl" => array( + "verify_peer" => false, + "verify_peer_name" => false, ), ); $contents = file_get_contents($request->input('icon'), false, stream_context_create($options)); @@ -214,15 +222,15 @@ class ItemController extends Controller $file = $request->input('icon'); $path_parts = pathinfo($file); $icon = md5($contents); - $icon .= '.'.$path_parts['extension']; + $icon .= '.' . $path_parts['extension']; } - $path = 'icons/'.$icon; + $path = 'icons/' . $icon; // Private apps could have here duplicated icons folder if (strpos($path, 'icons/icons/') !== false) { $path = str_replace('icons/icons/', 'icons/', $path); } - if (! Storage::disk('public')->exists($path)) { + if (!Storage::disk('public')->exists($path)) { Storage::disk('public')->put($path, $contents); } $request->merge([ @@ -347,8 +355,8 @@ class ItemController extends Controller { // Item::withTrashed() - ->where('id', $id) - ->restore(); + ->where('id', $id) + ->restore(); $route = route('items.index', []); @@ -382,7 +390,7 @@ class ItemController extends Controller if ((bool) $app->enhanced === true) { // if(!isset($app->config)) { // class based config - $output['custom'] = className($appdetails->name).'.config'; + $output['custom'] = className($appdetails->name) . '.config'; // } } @@ -392,10 +400,10 @@ class ItemController extends Controller $output['iconview'] = $app->icon; } elseif (strpos($app->icon, 'icons/') !== false) { // Private apps have the icon locally - $output['iconview'] = URL::to('/').'/storage/'.$app->icon; + $output['iconview'] = URL::to('/') . '/storage/' . $app->icon; $output['icon'] = str_replace('icons/', '', $output['icon']); } else { - $output['iconview'] = config('app.appsource').'icons/'.$app->icon; + $output['iconview'] = config('app.appsource') . 'icons/' . $app->icon; } @@ -410,7 +418,8 @@ class ItemController extends Controller $app = $single->class; // If password is not resubmitted fill it from the database when in edit mode - if (array_key_exists('password', $data) && + if ( + array_key_exists('password', $data) && $data['password'] === null && array_key_exists('id', $data) ) { @@ -431,12 +440,12 @@ class ItemController extends Controller $res = null; $vars = ($overridevars !== false) ? - $overridevars : [ - 'http_errors' => false, - 'timeout' => 15, - 'connect_timeout' => 15, - 'verify' => false, - ]; + $overridevars : [ + 'http_errors' => false, + 'timeout' => 15, + 'connect_timeout' => 15, + 'verify' => false, + ]; $client = new Client($vars); diff --git a/config/app.php b/config/app.php index c292cf24..d9d2d25b 100644 --- a/config/app.php +++ b/config/app.php @@ -14,7 +14,7 @@ return [ */ 'name' => env('APP_NAME', 'Heimdall'), - 'version' => '2.5.2', + 'version' => '2.5.3', /* |--------------------------------------------------------------------------