1
1
Fork 0

Merge pull request #10543 from annando/app-variables

App variables reduced and removed
This commit is contained in:
Hypolite Petovan 2021-07-25 08:56:05 -04:00 committed by GitHub
commit 69c75daf4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 532 additions and 552 deletions

View file

@ -297,13 +297,11 @@ function notice($s)
return; return;
} }
$a = DI::app();
if (empty($_SESSION['sysmsg'])) { if (empty($_SESSION['sysmsg'])) {
$_SESSION['sysmsg'] = []; $_SESSION['sysmsg'] = [];
} }
if ($a->interactive) {
$_SESSION['sysmsg'][] = $s; $_SESSION['sysmsg'][] = $s;
}
} }
/** /**
@ -315,14 +313,15 @@ function notice($s)
*/ */
function info($s) function info($s)
{ {
$a = DI::app(); if (empty($_SESSION)) {
return;
}
if (empty($_SESSION['sysmsg_info'])) { if (empty($_SESSION['sysmsg_info'])) {
$_SESSION['sysmsg_info'] = []; $_SESSION['sysmsg_info'] = [];
} }
if ($a->interactive) {
$_SESSION['sysmsg_info'][] = $s; $_SESSION['sysmsg_info'][] = $s;
}
} }
function feed_birthday($uid, $tz) function feed_birthday($uid, $tz)

View file

@ -599,7 +599,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
'$remove' => DI::l10n()->t('remove'), '$remove' => DI::l10n()->t('remove'),
'$mode' => $mode, '$mode' => $mode,
'$update' => $update, '$update' => $update,
'$user' => $a->user,
'$threads' => $threads, '$threads' => $threads,
'$dropping' => ($page_dropping ? DI::l10n()->t('Delete Selected Items') : False), '$dropping' => ($page_dropping ? DI::l10n()->t('Delete Selected Items') : False),
]); ]);
@ -1134,7 +1133,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$jotplugins' => $jotplugins, '$jotplugins' => $jotplugins,
'$notes_cid' => $notes_cid, '$notes_cid' => $notes_cid,
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$cancel' => DI::l10n()->t('Cancel'), '$cancel' => DI::l10n()->t('Cancel'),
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),

View file

@ -25,13 +25,11 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
@ -52,52 +50,34 @@ function cal_init(App $a)
Nav::setSelected('events'); Nav::setSelected('events');
$nick = $a->argv[1];
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException();
}
$a->data['user'] = $user;
$a->profile_uid = $user['uid'];
// if it's a json request abort here becaus we don't // if it's a json request abort here becaus we don't
// need the widget data // need the widget data
if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
return; return;
} }
$a->profile = User::getOwnerDataByNick($nick); $owner = User::getOwnerDataByNick($a->argv[1]);
if (empty($a->profile)) { if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$account_type = Contact::getAccountType($a->profile);
$tpl = Renderer::getMarkupTemplate('widget/vcard.tpl');
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $a->profile['name'],
'$photo' => $a->profile['photo'],
'$addr' => $a->profile['addr'] ?: '',
'$account_type' => $account_type,
'$about' => BBCode::convert($a->profile['about']),
]);
$cal_widget = Widget\CalendarExport::getHTML($user['uid']);
if (empty(DI::page()['aside'])) { if (empty(DI::page()['aside'])) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';
} }
DI::page()['aside'] .= $vcard_widget; DI::page()['aside'] .= Widget\VCard::getHTML($owner);
DI::page()['aside'] .= $cal_widget; DI::page()['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);
return; return;
} }
function cal_content(App $a) function cal_content(App $a)
{ {
$owner = User::getOwnerDataByNick($a->argv[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
Nav::setSelected('events'); Nav::setSelected('events');
// get the translation strings for the callendar // get the translation strings for the callendar
@ -110,7 +90,7 @@ function cal_content(App $a)
$htpl = Renderer::getMarkupTemplate('event_head.tpl'); $htpl = Renderer::getMarkupTemplate('event_head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
'$module_url' => '/cal/' . $a->data['user']['nickname'], '$module_url' => '/cal/' . $owner['nickname'],
'$modparams' => 2, '$modparams' => 2,
'$i18n' => $i18n, '$i18n' => $i18n,
]); ]);
@ -127,19 +107,16 @@ function cal_content(App $a)
} }
// Setup permissions structures // Setup permissions structures
$owner_uid = intval($a->data['user']['uid']); $owner_uid = intval($owner['uid']);
$nick = $a->data['user']['nickname']; $nick = $owner['nickname'];
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$contact_id = Session::getRemoteContactID($a->profile['uid']); $contact_id = Session::getRemoteContactID($owner['uid']);
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $a->profile['uid']]); $remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
$is_owner = local_user() == $a->profile['uid']; $is_owner = local_user() == $owner['uid'];
if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) { if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
notice(DI::l10n()->t('Access to this profile has been restricted.')); notice(DI::l10n()->t('Access to this profile has been restricted.'));
return; return;
} }
@ -150,7 +127,7 @@ function cal_content(App $a)
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms; $sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
// get the tab navigation bar // get the tab navigation bar
$tabs = BaseProfile::getTabsHTML($a, 'cal', false, $a->data['user']['nickname']); $tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner);
// The view mode part is similiar to /mod/events.php // The view mode part is similiar to /mod/events.php
if ($mode == 'view') { if ($mode == 'view') {

View file

@ -32,6 +32,7 @@ use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\ActivityPub\Objects; use Friendica\Module\ActivityPub\Objects;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -53,17 +54,17 @@ function display_init(App $a)
$item = null; $item = null;
$item_user = local_user(); $item_user = local_user();
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'body', 'uid', 'guid', 'gravity']; $fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
// If there is only one parameter, then check if this parameter could be a guid // If there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) { if ($a->argc == 2) {
$nick = ""; $nick = '';
// Does the local user have this item? // Does the local user have this item?
if (local_user()) { if (local_user()) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]); $item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$nick = $a->user["nickname"]; $nick = $a->user['nickname'];
} }
} }
@ -109,41 +110,29 @@ function display_init(App $a)
$item = $parent ?: $item; $item = $parent ?: $item;
} }
$profiledata = display_fetchauthor($a, $item); $profiledata = display_fetchauthor($item);
if (strstr(Strings::normaliseLink($profiledata['url']), Strings::normaliseLink(DI::baseUrl()))) {
$nickname = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/profile/', '', Strings::normaliseLink($profiledata['url']));
if (!empty($a->user['nickname']) && $nickname != $a->user['nickname']) {
$profile = DBA::selectFirst('owner-view', [], ['nickname' => $nickname]);
if (DBA::isResult($profile)) {
$profiledata = $profile;
}
$profiledata["network"] = Protocol::DFRN;
} else {
$profiledata = [];
}
}
DI::page()['aside'] = Widget\VCard::getHTML($profiledata); DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
} }
function display_fetchauthor($a, $item) function display_fetchauthor($item)
{ {
$author = DBA::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]); $profiledata = Contact::getByURLForUser($item['author-link'], local_user());
$profiledata = [];
$profiledata['uid'] = -1;
$profiledata['nickname'] = $author['nick'];
$profiledata['name'] = $author['name'];
$profiledata['picdate'] = '';
$profiledata['photo'] = $author['photo'];
$profiledata['url'] = $author['url'];
$profiledata['network'] = $author['network'];
// Check for a repeated message // Check for a repeated message
$shared = Item::getShareArray($item); $shared = Item::getShareArray($item);
if (!empty($shared) && empty($shared['comment'])) { if (!empty($shared) && empty($shared['comment'])) {
$profiledata = [
'uid' => -1,
'id' => -1,
'nickname' => '',
'name' => '',
'picdate' => '',
'photo' => '',
'url' => '',
'network' => '',
];
if (!empty($shared['author'])) { if (!empty($shared['author'])) {
$profiledata['name'] = $shared['author']; $profiledata['name'] = $shared['author'];
} }
@ -156,17 +145,17 @@ function display_fetchauthor($a, $item)
$profiledata['photo'] = $shared['avatar']; $profiledata['photo'] = $shared['avatar'];
} }
$profiledata["nickname"] = $profiledata["name"]; $profiledata['nickname'] = $profiledata['name'];
$profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]); $profiledata['network'] = Protocol::matchByProfileUrl($profiledata['url']);
$profiledata["address"] = ""; $profiledata['address'] = '';
$profiledata["about"] = ""; $profiledata['about'] = '';
$profiledata = Contact::getByURLForUser($profiledata['url'], local_user()) ?: $profiledata;
} }
$profiledata = Contact::getByURLForUser($profiledata["url"], local_user()) ?: $profiledata; if (!empty($profiledata['photo'])) {
$profiledata['photo'] = DI::baseUrl()->remove($profiledata['photo']);
if (!empty($profiledata["photo"])) {
$profiledata["photo"] = DI::baseUrl()->remove($profiledata["photo"]);
} }
return $profiledata; return $profiledata;
@ -189,9 +178,9 @@ function display_content(App $a, $update = false, $update_uid = 0)
$item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]); $item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]);
if (!empty($item)) { if (!empty($item)) {
if ($item['uid'] != 0) { if ($item['uid'] != 0) {
$a->profile = ['uid' => intval($item['uid'])]; $a->setProfileOwner($item['uid']);
} else { } else {
$a->profile = ['uid' => intval($update_uid)]; $a->setProfileOwner($update_uid);
} }
$parent_uri_id = $item['parent-uri-id']; $parent_uri_id = $item['parent-uri-id'];
} }
@ -273,14 +262,13 @@ function display_content(App $a, $update = false, $update_uid = 0)
$page_uid = $item['uid']; $page_uid = $item['uid'];
} }
$page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $page_uid]); if (!empty($page_uid) && ($page_uid != local_user())) {
if (DBA::isResult($page_contact)) { $page_user = User::getById($page_uid);
$a->page_contact = $page_contact;
} }
$is_owner = (local_user() && (in_array($page_uid, [local_user(), 0])) ? true : false); $is_owner = local_user() && (in_array($page_uid, [local_user(), 0]));
if (!empty($a->profile['hidewall']) && !$is_owner && !$is_remote_contact) { if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
} }
@ -334,13 +322,13 @@ function display_content(App $a, $update = false, $update_uid = 0)
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid); $o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid);
// Preparing the meta header // Preparing the meta header
$description = trim(BBCode::toPlaintext($item["body"])); $description = trim(BBCode::toPlaintext($item['body']));
$title = trim(BBCode::toPlaintext($item["title"])); $title = trim(BBCode::toPlaintext($item['title']));
$author_name = $item["author-name"]; $author_name = $item['author-name'];
$image = DI::baseUrl()->remove($item["author-avatar"]); $image = DI::baseUrl()->remove($item['author-avatar']);
if ($title == "") { if ($title == '') {
$title = $author_name; $title = $author_name;
} }

View file

@ -124,7 +124,6 @@ function editpost_content(App $a)
'$profile_uid' => $_SESSION['uid'], '$profile_uid' => $_SESSION['uid'],
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$jotplugins' => $jotplugins, '$jotplugins' => $jotplugins,
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$cancel' => DI::l10n()->t('Cancel'), '$cancel' => DI::l10n()->t('Cancel'),
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),

View file

@ -280,7 +280,7 @@ function events_content(App $a)
$tabs = ''; $tabs = '';
// tabs // tabs
if ($a->theme_events_in_profile) { if ($a->theme_events_in_profile) {
$tabs = BaseProfile::getTabsHTML($a, 'events', true); $tabs = BaseProfile::getTabsHTML($a, 'events', true, $a->user);
} }
$mode = 'view'; $mode = 'view';

View file

