Get rid of App->user completely

This commit is contained in:
Michael 2021-08-08 19:30:21 +00:00
commit 28090bd793
39 changed files with 158 additions and 234 deletions

View file

@ -26,12 +26,7 @@ require_once __DIR__ . '/../include/api.php';
function api_post(App $a)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
if (empty($a->getUserId()) || $a->getUserId() != local_user()) {
if (!$a->isLoggedIn()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}

View file

@ -273,18 +273,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
// We need the editor here to be able to reshare an item.
if ($is_owner && !$update) {
$x = [
'is_owner' => true,
'allow_location' => $a->getUserValue('allow_location'),
'default_location' => $a->getUserValue('default-location'),
'nickname' => $a->getNickname(),
'lockstate' => ACL::getLockstateForUserId($a->getUserId()) ? 'lock' : 'unlock',
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
];
$o .= status_editor($a, $x, 0, true);
$o .= status_editor($a, [], 0, true);
}
$sql_extra = Item::getPermissionsSQLByUserId($page_uid);

View file

@ -27,6 +27,7 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Util\Crypto;
function editpost_content(App $a)
@ -55,6 +56,8 @@ function editpost_content(App $a)
return;
}
$user = User::getById(local_user());
$geotag = '';
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
@ -107,7 +110,7 @@ function editpost_content(App $a)
'$posttype' => $item['post-type'],
'$content' => undo_post_tagging($item['body']),
'$post_id' => $post_id,
'$defloc' => $a->getUserValue('default-location'),
'$defloc' => $user['default-location'],
'$visitor' => 'none',
'$pvisit' => 'none',
'$emailcc' => DI::l10n()->t('CC: email addresses'),

View file

@ -513,7 +513,7 @@ function events_content(App $a)
$fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00';
if (!$cid && in_array($mode, ['new', 'copy'])) {
$acl = ACL::getFullSelectorHTML(DI::page(), $a->user, false, ACL::getDefaultUserPermissions($orig_event));
$acl = ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), false, ACL::getDefaultUserPermissions($orig_event));
} else {
$acl = '';
}

View file

@ -175,7 +175,7 @@ function follow_process(App $a, string $url)
{
$return_path = 'follow?url=' . urlencode($url);
$result = Contact::createFromProbe($a->user, $url, true);
$result = Contact::createFromProbe($a->getUserId(), $url);
if ($result['success'] == false) {
// Possibly it is a remote item and not an account

View file

@ -51,15 +51,8 @@ function notes_content(App $a, $update = false)
$o .= '<h3>' . DI::l10n()->t('Personal Notes') . '</h3>';
$x = [
'is_owner' => true,
'allow_location' => (($a->getUserValue('allow_location')) ? true : false),
'default_location' => $a->getUserValue('default-location'),
'nickname' => $a->getNickname(),
'lockstate' => 'lock',
'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(local_user(), DI::l10n()->t('Personal notes are visible only by yourself.')),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
'button' => DI::l10n()->t('Save'),
'acl_data' => '',
];

View file

@ -111,7 +111,7 @@ function ostatus_subscribe_content(App $a)
$probed = Contact::getByURL($url);
if (in_array($probed['network'], Protocol::FEDERATED)) {
$result = Contact::createFromProbe($a->user, $probed['url']);
$result = Contact::createFromProbe($a->getUserId(), $probed['url']);
if ($result['success']) {
$o .= ' - ' . DI::l10n()->t('success');
} else {

View file

@ -948,7 +948,7 @@ function photos_content(App $a)
$tpl = Renderer::getMarkupTemplate('photos_upload.tpl');
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->user));
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getUserId()));
$o .= Renderer::replaceMacros($tpl,[
'$pagename' => DI::l10n()->t('Upload Photos'),
@ -1307,7 +1307,7 @@ function photos_content(App $a)
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
$aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->user, false, ACL::getDefaultUserPermissions($ph[0]));
$aclselect_e = ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
$edit = Renderer::replaceMacros($edit_tpl, [
'$id' => $ph[0]['id'],

View file

@ -69,7 +69,7 @@ function removeme_post(App $a)
DI::emailer()->send($email);
}
if (User::getIdFromPasswordAuthentication($a->user, trim($_POST['qxz_password']))) {
if (User::getIdFromPasswordAuthentication($a->getUserId(), trim($_POST['qxz_password']))) {
User::remove($a->getUserId());
unset($_SESSION['authenticated']);

View file

@ -70,7 +70,7 @@ function repair_ostatus_content(App $a) {
$o .= "<p>".DI::l10n()->t("Keep this window open until done.")."</p>";
Contact::createFromProbe($a->user, $r[0]["url"], true);
Contact::createFromProbe($a->getUserId(), $r[0]["url"]);
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . DI::baseUrl() . '/repair_ostatus?counter='.$counter.'">';

View file

@ -53,7 +53,8 @@ function settings_init(App $a)
function settings_post(App $a)
{
if (!local_user()) {
if (!$a->isLoggedIn()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -61,11 +62,6 @@ function settings_post(App $a)
return;
}
if (empty($a->getUserId()) || $a->getUserId() != local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'addon')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
@ -752,7 +748,7 @@ function settings_content(App $a)
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail , DI::l10n()->t("\x28to prevent spam abuse\x29")],
'$group_select' => Group::displayGroupSelection(local_user(), $user['def_gid']),
'$permissions' => DI::l10n()->t('Default Post Permissions'),
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->user),
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getUserId()),
'$expire' => [
'label' => DI::l10n()->t('Expiration settings'),