return auth()->user() ?: \BookStack\User::getDefault();
}
+/**
+ * Check if current user is a signed in user.
+ * @return bool
+ */
+function signedInUser()
+{
+ return auth()->user() && !auth()->user()->isDefault();
+}
+
/**
* Check if the current user has a permission.
* If an ownable element is passed in the jointPermissions are checked against
*/
function setting($key = null, $default = false)
{
- $settingService = app(\BookStack\Services\SettingService::class);
- if (is_null($key)) return $settingService;
+ $settingService = resolve(\BookStack\Services\SettingService::class);
+ if (is_null($key)) {
+ return $settingService;
+ }
return $settingService->get($key, $default);
}
function baseUrl($path, $forceAppDomain = false)
{
$isFullUrl = strpos($path, 'http') === 0;
- if ($isFullUrl && !$forceAppDomain) return $path;
+ if ($isFullUrl && !$forceAppDomain) {
+ return $path;
+ }
$path = trim($path, '/');
// Remove non-specified domain if forced and we have a domain
return app('redirect')->to($to, $status, $headers, $secure);
}
-function icon($name, $attrs = []) {
+function icon($name, $attrs = [])
+{
$iconPath = resource_path('assets/icons/' . $name . '.svg');
$attrString = ' ';
foreach ($attrs as $attrName => $attr) {
foreach ($queryData as $name => $value) {
$trimmedVal = trim($value);
- if ($trimmedVal === '') continue;
+ if ($trimmedVal === '') {
+ continue;
+ }
$queryStringSections[] = urlencode($name) . '=' . urlencode($trimmedVal);
}
- if (count($queryStringSections) === 0) return $path;
+ if (count($queryStringSections) === 0) {
+ return $path;
+ }
return baseUrl($path . '?' . implode('&', $queryStringSections));
-}
\ No newline at end of file
+}