mhe / silverstripe-download-codes
Create download codes for protected files in SilverStripe
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- php: ^8.0
- colymba/gridfield-bulk-editing-tools: ^3.0 || ^4.0
- silverstripe/framework: ^4.0 || ^5.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- bummzack/sortablefile: Support for sortable UploadFields, e.g. for Download Package files
- ext/zip: Support for DownloadPackages as zip
This package is auto-updated.
Last update: 2025-03-29 01:08:04 UTC
README
An extension for SilverStripe for generating download codes to give frontend users special access to protected files. A typical use case would be the download of digital music albums via codes provided with the LP version or sold separately.
Requirements
Requires Silverstripe 5.x – for a version compatible with Silverstripe 4 see respective branch 4
Installation and setup
Install with composer:
composer require mhe/silverstripe-download-codes ^1.0
Perform dev/build
task
Add a page of type “Download Page” to your site. This will provide a form where users can redeem their code. You might want to deactivate the “Show in menus” setting and only communicate the URL together with the download codes.
Recommended extensions
These extensions will improve the experience, but are optional:
- bummzack/sortablefile: Support for sortable UploadFields, to sort Download Package files
- colymba/gridfield-bulk-editing-tools: Support for bulk actions in Admin area
- PHP with enabled ext/zip: Providing download packages as zip
Usage and administration
- see User guide
Configuration
The following templates are included providing the basic funcionality. You can adjust them via a theme or project templates to adjust the layout to your needs.
Templates
Mhe/DownloadCodes/Model/Layout/DLPage_redeem.ss
: Layout of the DownloadPage containing the main code redemption formMhe/DownloadCodes/Model/Layout/DLPage.ss
: Displayed after successful entering of a valid code, containing the actual links to downloadable files
Configuration options via Silverstripe YAML configuration
Mhe\DownloadCodes\Model\DLCode
- autogenerate_chars: string containing valid characters for auto generated codes (default: "ABCDEFGHIJAKLMNOPQRSTUVWXYZ0123456789")
- autogenerate_length: length of auto generated codes (default: 8)
- strip_whitespace: if true strips whitespace from user input for codes (default: false)
- case_sensitive: user’s code input needs to match the case of the valid code (default: true), otherwise matches case-insensitive
- usage_limit: number of attempts a regular code can be redeemed (default: 5). The actual file download after redemption (in case of download problems etc) is not limited by this.
Mhe\DownloadCodes\Model\DLRedemption
- validity_days: number of days a code redemption with the unique URL part will be valid and can be used for download
Available Backend Permissions
- Access to 'Download Codes' section: view download codes and packages
- Edit download packages: create, edit, delete download packages
- Edit download codes: create, edit, delete download codes