1<?php 2/* 3 * vim:set softtabstop=4 shiftwidth=4 expandtab: 4 * 5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later) 6 * Copyright 2001 - 2020 Ampache.org 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23declare(strict_types=0); 24 25namespace Ampache\Module\Application\Stats; 26 27use Ampache\Config\ConfigContainerInterface; 28use Ampache\Config\ConfigurationKeyEnum; 29use Ampache\Module\System\Core; 30use Ampache\Repository\Model\ModelFactoryInterface; 31use Ampache\Repository\Model\Share; 32use Ampache\Module\Application\ApplicationActionInterface; 33use Ampache\Module\Authorization\GuiGatekeeperInterface; 34use Ampache\Module\Util\Ui; 35use Ampache\Module\Util\UiInterface; 36use Psr\Http\Message\ResponseInterface; 37use Psr\Http\Message\ServerRequestInterface; 38 39final class ShareAction implements ApplicationActionInterface 40{ 41 public const REQUEST_KEY = 'share'; 42 43 private UiInterface $ui; 44 45 private ModelFactoryInterface $modelFactory; 46 47 private ConfigContainerInterface $configContainer; 48 49 public function __construct( 50 UiInterface $ui, 51 ModelFactoryInterface $modelFactory, 52 ConfigContainerInterface $configContainer 53 ) { 54 $this->ui = $ui; 55 $this->modelFactory = $modelFactory; 56 $this->configContainer = $configContainer; 57 } 58 59 public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface 60 { 61 $this->ui->showHeader(); 62 63 define('TABLE_RENDERED', 1); 64 65 // Temporary workaround to avoid sorting on custom base requests 66 define('NO_BROWSE_SORTING', true); 67 68 $this->ui->showBoxTop(T_('Shares')); 69 70 $text = <<<TEXT 71 <div id="information_actions"> 72 <ul> 73 <li> 74 <a href="%s/share.php?action=clean">%s %s</a> 75 </li> 76 </ul> 77 </div> 78 TEXT; 79 80 printf( 81 $text, 82 $this->configContainer->getWebPath(), 83 Ui::get_icon('clean', T_('Clean')), 84 T_('Clean Expired Shared Objects') 85 ); 86 $user = Core::get_global('user'); 87 $object_ids = ($user->id) 88 ? Share::get_share_list($user) 89 : array(); 90 91 $browse = $this->modelFactory->createBrowse(); 92 $browse->set_type('share'); 93 $browse->set_static_content(true); 94 $browse->save_objects($object_ids); 95 $browse->show_objects($object_ids); 96 $browse->store(); 97 98 $this->ui->showBoxBottom(); 99 100 show_table_render(false, true); 101 102 $this->ui->showQueryStats(); 103 $this->ui->showFooter(); 104 105 return null; 106 } 107} 108