32 protected $objectTypes;
34 protected $displayAttr;
35 protected $objectFilter =
'';
37 function __construct (
string $label,
string $description,
string $ldapName,
bool $required, array $objectTypes,
string $storeAttr =
'dn',
string $displayAttr =
'nameAttr', $objectFilter =
'', $acl =
'')
39 parent::__construct($label, $description, $ldapName, $required, [],
'', NULL, $acl);
40 $this->objectTypes = $objectTypes;
41 $this->storeAttr = $storeAttr;
42 $this->displayAttr = $displayAttr;
43 $this->objectFilter = $objectFilter;
46 function setParent (&$plugin)
48 parent::setParent($plugin);
49 if (is_object($this->plugin)) {
50 $this->updateChoices();
54 function updateChoices ()
58 foreach ($this->objectTypes as $objectType) {
60 $infos = objects::infos($objectType);
61 $realStoreAttr = $this->storeAttr;
62 if (in_array($this->storeAttr, [
'nameAttr',
'mainAttr'])) {
63 $realStoreAttr = $infos[$this->storeAttr];
65 $realDisplayAttr = $this->displayAttr;
66 if (in_array($this->displayAttr, [
'nameAttr',
'mainAttr'])) {
67 $realDisplayAttr = $infos[$this->displayAttr];
70 $realStoreAttr => (($realStoreAttr ==
'dn') ?
'raw' :
'1'),
71 $realDisplayAttr => (($realDisplayAttr ==
'dn') ?
'raw' :
'1'),
73 $objects =
objects::ls($objectType, $attributes, NULL, $this->objectFilter);
74 foreach (array_column($objects, $realStoreAttr) as $choice) {
77 foreach (array_column($objects, $realDisplayAttr) as $output) {
This class allow to handle easily a Select LDAP attribute with a set of choices.
This class allows to handle a select attribute which allow to choose an object.
static ls($types, $attrs=NULL, string $ou=NULL, string $filter='', bool $checkAcl=FALSE, string $scope='subtree', bool $templateSearch=FALSE, bool $sizeLimit=FALSE)
Get list of object of objectTypes from $types in $ou.
setChoices(array $choices, array $outputs=NULL)
Set the options of the select attribute.