Skip to content

Commit 839c4d7

Browse files
authored
Merge pull request #58518 from nextcloud/enh/58508/move-user-picker-to-profile
Move the profile picker to the profile app
2 parents e19db72 + 9464eab commit 839c4d7

395 files changed

Lines changed: 543 additions & 2055 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ node_modules/
4444
!/apps/updatenotification
4545
!/apps/theming
4646
!/apps/twofactor_backupcodes
47-
!/apps/user_picker
4847
!/apps/user_status
4948
!/apps/weather_status
5049
!/apps/webhook_listeners

.tx/config

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ source_file = translationfiles/templates/user_ldap.pot
170170
source_lang = en
171171
type = PO
172172

173-
[o:nextcloud:p:nextcloud:r:user_picker]
174-
file_filter = translationfiles/<lang>/user_picker.po
175-
source_file = translationfiles/templates/user_picker.pot
176-
source_lang = en
177-
type = PO
178-
179173
[o:nextcloud:p:nextcloud:r:user_status]
180174
file_filter = translationfiles/<lang>/user_status.po
181175
source_file = translationfiles/templates/user_status.pot

apps/profile/composer/composer/autoload_classmap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77

88
return array(
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10+
'OCA\\Profile\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
1011
'OCA\\Profile\\Controller\\ProfilePageController' => $baseDir . '/../lib/Controller/ProfilePageController.php',
12+
'OCA\\Profile\\Listener\\ProfilePickerReferenceListener' => $baseDir . '/../lib/Listener/ProfilePickerReferenceListener.php',
13+
'OCA\\Profile\\Reference\\ProfilePickerReferenceProvider' => $baseDir . '/../lib/Reference/ProfilePickerReferenceProvider.php',
1114
);

apps/profile/composer/composer/autoload_static.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class ComposerStaticInitProfile
2222

2323
public static $classMap = array (
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25+
'OCA\\Profile\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
2526
'OCA\\Profile\\Controller\\ProfilePageController' => __DIR__ . '/..' . '/../lib/Controller/ProfilePageController.php',
27+
'OCA\\Profile\\Listener\\ProfilePickerReferenceListener' => __DIR__ . '/..' . '/../lib/Listener/ProfilePickerReferenceListener.php',
28+
'OCA\\Profile\\Reference\\ProfilePickerReferenceProvider' => __DIR__ . '/..' . '/../lib/Reference/ProfilePickerReferenceProvider.php',
2629
);
2730

2831
public static function getInitializer(ClassLoader $loader)

apps/profile/img/app-dark.svg

Lines changed: 3 additions & 0 deletions
Loading

apps/profile/img/app.svg

Lines changed: 3 additions & 0 deletions
Loading

apps/user_picker/lib/AppInfo/Application.php renamed to apps/profile/lib/AppInfo/Application.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
77
* SPDX-License-Identifier: AGPL-3.0-or-later
88
*/
9-
namespace OCA\UserPicker\AppInfo;
9+
namespace OCA\Profile\AppInfo;
1010

11-
use OCA\UserPicker\Listener\UserPickerReferenceListener;
12-
use OCA\UserPicker\Reference\ProfilePickerReferenceProvider;
11+
use OCA\Profile\Listener\ProfilePickerReferenceListener;
12+
use OCA\Profile\Reference\ProfilePickerReferenceProvider;
1313
use OCP\AppFramework\App;
1414
use OCP\AppFramework\Bootstrap\IBootContext;
1515
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -18,15 +18,15 @@
1818
use OCP\Collaboration\Reference\RenderReferenceEvent;
1919

