diff --git a/app/Controllers/Admin/Podcast.php b/app/Controllers/Admin/Podcast.php index 1d10f9f2f0b6a92c25100a979609727f3d927063..05503ca221f2946da66d770c9f9f0e7673002535 100644 --- a/app/Controllers/Admin/Podcast.php +++ b/app/Controllers/Admin/Podcast.php @@ -156,6 +156,7 @@ class Podcast extends BaseController 'copyright' => $this->request->getPost('copyright'), 'block' => $this->request->getPost('block') === 'yes', 'complete' => $this->request->getPost('complete') === 'yes', + 'lock' => $this->request->getPost('lock') === 'yes', 'created_by' => user(), 'updated_by' => user(), ]); @@ -244,10 +245,19 @@ class Podcast extends BaseController ' ⎋</a>', ]); } - $nsItunes = $feed->channel[0]->children( 'http://www.itunes.com/dtds/podcast-1.0.dtd' ); + $nsPodcast = $feed->channel[0]->children( + 'https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md' + ); + + if ((string) $nsPodcast->locked === 'yes') { + return redirect() + ->back() + ->withInput() + ->with('errors', [lang('PodcastImport.lock_import')]); + } $podcast = new \App\Entities\Podcast([ 'name' => $this->request->getPost('name'), @@ -453,6 +463,7 @@ class Podcast extends BaseController $this->podcast->block = $this->request->getPost('block') === 'yes'; $this->podcast->complete = $this->request->getPost('complete') === 'yes'; + $this->podcast->lock = $this->request->getPost('lock') === 'yes'; $this->updated_by = user(); $db = \Config\Database::connect(); diff --git a/app/Database/Migrations/2020-05-30-101500_add_podcasts.php b/app/Database/Migrations/2020-05-30-101500_add_podcasts.php index 018315cfd952e78c4d6fcca01119c7b034501ae4..96633865eef03a16e3c044aab1583ef25a5ea0c8 100644 --- a/app/Database/Migrations/2020-05-30-101500_add_podcasts.php +++ b/app/Database/Migrations/2020-05-30-101500_add_podcasts.php @@ -79,6 +79,10 @@ class AddPodcasts extends Migration 'constraint' => 1024, 'null' => true, ], + 'episode_description_footer' => [ + 'type' => 'TEXT', + 'null' => true, + ], 'block' => [ 'type' => 'TINYINT', 'constraint' => 1, @@ -89,19 +93,12 @@ class AddPodcasts extends Migration 'constraint' => 1, 'default' => 0, ], - 'episode_description_footer' => [ - 'type' => 'TEXT', - 'null' => true, - ], - 'created_by' => [ - 'type' => 'INT', - 'constraint' => 11, - 'unsigned' => true, - ], - 'updated_by' => [ - 'type' => 'INT', - 'constraint' => 11, - 'unsigned' => true, + 'lock' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'comment' => + 'This tells other podcast platforms whether they are allowed to import this feed.', + 'default' => 1, ], 'imported_feed_url' => [ 'type' => 'VARCHAR', @@ -117,6 +114,16 @@ class AddPodcasts extends Migration 'The RSS new feed URL if this podcast is moving out, NULL otherwise.', 'null' => true, ], + 'created_by' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'updated_by' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], 'created_at' => [ 'type' => 'TIMESTAMP', ], diff --git a/app/Entities/Podcast.php b/app/Entities/Podcast.php index f60e44dc2b8f20552cff94a23b4fa96926b95e23..e64cd5bca7318f9e32a76122023eb61377977965 100644 --- a/app/Entities/Podcast.php +++ b/app/Entities/Podcast.php @@ -76,13 +76,14 @@ class Podcast extends Entity 'owner_email' => '?string', 'type' => 'string', 'copyright' => '?string', + 'episode_description_footer' => '?string', 'block' => 'boolean', 'complete' => 'boolean', - 'episode_description_footer' => '?string', - 'created_by' => 'integer', - 'updated_by' => 'integer', + 'lock' => 'boolean', 'imported_feed_url' => '?string', 'new_feed_url' => '?string', + 'created_by' => 'integer', + 'updated_by' => 'integer', ]; /** diff --git a/app/Helpers/rss_helper.php b/app/Helpers/rss_helper.php index 9f17a2f73c380065c6413257e02835c365ee598c..7841337834105ed685468c635754037f5a962544 100644 --- a/app/Helpers/rss_helper.php +++ b/app/Helpers/rss_helper.php @@ -21,8 +21,11 @@ function get_rss_feed($podcast) $itunes_namespace = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; + $podcast_namespace = + 'https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md'; + $rss = new SimpleRSSElement( - "<?xml version='1.0' encoding='utf-8'?><rss version='2.0' xmlns:itunes='$itunes_namespace' xmlns:content='http://purl.org/rss/1.0/modules/content/'></rss>" + "<?xml version='1.0' encoding='utf-8'?><rss version='2.0' xmlns:itunes='$itunes_namespace' xmlns:podcast='$podcast_namespace' xmlns:content='http://purl.org/rss/1.0/modules/content/'></rss>" ); $channel = $rss->addChild('channel'); @@ -60,7 +63,9 @@ function get_rss_feed($podcast) $itunes_image = $channel->addChild('image', null, $itunes_namespace); $itunes_image->addAttribute('href', $podcast->image->original_url); $channel->addChild('language', $podcast->language); - + $channel + ->addChild('locked', $podcast->lock ? 'yes' : 'no', $podcast_namespace) + ->addAttribute('owner', $podcast->owner_email); // set main category first, then other categories as apple add_category_tag($channel, $podcast->category); foreach ($podcast->other_categories as $other_category) { diff --git a/app/Language/en/Podcast.php b/app/Language/en/Podcast.php index fc54298c41d571240f96300b36d72e986b6fdc8a..d979ae78b5df0751875d303812373cb98c07c8fd 100644 --- a/app/Language/en/Podcast.php +++ b/app/Language/en/Podcast.php @@ -65,6 +65,9 @@ return [ 'status_section_subtitle' => 'Dead or alive?', 'block' => 'Podcast should be hidden from all platforms', 'complete' => 'Podcast will not be having new episodes', + 'lock' => 'Podcast is locked for export', + 'lock_hint' => + 'The purpose is to tell other podcast platforms whether they are allowed to import this feed. A value of yes means that any attempt to import this feed into a new platform should be rejected.', 'submit_create' => 'Create podcast', 'submit_edit' => 'Save podcast', ], diff --git a/app/Language/en/PodcastImport.php b/app/Language/en/PodcastImport.php index d914557a9b5b6fa9686fe9788c92900565909de2..5660a280f40dd5c26f47092dc2f6efc1baada748 100644 --- a/app/Language/en/PodcastImport.php +++ b/app/Language/en/PodcastImport.php @@ -40,5 +40,7 @@ return [ 'Use this if your podcast does not have a season number but wish to set one during import. Leave blank otherwise.', 'max_episodes' => 'Maximum number of episodes to import', 'max_episodes_hint' => 'Leave blank to import all episodes', + 'lock_import' => + 'This feed is protected. You cannot import it. If you are the owner, unprotect it on the origin platform.', 'submit' => 'Import podcast', ]; diff --git a/app/Language/fr/Podcast.php b/app/Language/fr/Podcast.php index 0452bbc6d1ad62ab01126c150ec5c83c461071f7..8fe3ad145de65c305f7f58f8a182251de58592da 100644 --- a/app/Language/fr/Podcast.php +++ b/app/Language/fr/Podcast.php @@ -66,6 +66,9 @@ return [ 'status_section_subtitle' => 'Vivant ou mort ?', 'block' => 'Le podcast doit être masqué sur toutes les plateformes', 'complete' => 'Le podcast n’aura plus de nouveaux épisodes.', + 'lock' => 'Le podcast est fermé à l’export', + 'lock_hint' => + 'Le but est d’indiquer aux autres plates-formes de podcast si elles sont autorisées à importer ce flux. La valeur « oui » signifie que toute tentative d’importation de ce flux dans une nouvelle plateforme doit être rejetée.', 'submit_create' => 'Créer le podcast', 'submit_edit' => 'Enregistrer le podcast', ], diff --git a/app/Language/fr/PodcastImport.php b/app/Language/fr/PodcastImport.php index c7d03e0c663212ab1517587abe3256f6c59d3aa9..539d06095a0b62f737bd753ec27b46ca51be6e81 100644 --- a/app/Language/fr/PodcastImport.php +++ b/app/Language/fr/PodcastImport.php @@ -41,5 +41,7 @@ return [ 'Utilisez ceci si le podcast à importer ne contient pas de numéros de saison mais que vous souhaitez en définir un. Laissez vide sinon.', 'max_episodes' => 'Nombre maximum d’épisodes à importer', 'max_episodes_hint' => 'Laissez vide pour importer tous les épisodes', + 'lock_import' => + 'Ce flux est protégé. Vous ne pouvez pas l’importer. Si en vous êtes le propriétaire, déprotégez-le sur la plate-forme d’origine.', 'submit' => 'Importer le podcast', ]; diff --git a/app/Models/PodcastModel.php b/app/Models/PodcastModel.php index 1fd98403bfe7e0eea9b77f8d317e48a0789edd13..84b26e6ba7db67a3e425f2c09f43e29209764a1b 100644 --- a/app/Models/PodcastModel.php +++ b/app/Models/PodcastModel.php @@ -32,6 +32,7 @@ class PodcastModel extends Model 'copyright', 'block', 'complete', + 'lock', 'created_by', 'updated_by', 'imported_feed_url', diff --git a/app/Views/admin/podcast/create.php b/app/Views/admin/podcast/create.php index 006dd61a87f490c6689f1e2c3dc06845ebdebb1a..1ee8414124f8c29eec5c51d2d81de85f168058b9 100644 --- a/app/Views/admin/podcast/create.php +++ b/app/Views/admin/podcast/create.php @@ -262,6 +262,13 @@ old('complete', false) ) ?> +<?= form_switch( + lang('Podcast.form.lock'), + ['id' => 'lock', 'name' => 'lock'], + 'yes', + old('lock', $podcast->lock) +) ?> + <?= form_section_close() ?> diff --git a/app/Views/admin/podcast/edit.php b/app/Views/admin/podcast/edit.php index 2a3933b719ea59c40e98ba0c771592a94e5e5c1e..b2c0286926af90c8a5df012a93b7d29df0c9253e 100644 --- a/app/Views/admin/podcast/edit.php +++ b/app/Views/admin/podcast/edit.php @@ -269,7 +269,16 @@ lang('Podcast.form.complete'), ['id' => 'complete', 'name' => 'complete'], 'yes', - old('complete', $podcast->complete) + old('complete', $podcast->complete), + 'mb-2' +) ?> + +<?= form_switch( + lang('Podcast.form.lock') . + hint_tooltip(lang('Podcast.form.lock_hint'), 'ml-1'), + ['id' => 'lock', 'name' => 'lock'], + 'yes', + old('lock', $podcast->lock) ) ?> <?= form_section_close() ?>