mhe/silverstripe-download-codes

Create download codes for protected files in SilverStripe

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

v1.0.4 2024-03-22 11:43 UTC

This package is auto-updated.

Last update: 2024-04-22 16:09:43 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, still works with Silverstripe 4 – see respective branches 4 and 5

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:

Usage and administration

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 form
  • Mhe/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