feature/RVRNEXT-24-use-slugs-for-communities #52
@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,11 +4,11 @@
 | 
			
		||||
    <h2>
 | 
			
		||||
        <?= $community->getName() ?>
 | 
			
		||||
        <?php if ($editPermission): ?>
 | 
			
		||||
            <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.edit')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
 | 
			
		||||
            <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.edit')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
    </h2>
 | 
			
		||||
 | 
			
		||||
    <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a></p>
 | 
			
		||||
    <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a></p>
 | 
			
		||||
 | 
			
		||||
    <div class="gridContainer marginTop">
 | 
			
		||||
        <div>
 | 
			
		||||
@ -27,7 +27,7 @@
 | 
			
		||||
            $mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits();
 | 
			
		||||
            ?>
 | 
			
		||||
            <h3 class="marginBottom">Finances</h3>
 | 
			
		||||
            <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">Transactions</a>
 | 
			
		||||
            <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a>
 | 
			
		||||
            <table class="fullWidth marginTop">
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td class="bold">You owe</td>
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,8 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> »
 | 
			
		||||
        Edit currencies
 | 
			
		||||
    </h2>
 | 
			
		||||
    <div class="box compactBox">
 | 
			
		||||
@ -18,8 +18,8 @@
 | 
			
		||||
            <?php foreach ($currencies as $currency): ?>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>
 | 
			
		||||
                        <form id="editCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.edit-action')->generateLink(['communityId' => $community->getId(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
 | 
			
		||||
                        <form id="deleteCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.delete-action')->generateLink(['communityId' => $community->getId(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                        <form id="editCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
 | 
			
		||||
                        <form id="deleteCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                        <input type="text" form="editCurrency_<?= $currency->getId() ?>" class="text fullWidth" name="code" value="<?= $currency->getCode() ?>" maxlength="3" required>
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td>
 | 
			
		||||
@ -35,7 +35,7 @@
 | 
			
		||||
            <?php endforeach; ?>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <form id="newCurrency" action="<?= Container::$routeCollection->getRoute('community.currencies.new-action')->generateLink(['communityId' => $community->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
 | 
			
		||||
                    <form id="newCurrency" action="<?= Container::$routeCollection->getRoute('community.currencies.new-action')->generateLink(['communitySlug' => $community->getSlug()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
 | 
			
		||||
                    <input type="text" form="newCurrency" class="text fullWidth" name="code" maxlength="3" required>
 | 
			
		||||
                </td>
 | 
			
		||||
                <td>
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <?php if (isset($community)): ?>
 | 
			
		||||
            <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
            <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
            Edit
 | 
			
		||||
        <?php else: ?>
 | 
			
		||||
            New community
 | 
			
		||||
@ -12,7 +12,7 @@
 | 
			
		||||
    <div class="box compactBox">
 | 
			
		||||
        <?php
 | 
			
		||||
        $formAction = isset($community) ?
 | 
			
		||||
            Container::$routeCollection->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();
 | 
			
		||||
        ?>
 | 
			
		||||
        <form id="communityForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="true">
 | 
			
		||||
 | 
			
		||||
@ -6,8 +6,8 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> »
 | 
			
		||||
        Edit members
 | 
			
		||||
    </h2>
 | 
			
		||||
    <div class="box compactBox">
 | 
			
		||||
@ -23,8 +23,8 @@
 | 
			
		||||
                <?php $editable = $member->getUserId() !== Container::$request->user()->getUniqueId(); ?>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>
 | 
			
		||||
                        <form id="editMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.edit-action')->generateLink(['communityId' => $community->getId(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="owner"></form>
 | 
			
		||||
                        <form id="deleteMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.delete-action')->generateLink(['communityId' => $community->getId(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                        <form id="editMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="owner"></form>
 | 
			
		||||
                        <form id="deleteMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                        <?= $member->getUser()->getDisplayName() ?>
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td style="text-align: center;">
 | 
			
		||||