@ -45,7 +45,7 @@ function notes_content(App $a, $update = false)
return; return;
} }
$o = BaseProfile::getTabsHTML($a, 'notes', true); $o = BaseProfile::getTabsHTML($a, 'notes', true, $a->user);
if (!$update) { if (!$update) {
$o .= '<h3>' . DI::l10n()->t('Personal Notes') . '</h3>'; $o .= '<h3>' . DI::l10n()->t('Personal Notes') . '</h3>';
@ -64,11 +64,11 @@ function notes_content(App $a, $update = false)
'acl_data' => '', 'acl_data' => '',
]; ];
$o .= status_editor($a, $x, $a->contact['id']); $o .= status_editor($a, $x, $a->getContactId());
} }
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT, $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'contact-id'=> $a->contact['id']]; 'contact-id'=> $a->getContactId()];
if (DI::mode()->isMobile()) { if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',

View file

@ -24,6 +24,7 @@ use Friendica\Content\Feature;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
use Friendica\Core\ACL; use Friendica\Core\ACL;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -51,6 +52,7 @@ use Friendica\Security\Security;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Network\HTTPException;
function photos_init(App $a) { function photos_init(App $a) {
@ -61,41 +63,18 @@ function photos_init(App $a) {
Nav::setSelected('home'); Nav::setSelected('home');
if ($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $owner = User::getOwnerDataByNick($a->argv[1]);
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { $is_owner = (local_user() && (local_user() == $owner['uid']));
return;
}
$a->data['user'] = $user; $albums = Photo::getAlbums($owner['uid']);
$a->profile_uid = $user['uid'];
$is_owner = (local_user() && (local_user() == $a->profile_uid));
$profile = User::getOwnerDataByNick($nick); $albums_visible = ((intval($owner['hidewall']) && !Session::isAuthenticated()) ? false : true);
$account_type = Contact::getAccountType($profile);
$tpl = Renderer::getMarkupTemplate('widget/vcard.tpl');
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'],
'$photo' => $profile['photo'],
'$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
'$about' => BBCode::convert($profile['about']),
]);
$albums = Photo::getAlbums($a->data['user']['uid']);
$albums_visible = ((intval($a->data['user']['hidewall']) && !Session::isAuthenticated()) ? false : true);
// add various encodings to the array so we can just loop through and pick them out in a template // add various encodings to the array so we can just loop through and pick them out in a template
$ret = ['success' => false]; $ret = ['success' => false];
if ($albums) { if ($albums) {
$a->data['albums'] = $albums;
if ($albums_visible) { if ($albums_visible) {
$ret['success'] = true; $ret['success'] = true;
} }
@ -103,12 +82,12 @@ function photos_init(App $a) {
$ret['albums'] = []; $ret['albums'] = [];
foreach ($albums as $k => $album) { foreach ($albums as $k => $album) {
//hide profile photos to others //hide profile photos to others
if (!$is_owner && !Session::getRemoteContactID($a->profile_uid) && ($album['album'] == DI::l10n()->t('Profile Photos'))) if (!$is_owner && !Session::getRemoteContactID($owner['uid']) && ($album['album'] == DI::l10n()->t('Profile Photos')))
continue; continue;
$entry = [ $entry = [
'text' => $album['album'], 'text' => $album['album'],
'total' => $album['total'], 'total' => $album['total'],
'url' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'url' => 'photos/' . $owner['nickname'] . '/album/' . bin2hex($album['album']),
'urlencode' => urlencode($album['album']), 'urlencode' => urlencode($album['album']),
'bin2hex' => bin2hex($album['album']) 'bin2hex' => bin2hex($album['album'])
]; ];
@ -116,7 +95,7 @@ function photos_init(App $a) {
} }
} }
if (local_user() && $a->data['user']['uid'] == local_user()) { if (local_user() && $owner['uid'] == local_user()) {
$can_post = true; $can_post = true;
} else { } else {
$can_post = false; $can_post = false;
@ -124,11 +103,11 @@ function photos_init(App $a) {
if ($ret['success']) { if ($ret['success']) {
$photo_albums_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('photo_albums.tpl'), [ $photo_albums_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('photo_albums.tpl'), [
'$nick' => $a->data['user']['nickname'], '$nick' => $owner['nickname'],
'$title' => DI::l10n()->t('Photo Albums'), '$title' => DI::l10n()->t('Photo Albums'),
'$recent' => DI::l10n()->t('Recent Photos'), '$recent' => DI::l10n()->t('Recent Photos'),
'$albums' => $ret['albums'], '$albums' => $ret['albums'],
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'], '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $owner['nickname'] . '/upload'],
'$can_post' => $can_post '$can_post' => $can_post
]); ]);
} }
@ -137,7 +116,7 @@ function photos_init(App $a) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';
} }
DI::page()['aside'] .= $vcard_widget; DI::page()['aside'] .= Widget\VCard::getHTML($owner);
if (!empty($photo_albums_widget)) { if (!empty($photo_albums_widget)) {
DI::page()['aside'] .= $photo_albums_widget; DI::page()['aside'] .= $photo_albums_widget;
@ -155,13 +134,18 @@ function photos_init(App $a) {
function photos_post(App $a) function photos_post(App $a)
{ {
$user = User::getByNickname($a->argv[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$phototypes = Images::supportedTypes(); $phototypes = Images::supportedTypes();
$can_post = false; $can_post = false;
$visitor = 0; $visitor = 0;
$page_owner_uid = intval($a->data['user']['uid']); $page_owner_uid = intval($user['uid']);
$community_page = $a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY; $community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) { if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true; $can_post = true;
@ -203,7 +187,7 @@ function photos_post(App $a)
if ($a->argc > 3 && $a->argv[2] === 'album') { if ($a->argc > 3 && $a->argv[2] === 'album') {
if (!Strings::isHex($a->argv[3])) { if (!Strings::isHex($a->argv[3])) {
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
} }
$album = hex2bin($a->argv[3]); $album = hex2bin($a->argv[3]);
@ -219,13 +203,13 @@ function photos_post(App $a)
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
notice(DI::l10n()->t('Album not found.')); notice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
return; // NOTREACHED return; // NOTREACHED
} }
// Check if the user has responded to a delete confirmation query // Check if the user has responded to a delete confirmation query
if (!empty($_REQUEST['canceled'])) { if (!empty($_REQUEST['canceled'])) {
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album/' . $a->argv[3]); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album/' . $a->argv[3]);
} }
// RENAME photo album // RENAME photo album
@ -282,7 +266,7 @@ function photos_post(App $a)
} }
} }
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
} }
if ($a->argc > 3 && $a->argv[2] === 'image') { if ($a->argc > 3 && $a->argv[2] === 'image') {
@ -419,7 +403,7 @@ function photos_post(App $a)
$arr['visible'] = $visibility; $arr['visible'] = $visibility;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $photo['resource-id'] . ']' $arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $photo['resource-id'] . ']'
. '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $photo['scale'] . '.'. $ext . '[/img]' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $photo['scale'] . '.'. $ext . '[/img]'
. '[/url]'; . '[/url]';
@ -523,7 +507,7 @@ function photos_post(App $a)
if (!empty($item['uri-id'])) { if (!empty($item['uri-id'])) {
Tag::store($item['uri-id'], Tag::MENTION, $newname, $profile); Tag::store($item['uri-id'], Tag::MENTION, $newname, $profile);
} }
} }
} elseif (strpos($tag, '#') === 0) { } elseif (strpos($tag, '#') === 0) {
$tagname = substr($tag, 1); $tagname = substr($tag, 1);
@ -831,12 +815,17 @@ function photos_content(App $a)
// photos/name/image/xxxxx/edit // photos/name/image/xxxxx/edit
// photos/name/image/xxxxx/drop // photos/name/image/xxxxx/drop
$user = User::getByNickname($a->argv[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.')); notice(DI::l10n()->t('Public access denied.'));
return; return;
} }
if (empty($a->data['user'])) { if (empty($user)) {
notice(DI::l10n()->t('No photos selected')); notice(DI::l10n()->t('No photos selected'));
return; return;
} }
@ -871,9 +860,9 @@ function photos_content(App $a)
$edit = ''; $edit = '';
$drop = ''; $drop = '';
$owner_uid = $a->data['user']['uid']; $owner_uid = $user['uid'];
$community_page = (($a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if (local_user() && (local_user() == $owner_uid)) { if (local_user() && (local_user() == $owner_uid)) {
$can_post = true; $can_post = true;
@ -899,10 +888,11 @@ function photos_content(App $a)
if (!$remote_contact && local_user()) { if (!$remote_contact && local_user()) {
$contact_id = $_SESSION['cid']; $contact_id = $_SESSION['cid'];
$contact = $a->contact;
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
} }
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
notice(DI::l10n()->t('Access to this item is restricted.')); notice(DI::l10n()->t('Access to this item is restricted.'));
return; return;
} }
@ -913,7 +903,7 @@ function photos_content(App $a)
// tabs // tabs
$is_owner = (local_user() && (local_user() == $owner_uid)); $is_owner = (local_user() && (local_user() == $owner_uid));
$o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $a->data['user']['nickname']); $o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user);
// Display upload form // Display upload form
if ($datatype === 'upload') { if ($datatype === 'upload') {
@ -927,8 +917,9 @@ function photos_content(App $a)
$albumselect = ''; $albumselect = '';
$albumselect .= '<option value="" ' . (!$selname ? ' selected="selected" ' : '') . '>&lt;current year&gt;</option>'; $albumselect .= '<option value="" ' . (!$selname ? ' selected="selected" ' : '') . '>&lt;current year&gt;</option>';
if (!empty($a->data['albums'])) { $albums = Photo::getAlbums($owner_uid);
foreach ($a->data['albums'] as $album) { if (!empty($albums)) {
foreach ($albums as $album) {
if (($album['album'] === '') || ($album['album'] === Photo::CONTACT_PHOTOS) || ($album['album'] === DI::l10n()->t(Photo::CONTACT_PHOTOS))) { if (($album['album'] === '') || ($album['album'] === Photo::CONTACT_PHOTOS) || ($album['album'] === DI::l10n()->t(Photo::CONTACT_PHOTOS))) {
continue; continue;
} }
@ -939,7 +930,7 @@ function photos_content(App $a)
$uploader = ''; $uploader = '';
$ret = ['post_url' => 'photos/' . $a->data['user']['nickname'], $ret = ['post_url' => 'photos/' . $user['nickname'],
'addon_text' => $uploader, 'addon_text' => $uploader,
'default_upload' => true]; 'default_upload' => true];
@ -960,7 +951,7 @@ function photos_content(App $a)
'$pagename' => DI::l10n()->t('Upload Photos'), '$pagename' => DI::l10n()->t('Upload Photos'),
'$sessid' => session_id(), '$sessid' => session_id(),
'$usage' => $usage_message, '$usage' => $usage_message,
'$nickname' => $a->data['user']['nickname'], '$nickname' => $user['nickname'],
'$newalbum' => DI::l10n()->t('New album name: '), '$newalbum' => DI::l10n()->t('New album name: '),
'$existalbumtext' => DI::l10n()->t('or select existing album:'), '$existalbumtext' => DI::l10n()->t('or select existing album:'),
'$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'), '$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
@ -989,7 +980,7 @@ function photos_content(App $a)
if ($datatype === 'album') { if ($datatype === 'album') {
// if $datum is not a valid hex, redirect to the default page // if $datum is not a valid hex, redirect to the default page
if (!Strings::isHex($datum)) { if (!Strings::isHex($datum)) {
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname']. '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname']. '/album');
} }
$album = hex2bin($datum); $album = hex2bin($datum);
@ -1047,7 +1038,7 @@ function photos_content(App $a)
$o .= Renderer::replaceMacros($edit_tpl,[ $o .= Renderer::replaceMacros($edit_tpl,[
'$nametext' => DI::l10n()->t('New album name: '), '$nametext' => DI::l10n()->t('New album name: '),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $user['nickname'],
'$album' => $album_e, '$album' => $album_e,
'$hexalbum' => bin2hex($album), '$hexalbum' => bin2hex($album),
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
@ -1057,15 +1048,15 @@ function photos_content(App $a)
} }
} else { } else {
if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS)) && $can_post) { if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS)) && $can_post) {
$edit = [DI::l10n()->t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit']; $edit = [DI::l10n()->t('Edit Album'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '/edit'];
$drop = [DI::l10n()->t('Drop Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/drop']; $drop = [DI::l10n()->t('Drop Album'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '/drop'];
} }
} }
if ($order_field === 'posted') { if ($order_field === 'posted') {
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album), 'oldest']; $order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
} else { } else {
$order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?order=posted', 'newest']; $order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=posted', 'newest'];
} }
$photos = []; $photos = [];
@ -1084,7 +1075,7 @@ function photos_content(App $a)
$photos[] = [ $photos[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4), 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'] 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
. ($order_field === 'posted' ? '?order=posted' : ''), . ($order_field === 'posted' ? '?order=posted' : ''),
'title' => DI::l10n()->t('View Photo'), 'title' => DI::l10n()->t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext, 'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
@ -1101,7 +1092,7 @@ function photos_content(App $a)
'$photos' => $photos, '$photos' => $photos,
'$album' => $album, '$album' => $album,
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)], '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
'$order' => $order, '$order' => $order,
'$edit' => $edit, '$edit' => $edit,
'$drop' => $drop, '$drop' => $drop,
@ -1184,10 +1175,10 @@ function photos_content(App $a)
} }
if (!is_null($prv)) { if (!is_null($prv)) {
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : ''); $prevlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
} }
if (!is_null($nxt)) { if (!is_null($nxt)) {
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : ''); $nextlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
} }
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl'); $tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
@ -1220,17 +1211,17 @@ function photos_content(App $a)
} }
} }
$album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']); $album_link = 'photos/' . $user['nickname'] . '/album/' . bin2hex($ph[0]['album']);
$tools = null; $tools = null;
if ($can_post && ($ph[0]['uid'] == $owner_uid)) { if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = []; $tools = [];
if ($cmd === 'edit') { if ($cmd === 'edit') {
$tools['view'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')]; $tools['view'] = ['photos/' . $user['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')];
} else { } else {
$tools['edit'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')]; $tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
$tools['delete'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')]; $tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
$tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')]; $tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
} }
@ -1329,7 +1320,7 @@ function photos_content(App $a)
'$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"),1,''], '$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"),1,''],
'$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"),2,''], '$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"),2,''],
'$nickname' => $a->data['user']['nickname'], '$nickname' => $user['nickname'],
'$resource_id' => $ph[0]['resource-id'], '$resource_id' => $ph[0]['resource-id'],
'$permissions' => DI::l10n()->t('Permissions'), '$permissions' => DI::l10n()->t('Permissions'),
'$aclselect' => $aclselect_e, '$aclselect' => $aclselect_e,
@ -1379,7 +1370,6 @@ function photos_content(App $a)
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$loading' => DI::l10n()->t('Loading...'), '$loading' => DI::l10n()->t('Loading...'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12) '$rand_num' => Crypto::randomDigits(12)
]); ]);
@ -1435,7 +1425,6 @@ function photos_content(App $a)
'$comment' => DI::l10n()->t('Comment'), '$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12) '$rand_num' => Crypto::randomDigits(12)
]); ]);
@ -1510,7 +1499,6 @@ function photos_content(App $a)
'$comment' => DI::l10n()->t('Comment'), '$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12) '$rand_num' => Crypto::randomDigits(12)
]); ]);
@ -1577,7 +1565,7 @@ function photos_content(App $a)
$total = 0; $total = 0;
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource-id`", $sql_extra GROUP BY `resource-id`",
intval($a->data['user']['uid']), intval($user['uid']),
DBA::escape(Photo::CONTACT_PHOTOS), DBA::escape(Photo::CONTACT_PHOTOS),
DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)) DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS))
); );
@ -1592,7 +1580,7 @@ function photos_content(App $a)
ANY_VALUE(`created`) AS `created` FROM `photo` ANY_VALUE(`created`) AS `created` FROM `photo`
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']), intval($user['uid']),
DBA::escape(Photo::CONTACT_PHOTOS), DBA::escape(Photo::CONTACT_PHOTOS),
DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)), DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)),
$pager->getStart(), $pager->getStart(),
@ -1618,12 +1606,12 @@ function photos_content(App $a)
$photos[] = [ $photos[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4), 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id'],
'title' => DI::l10n()->t('View Photo'), 'title' => DI::l10n()->t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e, 'alt' => $alt_e,
'album' => [ 'album' => [
'link' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'link' => 'photos/' . $user['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e, 'name' => $name_e,
'alt' => DI::l10n()->t('View Album'), 'alt' => DI::l10n()->t('View Album'),
], ],
@ -1636,7 +1624,7 @@ function photos_content(App $a)
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Recent Photos'), '$title' => DI::l10n()->t('Recent Photos'),
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/'.$a->data['user']['nickname'].'/upload'], '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload'],
'$photos' => $photos, '$photos' => $photos,
'$paginate' => $pager->renderFull($total), '$paginate' => $pager->renderFull($total),
]); ]);

View file

@ -230,7 +230,7 @@ function ping_init(App $a)
$all_events = count($ev); $all_events = count($ev);
if ($all_events) { if ($all_events) {
$str_now = DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d'); $str_now = DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d');
foreach ($ev as $x) { foreach ($ev as $x) {
$bd = false; $bd = false;
if ($x['type'] === 'birthday') { if ($x['type'] === 'birthday') {
@ -239,7 +239,7 @@ function ping_init(App $a)
} else { } else {
$events ++; $events ++;
} }
if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->getTimeZone() : 'UTC'), 'UTC', 'Y-m-d') === $str_now) {
$all_events_today ++; $all_events_today ++;
if ($bd) { if ($bd) {
$birthdays_today ++; $birthdays_today ++;

View file

@ -58,7 +58,7 @@ function redir_init(App $a) {
$contact_url = $contact['url']; $contact_url = $contact['url'];
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) { if (!empty($a->getContactId()) && $a->getContactId() == $cid) {
// Local user is already authenticated. // Local user is already authenticated.
redir_check_url($contact_url, $url); redir_check_url($contact_url, $url);
$a->redirect($url ?: $contact_url); $a->redirect($url ?: $contact_url);
@ -73,7 +73,7 @@ function redir_init(App $a) {
$cid = $contact['id']; $cid = $contact['id'];
} }
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) { if (!empty($a->getContactId()) && $a->getContactId() == $cid) {
// Local user is already authenticated. // Local user is already authenticated.
redir_check_url($contact_url, $url); redir_check_url($contact_url, $url);
$target_url = $url ?: $contact_url; $target_url = $url ?: $contact_url;

View file

@ -22,17 +22,17 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\BaseProfile; use Friendica\Module\BaseProfile;
use Friendica\Security\Security; use Friendica\Security\Security;
use Friendica\Network\HTTPException;
function videos_init(App $a) function videos_init(App $a)
{ {
@ -43,38 +43,17 @@ function videos_init(App $a)
Nav::setSelected('home'); Nav::setSelected('home');
if ($a->argc > 1) { if ($a->argc > 1) {
$nick = $a->argv[1]; $owner = User::getOwnerDataByNick($a->argv[1]);
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", if (empty($owner)) {
DBA::escape($nick) throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
);
if (!DBA::isResult($user)) {
return;
} }
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];
$profile = User::getOwnerDataByNick($nick);
$account_type = Contact::getAccountType($profile);
$tpl = Renderer::getMarkupTemplate('widget/vcard.tpl');
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'],
'$photo' => $profile['photo'],
'$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
'$about' => BBCode::convert($profile['about']),
]);
// If not there, create 'aside' empty // If not there, create 'aside' empty
if (!isset(DI::page()['aside'])) { if (!isset(DI::page()['aside'])) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';
} }
DI::page()['aside'] .= $vcard_widget; DI::page()['aside'] .= Widget\VCard::getHTML($owner);
$tpl = Renderer::getMarkupTemplate("videos_head.tpl"); $tpl = Renderer::getMarkupTemplate("videos_head.tpl");
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl); DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl);
@ -85,10 +64,13 @@ function videos_init(App $a)
function videos_post(App $a) function videos_post(App $a)
{ {
$owner_uid = $a->data['user']['uid']; $user = User::getByNickname($a->argv[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
if (local_user() != $owner_uid) { if (local_user() != $user['uid']) {
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); DI::baseUrl()->redirect('videos/' . $user['nickname']);
} }
if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) { if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
@ -105,11 +87,11 @@ function videos_post(App $a)
], local_user()); ], local_user());
} }
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); DI::baseUrl()->redirect('videos/' . $user['nickname']);
return; // NOTREACHED return; // NOTREACHED
} }
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']); DI::baseUrl()->redirect('videos/' . $user['nickname']);
} }
function videos_content(App $a) function videos_content(App $a)
@ -123,13 +105,17 @@ function videos_content(App $a)
// videos/name/video/xxxxx // videos/name/video/xxxxx
// videos/name/video/xxxxx/edit // videos/name/video/xxxxx/edit
$user = User::getByNickname($a->argv[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.')); notice(DI::l10n()->t('Public access denied.'));
return; return;
} }
if (empty($a->data['user'])) { if (empty($user)) {
notice(DI::l10n()->t('No videos selected') . EOL ); notice(DI::l10n()->t('No videos selected') . EOL );
return; return;
} }
@ -154,41 +140,38 @@ function videos_content(App $a)
// //
$can_post = false; $can_post = false;
$visitor = 0; $visitor = 0;
$contact = null;
$remote_contact = false; $remote_contact = false;
$contact_id = 0; $contact_id = 0;
$owner_uid = $a->data['user']['uid']; $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
$community_page = (($a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); if ((local_user()) && (local_user() == $user['uid'])) {
if ((local_user()) && (local_user() == $owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) { } elseif ($community_page && !empty(Session::getRemoteContactID($user['uid']))) {
$contact_id = Session::getRemoteContactID($owner_uid); $contact_id = Session::getRemoteContactID($user['uid']);
$can_post = true; $can_post = true;
$remote_contact = true; $remote_contact = true;
$visitor = $contact_id; $visitor = $contact_id;
} }
// perhaps they're visiting - but not a community page, so they wouldn't have write access // perhaps they're visiting - but not a community page, so they wouldn't have write access
if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) { if (!empty(Session::getRemoteContactID($user['uid'])) && !$visitor) {
$contact_id = Session::getRemoteContactID($owner_uid); $contact_id = Session::getRemoteContactID($user['uid']);
$remote_contact = true; $remote_contact = true;
} }
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($user['hidewall'] && (local_user() != $user['uid']) && !$remote_contact) {
notice(DI::l10n()->t('Access to this item is restricted.')); notice(DI::l10n()->t('Access to this item is restricted.'));
return; return;
} }
$sql_extra = Security::getPermissionsSQLByUserId($owner_uid); $sql_extra = Security::getPermissionsSQLByUserId($user['uid']);
$o = ""; $o = "";
// tabs // tabs
$_is_owner = (local_user() && (local_user() == $owner_uid)); $_is_owner = (local_user() && (local_user() == $user['uid']));
$o .= BaseProfile::getTabsHTML($a, 'videos', $_is_owner, $a->data['user']['nickname']); $o .= BaseProfile::getTabsHTML($a, 'videos', $_is_owner, $user);
// //
// dispatch request // dispatch request
@ -218,7 +201,7 @@ function videos_content(App $a)
$total = 0; $total = 0;
$r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%' $r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%'
$sql_extra GROUP BY hash", $sql_extra GROUP BY hash",
intval($a->data['user']['uid']) intval($user['uid'])
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$total = count($r); $total = count($r);
@ -231,7 +214,7 @@ function videos_content(App $a)
FROM `attach` FROM `attach`
WHERE `uid` = %d AND filetype LIKE '%%video%%' WHERE `uid` = %d AND filetype LIKE '%%video%%'
$sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']), intval($user['uid']),
$pager->getStart(), $pager->getStart(),
$pager->getItemsPerPage() $pager->getItemsPerPage()
); );
@ -247,13 +230,13 @@ function videos_content(App $a)
$videos[] = [ $videos[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'link' => DI::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['hash'], 'link' => DI::baseUrl() . '/videos/' . $user['nickname'] . '/video/' . $rr['hash'],
'title' => DI::l10n()->t('View Video'), 'title' => DI::l10n()->t('View Video'),
'src' => DI::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0', 'src' => DI::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0',
'alt' => $alt_e, 'alt' => $alt_e,
'mime' => $rr['filetype'], 'mime' => $rr['filetype'],
'album' => [ 'album' => [
'link' => DI::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'link' => DI::baseUrl() . '/videos/' . $user['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e, 'name' => $name_e,
'alt' => DI::l10n()->t('View Album'), 'alt' => DI::l10n()->t('View Album'),
], ],
@ -265,9 +248,9 @@ function videos_content(App $a)
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Recent Videos'), '$title' => DI::l10n()->t('Recent Videos'),
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => [DI::l10n()->t('Upload New Videos'), DI::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/upload'], '$upload' => [DI::l10n()->t('Upload New Videos'), DI::baseUrl() . '/videos/' . $user['nickname'] . '/upload'],
'$videos' => $videos, '$videos' => $videos,
'$delete_url' => (($can_post) ? DI::baseUrl() . '/videos/' . $a->data['user']['nickname'] : false) '$delete_url' => (($can_post) ? DI::baseUrl() . '/videos/' . $user['nickname'] : false)
]); ]);
$o .= $pager->renderFull($total); $o .= $pager->renderFull($total);

View file

@ -56,32 +56,24 @@ use Psr\Log\LoggerInterface;
*/ */
class App class App
{ {
public $profile;
public $profile_uid;
public $user; public $user;
public $cid;
public $contact;
public $contacts;
public $page_contact;
public $content;
public $data = []; public $data = [];
/** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */ /** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
public $argv; public $argv;
/** @deprecated 2019.09 - use App\Arguments->getArgc() */ /** @deprecated 2019.09 - use App\Arguments->getArgc() */
public $argc; public $argc;
public $timezone;
public $interactive = true;
public $identities;
public $theme_info = []; public $theme_info = [];
public $category;
// Allow themes to control internal parameters // Allow themes to control internal parameters
// by changing App values in theme.php // by changing App values in theme.php
public $sourcename = '';
public $videowidth = 425; public $videowidth = 425;
public $videoheight = 350; public $videoheight = 350;
public $theme_events_in_profile = true; public $theme_events_in_profile = true;
public $queue;
private $timezone = '';
private $profile_owner = 0;
private $contact_id = 0;
private $queue = [];
/** /**
* @var App\Mode The Mode of the Application * @var App\Mode The Mode of the Application
@ -138,6 +130,84 @@ class App
*/ */
private $pConfig; private $pConfig;
/**
* Set the profile owner ID
*
* @param int $owner_id
* @return void
*/
public function setProfileOwner(int $owner_id)
{
$this->profile_owner = $owner_id;
}
/**
* Get the profile owner ID
*
* @return int
*/
public function getProfileOwner():int
{
return $this->profile_owner;
}
/**
* Set the contact ID
*
* @param int $contact_id
* @return void
*/
public function setContactId(int $contact_id)
{
$this->contact_id = $contact_id;
}
/**
* Get the contact ID
*
* @return int
*/
public function getContactId():int
{
return $this->contact_id;
}
/**
* Set the timezone
*
* @param int $timezone
* @return void
*/
public function setTimeZone(string $timezone)
{
$this->timezone = $timezone;
}
/**
* Get the timezone
*
* @return int
*/
public function getTimeZone():string
{
return $this->timezone;
}
public function setQueue(array $queue)
{
$this->queue = $queue;
}
public function getQueue()
{
return $this->queue ?? [];
}
public function getQueueValue(string $index)
{
return $this->queue[$index] ?? null;
}
/** /**
* Returns the current config cache of this node * Returns the current config cache of this node
* *
@ -317,10 +387,10 @@ class App
$page_theme = null; $page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at // Find the theme that belongs to the user whose stuff we are looking at
if ($this->profile_uid && ($this->profile_uid != local_user())) { if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
// Allow folks to override user themes and always use their own on their own site. // Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server // This works only if the user is on the same server
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_uid]); $user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
if ($this->database->isResult($user) && !$this->pConfig->get(local_user(), 'system', 'always_my_theme')) { if ($this->database->isResult($user) && !$this->pConfig->get(local_user(), 'system', 'always_my_theme')) {
$page_theme = $user['theme']; $page_theme = $user['theme'];
} }
@ -350,11 +420,11 @@ class App
$page_mobile_theme = null; $page_mobile_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at // Find the theme that belongs to the user whose stuff we are looking at
if ($this->profile_uid && ($this->profile_uid != local_user())) { if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
// Allow folks to override user themes and always use their own on their own site. // Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server // This works only if the user is on the same server
if (!$this->pConfig->get(local_user(), 'system', 'always_my_theme')) { if (!$this->pConfig->get(local_user(), 'system', 'always_my_theme')) {
$page_mobile_theme = $this->pConfig->get($this->profile_uid, 'system', 'mobile-theme'); $page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
} }
} }
@ -547,7 +617,7 @@ class App
$this->baseURL->redirect('search'); $this->baseURL->redirect('search');
} }
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid // Initialize module that can set the current theme in the init() method, either directly or via App->setProfileOwner
$page['page_title'] = $moduleName; $page['page_title'] = $moduleName;
if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) { if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) {

View file

@ -459,7 +459,6 @@ class Page implements ArrayAccess
} }
$page = $this->page; $page = $this->page;
$profile = $app->profile;
header("X-Friendica-Version: " . FRIENDICA_VERSION); header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8"); header("Content-type: text/html; charset=utf-8");

View file

@ -289,7 +289,7 @@ class Nav
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')]; $nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')]; $nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
if (is_array($a->identities) && count($a->identities) > 1) { if (User::hasIdentities(DI::session()->get('submanage') ?: local_user())) {
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')]; $nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
} }

View file

@ -801,22 +801,6 @@ class HTML
]); ]);
} }
/**
* Get html for contact block.
*
* @deprecated since version 2019.03
* @see ContactBlock::getHTML()
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function contactBlock()
{
$a = DI::app();
return ContactBlock::getHTML($a->profile);
}
/** /**
* Format contacts as picture links or as text links * Format contacts as picture links or as text links
* *

View file

@ -334,7 +334,7 @@ class Widget
{ {
$a = DI::app(); $a = DI::app();
$uid = intval($a->profile['uid']); $uid = intval($a->getProfileOwner());
if (!Feature::isEnabled($uid, 'categories')) { if (!Feature::isEnabled($uid, 'categories')) {
return ''; return '';
@ -416,23 +416,20 @@ class Widget
/** /**
* Insert a tag cloud widget for the present profile. * Insert a tag cloud widget for the present profile.
* *
* @param int $uid User ID
* @param int $limit Max number of displayed tags. * @param int $limit Max number of displayed tags.
* @return string HTML formatted output. * @return string HTML formatted output.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function tagCloud($limit = 50) public static function tagCloud(int $uid, int $limit = 50)
{ {
$a = DI::app(); if (empty($uid)) {
$uid = intval($a->profile['uid']);
if (!$uid || !$a->profile['url']) {
return ''; return '';
} }
if (Feature::isEnabled($uid, 'tagadelic')) { if (Feature::isEnabled($uid, 'tagadelic')) {
$owner_id = Contact::getIdForURL($a->profile['url'], 0, false); $owner_id = Contact::getPublicIdByUserId($uid);
if (!$owner_id) { if (!$owner_id) {
return ''; return '';

View file

@ -21,9 +21,12 @@
namespace Friendica\Content\Widget; namespace Friendica\Content\Widget;
use Friendica\Content\ContactSelector;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -43,10 +46,16 @@ class VCard
*/ */
public static function getHTML(array $contact) public static function getHTML(array $contact)
{ {
if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) { if (!isset($contact['network']) || !isset($contact['id'])) {
$network_link = Strings::formatNetworkName($contact['network'], $contact['url']); Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
}
if ($contact['network'] != '') {
$network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
$network_avatar = ContactSelector::networkToIcon($contact['network'], $contact['url']);
} else { } else {
$network_link = ''; $network_link = '';
$network_avatar = '';
} }
$follow_link = ''; $follow_link = '';
@ -87,6 +96,7 @@ class VCard
'$xmpp' => DI::l10n()->t('XMPP:'), '$xmpp' => DI::l10n()->t('XMPP:'),
'$location' => DI::l10n()->t('Location:'), '$location' => DI::l10n()->t('Location:'),
'$network_link' => $network_link, '$network_link' => $network_link,
'$network_avatar' => $network_avatar,
'$network' => DI::l10n()->t('Network:'), '$network' => DI::l10n()->t('Network:'),
'$account_type' => Contact::getAccountType($contact), '$account_type' => Contact::getAccountType($contact),
'$follow' => DI::l10n()->t('Follow'), '$follow' => DI::l10n()->t('Follow'),

View file

@ -48,7 +48,6 @@ class Renderer
* beyond are used. * beyond are used.
*/ */
public static $theme = [ public static $theme = [
'sourcename' => '',
'videowidth' => 425, 'videowidth' => 425,
'videoheight' => 350, 'videoheight' => 350,
'stylesheet' => '', 'stylesheet' => '',

View file

@ -446,7 +446,7 @@ class Worker
$queue['priority'] = PRIORITY_MEDIUM; $queue['priority'] = PRIORITY_MEDIUM;
} }
$a->queue = $queue; $a->setQueue($queue);
$up_duration = microtime(true) - self::$up_start; $up_duration = microtime(true) - self::$up_start;
@ -462,7 +462,7 @@ class Worker
Logger::disableWorker(); Logger::disableWorker();
unset($a->queue); $a->setQueue([]);
$duration = (microtime(true) - $stamp); $duration = (microtime(true) - $stamp);
@ -831,7 +831,7 @@ class Worker
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$queues = DBA::p("SELECT `process`.`pid`, COUNT(`workerqueue`.`pid`) AS `entries` FROM `process` $queues = DBA::p("SELECT `process`.`pid`, COUNT(`workerqueue`.`pid`) AS `entries` FROM `process`
LEFT JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `workerqueue`.`done` LEFT JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `workerqueue`.`done`
GROUP BY `process`.`pid`"); GROUP BY `process`.`pid`");
while ($queue = DBA::fetch($queues)) { while ($queue = DBA::fetch($queues)) {
$ids[$queue['pid']] = $queue['entries']; $ids[$queue['pid']] = $queue['entries'];
@ -1351,12 +1351,12 @@ class Worker
*/ */
public static function defer() public static function defer()
{ {
if (empty(DI::app()->queue)) { $queue = DI::app()->getQueue();
if (empty($queue)) {
return false; return false;
} }
$queue = DI::app()->queue;
$retrial = $queue['retrial']; $retrial = $queue['retrial'];
$id = $queue['id']; $id = $queue['id'];
$priority = $queue['priority']; $priority = $queue['priority'];
@ -1587,7 +1587,7 @@ class Worker
} else { } else {
Logger::info('We are outside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]); Logger::info('We are outside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
} }
return $execute; return $execute;
} }
} }

View file

@ -63,8 +63,6 @@ class Notification extends BaseFactory
private $baseUrl; private $baseUrl;
/** @var L10n */ /** @var L10n */
private $l10n; private $l10n;
/** @var string */
private $nurl;
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session) public function __construct(LoggerInterface $logger, Database $dba, Repository\Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
{ {
@ -74,7 +72,6 @@ class Notification extends BaseFactory
$this->notification = $notification; $this->notification = $notification;
$this->baseUrl = $baseUrl; $this->baseUrl = $baseUrl;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->nurl = $app->contact['nurl'] ?? '';
} }
/** /**

View file

@ -1736,7 +1736,7 @@ class Contact
{ {
$condition = ["`nurl` = ? AND ((`uid` = ? AND `network` IN (?, ?)) OR `uid` = ?)", $condition = ["`nurl` = ? AND ((`uid` = ? AND `network` IN (?, ?)) OR `uid` = ?)",
Strings::normaliseLink($url), $uid, Protocol::FEED, Protocol::MAIL, 0]; Strings::normaliseLink($url), $uid, Protocol::FEED, Protocol::MAIL, 0];
$contact = self::selectFirst(['id', 'updated'], $condition); $contact = self::selectFirst(['id', 'updated'], $condition, ['order' => ['uid' => true]]);
return self::getAvatarUrlForId($contact['id'] ?? 0, $size, $contact['updated'] ?? ''); return self::getAvatarUrlForId($contact['id'] ?? 0, $size, $contact['updated'] ?? '');
} }

View file

@ -2685,7 +2685,7 @@ class Item
continue; continue;
} }
if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->contact['id']) && ($item['network'] == Protocol::DFRN)) { if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->getContactId()) && ($item['network'] == Protocol::DFRN)) {
$img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]); $img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']); $item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
} }

View file

@ -205,31 +205,27 @@ class Profile
* load a lot of theme-specific content * load a lot of theme-specific content
* *
* @param App $a * @param App $a
* @param string $nickname string * @param string $nickname string
* @param array $profiledata array *
* @param boolean $show_connect Show connect link * @return array Profile
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function load(App $a, $nickname) public static function load(App $a, string $nickname, bool $show_contacts = true)
{ {
$profile = User::getOwnerDataByNick($nickname); $profile = User::getOwnerDataByNick($nickname);
if (empty($profile)) { if (empty($profile)) {
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
return; return [];
} }
$a->profile = $profile; $a->setProfileOwner($profile['uid']);
$a->profile_uid = $profile['uid'];
$a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['uid'], 'system', 'mobile_theme'); DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
$a->profile['network'] = Protocol::DFRN;
DI::page()['title'] = $a->profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
if (!DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) { if (!DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) {
$a->setCurrentTheme($a->profile['theme']); $a->setCurrentTheme($profile['theme']);
$a->setCurrentMobileTheme($a->profile['mobile-theme']); $a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme'));
} }
/* /*
@ -250,9 +246,9 @@ class Profile
* By now, the contact block isn't shown, when a different profile is given * By now, the contact block isn't shown, when a different profile is given
* But: When this profile was on the same server, then we could display the contacts * But: When this profile was on the same server, then we could display the contacts
*/ */
DI::page()['aside'] .= self::sidebar($a, $a->profile, $block); DI::page()['aside'] .= self::sidebar($profile, $block, $show_contacts);
return; return $profile;
} }
/** /**
@ -261,9 +257,9 @@ class Profile
* It is very difficult to templatise the HTML completely * It is very difficult to templatise the HTML completely
* because of all the conditional logic. * because of all the conditional logic.
* *
* @param array $profile * @param array $profile Profile array
* @param int $block * @param bool $block Block personal details
* @param boolean $show_connect Show connect link * @param bool $show_contacts Show contact block
* *
* @return string HTML sidebar module * @return string HTML sidebar module
* *
@ -276,15 +272,11 @@ class Profile
* @hooks 'profile_sidebar' * @hooks 'profile_sidebar'
* array $arr * array $arr
*/ */
private static function sidebar(App $a, array $profile, $block = 0) private static function sidebar(array $profile, bool $block, bool $show_contacts)
{ {
$o = ''; $o = '';
$location = false; $location = false;
// This function can also use contact information in $profile, but the 'cid'
// value is going to be coming from 'owner-view', which means it's the wrong
// contact ID for the user viewing this page. Use 'nurl' to look up the
// correct contact table entry for the logged-in user.
$profile_contact = []; $profile_contact = [];
if (local_user() && ($profile['uid'] ?? 0) != local_user()) { if (local_user() && ($profile['uid'] ?? 0) != local_user()) {
@ -403,10 +395,10 @@ class Profile
$updated = date('c', strtotime($profile['last-item'])); $updated = date('c', strtotime($profile['last-item']));
} }
if (!$block) { if (!$block && $show_contacts) {
$contact_block = ContactBlock::getHTML($a->profile); $contact_block = ContactBlock::getHTML($profile);
if (is_array($a->profile) && !$a->profile['hide-friends']) { if (is_array($profile) && !$profile['hide-friends']) {
$contact_count = DBA::count('contact', [ $contact_count = DBA::count('contact', [
'uid' => $profile['uid'], 'uid' => $profile['uid'],
'self' => false, 'self' => false,
@ -552,7 +544,7 @@ class Profile
$rr['link'] = Contact::magicLinkById($rr['cid']); $rr['link'] = Contact::magicLinkById($rr['cid']);
$rr['title'] = $rr['name']; $rr['title'] = $rr['name'];
$rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : ''); $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $a->getTimeZone(), 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
$rr['startime'] = null; $rr['startime'] = null;
$rr['today'] = $today; $rr['today'] = $today;
} }
@ -611,8 +603,8 @@ class Profile
$total++; $total++;
} }
$strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d'); $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC', 'UTC', 'Y-m-d');
if ($strt === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) { if ($strt === DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) {
$istoday = true; $istoday = true;
} }
@ -627,17 +619,17 @@ class Profile
$description = DI::l10n()->t('[No description]'); $description = DI::l10n()->t('[No description]');
} }
$strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC'); $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC');
if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) { if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) {
continue; continue;
} }
$today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) ? true : false); $today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) ? true : false);
$rr['title'] = $title; $rr['title'] = $title;
$rr['description'] = $description; $rr['description'] = $description;
$rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : ''); $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
$rr['startime'] = $strt; $rr['startime'] = $strt;
$rr['today'] = $today; $rr['today'] = $today;
@ -776,7 +768,7 @@ class Profile
Session::setVisitorsContacts(); Session::setVisitorsContacts();
$a->contact = $visitor; $a->setContactId($visitor['id']);
Logger::info('Authenticated visitor', ['url' => $visitor['url']]); Logger::info('Authenticated visitor', ['url' => $visitor['url']]);
@ -837,7 +829,7 @@ class Profile
*/ */
Hook::callAll('magic_auth_success', $arr); Hook::callAll('magic_auth_success', $arr);
$a->contact = $arr['visitor']; $a->setContactId($arr['visitor']['id']);
info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name']));
@ -879,7 +871,7 @@ class Profile
*/ */
public static function getThemeUid(App $a) public static function getThemeUid(App $a)
{ {
$uid = !empty($a->profile_uid) ? intval($a->profile_uid) : 0; $uid = !empty($a->getProfileOwner()) ? intval($a->getProfileOwner()) : 0;
if (local_user() && (DI::pConfig()->get(local_user(), 'system', 'always_my_theme') || !$uid)) { if (local_user() && (DI::pConfig()->get(local_user(), 'system', 'always_my_theme') || !$uid)) {
return local_user(); return local_user();
} }

View file

@ -1569,6 +1569,38 @@ class User
return $identities; return $identities;
} }
/**
* Check if the given user id has delegations or is delegated
*
* @param int $uid
* @return bool
*/
public static function hasIdentities(int $uid):bool
{
if (empty($uid)) {
return false;
}
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => $uid, 'account_removed' => false]);
if (!DBA::isResult($user)) {
return false;
}
if ($user['parent-uid'] != 0) {
return true;
}
if (DBA::exists('user', ['parent-uid' => $uid, 'account_removed' => false])) {
return true;
}
if (DBA::exists('manage', ['uid' => $uid])) {
return true;
}
return false;
}
/** /**
* Returns statistical information about the current users of this node * Returns statistical information about the current users of this node
* *

View file

@ -39,11 +39,9 @@ class BaseProfile extends BaseModule
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function getTabsHTML(App $a, string $current, bool $is_owner, string $nickname = null) public static function getTabsHTML(App $a, string $current, bool $is_owner, array $profile)
{ {
if (is_null($nickname)) { $nickname = $profile['nickname'];
$nickname = $a->user['nickname'];
}
$baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname; $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
@ -116,7 +114,7 @@ class BaseProfile extends BaseModule
]; ];
} }
if (empty($a->profile['hide-friends'])) { if (empty($profile['hide-friends'])) {
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Contacts'), 'label' => DI::l10n()->t('Contacts'),
'url' => $baseProfileUrl . '/contacts', 'url' => $baseProfileUrl . '/contacts',

View file

@ -156,12 +156,6 @@ class Contact extends BaseModule
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
notice(DI::l10n()->t('Failed to update contact record.')); notice(DI::l10n()->t('Failed to update contact record.'));
} }
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
if (DBA::isResult($contact)) {
$a->data['contact'] = $contact;
}
return; return;
} }
@ -306,8 +300,6 @@ class Contact extends BaseModule
} }
} }
$a->data['contact'] = $contact;
$vcard_widget = Widget\VCard::getHTML($contact); $vcard_widget = Widget\VCard::getHTML($contact);
$findpeople_widget = ''; $findpeople_widget = '';
@ -453,9 +445,7 @@ class Contact extends BaseModule
$_SESSION['return_path'] = DI::args()->getQueryString(); $_SESSION['return_path'] = DI::args()->getQueryString();
if (!empty($a->data['contact']) && is_array($a->data['contact'])) { if (!empty($contact)) {
$contact = $a->data['contact'];
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [ DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
'$baseurl' => DI::baseUrl()->get(true), '$baseurl' => DI::baseUrl()->get(true),
]); ]);

View file

@ -11,6 +11,7 @@ use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Model\Contact;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -59,7 +60,7 @@ class Poke extends BaseModule
$deny_cid = ($private ? '' : $a->user['deny_cid']); $deny_cid = ($private ? '' : $a->user['deny_cid']);
$deny_gid = ($private ? '' : $a->user['deny_gid']); $deny_gid = ($private ? '' : $a->user['deny_gid']);
$actor = $a->contact; $actor = Contact::getById($a->getContactId());
$uri = Model\Item::newURI($uid); $uri = Model\Item::newURI($uid);

View file

@ -29,6 +29,8 @@ use Friendica\Util\Temporal;
class Localtime extends BaseModule class Localtime extends BaseModule
{ {
static $mod_localtime = '';
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$time = ($_REQUEST['time'] ?? '') ?: 'now'; $time = ($_REQUEST['time'] ?? '') ?: 'now';
@ -36,14 +38,12 @@ class Localtime extends BaseModule
$bd_format = DI::l10n()->t('l F d, Y \@ g:i A'); $bd_format = DI::l10n()->t('l F d, Y \@ g:i A');
if (!empty($_POST['timezone'])) { if (!empty($_POST['timezone'])) {
DI::app()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format); self::$mod_localtime = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
} }
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = DI::app();
$time = ($_REQUEST['time'] ?? '') ?: 'now'; $time = ($_REQUEST['time'] ?? '') ?: 'now';
$output = '<h3>' . DI::l10n()->t('Time Conversion') . '</h3>'; $output = '<h3>' . DI::l10n()->t('Time Conversion') . '</h3>';
@ -54,8 +54,8 @@ class Localtime extends BaseModule
$output .= '<p>' . DI::l10n()->t('Current timezone: %s', $_REQUEST['timezone']) . '</p>'; $output .= '<p>' . DI::l10n()->t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
} }
if (!empty($app->data['mod-localtime'])) { if (!empty(self::$mod_localtime)) {
$output .= '<p>' . DI::l10n()->t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>'; $output .= '<p>' . DI::l10n()->t('Converted localtime: %s', self::$mod_localtime) . '</p>';
} }
$output .= '<form action ="' . DI::baseUrl()->get() . '/localtime?time=' . $time . '" method="post" >'; $output .= '<form action ="' . DI::baseUrl()->get() . '/localtime?time=' . $time . '" method="post" >';

View file

@ -118,7 +118,7 @@ class Delegation extends BaseModule
throw new ForbiddenException(DI::l10n()->t('Permission denied.')); throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
$identities = DI::app()->identities; $identities = User::identities(DI::session()->get('submanage', local_user()));
//getting additinal information for each identity //getting additinal information for each identity
foreach ($identities as $key => $identity) { foreach ($identities as $key => $identity) {

View file

@ -48,28 +48,28 @@ class HCard extends BaseModule
throw new HTTPException\NotFoundException(DI::l10n()->t('No profile')); throw new HTTPException\NotFoundException(DI::l10n()->t('No profile'));
} }
Profile::load($a, $nickname); $profile = Profile::load($a, $nickname, false);
if (empty($a->profile)) { if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$page = DI::page(); $page = DI::page();
if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) { if (!empty($profile['page-flags']) && ($profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
$page['htmlhead'] .= '<meta name="friendica.community" content="true" />'; $page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
} }
if (!empty($a->profile['openidserver'])) { if (!empty($profile['openidserver'])) {
$page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="openid.server" href="' . $profile['openidserver'] . '" />' . "\r\n";
} }
if (!empty($a->profile['openid'])) { if (!empty($profile['openid'])) {
$delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); $delegate = ((strstr($profile['openid'], '://')) ? $profile['openid'] : 'http://' . $profile['openid']);
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
} }
// check if blocked // check if blocked
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
$keywords = $a->profile['pub_keywords'] ?? ''; $keywords = $profile['pub_keywords'] ?? '';
$keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords); $keywords = str_replace([',', ' ', ',,'], [' ', ',', ','], $keywords);
if (strlen($keywords)) { if (strlen($keywords)) {
$page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n"; $page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
@ -78,9 +78,9 @@ class HCard extends BaseModule
$baseUrl = DI::baseUrl(); $baseUrl = DI::baseUrl();
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : '')); $uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
$page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n"; $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
$page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);

View file

@ -28,6 +28,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
@ -86,7 +87,7 @@ class Compose extends BaseModule
$compose_title = DI::l10n()->t('Compose new personal note'); $compose_title = DI::l10n()->t('Compose new personal note');
$type = 'note'; $type = 'note';
$doesFederate = false; $doesFederate = false;
$contact_allow_list = [$a->contact['id']]; $contact_allow_list = [$a->getContactId()];
$group_allow_list = []; $group_allow_list = [];
$contact_deny_list = []; $contact_deny_list = [];
$group_deny_list = []; $group_deny_list = [];
@ -129,6 +130,8 @@ class Compose extends BaseModule
DI::page()->registerFooterScript(Theme::getPathForFile('js/linkPreview.js')); DI::page()->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/compose.js')); DI::page()->registerFooterScript(Theme::getPathForFile('js/compose.js'));
$contact = Contact::getById($a->getContactId());
$tpl = Renderer::getMarkupTemplate('item/compose.tpl'); $tpl = Renderer::getMarkupTemplate('item/compose.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$compose_title'=> $compose_title, '$compose_title'=> $compose_title,
@ -138,9 +141,9 @@ class Compose extends BaseModule
'$type' => $type, '$type' => $type,
'$wall' => $wall, '$wall' => $wall,
'$default' => '', '$default' => '',
'$mylink' => DI::baseUrl()->remove($a->contact['url']), '$mylink' => DI::baseUrl()->remove($contact['url']),
'$mytitle' => DI::l10n()->t('This is you'), '$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => DI::baseUrl()->remove($a->contact['thumb']), '$myphoto' => DI::baseUrl()->remove($contact['thumb']),
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$edbold' => DI::l10n()->t('Bold'), '$edbold' => DI::l10n()->t('Bold'),
'$editalic' => DI::l10n()->t('Italic'), '$editalic' => DI::l10n()->t('Italic'),
@ -171,7 +174,6 @@ class Compose extends BaseModule
'$group_deny' => implode(',', $group_deny_list), '$group_deny' => implode(',', $group_deny_list),
'$jotplugins' => $jotplugins, '$jotplugins' => $jotplugins,
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$rand_num' => Crypto::randomDigits(12), '$rand_num' => Crypto::randomDigits(12),
'$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->user, $doesFederate, [ '$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->user, $doesFederate, [
'allow_cid' => $contact_allow_list, 'allow_cid' => $contact_allow_list,

View file

@ -65,7 +65,7 @@ class Magic extends BaseModule
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site. // Redirect if the contact is already authenticated on this site.
if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) { if ($a->getContactId() && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) {
if ($test) { if ($test) {
$ret['success'] = true; $ret['success'] = true;
$ret['message'] .= 'Local site - you are already authenticated.' . EOL; $ret['message'] .= 'Local site - you are already authenticated.' . EOL;

View file

@ -47,28 +47,27 @@ class Common extends BaseProfile
$nickname = $parameters['nickname']; $nickname = $parameters['nickname'];
Profile::load($a, $nickname); $profile = Profile::load($a, $nickname);
if (empty($profile)) {
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
if (!empty($a->profile['hide-friends'])) { if (!empty($profile['hide-friends'])) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
$displayCommonTab = Session::isAuthenticated() && $a->profile['uid'] != local_user(); $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != local_user();
if (!$displayCommonTab) { if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts'); $a->redirect('profile/' . $nickname . '/contacts');
}; };
$o = self::getTabsHTML($a, 'contacts', false, $nickname); $o = self::getTabsHTML($a, 'contacts', false, $profile);
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab); $tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
$sourceId = Contact::getIdForURL(Profile::getMyURL()); $sourceId = Contact::getIdForURL(Profile::getMyURL());
$targetId = Contact::getPublicIdByUserId($a->profile['uid']); $targetId = Contact::getPublicIdByUserId($profile['uid']);
$condition = [ $condition = [
'blocked' => false, 'blocked' => false,
@ -87,7 +86,7 @@ class Common extends BaseProfile
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total); $title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = DI::l10n()->t( $desc = DI::l10n()->t(
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).', 'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
htmlentities($a->profile['name'], ENT_COMPAT, 'UTF-8') htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
); );
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl'); $tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Profile;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
@ -45,26 +46,25 @@ class Contacts extends Module\BaseProfile
$nickname = $parameters['nickname']; $nickname = $parameters['nickname'];
$type = $parameters['type'] ?? 'all'; $type = $parameters['type'] ?? 'all';
Model\Profile::load($a, $nickname); $profile = Model\Profile::load($a, $nickname);
if (empty($profile)) {
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$is_owner = $a->profile['uid'] == local_user(); $is_owner = $profile['uid'] == local_user();
if (!empty($a->profile['hide-friends']) && !$is_owner) { if (!empty($profile['hide-friends']) && !$is_owner) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
Nav::setSelected('home'); Nav::setSelected('home');
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname); $o = self::getTabsHTML($a, 'contacts', $is_owner, $profile);
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $a->profile['uid'] != local_user()); $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != local_user());
$condition = [ $condition = [
'uid' => $a->profile['uid'], 'uid' => $profile['uid'],
'blocked' => false, 'blocked' => false,
'pending' => false, 'pending' => false,
'hidden' => false, 'hidden' => false,
@ -103,7 +103,7 @@ class Contacts extends Module\BaseProfile
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total); $title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = DI::l10n()->t( $desc = DI::l10n()->t(
'These contacts both follow and are followed by <strong>%s</strong>.', 'These contacts both follow and are followed by <strong>%s</strong>.',
htmlentities($a->profile['name'], ENT_COMPAT, 'UTF-8') htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
); );
break; break;
case 'all': case 'all':

View file

@ -26,6 +26,7 @@ use Friendica\Content\ForumManager;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Content\Widget;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -76,36 +77,35 @@ class Profile extends BaseProfile
{ {
$a = DI::app(); $a = DI::app();
ProfileModel::load($a, $parameters['nickname']); $profile = ProfileModel::load($a, $parameters['nickname']);
if (!$profile) {
if (!$a->profile) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
} }
$remote_contact_id = Session::getRemoteContactID($a->profile_uid); $remote_contact_id = Session::getRemoteContactID($profile['uid']);
if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) { if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
return Login::form(); return Login::form();
} }
$is_owner = local_user() == $a->profile_uid; $is_owner = local_user() == $profile['uid'];
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
} }
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) { if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n"; DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
} }
DI::page()['htmlhead'] .= self::buildHtmlHead($a->profile, $parameters['nickname'], $remote_contact_id); DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $parameters['nickname'], $remote_contact_id);
Nav::setSelected('home'); Nav::setSelected('home');
$is_owner = local_user() == $a->profile['uid']; $is_owner = local_user() == $profile['uid'];
$o = self::getTabsHTML($a, 'profile', $is_owner, $a->profile['nickname']); $o = self::getTabsHTML($a, 'profile', $is_owner, $profile);
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
notice(DI::l10n()->t('Access to this profile has been restricted.')); notice(DI::l10n()->t('Access to this profile has been restricted.'));
return ''; return '';
} }
@ -141,59 +141,59 @@ class Profile extends BaseProfile
$basic_fields = []; $basic_fields = [];
$basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $a->profile['name']); $basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $profile['name']);
if (Feature::isEnabled($a->profile_uid, 'profile_membersince')) { if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
$basic_fields += self::buildField( $basic_fields += self::buildField(
'membersince', 'membersince',
DI::l10n()->t('Member since:'), DI::l10n()->t('Member since:'),
DateTimeFormat::local($a->profile['register_date']) DateTimeFormat::local($profile['register_date'])
); );
} }
if (!empty($a->profile['dob']) && $a->profile['dob'] > DBA::NULL_DATE) { if (!empty($profile['dob']) && $profile['dob'] > DBA::NULL_DATE) {
$year_bd_format = DI::l10n()->t('j F, Y'); $year_bd_format = DI::l10n()->t('j F, Y');
$short_bd_format = DI::l10n()->t('j F'); $short_bd_format = DI::l10n()->t('j F');
$dob = DI::l10n()->getDay( $dob = DI::l10n()->getDay(
intval($a->profile['dob']) ? intval($profile['dob']) ?
DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format) DateTimeFormat::utc($profile['dob'] . ' 00:00 +00:00', $year_bd_format)
: DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format) : DateTimeFormat::utc('2001-' . substr($profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
); );
$basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob); $basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob);
if ($age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'])) { if ($age = Temporal::getAgeByTimezone($profile['dob'], $profile['timezone'])) {
$basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age)); $basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age));
} }
} }
if ($a->profile['about']) { if ($profile['about']) {
$basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($a->profile['uri-id'], $a->profile['about'])); $basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
} }
if ($a->profile['xmpp']) { if ($profile['xmpp']) {
$basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $a->profile['xmpp']); $basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $profile['xmpp']);
} }
if ($a->profile['homepage']) { if ($profile['homepage']) {
$basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($a->profile['homepage'])); $basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($profile['homepage']));
} }
if ( if (
$a->profile['address'] $profile['address']
|| $a->profile['locality'] || $profile['locality']
|| $a->profile['postal-code'] || $profile['postal-code']
|| $a->profile['region'] || $profile['region']
|| $a->profile['country-name'] || $profile['country-name']
) { ) {
$basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($a->profile)); $basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($profile));
} }
if ($a->profile['pub_keywords']) { if ($profile['pub_keywords']) {
$tags = []; $tags = [];
// Separator is defined in Module\Settings\Profile\Index::cleanKeywords // Separator is defined in Module\Settings\Profile\Index::cleanKeywords
foreach (explode(', ', $a->profile['pub_keywords']) as $tag_label) { foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
$tags[] = [ $tags[] = [
'url' => '/search?tag=' . $tag_label, 'url' => '/search?tag=' . $tag_label,
'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label, 'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
@ -209,26 +209,26 @@ class Profile extends BaseProfile
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0; $contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
if ($is_owner && $contact_id === 0) { if ($is_owner && $contact_id === 0) {
$profile_fields = DI::profileField()->selectByUserId($a->profile_uid); $profile_fields = DI::profileField()->selectByUserId($profile['uid']);
} else { } else {
$profile_fields = DI::profileField()->selectByContactId($contact_id, $a->profile_uid); $profile_fields = DI::profileField()->selectByContactId($contact_id, $profile['uid']);
} }
foreach ($profile_fields as $profile_field) { foreach ($profile_fields as $profile_field) {
$custom_fields += self::buildField( $custom_fields += self::buildField(
'custom_' . $profile_field->order, 'custom_' . $profile_field->order,
$profile_field->label, $profile_field->label,
BBCode::convertForUriId($a->profile['uri-id'], $profile_field->value), BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
'aprofile custom' 'aprofile custom'
); );
}; };
//show subcribed forum if it is enabled in the usersettings //show subcribed forum if it is enabled in the usersettings
if (Feature::isEnabled($a->profile_uid, 'forumlist_profile')) { if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
$custom_fields += self::buildField( $custom_fields += self::buildField(
'forumlist', 'forumlist',
DI::l10n()->t('Forums:'), DI::l10n()->t('Forums:'),
ForumManager::profileAdvanced($a->profile_uid) ForumManager::profileAdvanced($profile['uid'])
); );
} }
@ -243,11 +243,11 @@ class Profile extends BaseProfile
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'), '$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'), '$advanced' => DI::l10n()->t('Advanced'),
'$is_owner' => $a->profile_uid == local_user(), '$is_owner' => $profile['uid'] == local_user(),
'$query_string' => DI::args()->getQueryString(), '$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields, '$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields, '$custom_fields' => $custom_fields,
'$profile' => $a->profile, '$profile' => $profile,
'$edit_link' => [ '$edit_link' => [
'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'), 'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'),
'title' => '', 'title' => '',

View file

@ -52,20 +52,20 @@ class Status extends BaseProfile
$a = DI::app(); $a = DI::app();
ProfileModel::load($a, $parameters['nickname']); $profile = ProfileModel::load($a, $parameters['nickname']);
if (empty($a->profile)) { if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
if (!$a->profile['net-publish']) { if (!$profile['net-publish']) {
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n"; DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
} }
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $a->profile['name']) . '"/>' . "\n"; DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $a->profile['name']) . '"/>' . "\n"; DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $a->profile['name']) . '"/>' . "\n"; DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $a->profile['name']) . '"/>' . "\n"; DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
$category = $datequery = $datequery2 = ''; $category = $datequery = $datequery2 = '';
@ -91,42 +91,42 @@ class Status extends BaseProfile
$hashtags = $_GET['tag'] ?? ''; $hashtags = $_GET['tag'] ?? '';
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['uid'])) { if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($profile['uid'])) {
return Login::form(); return Login::form();
} }
$o = ''; $o = '';
if ($a->profile['uid'] == local_user()) { if ($profile['uid'] == local_user()) {
Nav::setSelected('home'); Nav::setSelected('home');
} }
$remote_contact = Session::getRemoteContactID($a->profile['uid']); $remote_contact = Session::getRemoteContactID($profile['uid']);
$is_owner = local_user() == $a->profile['uid']; $is_owner = local_user() == $profile['uid'];
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact; $last_updated_key = "profile:" . $profile['uid'] . ":" . local_user() . ":" . $remote_contact;
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) {
notice(DI::l10n()->t('Access to this profile has been restricted.')); notice(DI::l10n()->t('Access to this profile has been restricted.'));
return ''; return '';
} }
$o .= self::getTabsHTML($a, 'status', $is_owner, $a->profile['nickname']); $o .= self::getTabsHTML($a, 'status', $is_owner, $profile);
$o .= Widget::commonFriendsVisitor($a->profile['uid'], $a->profile['nickname']); $o .= Widget::commonFriendsVisitor($profile['uid'], $profile['nickname']);
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY; $commpage = $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$commvisitor = $commpage && $remote_contact; $commvisitor = $commpage && $remote_contact;
DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $a->profile['nickname'] . '/status', $a->profile['profile_uid'] ?? 0, true); DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
DI::page()['aside'] .= Widget::categories(DI::baseUrl() . '/profile/' . $a->profile['nickname'] . '/status', XML::escape($category)); DI::page()['aside'] .= Widget::categories(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', XML::escape($category));
DI::page()['aside'] .= Widget::tagCloud(); DI::page()['aside'] .= Widget::tagCloud($profile['uid']);
if (Security::canWriteToUserWall($a->profile['uid'])) { if (Security::canWriteToUserWall($profile['uid'])) {
$x = [ $x = [
'is_owner' => $is_owner, 'is_owner' => $is_owner,
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'], 'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
'default_location' => $is_owner ? $a->user['default-location'] : '', 'default_location' => $is_owner ? $a->user['default-location'] : '',
'nickname' => $a->profile['nickname'], 'nickname' => $profile['nickname'],
'lockstate' => is_array($a->user) 'lockstate' => is_array($a->user)
&& (strlen($a->user['allow_cid']) && (strlen($a->user['allow_cid'])
|| strlen($a->user['allow_gid']) || strlen($a->user['allow_gid'])
@ -136,25 +136,25 @@ class Status extends BaseProfile
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->user, true) : '', 'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->user, true) : '',
'bang' => '', 'bang' => '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $a->profile['uid'], 'profile_uid' => $profile['uid'],
]; ];
$o .= status_editor($a, $x); $o .= status_editor($a, $x);
} }
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
$condition = Item::getPermissionsConditionArrayByUserId($a->profile['uid']); $condition = Item::getPermissionsConditionArrayByUserId($profile['uid']);
$last_updated_array = Session::get('last_updated', []); $last_updated_array = Session::get('last_updated', []);
if (!empty($category)) { if (!empty($category)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `category-view` WHERE `name` = ? AND `type` = ? AND `uid` = ?)", $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `category-view` WHERE `name` = ? AND `type` = ? AND `uid` = ?)",
$category, Category::CATEGORY, $a->profile['uid']]); $category, Category::CATEGORY, $profile['uid']]);
} }
if (!empty($hashtags)) { if (!empty($hashtags)) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` = ? AND `uid` = ?)", $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` = ? AND `uid` = ?)",
$hashtags, $a->profile['uid']]); $hashtags, $profile['uid']]);
} }
if (!empty($datequery)) { if (!empty($datequery)) {
@ -166,9 +166,9 @@ class Status extends BaseProfile
// Does the profile page belong to a forum? // Does the profile page belong to a forum?
// If not then we can improve the performance with an additional condition // If not then we can improve the performance with an additional condition
$condition2 = ['uid' => $a->profile['uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]]; $condition2 = ['uid' => $profile['uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
if (!DBA::exists('user', $condition2)) { if (!DBA::exists('user', $condition2)) {
$condition = DBA::mergeConditions($condition, ['contact-id' => $a->profile['id']]); $condition = DBA::mergeConditions($condition, ['contact-id' => $profile['id']]);
} }
if (DI::mode()->isMobile()) { if (DI::mode()->isMobile()) {
@ -186,7 +186,7 @@ class Status extends BaseProfile
GRAVITY_PARENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), GRAVITY_PARENT, GRAVITY_PARENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), GRAVITY_PARENT,
Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::OSTATUS]); Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::OSTATUS]);
$condition = DBA::mergeConditions($condition, ['uid' => $a->profile['uid'], 'network' => Protocol::FEDERATED, $condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
'visible' => true, 'deleted' => false]); 'visible' => true, 'deleted' => false]);
$pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network); $pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network);
@ -213,25 +213,25 @@ class Status extends BaseProfile
$items = Post::toArray($items_stmt); $items = Post::toArray($items_stmt);
if ($pager->getStart() == 0 && !empty($a->profile['uid'])) { if ($pager->getStart() == 0 && !empty($profile['uid'])) {
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED]]; $condition = ['private' => [Item::PUBLIC, Item::UNLISTED]];
$remote_user = Session::getRemoteContactID($a->profile['uid']); $remote_user = Session::getRemoteContactID($profile['uid']);
if (!empty($remote_user)) { if (!empty($remote_user)) {
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $a->profile['uid']); $permissionSets = DI::permissionSet()->selectByContactId($remote_user, $profile['uid']);
if (!empty($permissionSets)) { if (!empty($permissionSets)) {
$condition = ['psid' => array_merge($permissionSets->column('id'), $condition = ['psid' => array_merge($permissionSets->column('id'),
[DI::permissionSet()->getIdFromACL($a->profile['uid'], '', '', '', '')])]; [DI::permissionSet()->getIdFromACL($profile['uid'], '', '', '', '')])];
} }
} elseif ($a->profile['uid'] == local_user()) { } elseif ($profile['uid'] == local_user()) {
$condition = []; $condition = [];
} }
$pinned_items = Post::selectPinned($a->profile['uid'], ['uri-id', 'pinned'], $condition); $pinned_items = Post::selectPinned($profile['uid'], ['uri-id', 'pinned'], $condition);
$pinned = Post::toArray($pinned_items); $pinned = Post::toArray($pinned_items);
$items = array_merge($items, $pinned); $items = array_merge($items, $pinned);
} }
$o .= conversation($a, $items, 'profile', false, false, 'pinned_received', $a->profile['uid']); $o .= conversation($a, $items, 'profile', false, false, 'pinned_received', $profile['uid']);
$o .= $pager->renderMinimal(count($items)); $o .= $pager->renderMinimal(count($items));

