-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* commit du soir bonsoir * PrivacyBundle * corrections suite review PR * Update bundles.ini-dist
- Loading branch information
Showing
21 changed files
with
359 additions
and
0 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
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,9 @@ | ||
<?php | ||
|
||
namespace Claroline\PrivacyBundle; | ||
|
||
use Claroline\KernelBundle\Bundle\DistributionPluginBundle; | ||
|
||
class ClarolinePrivacyBundle extends DistributionPluginBundle | ||
{ | ||
} |
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,56 @@ | ||
<?php | ||
|
||
namespace Claroline\PrivacyBundle\Controller; | ||
|
||
use Claroline\AppBundle\API\Utils\ArrayUtils; | ||
use Claroline\AppBundle\Controller\AbstractSecurityController; | ||
use Claroline\AppBundle\Controller\RequestDecoderTrait; | ||
use Claroline\CoreBundle\API\Serializer\ParametersSerializer; | ||
use Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | ||
|
||
class PrivacyController extends AbstractSecurityController | ||
{ | ||
use RequestDecoderTrait; | ||
|
||
private AuthorizationCheckerInterface $authorization; | ||
|
||
private PlatformConfigurationHandler $config; | ||
|
||
private ParametersSerializer $serializer; | ||
|
||
public function __construct( | ||
AuthorizationCheckerInterface $authorization, | ||
PlatformConfigurationHandler $ch, | ||
ParametersSerializer $serializer | ||
) { | ||
$this->authorization = $authorization; | ||
$this->config = $ch; | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* @Route("/privacy", name="apiv2_privacy_update", methods={"PUT"}) | ||
*/ | ||
public function updateAction(Request $request): JsonResponse | ||
{ | ||
$this->canOpenAdminTool('privacy'); | ||
|
||
$parametersData = $this->decodeRequest($request); | ||
|
||
ArrayUtils::remove($parametersData, 'lockedParameters'); | ||
|
||
$locked = $this->config->getParameter('lockedParameters') ?? []; | ||
foreach ($locked as $lockedParam) { | ||
ArrayUtils::remove($parametersData, $lockedParam); | ||
} | ||
|
||
$parameters = $this->serializer->deserialize($parametersData); | ||
$this->config->setParameters($parameters); | ||
|
||
return new JsonResponse($parameters); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/privacy/DependencyInjection/ClarolinePrivacyExtension.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,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Claroline Connect package. | ||
* | ||
* (c) Claroline Consortium <consortium@claroline.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\PrivacyBundle\DependencyInjection; | ||
|
||
use Exception; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
class ClarolinePrivacyExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @throws Exception | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$locator = new FileLocator(__DIR__.'/../Resources/config'); | ||
$loader = new YamlFileLoader($container, $locator); | ||
$loader->load('services.yml'); | ||
} | ||
} |
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,4 @@ | ||
plugin: | ||
admin_tools: | ||
- name: privacy | ||
class: shield |
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,6 @@ | ||
claro_privacy: | ||
resource: "@ClarolinePrivacyBundle/Controller/" | ||
prefix: apiv2 | ||
type: api | ||
options: | ||
expose: true |
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,4 @@ | ||
imports: | ||
- { resource: services/controller.yml } | ||
- { resource: services/subscriber.yml } | ||
- { resource: services/serializer.yml } |
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,8 @@ | ||
services: | ||
Claroline\PrivacyBundle\Controller\PrivacyController: | ||
parent: Claroline\AppBundle\Controller\AbstractSecurityController | ||
public: true | ||
arguments: | ||
- '@security.authorization_checker' | ||
- '@Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler' | ||
- '@Claroline\CoreBundle\API\Serializer\ParametersSerializer' |
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,5 @@ | ||
services: | ||
_defaults: | ||
autowire: false | ||
autoconfigure: false | ||
public: true |
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,5 @@ | ||
services: | ||
Claroline\PrivacyBundle\Subscriber\Administration\PrivacySubscriber: | ||
tags: [ kernel.event_subscriber ] | ||
arguments: | ||
- '@Claroline\CoreBundle\API\Serializer\ParametersSerializer' |
95 changes: 95 additions & 0 deletions
95
src/main/privacy/Resources/modules/administration/privacy/components/tool.jsx
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,95 @@ | ||
import React from 'react' | ||
import {PropTypes as T} from 'prop-types' | ||
|
||
import {LINK_BUTTON} from '#/main/app/buttons' | ||
import {FormData} from '#/main/app/content/form/containers/data' | ||
import {ToolPage} from '#/main/core/tool/containers/page' | ||
import {selectors} from '#/main/privacy/administration/privacy/store' | ||
import get from 'lodash/get' | ||
|
||
import {trans} from '#/main/app/intl/translation' | ||
|
||
const PrivacyTool = (props) => | ||
<ToolPage> | ||
<FormData | ||
level={2} | ||
name={selectors.FORM_NAME} | ||
target={['apiv2_privacy_update']} | ||
buttons={true} | ||
cancel={{ | ||
type: LINK_BUTTON, | ||
target: props.path, | ||
exact: true | ||
}} | ||
locked={props.lockedParameters} | ||
sections={[ | ||
{ | ||
title: trans('general'), | ||
primary: true, | ||
fields: [ | ||
{ | ||
name: 'privacy.countryStorage', | ||
label: trans('Pays de stockage des données'), | ||
type: 'country' | ||
} | ||
] | ||
}, { | ||
icon: 'fa fa-fw fa-user-shield', | ||
title: trans('dpo'), | ||
fields: [ | ||
{ | ||
name: 'privacy.dpo.name', | ||
label: trans('name'), | ||
type: 'string' | ||
}, { | ||
name: 'privacy.dpo.email', | ||
label: trans('email'), | ||
type: 'email' | ||
}, { | ||
name: 'privacy.dpo.phone', | ||
label: trans('phone'), | ||
type: 'string' | ||
}, { | ||
name: 'privacy.dpo.address', | ||
label: trans('address'), | ||
type: 'address' | ||
} | ||
] | ||
}, { | ||
icon: 'fa fa-fw fa-copyright', | ||
title: trans('terms_of_service'), | ||
fields: [ | ||
{ | ||
name: 'tos.enabled', | ||
type: 'boolean', | ||
label: trans('terms_of_service_activation_message'), | ||
help: trans('terms_of_service_activation_help'), | ||
linked: [ | ||
{ | ||
name: 'tos.text', | ||
type: 'translated', | ||
label: trans('terms_of_service'), | ||
required: true, | ||
displayed: get(props.parameters, 'tos.enabled') | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]} | ||
/> | ||
</ToolPage> | ||
|
||
PrivacyTool.propTypes = { | ||
path: T.string.isRequired, | ||
lockedParameters: T.arrayOf(T.string), | ||
parameters: T.shape({ | ||
tos: T.shape({ | ||
enabled: T.bool | ||
}) | ||
}) | ||
} | ||
|
||
export { | ||
PrivacyTool | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/privacy/Resources/modules/administration/privacy/containers/tool.jsx
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,18 @@ | ||
import {connect} from 'react-redux' | ||
|
||
import {selectors} from '#/main/privacy/administration/privacy/store/selectors' | ||
import {selectors as toolSelectors} from '#/main/core/tool/store' | ||
|
||
import {PrivacyTool as PrivacyToolComponent} from '#/main/privacy/administration/privacy/components/tool' | ||
|
||
const PrivacyTool = connect( | ||
(state) => ({ | ||
path: toolSelectors.path(state), | ||
lockedParameters: selectors.lockedParameters(state), | ||
parameters: selectors.parameters(state) | ||
}) | ||
)(PrivacyToolComponent) | ||
|
||
export { | ||
PrivacyTool | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/privacy/Resources/modules/administration/privacy/index.js
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,8 @@ | ||
import {PrivacyTool} from '#/main/privacy/administration/privacy/components/tool' | ||
|
||
import {reducer} from '#/main/privacy/administration/privacy/store/reducer' | ||
|
||
export default { | ||
component: PrivacyTool, | ||
store: reducer | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/privacy/Resources/modules/administration/privacy/store/index.js
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,4 @@ | ||
import {reducer} from '#/main/privacy/administration/privacy/store/reducer' | ||
import {selectors} from '#/main/privacy/administration/privacy/store/selectors' | ||
|
||
export {reducer, selectors} |
26 changes: 26 additions & 0 deletions
26
src/main/privacy/Resources/modules/administration/privacy/store/reducer.js
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,26 @@ | ||
import {makeFormReducer} from '#/main/app/content/form/store/reducer' | ||
import {makeInstanceAction} from '#/main/app/store/actions' | ||
import {makeReducer, combineReducers} from '#/main/app/store/reducer' | ||
|
||
import {TOOL_LOAD} from '#/main/core/tool/store/actions' | ||
|
||
import {selectors} from '#/main/privacy/administration/privacy/store/selectors' | ||
|
||
const reducer = combineReducers({ | ||
lockedParameters: makeReducer([], { | ||
[makeInstanceAction(TOOL_LOAD, 'privacy')]: (state, action) => action.toolData.lockedParameters | ||
}), | ||
parameters: makeFormReducer(selectors.FORM_NAME, {}, { | ||
originalData: makeReducer({}, { | ||
[makeInstanceAction(TOOL_LOAD, 'privacy')]: (state, action) => action.toolData.parameters | ||
}), | ||
data: makeReducer({}, { | ||
[makeInstanceAction(TOOL_LOAD, 'privacy')]: (state, action) => action.toolData.parameters | ||
}) | ||
}) | ||
}) | ||
|
||
export { | ||
reducer | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
src/main/privacy/Resources/modules/administration/privacy/store/selectors.js
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,22 @@ | ||
import {createSelector} from 'reselect' | ||
import {selectors as formSelectors} from '#/main/app/content/form/store/selectors' | ||
|
||
const STORE_NAME = 'privacy' | ||
const FORM_NAME = STORE_NAME+'.parameters' | ||
const store = (state) => state[STORE_NAME] | ||
|
||
const lockedParameters = createSelector( | ||
[store], | ||
(store) => store.lockedParameters | ||
) | ||
|
||
const parameters = (state) => formSelectors.data(formSelectors.form(state, FORM_NAME)) | ||
|
||
|
||
export const selectors = { | ||
STORE_NAME, | ||
store, | ||
lockedParameters, | ||
parameters, | ||
FORM_NAME | ||
} |
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,9 @@ | ||
import {registry} from '#/main/app/plugins/registry' | ||
|
||
registry.add('ClarolinePrivacyBundle', { | ||
administration: { | ||
'privacy': () => { | ||
return import(/* webpackChunkName: "main-privacy-admin-privacy" */ '#/main/privacy/administration/privacy') | ||
} | ||
} | ||
}) |
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,3 @@ | ||
{ | ||
"privacy": "Private life" | ||
} |
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,3 @@ | ||
{ | ||
"privacy": "Vie privée" | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/privacy/Subscriber/Administration/PrivacySubscriber.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,39 @@ | ||
<?php | ||
|
||
namespace Claroline\PrivacyBundle\Subscriber\Administration; | ||
|
||
use Claroline\CoreBundle\API\Serializer\ParametersSerializer; | ||
use Claroline\CoreBundle\Entity\Tool\Tool; | ||
use Claroline\CoreBundle\Event\CatalogEvents\ToolEvents; | ||
use Claroline\CoreBundle\Event\Tool\OpenToolEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class PrivacySubscriber implements EventSubscriberInterface | ||
{ | ||
const NAME = 'privacy'; | ||
|
||
private ParametersSerializer $serializer; | ||
|
||
public function __construct( | ||
ParametersSerializer $serializer, | ||
) { | ||
$this->serializer = $serializer; | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ToolEvents::getEventName(ToolEvents::OPEN, Tool::ADMINISTRATION, static::NAME) => 'onOpen', | ||
]; | ||
} | ||
|
||
public function onOpen(OpenToolEvent $event): void | ||
{ | ||
$parameters = $this->serializer->serialize(); | ||
|
||
$event->setData([ | ||
'lockedParameters' => $parameters['lockedParameters'] ?? [], | ||
'parameters' => $parameters, | ||
]); | ||
} | ||
} |