Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ class DashboardController extends AbstractController
#[Route('/dashboard', name: 'dashboard')]
public function dashboard(ManagerRegistry $doctrine): Response
{
$users = $doctrine->getRepository(User::class)->findAll();
$calendars = $doctrine->getRepository(CalendarInstance::class)->findAll();
$addressbooks = $doctrine->getRepository(AddressBook::class)->findAll();
$events = $doctrine->getRepository(CalendarObject::class)->findAll();
$contacts = $doctrine->getRepository(Card::class)->findAll();
$usersCount = $doctrine->getRepository(User::class)->count([]);
$calendarsCount = $doctrine->getRepository(CalendarInstance::class)->count([]);
$addressBooksCount = $doctrine->getRepository(AddressBook::class)->count([]);
$eventsCount = $doctrine->getRepository(CalendarObject::class)->count([]);
$contactsCount = $doctrine->getRepository(Card::class)->count([]);

$timezoneParameter = $this->getParameter('timezone');

return $this->render('dashboard.html.twig', [
'users' => $users,
'calendars' => $calendars,
'addressbooks' => $addressbooks,
'events' => $events,
'contacts' => $contacts,
'usersCount' => $usersCount,
'calendarsCount' => $calendarsCount,
'addressBooksCount' => $addressBooksCount,
'eventsCount' => $eventsCount,
'contactsCount' => $contactsCount,
'timezone' => [
'actual_default' => date_default_timezone_get(),
'not_set_in_app' => '' === $timezoneParameter,
Expand Down
10 changes: 8 additions & 2 deletions src/Controller/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ public function userDelete(ManagerRegistry $doctrine, int $userId, TranslatorInt
$principalProxyWrite = $doctrine->getRepository(Principal::class)->findOneByUri($principal->getUri().Principal::WRITE_PROXY_SUFFIX);

$entityManager->remove($principal);
$entityManager->remove($principalProxyRead);
$entityManager->remove($principalProxyWrite);

if ($principalProxyRead) {
$entityManager->remove($principalProxyRead);
}

if ($principalProxyWrite) {
$entityManager->remove($principalProxyWrite);
}

$principalUri = Principal::PREFIX.$user->getUsername();

Expand Down
10 changes: 5 additions & 5 deletions templates/dashboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@

<ul class="list-group mb-5">
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ "dashboard.users"|trans }} <span class="badge bg-primary rounded-pill">{{ users|length }}</span>
{{ "dashboard.users"|trans }} <span class="badge bg-primary rounded-pill">{{ usersCount }}</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>{{ "dashboard.calendars"|trans }}&nbsp;<span class="small text-muted ms-1 me-auto">{{ "dashboard.calendars.help"|trans }}</span></div> <span class="badge bg-primary rounded-pill">{{ calendars|length }}</span>
<div>{{ "dashboard.calendars"|trans }}&nbsp;<span class="small text-muted ms-1 me-auto">{{ "dashboard.calendars.help"|trans }}</span></div> <span class="badge bg-primary rounded-pill">{{ calendarsCount }}</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
↳ {{ "dashboard.events"|trans }} <span class="badge bg-secondary rounded-pill">{{ events|length }}</span>
↳ {{ "dashboard.events"|trans }} <span class="badge bg-secondary rounded-pill">{{ eventsCount }}</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ "dashboard.address_books"|trans }} <span class="badge bg-primary rounded-pill">{{ addressbooks|length }}</span>
{{ "dashboard.address_books"|trans }} <span class="badge bg-primary rounded-pill">{{ addressBooksCount }}</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
↳ {{ "dashboard.contacts"|trans }} <span class="badge bg-secondary rounded-pill">{{ contacts|length }}</span>
↳ {{ "dashboard.contacts"|trans }} <span class="badge bg-secondary rounded-pill">{{ contactsCount }}</span>
</li>
</ul>
</div>
Expand Down
Loading