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
* Helper to access system settings.
* @param $key
* @param bool $default
- * @return mixed
+ * @return bool|string|\BookStack\Services\SettingService
*/
-function setting($key, $default = false)
+function setting($key = null, $default = false)
{
- $settingService = app(\BookStack\Services\SettingService::class);
+ $settingService = resolve(\BookStack\Services\SettingService::class);
+ if (is_null($key)) return $settingService;
return $settingService->get($key, $default);
}
return app('redirect')->to($to, $status, $headers, $secure);
}
+function icon($name, $attrs = []) {
+ $iconPath = resource_path('assets/icons/' . $name . '.svg');
+ $attrString = ' ';
+ foreach ($attrs as $attrName => $attr) {
+ $attrString .= $attrName . '="' . $attr . '" ';
+ }
+ $fileContents = file_get_contents($iconPath);
+ return str_replace('<svg', '<svg' . $attrString, $fileContents);
+}
+
/**
* Generate a url with multiple parameters for sorting purposes.
* Works out the logic to set the correct sorting direction
if (count($queryStringSections) === 0) return $path;
return baseUrl($path . '?' . implode('&', $queryStringSections));
-}
+}
\ No newline at end of file