diff --git a/public/static/style.css b/public/static/style.css index ab04854..4fd2214 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -54,13 +54,12 @@ nav a { nav a:link, nav a:visited { background-color: #eeeeee; - color: #ff00e6; + color: blue; text-decoration: none; } nav a:hover, nav a:focus { background-color: #ffffff; - color: #0066ff; text-decoration: underline; } @@ -95,16 +94,6 @@ h2 { margin: 0 0 0.5em 0; } -a:link, a:visited { - color: #ff00e6; - text-decoration: none; -} - -a:hover, a:focus { - color: #0066ff; - text-decoration: underline; -} - .error { background: #ff4444; width: 30em; @@ -112,40 +101,6 @@ a:hover, a:focus { padding: 1em; } -.gray { - color: gray; -} - button { padding: 0.2em 1em; } - -table, tr, td, th { - border: 1px solid #999999; - border-collapse: collapse; - padding: 0.25em 0.5em; -} - -.inactive { - color: gray; -} - -/* --- Filter options --- */ -.filter_options { - border: 1px solid #999999; - padding: 1em; - margin: 1em 0; -} - -.filter_options h4 { - margin: 0 0 0.5em 0; -} - -/* --- Detail columns --- */ -input#show_details_checkbox { - margin-bottom: 1em; -} - -input#show_details_checkbox:not(:checked) ~ table .detail_column { - display: none; -} diff --git a/src/Dependencies.php b/src/Dependencies.php index f7f9742..ac6fbb4 100644 --- a/src/Dependencies.php +++ b/src/Dependencies.php @@ -9,9 +9,7 @@ use MailAccountAdmin\Frontend\Accounts\AccountController; use MailAccountAdmin\Frontend\Domains\DomainController; use MailAccountAdmin\Frontend\Login\LoginController; use MailAccountAdmin\Frontend\Dashboard\DashboardController; -use MailAccountAdmin\Repositories\AccountRepository; use MailAccountAdmin\Repositories\AdminUserRepository; -use MailAccountAdmin\Repositories\DomainRepository; use PDO; use Psr\Container\ContainerInterface; use Slim\Views\Twig; @@ -60,16 +58,6 @@ class Dependencies $c->get(self::DATABASE), ); }); - $container->set(DomainRepository::class, function (ContainerInterface $c) { - return new DomainRepository( - $c->get(self::DATABASE), - ); - }); - $container->set(AccountRepository::class, function (ContainerInterface $c) { - return new AccountRepository( - $c->get(self::DATABASE), - ); - }); // Helper classes $container->set(UserHelper::class, function (ContainerInterface $c) { @@ -96,14 +84,12 @@ class Dependencies return new DomainController( $c->get(self::TWIG), $c->get(UserHelper::class), - $c->get(DomainRepository::class), ); }); $container->set(AccountController::class, function (ContainerInterface $c) { return new AccountController( $c->get(self::TWIG), $c->get(UserHelper::class), - $c->get(AccountRepository::class), ); }); diff --git a/src/Frontend/Accounts/AccountController.php b/src/Frontend/Accounts/AccountController.php index a93ed33..d948371 100644 --- a/src/Frontend/Accounts/AccountController.php +++ b/src/Frontend/Accounts/AccountController.php @@ -3,33 +3,15 @@ declare(strict_types=1); namespace MailAccountAdmin\Frontend\Accounts; -use MailAccountAdmin\Common\UserHelper; use MailAccountAdmin\Frontend\BaseController; -use MailAccountAdmin\Repositories\AccountRepository; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -use Slim\Views\Twig; class AccountController extends BaseController { - /** @var AccountRepository */ - private $accountRepository; - - public function __construct(Twig $view, UserHelper $userHelper, AccountRepository $accountRepository) - { - parent::__construct($view, $userHelper); - $this->accountRepository = $accountRepository; - } - public function showAccounts(Request $request, Response $response): Response { - // Parse query parameters for filters - $queryParams = $request->getQueryParams(); - $filterByDomain = $queryParams['domain'] ?? null; - $renderData = [ - 'filterDomain' => $filterByDomain, - 'accountList' => $this->accountRepository->fetchAccountList($filterByDomain), ]; return $this->view->render($response, 'accounts.html.twig', $renderData); diff --git a/src/Frontend/Domains/DomainController.php b/src/Frontend/Domains/DomainController.php index 5451a1c..172e25f 100644 --- a/src/Frontend/Domains/DomainController.php +++ b/src/Frontend/Domains/DomainController.php @@ -3,28 +3,15 @@ declare(strict_types=1); namespace MailAccountAdmin\Frontend\Domains; -use MailAccountAdmin\Common\UserHelper; use MailAccountAdmin\Frontend\BaseController; -use MailAccountAdmin\Repositories\DomainRepository; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -use Slim\Views\Twig; class DomainController extends BaseController { - /** @var DomainRepository */ - private $domainRepository; - - public function __construct(Twig $view, UserHelper $userHelper, DomainRepository $domainRepository) - { - parent::__construct($view, $userHelper); - $this->domainRepository = $domainRepository; - } - public function showDomains(Request $request, Response $response): Response { $renderData = [ - 'domainList' => $this->domainRepository->fetchDomainList(), ]; return $this->view->render($response, 'domains.html.twig', $renderData); diff --git a/src/Repositories/AccountRepository.php b/src/Repositories/AccountRepository.php deleted file mode 100644 index a97e3cd..0000000 --- a/src/Repositories/AccountRepository.php +++ /dev/null @@ -1,35 +0,0 @@ -pdo->prepare($query); - $statement->execute($queryParams); - return $statement->fetchAll(PDO::FETCH_ASSOC); - } -} diff --git a/src/Repositories/AdminUserRepository.php b/src/Repositories/AdminUserRepository.php index bc10c38..84376f5 100644 --- a/src/Repositories/AdminUserRepository.php +++ b/src/Repositories/AdminUserRepository.php @@ -7,8 +7,16 @@ use MailAccountAdmin\Exceptions\AdminUserNotFoundException; use MailAccountAdmin\Models\AdminUser; use PDO; -class AdminUserRepository extends BaseRepository +class AdminUserRepository { + /** @var PDO */ + private $pdo; + + public function __construct(PDO $pdo) + { + $this->pdo = $pdo; + } + /** * @throws AdminUserNotFoundException */ diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php deleted file mode 100644 index 2108442..0000000 --- a/src/Repositories/BaseRepository.php +++ /dev/null @@ -1,17 +0,0 @@ -pdo = $pdo; - } -} diff --git a/src/Repositories/DomainRepository.php b/src/Repositories/DomainRepository.php deleted file mode 100644 index 94dddb9..0000000 --- a/src/Repositories/DomainRepository.php +++ /dev/null @@ -1,38 +0,0 @@ -pdo->query(' - SELECT - REGEXP_REPLACE(address, "^.*@", "") AS domain, - COUNT(is_account) AS account_count, - COUNT(is_alias) AS alias_count - FROM ( - SELECT username AS address, 1 AS is_account, NULL AS is_alias FROM mail_users - UNION - SELECT mail_address AS address, NULL AS is_account, 1 AS is_alias FROM mail_aliases - ) AS addresses - GROUP BY domain - '); - - $domainRows = $statement->fetchAll(PDO::FETCH_ASSOC); - $domainsCounted = []; - foreach ($domainRows as $row) { - $domainsCounted[$row['domain']] = [ - 'accounts' => $row['account_count'], - 'aliases' => $row['alias_count'], - ]; - } - - ksort($domainsCounted); - return $domainsCounted; - } -} diff --git a/templates/accounts.html.twig b/templates/accounts.html.twig index b920b3b..ecfaddd 100644 --- a/templates/accounts.html.twig +++ b/templates/accounts.html.twig @@ -5,48 +5,6 @@ {% block content %}

Accounts

-

List of all mail accounts.

- -
-
-

Filter:

- - - - -
-
- - - - - - - - - - - - - - - {% if accountList %} - {% for account in accountList -%} - - - - - - - - - - - {% endfor %} - {% else %} - - - - {% endif %} -
UsernameDomainAliasesActiveHome directoryMemoCreatedLast modified
{{ account['username'] }}{{ account['domain'] }}{{ account['alias_count'] }}{{ account['is_active'] == 1 ? 'Yes' : 'No' }}vmail/{{ account['home_dir'] }}{{ account['memo'] }}{{ account['created_at'] }}{{ account['modified_at'] }}
No accounts found.
+

List of accounts ... TODO

+

Test

{% endblock %} diff --git a/templates/domains.html.twig b/templates/domains.html.twig index 79d0044..6ac7814 100644 --- a/templates/domains.html.twig +++ b/templates/domains.html.twig @@ -5,26 +5,6 @@ {% block content %}

Domains

-

This is a list of all domains auto-generated from the existing mail accounts and aliases. As such it is read-only.

- - - - - - - - {% if domainList %} - {% for domain, domainCounts in domainList -%} - - - - - - {% endfor %} - {% else %} - - - - {% endif %} -
DomainAccountsAliases
{{ domain }}{{ domainCounts['accounts'] }}{{ domainCounts['aliases'] }}
No domains found.
+

List of domains ... TODO

+

Test

{% endblock %}