@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | $l = \OC::$server->getL10N('user_ldap'); |
| 37 | 37 | |
| 38 | 38 | if(!isset($_POST['action'])) { |
| 39 | - \OCP\JSON::error(array('message' => $l->t('No action specified'))); |
|
| 39 | + \OCP\JSON::error(array('message' => $l->t('No action specified'))); |
|
| 40 | 40 | } |
| 41 | 41 | $action = (string)$_POST['action']; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | if(!isset($_POST['ldap_serverconfig_chooser'])) { |
| 45 | - \OCP\JSON::error(array('message' => $l->t('No configuration specified'))); |
|
| 45 | + \OCP\JSON::error(array('message' => $l->t('No configuration specified'))); |
|
| 46 | 46 | } |
| 47 | 47 | $prefix = (string)$_POST['ldap_serverconfig_chooser']; |
| 48 | 48 | |
@@ -55,95 +55,95 @@ discard block |
||
| 55 | 55 | $con->setIgnoreValidation(true); |
| 56 | 56 | |
| 57 | 57 | $userManager = new \OCA\User_LDAP\User\Manager( |
| 58 | - \OC::$server->getConfig(), |
|
| 59 | - new \OCA\User_LDAP\FilesystemHelper(), |
|
| 60 | - new \OCA\User_LDAP\LogWrapper(), |
|
| 61 | - \OC::$server->getAvatarManager(), |
|
| 62 | - new \OCP\Image(), |
|
| 63 | - \OC::$server->getDatabaseConnection(), |
|
| 64 | - \OC::$server->getUserManager(), |
|
| 65 | - \OC::$server->getNotificationManager()); |
|
| 58 | + \OC::$server->getConfig(), |
|
| 59 | + new \OCA\User_LDAP\FilesystemHelper(), |
|
| 60 | + new \OCA\User_LDAP\LogWrapper(), |
|
| 61 | + \OC::$server->getAvatarManager(), |
|
| 62 | + new \OCP\Image(), |
|
| 63 | + \OC::$server->getDatabaseConnection(), |
|
| 64 | + \OC::$server->getUserManager(), |
|
| 65 | + \OC::$server->getNotificationManager()); |
|
| 66 | 66 | |
| 67 | 67 | $access = new \OCA\User_LDAP\Access( |
| 68 | - $con, |
|
| 69 | - $ldapWrapper, |
|
| 70 | - $userManager, |
|
| 71 | - new \OCA\User_LDAP\Helper(\OC::$server->getConfig()), |
|
| 72 | - \OC::$server->getConfig() |
|
| 68 | + $con, |
|
| 69 | + $ldapWrapper, |
|
| 70 | + $userManager, |
|
| 71 | + new \OCA\User_LDAP\Helper(\OC::$server->getConfig()), |
|
| 72 | + \OC::$server->getConfig() |
|
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | 75 | $wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access); |
| 76 | 76 | |
| 77 | 77 | switch($action) { |
| 78 | - case 'guessPortAndTLS': |
|
| 79 | - case 'guessBaseDN': |
|
| 80 | - case 'detectEmailAttribute': |
|
| 81 | - case 'detectUserDisplayNameAttribute': |
|
| 82 | - case 'determineGroupMemberAssoc': |
|
| 83 | - case 'determineUserObjectClasses': |
|
| 84 | - case 'determineGroupObjectClasses': |
|
| 85 | - case 'determineGroupsForUsers': |
|
| 86 | - case 'determineGroupsForGroups': |
|
| 87 | - case 'determineAttributes': |
|
| 88 | - case 'getUserListFilter': |
|
| 89 | - case 'getUserLoginFilter': |
|
| 90 | - case 'getGroupFilter': |
|
| 91 | - case 'countUsers': |
|
| 92 | - case 'countGroups': |
|
| 93 | - case 'countInBaseDN': |
|
| 94 | - try { |
|
| 95 | - $result = $wizard->$action(); |
|
| 96 | - if($result !== false) { |
|
| 97 | - OCP\JSON::success($result->getResultArray()); |
|
| 98 | - exit; |
|
| 99 | - } |
|
| 100 | - } catch (\Exception $e) { |
|
| 101 | - \OCP\JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); |
|
| 102 | - exit; |
|
| 103 | - } |
|
| 104 | - \OCP\JSON::error(); |
|
| 105 | - exit; |
|
| 106 | - break; |
|
| 78 | + case 'guessPortAndTLS': |
|
| 79 | + case 'guessBaseDN': |
|
| 80 | + case 'detectEmailAttribute': |
|
| 81 | + case 'detectUserDisplayNameAttribute': |
|
| 82 | + case 'determineGroupMemberAssoc': |
|
| 83 | + case 'determineUserObjectClasses': |
|
| 84 | + case 'determineGroupObjectClasses': |
|
| 85 | + case 'determineGroupsForUsers': |
|
| 86 | + case 'determineGroupsForGroups': |
|
| 87 | + case 'determineAttributes': |
|
| 88 | + case 'getUserListFilter': |
|
| 89 | + case 'getUserLoginFilter': |
|
| 90 | + case 'getGroupFilter': |
|
| 91 | + case 'countUsers': |
|
| 92 | + case 'countGroups': |
|
| 93 | + case 'countInBaseDN': |
|
| 94 | + try { |
|
| 95 | + $result = $wizard->$action(); |
|
| 96 | + if($result !== false) { |
|
| 97 | + OCP\JSON::success($result->getResultArray()); |
|
| 98 | + exit; |
|
| 99 | + } |
|
| 100 | + } catch (\Exception $e) { |
|
| 101 | + \OCP\JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); |
|
| 102 | + exit; |
|
| 103 | + } |
|
| 104 | + \OCP\JSON::error(); |
|
| 105 | + exit; |
|
| 106 | + break; |
|
| 107 | 107 | |
| 108 | - case 'testLoginName': { |
|
| 109 | - try { |
|
| 110 | - $loginName = $_POST['ldap_test_loginname']; |
|
| 111 | - $result = $wizard->$action($loginName); |
|
| 112 | - if($result !== false) { |
|
| 113 | - OCP\JSON::success($result->getResultArray()); |
|
| 114 | - exit; |
|
| 115 | - } |
|
| 116 | - } catch (\Exception $e) { |
|
| 117 | - \OCP\JSON::error(array('message' => $e->getMessage())); |
|
| 118 | - exit; |
|
| 119 | - } |
|
| 120 | - \OCP\JSON::error(); |
|
| 121 | - exit; |
|
| 122 | - break; |
|
| 123 | - } |
|
| 108 | + case 'testLoginName': { |
|
| 109 | + try { |
|
| 110 | + $loginName = $_POST['ldap_test_loginname']; |
|
| 111 | + $result = $wizard->$action($loginName); |
|
| 112 | + if($result !== false) { |
|
| 113 | + OCP\JSON::success($result->getResultArray()); |
|
| 114 | + exit; |
|
| 115 | + } |
|
| 116 | + } catch (\Exception $e) { |
|
| 117 | + \OCP\JSON::error(array('message' => $e->getMessage())); |
|
| 118 | + exit; |
|
| 119 | + } |
|
| 120 | + \OCP\JSON::error(); |
|
| 121 | + exit; |
|
| 122 | + break; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - case 'save': |
|
| 126 | - $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; |
|
| 127 | - $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; |
|
| 128 | - if($key === false || is_null($val)) { |
|
| 129 | - \OCP\JSON::error(array('message' => $l->t('No data specified'))); |
|
| 130 | - exit; |
|
| 131 | - } |
|
| 132 | - $cfg = array($key => $val); |
|
| 133 | - $setParameters = array(); |
|
| 134 | - $configuration->setConfiguration($cfg, $setParameters); |
|
| 135 | - if(!in_array($key, $setParameters)) { |
|
| 136 | - \OCP\JSON::error(array('message' => $l->t($key. |
|
| 137 | - ' Could not set configuration %s', $setParameters[0]))); |
|
| 138 | - exit; |
|
| 139 | - } |
|
| 140 | - $configuration->saveConfiguration(); |
|
| 141 | - //clear the cache on save |
|
| 142 | - $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
|
| 143 | - $connection->clearCache(); |
|
| 144 | - OCP\JSON::success(); |
|
| 145 | - break; |
|
| 146 | - default: |
|
| 147 | - \OCP\JSON::error(array('message' => $l->t('Action does not exist'))); |
|
| 148 | - break; |
|
| 125 | + case 'save': |
|
| 126 | + $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; |
|
| 127 | + $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; |
|
| 128 | + if($key === false || is_null($val)) { |
|
| 129 | + \OCP\JSON::error(array('message' => $l->t('No data specified'))); |
|
| 130 | + exit; |
|
| 131 | + } |
|
| 132 | + $cfg = array($key => $val); |
|
| 133 | + $setParameters = array(); |
|
| 134 | + $configuration->setConfiguration($cfg, $setParameters); |
|
| 135 | + if(!in_array($key, $setParameters)) { |
|
| 136 | + \OCP\JSON::error(array('message' => $l->t($key. |
|
| 137 | + ' Could not set configuration %s', $setParameters[0]))); |
|
| 138 | + exit; |
|
| 139 | + } |
|
| 140 | + $configuration->saveConfiguration(); |
|
| 141 | + //clear the cache on save |
|
| 142 | + $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
|
| 143 | + $connection->clearCache(); |
|
| 144 | + OCP\JSON::success(); |
|
| 145 | + break; |
|
| 146 | + default: |
|
| 147 | + \OCP\JSON::error(array('message' => $l->t('Action does not exist'))); |
|
| 148 | + break; |
|
| 149 | 149 | } |