mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:10:11 +00:00
old boot.php functions replaced in src/module (2)
This commit is contained in:
parent
b36d4eb0dd
commit
c9f17e1ef5
21 changed files with 102 additions and 88 deletions
|
@ -28,6 +28,7 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module\Contact;
|
||||
|
@ -61,13 +62,13 @@ class Posts extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
// Backward compatibility: Ensure to use the public contact when the user contact is provided
|
||||
// Remove by version 2022.03
|
||||
$data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
|
||||
$data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
|
||||
if (empty($data)) {
|
||||
throw new NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ class Posts extends BaseModule
|
|||
throw new NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
||||
$localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
|
||||
$localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
|
||||
if ($localRelationship->rel === Model\Contact::SELF) {
|
||||
$this->baseUrl->redirect('profile/' . $contact['nick']);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -74,7 +75,7 @@ class Profile extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,7 @@ class Profile extends BaseModule
|
|||
|
||||
// Backward compatibility: The update still needs a user-specific contact ID
|
||||
// Change to user-contact table check by version 2022.03
|
||||
$cdata = Contact::getPublicAndUserContactID($contact_id, local_user());
|
||||
$cdata = Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
|
||||
if (empty($cdata['user']) || !DBA::exists('contact', ['id' => $cdata['user'], 'deleted' => false])) {
|
||||
return;
|
||||
}
|
||||
|
@ -124,20 +125,20 @@ class Profile extends BaseModule
|
|||
$fields['info'] = $_POST['info'];
|
||||
}
|
||||
|
||||
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => local_user()])) {
|
||||
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => Session::getLocalUser()])) {
|
||||
DI::sysmsg()->addNotice($this->t('Failed to update contact record.'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return Module\Security\Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
// Backward compatibility: Ensure to use the public contact when the user contact is provided
|
||||
// Remove by version 2022.03
|
||||
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
|
||||
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
|
||||
if (empty($data)) {
|
||||
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ class Profile extends BaseModule
|
|||
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
||||
$localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
|
||||
$localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
|
||||
|
||||
if ($localRelationship->rel === Contact::SELF) {
|
||||
$this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
|
||||
|
@ -173,12 +174,12 @@ class Profile extends BaseModule
|
|||
if ($cmd === 'block') {
|
||||
if ($localRelationship->blocked) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setBlocked($contact['id'], local_user(), false);
|
||||
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), false);
|
||||
|
||||
$message = $this->t('Contact has been unblocked');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setBlocked($contact['id'], local_user(), true);
|
||||
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), true);
|
||||
$message = $this->t('Contact has been blocked');
|
||||
}
|
||||
|
||||
|
@ -189,12 +190,12 @@ class Profile extends BaseModule
|
|||
if ($cmd === 'ignore') {
|
||||
if ($localRelationship->ignored) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setIgnored($contact['id'], local_user(), false);
|
||||
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), false);
|
||||
|
||||
$message = $this->t('Contact has been unignored');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setIgnored($contact['id'], local_user(), true);
|
||||
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), true);
|
||||
$message = $this->t('Contact has been ignored');
|
||||
}
|
||||
|
||||
|
@ -223,8 +224,8 @@ class Profile extends BaseModule
|
|||
'$baseurl' => $this->baseUrl->get(true),
|
||||
]);
|
||||
|
||||
$contact['blocked'] = Contact\User::isBlocked($contact['id'], local_user());
|
||||
$contact['readonly'] = Contact\User::isIgnored($contact['id'], local_user());
|
||||
$contact['blocked'] = Contact\User::isBlocked($contact['id'], Session::getLocalUser());
|
||||
$contact['readonly'] = Contact\User::isIgnored($contact['id'], Session::getLocalUser());
|
||||
|
||||
switch ($localRelationship->rel) {
|
||||
case Contact::FRIEND: $relation_text = $this->t('You are mutual friends with %s', $contact['name']); break;
|
||||
|
@ -485,7 +486,7 @@ class Profile extends BaseModule
|
|||
*/
|
||||
private static function updateContactFromProbe(int $contact_id)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, Session::getLocalUser()], 'deleted' => false]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
@ -54,11 +55,11 @@ class Revoke extends BaseModule
|
|||
|
||||
$this->dba = $dba;
|
||||
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user());
|
||||
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], Session::getLocalUser());
|
||||
if (!$this->dba->isResult($data)) {
|
||||
throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ class Revoke extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
throw new HTTPException\UnauthorizedException();
|
||||
}
|
||||
|
||||
|
@ -95,7 +96,7 @@ class Revoke extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue