diff --git a/src/Controller/OrganisationController.php b/src/Controller/OrganisationController.php index 1cb09c2..cd51f5b 100644 --- a/src/Controller/OrganisationController.php +++ b/src/Controller/OrganisationController.php @@ -1103,6 +1103,9 @@ class OrganisationController extends SimpleController /** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */ $authorizer = $this->ci->authorizer; + /** @var \UserFrosting\Support\Repository\Repository $config */ + $config = $this->ci->config; + /** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */ $currentUser = $this->ci->currentUser; @@ -1111,7 +1114,34 @@ class OrganisationController extends SimpleController throw new ForbiddenException(); } - return $this->ci->view->render($response, 'pages/organisations.html.twig'); + $tableColumns = [ 'description' ]; + + if ($currentUser->organisations(true)->count() == 0) { + $tableColumns[] = 'join'; + } else { + if (!$config['organisation']['membership']['single_membership']) { + $tableColumns[] = 'join'; + } + } + + if ($currentUser->organisations(true)->wherePivot('flag_admin', true) | + $authorizer->checkAccess($currentUser, 'delete_organisation') | + $authorizer->checkAccess($currentUser, 'update_organisation_field') | + $authorizer->checkAccess($currentUser, 'approve_organisation') | + $authorizer->checkAccess($currentUser, 'merge_organisations')) { + $tableColumns[] = 'status'; + $tableColumns[] = 'actions'; + } + + return $this->ci->view->render( + $response, + 'pages/organisations.html.twig', + [ + 'table' => [ + 'columns' => $tableColumns + ] + ] + ); } /** @@ -1142,7 +1172,23 @@ class OrganisationController extends SimpleController throw new ForbiddenException(); } - return $this->ci->view->render($response, 'pages/deleted-organisations.html.twig'); + $tableColumns = [ 'description' ]; + + if ($authorizer->checkAccess($currentUser, 'restore_organisation') | + $authorizer->checkAccess($currentUser, 'permanently_delete_organisation')) { + $tableColumns[] = 'status'; + $tableColumns[] = 'actions'; + } + + return $this->ci->view->render( + $response, + 'pages/deleted-organisations.html.twig', + [ + 'table' => [ + 'columns' => $tableColumns + ] + ] + ); } diff --git a/templates/pages/deleted-organisations.html.twig b/templates/pages/deleted-organisations.html.twig index 7c878bc..30c4a63 100644 --- a/templates/pages/deleted-organisations.html.twig +++ b/templates/pages/deleted-organisations.html.twig @@ -21,7 +21,8 @@