aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Profile
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-28 00:39:09 +0000
committerChristopher Ng <chrng8@gmail.com>2021-11-03 23:15:56 +0000
commitee1c6eefb4412fc972f06710e97a43100c6ddb9c (patch)
tree8aa0b28b7ab537ebb63d829cb9f26158fa5b969d /lib/private/Profile
parentb453fea4da230883619aba2df83da4ca9bb05b3a (diff)
downloadnextcloud-server-ee1c6eefb4412fc972f06710e97a43100c6ddb9c.tar.gz
nextcloud-server-ee1c6eefb4412fc972f06710e97a43100c6ddb9c.zip
Add additional check on action registrations
- Minor refactor Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'lib/private/Profile')
-rw-r--r--lib/private/Profile/ProfileManager.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/private/Profile/ProfileManager.php b/lib/private/Profile/ProfileManager.php
index a7fdfcc62f4..18b53ba9a7e 100644
--- a/lib/private/Profile/ProfileManager.php
+++ b/lib/private/Profile/ProfileManager.php
@@ -92,6 +92,7 @@ class ProfileManager {
*/
private const PROFILE_PROPERTIES = [
IAccountManager::PROPERTY_ADDRESS,
+ IAccountManager::PROPERTY_AVATAR,
IAccountManager::PROPERTY_BIOGRAPHY,
IAccountManager::PROPERTY_DISPLAYNAME,
IAccountManager::PROPERTY_HEADLINE,
@@ -150,6 +151,11 @@ class ProfileManager {
}
}
+ if (in_array($action->getId(), self::PROFILE_PROPERTIES, true)) {
+ $this->logger->error('Cannot register action with ID: ' . $action->getId() . ', as it is used by a core account property.');
+ return;
+ }
+
// Add action to associative array of actions
$this->actions[$action->getId()] = $action;
}
@@ -252,16 +258,26 @@ class ProfileManager {
// Add account properties
foreach (self::PROFILE_PROPERTIES as $property) {
- $profileParameters[$property] =
- $this->isParameterVisible($targetUser, $visitingUser, $property)
- // Explicitly set to null when value is empty string
- ? ($account->getProperty($property)->getValue() ?: null)
- : null;
+ switch ($property) {
+ case IAccountManager::PROPERTY_ADDRESS:
+ case IAccountManager::PROPERTY_BIOGRAPHY:
+ case IAccountManager::PROPERTY_DISPLAYNAME:
+ case IAccountManager::PROPERTY_HEADLINE:
+ case IAccountManager::PROPERTY_ORGANISATION:
+ case IAccountManager::PROPERTY_ROLE:
+ $profileParameters[$property] =
+ $this->isParameterVisible($targetUser, $visitingUser, $property)
+ // Explicitly set to null when value is empty string
+ ? ($account->getProperty($property)->getValue() ?: null)
+ : null;
+ break;
+ case IAccountManager::PROPERTY_AVATAR:
+ // Add avatar visibility
+ $profileParameters['isUserAvatarVisible'] = $this->isParameterVisible($targetUser, $visitingUser, $property);
+ break;
+ }
}
- // Add avatar visibility
- $profileParameters['isUserAvatarVisible'] = $this->isParameterVisible($targetUser, $visitingUser, IAccountManager::PROPERTY_AVATAR);
-
// Add actions
$profileParameters['actions'] = array_map(
function (ILinkAction $action) {