Skip to content

Commit 184a7ca

Browse files
committed
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 <[email protected]>
1 parent 828865a commit 184a7ca

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

apps/settings/js/federationsettingsview.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@
4343
if (!scopeOnly) {
4444
self._config.set(field, $('#' + field).val());
4545
}
46-
self._config.set(field + 'Scope', $('#' + field + 'scope').val());
46+
// A scope could have been stored as null due to a previous bug.
47+
// Null values should be kept as such until the user explicitly
48+
// sets the right value, but they will be returned as empty
49+
// strings in the template (which would overwrite the null value
50+
// if sent). Due to this an extra class is needed to
51+
// differentiate them.
52+
var initialScopeValue = $('#' + field + 'scope').hasClass('corrupted-scope-value') ? undefined : $('#' + field + 'scope').val();
53+
self._config.set(field + 'Scope', initialScopeValue);
4754

4855
// Set inputs whenever model values change
4956
if (!scopeOnly) {
@@ -219,6 +226,12 @@
219226
$icon.addClass('icon-link');
220227
$icon.removeClass('hidden');
221228
break;
229+
case '':
230+
case null:
231+
case undefined:
232+
$icon.addClass('icon-error');
233+
$icon.removeClass('hidden');
234+
break;
222235
}
223236
}
224237
});

apps/settings/templates/settings/personal/personal.info.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</div>
7171
</div>
7272
<span class="icon-checkmark hidden"></span>
73-
<input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>">
73+
<input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>"<?php if (is_null($_['avatarScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
7474
</form>
7575
</div>
7676
<div class="personal-settings-setting-box personal-settings-group-box section">
@@ -124,7 +124,7 @@
124124
<?php } ?>
125125
<span class="icon-checkmark hidden"></span>
126126
<span class="icon-error hidden" ></span>
127-
<input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>">
127+
<input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>"<?php if (is_null($_['displayNameScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
128128
</form>
129129
</div>
130130
<div class="personal-settings-setting-box">
@@ -172,7 +172,7 @@
172172
<?php if ($_['displayNameChangeSupported']) { ?>
173173
<em><?php p($l->t('For password reset and notifications')); ?></em>
174174
<?php } ?>
175-
<input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
175+
<input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>"<?php if (is_null($_['emailScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
176176
</form>
177177
</div>
178178
<?php if (!empty($_['phone']) || $_['lookupServerUploadEnabled']) { ?>
@@ -193,7 +193,7 @@
193193
placeholder="<?php p($l->t('Your phone number')); ?>"
194194
autocomplete="on" autocapitalize="none" autocorrect="off" />
195195
<span class="icon-checkmark hidden"></span>
196-
<input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>">
196+
<input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>"<?php if (is_null($_['phoneScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
197197
</form>
198198
</div>
199199
<?php } ?>
@@ -215,7 +215,7 @@
215215
value="<?php p($_['address']) ?>"
216216
autocomplete="on" autocapitalize="none" autocorrect="off" />
217217
<span class="icon-checkmark hidden"></span>
218-
<input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>">
218+
<input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>"<?php if (is_null($_['addressScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
219219
</form>
220220
</div>
221221
<?php } ?>
@@ -268,7 +268,7 @@
268268
} ?>
269269
/>
270270
<span class="icon-checkmark hidden"></span>
271-
<input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>">
271+
<input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>"<?php if (is_null($_['websiteScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
272272
</form>
273273
</div>
274274
<?php } ?>
@@ -321,7 +321,7 @@
321321
} ?>
322322
/>
323323
<span class="icon-checkmark hidden"></span>
324-
<input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
324+
<input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>"<?php if (is_null($_['twitterScope'])): ?> class="corrupted-scope-value"<?php endif ?>>
325325
</form>
326326
</div>
327327
<?php } ?>

0 commit comments

Comments
 (0)