Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/dav/lib/CardDAV/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function createCardFromUser(IUser $user): ?VCard {
);
}
break;
case IAccountManager::COLLECTION_PHONE:
case IAccountManager::PROPERTY_PHONE:
$vCard->add(new Text($vCard, 'TEL', $property->getValue(), ['TYPE' => 'VOICE', 'X-NC-SCOPE' => $scope]));
break;
Expand Down
14 changes: 14 additions & 0 deletions apps/provisioning_api/lib/Controller/AUserDataOCSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ protected function getUserData(string $userId, bool $includeScopes = false): ?ar
$data[IAccountManager::COLLECTION_EMAIL . self::SCOPE_SUFFIX] = $additionalEmailScopes;
}

$additionalPhones = $addtionalPhoneScopes = [];
$phoneCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_PHONE);
foreach ($phoneCollection->getProperties() as $property) {
$phone = $property->getValue();
$additionalPhones[] = $phone;
if ($includeScopes) {
$additionalPhoneScopes[] = $property->getScope();
}
}
$data[IAccountManager::COLLECTION_PHONE] = $additionalPhones;
if ($includeScopes) {
$data[IAccountManager::COLLECTION_PHONE . self::SCOPE_SUFFIX] = $additionalPhoneScopes;
}

$data[IAccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
$data[IAccountManager::PROPERTY_DISPLAYNAME_LEGACY] = $data[IAccountManager::PROPERTY_DISPLAYNAME];
if ($includeScopes) {
Expand Down
70 changes: 70 additions & 0 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ public function getEditableFieldsForUser(string $userId): DataResponse {
$permittedFields[] = IAccountManager::COLLECTION_EMAIL;
}

if ($targetUser->canEditProperty(IAccountManager::COLLECTION_PHONE)) {
$permittedFields[] = IAccountManager::COLLECTION_PHONE;
}

return new DataResponse($permittedFields);
}

Expand Down Expand Up @@ -833,11 +837,16 @@ public function editUserMultiValue(
$permittedFields[] = IAccountManager::COLLECTION_EMAIL;
}
$permittedFields[] = IAccountManager::COLLECTION_EMAIL . self::SCOPE_SUFFIX;
if ($targetUser->canEditProperty(IAccountManager::COLLECTION_PHONE)) {
$permittedFields[] = IAccountManager::COLLECTION_PHONE;
}
$permittedFields[] = IAccountManager::COLLECTION_PHONE . self::SCOPE_SUFFIX;
} else {
// Check if admin / subadmin
if ($isAdminOrSubadmin || $isDelegatedAdmin && !$this->groupManager->isInGroup($targetUser->getUID(), 'admin')) {
// They have permissions over the user
$permittedFields[] = IAccountManager::COLLECTION_EMAIL;
$permittedFields[] = IAccountManager::COLLECTION_PHONE;
} else {
// No rights
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
Expand Down Expand Up @@ -891,6 +900,43 @@ public function editUserMultiValue(
}
break;

case IAccountManager::COLLECTION_PHONE:
$userAccount = $this->accountManager->getAccount($targetUser);
$phoneCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_PHONE);
$phoneCollection->removePropertyByValue($key);
if ($value !== '') {
$phoneCollection->addPropertyWithDefaults($value);
}
try {
$this->accountManager->updateAccount($userAccount);
$this->knownUserService->deleteByContactUserId($targetUser->getUID());
} catch (InvalidArgumentException $e) {
throw new OCSException('Invalid ' . $e->getMessage(), 101);
}
break;

case IAccountManager::COLLECTION_PHONE . self::SCOPE_SUFFIX:
$userAccount = $this->accountManager->getAccount($targetUser);
$phoneCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_PHONE);
$targetProperty = null;
foreach ($phoneCollection->getProperties() as $property) {
if ($property->getValue() === $key) {
$targetProperty = $property;
break;
}
}
if ($targetProperty instanceof IAccountProperty) {
try {
$targetProperty->setScope($value);
$this->accountManager->updateAccount($userAccount);
} catch (InvalidArgumentException $e) {
throw new OCSException('', 102);
}
} else {
throw new OCSException('', 102);
}
break;

default:
throw new OCSException('', 103);
}
Expand Down Expand Up @@ -1199,6 +1245,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
}

$permittedFields[] = IAccountManager::COLLECTION_EMAIL;
$permittedFields[] = IAccountManager::COLLECTION_PHONE;

