Fixes #371 Tagged items when pinning/unpinning (#1036)

This commit is contained in:
KodeStar 2022-11-25 23:21:45 +00:00 committed by GitHub
parent 7565bd4028
commit aa49a5fb42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 25 deletions

View file

@ -106,12 +106,20 @@ class ItemController extends Controller
$item->pinned = $new; $item->pinned = $new;
$item->save(); $item->save();
if ($ajax) { if ($ajax) {
if (is_numeric($tag) && $tag > 0) {
$item = Item::whereId($tag)->first(); $item = Item::whereId($tag)->first();
$data['apps'] = $item->children()->pinned()->orderBy('order', 'asc')->get();
} else { $data['apps'] = new \Illuminate\Database\Eloquent\Collection;
$data['apps'] = Item::pinned()->orderBy('order', 'asc')->get();
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; $data['ajax'] = true;
return view('sortable', $data); return view('sortable', $data);
@ -200,10 +208,10 @@ class ItemController extends Controller
'icon' => $path, 'icon' => $path,
]); ]);
} elseif (strpos($request->input('icon'), 'http') === 0) { } elseif (strpos($request->input('icon'), 'http') === 0) {
$options=array( $options = array(
"ssl"=>array( "ssl" => array(
"verify_peer"=>false, "verify_peer" => false,
"verify_peer_name"=>false, "verify_peer_name" => false,
), ),
); );
$contents = file_get_contents($request->input('icon'), false, stream_context_create($options)); $contents = file_get_contents($request->input('icon'), false, stream_context_create($options));
@ -214,15 +222,15 @@ class ItemController extends Controller
$file = $request->input('icon'); $file = $request->input('icon');
$path_parts = pathinfo($file); $path_parts = pathinfo($file);
$icon = md5($contents); $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 // Private apps could have here duplicated icons folder
if (strpos($path, 'icons/icons/') !== false) { if (strpos($path, 'icons/icons/') !== false) {
$path = str_replace('icons/icons/', 'icons/', $path); $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); Storage::disk('public')->put($path, $contents);
} }
$request->merge([ $request->merge([
@ -382,7 +390,7 @@ class ItemController extends Controller
if ((bool) $app->enhanced === true) { if ((bool) $app->enhanced === true) {
// if(!isset($app->config)) { // class based config // 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; $output['iconview'] = $app->icon;
} elseif (strpos($app->icon, 'icons/') !== false) { } elseif (strpos($app->icon, 'icons/') !== false) {
// Private apps have the icon locally // 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']); $output['icon'] = str_replace('icons/', '', $output['icon']);
} else { } 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; $app = $single->class;
// If password is not resubmitted fill it from the database when in edit mode // 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 && $data['password'] === null &&
array_key_exists('id', $data) array_key_exists('id', $data)
) { ) {

View file

@ -14,7 +14,7 @@ return [
*/ */
'name' => env('APP_NAME', 'Heimdall'), 'name' => env('APP_NAME', 'Heimdall'),
'version' => '2.5.2', 'version' => '2.5.3',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------