2020
class Application extends App implements IBootstrap {
21-
public const APP_ID = 'user_picker';
21+
public const APP_ID = 'profile';
2222

2323
public function __construct(array $urlParams = []) {
2424
parent::__construct(self::APP_ID, $urlParams);
2525
}
2626

2727
public function register(IRegistrationContext $context): void {
2828
$context->registerReferenceProvider(ProfilePickerReferenceProvider::class);
29-
$context->registerEventListener(RenderReferenceEvent::class, UserPickerReferenceListener::class);
29+
$context->registerEventListener(RenderReferenceEvent::class, ProfilePickerReferenceListener::class);
3030
}
3131

3232
public function boot(IBootContext $context): void {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OCA\Profile\Listener;
10+
11+
use OCA\Profile\AppInfo\Application;
12+
use OCP\Collaboration\Reference\RenderReferenceEvent;
13+
use OCP\EventDispatcher\Event;
14+
use OCP\EventDispatcher\IEventListener;
15+
use OCP\IAppConfig;
16+
use OCP\Profile\IProfileManager;
17+
use OCP\Util;
18+
19+
/**
20+
* @template-implements IEventListener<RenderReferenceEvent>
21+
*/
22+
class ProfilePickerReferenceListener implements IEventListener {
23+
24+
public function __construct(
25+
private IAppConfig $appConfig,
26+
private IProfileManager $profileManager,
27+
) {
28+
}
29+
30+
public function handle(Event $event): void {
31+
if (!$event instanceof RenderReferenceEvent) {
32+
return;
33+
}
34+
35+
$profileEnabledGlobally = $this->profileManager->isProfileEnabled();
36+
37+
$profilePickerEnabled = filter_var(
38+
$this->appConfig->getValueString('settings', 'profile_picker_enabled', '1'),
39+
FILTER_VALIDATE_BOOLEAN,
40+
FILTER_NULL_ON_FAILURE,
41+
);
42+
43+
if ($profileEnabledGlobally && $profilePickerEnabled) {
44+
Util::addScript(Application::APP_ID, 'reference');
45+
}
46+
}
47+
}

apps/user_picker/lib/Reference/ProfilePickerReferenceProvider.php renamed to apps/profile/lib/Reference/ProfilePickerReferenceProvider.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,41 @@
66
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
77
* SPDX-License-Identifier: AGPL-3.0-or-later
88
*/
9-
namespace OCA\UserPicker\Reference;
9+
namespace OCA\Profile\Reference;
1010

11-
use OCA\UserPicker\AppInfo\Application;
11+
use OCA\Profile\AppInfo\Application;
1212
use OCP\Accounts\IAccountManager;
1313

1414
use OCP\Collaboration\Reference\ADiscoverableReferenceProvider;
1515
use OCP\Collaboration\Reference\IReference;
1616
use OCP\Collaboration\Reference\Reference;
1717

18+
use OCP\IAppConfig;
1819
use OCP\IL10N;
1920
use OCP\IURLGenerator;
2021
use OCP\IUserManager;
2122
use OCP\Profile\IProfileManager;
2223

2324
class ProfilePickerReferenceProvider extends ADiscoverableReferenceProvider {
24-
public const RICH_OBJECT_TYPE = 'user_picker_profile';
25+
public const RICH_OBJECT_TYPE = 'profile_widget';
26+
private bool $enabled;
2527

2628
public function __construct(
2729
private IL10N $l10n,
2830
private IURLGenerator $urlGenerator,
2931
private IUserManager $userManager,
3032
private IAccountManager $accountManager,
3133
private IProfileManager $profileManager,
34+
private IAppConfig $appConfig,
3235
private ?string $userId,
3336
) {
37+
$profileEnabledGlobally = $this->profileManager->isProfileEnabled();
38+
$profilePickerEnabled = filter_var(
39+
$this->appConfig->getValueString('settings', 'profile_picker_enabled', '1'),
40+
FILTER_VALIDATE_BOOLEAN,
41+
FILTER_NULL_ON_FAILURE,
42+
);
43+
$this->enabled = $profileEnabledGlobally && $profilePickerEnabled;
3444
}
3545

3646
/**
@@ -65,6 +75,9 @@ public function getIconUrl(): string {
6575
* @inheritDoc
6676
*/
6777
public function matchReference(string $referenceText): bool {
78+
if (!$this->enabled) {
79+
return false;
80+
}
6881
return $this->getObjectId($referenceText) !== null;
6982
}
7083

0 commit comments

Comments
 (0)