old boot.php functions replaced in src/module (3)

This commit is contained in:
Michael 2022-10-19 04:40:06 +00:00 committed by Hypolite Petovan
parent 83390d4b00
commit ae6d67ed1f
22 changed files with 158 additions and 147 deletions

View file

@ -25,6 +25,7 @@ use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
@ -43,11 +44,11 @@ class Index extends BaseSettings
{
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
$profile = Profile::getByUID(local_user());
$profile = Profile::getByUID(Session::getLocalUser());
if (!DBA::isResult($profile)) {
return;
}
@ -101,12 +102,12 @@ class Index extends BaseSettings
}
$profileFieldsNew = self::getProfileFieldsFromInput(
local_user(),
Session::getLocalUser(),
$_REQUEST['profile_field'],
$_REQUEST['profile_field_order']
);
DI::profileField()->saveCollectionForUser(local_user(), $profileFieldsNew);
DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew);
$result = Profile::update(
[
@ -124,7 +125,7 @@ class Index extends BaseSettings
'pub_keywords' => $pub_keywords,
'prv_keywords' => $prv_keywords,
],
local_user()
Session::getLocalUser()
);
if (!$result) {
@ -137,7 +138,7 @@ class Index extends BaseSettings
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
return Login::form();
}
@ -146,7 +147,7 @@ class Index extends BaseSettings
$o = '';
$profile = User::getOwnerDataById(local_user());
$profile = User::getOwnerDataById(Session::getLocalUser());
if (!DBA::isResult($profile)) {
throw new HTTPException\NotFoundException();
}
@ -158,7 +159,7 @@ class Index extends BaseSettings
$custom_fields = [];
$profileFields = DI::profileField()->selectByUserId(local_user());
$profileFields = DI::profileField()->selectByUserId(Session::getLocalUser());
foreach ($profileFields as $profileField) {
/** @var ProfileField $profileField */
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(

View file

@ -58,7 +58,7 @@ class Crop extends BaseSettings
$path = 'profile/' . DI::app()->getLoggedInUserNickname();
$base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => local_user(), 'scale' => $scale]);
$base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'scale' => $scale]);
if (DBA::isResult($base_image)) {
$Image = Photo::getImageForPhoto($base_image);
if (empty($Image)) {
@ -67,7 +67,7 @@ class Crop extends BaseSettings
if ($Image->isValid()) {
// If setting for the default profile, unset the profile photo flag from any other photos I own
DBA::update('photo', ['profile' => 0], ['uid' => local_user()]);
DBA::update('photo', ['profile' => 0], ['uid' => Session::getLocalUser()]);
// Normalizing expected square crop parameters
$selectionW = $selectionH = min($selectionW, $selectionH);
@ -92,11 +92,11 @@ class Crop extends BaseSettings
$Image->scaleDown(300);
}
$condition = ['resource-id' => $resource_id, 'uid' => local_user(), 'contact-id' => 0];
$condition = ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'contact-id' => 0];
$r = Photo::store(
$Image,
local_user(),
Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
@ -114,7 +114,7 @@ class Crop extends BaseSettings
$r = Photo::store(
$Image,
local_user(),
Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
@ -132,7 +132,7 @@ class Crop extends BaseSettings
$r = Photo::store(
$Image,
local_user(),
Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
@ -146,12 +146,12 @@ class Crop extends BaseSettings
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
}
Contact::updateSelfFromUserID(local_user(), true);
Contact::updateSelfFromUserID(Session::getLocalUser(), true);
DI::sysmsg()->addInfo(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.'));
// Update global directory in background
Profile::publishUpdate(local_user());
Profile::publishUpdate(Session::getLocalUser());
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
}
@ -170,7 +170,7 @@ class Crop extends BaseSettings
$resource_id = $this->parameters['guid'];
$photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => local_user()], ['order' => ['scale' => false]]);
$photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()], ['order' => ['scale' => false]]);
if (!DBA::isResult($photos)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.'));
}
@ -185,14 +185,14 @@ class Crop extends BaseSettings
// set an already uloaded photo as profile photo
// if photo is in 'Profile Photos', change it in db
if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) {
Photo::update(['profile' => false], ['uid' => local_user()]);
Photo::update(['profile' => false], ['uid' => Session::getLocalUser()]);
Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => local_user()]);
Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()]);
Contact::updateSelfFromUserID(local_user(), true);
Contact::updateSelfFromUserID(Session::getLocalUser(), true);
// Update global directory in background
Profile::publishUpdate(local_user());
Profile::publishUpdate(Session::getLocalUser());
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));

View file

@ -92,13 +92,13 @@ class Index extends BaseSettings
$filename = '';
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
}
}
@ -118,7 +118,7 @@ class Index extends BaseSettings
$newuser = $args->get($args->getArgc() - 1) === 'new';
$contact = Contact::selectFirst(['avatar'], ['uid' => local_user(), 'self' => true]);
$contact = Contact::selectFirst(['avatar'], ['uid' => Session::getLocalUser(), 'self' => true]);
$tpl = Renderer::getMarkupTemplate('settings/profile/photo/index.tpl');
$o = Renderer::replaceMacros($tpl, [