View file

@ -22,6 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Widget;
use Friendica\DI; use Friendica\DI;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
@ -30,6 +31,7 @@ use Friendica\Core\Search;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\Probe; use Friendica\Network\Probe;
/** /**
@ -37,20 +39,22 @@ use Friendica\Network\Probe;
*/ */
class RemoteFollow extends BaseModule class RemoteFollow extends BaseModule
{ {
static $owner;
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
Profile::load(DI::app(), $parameters['profile']); self::$owner = User::getOwnerDataByNick($parameters['profile']);
DI::page()['aside'] = Widget\VCard::getHTML(self::$owner);
} }
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$a = DI::app();
if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) { if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
} }
if (empty($a->profile['uid'])) { if (empty(self::$owner)) {
notice(DI::l10n()->t('Profile unavailable.')); notice(DI::l10n()->t('Profile unavailable.'));
return; return;
} }
@ -73,15 +77,15 @@ class RemoteFollow extends BaseModule
return; return;
} }
Logger::notice('Remote request', ['url' => $url, 'follow' => $a->profile['url'], 'remote' => $data['subscribe']]); Logger::notice('Remote request', ['url' => $url, 'follow' => self::$owner['url'], 'remote' => $data['subscribe']]);
// Substitute our user's feed URL into $data['subscribe'] // Substitute our user's feed URL into $data['subscribe']
// Send the subscriber home to subscribe // Send the subscriber home to subscribe
// Diaspora needs the uri in the format user@domain.tld // Diaspora needs the uri in the format user@domain.tld
if ($data['network'] == Protocol::DIASPORA) { if ($data['network'] == Protocol::DIASPORA) {
$uri = urlencode($a->profile['addr']); $uri = urlencode(self::$owner['addr']);
} else { } else {
$uri = urlencode($a->profile['url']); $uri = urlencode(self::$owner['url']);
} }
$follow_link = str_replace('{uri}', $uri, $data['subscribe']); $follow_link = str_replace('{uri}', $uri, $data['subscribe']);
@ -90,14 +94,12 @@ class RemoteFollow extends BaseModule
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = DI::app(); if (empty(self::$owner)) {
if (empty($a->profile)) {
return ''; return '';
} }
$target_addr = $a->profile['addr']; $target_addr = self::$owner['addr'];
$target_url = $a->profile['url']; $target_url = self::$owner['url'];
$tpl = Renderer::getMarkupTemplate('auto_request.tpl'); $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
@ -110,7 +112,7 @@ class RemoteFollow extends BaseModule
'$cancel' => DI::l10n()->t('Cancel'), '$cancel' => DI::l10n()->t('Cancel'),
'$request' => 'remote_follow/' . $parameters['profile'], '$request' => 'remote_follow/' . $parameters['profile'],
'$name' => $a->profile['name'], '$name' => self::$owner['name'],
'$myaddr' => Profile::getMyURL(), '$myaddr' => Profile::getMyURL(),
]); ]);
return $o; return $o;

