Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
if (!empty($oldName) && $user instanceof \OC\User\User) {
// if it was empty, it would be a new record, not a change emitting the trigger could
// potentially cause a UniqueConstraintViolationException, depending on some factors.
$user->triggerChange('displayName', $displayName);
$user->triggerChange('displayName', $displayName, $oldName);
}
}
return $displayName;
Expand Down
20 changes: 10 additions & 10 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ public function setDisplayName($displayName) {
$this->triggerChange('displayName', $displayName);
}
return $result !== false;
} else {
return false;
}
return false;
}

/**
Expand All @@ -159,12 +158,12 @@ public function setDisplayName($displayName) {
*/
public function setEMailAddress($mailAddress) {
$oldMailAddress = $this->getEMailAddress();
if($mailAddress === '') {
$this->config->deleteUserValue($this->uid, 'settings', 'email');
} else {
$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
}
if($oldMailAddress !== $mailAddress) {
if($mailAddress === '') {
$this->config->deleteUserValue($this->uid, 'settings', 'email');
} else {
$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
}
$this->triggerChange('eMailAddress', $mailAddress, $oldMailAddress);
}
}
Expand Down Expand Up @@ -365,7 +364,8 @@ public function setEnabled(bool $enabled = true) {
$oldStatus = $this->isEnabled();
$this->enabled = $enabled;
if ($oldStatus !== $this->enabled) {
$this->triggerChange('enabled', $enabled);
// TODO: First change the value, then trigger the event as done for all other properties.
$this->triggerChange('enabled', $enabled, $oldStatus);
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false');
}
}
Expand Down Expand Up @@ -407,9 +407,9 @@ public function setQuota($quota) {
$quota = OC_Helper::computerFileSize($quota);
$quota = OC_Helper::humanFileSize($quota);
}
$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
if($quota !== $oldQuota) {
$this->triggerChange('quota', $quota);
$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
$this->triggerChange('quota', $quota, $oldQuota);
}
}

Expand Down
20 changes: 4 additions & 16 deletions tests/lib/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,8 @@ public function testSetEMailAddressNoChange() {
$config->expects($this->any())
->method('getUserValue')
->willReturn('[email protected]');
$config->expects($this->once())
->method('setUserValue')
->with(
'foo',
'settings',
'email',
'[email protected]'
);
$config->expects($this->never())
->method('setUserValue');

$user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
$user->setEMailAddress('[email protected]');
Expand Down Expand Up @@ -741,14 +735,8 @@ public function testSetQuotaAddressNoChange() {
$config->expects($this->any())
->method('getUserValue')
->willReturn('23 TB');
$config->expects($this->once())
->method('setUserValue')
->with(
'foo',
'files',
'quota',
'23 TB'
);
$config->expects($this->never())
->method('setUserValue');

$user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
$user->setQuota('23 TB');
Expand Down