mirror of
https://github.com/friendica/friendica
synced 2025-04-26 06:30:11 +00:00
old boot.php functions replaced in src/module (4)
This commit is contained in:
parent
de6eabde58
commit
d47d78f2d4
22 changed files with 140 additions and 158 deletions
|
@ -27,6 +27,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -51,7 +52,7 @@ class Acl extends BaseModule
|
|||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
|
||||
}
|
||||
|
||||
|
@ -113,8 +114,8 @@ class Acl extends BaseModule
|
|||
Logger::info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
|
||||
|
||||
$sql_extra = '';
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", local_user()];
|
||||
$condition_group = ["`uid` = ? AND NOT `deleted`", local_user()];
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", Session::getLocalUser()];
|
||||
$condition_group = ["`uid` = ? AND NOT `deleted`", Session::getLocalUser()];
|
||||
|
||||
if ($search != '') {
|
||||
$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
|
||||
|
@ -176,7 +177,7 @@ class Acl extends BaseModule
|
|||
GROUP BY `group`.`name`, `group`.`id`
|
||||
ORDER BY `group`.`name`
|
||||
LIMIT ?, ?",
|
||||
local_user(),
|
||||
Session::getLocalUser(),
|
||||
$start,
|
||||
$count
|
||||
));
|
||||
|
@ -251,7 +252,7 @@ class Acl extends BaseModule
|
|||
|
||||
$condition = ["`parent` = ?", $conv_id];
|
||||
$params = ['order' => ['author-name' => true]];
|
||||
$authors = Post::selectForUser(local_user(), ['author-link'], $condition, $params);
|
||||
$authors = Post::selectForUser(Session::getLocalUser(), ['author-link'], $condition, $params);
|
||||
$item_authors = [];
|
||||
while ($author = Post::fetch($authors)) {
|
||||
$item_authors[$author['author-link']] = $author['author-link'];
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Module\Search;
|
||||
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseSearch;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
@ -33,7 +34,7 @@ class Directory extends BaseSearch
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return Login::form();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Content\Pager;
|
|||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -38,13 +39,13 @@ class Filed extends BaseSearch
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
|
||||
|
||||
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
} else {
|
||||
|
@ -59,10 +60,10 @@ class Filed extends BaseSearch
|
|||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@ class Filed extends BaseSearch
|
|||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
|
||||
|
||||
$term_condition = ['type' => Category::FILE, 'uid' => local_user()];
|
||||
$term_condition = ['type' => Category::FILE, 'uid' => Session::getLocalUser()];
|
||||
if ($file) {
|
||||
$term_condition['name'] = $file;
|
||||
}
|
||||
|
@ -93,14 +94,14 @@ class Filed extends BaseSearch
|
|||
if (count($posts) == 0) {
|
||||
return '';
|
||||
}
|
||||
$item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts];
|
||||
$item_condition = ['uid' => [0, Session::getLocalUser()], 'uri-id' => $posts];
|
||||
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
|
||||
|
||||
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
|
||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
|
||||
|
||||
$o .= DI::conversation()->create($items, 'filed', false, false, '', local_user());
|
||||
$o .= DI::conversation()->create($items, 'filed', false, false, '', Session::getLocalUser());
|
||||
|
||||
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$o .= $pager->renderMinimal($count);
|
||||
|
|
|
@ -94,7 +94,7 @@ class Index extends BaseSearch
|
|||
}
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
if (Session::getLocalUser()) {
|
||||
DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search);
|
||||
}
|
||||
|
||||
|
@ -161,10 +161,10 @@ class Index extends BaseSearch
|
|||
// No items will be shown if the member has a blocked profile wall.
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -174,19 +174,19 @@ class Index extends BaseSearch
|
|||
|
||||
if ($tag) {
|
||||
Logger::info('Start tag search.', ['q' => $search]);
|
||||
$uriids = Tag::getURIIdListByTag($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Tag::countByTag($search, local_user());
|
||||
$uriids = Tag::getURIIdListByTag($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Tag::countByTag($search, Session::getLocalUser());
|
||||
} else {
|
||||
Logger::info('Start fulltext search.', ['q' => $search]);
|
||||
$uriids = Post\Content::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Post\Content::countBySearch($search, local_user());
|
||||
$uriids = Post\Content::getURIIdListBySearch($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Post\Content::countBySearch($search, Session::getLocalUser());
|
||||
}
|
||||
|
||||
if (!empty($uriids)) {
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()];
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, Session::getLocalUser()];
|
||||
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
|
||||
$params = ['order' => ['id' => true]];
|
||||
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
}
|
||||
|
||||
if (empty($items)) {
|
||||
|
@ -196,7 +196,7 @@ class Index extends BaseSearch
|
|||
return $o;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
}
|
||||
|
@ -213,9 +213,9 @@ class Index extends BaseSearch
|
|||
|
||||
Logger::info('Start Conversation.', ['q' => $search]);
|
||||
|
||||
$o .= DI::conversation()->create($items, 'search', false, false, 'commented', local_user());
|
||||
$o .= DI::conversation()->create($items, 'search', false, false, 'commented', Session::getLocalUser());
|
||||
|
||||
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$o .= $pager->renderMinimal($count);
|
||||
|
@ -254,9 +254,9 @@ class Index extends BaseSearch
|
|||
$search = $matches[1];
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
if (Session::getLocalUser()) {
|
||||
// User-specific contact URL/address search
|
||||
$contact_id = Contact::getIdForURL($search, local_user());
|
||||
$contact_id = Contact::getIdForURL($search, Session::getLocalUser());
|
||||
if (!$contact_id) {
|
||||
// User-specific contact URL/address search and probe
|
||||
$contact_id = Contact::getIdForURL($search);
|
||||
|
@ -293,9 +293,9 @@ class Index extends BaseSearch
|
|||
|
||||
$search = Network::convertToIdn($search);
|
||||
|
||||
if (local_user()) {
|
||||
if (Session::getLocalUser()) {
|
||||
// Post URL search
|
||||
$item_id = Item::fetchByLink($search, local_user());
|
||||
$item_id = Item::fetchByLink($search, Session::getLocalUser());
|
||||
if (!$item_id) {
|
||||
// If the user-specific search failed, we search and probe a public post
|
||||
$item_id = Item::fetchByLink($search);
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Response;
|
||||
|
@ -50,10 +51,10 @@ class Saved extends BaseModule
|
|||
|
||||
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
|
||||
|
||||
if (local_user() && $search) {
|
||||
if (Session::getLocalUser() && $search) {
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$fields = ['uid' => local_user(), 'term' => $search];
|
||||
$fields = ['uid' => Session::getLocalUser(), 'term' => $search];
|
||||
if (!$this->dba->exists('search', $fields)) {
|
||||
if (!$this->dba->insert('search', $fields)) {
|
||||
DI::sysmsg()->addNotice($this->t('Search term was not saved.'));
|
||||
|
@ -64,7 +65,7 @@ class Saved extends BaseModule
|
|||
break;
|
||||
|
||||
case 'remove':
|
||||
if (!$this->dba->delete('search', ['uid' => local_user(), 'term' => $search])) {
|
||||
if (!$this->dba->delete('search', ['uid' => Session::getLocalUser(), 'term' => $search])) {
|
||||
DI::sysmsg()->addNotice($this->t('Search term was not removed.'));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue