Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2021-02-01 06:32:28 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2021-04-23 17:53:14 +0300
commit184a7cadab93ef438ecfc6cca703c23f2fda9787 (patch)
tree3a56eb5b6ce9a2d14aca49212ddfc3d1a62c20e3 /apps/settings
parent828865a508bf5b7e6fa254c22dc9ea47ddb352f8 (diff)
Handle corrupted scope values
Due to a bug (fixed some commits ago) in the UsersController of the settings app the scope of the properties can be null (for example, if lookup server upload was disabled and the user then changed the display name in the profile information). In that case now the scope menu icon shows an error to inform the user. The scope value will not change when other properties are modified until the user chooses an explicit value from the menu. Note that until a scope is explicitly set the property will behave as if it is private. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/settings')
-rw-r--r--apps/settings/js/federationsettingsview.js15
-rw-r--r--apps/settings/templates/settings/personal/personal.info.php14
2 files changed, 21 insertions, 8 deletions
diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js
index 9cefaf132f2..2476c3f9429 100644
--- a/apps/settings/js/federationsettingsview.js
+++ b/apps/settings/js/federationsettingsview.js
@@ -43,7 +43,14 @@
if (!scopeOnly) {
self._config.set(field, $('#' + field).val());
}
- self._config.set(field + 'Scope', $('#' + field + 'scope').val());
+ // A scope could have been stored as null due to a previous bug.
+ // Null values should be kept as such until the user explicitly
+ // sets the right value, but they will be returned as empty
+ // strings in the template (which would overwrite the null value
+ // if sent). Due to this an extra class is needed to
+ // differentiate them.
+ var initialScopeValue = $('#' + field + 'scope').hasClass('corrupted-scope-value') ? undefined : $('#' + field + 'scope').val();
+ self._config.set(field + 'Scope', initialScopeValue);
// Set inputs whenever model values change
if (!scopeOnly) {
@@ -219,6 +226,12 @@
$icon.addClass('icon-link');
$icon.removeClass('hidden');
break;
+ case '':
+ case null:
+ case undefined:
+ $icon.addClass('icon-error');
+ $icon.removeClass('hidden');
+ break;
}
}
});
diff --git a/apps/settings/templates/settings/personal/personal.info.php b/apps/settings/templates/settings/personal/personal.info.php
index 0dee09d1cb9..cf940a9cd04 100644
--- a/apps/settings/templates/settings/personal/personal.info.php
+++ b/apps/settings/templates/settings/personal/personal.info.php
@@ -70,7 +70,7 @@ script('settings', [
</div>
</div>
<span class="icon-checkmark hidden"></span>
- <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>">
+ <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>"<?php if (is_null($_['avatarScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<div class="personal-settings-setting-box personal-settings-group-box section">
@@ -124,7 +124,7 @@ script('settings', [
<?php } ?>
<span class="icon-checkmark hidden"></span>
<span class="icon-error hidden" ></span>
- <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>">
+ <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>"<?php if (is_null($_['displayNameScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<div class="personal-settings-setting-box">
@@ -172,7 +172,7 @@ script('settings', [
<?php if ($_['displayNameChangeSupported']) { ?>
<em><?php p($l->t('For password reset and notifications')); ?></em>
<?php } ?>
- <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
+ <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>"<?php if (is_null($_['emailScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<?php if (!empty($_['phone']) || $_['lookupServerUploadEnabled']) { ?>
@@ -193,7 +193,7 @@ script('settings', [
placeholder="<?php p($l->t('Your phone number')); ?>"
autocomplete="on" autocapitalize="none" autocorrect="off" />
<span class="icon-checkmark hidden"></span>
- <input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>">
+ <input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>"<?php if (is_null($_['phoneScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<?php } ?>
@@ -215,7 +215,7 @@ script('settings', [
value="<?php p($_['address']) ?>"
autocomplete="on" autocapitalize="none" autocorrect="off" />
<span class="icon-checkmark hidden"></span>
- <input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>">
+ <input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>"<?php if (is_null($_['addressScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<?php } ?>
@@ -268,7 +268,7 @@ script('settings', [
} ?>
/>
<span class="icon-checkmark hidden"></span>
- <input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>">
+ <input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>"<?php if (is_null($_['websiteScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<?php } ?>
@@ -321,7 +321,7 @@ script('settings', [
} ?>
/>
<span class="icon-checkmark hidden"></span>
- <input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
+ <input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>"<?php if (is_null($_['twitterScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
</form>
</div>
<?php } ?>