View file

@ -29,6 +29,7 @@ use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Profile as ProfileModel; use Friendica\Model\Profile as ProfileModel;
use Friendica\Model\User;
use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Network\HTTPException\ForbiddenException;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -38,21 +39,22 @@ class Profile extends BaseModule
{ {
$a = DI::app(); $a = DI::app();
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['uid'])) { // Ensure we've got a profile owner if updating.
$a->setProfileOwner($_GET['p'] ?? 0);
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->getProfileOwner())) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
$profile_uid = intval($_GET['p'] ?? 0); $remote_contact = Session::getRemoteContactID($a->getProfileOwner());
$is_owner = local_user() == $a->getProfileOwner();
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . local_user() . ":" . $remote_contact;
// Ensure we've got a profile owner if updating. if (!$is_owner && !$remote_contact) {
$a->profile['uid'] = $profile_uid; $user = User::getById($a->getProfileOwner(), ['hidewall']);
if ($user['hidewall']) {
$remote_contact = Session::getRemoteContactID($a->profile['uid']); throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
$is_owner = local_user() == $a->profile['uid']; }
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact;
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
} }
$o = ''; $o = '';
@ -62,7 +64,7 @@ class Profile extends BaseModule
} }
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
$sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']); $sql_extra = Item::getPermissionsSQLByUserId($a->getProfileOwner());
$last_updated_array = Session::get('last_updated', []); $last_updated_array = Session::get('last_updated', []);
@ -86,7 +88,7 @@ class Profile extends BaseModule
AND `visible` AND (NOT `deleted` OR `gravity` = ?) AND `visible` AND (NOT `deleted` OR `gravity` = ?)
AND `wall` $sql_extra4 $sql_extra AND `wall` $sql_extra4 $sql_extra
GROUP BY `parent-uri-id` ORDER BY `received` DESC", GROUP BY `parent-uri-id` ORDER BY `received` DESC",
$a->profile['uid'], $a->getProfileOwner(),
GRAVITY_ACTIVITY GRAVITY_ACTIVITY
); );
@ -99,7 +101,7 @@ class Profile extends BaseModule
$last_updated_array[$last_updated_key] = time(); $last_updated_array[$last_updated_key] = time();
Session::set('last_updated', $last_updated_array); Session::set('last_updated', $last_updated_array);
if ($is_owner && !$profile_uid && !DI::config()->get('theme', 'hide_eventlist')) { if ($is_owner && !$a->getProfileOwner() && !DI::config()->get('theme', 'hide_eventlist')) {
$o .= ProfileModel::getBirthdays(); $o .= ProfileModel::getBirthdays();
$o .= ProfileModel::getEventsReminderHTML(); $o .= ProfileModel::getEventsReminderHTML();
} }
@ -113,7 +115,7 @@ class Profile extends BaseModule
$items = DBA::toArray($items_stmt); $items = DBA::toArray($items_stmt);
$o .= conversation($a, $items, 'profile', $profile_uid, false, 'received', $a->profile['uid']); $o .= conversation($a, $items, 'profile', $a->getProfileOwner(), false, 'received', $a->getProfileOwner());
System::htmlUpdateExit($o); System::htmlUpdateExit($o);
} }

View file

@ -187,7 +187,7 @@ class Post
$edpost = false; $edpost = false;
if (local_user()) { if (local_user()) {
if (Strings::compareLink($a->contact['url'], $item['author-link'])) { if (Strings::compareLink(Session::get('my_url'), $item['author-link'])) {
if ($item["event-id"] != 0) { if ($item["event-id"] != 0) {
$edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")]; $edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")];
} else { } else {
@ -936,6 +936,8 @@ class Post
$uid = $conv->getProfileOwner(); $uid = $conv->getProfileOwner();
$parent_uid = $this->getDataValue('uid'); $parent_uid = $this->getDataValue('uid');
$contact = Contact::getById($a->getContactId());
$default_text = $this->getDefaultText(); $default_text = $this->getDefaultText();
if (!is_null($parent_uid) && ($uid != $parent_uid)) { if (!is_null($parent_uid) && ($uid != $parent_uid)) {
@ -953,9 +955,9 @@ class Post
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$default' => $default_text, '$default' => $default_text,
'$profile_uid' => $uid, '$profile_uid' => $uid,
'$mylink' => DI::baseUrl()->remove($a->contact['url'] ?? ''), '$mylink' => DI::baseUrl()->remove($contact['url'] ?? ''),
'$mytitle' => DI::l10n()->t('This is you'), '$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => DI::baseUrl()->remove($a->contact['thumb'] ?? ''), '$myphoto' => DI::baseUrl()->remove($contact['thumb'] ?? ''),
'$comment' => DI::l10n()->t('Comment'), '$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$loading' => DI::l10n()->t('Loading...'), '$loading' => DI::l10n()->t('Loading...'),
@ -970,7 +972,6 @@ class Post
'$prompttext' => DI::l10n()->t('Please enter a image/video/audio/webpage URL:'), '$prompttext' => DI::l10n()->t('Please enter a image/video/audio/webpage URL:'),
'$preview' => DI::l10n()->t('Preview'), '$preview' => DI::l10n()->t('Preview'),
'$indent' => $indent, '$indent' => $indent,
'$sourceapp' => DI::l10n()->t($a->sourcename),
'$rand_num' => Crypto::randomDigits(12) '$rand_num' => Crypto::randomDigits(12)
]); ]);
} }
@ -1000,15 +1001,7 @@ class Post
if ($this->isToplevel()) { if ($this->isToplevel()) {
if ($conv->getMode() !== 'profile') { if ($conv->getMode() !== 'profile') {
if ($this->getDataValue('wall') && !$this->getDataValue('self') && !empty($a->page_contact)) { if ($this->getDataValue('owner-link')) {
// On the network page, I am the owner. On the display page it will be the profile owner.
// This will have been stored in $a->page_contact by our calling page.
// Put this person as the wall owner of the wall-to-wall notice.
$this->owner_url = Contact::magicLinkByContact($a->page_contact);
$this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true;
} elseif ($this->getDataValue('owner-link')) {
$owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link'))); $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
$alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link'))); $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
$owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name')); $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));

View file

@ -79,11 +79,11 @@ class Thread
$this->writable = true; $this->writable = true;
break; break;
case 'profile': case 'profile':
$this->profile_owner = $a->profile['uid']; $this->profile_owner = $a->getProfileOwner();
$this->writable = Security::canWriteToUserWall($this->profile_owner); $this->writable = Security::canWriteToUserWall($this->profile_owner);
break; break;
case 'display': case 'display':
$this->profile_owner = $a->profile['uid']; $this->profile_owner = $a->getProfileOwner();
$this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable; $this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable;
break; break;
case 'community': case 'community':

View file

@ -142,9 +142,9 @@ class Authentication
if ($this->session->get('authenticated')) { if ($this->session->get('authenticated')) {
if ($this->session->get('visitor_id') && !$this->session->get('uid')) { if ($this->session->get('visitor_id') && !$this->session->get('uid')) {
$contact = $this->dba->selectFirst('contact', [], ['id' => $this->session->get('visitor_id')]); $contact = $this->dba->selectFirst('contact', ['id'], ['id' => $this->session->get('visitor_id')]);
if ($this->dba->isResult($contact)) { if ($this->dba->isResult($contact)) {
$a->contact = $contact; $a->setContactId($contact['id']);
} }
} }
@ -307,33 +307,13 @@ class Authentication
if (strlen($user_record['timezone'])) { if (strlen($user_record['timezone'])) {
date_default_timezone_set($user_record['timezone']); date_default_timezone_set($user_record['timezone']);
$a->timezone = $user_record['timezone']; $a->setTimeZone($user_record['timezone']);
} }
$masterUid = $user_record['uid']; $contact = $this->dba->selectFirst('contact', ['id'], ['uid' => $user_record['uid'], 'self' => true]);
if ($this->session->get('submanage')) {
$user = $this->dba->selectFirst('user', ['uid'], ['uid' => $this->session->get('submanage')]);
if ($this->dba->isResult($user)) {
$masterUid = $user['uid'];
}
}
$a->identities = User::identities($masterUid);
if ($login_initial) {
$this->logger->info('auth_identities: ' . print_r($a->identities, true));
}
if ($login_refresh) {
$this->logger->info('auth_identities refresh: ' . print_r($a->identities, true));
}
$contact = $this->dba->selectFirst('contact', [], ['uid' => $user_record['uid'], 'self' => true]);
if ($this->dba->isResult($contact)) { if ($this->dba->isResult($contact)) {
$a->contact = $contact; $a->setContactId($contact['id']);
$a->cid = $contact['id']; $this->session->set('cid', $contact['id']);
$this->session->set('cid', $a->cid);
} }
header('X-Account-Management-Status: active; name="' . $user_record['username'] . '"; id="' . $user_record['nickname'] . '"'); header('X-Account-Management-Status: active; name="' . $user_record['username'] . '"; id="' . $user_record['nickname'] . '"');
@ -342,10 +322,8 @@ class Authentication
$this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]); $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);
// Set the login date for all identities of the user // Set the login date for all identities of the user
if (!empty($masterUid)) { $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()],
$this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()], ['parent-uid' => $user_record['uid'], 'account_removed' => false]);
['parent-uid' => $masterUid, 'account_removed' => false]);
}
} }
if ($login_initial) { if ($login_initial) {

View file

@ -62,7 +62,7 @@ class Expire
$r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0"); $r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0");
while ($row = DBA::fetch($r)) { while ($row = DBA::fetch($r)) {
Logger::info('Calling expiry', ['user' => $row['uid'], 'username' => $row['username']]); Logger::info('Calling expiry', ['user' => $row['uid'], 'username' => $row['username']]);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
'Expire', (int)$row['uid']); 'Expire', (int)$row['uid']);
} }
DBA::close($r); DBA::close($r);
@ -70,7 +70,7 @@ class Expire
Logger::notice('calling hooks'); Logger::notice('calling hooks');
foreach (Hook::getByName('expire') as $hook) { foreach (Hook::getByName('expire') as $hook) {
Logger::info('Calling expire', ['hook' => $hook[1]]); Logger::info('Calling expire', ['hook' => $hook[1]]);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
'Expire', 'hook', $hook[1]); 'Expire', 'hook', $hook[1]);
} }

View file

@ -86,7 +86,7 @@ class Notifier
foreach ($inboxes as $inbox => $receivers) { foreach ($inboxes as $inbox => $receivers) {
$ap_contacts = array_merge($ap_contacts, $receivers); $ap_contacts = array_merge($ap_contacts, $receivers);
Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]); Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true], Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid); 'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
} }
} elseif ($cmd == Delivery::SUGGESTION) { } elseif ($cmd == Delivery::SUGGESTION) {
@ -94,7 +94,7 @@ class Notifier
$uid = $suggest->uid; $uid = $suggest->uid;
$recipients[] = $suggest->cid; $recipients[] = $suggest->cid;
} elseif ($cmd == Delivery::REMOVAL) { } elseif ($cmd == Delivery::REMOVAL) {
return self::notifySelfRemoval($target_id, $a->queue['priority'], $a->queue['created']); return self::notifySelfRemoval($target_id, $a->getQueueValue('priority'), $a->getQueueValue('created'));
} elseif ($cmd == Delivery::RELOCATION) { } elseif ($cmd == Delivery::RELOCATION) {
$uid = $target_id; $uid = $target_id;
@ -182,7 +182,7 @@ class Notifier
Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG); Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG);
if (!self::isRemovalActivity($cmd, $owner, Protocol::ACTIVITYPUB)) { if (!self::isRemovalActivity($cmd, $owner, Protocol::ACTIVITYPUB)) {
$apdelivery = self::activityPubDelivery($cmd, $target_item, $parent, $thr_parent, $a->queue['priority'], $a->queue['created'], $owner); $apdelivery = self::activityPubDelivery($cmd, $target_item, $parent, $thr_parent, $a->getQueueValue('priority'), $a->getQueueValue('created'), $owner);
$ap_contacts = $apdelivery['contacts']; $ap_contacts = $apdelivery['contacts'];
$delivery_queue_count += $apdelivery['count']; $delivery_queue_count += $apdelivery['count'];
} }
@ -339,7 +339,7 @@ class Notifier
if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== Delivery::UPLINK) if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== Delivery::UPLINK)
&& ($target_item['verb'] != Activity::ANNOUNCE)) { && ($target_item['verb'] != Activity::ANNOUNCE)) {
Worker::add($a->queue['priority'], 'Notifier', Delivery::UPLINK, $post_uriid, $sender_uid); Worker::add($a->getQueueValue('priority'), 'Notifier', Delivery::UPLINK, $post_uriid, $sender_uid);
} }
foreach ($items as $item) { foreach ($items as $item) {
@ -492,7 +492,7 @@ class Notifier
if (!empty($target_item)) { if (!empty($target_item)) {
Logger::log('Calling hooks for ' . $cmd . ' ' . $target_id, Logger::DEBUG); Logger::log('Calling hooks for ' . $cmd . ' ' . $target_id, Logger::DEBUG);
Hook::fork($a->queue['priority'], 'notifier_normal', $target_item); Hook::fork($a->getQueueValue('priority'), 'notifier_normal', $target_item);
Hook::callAll('notifier_end', $target_item); Hook::callAll('notifier_end', $target_item);
@ -581,10 +581,10 @@ class Notifier
// Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first. // Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
// The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts. // The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts.
// This is only important for high and medium priority tasks and not for Low priority jobs like deletions. // This is only important for high and medium priority tasks and not for Low priority jobs like deletions.
if (($contact['network'] == Protocol::DIASPORA) && in_array($a->queue['priority'], [PRIORITY_HIGH, PRIORITY_MEDIUM])) { if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [PRIORITY_HIGH, PRIORITY_MEDIUM])) {
$deliver_options = ['priority' => $a->queue['priority'], 'dont_fork' => true]; $deliver_options = ['priority' => $a->getQueueValue('priority'), 'dont_fork' => true];
} else { } else {
$deliver_options = ['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true]; $deliver_options = ['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true];
} }
if (Worker::add($deliver_options, 'Delivery', $cmd, $post_uriid, (int)$contact['id'], $sender_uid)) { if (Worker::add($deliver_options, 'Delivery', $cmd, $post_uriid, (int)$contact['id'], $sender_uid)) {
@ -631,7 +631,7 @@ class Notifier
Logger::info('Activating internal PuSH', ['item' => $target_id]); Logger::info('Activating internal PuSH', ['item' => $target_id]);
// Handling the pubsubhubbub requests // Handling the pubsubhubbub requests
PushSubscriber::publishFeed($owner['uid'], $a->queue['priority']); PushSubscriber::publishFeed($owner['uid'], $a->getQueueValue('priority'));
} }
return $delivery_queue_count; return $delivery_queue_count;
} }