@ -40,7 +40,7 @@
 | 
			
		||||
            <?php endforeach; ?>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <form id="newMember" action="<?= Container::$routeCollection->getRoute('community.members.new-action')->generateLink(['communityId' => $community->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="user_id"></form>
 | 
			
		||||
                    <form id="newMember" action="<?= Container::$routeCollection->getRoute('community.members.new-action')->generateLink(['communitySlug' => $community->getSlug()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="user_id"></form>
 | 
			
		||||
                    <select type="text" form="newMember" name="user_id">
 | 
			
		||||
                </td>
 | 
			
		||||
                <td style="text-align: center;">
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        Settings
 | 
			
		||||
    </h2>
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,7 @@
 | 
			
		||||
            <h3 class="marginBottom">
 | 
			
		||||
                Members
 | 
			
		||||
                <?php if ($editPermission): ?>
 | 
			
		||||
                    <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.members')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
 | 
			
		||||
                    <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.members')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span>
 | 
			
		||||
                <?php endif; ?>
 | 
			
		||||
            </h3>
 | 
			
		||||
            <?php foreach ($members as $member): ?>
 | 
			
		||||
@ -22,7 +22,7 @@
 | 
			
		||||
            <h3 class="marginBottom">
 | 
			
		||||
                Currencies
 | 
			
		||||
                <?php if ($editPermission): ?>
 | 
			
		||||
                    <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.currencies')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
 | 
			
		||||
                    <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.currencies')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span>
 | 
			
		||||
                <?php endif; ?>
 | 
			
		||||
            </h3>
 | 
			
		||||
            <?php foreach ($currencies as $currency): ?>
 | 
			
		||||
@ -30,7 +30,7 @@
 | 
			
		||||
                    <?php if ($currency->getId() === $community->getMainCurrencyId()): ?>
 | 
			
		||||
                        <b><?= $currency->getCode() ?></b>
 | 
			
		||||
                    <?php else: ?>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a>
 | 
			
		||||
                    <?php endif; ?>
 | 
			
		||||
                </p>
 | 
			
		||||
            <?php endforeach; ?>
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,8 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> »
 | 
			
		||||
        Exchange rates for <?= $currency->getCode() ?>
 | 
			
		||||
    </h2>
 | 
			
		||||
    <div class="box compactBox">
 | 
			
		||||
@ -24,8 +24,8 @@
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <?php if ($editPermission): ?>
 | 
			
		||||
                        <td>
 | 
			
		||||
                            <form id="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.edit-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
 | 
			
		||||
                            <form id="deleteCurrency_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.delete-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                            <form id="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
 | 
			
		||||
                            <form id="deleteCurrency_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true"></form>
 | 
			
		||||
                            <input type="number" form="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" class="text fullWidth" name="exchange_rate" value="<?= $currencyExchangeRate->getExchangeRate() ?>" min="0" step="0.000000001" required>
 | 
			
		||||
                        </td>
 | 
			
		||||
                        <td>
 | 
			
		||||
@ -44,7 +44,7 @@
 | 
			
		||||
            <?php if ($editPermission): ?>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>
 | 
			
		||||
                        <form id="newExchangeRate" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.new-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
 | 
			
		||||
                        <form id="newExchangeRate" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.new-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
 | 
			
		||||
                        <input type="number" form="newExchangeRate" class="text fullWidth" name="exchange_rate" min="0" step="0.000000001" required>
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td>
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,8 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">Transactions</a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a> »
 | 
			
		||||
        <?php if (isset($transaction)): ?>
 | 
			
		||||
            Edit transaction
 | 
			
		||||
        <?php else: ?>
 | 
			
		||||
@ -13,10 +13,10 @@
 | 
			
		||||
    <div class="box compactBox">
 | 
			
		||||
        <?php
 | 
			
		||||
        $formAction = isset($transaction) ?
 | 
			
		||||
            Container::$routeCollection->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()]);
 | 
			
		||||
        ?>
 | 
			
		||||
        <form id="transactionForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">
 | 
			
		||||
        <form id="transactionForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">
 | 
			
		||||
            <p class="formLabel">Payer</p>
 | 
			
		||||
            <select class="big fullWidth" name="payer_user_id" required>
 | 
			
		||||
                <option value="" hidden></option>
 | 
			
		||||
@ -53,7 +53,7 @@
 | 
			
		||||
            </div>
 | 
			
		||||
        </form>
 | 
			
		||||
        <?php if (isset($transaction)): ?>
 | 
			
		||||
            <form id="deleteTransaction" action="<?= Container::$routeCollection->getRoute('community.transactions.delete-action')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>"></form>
 | 
			
		||||
            <form id="deleteTransaction" action="<?= Container::$routeCollection->getRoute('community.transactions.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>"></form>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
    </div>
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@ -2,31 +2,31 @@
 | 
			
		||||
 | 
			
		||||
