dmstr / yii2-filefly-module
FlySystem API for Filemanager
Installs: 51 085
Dependents: 2
Suggesters: 0
Security: 0
Stars: 8
Watchers: 9
Forks: 8
Open Issues: 7
Type:yii2-extension
Requires
- creocoder/yii2-flysystem: ^1.0.0
- dmstr/yii2-active-record-permissions: ^1.0.0
- yiisoft/yii2: ~2.0.13
Suggests
- dmstr/yii2-filemanager-widgets: Useful widget for working with files via the filefly api
- league/flysystem-sftp: SFTP adapter (~1.0)
- league/flysystem-webdav: WebDAV adapter (~1.0)
- dev-master
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.7.0-rc3
- 1.7.0-rc2
- 1.7.0-rc1
- 1.6.x-dev
- 1.6.2
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.4.0-beta3
- 1.4.0-beta2
- 1.4.0-beta1
- 1.3.0-rc1
- 1.3.0-beta4
- 1.3.0-beta3
- 1.3.0-beta2
- 1.3.0-beta1
- 1.2.0-rc2
- 1.2.0-rc1
- 1.1.0-rc6
- 1.1.0-rc5
- 1.1.0-rc4
- 1.1.0-rc3
- 1.1.0-rc1
- 1.0.0
- 1.0.0-alpha2
- 1.0.0-alpha1
- 0.7.0-beta2
- 0.7.0-beta1
- 0.6.20
- 0.6.19
- 0.6.18
- 0.6.17
- 0.6.16
- 0.6.15
- 0.6.14
- 0.6.13
- 0.6.12
- 0.6.11
- 0.6.11-rc7
- 0.6.11-rc6
- 0.6.11-rc5
- 0.6.11-rc4
- 0.6.11-rc3
- 0.6.11-rc2
- 0.6.11-rc1
- 0.6.10
- 0.6.9.1
- 0.6.9
- 0.6.8
- 0.6.7
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.5
- 0.5.5-rc5
- 0.5.5-rc4
- 0.5.5-rc3
- 0.5.5-rc2
- 0.5.5-rc1
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-feature/fix-search-permission-checks
- dev-feature/filemanager-widget-options
- dev-feature/rm-bootstrap
- dev-feature/preview-callback
- dev-feature/url-callback
- dev-feature/file-events
- dev-feature/postgres-support
- dev-feature/wip-improve-permissions
- dev-feature/search-action
This package is auto-updated.
Last update: 2024-10-18 12:06:22 UTC
README
FlySystem API for dmstr/yii2-filemanager-widgets
Installation
ENV variables
i.e. AFM_FILESYSTEM=fsLocal
❓ How to configure a filesystem component Filesystem docs
Yii config
'filefly' => [ 'class' => 'hrzg\filefly\Module', 'layout' => '@backend/views/layouts/main', 'filesystem' => getenv('AFM_FILESYSTEM'), 'slugNames' => (getenv('AFM_SLUG_NAMES')) ? getenv('AFM_SLUG_NAMES') : true, 'repair' => (getenv('AFM_REPAIR')) ? getenv('AFM_REPAIR') : true, 'deleteRecursive' => (getenv('AFM_DELETE_RECURSIVE')) ? getenv('AFM_DELETE_RECURSIVE') : false, 'streamExpireOffset' => 604800 # Offset (in seconds) for Expires Header in stream action 'defaultPermissions' => [ \hrzg\filefly\Module::ACCESS_OWNER => 1, \hrzg\filefly\Module::ACCESS_READ => \hrzg\filefly\models\FileflyHashmap::$_all, \hrzg\filefly\Module::ACCESS_UPDATE => \hrzg\filefly\models\FileflyHashmap::$_all, \hrzg\filefly\Module::ACCESS_DELETE => \hrzg\filefly\models\FileflyHashmap::$_all, ], # the urlCallbck property can be used to provide customized urls for each file item which (if defined) will overwrite # the default handler URLs 'urlCallback' => function($item) { $urls = []; $isImageFileExtList = ['jpg', 'jpeg', 'gif', 'tiff', 'tif', 'svg', 'png', 'bmp'] ; if ($item['type'] === 'file') { if (in_array(strtolower($item['extension']), $isImageFileExtList)) { $urls['image url'] = \dmstr\willnorrisImageproxy\Url::image($item['path']); } else { $urls['download url'] = implode('/', ['/img/download', ltrim($item['path'], '/')]) . ',p1'; } } return $urls; }, // previewCallback can be used to overwrite the default downloadUrl for preview URLs within filemanagerApp 'previewCallback' => function($item) { $isImageFileExtList = ['jpg', 'jpeg', 'gif', 'tiff', 'tif', 'png', 'bmp'] ; if ($item['type'] === 'file') { if (in_array(strtolower($item['extension']), $isImageFileExtList)) { return \dmstr\willnorrisImageproxy\Url::image($item['path'], '500x'); } } return ''; } ],
RBAC
Prosa
-
FileflyAdmin
full module access including debug information -
FileflyDefault
management access (eg. POST request for upload, change, delete) -
FileflyPermissions
assigned users can set or unset roles or permissions which the user himself has assigned -
access_owner
permission beforeaccess_read
,access_update
,access_delete
-
If no permission is set, it will check if any inherited permission can be granted
So if inherited access_*
permissions should be used, set defaultPermissions to null
NOT to '*'
.
'defaultPermissions' => [
\hrzg\filefly\Module::ACCESS_OWNER => 1,
\hrzg\filefly\Module::ACCESS_READ => null,
\hrzg\filefly\Module::ACCESS_UPDATE => null,
\hrzg\filefly\Module::ACCESS_DELETE => null,
],
ActiveRecord: FileflyHashmap
- uses
dmstr\activeRecordPermissions\ActiveRecordAccessTrait
with$activeAccessTrait = false
- access checks will be done for each permission type explicitly,
hasPermission($action)
- uses a
pathValidator
rule to ensure thepath
syntax on active record operations
Roles
-
FileflyAdmin
- filefly
-
FileflyDefault
- filefly_default_index
-
FileflyApi
- filefly_api_index
-
FileflyPermissions
Permissions
- filefly
- filefly_default_index
- filefly_api_index
RBAC Plugins
Permission checks will ever come after file or folder operation
GrantPermission
Granted or deny permission
1. access field empty (is owner, true or continue)
2. access field set (permission granted, true)
access field set (is access owner, true, permission denied, false)
SetPermission
Create or update permission
1. Add new hash records
2. Update hash records (recursive option)
- Multi create and update option
RemovePermission
Remove permission
1. Deletes file or folder records
- Multi delete option
CLI
Configure
'controllerMap' => [
'fs' => [
'class' => '\hrzg\filefly\commands\FsController',
'filesystemComponents' => [
'local' => 'fs',
's3' => 'fsS3',
'storage' => 'fsFtp',
],
],
]
Widget
see https://github.com/dmstr/yii2-filemanager-widgets
{{ use ('hrzg/filemanager/widgets') }}
{{ file_manager_widget_widget(
{
"handlerUrl": "/#{app.language}/filefly/api"
}
) }}
Options for the yii2-filemanager-widgets Widget can be injected via the Module property fileManagerWidgetOptions
example:
'filefly' => [ 'filesystemComponents' => [ 'ftp' => 'fsFtp', 'ftpcrud' => 'fsFtpCrud', ], // ... // other configs // ... // Options for the angular fileManagerWidget 'fileManagerWidgetOptions' => [ 'searchForm' => false, 'allowedActions' => [ 'move' => false, 'upload' => false, 'createFolder' => false, ], ], ],
Controller action in iFrame
Modal button
<a type="button" data-toggle="modal" data-target="#modal-filemanager" id="filefly-iframe-toggle">
<i class="fa fa-folder-open"></i>
</a>
Load event listener
<script>
window.addEventListener('load', function () {
var fileflyIframeToggle = document.querySelector('#filefly-iframe-toggle');
var iframe = document.querySelector('#filefly-iframe');
fileflyIframeToggle.addEventListener('click', function () {
iframe.src = "/filefly/default/filemanager-full-screen";
});
});
</script>
Iframe
{{ use ('yii/bootstrap') }}
{{ modal_begin(
{
'id': 'modal-filemanager',
'size': 'modal-lg'
}) }}
<iframe id="filefly-iframe" width="100%" height="100%" frameborder="0" src=""></iframe>
{{ modal_end() }}'