-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
488 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Bundle\AdminUi\Controller\User; | ||
|
||
use Ibexa\AdminUi\UserProfile\UserProfileConfiguration; | ||
use Ibexa\Contracts\AdminUi\Controller\Controller; | ||
use Ibexa\Contracts\Core\Repository\RoleService; | ||
use Ibexa\Contracts\Core\Repository\UserService; | ||
use Ibexa\Contracts\Core\Repository\Values\User\User; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class ProfileController extends Controller | ||
{ | ||
private UserService $userService; | ||
|
||
private RoleService $roleService; | ||
|
||
private UserProfileConfiguration $configuration; | ||
|
||
public function __construct( | ||
UserService $userService, | ||
RoleService $roleService, | ||
UserProfileConfiguration $configuration | ||
) { | ||
$this->userService = $userService; | ||
$this->roleService = $roleService; | ||
$this->configuration = $configuration; | ||
} | ||
|
||
public function viewAction(int $userId): Response | ||
{ | ||
$user = $this->userService->loadUser($userId); | ||
if (!$this->isUserProfileEnabled($user)) { | ||
throw $this->createNotFoundException(); | ||
} | ||
|
||
$roles = $this->roleService->getRoleAssignmentsForUser($user, true); | ||
|
||
return $this->render( | ||
'@ibexadesign/account/profile/view.html.twig', | ||
[ | ||
'user' => $user, | ||
'roles' => $roles, | ||
'field_groups' => $this->configuration->getFieldGroup(), | ||
] | ||
); | ||
} | ||
|
||
public function editAction(int $userId): Response | ||
{ | ||
$user = $this->userService->loadUser($userId); | ||
if (!$this->isUserProfileEnabled($user)) { | ||
throw $this->createNotFoundException(); | ||
} | ||
|
||
// TODO: Add language selection ? | ||
return $this->redirectToRoute( | ||
'ibexa.user.update', | ||
[ | ||
'contentId' => $user->getUserId(), | ||
'language' => $user->contentInfo->mainLanguageCode, | ||
'versionNo' => $user->versionInfo->versionNo, | ||
] | ||
); | ||
} | ||
|
||
private function isUserProfileEnabled(User $user): bool | ||
{ | ||
if ($this->configuration->isEnabled()) { | ||
return in_array( | ||
$user->getContentType()->identifier, | ||
$this->configuration->getContentTypes(), | ||
true | ||
); | ||
} | ||
|
||
return false; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/bundle/DependencyInjection/Configuration/Parser/UserProfile.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Bundle\AdminUi\DependencyInjection\Configuration\Parser; | ||
|
||
use Ibexa\Bundle\Core\DependencyInjection\Configuration\AbstractParser; | ||
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; | ||
use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|
||
final class UserProfile extends AbstractParser | ||
{ | ||
public function addSemanticConfig(NodeBuilder $nodeBuilder): void | ||
{ | ||
$nodeBuilder | ||
->arrayNode('user_profile') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->booleanNode('enabled') | ||
->defaultFalse() | ||
->end() | ||
->arrayNode('content_types') | ||
->scalarPrototype()->end() | ||
->defaultValue(['editor']) | ||
->example(['editor', 'administrator']) | ||
->end() | ||
->arrayNode('field_groups') | ||
->defaultValue(['about', 'contact']) | ||
->scalarPrototype()->end() | ||
->example(['about', 'contact']) | ||
->end() | ||
->end() | ||
->end(); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $scopeSettings | ||
* @param string $currentScope | ||
*/ | ||
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void | ||
{ | ||
if (empty($scopeSettings['user_profile'])) { | ||
return; | ||
} | ||
|
||
$contextualizer->setContextualParameter( | ||
'user_profile.enabled', | ||
$currentScope, | ||
$scopeSettings['user_profile']['enabled'] | ||
); | ||
|
||
$contextualizer->setContextualParameter( | ||
'user_profiler.content_types', | ||
$currentScope, | ||
$scopeSettings['user_profile']['content_types'] | ||
); | ||
|
||
$contextualizer->setContextualParameter( | ||
'user_profile.field_groups', | ||
$currentScope, | ||
$scopeSettings['user_profile']['field_groups'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Ibexa\AdminUi\UserProfile\UserProfileConfiguration: ~ | ||
|
||
Ibexa\AdminUi\UserProfile\UserProfileFieldGroupsProvider: | ||
decorates: Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList | ||
arguments: | ||
$innerService: '@.inner' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.ibexa-user-profile-view { | ||
.ibexa-user-profile { | ||
display: flex; | ||
|
||
&__aside { | ||
width: 30%; | ||
margin-right: 20px; | ||
|
||
.ibexa-user-thumbnail-wrapper { | ||
text-align: center; | ||
margin-bottom: -80px; | ||
|
||
.ibexa-user-thumbnail { | ||
background: $ibexa-color-white; | ||
border: calculateRem(1px) solid $ibexa-color-light; | ||
border-radius: 50%; | ||
padding: calculateRem(3px); | ||
|
||
&--img { | ||
width: 200px; | ||
height: 200px; | ||
} | ||
} | ||
} | ||
|
||
.ibexa-user-profile-info { | ||
padding-top: 100px; | ||
} | ||
} | ||
|
||
&__body { | ||
width: 75%; | ||
|
||
.ibexa-user-profile-name { | ||
min-height: 120px; | ||
vertical-align: middle; | ||
display: flex; | ||
|
||
h1 { | ||
margin: 40px 0; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,3 +129,4 @@ | |
@import 'switcher'; | ||
@import 'global-search'; | ||
@import 'user-name'; | ||
@import 'user-profile'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.