@section(main)
 | 
			
		||||
    <h2>
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
 | 
			
		||||
        Transactions
 | 
			
		||||
    </h2>
 | 
			
		||||
 | 
			
		||||
    <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
 | 
			
		||||
    <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New transaction</a></p>
 | 
			
		||||
 | 
			
		||||
    <?php if ($numberOfTransactions > 0): ?>
 | 
			
		||||
        <?php if ($pages > 1): ?>
 | 
			
		||||
            <p class="paginateContainer marginTop">
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
 | 
			
		||||
                <?php for ($i = 0; $i < $pages; $i++): ?>
 | 
			
		||||
                    <?php if ($currentPage == $i): ?>
 | 
			
		||||
                        <span class="selected"><?= $i + 1 ?></span>
 | 
			
		||||
                    <?php else: ?>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
 | 
			
		||||
                    <?php endif; ?>
 | 
			
		||||
                <?php endfor; ?>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $pages - 1]) ?>">»</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a>
 | 
			
		||||
            </p>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
 | 
			
		||||
        <?php foreach ($transactions as $transaction): ?>
 | 
			
		||||
            <a class="block" href="<?= Container::$routeCollection->getRoute('community.transactions.edit')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) ?>">
 | 
			
		||||
            <a class="block" href="<?= Container::$routeCollection->getRoute('community.transactions.edit')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) ?>">
 | 
			
		||||
            <div class="box transaction">
 | 
			
		||||
                <div>
 | 
			
		||||
                    <p style="font-weight: bold;"><?= $transaction->getDescription() ?></p>
 | 
			
		||||
@ -45,21 +45,21 @@
 | 
			
		||||
 | 
			
		||||
        <?php if ($pages > 1): ?>
 | 
			
		||||
            <p class="paginateContainer marginTop">
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
 | 
			
		||||
                <?php for ($i = 0; $i < $pages; $i++): ?>
 | 
			
		||||
                    <?php if ($currentPage == $i): ?>
 | 
			
		||||
                        <span class="selected"><?= $i + 1 ?></span>
 | 
			
		||||
                    <?php else: ?>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
 | 
			
		||||
                        <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
 | 
			
		||||
                    <?php endif; ?>
 | 
			
		||||
                <?php endfor; ?>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $pages - 1]) ?>">»</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
 | 
			
		||||
                <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a>
 | 
			
		||||
            </p>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
 | 
			
		||||
        <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
 | 
			
		||||
        <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New transaction</a></p>
 | 
			
		||||
    <?php else: ?>
 | 
			
		||||
        <div class="box">
 | 
			
		||||
            <p>There are no transactions yet.</p>
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@
 | 
			
		||||
            </h3>
 | 
			
		||||
            <?php if (count($communities) > 0): ?>
 | 
			
		||||
                <?php foreach ($communities as $community): ?>
 | 
			
		||||
                    <p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a></p>
 | 
			
		||||
                    <p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a></p>
 | 
			
		||||
                <?php endforeach; ?>
 | 
			
		||||
            <?php else: ?>
 | 
			
		||||
                <p>You have no community.</p>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								web.php
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								web.php
									
									
									
									
									
								
							@ -64,7 +64,7 @@ Container::$routeCollection->get('searchUser', 'searchUser', [UserSearchControll
 | 
			
		||||
Container::$routeCollection->group('communities', function (RouteCollection $routeCollection) {
 | 
			
		||||
    $routeCollection->get('community.new', 'new', [CommunityController::class, 'getCommunityNew']);
 | 
			
		||||
    $routeCollection->post('community.new-action', 'new', [CommunityController::class, 'saveCommunity']);
 | 
			
		||||
    $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) {
 | 
			
		||||
    $routeCollection->group('{communitySlug}', function (RouteCollection $routeCollection) {
 | 
			
		||||
        $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']);
 | 
			
		||||
        $routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']);
 | 
			
		||||
        $routeCollection->get('community.edit', 'edit', [CommunityController::class, 'getCommunityEdit']);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user