This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5d4874
commit 73512db
Showing
12 changed files
with
123 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
modules/tide_media_secure_files/tide_media_secure_files.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { } |
98 changes: 98 additions & 0 deletions
98
modules/tide_media_secure_files/tide_media_secure_files.install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Tide Media Secure Files. | ||
*/ | ||
|
||
/** | ||
* Implements hook_uninstall(). | ||
*/ | ||
function tide_media_secure_files_uninstall() { | ||
} | ||
|
||
/** | ||
* 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']); | ||
} | ||
} | ||
|
||
/** | ||
* Enable Private files download permission module. | ||
*/ | ||
/* function tide_media_update_10004() { | ||
if (!\Drupal::moduleHandler()->moduleExists('pfdp')) { | ||
$module_installer = \Drupal::service('module_installer'); | ||
$module_installer->install(['pfdp']); | ||
|
||
$configs = [ | ||
'pfdp.pfdp_directory.secure', | ||
'media.type.secure_file', | ||
'user.role.secure_file_user', | ||
]; | ||
|
||
$config_path = \Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install'; | ||
$source = new FileStorage($config_path); | ||
$config_storage = \Drupal::service('config.storage'); | ||
|
||
foreach ($configs as $config) { | ||
$config_storage->write($config, $source->read($config)); | ||
} | ||
|
||
// Add field. | ||
$field_configs = [ | ||
'field.storage.media.field_secure_file' => 'field_storage_config', | ||
'field.field.media.secure_file.field_secure_file' => 'field_config', | ||
]; | ||
module_load_include('inc', 'tide_core', 'includes/helpers'); | ||
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; | ||
|
||
// Check if field already exported to config/sync. | ||
foreach ($field_configs as $config => $type) { | ||
$config_read = _tide_read_config($config, $config_location, TRUE); | ||
$storage = \Drupal::entityTypeManager()->getStorage($type); | ||
$id = substr($config, strrpos($config, '.') + 1); | ||
if ($storage->load($id) == NULL) { | ||
$config_entity = $storage->createFromStorageRecord($config_read); | ||
$config_entity->save(); | ||
} | ||
} | ||
|
||
$update_configs = [ | ||
'core.entity_form_display.media.secure_file.default' => 'entity_form_display', | ||
'core.entity_view_display.media.secure_file.default' => 'entity_view_display', | ||
]; | ||
$skipped_settings = [ | ||
'uuid', | ||
'langcode', | ||
'status', | ||
'id', | ||
'bundle', | ||
]; | ||
foreach ($update_configs as $update_config => $type) { | ||
$config_read = _tide_read_config($update_config, $config_location, FALSE); | ||
$config = \Drupal::configFactory()->getEditable($update_config); | ||
if (!$config) { | ||
continue; | ||
} | ||
$data = $config->getRawData(); | ||
foreach ($config_read as $key => $item) { | ||
if (in_array($key, $skipped_settings)) { | ||
continue; | ||
} | ||
NestedArray::setValue($data, [ | ||
$key, | ||
], NestedArray::getValue($config_read, [ | ||
$key, | ||
])); | ||
} | ||
$config->setData($data)->save(); | ||
} | ||
} | ||
} */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters