*
*/
-use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
-function message_init(App $a)
+function message_init()
{
$tabs = '';
]);
}
-function message_post(App $a)
+function message_post()
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
}
}
-function message_content(App $a)
+function message_content()
{
$o = '';
Nav::setSelected('messages');
return Login::form();
}
- $myprofile = DI::baseUrl() . '/profile/' . $a->getLoggedInUserNickname();
+ $myprofile = DI::baseUrl() . '/profile/' . DI::userSession()->getLocalUserNickname();
$tpl = Renderer::getMarkupTemplate('mail_head.tpl');
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
- '$nickname' => $a->getLoggedInUserNickname(),
+ '$nickname' => DI::userSession()->getLocalUserNickname(),
'$linkurl' => DI::l10n()->t('Please enter a link URL:')
]);
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
- '$nickname' => $a->getLoggedInUserNickname(),
+ '$nickname' => DI::userSession()->getLocalUserNickname(),
'$linkurl' => DI::l10n()->t('Please enter a link URL:')
]);
function render_messages(array $msg, string $t): string
{
- $a = DI::app();
-
$tpl = Renderer::getMarkupTemplate($t);
$rslt = '';
- $myprofile = DI::baseUrl() . '/profile/' . $a->getLoggedInUserNickname();
+ $myprofile = DI::baseUrl() . '/profile/' . DI::userSession()->getLocalUserNickname();
foreach ($msg as $rr) {
if ($rr['unknown']) {
return;
}
- $o = BaseProfile::getTabsHTML('notes', true, $a->getLoggedInUserNickname(), false);
+ $o = BaseProfile::getTabsHTML('notes', true, DI::userSession()->getLocalUserNickname(), false);
if (!$update) {
$o .= '<h3>' . DI::l10n()->t('Personal Notes') . '</h3>';
*
*/
-use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
-use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
-function photos_init(App $a)
+function photos_init()
{
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
return;
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
- $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner['uid']));
-
$albums = Photo::getAlbums($owner['uid']);
$albums_visible = ((intval($owner['hidewall']) && !DI::userSession()->isAuthenticated()) ? false : true);
return;
}
-function photos_post(App $a)
+function photos_post()
{
$user = User::getByNickname(DI::args()->getArgv()[1]);
if (!DBA::isResult($user)) {
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
- DI::baseUrl()->redirect('photos/' . $a->getLoggedInUserNickname() . '/album/' . bin2hex($newalbum));
+ DI::baseUrl()->redirect('photos/' . DI::userSession()->getLocalUserNickname() . '/album/' . bin2hex($newalbum));
return; // NOTREACHED
}
}
}
-function photos_content(App $a)
+function photos_content()
{
// URLs:
// photos/name/upload
$tpl = Renderer::getMarkupTemplate('photos_upload.tpl');
- $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()));
+ $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId()));
$o .= Renderer::replaceMacros($tpl, [
'$pagename' => DI::l10n()->t('Upload Photos'),
'$selname' => $selname,
'$permissions' => DI::l10n()->t('Permissions'),
'$aclselect' => $aclselect_e,
- '$lockstate' => ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock',
+ '$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
'$alt_uploader' => $ret['addon_text'],
'$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
'$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
- $aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
+ $aclselect_e = ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
$edit = Renderer::replaceMacros($edit_tpl, [
'$id' => $ph[0]['id'],
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
- Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
+ Logger::notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
DI::sysmsg()->addNotice(self::getFormSecurityStandardErrorMessage());
DI::baseUrl()->redirect($err_redirect);
public static function checkFormSecurityTokenForbiddenOnError(string $typename = '', string $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
- Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
+ Logger::notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
throw new \Friendica\Network\HTTPException\ForbiddenException();
return $fields;
}
- if (Network::isLocalLink($avatar) || empty($avatar)) {
+ if (DI::baseUrl()->isLocalUrl($avatar) || empty($avatar)) {
self::deleteCache($contact);
return $fields;
}
return $fields;
}
- if (Network::isLocalLink($contact['avatar']) || empty($contact['avatar'])) {
+ if (DI::baseUrl()->isLocalUrl($contact['avatar']) || empty($contact['avatar'])) {
self::deleteCache($contact);
return $fields;
}
DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
}
- if (Network::isLocalLink($url) && ($local_uid = User::getIdForURL($url))) {
+ if (DI::baseUrl()->isLocalUrl($url) && ($local_uid = User::getIdForURL($url))) {
try {
$data = Transmitter::getProfile($local_uid);
$local_owner = User::getOwnerDataById($local_uid);
{
preg_match_all("/\[attachment\](.*?)\[\/attachment\]/ism", $post['body'], $matches, PREG_SET_ORDER);
foreach ($matches as $attachment) {
- if (Network::isLocalLink($attachment[1]) && preg_match('|.*?/attach/(\d+)|', $attachment[1], $match)) {
+ if (DI::baseUrl()->isLocalUrl($attachment[1]) && preg_match('|.*?/attach/(\d+)|', $attachment[1], $match)) {
$fields = [
'allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'],
'deny_cid' => $post['deny_cid'], 'deny_gid' => $post['deny_gid']
{
preg_match_all("/\[attachment\](.*?)\[\/attachment\]/ism", $body, $matches, PREG_SET_ORDER);
foreach ($matches as $attachment) {
- if (Network::isLocalLink($attachment[1]) && preg_match('|.*?/attach/(\d+)|', $attachment[1], $match)) {
+ if (DI::baseUrl()->isLocalUrl($attachment[1]) && preg_match('|.*?/attach/(\d+)|', $attachment[1], $match)) {
$attach = self::getById($match[1], $uid);
if (empty($attach)) {
return $body;
return;
}
- if (Network::isLocalLink($contact['url'])) {
+ if (DI::baseUrl()->isLocalUrl($contact['url'])) {
return;
}
return $contact;
}
- $local = !empty($contact['url']) && Network::isLocalLink($contact['url']);
+ $local = !empty($contact['url']) && DI::baseUrl()->isLocalUrl($contact['url']);
if (!$local && !empty($contact['id']) && !empty($contact['avatar'])) {
self::updateAvatar($contact['id'], $contact['avatar'], true);
if (($uid == 0) && !$force && empty($contact['thumb']) && empty($contact['micro']) && !$create_cache) {
if (($contact['avatar'] != $avatar) || empty($contact['blurhash'])) {
$update_fields = ['avatar' => $avatar];
- if (!Network::isLocalLink($avatar)) {
+ if (!DI::baseUrl()->isLocalUrl($avatar)) {
try {
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
$cache_avatar = DI::config()->get('system', 'cache_contact_avatar');
// Local contact avatars don't need to be cached
- if ($cache_avatar && Network::isLocalLink($contact['url'])) {
+ if ($cache_avatar && DI::baseUrl()->isLocalUrl($contact['url'])) {
$cache_avatar = !DBA::exists('contact', ['nurl' => $contact['nurl'], 'self' => true]);
}
'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', 'owner-gsid',
'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-gsid',
'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
- 'writable', 'restrictions', 'self', 'cid', 'alias',
+ 'writable', 'restrictions', 'self', 'cid', 'alias', 'post-reason',
'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-ignore', 'event-id',
{
if (!empty($item['plink']) && Network::isValidHttpUrl($item['plink'])) {
$plink = $item['plink'];
- } elseif (!empty($item['uri']) && Network::isValidHttpUrl($item['uri']) && !Network::isLocalLink($item['uri'])) {
+ } elseif (!empty($item['uri']) && Network::isValidHttpUrl($item['uri']) && !DI::baseUrl()->isLocalUrl($item['uri'])) {
$plink = $item['uri'];
}
*/
public static function fetchAdditionalData(array $media): array
{
- if (Network::isLocalLink($media['url'])) {
+ if (DI::baseUrl()->isLocalUrl($media['url'])) {
$media = self::fetchLocalData($media);
if (preg_match('|.*?/search\?(.+)|', $media['url'], $matches)) {
return $media;
protected function rawContent(array $request = [])
{
- $nickname = $this->parameters['nickname'] ?? $this->app->getLoggedInUserNickname();
+ $nickname = $this->parameters['nickname'] ?? $this->session->getLocalUserNickname();
if (!$nickname) {
throw new HTTPException\UnauthorizedException();
}
$this->page->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
$this->page->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
- $is_owner = $nickname == $this->app->getLoggedInUserNickname();
+ $is_owner = $nickname == $this->session->getLocalUserNickname();
$htpl = Renderer::getMarkupTemplate('calendar/calendar_head.tpl');
$this->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
{
if (DI::userSession()->getLocalUserId() && ($this->parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user
- $nickname = DI::app()->getLoggedInUserNickname();
+ $nickname = DI::userSession()->getLocalUserNickname();
} elseif (empty($this->parameters['action'])) {
// Show the profile hCard
$nickname = $this->parameters['profile'];
Hook::callAll('home_init', $ret);
- if (DI::userSession()->getLocalUserId() && ($app->getLoggedInUserNickname())) {
+ if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserNickname())) {
DI::baseUrl()->redirect('network');
}
'$folders' => false,
'$files' => $fileArray,
'$cancel' => $this->t('Cancel'),
- '$nickname' => $this->app->getLoggedInUserNickname(),
+ '$nickname' => $this->session->getLocalUserNickname(),
'$upload' => $this->t('Upload'),
]);
'$folders' => $albums,
'$files' => $photosArray,
'$cancel' => $this->t('Cancel'),
- '$nickname' => $this->app->getLoggedInUserNickname(),
+ '$nickname' => $this->session->getLocalUserNickname(),
'$upload' => $this->t('Upload'),
]);
$scale = $photo['scale'] ?? $record['loq'];
return [
- sprintf('%s/photos/%s/image/%s', $this->baseUrl, $this->app->getLoggedInUserNickname(), $record['resource-id']),
+ sprintf('%s/photos/%s/image/%s', $this->baseUrl, $this->session->getLocalUserNickname(), $record['resource-id']),
$filename_e,
sprintf('%s/photo/%s-%s%s', $this->baseUrl, $record['resource-id'], $scale, $ext),
$record['desc'],
$which = $this->parameters['nick'];
} elseif (DI::userSession()->getLocalUserId() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
// view infos about a known profile (needs a login)
- $which = $a->getLoggedInUserNickname();
+ $which = DI::userSession()->getLocalUserNickname();
} else {
$this->jsonError(403, 'Authentication required');
}
return false;
}
- if (Network::isLocalLink($url) && preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $url, $matches)) {
+ if (DI::baseUrl()->isLocalUrl($url) && preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $url, $matches)) {
return MPhoto::getPhoto($matches[1], $matches[2], self::getCurrentUserID());
}
return false;
}
- if (Network::isLocalLink($media['url']) && preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $media['url'], $matches)) {
+ if (DI::baseUrl()->isLocalUrl($media['url']) && preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $media['url'], $matches)) {
return MPhoto::getPhoto($matches[1], $matches[2], self::getCurrentUserID());
}
}
// For local users directly use the photo record that is marked as the profile
- if (Network::isLocalLink($contact['url'])) {
+ if (DI::baseUrl()->isLocalUrl($contact['url'])) {
$contact = Contact::selectFirst($fields, ['nurl' => $contact['nurl'], 'self' => true]);
if (!empty($contact)) {
if ($customsize <= Proxy::PIXEL_MICRO) {
}
// If it is a local link, we save resources by just redirecting to it.
- if (!empty($url) && Network::isLocalLink($url)) {
+ if (!empty($url) && DI::baseUrl()->isLocalUrl($url)) {
System::externalRedirect($url);
}
} else {
$url = Contact::getDefaultAvatar($contact ?: [], Proxy::SIZE_SMALL);
}
- if (Network::isLocalLink($url)) {
+ if (DI::baseUrl()->isLocalUrl($url)) {
System::externalRedirect($url);
}
}
return false;
}
- if (Network::isLocalLink($contact['url'])) {
+ if (DI::baseUrl()->isLocalUrl($contact['url'])) {
$header_uid = User::getIdForURL($contact['url']);
if (empty($header_uid)) {
throw new HTTPException\NotFoundException();
$url = $contact['header'];
} else {
$url = Contact::getDefaultHeader($contact);
- if (Network::isLocalLink($url)) {
+ if (DI::baseUrl()->isLocalUrl($url)) {
System::externalRedirect($url);
}
}
$default = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
}
- if (Network::isLocalLink($default)) {
+ if (DI::baseUrl()->isLocalUrl($default)) {
System::externalRedirect($default);
}
$this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('jot-header.tpl'), [
'$ispublic' => ' ',
'$geotag' => '',
- '$nickname' => $this->app->getLoggedInUserNickname(),
+ '$nickname' => $this->session->getLocalUserNickname(),
'$is_mobile' => $this->mode->isMobile(),
]);
$a = DI::app();
- $o = self::getTabsHTML('schedule', true, $a->getLoggedInUserNickname(), false);
+ $o = self::getTabsHTML('schedule', true, DI::userSession()->getLocalUserNickname(), false);
$schedule = [];
$delayed = DBA::select('delayed-post', [], ['uid' => DI::userSession()->getLocalUserId()]);
$username = $user['username'];
$email = $user['email'];
- $nickname = $a->getLoggedInUserNickname();
+ $nickname = DI::userSession()->getLocalUserNickname();
$timezone = $user['timezone'];
$language = $user['language'];
$notify = $user['notify-flags'];
$selectionW = intval($_POST['width'] ?? 0);
$selectionH = intval($_POST['height'] ?? 0);
- $path = 'profile/' . DI::app()->getLoggedInUserNickname();
+ $path = 'profile/' . DI::userSession()->getLocalUserNickname();
$base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId(), 'scale' => $scale]);
if (DBA::isResult($base_image)) {
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
- DI::baseUrl()->redirect('profile/' . DI::app()->getLoggedInUserNickname());
+ DI::baseUrl()->redirect('profile/' . DI::userSession()->getLocalUserNickname());
}
$Image = Photo::getImageForPhoto($photos[0]);
DI::l10n()->t('or'),
($newuser) ?
'<a href="' . DI::baseUrl() . '">' . DI::l10n()->t('skip this step') . '</a>'
- : '<a href="' . DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname() . '/photos">'
+ : '<a href="' . DI::baseUrl() . '/profile/' . DI::userSession()->getLocalUserNickname() . '/photos">'
. DI::l10n()->t('select a photo from your photo albums') . '</a>'
),
]);
namespace Friendica\Navigation\Notifications\Factory;
use Exception;
-use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\BaseFactory;
use Friendica\Content\Text\BBCode;
/** @var string */
private $nick;
- public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session)
+ public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session)
{
parent::__construct($logger);
$this->l10n = $l10n;
$this->pConfig = $pConfig;
$this->session = $session;
- $this->nick = $app->getLoggedInUserNickname() ?? '';
+ $this->nick = $session->getLocalUserNickname() ?? '';
}
/**
return $data;
}
- if (Network::isLocalLink($url) && ($data = Photo::getResourceData($url))) {
+ if (DI::baseUrl()->isLocalUrl($url) && ($data = Photo::getResourceData($url))) {
$photo = Photo::selectFirst([], ['resource-id' => $data['guid'], 'scale' => $data['scale']]);
if (!empty($photo)) {
$img_str = Photo::getImageDataForPhoto($photo);
return true;
}
- return Network::isLocalLink($url);
+ return DI::baseUrl()->isLocalUrl($url);
}
/**
foreach ($inboxes as $inbox => $receivers) {
$contacts = array_merge($contacts, $receivers);
- if ((count($receivers) == 1) && Network::isLocalLink($inbox)) {
+ if ((count($receivers) == 1) && DI::baseUrl()->isLocalUrl($inbox)) {
$contact = Contact::getById($receivers[0], ['url']);
if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::MAIL]) && ($target_uid = User::getIdForURL($contact['url']))) {
if ($cmd == Delivery::DELETION) {
}
continue;
}
- } elseif ((count($receivers) >= 1) && Network::isLocalLink($inbox)) {
+ } elseif ((count($receivers) >= 1) && DI::baseUrl()->isLocalUrl($inbox)) {
Logger::info('Is this a thing?', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
}
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
-function vier_init(App $a)
+function vier_init()
{
Renderer::setActiveTemplateEngine('smarty3');
if (
DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
&& (
- $args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '')
+ $args->get(0) === 'profile' && $args->get(1) === (DI::userSession()->getLocalUserNickname() ?? '')
|| $args->get(0) === 'network' && DI::userSession()->getLocalUserId()
)
) {
}
/**
- * @param int|null $uid
* @return null
* @see \Friendica\Core\Theme::getBackgroundColor()
* @TODO Implement this function
*/
-function vier_get_background_color(int $uid = null)
+function vier_get_background_color()
{
return null;
}
/**
- * @param int|null $uid
* @return null
* @see \Friendica\Core\Theme::getThemeColor()
* @TODO Implement this function
*/
-function vier_get_theme_color(int $uid = null)
+function vier_get_theme_color()
{
return null;
}