View file

@ -42,7 +42,7 @@ class ProfileUpdate {
foreach ($inboxes as $inbox => $receivers) { foreach ($inboxes as $inbox => $receivers) {
Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG); Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
'APDelivery', Delivery::PROFILEUPDATE, 0, $inbox, $uid, $receivers); 'APDelivery', Delivery::PROFILEUPDATE, 0, $inbox, $uid, $receivers);
} }

View file

@ -1165,7 +1165,7 @@ aside .vcard .title {
} }
aside .vcard .detail { aside .vcard .detail {
display: table; display: table;
padding: 5px 0; padding: 2px 0;
} }
aside .xmpp { aside .xmpp {
display: table; display: table;

View file

@ -63,19 +63,22 @@
{{if $contact.location}} {{if $contact.location}}
<div class="location detail"> <div class="location detail">
<span class="location-label icon"><i class="fa fa-map-marker"></i></span> <span class="location-label icon"><i class="fa fa-map-marker"></i></span>
<span class="adr"> <span class="adr p-location">{{$contact.location}}</span>
<p class="p-location">{{$contact.location}}</p>
</span>
</div> </div>
{{/if}} {{/if}}
{{if $contact.xmpp}} {{if $contact.xmpp}}
<div class="xmpp"> <div class="xmpp detail">
<span class="xmpp-label icon"><i class="fa fa-comments"></i></span> <span class="xmpp-label icon"><i class="fa fa-comments"></i></span>
<span class="xmpp-data"><a href="xmpp:{{$contact.xmpp}}" rel="me" target="_blank" rel="noopener noreferrer">{{include file="sub/punct_wrap.tpl" text=$contact.xmpp}}</a></span> <span class="xmpp-data"><a href="xmpp:{{$contact.xmpp}}" rel="me" target="_blank" rel="noopener noreferrer">{{include file="sub/punct_wrap.tpl" text=$contact.xmpp}}</a></span>
</div> </div>
{{/if}} {{/if}}
{{if $network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$network_link nofilter}}</dd></dl>{{/if}} {{if $network_link}}
<div class="network detail">
<span class="network-label icon"><i class="fa fa-{{$network_avatar}}"></i></span>
<span class="x-network">{{$network_link nofilter}}</span>
</div>
{{/if}}
</div> </div>
</div> </div>