Move mod/filerm to src/Module/FilerM
This commit is contained in:
parent
0046e62077
commit
a052b098fc
4 changed files with 55 additions and 43 deletions
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Model\FileTag;
|
|
||||||
use Friendica\Util\XML;
|
|
||||||
|
|
||||||
function filerm_content(App $a)
|
|
||||||
{
|
|
||||||
if (! local_user())
|
|
||||||
{
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
|
||||||
$cat = XML::unescape(trim(defaults($_GET, 'cat', '')));
|
|
||||||
|
|
||||||
$category = (($cat) ? true : false);
|
|
||||||
|
|
||||||
if ($category)
|
|
||||||
{
|
|
||||||
$term = $cat;
|
|
||||||
}
|
|
||||||
|
|
||||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
|
||||||
|
|
||||||
Logger::log('filerm: tag ' . $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');
|
|
||||||
}
|
|
||||||
|
|
||||||
$a->internalRedirect('/network?f=&file=' . rawurlencode($term));
|
|
||||||
exit();
|
|
||||||
}
|
|
|
@ -109,7 +109,8 @@ class Router
|
||||||
$collector->addRoute(['GET'], '/{guid}/status_message', Module\Diaspora\Fetch::class);
|
$collector->addRoute(['GET'], '/{guid}/status_message', Module\Diaspora\Fetch::class);
|
||||||
$collector->addRoute(['GET'], '/{guid}/reshare', Module\Diaspora\Fetch::class);
|
$collector->addRoute(['GET'], '/{guid}/reshare', Module\Diaspora\Fetch::class);
|
||||||
});
|
});
|
||||||
$this->routeCollector->addRoute(['GET'], '/filer[/{id:\d+}]', Module\Filer::class);
|
$this->routeCollector->addRoute(['GET'], '/filer[/{id:\d+}]', Module\Filer\SaveTag::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/filerm/{id:\d+}', Module\Filer\RemoveTag::class);
|
||||||
$this->routeCollector->addRoute(['GET'], '/followers/{owner}', Module\Followers::class);
|
$this->routeCollector->addRoute(['GET'], '/followers/{owner}', Module\Followers::class);
|
||||||
$this->routeCollector->addRoute(['GET'], '/following/{owner}', Module\Following::class);
|
$this->routeCollector->addRoute(['GET'], '/following/{owner}', Module\Following::class);
|
||||||
$this->routeCollector->addGroup('/group', function (RouteCollector $collector) {
|
$this->routeCollector->addGroup('/group', function (RouteCollector $collector) {
|
||||||
|
|
51
src/Module/Filer/RemoveTag.php
Normal file
51
src/Module/Filer/RemoveTag.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?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(defaults($_GET, 'term', '')));
|
||||||
|
$cat = XML::unescape(trim(defaults($_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?f=&file=' . rawurlencode($term));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module\Filer;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -12,7 +12,7 @@ use Friendica\Util\XML;
|
||||||
/**
|
/**
|
||||||
* Shows a dialog for adding tags to a file
|
* Shows a dialog for adding tags to a file
|
||||||
*/
|
*/
|
||||||
class Filer extends BaseModule
|
class SaveTag extends BaseModule
|
||||||
{
|
{
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
Loading…
Reference in a new issue