Debian Codegraph @

lib/types/kolabSharedFolderType.inc

raw
1 <?php
2 /*
3
4 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
5 Copyright (C) 2013 - 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 Kolab shared folders.
25 *
26 * @package types
27 * @author Roland Gruber
28 */
29
30 use LAM\TYPES\ConfiguredType;
31
32 /**
33 * The account type for Kolab shared folders.
34 *
35 * @package types
36 */
37 class kolabSharedFolderType extends baseType {
38
39 /**
40 * Constructs a new shared folder 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 shared folder');
47 $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to shared folder list');
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function getAlias(): string {
54 return _("Kolab shared folders");
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function getDescription(): string {
61 return _("Kolab shared folders (e.g. mail folders)");
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 public function getListClassName(): string {
68 return kolabSharedFolderTypeList::class;
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 public function getDefaultListAttributes(): string {
75 return "#cn;#kolabDelegate;#alias";
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 public function getTitleBarTitle(accountContainer $container): ?string {
82 // get attributes
83 $attributes = [];
84 if ($container->getAccountModule('kolabSharedFolder') != null) {
85 $attributes = $container->getAccountModule('kolabSharedFolder')->getAttributes();
86 }
87 // check if cn is set
88 if (isset($attributes['cn'][0])) {
89 return htmlspecialchars($attributes['cn'][0]);
90 }
91 // show new label
92 if ($container->isNewAccount) {
93 return _("New shared folder");
94 }
95 // fall back to default
96 return parent::getTitleBarTitle($container);
97 }
98
99 }
100
101
102 /**
103 * Generates the list view.
104 *
105 * @package lists
106 * @author Roland Gruber
107 *
108 */
109 class kolabSharedFolderTypeList extends lamList {
110
111 /**
112 * Constructor
113 *
114 * @param ConfiguredType $type account type
115 */
116 public function __construct(ConfiguredType $type) {
117 parent::__construct($type);
118 $this->labels = [
119 'nav' => _("Shared folder count: %s"),
120 'error_noneFound' => _("No shared folders found!"),
121 'newEntry' => _("New shared folder"),
122 'deleteEntry' => _("Delete selected shared folders")
123 ];
124 }
125
126 }