]> source.dussan.org Git - nextcloud-server.git/commitdiff
Port LDAP: fix filter can be reset and broken after upgrade from OC 5 #8579
authorArthur Schiwon <blizzz@owncloud.com>
Tue, 13 May 2014 15:47:00 +0000 (17:47 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 2 Jun 2014 10:08:01 +0000 (12:08 +0200)
LDAP: set filter mode to raw, so filters will not be changed and broken after upgrade from oc5, when visiting the LDAP settings and opening filter tabs

get the correct version number for compare -.-

bump version and don't overwrite values on next update if not necessary

simpler and better readable assignment

apps/user_ldap/appinfo/update.php
apps/user_ldap/appinfo/version

index 41770cf97b16209ba74660d2b7859b309624a911..1e706ce869bcd10a694f64ac1582ef5d5bb6656b 100644 (file)
@@ -7,21 +7,39 @@ if($state === 'unset') {
        OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
 }
 
+$installedVersion = OCP\Config::getAppValue('user_ldap', 'installed_version');
+$enableRawMode = version_compare($installedVersion, '0.4.1', '<');
+
 $configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true);
 $ldap = new OCA\user_ldap\lib\LDAP();
 foreach($configPrefixes as $config) {
        $connection = new OCA\user_ldap\lib\Connection($ldap, $config);
-       $value = \OCP\Config::getAppValue('user_ldap',
-                                                                         $config.'ldap_uuid_attribute', 'auto');
-       \OCP\Config::setAppValue('user_ldap',
-                                                        $config.'ldap_uuid_user_attribute', $value);
-       \OCP\Config::setAppValue('user_ldap',
-                                                        $config.'ldap_uuid_group_attribute', $value);
 
-       $value = \OCP\Config::getAppValue('user_ldap',
-                                                                         $config.'ldap_expert_uuid_attr', 'auto');
-       \OCP\Config::setAppValue('user_ldap',
-                                                        $config.'ldap_expert_uuid_user_attr', $value);
-       \OCP\Config::setAppValue('user_ldap',
-                                                        $config.'ldap_expert_uuid_group_attr', $value);
+       $state = \OCP\Config::getAppValue(
+               'user_ldap', $config.'ldap_uuid_user_attribute', 'not existing');
+       if($state === 'non existing') {
+               $value = \OCP\Config::getAppValue(
+                       'user_ldap', $config.'ldap_uuid_attribute', 'auto');
+               \OCP\Config::setAppValue(
+                       'user_ldap', $config.'ldap_uuid_user_attribute', $value);
+               \OCP\Config::setAppValue(
+                       'user_ldap', $config.'ldap_uuid_group_attribute', $value);
+       }
+
+       $state = \OCP\Config::getAppValue(
+               'user_ldap', $config.'ldap_expert_uuid_user_attr', 'not existing');
+       if($state === 'non existing') {
+               $value = \OCP\Config::getAppValue(
+                       'user_ldap', $config.'ldap_expert_uuid_attr', 'auto');
+               \OCP\Config::setAppValue(
+                       'user_ldap', $config.'ldap_expert_uuid_user_attr', $value);
+               \OCP\Config::setAppValue(
+                       'user_ldap', $config.'ldap_expert_uuid_group_attr', $value);
+       }
+
+       if($enableRawMode) {
+               \OCP\Config::setAppValue('user_ldap', $config.'ldap_user_filter_mode', 1);
+               \OCP\Config::setAppValue('user_ldap', $config.'ldap_login_filter_mode', 1);
+               \OCP\Config::setAppValue('user_ldap', $config.'ldap_group_filter_mode', 1);
+       }
 }
index 44bb5d1f74358758e75a906eebebb458e9de7fcb..2b7c5ae01848a77d95e2792eb83ab605c9aed91a 100644 (file)
@@ -1 +1 @@
-0.4.1
\ No newline at end of file
+0.4.2