FusionDirectory
class_MailsAttribute.inc
1 <?php
2 /*
3  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
4 
5  Copyright (C) 2018-2019 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21 
23 {
24  /* Default columns */
25  public static $columns = [
26  ['ObjectTypeColumn', []],
27  ['LinkColumn', ['attributes' => 'mail', 'label' => 'Email']],
28  ['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']],
29  ];
30 }
31 
35 {
36  protected $dialogClass = 'mailAddressSelect';
37 }
38 
45 {
46  protected $dialogClass = 'MailSelectDialog';
47 
57  function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $acl = '')
58  {
59  SetAttribute::__construct(new MailAttribute($label, $description, $ldapName, $required, '', $acl), $defaultValue);
60  }
61 
62  public function getSelectManagementParameters (): array
63  {
64  return [
65  ['user','group'],
66  TRUE,
67  [
68  'objectClass' => '*',
69  'dn' => 'raw',
70  'cn' => '*',
71  'mail' => '*',
72  ],
73  $this->getFilterBlackList(),
74  [],
75  [
76  ['TabFilterElement', []],
77  ['FixedFilterElement', ['(mail=*)']],
78  ]
79  ];
80  }
81 
82  function getFilterBlackList ()
83  {
84  return ['mail' => $this->getValue()];
85  }
86 
87  function addValue (string $dn, $attrs = NULL)
88  {
89  $value = (($attrs != NULL) ? $attrs['mail'][0] : $dn);
90  if (!in_array($value, $this->value)) {
91  $this->value[] = $value;
92  }
93  }
94 
95  function renderButtons ()
96  {
97  $id = $this->getHtmlId();
98  $buttons = $this->renderInputField(
99  'submit', 'add'.$id,
100  [
101  'class' => 'subattribute',
102  'value' => msgPool::addButton(FALSE),
103  ]
104  );
105  $buttons .= $this->renderInputField(
106  'submit', 'add'.$id.'_dialog',
107  [
108  'class' => 'dialog subattribute',
109  'value' => sprintf(_('%s (from list)'), msgPool::addButton(FALSE)),
110  ]
111  );
112  $buttons .= $this->renderInputField(
113  'submit', 'del'.$id,
114  [
115  'class' => 'subattribute',
116  'value' => msgPool::delButton(FALSE),
117  ]
118  );
119  return $buttons;
120  }
121 
122  public function htmlIds (): array
123  {
124  $id = $this->getHtmlId();
125  return ['add'.$id,'add'.$id.'_dialog','del'.$id,'row'.$id];
126  }
127 }
Mail address selection dialog.
static delButton($escape=TRUE)
Text for an delete button.
Generic dialog for selection using a selectManagement class.
static addButton($escape=TRUE)
Text for an add button.
This class allows to handle an attribute with a popup for selection.
__construct($label, $description, $ldapName, $required=FALSE, $defaultValue=[], $acl='')
The constructor of MailsAttribute.
__construct(\FusionDirectory\Core\SimplePlugin\Attribute $attribute, array $values=[], bool $valueUnicity=TRUE)
The constructor of SetAttribute.
Management class for selection dialogs.
This class allow to handle easily a String LDAP attribute that contains a mail address.
This class allows to handle an attribute for selecting an mail address.