@@ -30,33 +30,33 @@ |
||
| 30 | 30 | $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); |
| 31 | 31 | $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
| 32 | 32 | if(count($configPrefixes) > 0) { |
| 33 | - $ldapWrapper = new OCA\User_LDAP\LDAP(); |
|
| 34 | - $ocConfig = \OC::$server->getConfig(); |
|
| 35 | - $notificationManager = \OC::$server->getNotificationManager(); |
|
| 36 | - $notificationManager->registerNotifier(function() { |
|
| 37 | - return new \OCA\User_LDAP\Notification\Notifier( |
|
| 38 | - \OC::$server->getL10NFactory() |
|
| 39 | - ); |
|
| 40 | - }, function() { |
|
| 41 | - $l = \OC::$server->getL10N('user_ldap'); |
|
| 42 | - return [ |
|
| 43 | - 'id' => 'user_ldap', |
|
| 44 | - 'name' => $l->t('LDAP user and group backend'), |
|
| 45 | - ]; |
|
| 46 | - }); |
|
| 33 | + $ldapWrapper = new OCA\User_LDAP\LDAP(); |
|
| 34 | + $ocConfig = \OC::$server->getConfig(); |
|
| 35 | + $notificationManager = \OC::$server->getNotificationManager(); |
|
| 36 | + $notificationManager->registerNotifier(function() { |
|
| 37 | + return new \OCA\User_LDAP\Notification\Notifier( |
|
| 38 | + \OC::$server->getL10NFactory() |
|
| 39 | + ); |
|
| 40 | + }, function() { |
|
| 41 | + $l = \OC::$server->getL10N('user_ldap'); |
|
| 42 | + return [ |
|
| 43 | + 'id' => 'user_ldap', |
|
| 44 | + 'name' => $l->t('LDAP user and group backend'), |
|
| 45 | + ]; |
|
| 46 | + }); |
|
| 47 | 47 | |
| 48 | - $userBackend = new OCA\User_LDAP\User_Proxy( |
|
| 49 | - $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager |
|
| 50 | - ); |
|
| 51 | - $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 52 | - // register user backend |
|
| 53 | - OC_User::useBackend($userBackend); |
|
| 54 | - \OC::$server->getGroupManager()->addBackend($groupBackend); |
|
| 48 | + $userBackend = new OCA\User_LDAP\User_Proxy( |
|
| 49 | + $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager |
|
| 50 | + ); |
|
| 51 | + $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 52 | + // register user backend |
|
| 53 | + OC_User::useBackend($userBackend); |
|
| 54 | + \OC::$server->getGroupManager()->addBackend($groupBackend); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | \OCP\Util::connectHook( |
| 58 | - '\OCA\Files_Sharing\API\Server2Server', |
|
| 59 | - 'preLoginNameUsedAsUserName', |
|
| 60 | - '\OCA\User_LDAP\Helper', |
|
| 61 | - 'loginName2UserName' |
|
| 58 | + '\OCA\Files_Sharing\API\Server2Server', |
|
| 59 | + 'preLoginNameUsedAsUserName', |
|
| 60 | + '\OCA\User_LDAP\Helper', |
|
| 61 | + 'loginName2UserName' |
|
| 62 | 62 | ); |
@@ -5,46 +5,46 @@ discard block |
||
| 5 | 5 | vendor_style('user_ldap', 'ui-multiselect/jquery.multiselect'); |
| 6 | 6 | |
| 7 | 7 | script('user_ldap', [ |
| 8 | - 'wizard/controller', |
|
| 9 | - 'wizard/configModel', |
|
| 10 | - 'wizard/view', |
|
| 11 | - 'wizard/wizardObject', |
|
| 12 | - 'wizard/wizardTabGeneric', |
|
| 13 | - 'wizard/wizardTabElementary', |
|
| 14 | - 'wizard/wizardTabAbstractFilter', |
|
| 15 | - 'wizard/wizardTabUserFilter', |
|
| 16 | - 'wizard/wizardTabLoginFilter', |
|
| 17 | - 'wizard/wizardTabGroupFilter', |
|
| 18 | - 'wizard/wizardTabAdvanced', |
|
| 19 | - 'wizard/wizardTabExpert', |
|
| 20 | - 'wizard/wizardDetectorQueue', |
|
| 21 | - 'wizard/wizardDetectorGeneric', |
|
| 22 | - 'wizard/wizardDetectorPort', |
|
| 23 | - 'wizard/wizardDetectorBaseDN', |
|
| 24 | - 'wizard/wizardDetectorFeatureAbstract', |
|
| 25 | - 'wizard/wizardDetectorUserObjectClasses', |
|
| 26 | - 'wizard/wizardDetectorGroupObjectClasses', |
|
| 27 | - 'wizard/wizardDetectorGroupsForUsers', |
|
| 28 | - 'wizard/wizardDetectorGroupsForGroups', |
|
| 29 | - 'wizard/wizardDetectorSimpleRequestAbstract', |
|
| 30 | - 'wizard/wizardDetectorFilterUser', |
|
| 31 | - 'wizard/wizardDetectorFilterLogin', |
|
| 32 | - 'wizard/wizardDetectorFilterGroup', |
|
| 33 | - 'wizard/wizardDetectorUserCount', |
|
| 34 | - 'wizard/wizardDetectorGroupCount', |
|
| 35 | - 'wizard/wizardDetectorEmailAttribute', |
|
| 36 | - 'wizard/wizardDetectorUserDisplayNameAttribute', |
|
| 37 | - 'wizard/wizardDetectorUserGroupAssociation', |
|
| 38 | - 'wizard/wizardDetectorAvailableAttributes', |
|
| 39 | - 'wizard/wizardDetectorTestAbstract', |
|
| 40 | - 'wizard/wizardDetectorTestLoginName', |
|
| 41 | - 'wizard/wizardDetectorTestBaseDN', |
|
| 42 | - 'wizard/wizardDetectorTestConfiguration', |
|
| 43 | - 'wizard/wizardDetectorClearUserMappings', |
|
| 44 | - 'wizard/wizardDetectorClearGroupMappings', |
|
| 45 | - 'wizard/wizardFilterOnType', |
|
| 46 | - 'wizard/wizardFilterOnTypeFactory', |
|
| 47 | - 'wizard/wizard' |
|
| 8 | + 'wizard/controller', |
|
| 9 | + 'wizard/configModel', |
|
| 10 | + 'wizard/view', |
|
| 11 | + 'wizard/wizardObject', |
|
| 12 | + 'wizard/wizardTabGeneric', |
|
| 13 | + 'wizard/wizardTabElementary', |
|
| 14 | + 'wizard/wizardTabAbstractFilter', |
|
| 15 | + 'wizard/wizardTabUserFilter', |
|
| 16 | + 'wizard/wizardTabLoginFilter', |
|
| 17 | + 'wizard/wizardTabGroupFilter', |
|
| 18 | + 'wizard/wizardTabAdvanced', |
|
| 19 | + 'wizard/wizardTabExpert', |
|
| 20 | + 'wizard/wizardDetectorQueue', |
|
| 21 | + 'wizard/wizardDetectorGeneric', |
|
| 22 | + 'wizard/wizardDetectorPort', |
|
| 23 | + 'wizard/wizardDetectorBaseDN', |
|
| 24 | + 'wizard/wizardDetectorFeatureAbstract', |
|
| 25 | + 'wizard/wizardDetectorUserObjectClasses', |
|
| 26 | + 'wizard/wizardDetectorGroupObjectClasses', |
|
| 27 | + 'wizard/wizardDetectorGroupsForUsers', |
|
| 28 | + 'wizard/wizardDetectorGroupsForGroups', |
|
| 29 | + 'wizard/wizardDetectorSimpleRequestAbstract', |
|
| 30 | + 'wizard/wizardDetectorFilterUser', |
|
| 31 | + 'wizard/wizardDetectorFilterLogin', |
|
| 32 | + 'wizard/wizardDetectorFilterGroup', |
|
| 33 | + 'wizard/wizardDetectorUserCount', |
|
| 34 | + 'wizard/wizardDetectorGroupCount', |
|
| 35 | + 'wizard/wizardDetectorEmailAttribute', |
|
| 36 | + 'wizard/wizardDetectorUserDisplayNameAttribute', |
|
| 37 | + 'wizard/wizardDetectorUserGroupAssociation', |
|
| 38 | + 'wizard/wizardDetectorAvailableAttributes', |
|
| 39 | + 'wizard/wizardDetectorTestAbstract', |
|
| 40 | + 'wizard/wizardDetectorTestLoginName', |
|
| 41 | + 'wizard/wizardDetectorTestBaseDN', |
|
| 42 | + 'wizard/wizardDetectorTestConfiguration', |
|
| 43 | + 'wizard/wizardDetectorClearUserMappings', |
|
| 44 | + 'wizard/wizardDetectorClearGroupMappings', |
|
| 45 | + 'wizard/wizardFilterOnType', |
|
| 46 | + 'wizard/wizardFilterOnTypeFactory', |
|
| 47 | + 'wizard/wizard' |
|
| 48 | 48 | ]); |
| 49 | 49 | |
| 50 | 50 | style('user_ldap', 'settings'); |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li> |
| 68 | 68 | </ul> |
| 69 | 69 | <?php |
| 70 | - if(!function_exists('ldap_connect')) { |
|
| 71 | - print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
|
| 72 | - } |
|
| 73 | - ?> |
|
| 70 | + if(!function_exists('ldap_connect')) { |
|
| 71 | + print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
|
| 72 | + } |
|
| 73 | + ?> |
|
| 74 | 74 | <?php require_once(__DIR__ . '/part.wizard-server.php'); ?> |
| 75 | 75 | <?php require_once(__DIR__ . '/part.wizard-userfilter.php'); ?> |
| 76 | 76 | <?php require_once(__DIR__ . '/part.wizard-loginfilter.php'); ?> |
@@ -34,132 +34,132 @@ |
||
| 34 | 34 | use OCP\Migration\IRepairStep; |
| 35 | 35 | |
| 36 | 36 | class RepairMimeTypes implements IRepairStep { |
| 37 | - /** |
|
| 38 | - * @var \OCP\IConfig |
|
| 39 | - */ |
|
| 40 | - protected $config; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var int |
|
| 44 | - */ |
|
| 45 | - protected $folderMimeTypeId; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param \OCP\IConfig $config |
|
| 49 | - */ |
|
| 50 | - public function __construct($config) { |
|
| 51 | - $this->config = $config; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function getName() { |
|
| 55 | - return 'Repair mime types'; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - private static function existsStmt() { |
|
| 59 | - return \OC_DB::prepare(' |
|
| 37 | + /** |
|
| 38 | + * @var \OCP\IConfig |
|
| 39 | + */ |
|
| 40 | + protected $config; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var int |
|
| 44 | + */ |
|
| 45 | + protected $folderMimeTypeId; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param \OCP\IConfig $config |
|
| 49 | + */ |
|
| 50 | + public function __construct($config) { |
|
| 51 | + $this->config = $config; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function getName() { |
|
| 55 | + return 'Repair mime types'; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + private static function existsStmt() { |
|
| 59 | + return \OC_DB::prepare(' |
|
| 60 | 60 | SELECT count(`mimetype`) |
| 61 | 61 | FROM `*PREFIX*mimetypes` |
| 62 | 62 | WHERE `mimetype` = ? |
| 63 | 63 | '); |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - private static function getIdStmt() { |
|
| 67 | - return \OC_DB::prepare(' |
|
| 66 | + private static function getIdStmt() { |
|
| 67 | + return \OC_DB::prepare(' |
|
| 68 | 68 | SELECT `id` |
| 69 | 69 | FROM `*PREFIX*mimetypes` |
| 70 | 70 | WHERE `mimetype` = ? |
| 71 | 71 | '); |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - private static function insertStmt() { |
|
| 75 | - return \OC_DB::prepare(' |
|
| 74 | + private static function insertStmt() { |
|
| 75 | + return \OC_DB::prepare(' |
|
| 76 | 76 | INSERT INTO `*PREFIX*mimetypes` ( `mimetype` ) |
| 77 | 77 | VALUES ( ? ) |
| 78 | 78 | '); |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - private static function updateByNameStmt() { |
|
| 82 | - return \OC_DB::prepare(' |
|
| 81 | + private static function updateByNameStmt() { |
|
| 82 | + return \OC_DB::prepare(' |
|
| 83 | 83 | UPDATE `*PREFIX*filecache` |
| 84 | 84 | SET `mimetype` = ? |
| 85 | 85 | WHERE `mimetype` <> ? AND `mimetype` <> ? AND `name` ILIKE ? |
| 86 | 86 | '); |
| 87 | - } |
|
| 88 | - |
|
| 89 | - private function updateMimetypes($updatedMimetypes) { |
|
| 90 | - if (empty($this->folderMimeTypeId)) { |
|
| 91 | - $result = \OC_DB::executeAudited(self::getIdStmt(), array('httpd/unix-directory')); |
|
| 92 | - $this->folderMimeTypeId = (int)$result->fetchOne(); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - foreach ($updatedMimetypes as $extension => $mimetype) { |
|
| 96 | - $result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype)); |
|
| 97 | - $exists = $result->fetchOne(); |
|
| 98 | - |
|
| 99 | - if (!$exists) { |
|
| 100 | - // insert mimetype |
|
| 101 | - \OC_DB::executeAudited(self::insertStmt(), array($mimetype)); |
|
| 102 | - } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + private function updateMimetypes($updatedMimetypes) { |
|
| 90 | + if (empty($this->folderMimeTypeId)) { |
|
| 91 | + $result = \OC_DB::executeAudited(self::getIdStmt(), array('httpd/unix-directory')); |
|
| 92 | + $this->folderMimeTypeId = (int)$result->fetchOne(); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + foreach ($updatedMimetypes as $extension => $mimetype) { |
|
| 96 | + $result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype)); |
|
| 97 | + $exists = $result->fetchOne(); |
|
| 98 | + |
|
| 99 | + if (!$exists) { |
|
| 100 | + // insert mimetype |
|
| 101 | + \OC_DB::executeAudited(self::insertStmt(), array($mimetype)); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // get target mimetype id |
|
| 105 | - $result = \OC_DB::executeAudited(self::getIdStmt(), array($mimetype)); |
|
| 106 | - $mimetypeId = $result->fetchOne(); |
|
| 107 | - |
|
| 108 | - // change mimetype for files with x extension |
|
| 109 | - \OC_DB::executeAudited(self::updateByNameStmt(), array($mimetypeId, $this->folderMimeTypeId, $mimetypeId, '%.' . $extension)); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - private function introduceImageTypes() { |
|
| 114 | - $updatedMimetypes = array( |
|
| 115 | - 'jp2' => 'image/jp2', |
|
| 116 | - 'webp' => 'image/webp', |
|
| 117 | - ); |
|
| 118 | - |
|
| 119 | - $this->updateMimetypes($updatedMimetypes); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - private function introduceWindowsProgramTypes() { |
|
| 123 | - $updatedMimetypes = array( |
|
| 124 | - 'htaccess' => 'text/plain', |
|
| 125 | - 'bat' => 'application/x-msdos-program', |
|
| 126 | - 'cmd' => 'application/cmd', |
|
| 127 | - ); |
|
| 128 | - |
|
| 129 | - $this->updateMimetypes($updatedMimetypes); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - private function introduceLocationTypes() { |
|
| 133 | - $updatedMimetypes = [ |
|
| 134 | - 'gpx' => 'application/gpx+xml', |
|
| 135 | - 'kml' => 'application/vnd.google-earth.kml+xml', |
|
| 136 | - 'kmz' => 'application/vnd.google-earth.kmz', |
|
| 137 | - 'tcx' => 'application/vnd.garmin.tcx+xml', |
|
| 138 | - ]; |
|
| 139 | - |
|
| 140 | - $this->updateMimetypes($updatedMimetypes); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Fix mime types |
|
| 145 | - */ |
|
| 146 | - public function run(IOutput $out) { |
|
| 147 | - |
|
| 148 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
| 149 | - |
|
| 150 | - // NOTE TO DEVELOPERS: when adding new mime types, please make sure to |
|
| 151 | - // add a version comparison to avoid doing it every time |
|
| 152 | - |
|
| 153 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.14', '<') && $this->introduceImageTypes()) { |
|
| 154 | - $out->info('Fixed image mime types'); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.13', '<') && $this->introduceWindowsProgramTypes()) { |
|
| 158 | - $out->info('Fixed windows program mime types'); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if (version_compare($ocVersionFromBeforeUpdate, '13.0.0.0', '<') && $this->introduceLocationTypes()) { |
|
| 162 | - $out->info('Fixed geospatial mime types'); |
|
| 163 | - } |
|
| 164 | - } |
|
| 104 | + // get target mimetype id |
|
| 105 | + $result = \OC_DB::executeAudited(self::getIdStmt(), array($mimetype)); |
|
| 106 | + $mimetypeId = $result->fetchOne(); |
|
| 107 | + |
|
| 108 | + // change mimetype for files with x extension |
|
| 109 | + \OC_DB::executeAudited(self::updateByNameStmt(), array($mimetypeId, $this->folderMimeTypeId, $mimetypeId, '%.' . $extension)); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + private function introduceImageTypes() { |
|
| 114 | + $updatedMimetypes = array( |
|
| 115 | + 'jp2' => 'image/jp2', |
|
| 116 | + 'webp' => 'image/webp', |
|
| 117 | + ); |
|
| 118 | + |
|
| 119 | + $this->updateMimetypes($updatedMimetypes); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + private function introduceWindowsProgramTypes() { |
|
| 123 | + $updatedMimetypes = array( |
|
| 124 | + 'htaccess' => 'text/plain', |
|
| 125 | + 'bat' => 'application/x-msdos-program', |
|
| 126 | + 'cmd' => 'application/cmd', |
|
| 127 | + ); |
|
| 128 | + |
|
| 129 | + $this->updateMimetypes($updatedMimetypes); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + private function introduceLocationTypes() { |
|
| 133 | + $updatedMimetypes = [ |
|
| 134 | + 'gpx' => 'application/gpx+xml', |
|
| 135 | + 'kml' => 'application/vnd.google-earth.kml+xml', |
|
| 136 | + 'kmz' => 'application/vnd.google-earth.kmz', |
|
| 137 | + 'tcx' => 'application/vnd.garmin.tcx+xml', |
|
| 138 | + ]; |
|
| 139 | + |
|
| 140 | + $this->updateMimetypes($updatedMimetypes); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Fix mime types |
|
| 145 | + */ |
|
| 146 | + public function run(IOutput $out) { |
|
| 147 | + |
|
| 148 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
| 149 | + |
|
| 150 | + // NOTE TO DEVELOPERS: when adding new mime types, please make sure to |
|
| 151 | + // add a version comparison to avoid doing it every time |
|
| 152 | + |
|
| 153 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.14', '<') && $this->introduceImageTypes()) { |
|
| 154 | + $out->info('Fixed image mime types'); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.13', '<') && $this->introduceWindowsProgramTypes()) { |
|
| 158 | + $out->info('Fixed windows program mime types'); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if (version_compare($ocVersionFromBeforeUpdate, '13.0.0.0', '<') && $this->introduceLocationTypes()) { |
|
| 162 | + $out->info('Fixed geospatial mime types'); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | } |