X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FFriendSuggest.php;h=71d373000ff1e9a8bc25ac4ace64afcb2bdf1644;hb=ed520a3f39ec7136db9c9adf731090e647613d4d;hp=a53f78cc6d90d6161ad3f797b8b3b28c8476fa70;hpb=ce578a77453fd421e9598c994ef008ad7e128de6;p=friendica.git diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index a53f78cc6d..71d373000f 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -1,6 +1,6 @@ l10n->t('Permission denied.')); + if (!DI::userSession()->getLocalUserId()) { + throw new ForbiddenException($this->t('Permission denied.')); } - $this->baseUrl = $baseUrl; $this->dba = $dba; $this->friendSuggestRepo = $friendSuggestRepo; $this->friendSuggestFac = $friendSuggestFac; } - public function post() + protected function post(array $request = []) { $cid = intval($this->parameters['contact']); // We do query the "uid" as well to ensure that it is our contact - if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => local_user()])) { - throw new NotFoundException($this->l10n->t('Contact not found.')); + if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()])) { + throw new NotFoundException($this->t('Contact not found.')); } $suggest_contact_id = intval($_POST['suggest']); @@ -77,16 +77,16 @@ class FriendSuggest extends BaseModule } // We do query the "uid" as well to ensure that it is our contact - $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]); + $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => DI::userSession()->getLocalUserId()]); if (empty($contact)) { - notice($this->l10n->t('Suggested contact not found.')); + DI::sysmsg()->addNotice($this->t('Suggested contact not found.')); return; } $note = Strings::escapeHtml(trim($_POST['note'] ?? '')); $suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew( - local_user(), + DI::userSession()->getLocalUserId(), $cid, $contact['name'], $contact['url'], @@ -95,18 +95,18 @@ class FriendSuggest extends BaseModule $note )); - Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id); + Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id); - info($this->l10n->t('Friend suggestion sent.')); + DI::sysmsg()->addInfo($this->t('Friend suggestion sent.')); } - public function content(): string + protected function content(array $request = []): string { $cid = intval($this->parameters['contact']); - $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); + $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]); if (empty($contact)) { - notice($this->l10n->t('Contact not found.')); + DI::sysmsg()->addNotice($this->t('Contact not found.')); $this->baseUrl->redirect(); } @@ -120,7 +120,7 @@ class FriendSuggest extends BaseModule AND NOT `archive` AND NOT `deleted` AND `notify` != ""', - local_user(), + DI::userSession()->getLocalUserId(), $cid, Protocol::DFRN, ]); @@ -134,15 +134,15 @@ class FriendSuggest extends BaseModule $tpl = Renderer::getMarkupTemplate('fsuggest.tpl'); return Renderer::replaceMacros($tpl, [ '$contact_id' => $cid, - '$fsuggest_title' => $this->l10n->t('Suggest Friends'), + '$fsuggest_title' => $this->t('Suggest Friends'), '$fsuggest_select' => [ 'suggest', - $this->l10n->t('Suggest a friend for %s', $contact['name']), + $this->t('Suggest a friend for %s', $contact['name']), '', '', $formattedContacts, ], - '$submit' => $this->l10n->t('Submit'), + '$submit' => $this->t('Submit'), ]); } }