mirror of
https://github.com/friendica/friendica
synced 2025-04-24 22:30:11 +00:00
Add new module and widget for managing saved searches
This commit is contained in:
parent
11ad0acd28
commit
cdefa7f32a
11 changed files with 140 additions and 152 deletions
40
src/Module/Search/Saved.php
Normal file
40
src/Module/Search/Saved.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Search;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
class Saved extends BaseModule
|
||||
{
|
||||
public static function rawContent()
|
||||
{
|
||||
$action = self::getArgs()->get(2, 'none');
|
||||
$search = Strings::escapeTags(trim(rawurldecode(self::getArgs()->get(3, ''))));
|
||||
|
||||
$return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search);
|
||||
|
||||
if (local_user()) {
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$fields = ['uid' => local_user(), 'term' => $search];
|
||||
if (!DBA::exists('search', $fields)) {
|
||||
DBA::insert('search', $fields);
|
||||
info(L10n::t('Search term successfully saved.'));
|
||||
} else {
|
||||
info(L10n::t('Search term already saved.'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'remove':
|
||||
DBA::delete('search', ['uid' => local_user(), 'term' => $search]);
|
||||
info(L10n::t('Search term successfully removed.'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self::getApp()->internalRedirect($return_url);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue