From 5b1eedefea870f47e4dbb7e9f90bb42d632ae436 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Thu, 24 Jan 2019 11:49:47 +0100
Subject: [PATCH] :ambulance: fix(5135) Fix problems with management config
 saving

Fix schema error, PHP error, and ACL setup.

issue #5135
---
 contrib/openldap/core-fd-conf.schema                       | 2 +-
 include/class_config.inc                                   | 4 ++--
 include/management/class_ManagementConfigurationDialog.inc | 7 ++++++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/openldap/core-fd-conf.schema b/contrib/openldap/core-fd-conf.schema
index bddfd45d8..e776dda15 100644
--- a/contrib/openldap/core-fd-conf.schema
+++ b/contrib/openldap/core-fd-conf.schema
@@ -576,7 +576,7 @@ objectclass ( 1.3.6.1.4.1.38414.8.2.1 NAME 'fusionDirectoryConf'
     fdDisplayErrors $ fdLdapMaxQueryTime $ fdLdapStats $ fdDebugLevel $
     fdEnableSnapshots $ fdSnapshotBase $
     fdTabHook $ fdShells $ fdDefaultShell $ fdDisplayHookOutput $
-    fdPluginsMenuBlacklist $
+    fdPluginsMenuBlacklist $ fdManagementConfig $
     fdAclTabOnObjects $ fdDepartmentCategories $
     fdSslCaCertPath $ fdSslKeyPath $ fdSslCertPath $
     fdCasActivated $ fdCasServerCaCertPath $ fdCasHost $ fdCasPort $ fdCasContext $
diff --git a/include/class_config.inc b/include/class_config.inc
index 762f86916..ae152d3c0 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -527,7 +527,7 @@ class config
    */
   public function updateManagementConfig($managementClass, $managementConfig)
   {
-    $managementConfig = json_encode($managementConfig, JSON_THROW_ON_ERROR);
+    $managementConfig = json_encode($managementConfig);
     $changes = array();
     if (isset($this->current['MANAGEMENTCONFIG'][$managementClass])) {
       /* If there already was a config for this class, remove it */
@@ -549,7 +549,7 @@ class config
     );
     $ldap = $this->get_ldap_link();
     $ldap->cd(CONFIGRDN.$this->current['BASE']);
-    if (!$ldap->modify_batch($modifs)) {
+    if (!$ldap->modify_batch($changes)) {
       return array($ldap->get_error());
     }
   }
diff --git a/include/management/class_ManagementConfigurationDialog.inc b/include/management/class_ManagementConfigurationDialog.inc
index 7190c9485..2cdeecad8 100644
--- a/include/management/class_ManagementConfigurationDialog.inc
+++ b/include/management/class_ManagementConfigurationDialog.inc
@@ -85,7 +85,9 @@ class ManagementConfigurationDialog extends simplePlugin
           ),
           new BooleanAttribute(
             _('Persitent'), _('Should this configuration be saved in the LDAP as the default configuration for this management page'),
-            'saveInLdap', FALSE
+            'saveInLdap', FALSE,
+            FALSE,
+            'fdManagementConfig'
           ),
         )
       ),
@@ -135,8 +137,11 @@ class ManagementConfigurationDialog extends simplePlugin
 
   function execute ()
   {
+    global $config, $ui;
+
     $smarty = get_smarty();
     $smarty->assign('ManagementConfigurationACL', 'rw');
+    $smarty->assign('fdManagementConfigACL', $ui->get_permissions(CONFIGRDN.$config->current['BASE'], 'configuration/configInLdap', 'fdManagementConfig', $this->readOnly()));
     $str = parent::execute();
 
     $str .= '<p class="plugbottom">'.
-- 
GitLab