<?php
-if (! function_exists('versioned_asset')) {
+if (!function_exists('versioned_asset')) {
/**
* Get the path to a versioned file.
*
- * @param string $file
+ * @param string $file
* @return string
*
* @throws \InvalidArgumentException
/**
* Check if the current user has a permission.
- * If an ownable element is passed in the permissions are checked against
+ * If an ownable element is passed in the jointPermissions are checked against
* that particular item.
* @param $permission
* @param \BookStack\Ownable $ownable
return auth()->user() && auth()->user()->can($permission);
}
- $permissionBaseName = strtolower($permission) . '-';
- if (userCan($permissionBaseName . 'all')) return true;
- if (userCan($permissionBaseName . 'own') && $ownable->createdBy->id === auth()->user()->id) return true;
- return false;
-}
\ No newline at end of file
+ // Check permission on ownable item
+ $permissionService = app('BookStack\Services\PermissionService');
+ return $permissionService->checkEntityUserAccess($ownable, $permission);
+}
+
+/**
+ * Helper to access system settings.
+ * @param $key
+ * @param bool $default
+ * @return mixed
+ */
+function setting($key, $default = false)
+{
+ $settingService = app('BookStack\Services\SettingService');
+ return $settingService->get($key, $default);
+}