summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-12-16 16:44:47 +0100
committerJulius Härtl <jus@bitgrid.net>2017-12-19 18:49:26 +0100
commit4c3eb80a9102ceaf08d5143eaba8877a8a43e57d (patch)
tree0c9aed8fbd785bc585cfef63c66105b0578238db
parentd497f79625a35330f8a07d9d6913281fa2d0deac (diff)
downloadnextcloud-server-4c3eb80a9102ceaf08d5143eaba8877a8a43e57d.tar.gz
nextcloud-server-4c3eb80a9102ceaf08d5143eaba8877a8a43e57d.zip
Hide delete button if the avatar is a generated one
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/private/Avatar.php3
-rw-r--r--lib/private/Template/JSConfigHelper.php1
-rw-r--r--settings/js/settings/personalInfo.js6
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index 3b1aac4b514..afa9118c509 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -141,6 +141,7 @@ class Avatar implements IAvatar {
try {
$generated = $this->folder->getFile('generated');
+ $this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'false');
$generated->delete();
} catch (NotFoundException $e) {
//
@@ -161,6 +162,7 @@ class Avatar implements IAvatar {
foreach ($avatars as $avatar) {
$avatar->delete();
}
+ $this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
$this->user->triggerChange('avatar', '');
}
@@ -177,6 +179,7 @@ class Avatar implements IAvatar {
$ext = 'png';
$this->folder->newFile('generated');
+ $this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
}
if ($size === -1) {
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index 60ac4bfecb0..551fc3b9b0d 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -254,6 +254,7 @@ class JSConfigHelper {
$array['oc_userconfig'] = json_encode([
'avatar' => [
'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0),
+ 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true',
]
]);
}
diff --git a/settings/js/settings/personalInfo.js b/settings/js/settings/personalInfo.js
index c95b87b01da..0a39e607762 100644
--- a/settings/js/settings/personalInfo.js
+++ b/settings/js/settings/personalInfo.js
@@ -60,7 +60,7 @@ function updateAvatar (hidedefault) {
$displaydiv.avatar(user.uid, 145, true, null, function() {
$displaydiv.removeClass('loading');
$('#displayavatar img').show();
- if($('#displayavatar img').length === 0) {
+ if($('#displayavatar img').length === 0 || oc_userconfig.avatar.generated) {
$('#removeavatar').removeClass('inlineblock').addClass('hidden');
} else {
$('#removeavatar').removeClass('hidden').addClass('inlineblock');
@@ -129,6 +129,7 @@ function avatarResponseHandler (data) {
$warning.hide();
if (data.status === "success") {
$('#displayavatar .avatardiv').removeClass('icon-loading');
+ oc_userconfig.avatar.generated = false;
updateAvatar();
} else if (data.data === "notsquare") {
showAvatarCropper();
@@ -368,6 +369,7 @@ $(document).ready(function () {
type: 'DELETE',
url: OC.generateUrl('/avatar/'),
success: function () {
+ oc_userconfig.avatar.generated = true;
updateAvatar(true);
}
});
@@ -398,7 +400,7 @@ $(document).ready(function () {
// Load the big avatar
var user = OC.getCurrentUser();
$('#avatarform .avatardiv').avatar(user.uid, 145, true, null, function() {
- if($('#displayavatar img').length === 0) {
+ if($('#displayavatar img').length === 0 || oc_userconfig.avatar.generated) {
$('#removeavatar').removeClass('inlineblock').addClass('hidden');
} else {
$('#removeavatar').removeClass('hidden').addClass('inlineblock');