Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Added secure file media type and config files #123

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"drupal/embed": "^1.6",
"drupal/focal_point": "^2.0",
"drupal/inline_entity_form": "^1.0@RC",
"drupal/private_files_download_permission": "^3.1",
"drupal/svg_image": "^3.0",
"drupal/video_embed_field": "2.5",
"drupal/entity_usage": "^2.0@beta"
Expand All @@ -21,9 +22,6 @@
},
"extra": {
"patches": {
"drupal/core": {
"Use CKEditor 5's native <ol type> and <ul type> UX - https://www.drupal.org/project/drupal/issues/3274635#comment-15723525": "https://www.drupal.org/files/issues/2024-08-11/3274635--ckeditor_list_styles-10.3.2--108.patch"
},
"drupal/video_embed_field": {
"Add support for Ckeditor 5 - https://www.drupal.org/project/video_embed_field/issues/3311063": "./patches/video_embed_field/video_embed_field_6.patch"
}
Expand Down
5 changes: 5 additions & 0 deletions modules/tide_media_secure_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# tide_media_secure_files
Allows author to create secure private files

## Purpose
- media
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
langcode: en
status: true
dependencies:
config:
- field.field.media.secure_file.field_secure_file
- media.type.secure_file
module:
- file
- path
id: media.secure_file.default
targetEntityType: media
bundle: secure_file
mode: default
content:
created:
type: datetime_timestamp
weight: 10
region: content
settings: { }
third_party_settings: { }
field_secure_file:
type: file_generic
weight: 0
region: content
settings:
progress_indicator: throbber
third_party_settings: { }
name:
type: string_textfield
weight: -5
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
path:
type: path
weight: 30
region: content
settings: { }
third_party_settings: { }
status:
type: boolean_checkbox
weight: 100
region: content
settings:
display_label: true
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
region: content
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
config:
- field.field.media.secure_file.field_secure_file
- media.type.secure_file
module:
- file
id: media.secure_file.default
targetEntityType: media
bundle: secure_file
mode: default
content:
field_secure_file:
type: file_default
label: visually_hidden
settings:
use_description_as_link_text: true
third_party_settings: { }
weight: 0
region: content
hidden:
created: true
name: true
thumbnail: true
uid: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_site
- media.type.secure_file
- taxonomy.vocabulary.sites
id: media.secure_file.field_media_site
field_name: field_media_site
entity_type: media
bundle: secure_file
label: Site
description: ''
required: true
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
sites: sites
field_type: entity_reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_secure_file
- media.type.secure_file
module:
- file
id: media.secure_file.field_secure_file
field_name: field_secure_file
entity_type: media
bundle: secure_file
label: File
description: ''
required: true
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:file'
handler_settings: { }
file_directory: 'secure/[date:custom:Y]-[date:custom:m]'
file_extensions: 'xls xlsx csv xlsm doc docx dotx pdf ppt pptx'
max_filesize: ''
description_field: true
field_type: file
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
module:
- field_permissions
- file
- media
third_party_settings:
field_permissions:
permission_type: custom
id: media.field_secure_file
field_name: field_secure_file
entity_type: media
type: file
settings:
target_type: file
display_field: false
display_default: false
uri_scheme: private
module: file
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
langcode: en
status: true
dependencies: { }
id: secure_file
label: 'Secure File'
description: ''
source: file
queue_thumbnail_downloads: false
new_revision: false
source_configuration:
source_field: field_secure_file
field_map: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
langcode: en
status: true
dependencies: { }
id: secure
path: /secure
bypass: false
grant_file_owners: false
users: { }
roles:
secure_file_user: secure_file_user
anonymous: '0'
authenticated: '0'
administrator: '0'
approver: '0'
site_admin: '0'
editor: '0'
previewer: '0'
contributor: '0'
site_auditor: '0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
langcode: en
status: true
dependencies:
config:
- user.role.secure_file_user
module:
- user
id: user_add_role_action.secure_file_user
label: 'Add the Secure File User role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: secure_file_user
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
langcode: en
status: true
dependencies:
config:
- user.role.secure_file_user
module:
- user
id: user_remove_role_action.secure_file_user
label: 'Remove the Secure File User role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: secure_file_user
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
config:
- media.type.secure_file
module:
- field_permissions
- media
id: secure_file_user
label: 'Secure File User'
weight: 102
is_admin: null
permissions:
- 'create field_secure_file'
- 'create secure_file media'
- 'delete any secure_file media'
- 'delete any secure_file media revisions'
- 'delete own secure_file media'
- 'edit any secure_file media'
- 'edit field_secure_file'
- 'edit own field_secure_file'
- 'edit own secure_file media'
- 'revert any secure_file media revisions'
- 'view any secure_file media revisions'
- 'view field_secure_file'
- 'view own field_secure_file'
19 changes: 19 additions & 0 deletions modules/tide_media_secure_files/tide_media_secure_files.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Tide Media Secure Files'
description: 'Gives the author option to create secure files.'
type: module
package: Tide
core_version_requirement: ^9 || ^10
dependencies:
- dpc-sdp:tide_core
- dpc-sdp:tide_media
- pfdp:pfdp
config_devel:
install:
- core.entity_form_display.media.secure_file.default
- core.entity_view_display.media.secure_file.default
- field.field.media.secure_file.field_secure_file
- field.storage.media.field_secure_file
- media.type.secure_file
- pfdp.pfdp_directory.secure
- user.role.dtf_secure_file_user
optional: { }
64 changes: 64 additions & 0 deletions modules/tide_media_secure_files/tide_media_secure_files.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* @file
* Tide Media Secure Files.
*/

use Drupal\user\Entity\Role;

/**
* Implements hook_uninstall().
*/
function tide_media_secure_files_uninstall() {
\Drupal::configFactory()->getEditable('pfdp.pfdp_directory.secure')->delete();

$secure_file_media_type = 'secure_file';
$ids = \Drupal::entityQuery('media')
->condition('bundle', $secure_file_media_type)
->accessCheck(FALSE)
->execute();
$storageHandler = \Drupal::entityTypeManager()->getStorage('media');
$entities = $storageHandler->loadMultiple($ids);
if ($entities) {
foreach ($entities as $entity) {
$entity->delete();
}
}

$media_type = \Drupal::entityTypeManager()
->getStorage('media_type')
->load($secure_file_media_type);
if ($media_type) {
$media_type->delete();
}

$secure_file_user_role = 'secure_file_user';
$secure_file_users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(['roles' => 'secure_file_user']);
if ($secure_file_users) {
foreach ($secure_file_users as $user) {
$user->removeRole($secure_file_user_role);
$user->save();
}
}

$role = Role::load($secure_file_user_role);
if ($role) {
$role->delete();
}

drupal_flush_all_caches();

\Drupal::service('module_installer')->uninstall(['pfdp']);
}

/**
* Implements hook_install().
*/
function tide_media_secure_files_install() {
if (!\Drupal::moduleHandler()->moduleExists('pfdp')) {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['pfdp']);
}
}
2 changes: 1 addition & 1 deletion tide_media.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ config_devel:
- core.entity_view_display.media.document.default
- core.entity_view_display.media.document.embedded
- core.entity_view_display.media.document.media_browser_preview
- core.entity_view_display.media.embedded_video.defailt
- core.entity_view_display.media.embedded_video.default
- core.entity_view_display.media.embedded_video.embedded
- core.entity_view_display.media.embedded_video.embedded_with_transcript
- core.entity_view_display.media.embedded_video.media_browser_preview
Expand Down
Loading