$permittedFields[] = self::USER_FIELD_PASSWORD;
$permittedFields[] = self::USER_FIELD_NOTIFICATION_EMAIL;
Expand Down Expand Up @@ -1256,6 +1303,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
}
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
$permittedFields[] = IAccountManager::COLLECTION_EMAIL;
$permittedFields[] = IAccountManager::COLLECTION_PHONE;
$permittedFields[] = self::USER_FIELD_PASSWORD;
$permittedFields[] = self::USER_FIELD_LANGUAGE;
$permittedFields[] = self::USER_FIELD_LOCALE;
Expand Down Expand Up @@ -1389,6 +1437,28 @@ public function editUser(string $userId, string $key, string $value): DataRespon
throw new OCSException('', 101);
}
break;
case IAccountManager::COLLECTION_PHONE:
if ($value !== '') {
$userAccount = $this->accountManager->getAccount($targetUser);
$primaryPhone = $userAccount->getProperty(IAccountManager::PROPERTY_PHONE)->getValue();
if ($value === $primaryPhone) {
throw new OCSException('', 101);
}
$phoneCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_PHONE);
if ($phoneCollection->getPropertyByValue($value)) {
throw new OCSException('', 101);
}
$phoneCollection->addPropertyWithDefaults($value);
try {
$this->accountManager->updateAccount($userAccount);
$this->knownUserService->deleteByContactUserId($targetUser->getUID());
} catch (InvalidArgumentException $e) {
throw new OCSException('Invalid ' . $e->getMessage(), 101);
}
} else {
throw new OCSException('', 101);
}
break;
case IAccountManager::PROPERTY_PHONE:
case IAccountManager::PROPERTY_ADDRESS:
case IAccountManager::PROPERTY_WEBSITE:
Expand Down
2 changes: 2 additions & 0 deletions apps/provisioning_api/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @psalm-type Provisioning_APIUserDetails = array{
* additional_mail: list<string>,
* additional_mailScope?: list<Provisioning_APIUserDetailsScope>,
* additional_phone: list<string>,
* additional_phoneScope?: list<Provisioning_APIUserDetailsScope>,
* address: string,
* addressScope?: Provisioning_APIUserDetailsScope,
* avatarScope?: Provisioning_APIUserDetailsScope,
Expand Down
13 changes: 13 additions & 0 deletions apps/provisioning_api/openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"type": "object",
"required": [
"additional_mail",
"additional_phone",
"address",
"backend",
"backendCapabilities",
Expand Down Expand Up @@ -123,6 +124,18 @@
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"additional_phone": {
"type": "array",
"items": {
"type": "string"
}
},
"additional_phoneScope": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"address": {
"type": "string"
},
Expand Down
13 changes: 13 additions & 0 deletions apps/provisioning_api/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"type": "object",
"required": [
"additional_mail",
"additional_phone",
"address",
"backend",
"backendCapabilities",
Expand Down Expand Up @@ -170,6 +171,18 @@
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"additional_phone": {
"type": "array",
"items": {
"type": "string"
}
},
"additional_phoneScope": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"address": {
"type": "string"
},
Expand Down
13 changes: 13 additions & 0 deletions apps/provisioning_api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"type": "object",
"required": [
"additional_mail",
"additional_phone",
"address",
"backend",
"backendCapabilities",
Expand Down Expand Up @@ -170,6 +171,18 @@
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"additional_phone": {
"type": "array",
"items": {
"type": "string"
}
},
"additional_phoneScope": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UserDetailsScope"
}
},
"address": {
"type": "string"
},
Expand Down
34 changes: 33 additions & 1 deletion apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getForm(): TemplateResponse {
'usageRelative' => round($storageInfo['relative']),
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
'emailMap' => $this->getEmailMap($account),
'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
'phoneMap' => $this->getPhoneMap($account),
'defaultPhoneRegion' => $this->config->getSystemValueString('default_phone_region'),
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
Expand Down Expand Up @@ -243,6 +243,38 @@ function (IAccountProperty $property) {
return $emailMap;
}

/**
* returns the primary phone and additional phones in an
* associative array
*/
private function getPhoneMap(IAccount $account): array {
$primaryPhone = [
'name' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getName(),
'value' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
'scope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
'verified' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getVerified(),
];

$additionalPhones = array_map(
function (IAccountProperty $property) {
return [
'name' => $property->getName(),
'value' => $property->getValue(),
'scope' => $property->getScope(),
'verified' => $property->getVerified(),
];
},
$account->getPropertyCollection(IAccountManager::COLLECTION_PHONE)->getProperties(),
);

$phoneMap = [
'primaryPhone' => $primaryPhone,
'additionalPhones' => $additionalPhones,
];

return $phoneMap;
}

/**
* returns the user's active language, common languages, and other languages in an
* associative array
Expand Down
52 changes: 0 additions & 52 deletions apps/settings/src/components/PersonalInfo/PhoneSection.vue

This file was deleted.

Loading