1<?php
2
3/*
4 * vim:set softtabstop=4 shiftwidth=4 expandtab:
5 *
6 *  LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later)
7 * Copyright 2001 - 2020 Ampache.org
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21 *
22 */
23
24declare(strict_types=0);
25
26namespace Ampache\Module\Api\Method;
27
28use Ampache\Config\AmpConfig;
29use Ampache\Repository\Model\Podcast;
30use Ampache\Module\Api\Api;
31use Ampache\Module\Api\Json_Data;
32use Ampache\Module\Api\Xml_Data;
33use Ampache\Module\System\Session;
34use Ampache\Repository\Model\Podcast_Episode;
35use Ampache\Repository\Model\User;
36
37/**
38 * Class DeletedPodcastEpisodesMethod
39 * @package Lib\ApiMethods
40 */
41final class DeletedPodcastEpisodesMethod
42{
43    private const ACTION = 'deleted_podcast_episodes';
44
45    /**
46     * deleted_podcast_episodes
47     * MINIMUM_API_VERSION=420000
48     *
49     * This returns the episodes for a podcast that have been deleted
50     *
51     * @param array $input
52     * offset = (integer) //optional
53     * limit  = (integer) //optional
54     * @return boolean
55     */
56    public static function deleted_podcast_episodes(array $input)
57    {
58        if (!AmpConfig::get('podcast')) {
59            Api::error(T_('Enable: podcast'), '4703', self::ACTION, 'system', $input['api_format']);
60
61            return false;
62        }
63        $items = Podcast_Episode::get_deleted();
64        if (empty($items)) {
65            Api::empty('deleted_podcast_episodes', $input['api_format']);
66
67            return false;
68        }
69
70        ob_end_clean();
71        switch ($input['api_format']) {
72            case 'json':
73                JSON_Data::set_offset($input['offset']);
74                JSON_Data::set_limit($input['limit']);
75                echo JSON_Data::deleted('podcast_episode', $items);
76                break;
77            default:
78                XML_Data::set_offset($input['offset']);
79                XML_Data::set_limit($input['limit']);
80                echo XML_Data::deleted('podcast_episode', $items);
81        }
82        Session::extend($input['auth']);
83
84        return true;
85    }
86}
87