Skip to content

Commit

Permalink
fixup! feat: let users configure their first day of week
Browse files Browse the repository at this point in the history
  • Loading branch information
st3iny committed Jul 18, 2024
1 parent 4674699 commit 76ff158
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,9 @@ public function editUser(string $userId, string $key, string $value): DataRespon
throw new OCSException($this->l10n->t('Invalid first day of week'), 102);
}
if ($intValue === -1) {
$this->config->deleteUserValue($targetUser->getUID(), 'core', 'first_day_of_week');
$this->config->deleteUserValue($targetUser->getUID(), 'core', AUserData::USER_FIELD_FIRST_DAY_OF_WEEK);
} else {
$this->config->setUserValue($targetUser->getUID(), 'core', 'first_day_of_week', $value);
$this->config->setUserValue($targetUser->getUID(), 'core', AUserData::USER_FIELD_FIRST_DAY_OF_WEEK, $value);
}
break;
case self::USER_FIELD_NOTIFICATION_EMAIL:
Expand Down
3 changes: 2 additions & 1 deletion apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OC\Profile\ProfileManager;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Provisioning_API\Controller\AUserData;
use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
Expand Down Expand Up @@ -141,7 +142,7 @@ public function getForm(): TemplateResponse {
'headline' => $this->getProperty($account, IAccountManager::PROPERTY_HEADLINE),
'biography' => $this->getProperty($account, IAccountManager::PROPERTY_BIOGRAPHY),
'birthdate' => $this->getProperty($account, IAccountManager::PROPERTY_BIRTHDATE),
'firstDayOfWeek' => $this->config->getUserValue($uid, 'core', 'first_day_of_week')
'firstDayOfWeek' => $this->config->getUserValue($uid, 'core', AUserData::USER_FIELD_FIRST_DAY_OF_WEEK),

Check notice

Code scanning / Psalm

PossiblyFalseArgument Note

Argument 1 of OCP\IConfig::getUserValue cannot be false, possibly null|string value expected
];

$accountParameters = [
Expand Down
6 changes: 4 additions & 2 deletions lib/private/Template/JSConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OC\CapabilitiesManager;
use OC\Files\FilenameValidator;
use OC\Share\Share;
use OCA\Provisioning_API\Controller\AUserData;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\Authentication\Exceptions\ExpiredTokenException;
Expand Down Expand Up @@ -133,7 +134,8 @@ public function getConfig(): string {

$capabilities = $this->capabilitiesManager->getCapabilities(false, true);

$firstDay = $this->config->getUserValue($uid, 'core', 'first_day_of_week', null);
$userFirstDay = $this->config->getUserValue($uid, 'core', AUserData::USER_FIELD_FIRST_DAY_OF_WEEK, null);
$firstDay = (int)($userFirstDay ?? $this->l->l('firstday', null));

$config = [
/** @deprecated 30.0.0 - use files capabilities instead */
Expand Down Expand Up @@ -222,7 +224,7 @@ public function getConfig(): string {
$this->l->t('Nov.'),
$this->l->t('Dec.')
]),
"firstDay" => json_encode($firstDay ?? $this->l->l('firstday', null)),
"firstDay" => json_encode($firstDay),
"_oc_config" => json_encode($config),
"oc_appconfig" => json_encode([
'core' => [
Expand Down

0 comments on commit 76ff158

Please sign in to comment.