@@ -48,84 +48,84 @@ |
||
| 48 | 48 | use Psr\Container\ContainerInterface; |
| 49 | 49 | |
| 50 | 50 | class Application extends App implements IBootstrap { |
| 51 | - public const APP_ID = 'files_versions'; |
|
| 51 | + public const APP_ID = 'files_versions'; |
|
| 52 | 52 | |
| 53 | - public function __construct(array $urlParams = []) { |
|
| 54 | - parent::__construct(self::APP_ID, $urlParams); |
|
| 55 | - } |
|
| 53 | + public function __construct(array $urlParams = []) { |
|
| 54 | + parent::__construct(self::APP_ID, $urlParams); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function register(IRegistrationContext $context): void { |
|
| 58 | - /** |
|
| 59 | - * Register capabilities |
|
| 60 | - */ |
|
| 61 | - $context->registerCapability(Capabilities::class); |
|
| 57 | + public function register(IRegistrationContext $context): void { |
|
| 58 | + /** |
|
| 59 | + * Register capabilities |
|
| 60 | + */ |
|
| 61 | + $context->registerCapability(Capabilities::class); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Register $principalBackend for the DAV collection |
|
| 65 | - */ |
|
| 66 | - $context->registerService('principalBackend', function (ContainerInterface $c) { |
|
| 67 | - /** @var IServerContainer $server */ |
|
| 68 | - $server = $c->get(IServerContainer::class); |
|
| 69 | - return new Principal( |
|
| 70 | - $server->getUserManager(), |
|
| 71 | - $server->getGroupManager(), |
|
| 72 | - $server->getShareManager(), |
|
| 73 | - $server->getUserSession(), |
|
| 74 | - $server->getAppManager(), |
|
| 75 | - $server->get(ProxyMapper::class), |
|
| 76 | - $server->get(KnownUserService::class), |
|
| 77 | - $server->getConfig() |
|
| 78 | - ); |
|
| 79 | - }); |
|
| 63 | + /** |
|
| 64 | + * Register $principalBackend for the DAV collection |
|
| 65 | + */ |
|
| 66 | + $context->registerService('principalBackend', function (ContainerInterface $c) { |
|
| 67 | + /** @var IServerContainer $server */ |
|
| 68 | + $server = $c->get(IServerContainer::class); |
|
| 69 | + return new Principal( |
|
| 70 | + $server->getUserManager(), |
|
| 71 | + $server->getGroupManager(), |
|
| 72 | + $server->getShareManager(), |
|
| 73 | + $server->getUserSession(), |
|
| 74 | + $server->getAppManager(), |
|
| 75 | + $server->get(ProxyMapper::class), |
|
| 76 | + $server->get(KnownUserService::class), |
|
| 77 | + $server->getConfig() |
|
| 78 | + ); |
|
| 79 | + }); |
|
| 80 | 80 | |
| 81 | - $context->registerService(IVersionManager::class, function () { |
|
| 82 | - return new VersionManager(); |
|
| 83 | - }); |
|
| 81 | + $context->registerService(IVersionManager::class, function () { |
|
| 82 | + return new VersionManager(); |
|
| 83 | + }); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Register Events |
|
| 87 | - */ |
|
| 88 | - $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
| 89 | - $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
| 90 | - } |
|
| 85 | + /** |
|
| 86 | + * Register Events |
|
| 87 | + */ |
|
| 88 | + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
| 89 | + $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - public function boot(IBootContext $context): void { |
|
| 93 | - $context->injectFn(\Closure::fromCallable([$this, 'registerVersionBackends'])); |
|
| 92 | + public function boot(IBootContext $context): void { |
|
| 93 | + $context->injectFn(\Closure::fromCallable([$this, 'registerVersionBackends'])); |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Register hooks |
|
| 97 | - */ |
|
| 98 | - Hooks::connectHooks(); |
|
| 99 | - } |
|
| 95 | + /** |
|
| 96 | + * Register hooks |
|
| 97 | + */ |
|
| 98 | + Hooks::connectHooks(); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public function registerVersionBackends(ContainerInterface $container, IAppManager $appManager, ILogger $logger) { |
|
| 102 | - foreach ($appManager->getInstalledApps() as $app) { |
|
| 103 | - $appInfo = $appManager->getAppInfo($app); |
|
| 104 | - if (isset($appInfo['versions'])) { |
|
| 105 | - $backends = $appInfo['versions']; |
|
| 106 | - foreach ($backends as $backend) { |
|
| 107 | - if (isset($backend['@value'])) { |
|
| 108 | - $this->loadBackend($backend, $container, $logger); |
|
| 109 | - } else { |
|
| 110 | - foreach ($backend as $singleBackend) { |
|
| 111 | - $this->loadBackend($singleBackend, $container, $logger); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } |
|
| 101 | + public function registerVersionBackends(ContainerInterface $container, IAppManager $appManager, ILogger $logger) { |
|
| 102 | + foreach ($appManager->getInstalledApps() as $app) { |
|
| 103 | + $appInfo = $appManager->getAppInfo($app); |
|
| 104 | + if (isset($appInfo['versions'])) { |
|
| 105 | + $backends = $appInfo['versions']; |
|
| 106 | + foreach ($backends as $backend) { |
|
| 107 | + if (isset($backend['@value'])) { |
|
| 108 | + $this->loadBackend($backend, $container, $logger); |
|
| 109 | + } else { |
|
| 110 | + foreach ($backend as $singleBackend) { |
|
| 111 | + $this->loadBackend($singleBackend, $container, $logger); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - private function loadBackend(array $backend, ContainerInterface $container, ILogger $logger) { |
|
| 120 | - /** @var IVersionManager $versionManager */ |
|
| 121 | - $versionManager = $container->get(IVersionManager::class); |
|
| 122 | - $class = $backend['@value']; |
|
| 123 | - $for = $backend['@attributes']['for']; |
|
| 124 | - try { |
|
| 125 | - $backendObject = $container->get($class); |
|
| 126 | - $versionManager->registerBackend($for, $backendObject); |
|
| 127 | - } catch (\Exception $e) { |
|
| 128 | - $logger->logException($e); |
|
| 129 | - } |
|
| 130 | - } |
|
| 119 | + private function loadBackend(array $backend, ContainerInterface $container, ILogger $logger) { |
|
| 120 | + /** @var IVersionManager $versionManager */ |
|
| 121 | + $versionManager = $container->get(IVersionManager::class); |
|
| 122 | + $class = $backend['@value']; |
|
| 123 | + $for = $backend['@attributes']['for']; |
|
| 124 | + try { |
|
| 125 | + $backendObject = $container->get($class); |
|
| 126 | + $versionManager->registerBackend($for, $backendObject); |
|
| 127 | + } catch (\Exception $e) { |
|
| 128 | + $logger->logException($e); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -71,518 +71,518 @@ |
||
| 71 | 71 | use function in_array; |
| 72 | 72 | |
| 73 | 73 | class UsersController extends Controller { |
| 74 | - /** @var UserManager */ |
|
| 75 | - private $userManager; |
|
| 76 | - /** @var GroupManager */ |
|
| 77 | - private $groupManager; |
|
| 78 | - /** @var IUserSession */ |
|
| 79 | - private $userSession; |
|
| 80 | - /** @var IConfig */ |
|
| 81 | - private $config; |
|
| 82 | - /** @var bool */ |
|
| 83 | - private $isAdmin; |
|
| 84 | - /** @var IL10N */ |
|
| 85 | - private $l10n; |
|
| 86 | - /** @var IMailer */ |
|
| 87 | - private $mailer; |
|
| 88 | - /** @var Factory */ |
|
| 89 | - private $l10nFactory; |
|
| 90 | - /** @var IAppManager */ |
|
| 91 | - private $appManager; |
|
| 92 | - /** @var AccountManager */ |
|
| 93 | - private $accountManager; |
|
| 94 | - /** @var Manager */ |
|
| 95 | - private $keyManager; |
|
| 96 | - /** @var IJobList */ |
|
| 97 | - private $jobList; |
|
| 98 | - /** @var IManager */ |
|
| 99 | - private $encryptionManager; |
|
| 100 | - /** @var KnownUserService */ |
|
| 101 | - private $knownUserService; |
|
| 102 | - /** @var IEventDispatcher */ |
|
| 103 | - private $dispatcher; |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - public function __construct( |
|
| 107 | - string $appName, |
|
| 108 | - IRequest $request, |
|
| 109 | - IUserManager $userManager, |
|
| 110 | - IGroupManager $groupManager, |
|
| 111 | - IUserSession $userSession, |
|
| 112 | - IConfig $config, |
|
| 113 | - bool $isAdmin, |
|
| 114 | - IL10N $l10n, |
|
| 115 | - IMailer $mailer, |
|
| 116 | - IFactory $l10nFactory, |
|
| 117 | - IAppManager $appManager, |
|
| 118 | - AccountManager $accountManager, |
|
| 119 | - Manager $keyManager, |
|
| 120 | - IJobList $jobList, |
|
| 121 | - IManager $encryptionManager, |
|
| 122 | - KnownUserService $knownUserService, |
|
| 123 | - IEventDispatcher $dispatcher |
|
| 124 | - ) { |
|
| 125 | - parent::__construct($appName, $request); |
|
| 126 | - $this->userManager = $userManager; |
|
| 127 | - $this->groupManager = $groupManager; |
|
| 128 | - $this->userSession = $userSession; |
|
| 129 | - $this->config = $config; |
|
| 130 | - $this->isAdmin = $isAdmin; |
|
| 131 | - $this->l10n = $l10n; |
|
| 132 | - $this->mailer = $mailer; |
|
| 133 | - $this->l10nFactory = $l10nFactory; |
|
| 134 | - $this->appManager = $appManager; |
|
| 135 | - $this->accountManager = $accountManager; |
|
| 136 | - $this->keyManager = $keyManager; |
|
| 137 | - $this->jobList = $jobList; |
|
| 138 | - $this->encryptionManager = $encryptionManager; |
|
| 139 | - $this->knownUserService = $knownUserService; |
|
| 140 | - $this->dispatcher = $dispatcher; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @NoCSRFRequired |
|
| 146 | - * @NoAdminRequired |
|
| 147 | - * |
|
| 148 | - * Display users list template |
|
| 149 | - * |
|
| 150 | - * @return TemplateResponse |
|
| 151 | - */ |
|
| 152 | - public function usersListByGroup(): TemplateResponse { |
|
| 153 | - return $this->usersList(); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @NoCSRFRequired |
|
| 158 | - * @NoAdminRequired |
|
| 159 | - * |
|
| 160 | - * Display users list template |
|
| 161 | - * |
|
| 162 | - * @return TemplateResponse |
|
| 163 | - */ |
|
| 164 | - public function usersList(): TemplateResponse { |
|
| 165 | - $user = $this->userSession->getUser(); |
|
| 166 | - $uid = $user->getUID(); |
|
| 167 | - |
|
| 168 | - \OC::$server->getNavigationManager()->setActiveEntry('core_users'); |
|
| 169 | - |
|
| 170 | - /* SORT OPTION: SORT_USERCOUNT or SORT_GROUPNAME */ |
|
| 171 | - $sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT; |
|
| 172 | - $isLDAPUsed = false; |
|
| 173 | - if ($this->config->getSystemValue('sort_groups_by_name', false)) { |
|
| 174 | - $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME; |
|
| 175 | - } else { |
|
| 176 | - if ($this->appManager->isEnabledForUser('user_ldap')) { |
|
| 177 | - $isLDAPUsed = |
|
| 178 | - $this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy'); |
|
| 179 | - if ($isLDAPUsed) { |
|
| 180 | - // LDAP user count can be slow, so we sort by group name here |
|
| 181 | - $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $canChangePassword = $this->canAdminChangeUserPasswords(); |
|
| 187 | - |
|
| 188 | - /* GROUPS */ |
|
| 189 | - $groupsInfo = new \OC\Group\MetaData( |
|
| 190 | - $uid, |
|
| 191 | - $this->isAdmin, |
|
| 192 | - $this->groupManager, |
|
| 193 | - $this->userSession |
|
| 194 | - ); |
|
| 195 | - |
|
| 196 | - $groupsInfo->setSorting($sortGroupsBy); |
|
| 197 | - [$adminGroup, $groups] = $groupsInfo->get(); |
|
| 198 | - |
|
| 199 | - if (!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { |
|
| 200 | - $isLDAPUsed = (bool)array_reduce($this->userManager->getBackends(), function ($ldapFound, $backend) { |
|
| 201 | - return $ldapFound || $backend instanceof User_Proxy; |
|
| 202 | - }); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $disabledUsers = -1; |
|
| 206 | - $userCount = 0; |
|
| 207 | - |
|
| 208 | - if (!$isLDAPUsed) { |
|
| 209 | - if ($this->isAdmin) { |
|
| 210 | - $disabledUsers = $this->userManager->countDisabledUsers(); |
|
| 211 | - $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { |
|
| 212 | - return $v + (int)$w; |
|
| 213 | - }, 0); |
|
| 214 | - } else { |
|
| 215 | - // User is subadmin ! |
|
| 216 | - // Map group list to names to retrieve the countDisabledUsersOfGroups |
|
| 217 | - $userGroups = $this->groupManager->getUserGroups($user); |
|
| 218 | - $groupsNames = []; |
|
| 219 | - |
|
| 220 | - foreach ($groups as $key => $group) { |
|
| 221 | - // $userCount += (int)$group['usercount']; |
|
| 222 | - array_push($groupsNames, $group['name']); |
|
| 223 | - // we prevent subadmins from looking up themselves |
|
| 224 | - // so we lower the count of the groups he belongs to |
|
| 225 | - if (array_key_exists($group['id'], $userGroups)) { |
|
| 226 | - $groups[$key]['usercount']--; |
|
| 227 | - $userCount -= 1; // we also lower from one the total count |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - $userCount += $this->userManager->countUsersOfGroups($groupsInfo->getGroups()); |
|
| 231 | - $disabledUsers = $this->userManager->countDisabledUsersOfGroups($groupsNames); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - $userCount -= $disabledUsers; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - $disabledUsersGroup = [ |
|
| 238 | - 'id' => 'disabled', |
|
| 239 | - 'name' => 'Disabled users', |
|
| 240 | - 'usercount' => $disabledUsers |
|
| 241 | - ]; |
|
| 242 | - |
|
| 243 | - /* QUOTAS PRESETS */ |
|
| 244 | - $quotaPreset = $this->parseQuotaPreset($this->config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB')); |
|
| 245 | - $defaultQuota = $this->config->getAppValue('files', 'default_quota', 'none'); |
|
| 246 | - |
|
| 247 | - $event = new BeforeTemplateRenderedEvent(); |
|
| 248 | - $this->dispatcher->dispatch('OC\Settings\Users::loadAdditionalScripts', $event); |
|
| 249 | - $this->dispatcher->dispatchTyped($event); |
|
| 250 | - |
|
| 251 | - /* LANGUAGES */ |
|
| 252 | - $languages = $this->l10nFactory->getLanguages(); |
|
| 253 | - |
|
| 254 | - /* FINAL DATA */ |
|
| 255 | - $serverData = []; |
|
| 256 | - // groups |
|
| 257 | - $serverData['groups'] = array_merge_recursive($adminGroup, [$disabledUsersGroup], $groups); |
|
| 258 | - // Various data |
|
| 259 | - $serverData['isAdmin'] = $this->isAdmin; |
|
| 260 | - $serverData['sortGroups'] = $sortGroupsBy; |
|
| 261 | - $serverData['quotaPreset'] = $quotaPreset; |
|
| 262 | - $serverData['userCount'] = $userCount; |
|
| 263 | - $serverData['languages'] = $languages; |
|
| 264 | - $serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en'); |
|
| 265 | - $serverData['forceLanguage'] = $this->config->getSystemValue('force_language', false); |
|
| 266 | - // Settings |
|
| 267 | - $serverData['defaultQuota'] = $defaultQuota; |
|
| 268 | - $serverData['canChangePassword'] = $canChangePassword; |
|
| 269 | - $serverData['newUserGenerateUserID'] = $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes'; |
|
| 270 | - $serverData['newUserRequireEmail'] = $this->config->getAppValue('core', 'newUser.requireEmail', 'no') === 'yes'; |
|
| 271 | - $serverData['newUserSendEmail'] = $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes'; |
|
| 272 | - |
|
| 273 | - return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData]); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @param string $key |
|
| 278 | - * @param string $value |
|
| 279 | - * |
|
| 280 | - * @return JSONResponse |
|
| 281 | - */ |
|
| 282 | - public function setPreference(string $key, string $value): JSONResponse { |
|
| 283 | - $allowed = ['newUser.sendEmail']; |
|
| 284 | - if (!in_array($key, $allowed, true)) { |
|
| 285 | - return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - $this->config->setAppValue('core', $key, $value); |
|
| 289 | - |
|
| 290 | - return new JSONResponse([]); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Parse the app value for quota_present |
|
| 295 | - * |
|
| 296 | - * @param string $quotaPreset |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - protected function parseQuotaPreset(string $quotaPreset): array { |
|
| 300 | - // 1 GB, 5 GB, 10 GB => [1 GB, 5 GB, 10 GB] |
|
| 301 | - $presets = array_filter(array_map('trim', explode(',', $quotaPreset))); |
|
| 302 | - // Drop default and none, Make array indexes numerically |
|
| 303 | - return array_values(array_diff($presets, ['default', 'none'])); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * check if the admin can change the users password |
|
| 308 | - * |
|
| 309 | - * The admin can change the passwords if: |
|
| 310 | - * |
|
| 311 | - * - no encryption module is loaded and encryption is disabled |
|
| 312 | - * - encryption module is loaded but it doesn't require per user keys |
|
| 313 | - * |
|
| 314 | - * The admin can not change the passwords if: |
|
| 315 | - * |
|
| 316 | - * - an encryption module is loaded and it uses per-user keys |
|
| 317 | - * - encryption is enabled but no encryption modules are loaded |
|
| 318 | - * |
|
| 319 | - * @return bool |
|
| 320 | - */ |
|
| 321 | - protected function canAdminChangeUserPasswords(): bool { |
|
| 322 | - $isEncryptionEnabled = $this->encryptionManager->isEnabled(); |
|
| 323 | - try { |
|
| 324 | - $noUserSpecificEncryptionKeys = !$this->encryptionManager->getEncryptionModule()->needDetailedAccessList(); |
|
| 325 | - $isEncryptionModuleLoaded = true; |
|
| 326 | - } catch (ModuleDoesNotExistsException $e) { |
|
| 327 | - $noUserSpecificEncryptionKeys = true; |
|
| 328 | - $isEncryptionModuleLoaded = false; |
|
| 329 | - } |
|
| 330 | - $canChangePassword = ($isEncryptionModuleLoaded && $noUserSpecificEncryptionKeys) |
|
| 331 | - || (!$isEncryptionModuleLoaded && !$isEncryptionEnabled); |
|
| 332 | - |
|
| 333 | - return $canChangePassword; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @NoAdminRequired |
|
| 338 | - * @NoSubAdminRequired |
|
| 339 | - * @PasswordConfirmationRequired |
|
| 340 | - * |
|
| 341 | - * @param string|null $avatarScope |
|
| 342 | - * @param string|null $displayname |
|
| 343 | - * @param string|null $displaynameScope |
|
| 344 | - * @param string|null $phone |
|
| 345 | - * @param string|null $phoneScope |
|
| 346 | - * @param string|null $email |
|
| 347 | - * @param string|null $emailScope |
|
| 348 | - * @param string|null $website |
|
| 349 | - * @param string|null $websiteScope |
|
| 350 | - * @param string|null $address |
|
| 351 | - * @param string|null $addressScope |
|
| 352 | - * @param string|null $twitter |
|
| 353 | - * @param string|null $twitterScope |
|
| 354 | - * |
|
| 355 | - * @return DataResponse |
|
| 356 | - */ |
|
| 357 | - public function setUserSettings(?string $avatarScope = null, |
|
| 358 | - ?string $displayname = null, |
|
| 359 | - ?string $displaynameScope = null, |
|
| 360 | - ?string $phone = null, |
|
| 361 | - ?string $phoneScope = null, |
|
| 362 | - ?string $email = null, |
|
| 363 | - ?string $emailScope = null, |
|
| 364 | - ?string $website = null, |
|
| 365 | - ?string $websiteScope = null, |
|
| 366 | - ?string $address = null, |
|
| 367 | - ?string $addressScope = null, |
|
| 368 | - ?string $twitter = null, |
|
| 369 | - ?string $twitterScope = null |
|
| 370 | - ) { |
|
| 371 | - $user = $this->userSession->getUser(); |
|
| 372 | - if (!$user instanceof IUser) { |
|
| 373 | - return new DataResponse( |
|
| 374 | - [ |
|
| 375 | - 'status' => 'error', |
|
| 376 | - 'data' => [ |
|
| 377 | - 'message' => $this->l10n->t('Invalid user') |
|
| 378 | - ] |
|
| 379 | - ], |
|
| 380 | - Http::STATUS_UNAUTHORIZED |
|
| 381 | - ); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - $email = strtolower($email); |
|
| 385 | - if (!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
| 386 | - return new DataResponse( |
|
| 387 | - [ |
|
| 388 | - 'status' => 'error', |
|
| 389 | - 'data' => [ |
|
| 390 | - 'message' => $this->l10n->t('Invalid mail address') |
|
| 391 | - ] |
|
| 392 | - ], |
|
| 393 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 394 | - ); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - $data = $this->accountManager->getUser($user); |
|
| 398 | - $beforeData = $data; |
|
| 399 | - $data[IAccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope]; |
|
| 400 | - if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) { |
|
| 401 | - $data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope]; |
|
| 402 | - $data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope]; |
|
| 403 | - } |
|
| 404 | - if ($this->appManager->isEnabledForUser('federatedfilesharing')) { |
|
| 405 | - $shareProvider = \OC::$server->query(FederatedShareProvider::class); |
|
| 406 | - if ($shareProvider->isLookupServerUploadEnabled()) { |
|
| 407 | - $data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope]; |
|
| 408 | - $data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope]; |
|
| 409 | - $data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope]; |
|
| 410 | - $data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope]; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - try { |
|
| 414 | - $data = $this->saveUserSettings($user, $data); |
|
| 415 | - if ($beforeData[IAccountManager::PROPERTY_PHONE]['value'] !== $data[IAccountManager::PROPERTY_PHONE]['value']) { |
|
| 416 | - $this->knownUserService->deleteByContactUserId($user->getUID()); |
|
| 417 | - } |
|
| 418 | - return new DataResponse( |
|
| 419 | - [ |
|
| 420 | - 'status' => 'success', |
|
| 421 | - 'data' => [ |
|
| 422 | - 'userId' => $user->getUID(), |
|
| 423 | - 'avatarScope' => $data[IAccountManager::PROPERTY_AVATAR]['scope'], |
|
| 424 | - 'displayname' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 425 | - 'displaynameScope' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'], |
|
| 426 | - 'phone' => $data[IAccountManager::PROPERTY_PHONE]['value'], |
|
| 427 | - 'phoneScope' => $data[IAccountManager::PROPERTY_PHONE]['scope'], |
|
| 428 | - 'email' => $data[IAccountManager::PROPERTY_EMAIL]['value'], |
|
| 429 | - 'emailScope' => $data[IAccountManager::PROPERTY_EMAIL]['scope'], |
|
| 430 | - 'website' => $data[IAccountManager::PROPERTY_WEBSITE]['value'], |
|
| 431 | - 'websiteScope' => $data[IAccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 432 | - 'address' => $data[IAccountManager::PROPERTY_ADDRESS]['value'], |
|
| 433 | - 'addressScope' => $data[IAccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 434 | - 'twitter' => $data[IAccountManager::PROPERTY_TWITTER]['value'], |
|
| 435 | - 'twitterScope' => $data[IAccountManager::PROPERTY_TWITTER]['scope'], |
|
| 436 | - 'message' => $this->l10n->t('Settings saved') |
|
| 437 | - ] |
|
| 438 | - ], |
|
| 439 | - Http::STATUS_OK |
|
| 440 | - ); |
|
| 441 | - } catch (ForbiddenException $e) { |
|
| 442 | - return new DataResponse([ |
|
| 443 | - 'status' => 'error', |
|
| 444 | - 'data' => [ |
|
| 445 | - 'message' => $e->getMessage() |
|
| 446 | - ], |
|
| 447 | - ]); |
|
| 448 | - } catch (\InvalidArgumentException $e) { |
|
| 449 | - return new DataResponse([ |
|
| 450 | - 'status' => 'error', |
|
| 451 | - 'data' => [ |
|
| 452 | - 'message' => $e->getMessage() |
|
| 453 | - ], |
|
| 454 | - ]); |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - /** |
|
| 458 | - * update account manager with new user data |
|
| 459 | - * |
|
| 460 | - * @param IUser $user |
|
| 461 | - * @param array $data |
|
| 462 | - * @return array |
|
| 463 | - * @throws ForbiddenException |
|
| 464 | - * @throws \InvalidArgumentException |
|
| 465 | - */ |
|
| 466 | - protected function saveUserSettings(IUser $user, array $data): array { |
|
| 467 | - // keep the user back-end up-to-date with the latest display name and email |
|
| 468 | - // address |
|
| 469 | - $oldDisplayName = $user->getDisplayName(); |
|
| 470 | - $oldDisplayName = is_null($oldDisplayName) ? '' : $oldDisplayName; |
|
| 471 | - if (isset($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']) |
|
| 472 | - && $oldDisplayName !== $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] |
|
| 473 | - ) { |
|
| 474 | - $result = $user->setDisplayName($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']); |
|
| 475 | - if ($result === false) { |
|
| 476 | - throw new ForbiddenException($this->l10n->t('Unable to change full name')); |
|
| 477 | - } |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - $oldEmailAddress = $user->getEMailAddress(); |
|
| 481 | - $oldEmailAddress = is_null($oldEmailAddress) ? '' : strtolower($oldEmailAddress); |
|
| 482 | - if (isset($data[IAccountManager::PROPERTY_EMAIL]['value']) |
|
| 483 | - && $oldEmailAddress !== $data[IAccountManager::PROPERTY_EMAIL]['value'] |
|
| 484 | - ) { |
|
| 485 | - // this is the only permission a backend provides and is also used |
|
| 486 | - // for the permission of setting a email address |
|
| 487 | - if (!$user->canChangeDisplayName()) { |
|
| 488 | - throw new ForbiddenException($this->l10n->t('Unable to change email address')); |
|
| 489 | - } |
|
| 490 | - $user->setEMailAddress($data[IAccountManager::PROPERTY_EMAIL]['value']); |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - try { |
|
| 494 | - return $this->accountManager->updateUser($user, $data, true); |
|
| 495 | - } catch (\InvalidArgumentException $e) { |
|
| 496 | - if ($e->getMessage() === IAccountManager::PROPERTY_PHONE) { |
|
| 497 | - throw new \InvalidArgumentException($this->l10n->t('Unable to set invalid phone number')); |
|
| 498 | - } |
|
| 499 | - throw new \InvalidArgumentException($this->l10n->t('Some account data was invalid')); |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Set the mail address of a user |
|
| 505 | - * |
|
| 506 | - * @NoAdminRequired |
|
| 507 | - * @NoSubAdminRequired |
|
| 508 | - * @PasswordConfirmationRequired |
|
| 509 | - * |
|
| 510 | - * @param string $account |
|
| 511 | - * @param bool $onlyVerificationCode only return verification code without updating the data |
|
| 512 | - * @return DataResponse |
|
| 513 | - */ |
|
| 514 | - public function getVerificationCode(string $account, bool $onlyVerificationCode): DataResponse { |
|
| 515 | - $user = $this->userSession->getUser(); |
|
| 516 | - |
|
| 517 | - if ($user === null) { |
|
| 518 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - $accountData = $this->accountManager->getUser($user); |
|
| 522 | - $cloudId = $user->getCloudId(); |
|
| 523 | - $message = 'Use my Federated Cloud ID to share with me: ' . $cloudId; |
|
| 524 | - $signature = $this->signMessage($user, $message); |
|
| 525 | - |
|
| 526 | - $code = $message . ' ' . $signature; |
|
| 527 | - $codeMd5 = $message . ' ' . md5($signature); |
|
| 528 | - |
|
| 529 | - switch ($account) { |
|
| 530 | - case 'verify-twitter': |
|
| 531 | - $accountData[IAccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
| 532 | - $msg = $this->l10n->t('In order to verify your Twitter account, post the following tweet on Twitter (please make sure to post it without any line breaks):'); |
|
| 533 | - $code = $codeMd5; |
|
| 534 | - $type = IAccountManager::PROPERTY_TWITTER; |
|
| 535 | - $accountData[IAccountManager::PROPERTY_TWITTER]['signature'] = $signature; |
|
| 536 | - break; |
|
| 537 | - case 'verify-website': |
|
| 538 | - $accountData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
| 539 | - $msg = $this->l10n->t('In order to verify your Website, store the following content in your web-root at \'.well-known/CloudIdVerificationCode.txt\' (please make sure that the complete text is in one line):'); |
|
| 540 | - $type = IAccountManager::PROPERTY_WEBSITE; |
|
| 541 | - $accountData[IAccountManager::PROPERTY_WEBSITE]['signature'] = $signature; |
|
| 542 | - break; |
|
| 543 | - default: |
|
| 544 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - if ($onlyVerificationCode === false) { |
|
| 548 | - $accountData = $this->accountManager->updateUser($user, $accountData); |
|
| 549 | - $data = $accountData[$type]['value']; |
|
| 550 | - |
|
| 551 | - $this->jobList->add(VerifyUserData::class, |
|
| 552 | - [ |
|
| 553 | - 'verificationCode' => $code, |
|
| 554 | - 'data' => $data, |
|
| 555 | - 'type' => $type, |
|
| 556 | - 'uid' => $user->getUID(), |
|
| 557 | - 'try' => 0, |
|
| 558 | - 'lastRun' => $this->getCurrentTime() |
|
| 559 | - ] |
|
| 560 | - ); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - return new DataResponse(['msg' => $msg, 'code' => $code]); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * get current timestamp |
|
| 568 | - * |
|
| 569 | - * @return int |
|
| 570 | - */ |
|
| 571 | - protected function getCurrentTime(): int { |
|
| 572 | - return time(); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * sign message with users private key |
|
| 577 | - * |
|
| 578 | - * @param IUser $user |
|
| 579 | - * @param string $message |
|
| 580 | - * |
|
| 581 | - * @return string base64 encoded signature |
|
| 582 | - */ |
|
| 583 | - protected function signMessage(IUser $user, string $message): string { |
|
| 584 | - $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
| 585 | - openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
| 586 | - return base64_encode($signature); |
|
| 587 | - } |
|
| 74 | + /** @var UserManager */ |
|
| 75 | + private $userManager; |
|
| 76 | + /** @var GroupManager */ |
|
| 77 | + private $groupManager; |
|
| 78 | + /** @var IUserSession */ |
|
| 79 | + private $userSession; |
|
| 80 | + /** @var IConfig */ |
|
| 81 | + private $config; |
|
| 82 | + /** @var bool */ |
|
| 83 | + private $isAdmin; |
|
| 84 | + /** @var IL10N */ |
|
| 85 | + private $l10n; |
|
| 86 | + /** @var IMailer */ |
|
| 87 | + private $mailer; |
|
| 88 | + /** @var Factory */ |
|
| 89 | + private $l10nFactory; |
|
| 90 | + /** @var IAppManager */ |
|
| 91 | + private $appManager; |
|
| 92 | + /** @var AccountManager */ |
|
| 93 | + private $accountManager; |
|
| 94 | + /** @var Manager */ |
|
| 95 | + private $keyManager; |
|
| 96 | + /** @var IJobList */ |
|
| 97 | + private $jobList; |
|
| 98 | + /** @var IManager */ |
|
| 99 | + private $encryptionManager; |
|
| 100 | + /** @var KnownUserService */ |
|
| 101 | + private $knownUserService; |
|
| 102 | + /** @var IEventDispatcher */ |
|
| 103 | + private $dispatcher; |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + public function __construct( |
|
| 107 | + string $appName, |
|
| 108 | + IRequest $request, |
|
| 109 | + IUserManager $userManager, |
|
| 110 | + IGroupManager $groupManager, |
|
| 111 | + IUserSession $userSession, |
|
| 112 | + IConfig $config, |
|
| 113 | + bool $isAdmin, |
|
| 114 | + IL10N $l10n, |
|
| 115 | + IMailer $mailer, |
|
| 116 | + IFactory $l10nFactory, |
|
| 117 | + IAppManager $appManager, |
|
| 118 | + AccountManager $accountManager, |
|
| 119 | + Manager $keyManager, |
|
| 120 | + IJobList $jobList, |
|
| 121 | + IManager $encryptionManager, |
|
| 122 | + KnownUserService $knownUserService, |
|
| 123 | + IEventDispatcher $dispatcher |
|
| 124 | + ) { |
|
| 125 | + parent::__construct($appName, $request); |
|
| 126 | + $this->userManager = $userManager; |
|
| 127 | + $this->groupManager = $groupManager; |
|
| 128 | + $this->userSession = $userSession; |
|
| 129 | + $this->config = $config; |
|
| 130 | + $this->isAdmin = $isAdmin; |
|
| 131 | + $this->l10n = $l10n; |
|
| 132 | + $this->mailer = $mailer; |
|
| 133 | + $this->l10nFactory = $l10nFactory; |
|
| 134 | + $this->appManager = $appManager; |
|
| 135 | + $this->accountManager = $accountManager; |
|
| 136 | + $this->keyManager = $keyManager; |
|
| 137 | + $this->jobList = $jobList; |
|
| 138 | + $this->encryptionManager = $encryptionManager; |
|
| 139 | + $this->knownUserService = $knownUserService; |
|
| 140 | + $this->dispatcher = $dispatcher; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @NoCSRFRequired |
|
| 146 | + * @NoAdminRequired |
|
| 147 | + * |
|
| 148 | + * Display users list template |
|
| 149 | + * |
|
| 150 | + * @return TemplateResponse |
|
| 151 | + */ |
|
| 152 | + public function usersListByGroup(): TemplateResponse { |
|
| 153 | + return $this->usersList(); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @NoCSRFRequired |
|
| 158 | + * @NoAdminRequired |
|
| 159 | + * |
|
| 160 | + * Display users list template |
|
| 161 | + * |
|
| 162 | + * @return TemplateResponse |
|
| 163 | + */ |
|
| 164 | + public function usersList(): TemplateResponse { |
|
| 165 | + $user = $this->userSession->getUser(); |
|
| 166 | + $uid = $user->getUID(); |
|
| 167 | + |
|
| 168 | + \OC::$server->getNavigationManager()->setActiveEntry('core_users'); |
|
| 169 | + |
|
| 170 | + /* SORT OPTION: SORT_USERCOUNT or SORT_GROUPNAME */ |
|
| 171 | + $sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT; |
|
| 172 | + $isLDAPUsed = false; |
|
| 173 | + if ($this->config->getSystemValue('sort_groups_by_name', false)) { |
|
| 174 | + $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME; |
|
| 175 | + } else { |
|
| 176 | + if ($this->appManager->isEnabledForUser('user_ldap')) { |
|
| 177 | + $isLDAPUsed = |
|
| 178 | + $this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy'); |
|
| 179 | + if ($isLDAPUsed) { |
|
| 180 | + // LDAP user count can be slow, so we sort by group name here |
|
| 181 | + $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $canChangePassword = $this->canAdminChangeUserPasswords(); |
|
| 187 | + |
|
| 188 | + /* GROUPS */ |
|
| 189 | + $groupsInfo = new \OC\Group\MetaData( |
|
| 190 | + $uid, |
|
| 191 | + $this->isAdmin, |
|
| 192 | + $this->groupManager, |
|
| 193 | + $this->userSession |
|
| 194 | + ); |
|
| 195 | + |
|
| 196 | + $groupsInfo->setSorting($sortGroupsBy); |
|
| 197 | + [$adminGroup, $groups] = $groupsInfo->get(); |
|
| 198 | + |
|
| 199 | + if (!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { |
|
| 200 | + $isLDAPUsed = (bool)array_reduce($this->userManager->getBackends(), function ($ldapFound, $backend) { |
|
| 201 | + return $ldapFound || $backend instanceof User_Proxy; |
|
| 202 | + }); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $disabledUsers = -1; |
|
| 206 | + $userCount = 0; |
|
| 207 | + |
|
| 208 | + if (!$isLDAPUsed) { |
|
| 209 | + if ($this->isAdmin) { |
|
| 210 | + $disabledUsers = $this->userManager->countDisabledUsers(); |
|
| 211 | + $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { |
|
| 212 | + return $v + (int)$w; |
|
| 213 | + }, 0); |
|
| 214 | + } else { |
|
| 215 | + // User is subadmin ! |
|
| 216 | + // Map group list to names to retrieve the countDisabledUsersOfGroups |
|
| 217 | + $userGroups = $this->groupManager->getUserGroups($user); |
|
| 218 | + $groupsNames = []; |
|
| 219 | + |
|
| 220 | + foreach ($groups as $key => $group) { |
|
| 221 | + // $userCount += (int)$group['usercount']; |
|
| 222 | + array_push($groupsNames, $group['name']); |
|
| 223 | + // we prevent subadmins from looking up themselves |
|
| 224 | + // so we lower the count of the groups he belongs to |
|
| 225 | + if (array_key_exists($group['id'], $userGroups)) { |
|
| 226 | + $groups[$key]['usercount']--; |
|
| 227 | + $userCount -= 1; // we also lower from one the total count |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + $userCount += $this->userManager->countUsersOfGroups($groupsInfo->getGroups()); |
|
| 231 | + $disabledUsers = $this->userManager->countDisabledUsersOfGroups($groupsNames); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + $userCount -= $disabledUsers; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + $disabledUsersGroup = [ |
|
| 238 | + 'id' => 'disabled', |
|
| 239 | + 'name' => 'Disabled users', |
|
| 240 | + 'usercount' => $disabledUsers |
|
| 241 | + ]; |
|
| 242 | + |
|
| 243 | + /* QUOTAS PRESETS */ |
|
| 244 | + $quotaPreset = $this->parseQuotaPreset($this->config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB')); |
|
| 245 | + $defaultQuota = $this->config->getAppValue('files', 'default_quota', 'none'); |
|
| 246 | + |
|
| 247 | + $event = new BeforeTemplateRenderedEvent(); |
|
| 248 | + $this->dispatcher->dispatch('OC\Settings\Users::loadAdditionalScripts', $event); |
|
| 249 | + $this->dispatcher->dispatchTyped($event); |
|
| 250 | + |
|
| 251 | + /* LANGUAGES */ |
|
| 252 | + $languages = $this->l10nFactory->getLanguages(); |
|
| 253 | + |
|
| 254 | + /* FINAL DATA */ |
|
| 255 | + $serverData = []; |
|
| 256 | + // groups |
|
| 257 | + $serverData['groups'] = array_merge_recursive($adminGroup, [$disabledUsersGroup], $groups); |
|
| 258 | + // Various data |
|
| 259 | + $serverData['isAdmin'] = $this->isAdmin; |
|
| 260 | + $serverData['sortGroups'] = $sortGroupsBy; |
|
| 261 | + $serverData['quotaPreset'] = $quotaPreset; |
|
| 262 | + $serverData['userCount'] = $userCount; |
|
| 263 | + $serverData['languages'] = $languages; |
|
| 264 | + $serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en'); |
|
| 265 | + $serverData['forceLanguage'] = $this->config->getSystemValue('force_language', false); |
|
| 266 | + // Settings |
|
| 267 | + $serverData['defaultQuota'] = $defaultQuota; |
|
| 268 | + $serverData['canChangePassword'] = $canChangePassword; |
|
| 269 | + $serverData['newUserGenerateUserID'] = $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes'; |
|
| 270 | + $serverData['newUserRequireEmail'] = $this->config->getAppValue('core', 'newUser.requireEmail', 'no') === 'yes'; |
|
| 271 | + $serverData['newUserSendEmail'] = $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes'; |
|
| 272 | + |
|
| 273 | + return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData]); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @param string $key |
|
| 278 | + * @param string $value |
|
| 279 | + * |
|
| 280 | + * @return JSONResponse |
|
| 281 | + */ |
|
| 282 | + public function setPreference(string $key, string $value): JSONResponse { |
|
| 283 | + $allowed = ['newUser.sendEmail']; |
|
| 284 | + if (!in_array($key, $allowed, true)) { |
|
| 285 | + return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + $this->config->setAppValue('core', $key, $value); |
|
| 289 | + |
|
| 290 | + return new JSONResponse([]); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Parse the app value for quota_present |
|
| 295 | + * |
|
| 296 | + * @param string $quotaPreset |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + protected function parseQuotaPreset(string $quotaPreset): array { |
|
| 300 | + // 1 GB, 5 GB, 10 GB => [1 GB, 5 GB, 10 GB] |
|
| 301 | + $presets = array_filter(array_map('trim', explode(',', $quotaPreset))); |
|
| 302 | + // Drop default and none, Make array indexes numerically |
|
| 303 | + return array_values(array_diff($presets, ['default', 'none'])); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * check if the admin can change the users password |
|
| 308 | + * |
|
| 309 | + * The admin can change the passwords if: |
|
| 310 | + * |
|
| 311 | + * - no encryption module is loaded and encryption is disabled |
|
| 312 | + * - encryption module is loaded but it doesn't require per user keys |
|
| 313 | + * |
|
| 314 | + * The admin can not change the passwords if: |
|
| 315 | + * |
|
| 316 | + * - an encryption module is loaded and it uses per-user keys |
|
| 317 | + * - encryption is enabled but no encryption modules are loaded |
|
| 318 | + * |
|
| 319 | + * @return bool |
|
| 320 | + */ |
|
| 321 | + protected function canAdminChangeUserPasswords(): bool { |
|
| 322 | + $isEncryptionEnabled = $this->encryptionManager->isEnabled(); |
|
| 323 | + try { |
|
| 324 | + $noUserSpecificEncryptionKeys = !$this->encryptionManager->getEncryptionModule()->needDetailedAccessList(); |
|
| 325 | + $isEncryptionModuleLoaded = true; |
|
| 326 | + } catch (ModuleDoesNotExistsException $e) { |
|
| 327 | + $noUserSpecificEncryptionKeys = true; |
|
| 328 | + $isEncryptionModuleLoaded = false; |
|
| 329 | + } |
|
| 330 | + $canChangePassword = ($isEncryptionModuleLoaded && $noUserSpecificEncryptionKeys) |
|
| 331 | + || (!$isEncryptionModuleLoaded && !$isEncryptionEnabled); |
|
| 332 | + |
|
| 333 | + return $canChangePassword; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @NoAdminRequired |
|
| 338 | + * @NoSubAdminRequired |
|
| 339 | + * @PasswordConfirmationRequired |
|
| 340 | + * |
|
| 341 | + * @param string|null $avatarScope |
|
| 342 | + * @param string|null $displayname |
|
| 343 | + * @param string|null $displaynameScope |
|
| 344 | + * @param string|null $phone |
|
| 345 | + * @param string|null $phoneScope |
|
| 346 | + * @param string|null $email |
|
| 347 | + * @param string|null $emailScope |
|
| 348 | + * @param string|null $website |
|
| 349 | + * @param string|null $websiteScope |
|
| 350 | + * @param string|null $address |
|
| 351 | + * @param string|null $addressScope |
|
| 352 | + * @param string|null $twitter |
|
| 353 | + * @param string|null $twitterScope |
|
| 354 | + * |
|
| 355 | + * @return DataResponse |
|
| 356 | + */ |
|
| 357 | + public function setUserSettings(?string $avatarScope = null, |
|
| 358 | + ?string $displayname = null, |
|
| 359 | + ?string $displaynameScope = null, |
|
| 360 | + ?string $phone = null, |
|
| 361 | + ?string $phoneScope = null, |
|
| 362 | + ?string $email = null, |
|
| 363 | + ?string $emailScope = null, |
|
| 364 | + ?string $website = null, |
|
| 365 | + ?string $websiteScope = null, |
|
| 366 | + ?string $address = null, |
|
| 367 | + ?string $addressScope = null, |
|
| 368 | + ?string $twitter = null, |
|
| 369 | + ?string $twitterScope = null |
|
| 370 | + ) { |
|
| 371 | + $user = $this->userSession->getUser(); |
|
| 372 | + if (!$user instanceof IUser) { |
|
| 373 | + return new DataResponse( |
|
| 374 | + [ |
|
| 375 | + 'status' => 'error', |
|
| 376 | + 'data' => [ |
|
| 377 | + 'message' => $this->l10n->t('Invalid user') |
|
| 378 | + ] |
|
| 379 | + ], |
|
| 380 | + Http::STATUS_UNAUTHORIZED |
|
| 381 | + ); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + $email = strtolower($email); |
|
| 385 | + if (!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
| 386 | + return new DataResponse( |
|
| 387 | + [ |
|
| 388 | + 'status' => 'error', |
|
| 389 | + 'data' => [ |
|
| 390 | + 'message' => $this->l10n->t('Invalid mail address') |
|
| 391 | + ] |
|
| 392 | + ], |
|
| 393 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 394 | + ); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + $data = $this->accountManager->getUser($user); |
|
| 398 | + $beforeData = $data; |
|
| 399 | + $data[IAccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope]; |
|
| 400 | + if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) { |
|
| 401 | + $data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope]; |
|
| 402 | + $data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope]; |
|
| 403 | + } |
|
| 404 | + if ($this->appManager->isEnabledForUser('federatedfilesharing')) { |
|
| 405 | + $shareProvider = \OC::$server->query(FederatedShareProvider::class); |
|
| 406 | + if ($shareProvider->isLookupServerUploadEnabled()) { |
|
| 407 | + $data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope]; |
|
| 408 | + $data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope]; |
|
| 409 | + $data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope]; |
|
| 410 | + $data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope]; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + try { |
|
| 414 | + $data = $this->saveUserSettings($user, $data); |
|
| 415 | + if ($beforeData[IAccountManager::PROPERTY_PHONE]['value'] !== $data[IAccountManager::PROPERTY_PHONE]['value']) { |
|
| 416 | + $this->knownUserService->deleteByContactUserId($user->getUID()); |
|
| 417 | + } |
|
| 418 | + return new DataResponse( |
|
| 419 | + [ |
|
| 420 | + 'status' => 'success', |
|
| 421 | + 'data' => [ |
|
| 422 | + 'userId' => $user->getUID(), |
|
| 423 | + 'avatarScope' => $data[IAccountManager::PROPERTY_AVATAR]['scope'], |
|
| 424 | + 'displayname' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 425 | + 'displaynameScope' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'], |
|
| 426 | + 'phone' => $data[IAccountManager::PROPERTY_PHONE]['value'], |
|
| 427 | + 'phoneScope' => $data[IAccountManager::PROPERTY_PHONE]['scope'], |
|
| 428 | + 'email' => $data[IAccountManager::PROPERTY_EMAIL]['value'], |
|
| 429 | + 'emailScope' => $data[IAccountManager::PROPERTY_EMAIL]['scope'], |
|
| 430 | + 'website' => $data[IAccountManager::PROPERTY_WEBSITE]['value'], |
|
| 431 | + 'websiteScope' => $data[IAccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 432 | + 'address' => $data[IAccountManager::PROPERTY_ADDRESS]['value'], |
|
| 433 | + 'addressScope' => $data[IAccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 434 | + 'twitter' => $data[IAccountManager::PROPERTY_TWITTER]['value'], |
|
| 435 | + 'twitterScope' => $data[IAccountManager::PROPERTY_TWITTER]['scope'], |
|
| 436 | + 'message' => $this->l10n->t('Settings saved') |
|
| 437 | + ] |
|
| 438 | + ], |
|
| 439 | + Http::STATUS_OK |
|
| 440 | + ); |
|
| 441 | + } catch (ForbiddenException $e) { |
|
| 442 | + return new DataResponse([ |
|
| 443 | + 'status' => 'error', |
|
| 444 | + 'data' => [ |
|
| 445 | + 'message' => $e->getMessage() |
|
| 446 | + ], |
|
| 447 | + ]); |
|
| 448 | + } catch (\InvalidArgumentException $e) { |
|
| 449 | + return new DataResponse([ |
|
| 450 | + 'status' => 'error', |
|
| 451 | + 'data' => [ |
|
| 452 | + 'message' => $e->getMessage() |
|
| 453 | + ], |
|
| 454 | + ]); |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + /** |
|
| 458 | + * update account manager with new user data |
|
| 459 | + * |
|
| 460 | + * @param IUser $user |
|
| 461 | + * @param array $data |
|
| 462 | + * @return array |
|
| 463 | + * @throws ForbiddenException |
|
| 464 | + * @throws \InvalidArgumentException |
|
| 465 | + */ |
|
| 466 | + protected function saveUserSettings(IUser $user, array $data): array { |
|
| 467 | + // keep the user back-end up-to-date with the latest display name and email |
|
| 468 | + // address |
|
| 469 | + $oldDisplayName = $user->getDisplayName(); |
|
| 470 | + $oldDisplayName = is_null($oldDisplayName) ? '' : $oldDisplayName; |
|
| 471 | + if (isset($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']) |
|
| 472 | + && $oldDisplayName !== $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] |
|
| 473 | + ) { |
|
| 474 | + $result = $user->setDisplayName($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']); |
|
| 475 | + if ($result === false) { |
|
| 476 | + throw new ForbiddenException($this->l10n->t('Unable to change full name')); |
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + $oldEmailAddress = $user->getEMailAddress(); |
|
| 481 | + $oldEmailAddress = is_null($oldEmailAddress) ? '' : strtolower($oldEmailAddress); |
|
| 482 | + if (isset($data[IAccountManager::PROPERTY_EMAIL]['value']) |
|
| 483 | + && $oldEmailAddress !== $data[IAccountManager::PROPERTY_EMAIL]['value'] |
|
| 484 | + ) { |
|
| 485 | + // this is the only permission a backend provides and is also used |
|
| 486 | + // for the permission of setting a email address |
|
| 487 | + if (!$user->canChangeDisplayName()) { |
|
| 488 | + throw new ForbiddenException($this->l10n->t('Unable to change email address')); |
|
| 489 | + } |
|
| 490 | + $user->setEMailAddress($data[IAccountManager::PROPERTY_EMAIL]['value']); |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + try { |
|
| 494 | + return $this->accountManager->updateUser($user, $data, true); |
|
| 495 | + } catch (\InvalidArgumentException $e) { |
|
| 496 | + if ($e->getMessage() === IAccountManager::PROPERTY_PHONE) { |
|
| 497 | + throw new \InvalidArgumentException($this->l10n->t('Unable to set invalid phone number')); |
|
| 498 | + } |
|
| 499 | + throw new \InvalidArgumentException($this->l10n->t('Some account data was invalid')); |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Set the mail address of a user |
|
| 505 | + * |
|
| 506 | + * @NoAdminRequired |
|
| 507 | + * @NoSubAdminRequired |
|
| 508 | + * @PasswordConfirmationRequired |
|
| 509 | + * |
|
| 510 | + * @param string $account |
|
| 511 | + * @param bool $onlyVerificationCode only return verification code without updating the data |
|
| 512 | + * @return DataResponse |
|
| 513 | + */ |
|
| 514 | + public function getVerificationCode(string $account, bool $onlyVerificationCode): DataResponse { |
|
| 515 | + $user = $this->userSession->getUser(); |
|
| 516 | + |
|
| 517 | + if ($user === null) { |
|
| 518 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + $accountData = $this->accountManager->getUser($user); |
|
| 522 | + $cloudId = $user->getCloudId(); |
|
| 523 | + $message = 'Use my Federated Cloud ID to share with me: ' . $cloudId; |
|
| 524 | + $signature = $this->signMessage($user, $message); |
|
| 525 | + |
|
| 526 | + $code = $message . ' ' . $signature; |
|
| 527 | + $codeMd5 = $message . ' ' . md5($signature); |
|
| 528 | + |
|
| 529 | + switch ($account) { |
|
| 530 | + case 'verify-twitter': |
|
| 531 | + $accountData[IAccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
| 532 | + $msg = $this->l10n->t('In order to verify your Twitter account, post the following tweet on Twitter (please make sure to post it without any line breaks):'); |
|
| 533 | + $code = $codeMd5; |
|
| 534 | + $type = IAccountManager::PROPERTY_TWITTER; |
|
| 535 | + $accountData[IAccountManager::PROPERTY_TWITTER]['signature'] = $signature; |
|
| 536 | + break; |
|
| 537 | + case 'verify-website': |
|
| 538 | + $accountData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
| 539 | + $msg = $this->l10n->t('In order to verify your Website, store the following content in your web-root at \'.well-known/CloudIdVerificationCode.txt\' (please make sure that the complete text is in one line):'); |
|
| 540 | + $type = IAccountManager::PROPERTY_WEBSITE; |
|
| 541 | + $accountData[IAccountManager::PROPERTY_WEBSITE]['signature'] = $signature; |
|
| 542 | + break; |
|
| 543 | + default: |
|
| 544 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + if ($onlyVerificationCode === false) { |
|
| 548 | + $accountData = $this->accountManager->updateUser($user, $accountData); |
|
| 549 | + $data = $accountData[$type]['value']; |
|
| 550 | + |
|
| 551 | + $this->jobList->add(VerifyUserData::class, |
|
| 552 | + [ |
|
| 553 | + 'verificationCode' => $code, |
|
| 554 | + 'data' => $data, |
|
| 555 | + 'type' => $type, |
|
| 556 | + 'uid' => $user->getUID(), |
|
| 557 | + 'try' => 0, |
|
| 558 | + 'lastRun' => $this->getCurrentTime() |
|
| 559 | + ] |
|
| 560 | + ); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + return new DataResponse(['msg' => $msg, 'code' => $code]); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * get current timestamp |
|
| 568 | + * |
|
| 569 | + * @return int |
|
| 570 | + */ |
|
| 571 | + protected function getCurrentTime(): int { |
|
| 572 | + return time(); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * sign message with users private key |
|
| 577 | + * |
|
| 578 | + * @param IUser $user |
|
| 579 | + * @param string $message |
|
| 580 | + * |
|
| 581 | + * @return string base64 encoded signature |
|
| 582 | + */ |
|
| 583 | + protected function signMessage(IUser $user, string $message): string { |
|
| 584 | + $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
| 585 | + openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
| 586 | + return base64_encode($signature); |
|
| 587 | + } |
|
| 588 | 588 | } |
@@ -39,107 +39,107 @@ |
||
| 39 | 39 | use OCP\Util; |
| 40 | 40 | |
| 41 | 41 | class Sharing implements ISettings { |
| 42 | - /** @var IConfig */ |
|
| 43 | - private $config; |
|
| 42 | + /** @var IConfig */ |
|
| 43 | + private $config; |
|
| 44 | 44 | |
| 45 | - /** @var IL10N */ |
|
| 46 | - private $l; |
|
| 45 | + /** @var IL10N */ |
|
| 46 | + private $l; |
|
| 47 | 47 | |
| 48 | - /** @var IManager */ |
|
| 49 | - private $shareManager; |
|
| 48 | + /** @var IManager */ |
|
| 49 | + private $shareManager; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param IConfig $config |
|
| 53 | - */ |
|
| 54 | - public function __construct(IConfig $config, IL10N $l, IManager $shareManager) { |
|
| 55 | - $this->config = $config; |
|
| 56 | - $this->l = $l; |
|
| 57 | - $this->shareManager = $shareManager; |
|
| 58 | - } |
|
| 51 | + /** |
|
| 52 | + * @param IConfig $config |
|
| 53 | + */ |
|
| 54 | + public function __construct(IConfig $config, IL10N $l, IManager $shareManager) { |
|
| 55 | + $this->config = $config; |
|
| 56 | + $this->l = $l; |
|
| 57 | + $this->shareManager = $shareManager; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return TemplateResponse |
|
| 62 | - */ |
|
| 63 | - public function getForm() { |
|
| 64 | - $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
| 65 | - $excludeGroupsList = !is_null(json_decode($excludedGroups)) |
|
| 66 | - ? implode('|', json_decode($excludedGroups, true)) : ''; |
|
| 60 | + /** |
|
| 61 | + * @return TemplateResponse |
|
| 62 | + */ |
|
| 63 | + public function getForm() { |
|
| 64 | + $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
| 65 | + $excludeGroupsList = !is_null(json_decode($excludedGroups)) |
|
| 66 | + ? implode('|', json_decode($excludedGroups, true)) : ''; |
|
| 67 | 67 | |
| 68 | - $parameters = [ |
|
| 69 | - // Built-In Sharing |
|
| 70 | - 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'), |
|
| 71 | - 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'), |
|
| 72 | - 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), |
|
| 73 | - 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), |
|
| 74 | - 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), |
|
| 75 | - 'restrictUserEnumerationToGroup' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no'), |
|
| 76 | - 'restrictUserEnumerationToPhone' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no'), |
|
| 77 | - 'restrictUserEnumerationFullMatch' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes'), |
|
| 78 | - 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(), |
|
| 79 | - 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(), |
|
| 80 | - 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), |
|
| 81 | - 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), |
|
| 82 | - 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), |
|
| 83 | - 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), |
|
| 84 | - 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes', |
|
| 85 | - 'shareExcludedGroupsList' => $excludeGroupsList, |
|
| 86 | - 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null), |
|
| 87 | - 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), |
|
| 88 | - 'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL), |
|
| 89 | - 'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(), |
|
| 90 | - 'shareDefaultInternalExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no'), |
|
| 91 | - 'shareInternalExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'), |
|
| 92 | - 'shareInternalEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no'), |
|
| 93 | - ]; |
|
| 68 | + $parameters = [ |
|
| 69 | + // Built-In Sharing |
|
| 70 | + 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'), |
|
| 71 | + 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'), |
|
| 72 | + 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), |
|
| 73 | + 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), |
|
| 74 | + 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), |
|
| 75 | + 'restrictUserEnumerationToGroup' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no'), |
|
| 76 | + 'restrictUserEnumerationToPhone' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no'), |
|
| 77 | + 'restrictUserEnumerationFullMatch' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes'), |
|
| 78 | + 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(), |
|
| 79 | + 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(), |
|
| 80 | + 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), |
|
| 81 | + 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), |
|
| 82 | + 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), |
|
| 83 | + 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), |
|
| 84 | + 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes', |
|
| 85 | + 'shareExcludedGroupsList' => $excludeGroupsList, |
|
| 86 | + 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null), |
|
| 87 | + 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), |
|
| 88 | + 'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL), |
|
| 89 | + 'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(), |
|
| 90 | + 'shareDefaultInternalExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no'), |
|
| 91 | + 'shareInternalExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'), |
|
| 92 | + 'shareInternalEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no'), |
|
| 93 | + ]; |
|
| 94 | 94 | |
| 95 | - return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, ''); |
|
| 96 | - } |
|
| 95 | + return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, ''); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * get share permission list for template |
|
| 100 | - * |
|
| 101 | - * @return array |
|
| 102 | - */ |
|
| 103 | - private function getSharePermissionList() { |
|
| 104 | - return [ |
|
| 105 | - [ |
|
| 106 | - 'id' => 'cancreate', |
|
| 107 | - 'label' => $this->l->t('Create'), |
|
| 108 | - 'value' => Constants::PERMISSION_CREATE |
|
| 109 | - ], |
|
| 110 | - [ |
|
| 111 | - 'id' => 'canupdate', |
|
| 112 | - 'label' => $this->l->t('Change'), |
|
| 113 | - 'value' => Constants::PERMISSION_UPDATE |
|
| 114 | - ], |
|
| 115 | - [ |
|
| 116 | - 'id' => 'candelete', |
|
| 117 | - 'label' => $this->l->t('Delete'), |
|
| 118 | - 'value' => Constants::PERMISSION_DELETE |
|
| 119 | - ], |
|
| 120 | - [ |
|
| 121 | - 'id' => 'canshare', |
|
| 122 | - 'label' => $this->l->t('Reshare'), |
|
| 123 | - 'value' => Constants::PERMISSION_SHARE |
|
| 124 | - ], |
|
| 125 | - ]; |
|
| 126 | - } |
|
| 98 | + /** |
|
| 99 | + * get share permission list for template |
|
| 100 | + * |
|
| 101 | + * @return array |
|
| 102 | + */ |
|
| 103 | + private function getSharePermissionList() { |
|
| 104 | + return [ |
|
| 105 | + [ |
|
| 106 | + 'id' => 'cancreate', |
|
| 107 | + 'label' => $this->l->t('Create'), |
|
| 108 | + 'value' => Constants::PERMISSION_CREATE |
|
| 109 | + ], |
|
| 110 | + [ |
|
| 111 | + 'id' => 'canupdate', |
|
| 112 | + 'label' => $this->l->t('Change'), |
|
| 113 | + 'value' => Constants::PERMISSION_UPDATE |
|
| 114 | + ], |
|
| 115 | + [ |
|
| 116 | + 'id' => 'candelete', |
|
| 117 | + 'label' => $this->l->t('Delete'), |
|
| 118 | + 'value' => Constants::PERMISSION_DELETE |
|
| 119 | + ], |
|
| 120 | + [ |
|
| 121 | + 'id' => 'canshare', |
|
| 122 | + 'label' => $this->l->t('Reshare'), |
|
| 123 | + 'value' => Constants::PERMISSION_SHARE |
|
| 124 | + ], |
|
| 125 | + ]; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * @return string the section ID, e.g. 'sharing' |
|
| 130 | - */ |
|
| 131 | - public function getSection() { |
|
| 132 | - return 'sharing'; |
|
| 133 | - } |
|
| 128 | + /** |
|
| 129 | + * @return string the section ID, e.g. 'sharing' |
|
| 130 | + */ |
|
| 131 | + public function getSection() { |
|
| 132 | + return 'sharing'; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * @return int whether the form should be rather on the top or bottom of |
|
| 137 | - * the admin section. The forms are arranged in ascending order of the |
|
| 138 | - * priority values. It is required to return a value between 0 and 100. |
|
| 139 | - * |
|
| 140 | - * E.g.: 70 |
|
| 141 | - */ |
|
| 142 | - public function getPriority() { |
|
| 143 | - return 0; |
|
| 144 | - } |
|
| 135 | + /** |
|
| 136 | + * @return int whether the form should be rather on the top or bottom of |
|
| 137 | + * the admin section. The forms are arranged in ascending order of the |
|
| 138 | + * priority values. It is required to return a value between 0 and 100. |
|
| 139 | + * |
|
| 140 | + * E.g.: 70 |
|
| 141 | + */ |
|
| 142 | + public function getPriority() { |
|
| 143 | + return 0; |
|
| 144 | + } |
|
| 145 | 145 | } |
@@ -35,22 +35,22 @@ discard block |
||
| 35 | 35 | <p id="enable"> |
| 36 | 36 | <input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled" class="checkbox" |
| 37 | 37 | value="1" <?php if ($_['shareAPIEnabled'] === 'yes') { |
| 38 | - print_unescaped('checked="checked"'); |
|
| 38 | + print_unescaped('checked="checked"'); |
|
| 39 | 39 | } ?> /> |
| 40 | 40 | <label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/> |
| 41 | 41 | </p> |
| 42 | 42 | |
| 43 | 43 | <p id="internalShareSettings" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
| 44 | - p('hidden'); |
|
| 44 | + p('hidden'); |
|
| 45 | 45 | } ?>"> |
| 46 | 46 | <input type="checkbox" name="shareapi_default_internal_expire_date" id="shareapiDefaultInternalExpireDate" class="checkbox" |
| 47 | 47 | value="1" <?php if ($_['shareDefaultInternalExpireDateSet'] === 'yes') { |
| 48 | - print_unescaped('checked="checked"'); |
|
| 48 | + print_unescaped('checked="checked"'); |
|
| 49 | 49 | } ?> /> |
| 50 | 50 | <label for="shareapiDefaultInternalExpireDate"><?php p($l->t('Set default expiration date for shares'));?></label><br/> |
| 51 | 51 | </p> |
| 52 | 52 | <p id="setDefaultInternalExpireDate" class="double-indent <?php if ($_['shareDefaultInternalExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') { |
| 53 | - p('hidden'); |
|
| 53 | + p('hidden'); |
|
| 54 | 54 | }?>"> |
| 55 | 55 | <?php p($l->t('Expire after ')); ?> |
| 56 | 56 | <input type="text" name='shareapi_internal_expire_after_n_days' id="shareapiInternalExpireAfterNDays" placeholder="<?php p('7')?>" |
@@ -58,49 +58,49 @@ discard block |
||
| 58 | 58 | <?php p($l->t('days')); ?> |
| 59 | 59 | <input type="checkbox" name="shareapi_enforce_internal_expire_date" id="shareapiInternalEnforceExpireDate" class="checkbox" |
| 60 | 60 | value="1" <?php if ($_['shareInternalEnforceExpireDate'] === 'yes') { |
| 61 | - print_unescaped('checked="checked"'); |
|
| 61 | + print_unescaped('checked="checked"'); |
|
| 62 | 62 | } ?> /> |
| 63 | 63 | <label for="shareapiInternalEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/> |
| 64 | 64 | </p> |
| 65 | 65 | |
| 66 | 66 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 67 | - p('hidden'); |
|
| 67 | + p('hidden'); |
|
| 68 | 68 | }?>"> |
| 69 | 69 | <input type="checkbox" name="shareapi_allow_links" id="allowLinks" class="checkbox" |
| 70 | 70 | value="1" <?php if ($_['allowLinks'] === 'yes') { |
| 71 | - print_unescaped('checked="checked"'); |
|
| 71 | + print_unescaped('checked="checked"'); |
|
| 72 | 72 | } ?> /> |
| 73 | 73 | <label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/> |
| 74 | 74 | </p> |
| 75 | 75 | |
| 76 | 76 | <p id="publicLinkSettings" class="indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareAPIEnabled'] === 'no') { |
| 77 | - p('hidden'); |
|
| 77 | + p('hidden'); |
|
| 78 | 78 | } ?>"> |
| 79 | 79 | <input type="checkbox" name="shareapi_allow_public_upload" id="allowPublicUpload" class="checkbox" |
| 80 | 80 | value="1" <?php if ($_['allowPublicUpload'] == 'yes') { |
| 81 | - print_unescaped('checked="checked"'); |
|
| 81 | + print_unescaped('checked="checked"'); |
|
| 82 | 82 | } ?> /> |
| 83 | 83 | <label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/> |
| 84 | 84 | <input type="checkbox" name="shareapi_enable_link_password_by_default" id="enableLinkPasswordByDefault" class="checkbox" |
| 85 | 85 | value="1" <?php if ($_['enableLinkPasswordByDefault'] === 'yes') { |
| 86 | - print_unescaped('checked="checked"'); |
|
| 86 | + print_unescaped('checked="checked"'); |
|
| 87 | 87 | } ?> /> |
| 88 | 88 | <label for="enableLinkPasswordByDefault"><?php p($l->t('Always ask for a password'));?></label><br/> |
| 89 | 89 | <input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox" |
| 90 | 90 | value="1" <?php if ($_['enforceLinkPassword']) { |
| 91 | - print_unescaped('checked="checked"'); |
|
| 91 | + print_unescaped('checked="checked"'); |
|
| 92 | 92 | } ?> /> |
| 93 | 93 | <label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/> |
| 94 | 94 | |
| 95 | 95 | <input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate" class="checkbox" |
| 96 | 96 | value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') { |
| 97 | - print_unescaped('checked="checked"'); |
|
| 97 | + print_unescaped('checked="checked"'); |
|
| 98 | 98 | } ?> /> |
| 99 | 99 | <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date for link shares'));?></label><br/> |
| 100 | 100 | |
| 101 | 101 | </p> |
| 102 | 102 | <p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') { |
| 103 | - p('hidden'); |
|
| 103 | + p('hidden'); |
|
| 104 | 104 | }?>"> |
| 105 | 105 | <?php p($l->t('Expire after ')); ?> |
| 106 | 106 | <input type="text" name='shareapi_expire_after_n_days' id="shareapiExpireAfterNDays" placeholder="<?php p('7')?>" |
@@ -108,48 +108,48 @@ discard block |
||
| 108 | 108 | <?php p($l->t('days')); ?> |
| 109 | 109 | <input type="checkbox" name="shareapi_enforce_expire_date" id="shareapiEnforceExpireDate" class="checkbox" |
| 110 | 110 | value="1" <?php if ($_['shareEnforceExpireDate'] === 'yes') { |
| 111 | - print_unescaped('checked="checked"'); |
|
| 111 | + print_unescaped('checked="checked"'); |
|
| 112 | 112 | } ?> /> |
| 113 | 113 | <label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/> |
| 114 | 114 | </p> |
| 115 | 115 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 116 | - p('hidden'); |
|
| 116 | + p('hidden'); |
|
| 117 | 117 | }?>"> |
| 118 | 118 | <input type="checkbox" name="shareapi_allow_resharing" id="allowResharing" class="checkbox" |
| 119 | 119 | value="1" <?php if ($_['allowResharing'] === 'yes') { |
| 120 | - print_unescaped('checked="checked"'); |
|
| 120 | + print_unescaped('checked="checked"'); |
|
| 121 | 121 | } ?> /> |
| 122 | 122 | <label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/> |
| 123 | 123 | </p> |
| 124 | 124 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 125 | - p('hidden'); |
|
| 125 | + p('hidden'); |
|
| 126 | 126 | }?>"> |
| 127 | 127 | <input type="checkbox" name="shareapi_allow_group_sharing" id="allowGroupSharing" class="checkbox" |
| 128 | 128 | value="1" <?php if ($_['allowGroupSharing'] === 'yes') { |
| 129 | - print_unescaped('checked="checked"'); |
|
| 129 | + print_unescaped('checked="checked"'); |
|
| 130 | 130 | } ?> /> |
| 131 | 131 | <label for="allowGroupSharing"><?php p($l->t('Allow sharing with groups'));?></label><br /> |
| 132 | 132 | </p> |
| 133 | 133 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 134 | - p('hidden'); |
|
| 134 | + p('hidden'); |
|
| 135 | 135 | }?>"> |
| 136 | 136 | <input type="checkbox" name="shareapi_only_share_with_group_members" id="onlyShareWithGroupMembers" class="checkbox" |
| 137 | 137 | value="1" <?php if ($_['onlyShareWithGroupMembers']) { |
| 138 | - print_unescaped('checked="checked"'); |
|
| 138 | + print_unescaped('checked="checked"'); |
|
| 139 | 139 | } ?> /> |
| 140 | 140 | <label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/> |
| 141 | 141 | </p> |
| 142 | 142 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 143 | - p('hidden'); |
|
| 143 | + p('hidden'); |
|
| 144 | 144 | }?>"> |
| 145 | 145 | <input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups" class="checkbox" |
| 146 | 146 | value="1" <?php if ($_['shareExcludeGroups']) { |
| 147 | - print_unescaped('checked="checked"'); |
|
| 147 | + print_unescaped('checked="checked"'); |
|
| 148 | 148 | } ?> /> |
| 149 | 149 | <label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/> |
| 150 | 150 | </p> |
| 151 | 151 | <p id="selectExcludedGroups" class="indent <?php if (!$_['shareExcludeGroups'] || $_['shareAPIEnabled'] === 'no') { |
| 152 | - p('hidden'); |
|
| 152 | + p('hidden'); |
|
| 153 | 153 | } ?>"> |
| 154 | 154 | <input name="shareapi_exclude_groups_list" type="hidden" id="excludedGroups" value="<?php p($_['shareExcludedGroupsList']) ?>" style="width: 400px" class="noJSAutoUpdate"/> |
| 155 | 155 | <br /> |
@@ -157,45 +157,45 @@ discard block |
||
| 157 | 157 | </p> |
| 158 | 158 | |
| 159 | 159 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 160 | - p('hidden'); |
|
| 160 | + p('hidden'); |
|
| 161 | 161 | }?>"> |
| 162 | 162 | <input type="checkbox" name="shareapi_allow_share_dialog_user_enumeration" value="1" id="shareapi_allow_share_dialog_user_enumeration" class="checkbox" |
| 163 | 163 | <?php if ($_['allowShareDialogUserEnumeration'] === 'yes') { |
| 164 | - print_unescaped('checked="checked"'); |
|
| 164 | + print_unescaped('checked="checked"'); |
|
| 165 | 165 | } ?> /> |
| 166 | 166 | <label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog'));?></label><br /> |
| 167 | 167 | </p> |
| 168 | 168 | |
| 169 | 169 | <p id="shareapi_restrict_user_enumeration_to_group_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
| 170 | - p('hidden'); |
|
| 170 | + p('hidden'); |
|
| 171 | 171 | }?>"> |
| 172 | 172 | <input type="checkbox" name="shareapi_restrict_user_enumeration_to_group" value="1" id="shareapi_restrict_user_enumeration_to_group" class="checkbox" |
| 173 | 173 | <?php if ($_['restrictUserEnumerationToGroup'] === 'yes') { |
| 174 | - print_unescaped('checked="checked"'); |
|
| 174 | + print_unescaped('checked="checked"'); |
|
| 175 | 175 | } ?> /> |
| 176 | 176 | <label for="shareapi_restrict_user_enumeration_to_group"><?php p($l->t('Allow username autocompletion to users within the same groups'));?></label><br /> |
| 177 | 177 | </p> |
| 178 | 178 | |
| 179 | 179 | <p id="shareapi_restrict_user_enumeration_to_phone_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
| 180 | - p('hidden'); |
|
| 180 | + p('hidden'); |
|
| 181 | 181 | }?>"> |
| 182 | 182 | <input type="checkbox" name="shareapi_restrict_user_enumeration_to_phone" value="1" id="shareapi_restrict_user_enumeration_to_phone" class="checkbox" |
| 183 | 183 | <?php if ($_['restrictUserEnumerationToPhone'] === 'yes') { |
| 184 | - print_unescaped('checked="checked"'); |
|
| 184 | + print_unescaped('checked="checked"'); |
|
| 185 | 185 | } ?> /> |
| 186 | 186 | <label for="shareapi_restrict_user_enumeration_to_phone"><?php p($l->t('Allow username autocompletion to users based on phonebook matches'));?></label><br /> |
| 187 | 187 | </p> |
| 188 | 188 | <p id="shareapi_restrict_user_enumeration_combinewarning_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
| 189 | - p('hidden'); |
|
| 189 | + p('hidden'); |
|
| 190 | 190 | }?>"> |
| 191 | 191 | <em><?php p($l->t('If autocompletion "same group" and "phonebook matches" are enabled a match in either is enough to show the user.'));?></em><br /> |
| 192 | 192 | </p> |
| 193 | 193 | <p id="shareapi_restrict_user_enumeration_full_match_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
| 194 | - p('hidden'); |
|
| 194 | + p('hidden'); |
|
| 195 | 195 | }?>"> |
| 196 | 196 | <input type="checkbox" name="shareapi_restrict_user_enumeration_full_match" value="1" id="shareapi_restrict_user_enumeration_full_match" class="checkbox" |
| 197 | 197 | <?php if ($_['restrictUserEnumerationFullMatch'] === 'yes') { |
| 198 | - print_unescaped('checked="checked"'); |
|
| 198 | + print_unescaped('checked="checked"'); |
|
| 199 | 199 | } ?> /> |
| 200 | 200 | <label for="shareapi_restrict_user_enumeration_full_match"><?php p($l->t('Allow username autocompletion when entering the full name or email address (ignoring missing phonebook match and being in the same group)'));?></label><br /> |
| 201 | 201 | </p> |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | <p> |
| 204 | 204 | <input type="checkbox" id="publicShareDisclaimer" class="checkbox noJSAutoUpdate" |
| 205 | 205 | <?php if ($_['publicShareDisclaimerText'] !== null) { |
| 206 | - print_unescaped('checked="checked"'); |
|
| 206 | + print_unescaped('checked="checked"'); |
|
| 207 | 207 | } ?> /> |
| 208 | 208 | <label for="publicShareDisclaimer"><?php p($l->t('Show disclaimer text on the public link upload page (only shown when the file list is hidden)'));?></label> |
| 209 | 209 | <span id="publicShareDisclaimerStatus" class="msg" style="display:none"></span> |
| 210 | 210 | <br/> |
| 211 | 211 | <textarea placeholder="<?php p($l->t('This text will be shown on the public link upload page when the file list is hidden.')) ?>" id="publicShareDisclaimerText" <?php if ($_['publicShareDisclaimerText'] === null) { |
| 212 | - print_unescaped('class="hidden"'); |
|
| 212 | + print_unescaped('class="hidden"'); |
|
| 213 | 213 | } ?>><?php p($_['publicShareDisclaimerText']) ?></textarea> |
| 214 | 214 | </p> |
| 215 | 215 | |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | <input type="hidden" name="shareapi_default_permissions" id="shareApiDefaultPermissions" class="checkbox" |
| 218 | 218 | value="<?php p($_['shareApiDefaultPermissions']) ?>" /> |
| 219 | 219 | <p id="shareApiDefaultPermissionsSection" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
| 220 | - p('hidden'); |
|
| 220 | + p('hidden'); |
|
| 221 | 221 | } ?>"> |
| 222 | 222 | <?php foreach ($_['shareApiDefaultPermissionsCheckboxes'] as $perm): ?> |
| 223 | 223 | <input type="checkbox" name="shareapi_default_permission_<?php p($perm['id']) ?>" id="shareapi_default_permission_<?php p($perm['id']) ?>" |
| 224 | 224 | class="noautosave checkbox" value="<?php p($perm['value']) ?>" <?php if (($_['shareApiDefaultPermissions'] & $perm['value']) !== 0) { |
| 225 | - print_unescaped('checked="checked"'); |
|
| 225 | + print_unescaped('checked="checked"'); |
|
| 226 | 226 | } ?> /> |
| 227 | 227 | <label for="shareapi_default_permission_<?php p($perm['id']) ?>"><?php p($perm['label']);?></label> |
| 228 | 228 | <?php endforeach ?> |
@@ -27,17 +27,17 @@ discard block |
||
| 27 | 27 | ?> |
| 28 | 28 | |
| 29 | 29 | <div class="section" id="shareAPI"> |
| 30 | - <h2><?php p($l->t('Sharing'));?></h2> |
|
| 30 | + <h2><?php p($l->t('Sharing')); ?></h2> |
|
| 31 | 31 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
| 32 | - title="<?php p($l->t('Open documentation'));?>" |
|
| 32 | + title="<?php p($l->t('Open documentation')); ?>" |
|
| 33 | 33 | href="<?php p(link_to_docs('admin-sharing')); ?>"></a> |
| 34 | - <p class="settings-hint"><?php p($l->t('As admin you can fine-tune the sharing behavior. Please see the documentation for more information.'));?></p> |
|
| 34 | + <p class="settings-hint"><?php p($l->t('As admin you can fine-tune the sharing behavior. Please see the documentation for more information.')); ?></p> |
|
| 35 | 35 | <p id="enable"> |
| 36 | 36 | <input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled" class="checkbox" |
| 37 | 37 | value="1" <?php if ($_['shareAPIEnabled'] === 'yes') { |
| 38 | 38 | print_unescaped('checked="checked"'); |
| 39 | 39 | } ?> /> |
| 40 | - <label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/> |
|
| 40 | + <label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API')); ?></label><br/> |
|
| 41 | 41 | </p> |
| 42 | 42 | |
| 43 | 43 | <p id="internalShareSettings" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | value="1" <?php if ($_['shareDefaultInternalExpireDateSet'] === 'yes') { |
| 48 | 48 | print_unescaped('checked="checked"'); |
| 49 | 49 | } ?> /> |
| 50 | - <label for="shareapiDefaultInternalExpireDate"><?php p($l->t('Set default expiration date for shares'));?></label><br/> |
|
| 50 | + <label for="shareapiDefaultInternalExpireDate"><?php p($l->t('Set default expiration date for shares')); ?></label><br/> |
|
| 51 | 51 | </p> |
| 52 | 52 | <p id="setDefaultInternalExpireDate" class="double-indent <?php if ($_['shareDefaultInternalExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') { |
| 53 | 53 | p('hidden'); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | value="1" <?php if ($_['shareInternalEnforceExpireDate'] === 'yes') { |
| 61 | 61 | print_unescaped('checked="checked"'); |
| 62 | 62 | } ?> /> |
| 63 | - <label for="shareapiInternalEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/> |
|
| 63 | + <label for="shareapiInternalEnforceExpireDate"><?php p($l->t('Enforce expiration date')); ?></label><br/> |
|
| 64 | 64 | </p> |
| 65 | 65 | |
| 66 | 66 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | value="1" <?php if ($_['allowLinks'] === 'yes') { |
| 71 | 71 | print_unescaped('checked="checked"'); |
| 72 | 72 | } ?> /> |
| 73 | - <label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/> |
|
| 73 | + <label for="allowLinks"><?php p($l->t('Allow users to share via link')); ?></label><br/> |
|
| 74 | 74 | </p> |
| 75 | 75 | |
| 76 | 76 | <p id="publicLinkSettings" class="indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareAPIEnabled'] === 'no') { |
@@ -80,23 +80,23 @@ discard block |
||
| 80 | 80 | value="1" <?php if ($_['allowPublicUpload'] == 'yes') { |
| 81 | 81 | print_unescaped('checked="checked"'); |
| 82 | 82 | } ?> /> |
| 83 | - <label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/> |
|
| 83 | + <label for="allowPublicUpload"><?php p($l->t('Allow public uploads')); ?></label><br/> |
|
| 84 | 84 | <input type="checkbox" name="shareapi_enable_link_password_by_default" id="enableLinkPasswordByDefault" class="checkbox" |
| 85 | 85 | value="1" <?php if ($_['enableLinkPasswordByDefault'] === 'yes') { |
| 86 | 86 | print_unescaped('checked="checked"'); |
| 87 | 87 | } ?> /> |
| 88 | - <label for="enableLinkPasswordByDefault"><?php p($l->t('Always ask for a password'));?></label><br/> |
|
| 88 | + <label for="enableLinkPasswordByDefault"><?php p($l->t('Always ask for a password')); ?></label><br/> |
|
| 89 | 89 | <input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox" |
| 90 | 90 | value="1" <?php if ($_['enforceLinkPassword']) { |
| 91 | 91 | print_unescaped('checked="checked"'); |
| 92 | 92 | } ?> /> |
| 93 | - <label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/> |
|
| 93 | + <label for="enforceLinkPassword"><?php p($l->t('Enforce password protection')); ?></label><br/> |
|
| 94 | 94 | |
| 95 | 95 | <input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate" class="checkbox" |
| 96 | 96 | value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') { |
| 97 | 97 | print_unescaped('checked="checked"'); |
| 98 | 98 | } ?> /> |
| 99 | - <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date for link shares'));?></label><br/> |
|
| 99 | + <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date for link shares')); ?></label><br/> |
|
| 100 | 100 | |
| 101 | 101 | </p> |
| 102 | 102 | <p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | value="1" <?php if ($_['shareEnforceExpireDate'] === 'yes') { |
| 111 | 111 | print_unescaped('checked="checked"'); |
| 112 | 112 | } ?> /> |
| 113 | - <label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/> |
|
| 113 | + <label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date')); ?></label><br/> |
|
| 114 | 114 | </p> |
| 115 | 115 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 116 | 116 | p('hidden'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | value="1" <?php if ($_['allowResharing'] === 'yes') { |
| 120 | 120 | print_unescaped('checked="checked"'); |
| 121 | 121 | } ?> /> |
| 122 | - <label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/> |
|
| 122 | + <label for="allowResharing"><?php p($l->t('Allow resharing')); ?></label><br/> |
|
| 123 | 123 | </p> |
| 124 | 124 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 125 | 125 | p('hidden'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | value="1" <?php if ($_['allowGroupSharing'] === 'yes') { |
| 129 | 129 | print_unescaped('checked="checked"'); |
| 130 | 130 | } ?> /> |
| 131 | - <label for="allowGroupSharing"><?php p($l->t('Allow sharing with groups'));?></label><br /> |
|
| 131 | + <label for="allowGroupSharing"><?php p($l->t('Allow sharing with groups')); ?></label><br /> |
|
| 132 | 132 | </p> |
| 133 | 133 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 134 | 134 | p('hidden'); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | value="1" <?php if ($_['onlyShareWithGroupMembers']) { |
| 138 | 138 | print_unescaped('checked="checked"'); |
| 139 | 139 | } ?> /> |
| 140 | - <label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/> |
|
| 140 | + <label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups')); ?></label><br/> |
|
| 141 | 141 | </p> |
| 142 | 142 | <p class="<?php if ($_['shareAPIEnabled'] === 'no') { |
| 143 | 143 | p('hidden'); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | value="1" <?php if ($_['shareExcludeGroups']) { |
| 147 | 147 | print_unescaped('checked="checked"'); |
| 148 | 148 | } ?> /> |
| 149 | - <label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/> |
|
| 149 | + <label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing')); ?></label><br/> |
|
| 150 | 150 | </p> |
| 151 | 151 | <p id="selectExcludedGroups" class="indent <?php if (!$_['shareExcludeGroups'] || $_['shareAPIEnabled'] === 'no') { |
| 152 | 152 | p('hidden'); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | <?php if ($_['allowShareDialogUserEnumeration'] === 'yes') { |
| 164 | 164 | print_unescaped('checked="checked"'); |
| 165 | 165 | } ?> /> |
| 166 | - <label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog'));?></label><br /> |
|
| 166 | + <label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog')); ?></label><br /> |
|
| 167 | 167 | </p> |
| 168 | 168 | |
| 169 | 169 | <p id="shareapi_restrict_user_enumeration_to_group_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | <?php if ($_['restrictUserEnumerationToGroup'] === 'yes') { |
| 174 | 174 | print_unescaped('checked="checked"'); |
| 175 | 175 | } ?> /> |
| 176 | - <label for="shareapi_restrict_user_enumeration_to_group"><?php p($l->t('Allow username autocompletion to users within the same groups'));?></label><br /> |
|
| 176 | + <label for="shareapi_restrict_user_enumeration_to_group"><?php p($l->t('Allow username autocompletion to users within the same groups')); ?></label><br /> |
|
| 177 | 177 | </p> |
| 178 | 178 | |
| 179 | 179 | <p id="shareapi_restrict_user_enumeration_to_phone_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | <?php if ($_['restrictUserEnumerationToPhone'] === 'yes') { |
| 184 | 184 | print_unescaped('checked="checked"'); |
| 185 | 185 | } ?> /> |
| 186 | - <label for="shareapi_restrict_user_enumeration_to_phone"><?php p($l->t('Allow username autocompletion to users based on phonebook matches'));?></label><br /> |
|
| 186 | + <label for="shareapi_restrict_user_enumeration_to_phone"><?php p($l->t('Allow username autocompletion to users based on phonebook matches')); ?></label><br /> |
|
| 187 | 187 | </p> |
| 188 | 188 | <p id="shareapi_restrict_user_enumeration_combinewarning_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { |
| 189 | 189 | p('hidden'); |
| 190 | 190 | }?>"> |
| 191 | - <em><?php p($l->t('If autocompletion "same group" and "phonebook matches" are enabled a match in either is enough to show the user.'));?></em><br /> |
|
| 191 | + <em><?php p($l->t('If autocompletion "same group" and "phonebook matches" are enabled a match in either is enough to show the user.')); ?></em><br /> |
|
| 192 | 192 | </p> |
| 193 | 193 | <p id="shareapi_restrict_user_enumeration_full_match_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
| 194 | 194 | p('hidden'); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | <?php if ($_['restrictUserEnumerationFullMatch'] === 'yes') { |
| 198 | 198 | print_unescaped('checked="checked"'); |
| 199 | 199 | } ?> /> |
| 200 | - <label for="shareapi_restrict_user_enumeration_full_match"><?php p($l->t('Allow username autocompletion when entering the full name or email address (ignoring missing phonebook match and being in the same group)'));?></label><br /> |
|
| 200 | + <label for="shareapi_restrict_user_enumeration_full_match"><?php p($l->t('Allow username autocompletion when entering the full name or email address (ignoring missing phonebook match and being in the same group)')); ?></label><br /> |
|
| 201 | 201 | </p> |
| 202 | 202 | |
| 203 | 203 | <p> |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | <?php if ($_['publicShareDisclaimerText'] !== null) { |
| 206 | 206 | print_unescaped('checked="checked"'); |
| 207 | 207 | } ?> /> |
| 208 | - <label for="publicShareDisclaimer"><?php p($l->t('Show disclaimer text on the public link upload page (only shown when the file list is hidden)'));?></label> |
|
| 208 | + <label for="publicShareDisclaimer"><?php p($l->t('Show disclaimer text on the public link upload page (only shown when the file list is hidden)')); ?></label> |
|
| 209 | 209 | <span id="publicShareDisclaimerStatus" class="msg" style="display:none"></span> |
| 210 | 210 | <br/> |
| 211 | 211 | <textarea placeholder="<?php p($l->t('This text will be shown on the public link upload page when the file list is hidden.')) ?>" id="publicShareDisclaimerText" <?php if ($_['publicShareDisclaimerText'] === null) { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } ?>><?php p($_['publicShareDisclaimerText']) ?></textarea> |
| 214 | 214 | </p> |
| 215 | 215 | |
| 216 | - <h3><?php p($l->t('Default share permissions'));?></h3> |
|
| 216 | + <h3><?php p($l->t('Default share permissions')); ?></h3> |
|
| 217 | 217 | <input type="hidden" name="shareapi_default_permissions" id="shareApiDefaultPermissions" class="checkbox" |
| 218 | 218 | value="<?php p($_['shareApiDefaultPermissions']) ?>" /> |
| 219 | 219 | <p id="shareApiDefaultPermissionsSection" class="indent <?php if ($_['shareAPIEnabled'] === 'no') { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | class="noautosave checkbox" value="<?php p($perm['value']) ?>" <?php if (($_['shareApiDefaultPermissions'] & $perm['value']) !== 0) { |
| 225 | 225 | print_unescaped('checked="checked"'); |
| 226 | 226 | } ?> /> |
| 227 | - <label for="shareapi_default_permission_<?php p($perm['id']) ?>"><?php p($perm['label']);?></label> |
|
| 227 | + <label for="shareapi_default_permission_<?php p($perm['id']) ?>"><?php p($perm['label']); ?></label> |
|
| 228 | 228 | <?php endforeach ?> |
| 229 | 229 | </p> |
| 230 | 230 | </div> |