Skip to content

Commit

Permalink
fix: only display active files in download widgets and web player
Browse files Browse the repository at this point in the history
  • Loading branch information
eteubert committed Feb 11, 2024
1 parent 1cbe27d commit 1ecd3d1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/podlove-web-player-5.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function podlove_pwp5_files($episode, $context)
LEFT JOIN '.EpisodeAsset::table_name().' a ON a.id = mf.episode_asset_id
LEFT JOIN '.FileType::table_name().' ft ON ft.id = a.file_type_id
WHERE
e.id = %d AND a.downloadable
e.id = %d AND a.downloadable AND mf.active
ORDER BY
position ASC
';
Expand Down
12 changes: 12 additions & 0 deletions lib/template/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function id()
* Episode related to this file.
*
* @see episode
*
* @accessor
*/
public function episode()
Expand All @@ -48,6 +49,7 @@ public function episode()
* Asset related to this file.
*
* @see asset
*
* @accessor
*/
public function asset()
Expand All @@ -65,6 +67,16 @@ public function size()
return $this->file->size;
}

/**
* Is it active?
*
* @accessor
*/
public function active()
{
return $this->file->active;
}

/**
* URL.
*
Expand Down
7 changes: 7 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ This product includes GeoLite2 data created by MaxMind, available from http://ww

= 4.0.13 =

**Features**

- Templates: new `active` accessor for `File` objects. Returns if the file is marked as active.

**Bugfixes and Improvements**

- fix: don't use the Auphonic chapter image URL (real fix where chapter images are downloaded and served from WordPress will follow later)
- fix: only display active files in download widgets
- improve handling of upload directory

= 4.0.12 =
Expand Down
2 changes: 1 addition & 1 deletion templates/shortcode/downloads-buttons.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<li>Download:</li>
{% for file in episode.files %}
{% set asset = file.asset %}
{% if asset.downloadable %}
{% if asset.downloadable and file.active %}
<li>
<a href="{{ file.publicUrl("download", "buttonlist") }}">{{ asset.title }}<span class="size">{{ file.size|formatBytes }}</span></a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion templates/shortcode/downloads-select.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<select name="download_media_file">
{% for file in episode.files %}
{% set asset = file.asset %}
{% if asset.downloadable %}
{% if asset.downloadable and file.active %}
<option value="{{ file.id }}" data-raw-url="{{ file.publicUrl("download", "select-show") }}">{{ asset.title }} [{{ file.size|formatBytes }}]</option>
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 1ecd3d1

Please sign in to comment.