Merge remote-tracking branch 'origin/master' into oasis

# Conflicts:
#	app/Http/helpers.php
This commit is contained in:
Peter Papp
2021-07-09 12:06:58 +02:00
+76 -1
View File
@@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Storage;
use Intervention\Image\ImageManagerStatic as Image; use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
if (!function_exists('obfuscate_email')) {
/** /**
* Obfuscate email * Obfuscate email
* *
@@ -30,7 +31,9 @@ function obfuscate_email($email)
return substr($name, 0, $len) . str_repeat('*', $len) . '@' . end($em); return substr($name, 0, $len) . str_repeat('*', $len) . '@' . end($em);
} }
}
if (!function_exists('get_setting')) {
/** /**
* Get single value from settings table * Get single value from settings table
* *
@@ -41,7 +44,9 @@ function get_setting($setting)
{ {
return Setting::find($setting)->value ?? null; return Setting::find($setting)->value ?? null;
} }
}
if (!function_exists('get_settings_in_json')) {
/** /**
* Get all app settings and return them as json * Get all app settings and return them as json
*/ */
@@ -53,7 +58,9 @@ function get_settings_in_json()
->toJson() ->toJson()
); );
} }
}
if (!function_exists('get_setup_status')) {
/** /**
* Check if setup wizard was passed * Check if setup wizard was passed
* *
@@ -65,7 +72,9 @@ function get_setup_status()
return boolval($setup_success) ? 'setup-done' : 'setup-disclaimer'; return boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
} }
}
if (!function_exists('add_paragraphs')) {
/** /**
* Create paragraph from text * Create paragraph from text
* *
@@ -112,7 +121,9 @@ function add_paragraphs($str)
return $str; return $str;
} }
}
if (!function_exists('setEnvironmentValue')) {
/** /**
* Set environment value * Set environment value
* *
@@ -141,6 +152,7 @@ function setEnvironmentValue(array $values)
return !(!file_put_contents($envFile, $str)); return !(!file_put_contents($envFile, $str));
} }
}
if (!function_exists('get_invoice_number')) { if (!function_exists('get_invoice_number')) {
/** /**
@@ -150,7 +162,7 @@ if (!function_exists('get_invoice_number')) {
*/ */
function get_invoice_number() function get_invoice_number()
{ {
$invoices = Invoice::all(); $invoices = \App\Invoice::all();
if ($invoices->isEmpty()) { if ($invoices->isEmpty()) {
return now()->year . '001'; return now()->year . '001';
@@ -160,6 +172,7 @@ if (!function_exists('get_invoice_number')) {
} }
} }
if (!function_exists('cache_forget_many')) {
/** /**
* Forget many cache keys at once * Forget many cache keys at once
* @param $cache * @param $cache
@@ -170,7 +183,9 @@ function cache_forget_many($cache)
\Illuminate\Support\Facades\Cache::forget($item); \Illuminate\Support\Facades\Cache::forget($item);
} }
} }
}
if (!function_exists('get_storage')) {
/** /**
* Get app version from config * Get app version from config
* *
@@ -180,7 +195,9 @@ function get_storage()
{ {
return env('FILESYSTEM_DRIVER'); return env('FILESYSTEM_DRIVER');
} }
}
if (!function_exists('is_storage_driver')) {
/** /**
* Check if is running AWS s3 as storage * Check if is running AWS s3 as storage
* *
@@ -194,7 +211,9 @@ function is_storage_driver($driver)
return config('filesystems.default') === $driver; return config('filesystems.default') === $driver;
} }
}
if (!function_exists('get_version')) {
/** /**
* Get app version from config * Get app version from config
* *
@@ -204,7 +223,9 @@ function get_version()
{ {
return config('vuefilemanager.version'); return config('vuefilemanager.version');
} }
}
if (!function_exists('is_demo')) {
/** /**
* Check if is demo * Check if is demo
* *
@@ -214,7 +235,9 @@ function is_demo()
{ {
return config('vuefilemanager.is_demo'); return config('vuefilemanager.is_demo');
} }
}
if (!function_exists('is_demo_account')) {
/** /**
* Check if is demo * Check if is demo
* *
@@ -225,7 +248,9 @@ function is_demo_account($email)
{ {
return config('vuefilemanager.is_demo') && $email === 'howdy@hi5ve.digital'; return config('vuefilemanager.is_demo') && $email === 'howdy@hi5ve.digital';
} }
}
if (!function_exists('get_item')) {
/** /**
* Get folder or file item * Get folder or file item
* *
@@ -239,7 +264,9 @@ function get_item($type, $id)
return ("App\\Models\\$model")::find($id); return ("App\\Models\\$model")::find($id);
} }
}
if (!function_exists('get_shared')) {
/** /**
* Get shared token * Get shared token
* *
@@ -251,7 +278,9 @@ function get_shared($token)
return Share::whereToken($token) return Share::whereToken($token)
->firstOrFail(); ->firstOrFail();
} }
}
if (!function_exists('is_editor')) {
/** /**
* Check if shared permission is editor * Check if shared permission is editor
* *
@@ -262,7 +291,9 @@ function is_editor($shared)
{ {
return $shared->permission === 'editor'; return $shared->permission === 'editor';
} }
}
if (!function_exists('is_visitor')) {
/** /**
* Check if shared permission is visitor * Check if shared permission is visitor
* *
@@ -273,7 +304,9 @@ function is_visitor($shared)
{ {
return $shared->permission === 'visitor'; return $shared->permission === 'visitor';
} }
}
if (!function_exists('store_avatar')) {
/** /**
* Store user avatar to storage * Store user avatar to storage
* *
@@ -310,7 +343,9 @@ function store_avatar($request, $name)
// Return path to image // Return path to image
return "avatars/$image_path"; return "avatars/$image_path";
} }
}
if (!function_exists('store_system_image')) {
/** /**
* Store system image * Store system image
* *
@@ -335,7 +370,9 @@ function store_system_image($request, $name)
// Return path to image // Return path to image
return "system/$filename"; return "system/$filename";
} }
}
if (!function_exists('make_single_input')) {
/** /**
* Make input from request * Make input from request
* *
@@ -353,7 +390,9 @@ function make_single_input($request)
// Return input // Return input
return $data; return $data;
} }
}
if (!function_exists('format_gigabytes')) {
/** /**
* Format integer to gigabytes * Format integer to gigabytes
* *
@@ -368,7 +407,9 @@ function format_gigabytes($gigabytes)
return Metric::gigabytes($gigabytes)->format('GB/'); return Metric::gigabytes($gigabytes)->format('GB/');
} }
}
if (!function_exists('format_megabytes')) {
/** /**
* Format string to formated megabytes string * Format string to formated megabytes string
* *
@@ -387,7 +428,9 @@ function format_megabytes($megabytes)
return $megabytes . 'MB'; return $megabytes . 'MB';
} }
}
if (!function_exists('format_bytes')) {
/** /**
* Convert megabytes to bytes * Convert megabytes to bytes
* *
@@ -398,7 +441,9 @@ function format_bytes($megabytes)
{ {
return Metric::megabytes($megabytes)->numberOfBytes(); return Metric::megabytes($megabytes)->numberOfBytes();
} }
}
if (!function_exists('get_storage_fill_percentage')) {
/** /**
* Get storage usage in percent * Get storage usage in percent
* *
@@ -421,7 +466,9 @@ function get_storage_fill_percentage($used, $capacity)
// Return in 2 decimal // Return in 2 decimal
return number_format((float)$progress, 2, '.', ''); return number_format((float)$progress, 2, '.', '');
} }
}
if (!function_exists('user_storage_percentage')) {
/** /**
* Get user capacity fill by percentage * Get user capacity fill by percentage
* *
@@ -441,7 +488,9 @@ function user_storage_percentage($id, $additionals = null)
return get_storage_fill_percentage($used, $user->settings->storage_capacity); return get_storage_fill_percentage($used, $user->settings->storage_capacity);
} }
}
if (!function_exists('recursiveFind')) {
/** /**
* Find all key values in recursive array * Find all key values in recursive array
* *
@@ -463,7 +512,9 @@ function recursiveFind(array $array, $needle)
return $aHitList; return $aHitList;
} }
}
if (!function_exists('appeared_once')) {
/** /**
* Get values which appears only once in array * Get values which appears only once in array
* @param $arr * @param $arr
@@ -483,7 +534,9 @@ function appeared_once($arr)
return $single_time_comming_values_array; return $single_time_comming_values_array;
} }
}
if (!function_exists('filter_folders_ids')) {
/** /**
* @param $folders * @param $folders
* @param string $by_column * @param string $by_column
@@ -495,7 +548,9 @@ function filter_folders_ids($folders, $by_column = 'id')
return appeared_once($folder_ids); return appeared_once($folder_ids);
} }
}
if (!function_exists('format_date')) {
/** /**
* Format localized date * Format localized date
* *
@@ -509,7 +564,9 @@ function format_date($date, $format = '%d. %B. %Y, %H:%M')
return $start->formatLocalized($format); return $start->formatLocalized($format);
} }
}
if (!function_exists('get_file_type')) {
/** /**
* Get file type from mimetype * Get file type from mimetype
* *
@@ -527,6 +584,7 @@ function get_file_type($file_mimetype)
return 'file'; return 'file';
} }
}
if (!function_exists('map_language_translations')) { if (!function_exists('map_language_translations')) {
/** /**
@@ -543,6 +601,7 @@ if (!function_exists('map_language_translations')) {
} }
} }
if (!function_exists('get_file_type_from_mimetype')) {
/** /**
* Get file type from mimetype * Get file type from mimetype
* *
@@ -553,7 +612,9 @@ function get_file_type_from_mimetype($mimetype)
{ {
return explode('/', $mimetype)[1]; return explode('/', $mimetype)[1];
} }
}
if (!function_exists('get_pretty_name')) {
/** /**
* Format pretty name file * Format pretty name file
* *
@@ -576,7 +637,9 @@ function get_pretty_name($basename, $name, $mimetype)
return $name . '.' . $mimetype; return $name . '.' . $mimetype;
} }
}
if (!function_exists('get_image_meta_data')) {
/** /**
* Get exif data from jpeg image * Get exif data from jpeg image
* *
@@ -594,6 +657,7 @@ function get_image_meta_data($file)
} }
} }
} }
}
if (!function_exists('get_default_language_translations')) { if (!function_exists('get_default_language_translations')) {
/** /**
@@ -609,6 +673,7 @@ if (!function_exists('get_default_language_translations')) {
} }
} }
if (!function_exists('is_dev')) {
/** /**
* Check if app is in dev mode * Check if app is in dev mode
* *
@@ -618,7 +683,9 @@ function is_dev()
{ {
return env('APP_ENV') === 'local'; return env('APP_ENV') === 'local';
} }
}
if (!function_exists('seems_utf8')) {
/** /**
* @param $str * @param $str
* @return bool * @return bool
@@ -661,7 +728,9 @@ function seems_utf8($str)
return true; return true;
} }
}
if (!function_exists('remove_accents')) {
/** /**
* Converts all accent characters to ASCII characters. * Converts all accent characters to ASCII characters.
* *
@@ -801,6 +870,9 @@ function remove_accents($string)
return $string; return $string;
} }
}
if (!function_exists('get_files_for_zip')) {
/** /**
* Get all files from folder and get their folder location in VueFileManager directories * Get all files from folder and get their folder location in VueFileManager directories
@@ -839,7 +911,9 @@ function get_files_for_zip($folders, $files, $path = [])
return get_files_for_zip($folders->folders->first(), $files, $path); return get_files_for_zip($folders->folders->first(), $files, $path);
} }
}
if (!function_exists('set_time_by_user_timezone')) {
/** /**
* Set time by user timezone GMT * Set time by user timezone GMT
* *
@@ -858,6 +932,7 @@ function set_time_by_user_timezone($time)
return Carbon::parse($time); return Carbon::parse($time);
} }
}
if (!function_exists('__t')) { if (!function_exists('__t')) {
/** /**