Skip to content
Snippets Groups Projects
Commit ca109ba3 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(premium-podcasts): display unlock button in embed when premium episode

parent 242352c4
No related branches found
No related tags found
No related merge requests found
Pipeline #8630 passed
Pipeline: Castopod

#8631

    ......@@ -177,10 +177,19 @@ class EpisodeController extends BaseController
    $session->set('embed_domain', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST));
    }
    $locale = service('request')
    ->getLocale();
    $cacheName = "page_podcast#{$this->podcast->id}_episode#{$this->episode->id}_embed_{$theme}_{$locale}";
    $cacheName = implode(
    '_',
    array_filter([
    'page',
    "podcast#{$this->podcast->id}",
    "episode#{$this->episode->id}",
    'embed',
    $theme,
    service('request')
    ->getLocale(),
    is_unlocked($this->podcast->handle) ? 'unlocked' : null,
    ]),
    );
    if (! ($cachedView = cache($cacheName))) {
    $themeData = EpisodeModel::$themes[$theme];
    ......
    ......@@ -67,6 +67,11 @@ class PodcastUnlockFilter implements FilterInterface
    return;
    }
    // Episode should be embeddable even if it is premium
    if ($current === route_to('embed', $episode->podcast->handle, $episode->slug)) {
    return;
    }
    // if podcast is locked then send to the unlock form
    /** @var PremiumPodcasts $premiumPodcasts */
    $premiumPodcasts = service('premium_podcasts');
    ......
    ......@@ -33,6 +33,9 @@
    <a href="<?= $episode->link ?>" class="flex flex-col items-start text-sm" style="color: <?= $themeData['text'] ?>;" target="_blank" rel="noopener noreferrer">
    <h1 class="font-semibold leading-tight opacity-100 line-clamp-2 hover:opacity-75"><?= esc($episode->title) ?></h1>
    </a>
    <?php if ($episode->is_premium && ! is_unlocked($podcast->handle)): ?>
    <Button variant="primary" class="mt-auto mb-2" iconLeft="lock" uri="<?= $episode->link ?>" target="_blank" rel="noopener noreferrer"><?= lang('PremiumPodcasts.unlock') ?></Button>
    <?php else: ?>
    <vm-player
    id="castopod-vm-player"
    theme="<?= str_starts_with($theme, 'dark') ? 'dark' : 'light' ?>"
    ......@@ -60,6 +63,7 @@
    </vm-controls>
    </vm-ui>
    </vm-player>
    <?php endif; ?>
    </div>
    </body>
    ......
    ......@@ -17,7 +17,7 @@
    </div>
    <h2 class="flex-1 mt-1 font-semibold leading-tight line-clamp-2"><a class="hover:underline" href="<?= $episode->link ?>"><?= esc($episode->title) ?></a></h2>
    </div>
    <?php if ($episode->is_premium && ! subscription($podcast->handle)): ?>
    <?php if ($episode->is_premium && ! is_unlocked($podcast->handle)): ?>
    <a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
    <Icon glyph="lock" class="text-xl" />
    </a>
    ......
    ......@@ -17,7 +17,7 @@
    </div>
    <a href="<?= $episode->link ?>" class="flex items-baseline font-semibold line-clamp-2" title="<?= esc($episode->title) ?>"><?= esc($episode->title) ?></a>
    </div>
    <?php if ($episode->is_premium && ! subscription($episode->podcast->handle)): ?>
    <?php if ($episode->is_premium && ! is_unlocked($episode->podcast->handle)): ?>
    <a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 mr-4 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
    <Icon glyph="lock" class="text-xl" />
    </a>
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment