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\User;
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\Video;
35
36/**
37 * Class DeletedVideosMethod
38 * @package Lib\ApiMethods
39 */
40final class DeletedVideosMethod
41{
42    private const ACTION = 'deleted_videos';
43
44    /**
45     * deleted_videos
46     * This returns video objects that have been deleted
47     *
48     * @param array $input
49     * offset = (integer) //optional
50     * limit  = (integer) //optional
51     * @return bool
52     */
53    public static function deleted_videos(array $input)
54    {
55        if (!AmpConfig::get('allow_video')) {
56            Api::error(T_('Enable: video'), '4703', self::ACTION, 'system', $input['api_format']);
57
58            return false;
59        }
60
61        $video_ids = Video::get_deleted();
62        if (empty($video_ids)) {
63            Api::empty('deleted_videos', $input['api_format']);
64
65            return false;
66        }
67
68        ob_end_clean();
69        switch ($input['api_format']) {
70            case 'json':
71                Json_Data::set_offset($input['offset']);
72                Json_Data::set_limit($input['limit']);
73                echo Json_Data::deleted('video', $video_ids);
74                break;
75            default:
76                Xml_Data::set_offset($input['offset']);
77                Xml_Data::set_limit($input['limit']);
78                echo Xml_Data::deleted('video', $video_ids);
79        }
80        Session::extend($input['auth']);
81
82        return true;
83    }
84}
85