*/
use Friendica\App;
-use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
function network_init(App $a)
{
if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
return;
}
$a->page_contact = $a->contact;
if (!is_array($items)) {
- Logger::log("Expecting items to be an array. Got " . print_r($items, true));
+ Logger::info('Expecting items to be an array.', ['items' => $items]);
$items = [];
}
}
if ($o === '') {
- info("No items found");
+ notice(DI::l10n()->t("No items found"));
}
return $o;
}
$sql_nets = (($nets) ? sprintf(" AND $sql_table.`network` = '%s' ", DBA::escape($nets)) : '');
- $sql_tag_nets = (($nets) ? sprintf(" AND `item`.`network` = '%s' ", DBA::escape($nets)) : '');
if ($gid) {
$group = DBA::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]);
if ($update) {
exit();
}
- notice(DI::l10n()->t('No such group') . EOL);
+ notice(DI::l10n()->t('No such group'));
DI::baseUrl()->redirect('network/0');
// NOTREACHED
}
$sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '" . Strings::protectSprintf('%<' . intval($gid) . '>%') . "' AND `temp1`.`private`))";
} else {
$sql_extra3 .= " AND false ";
- info(DI::l10n()->t('Group is empty'));
+ notice(DI::l10n()->t('Group is empty'));
}
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [
'id' => 'network',
'name' => $contact['name'],
'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'],
- 'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact),
'details' => $contact['location'],
];
'id' => 'network',
]) . $o;
} else {
- notice(DI::l10n()->t('Invalid contact.') . EOL);
+ notice(DI::l10n()->t('Invalid contact.'));
DI::baseUrl()->redirect('network');
// NOTREACHED
}
);
}
- // Only show it when unfiltered (no groups, no networks, ...)
- if (in_array($nets, ['', Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
- if (DBA::isResult($r)) {
- $top_limit = current($r)['order_date'];
- $bottom_limit = end($r)['order_date'];
- if (empty($_SESSION['network_last_top_limit']) || ($_SESSION['network_last_top_limit'] < $top_limit)) {
- $_SESSION['network_last_top_limit'] = $top_limit;
- }
- } else {
- $top_limit = $bottom_limit = DateTimeFormat::utcNow();
- }
-
- // When checking for updates we need to fetch from the newest date to the newest date before
- // Only do this, when the last stored date isn't too long ago (10 times the update interval)
- $browser_update = DI::pConfig()->get(local_user(), 'system', 'update_interval', 40000) / 1000;
-
- if (($browser_update > 0) && $update && !empty($_SESSION['network_last_date']) &&
- (($bottom_limit < $_SESSION['network_last_date']) || ($top_limit == $bottom_limit)) &&
- ((time() - $_SESSION['network_last_date_timestamp']) < ($browser_update * 10))) {
- $bottom_limit = $_SESSION['network_last_date'];
- }
- $_SESSION['network_last_date'] = Session::get('network_last_top_limit', $top_limit);
- $_SESSION['network_last_date_timestamp'] = time();
-
- if ($last_date > $top_limit) {
- $top_limit = $last_date;
- } elseif ($pager->getPage() == 1) {
- // Highest possible top limit when we are on the first page
- $top_limit = DateTimeFormat::utcNow();
- }
-
- // Handle bad performance situations when the distance between top and bottom is too high
- // See issue https://github.com/friendica/friendica/issues/8619
- if (strtotime($top_limit) - strtotime($bottom_limit) > 86400) {
- // Set the bottom limit to one day in the past at maximum
- $bottom_limit = DateTimeFormat::utc(date('c', strtotime($top_limit) - 86400));
- }
-
- $items = DBA::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item`
- STRAIGHT_JOIN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` IN
- (SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `uid` = 0) AS `tag-search`
- ON `item`.`uri-id` = `tag-search`.`uri-id`
- STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
- WHERE `item`.`uid` = 0 AND `item`.$ordering < ? AND `item`.$ordering > ? AND `item`.`gravity` = ?
- AND NOT `author`.`hidden` AND NOT `author`.`blocked`" . $sql_tag_nets,
- local_user(), $top_limit, $bottom_limit, GRAVITY_PARENT);
-
- $data = DBA::toArray($items);
-
- if (count($data) > 0) {
- $tag_top_limit = current($data)['order_date'];
- if ($_SESSION['network_last_date'] < $tag_top_limit) {
- $_SESSION['network_last_date'] = $tag_top_limit;
- }
-
- Logger::log('Tagged items: ' . count($data) . ' - ' . $bottom_limit . ' - ' . $top_limit . ' - ' . local_user().' - '.(int)$update);
- $s = [];
- foreach ($r as $item) {
- $s[$item['uri']] = $item;
- }
- foreach ($data as $item) {
- // Don't show hash tag posts from blocked or ignored contacts
- $condition = ["`nurl` = ? AND `uid` = ? AND (`blocked` OR `readonly`)",
- Strings::normaliseLink($item['author-link']), local_user()];
- if (!DBA::exists('contact', $condition)) {
- $s[$item['uri']] = $item;
- }
- }
- $r = $s;
- }
- }
-
$parents_str = '';
$date_offset = '';