Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
1.0 KiB

<?php
namespace Friendica\Module\Filer;
use Friendica\BaseModule;
use Friendica\Model\FileTag;
use Friendica\Network\HTTPException;
use Friendica\Util\XML;
/**
* Remove a tag from a file
*/
class RemoveTag extends BaseModule
{
public static function content()
{
if (!local_user()) {
throw new HTTPException\ForbiddenException();
}
$app = self::getApp();
$logger = $app->getLogger();
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);
$term = XML::unescape(trim($_GET['term'] ?? ''));
$cat = XML::unescape(trim($_GET['cat'] ?? ''));
$category = (($cat) ? true : false);
if ($category) {
$term = $cat;
}
$logger->info('Filer - Remove Tag', [
'term' => $term,
'item' => $item_id,
'category' => ($category ? 'true' : 'false')
]);
if ($item_id && strlen($term)) {
if (FileTag::unsaveFile(local_user(), $item_id, $term, $category)) {
info('Item removed');
}
} else {
info('Item was not deleted');
}
$app->internalRedirect('network?file=' . rawurlencode($term));
}
}