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

This commit is contained in:
Michael 2022-10-19 04:35:37 +00:00 committed by Hypolite Petovan
parent b36d4eb0dd
commit c9f17e1ef5
21 changed files with 102 additions and 88 deletions

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Contact\Introduction\Repository\Introduction;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
@ -72,14 +73,14 @@ class Notification extends BaseModule
*/
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
$request_id = $this->parameters['id'] ?? false;
if ($request_id) {
$intro = $this->introductionRepo->selectOneById($request_id, local_user());
$intro = $this->introductionRepo->selectOneById($request_id, Session::getLocalUser());
switch ($_POST['submit']) {
case $this->l10n->t('Discard'):
@ -103,14 +104,14 @@ class Notification extends BaseModule
*/
protected function rawContent(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
if ($this->args->get(1) === 'mark' && $this->args->get(2) === 'all') {
try {
$this->notificationRepo->setAllSeenForUser(local_user());
$success = $this->notifyRepo->setAllSeenForUser(local_user());
$this->notificationRepo->setAllSeenForUser(Session::getLocalUser());
$success = $this->notifyRepo->setAllSeenForUser(Session::getLocalUser());
} catch (\Exception $e) {
$this->logger->warning('set all seen failed.', ['exception' => $e]);
$success = false;
@ -131,7 +132,7 @@ class Notification extends BaseModule
*/
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.'));
return Login::form();
}
@ -150,11 +151,11 @@ class Notification extends BaseModule
private function handleNotify(int $notifyId)
{
$Notify = $this->notifyRepo->selectOneById($notifyId);
if ($Notify->uid !== local_user()) {
if ($Notify->uid !== Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
$Notify->setSeen();
$this->notifyRepo->save($Notify);
} else {
@ -175,11 +176,11 @@ class Notification extends BaseModule
private function handleNotification(int $notificationId)
{
$Notification = $this->notificationRepo->selectOneById($notificationId);
if ($Notification->uid !== local_user()) {
if ($Notification->uid !== Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
$Notification->setSeen();
$this->notificationRepo->save($Notification);
} else {