23 function __construct ($label, $description, $ldapName, $attributes, $acl =
"")
25 parent::__construct($description, $ldapName, $attributes, FALSE, FALSE, $acl, $label);
34 static function plInfo (): array
37 'plShortName' =>
'ManagementConfigurationDialog',
41 static function getAttributesInfo (): array
43 global $class_mapping;
47 foreach (array_keys($class_mapping) as $class) {
48 if (preg_match(
'/Column$/', $class) && is_a($class,
'Column', TRUE)) {
56 'class' => [
'fullwidth'],
57 'name' => _(
'Management configuration'),
62 _(
'Columns displayed for this management list'),
66 _(
'Type'), _(
'Type of column'),
71 _(
'Attribute'), _(
'LDAP attributes to display, comma separated. Special values "nameAttr" and "mainAttr" also work.'),
72 'columnAttribute', FALSE
75 _(
'Label'), _(
'Column title'),
79 'ManagementConfiguration' 86 _(
'Persistent'), _(
'Should this configuration be saved in the LDAP as your default configuration for this management page'),
87 'saveInLdapUser', FALSE,
89 'ManagementConfiguration' 92 _(
'Forget my persistent configuration'), _(
'Delete the persistent configuration for this management page so that the default one is used'),
93 'resetInLdapUser', _(
'Forget'),
95 'ManagementConfiguration' 98 _(
'Global default'), _(
'Should this configuration be saved in the LDAP as the default configuration for this management page for all users'),
104 _(
'Forget global default'), _(
'Delete the global default configuration for this management page so that the default one is used'),
105 'resetInLdap', _(
'Forget'),
118 parent::__construct(NULL, NULL, $parent);
120 $this->attributesAccess[
'saveInLdap']->setInLdap(FALSE);
121 $this->attributesAccess[
'saveInLdapUser']->setInLdap(FALSE);
122 if (!$this->attrIsWriteable(
'saveInLdap')) {
123 $this->attributesAccess[
'saveInLdap']->setVisible(FALSE);
125 $this->attributesAccess[
'resetInLdap']->setInLdap(FALSE);
126 $this->attributesAccess[
'resetInLdapUser']->setInLdap(FALSE);
127 if (!$this->attrIsWriteable(
'resetInLdap')) {
128 $this->attributesAccess[
'resetInLdap']->setVisible(FALSE);
131 if (!$config->hasManagementConfig(get_class($this->parent), TRUE)) {
132 $this->attributesAccess[
'resetInLdapUser']->setVisible(FALSE);
134 if (!$config->hasManagementConfig(get_class($this->parent), FALSE)) {
135 $this->attributesAccess[
'resetInLdap']->setVisible(FALSE);
138 $this->attributesAccess[
'managementColumns']->setInLdap(FALSE);
139 $this->attributesAccess[
'managementColumns']->setLinearRendering(FALSE);
140 $columnInfos = $this->parent->getColumnConfiguration();
142 foreach ($columnInfos as $column) {
143 if (!isset($column[1][
'attributes'])) {
144 $column[1][
'attributes'] =
'';
145 } elseif (is_array($column[1][
'attributes'])) {
146 $column[1][
'attributes'] = json_encode($column[1][
'attributes']);
148 if (!isset($column[1][
'label'])) {
149 $column[1][
'label'] =
'';
151 $value[] = [$column[0], $column[1][
'attributes'], $column[1][
'label']];
153 $this->attributesAccess[
'managementColumns']->setValue($value);
158 return $this->attrIsWriteable($attr);
165 $noAclAttrs = [
'managementColumns',
'saveInLdapUser',
'resetInLdapUser'];
166 $configAttrs = [
'saveInLdap',
'resetInLdap'];
168 if ((is_object($attr) && in_array($attr->getLdapName(), $noAclAttrs)) || in_array($attr, $noAclAttrs)) {
170 } elseif ((is_object($attr) && in_array($attr->getLdapName(), $configAttrs)) || in_array($attr, $configAttrs)) {
171 $acl = $ui->get_permissions(
CONFIGRDN.$config->current[
'BASE'],
'configuration/configInLdap',
'fdManagementConfig', $this->readOnly());
172 return (strpos($acl,
'w') !== FALSE);
174 return parent::attrIsWriteable($attr);
178 function handle_resetInLdapUser ()
181 $errors = $config->updateManagementConfig(get_class($this->parent), NULL, TRUE);
182 msg_dialog::displayChecks($errors);
183 if (empty($errors)) {
184 $this->attributesAccess[
'resetInLdapUser']->setVisible(FALSE);
188 function handle_resetInLdap ()
191 $errors = $config->updateManagementConfig(get_class($this->parent), NULL, FALSE);
192 msg_dialog::displayChecks($errors);
193 if (empty($errors)) {
194 $this->attributesAccess[
'resetInLdap']->setVisible(FALSE);
203 $smarty->assign(
'ManagementConfigurationACL',
'rw');
204 $smarty->assign(
'fdManagementConfigACL', $ui->get_permissions(
CONFIGRDN.$config->current[
'BASE'],
'configuration/configInLdap',
'fdManagementConfig', $this->readOnly()));
205 return parent::render();
212 $values = $this->managementColumns;
213 foreach ($values as $value) {
214 $column = [$value[0], []];
215 if (!empty($value[1])) {
216 $jsonDecoded = json_decode($value[1], TRUE);
217 if ($jsonDecoded !== NULL) {
218 $column[1][
'attributes'] = $jsonDecoded;
220 $column[1][
'attributes'] = $value[1];
223 if (!empty($value[2])) {
224 $column[1][
'label'] = $value[2];
226 $columnInfos[] = $column;
228 $this->parent->setColumnConfiguration($columnInfos);
230 if ($this->saveInLdapUser) {
231 return $config->updateManagementConfig(get_class($this->parent), $columnInfos, TRUE);
234 if ($this->saveInLdap) {
235 return $config->updateManagementConfig(get_class($this->parent), $columnInfos);
This class allow to handle easily a Select LDAP attribute with a set of choices.
attrIsReadable($attr)
Check if logged in user have enough right to read this attribute value.
save()
Save data to the LDAP and return errors.
Management configuration dialog.
This class allow to handle easily a composite attribute.
const CONFIGRDN
FusionDirectory config object RDN.
render()
Render the dialog and returns the HTML code.
& get_smarty()
Get global smarty object.
attrIsWriteable($attr)
Check if logged in user have enough right to write this attribute value.
This class allow to handle easily a Boolean LDAP attribute.
Multivalued attribute displayed as a columned table. May allow ordering and/or editing.
This class allow to handle easily a String LDAP attribute.