. * */ namespace Friendica\Module\Filer; use Friendica\BaseModule; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Post; use Friendica\Network\HTTPException; use Friendica\Util\XML; /** * Remove a tag from a file */ class RemoveTag extends BaseModule { public static function content(array $parameters = []) { if (!local_user()) { throw new HTTPException\ForbiddenException(); } $app = DI::app(); $logger = DI::logger(); $item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0); $term = XML::unescape(trim($_GET['term'] ?? '')); $cat = XML::unescape(trim($_GET['cat'] ?? '')); if (!empty($cat)) { $type = Post\Category::CATEGORY; $term = $cat; } else { $type = Post\Category::FILE; } $logger->info('Filer - Remove Tag', [ 'term' => $term, 'item' => $item_id, 'type' => $type ]); if ($item_id && strlen($term)) { $item = Post::selectFirst(['uri-id'], ['id' => $item_id]); if (!DBA::isResult($item)) { return; } if (!Post\Category::deleteFileByURIId($item['uri-id'], local_user(), $type, $term)) { notice(DI::l10n()->t('Item was not removed')); } } else { notice(DI::l10n()->t('Item was not deleted')); } if ($type == Post\Category::FILE) { DI::baseUrl()->redirect('filed?file=' . rawurlencode($term)); } } }