Debian Codegraph @

lib/types/mailAlias.inc

raw
1 <?php
2 /*
3
4 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
5 Copyright (C) 2005 - 2025 Roland Gruber
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 */
22
23 /**
24 * The account type for mail aliases.
25 *
26 * @package types
27 * @author Roland Gruber
28 */
29
30 use LAM\TYPES\ConfiguredType;
31
32 /**
33 * The account type for mail aliases.
34 *
35 * @package types
36 */
37 class mailAlias extends baseType {
38
39 /**
40 * Constructs a new alias type object.
41 *
42 * @param ConfiguredType $type configuration
43 */
44 public function __construct($type) {
45 parent::__construct($type);
46 $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another alias');
47 $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to alias list');
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function getAlias(): string {
54 return _("Mail aliases");
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function getDescription(): string {
61 return _("Mailing aliases (e.g. NIS mail aliases)");
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 public function getIcon(): string {
68 return 'mail.svg';
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 public function getListClassName(): string {
75 return lamMailAliasList::class;
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 public function getDefaultListAttributes(): string {
82 return "#cn;#rfc822MailMember";
83 }
84
85 /**
86 * {@inheritDoc}
87 */
88 public function getTitleBarTitle(accountContainer $container): ?string {
89 // get attributes
90 $attributes = null;
91 if ($container->getAccountModule('nisMailAlias') != null) {
92 $attributes = $container->getAccountModule('nisMailAlias')->getAttributes();
93 }
94 // check if a common name is set
95 if (isset($attributes['cn'][0])) {
96 return htmlspecialchars($attributes['cn'][0]);
97 }
98 // new entry
99 if ($container->isNewAccount) {
100 return _("New alias");
101 }
102 // fall back to default
103 return parent::getTitleBarTitle($container);
104 }
105
106 }
107
108
109 /**
110 * Generates the list view.
111 *
112 * @package lists
113 * @author Roland Gruber
114 *
115 */
116 class lamMailAliasList extends lamList {
117
118 /**
119 * Constructor
120 *
121 * @param ConfiguredType $type account type
122 */
123 public function __construct(ConfiguredType $type) {
124 parent::__construct($type);
125 $this->labels = [
126 'nav' => _("Alias count: %s"),
127 'error_noneFound' => _("No aliases found!"),
128 'newEntry' => _("New alias"),
129 'deleteEntry' => _("Delete selected aliases")
130 ];
131 }
132
133 }