Debian Codegraph @

lib/types/smbDomain.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 Samba domains.
25 *
26 * @package types
27 * @author Roland Gruber
28 */
29
30 use LAM\TYPES\ConfiguredType;
31
32 /**
33 * The account type for Samba domains.
34 *
35 * @package types
36 */
37 class smbDomain extends baseType {
38
39 /**
40 * Constructs a new domain 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 domain');
47 $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to domain list');
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function getAlias(): string {
54 return _("Samba domains");
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function getDescription(): string {
61 return _("Samba 3 domain entries");
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 public function getIcon(): string {
68 return 'samba.svg';
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 public function getListClassName(): string {
75 return lamSmbDomainList::class;
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 public function getDefaultListAttributes(): string {
82 return "#sambaDomainName;#sambaSID";
83 }
84
85 /**
86 * {@inheritDoc}
87 */
88 public function getTitleBarTitle(accountContainer $container): ?string {
89 // get attributes
90 $attributes = null;
91 if ($container->getAccountModule('sambaDomain') != null) {
92 $attributes = $container->getAccountModule('sambaDomain')->getAttributes();
93 }
94 // check if a domain name is set
95 if (isset($attributes['sambaDomainName'][0])) {
96 return htmlspecialchars($attributes['sambaDomainName'][0]);
97 }
98 // new entry
99 if ($container->isNewAccount) {
100 return _("New domain");
101 }
102 // fall back to default
103 return parent::getTitleBarTitle($container);
104 }
105
106 /**
107 * {@inheritDoc}
108 */
109 public function getTitleBarSubtitle(accountContainer $container): string {
110 // get attributes
111 $attributes = null;
112 if ($container->getAccountModule('sambaDomain') != null) {
113 $attributes = $container->getAccountModule('sambaDomain')->getAttributes();
114 }
115 if ($attributes == null) {
116 return '';
117 }
118 $subtitle = '';
119 // check if a SID can be shown
120 if (isset($attributes['sambaSID'][0])) {
121 $subtitle .= htmlspecialchars($attributes['sambaSID'][0]);
122 }
123 return $subtitle;
124 }
125
126 }
127
128
129 /**
130 * Generates the list view.
131 *
132 * @package lists
133 * @author Roland Gruber
134 *
135 */
136 class lamSmbDomainList extends lamList {
137
138 /**
139 * Constructor
140 *
141 * @param ConfiguredType $type account type
142 */
143 public function __construct(ConfiguredType $type) {
144 parent::__construct($type);
145 $this->labels = [
146 'nav' => _("Domain count: %s"),
147 'error_noneFound' => _("No domains found!"),
148 'newEntry' => _("New domain"),
149 'deleteEntry' => _("Delete selected domains")
150 ];
151 }
152
153 }