diff --git a/src/Controller/CommunityController.php b/src/Controller/CommunityController.php index 39ffa82..84735b3 100644 --- a/src/Controller/CommunityController.php +++ b/src/Controller/CommunityController.php @@ -49,7 +49,7 @@ class CommunityController implements IAuthenticationRequired public function getCommunityHome(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), false, $community, $ownCommunityMember)) { return null; } @@ -87,7 +87,7 @@ class CommunityController implements IAuthenticationRequired public function getCommunitySettings(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), false, $community, $ownCommunityMember)) { return null; } @@ -106,7 +106,7 @@ class CommunityController implements IAuthenticationRequired public function getCommunityEdit(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -124,9 +124,9 @@ class CommunityController implements IAuthenticationRequired ]); } - $communityId = \Container::$request->query('communityId'); - if ($communityId){ - if (!$this->checkPermission($communityId, true, $community, $ownCommunityMember)) { + $communitySlug = \Container::$request->query('communitySlug'); + if ($communitySlug){ + if (!$this->checkPermission($communitySlug, true, $community, $ownCommunityMember)) { return null; } } else { @@ -145,7 +145,7 @@ class CommunityController implements IAuthenticationRequired $community->setName($name); \Container::$persistentDataManager->saveToDb($community); - if (!$communityId) { + if (!$communitySlug) { /** * @var User $user */ @@ -168,13 +168,13 @@ class CommunityController implements IAuthenticationRequired } return new JsonContent([ - 'redirect' => ['target' => \Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()])] + 'redirect' => ['target' => \Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()])] ]); } public function getMembersEdit(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -186,7 +186,7 @@ class CommunityController implements IAuthenticationRequired public function saveMember(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -225,7 +225,7 @@ class CommunityController implements IAuthenticationRequired public function deleteMember(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -250,7 +250,7 @@ class CommunityController implements IAuthenticationRequired public function getCurrenciesEdit(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -262,7 +262,7 @@ class CommunityController implements IAuthenticationRequired public function saveCurrency(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -298,7 +298,7 @@ class CommunityController implements IAuthenticationRequired public function deleteCurrency(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -324,7 +324,7 @@ class CommunityController implements IAuthenticationRequired public function getCurrencyExchangeRates(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -345,7 +345,7 @@ class CommunityController implements IAuthenticationRequired public function saveCurrencyExchangeRate(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -378,7 +378,7 @@ class CommunityController implements IAuthenticationRequired public function deleteCurrencyExchangeRate(): ?IContent { - if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) { + if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { return null; } @@ -415,12 +415,12 @@ class CommunityController implements IAuthenticationRequired } private function checkPermission( - int $communityId, + string $communitySlug, bool $needToBeOwner, ?Community &$community, ?CommunityMember &$ownCommunityMember): bool { - $community = $this->communityRepository->getById($communityId); + $community = $this->communityRepository->getBySlug($communitySlug); if ($community === null) { return false; } diff --git a/src/Controller/TransactionController.php b/src/Controller/TransactionController.php index 3f075c9..aafbea0 100644 --- a/src/Controller/TransactionController.php +++ b/src/Controller/TransactionController.php @@ -46,8 +46,8 @@ class TransactionController implements IAuthenticationRequired, ISecured public function authorize(): bool { - $communityId = \Container::$request->query('communityId'); - $this->community = $this->communityRepository->getById($communityId); + $communitySlug = \Container::$request->query('communitySlug'); + $this->community = $this->communityRepository->getBySlug($communitySlug); if ($this->community === null) { return false; } diff --git a/src/Repository/CommunityRepository.php b/src/Repository/CommunityRepository.php index a1b4c96..49f0568 100644 --- a/src/Repository/CommunityRepository.php +++ b/src/Repository/CommunityRepository.php @@ -8,4 +8,9 @@ class CommunityRepository { return \Container::$persistentDataManager->selectFromDbById($id, Community::class); } + + public function getBySlug(string $slug): ?Community + { + return \Container::$persistentDataManager->selectFromDbBySlug($slug, Community::class); + } } diff --git a/views/communities/community.php b/views/communities/community.php index 8055113..b401d27 100644 --- a/views/communities/community.php +++ b/views/communities/community.php @@ -4,11 +4,11 @@

getName() ?> - [edit] + [edit]

-

Settings

+

Settings

@@ -27,7 +27,7 @@ $mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits(); ?>

Finances

- Transactions + Transactions diff --git a/views/communities/community_currencies.php b/views/communities/community_currencies.php index 2dc9dfa..7c09dbf 100644 --- a/views/communities/community_currencies.php +++ b/views/communities/community_currencies.php @@ -2,8 +2,8 @@ @section(main)

- getName() ?> » - Settings » + getName() ?> » + Settings » Edit currencies

@@ -18,8 +18,8 @@
You owe
-
-
+
+
@@ -35,7 +35,7 @@
-
+
diff --git a/views/communities/community_edit.php b/views/communities/community_edit.php index 9655d66..2f6f5bd 100644 --- a/views/communities/community_edit.php +++ b/views/communities/community_edit.php @@ -3,7 +3,7 @@ @section(main)

- getName() ?> » + getName() ?> » Edit New community @@ -12,7 +12,7 @@
getRoute('community.edit-action')->generateLink(['communityId' => $community->getId()]) : + Container::$routeCollection->getRoute('community.edit-action')->generateLink(['communitySlug' => $community->getSlug()]) : Container::$routeCollection->getRoute('community.new-action')->generateLink(); ?>
diff --git a/views/communities/community_members.php b/views/communities/community_members.php index 1bdbccc..0fcc42d 100644 --- a/views/communities/community_members.php +++ b/views/communities/community_members.php @@ -6,8 +6,8 @@ @section(main)

- getName() ?> » - Settings » + getName() ?> » + Settings » Edit members

@@ -23,8 +23,8 @@ getUserId() !== Container::$request->user()->getUniqueId(); ?>

- -
+
+
getUser()->getDisplayName() ?>
@@ -40,7 +40,7 @@
-
+
diff --git a/views/communities/community_settings.php b/views/communities/community_settings.php index 1708d67..bf1f49b 100644 --- a/views/communities/community_settings.php +++ b/views/communities/community_settings.php @@ -2,7 +2,7 @@ @section(main)

- getName() ?> » + getName() ?> » Settings

@@ -11,7 +11,7 @@

Members - [edit] + [edit]

@@ -22,7 +22,7 @@

Currencies - [edit] + [edit]

@@ -30,7 +30,7 @@ getId() === $community->getMainCurrencyId()): ?> getCode() ?> - getCode() ?> + getCode() ?>

diff --git a/views/communities/currency_exchange_rates.php b/views/communities/currency_exchange_rates.php index 0fc62b9..abd5cb4 100644 --- a/views/communities/currency_exchange_rates.php +++ b/views/communities/currency_exchange_rates.php @@ -2,8 +2,8 @@ @section(main)

- getName() ?> » - Settings » + getName() ?> » + Settings » Exchange rates for getCode() ?>

@@ -24,8 +24,8 @@
-
-
+
+
@@ -44,7 +44,7 @@
-
+
diff --git a/views/communities/transaction_edit.php b/views/communities/transaction_edit.php index 1bbbb6e..76c3392 100644 --- a/views/communities/transaction_edit.php +++ b/views/communities/transaction_edit.php @@ -2,8 +2,8 @@ @section(main)

- getName() ?> » - Transactions » + getName() ?> » + Transactions » Edit transaction @@ -13,10 +13,10 @@
getRoute('community.transactions.edit-action')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) : - Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communityId' => $community->getId()]); + Container::$routeCollection->getRoute('community.transactions.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) : + Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communitySlug' => $community->getSlug()]); ?> -
+

Payer