fix conflicts when merging master

This commit is contained in:
nobohan
2022-01-04 15:56:32 +01:00
477 changed files with 6052 additions and 2047 deletions

View File

@@ -39,6 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Serializer\SerializerInterface;
use function array_key_exists;
final class ActivityController extends AbstractController
@@ -307,8 +308,10 @@ final class ActivityController extends AbstractController
$activityData = $request->query->get('activityData');
}
if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType
|| !$activityType->isActive()) {
if (
!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType
|| !$activityType->isActive()
) {
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
if (null !== $activityData) {

View File

@@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;

View File

@@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Form\ActivityReasonType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;

View File

@@ -19,6 +19,7 @@ use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
/**

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int;
/**

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;

View File

@@ -27,6 +27,7 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
use function in_array;
@@ -189,7 +190,9 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {

View File

@@ -25,6 +25,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;

View File

@@ -24,6 +24,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface

View File

@@ -31,6 +31,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface

View File

@@ -48,6 +48,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array;
class ActivityType extends AbstractType

View File

@@ -36,8 +36,10 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{
$period = $parameters['accompanyingCourse'];
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()
&& $this->security->isGranted(ActivityVoter::SEE, $period)) {
if (
AccompanyingPeriod::STEP_DRAFT !== $period->getStep()
&& $this->security->isGranted(ActivityVoter::SEE, $period)
) {
$menu->addChild($this->translator->trans('Activity'), [
'route' => 'chill_activity_activity_list',
'routeParameters' => [

View File

@@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security;
use function in_array;
final class AdminMenuBuilder implements LocalMenuBuilderInterface

View File

@@ -22,6 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
use function count;
use function in_array;
@@ -167,7 +168,9 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
// we get the ids for those scopes
$reachablesScopesId = array_map(
static function (Scope $scope) { return $scope->getId(); },
static function (Scope $scope) {
return $scope->getId();
},
$reachableScopes
);

View File

@@ -17,6 +17,14 @@ const getLocations = () => fetchResults('/api/1.0/main/location.json');
const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json');
const getUserCurrentLocation =
() => fetch('/api/1.0/main/user-current-location.json')
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
/*
* Load Location Type by defaultFor
* @param {string} entity - can be "person" or "thirdparty"
@@ -48,5 +56,6 @@ export {
getLocations,
getLocationTypes,
getLocationTypeByDefaultFor,
postLocation
postLocation,
getUserCurrentLocation
};

View File

@@ -1,8 +1,7 @@
<template>
<li>
<span :title="person.text">
<span class="chill_denomination">{{ textCutted }}</span>
<a @click.prevent="$emit('remove', person)"></a>
<span class="chill_denomination" @click.prevent="$emit('remove', person)">{{ textCutted }}</span>
</span>
</li>
</template>

View File

@@ -15,7 +15,7 @@
:searchable="true"
:placeholder="$t('activity.choose_location')"
:custom-label="customLabel"
:options="locations"
:options="availableLocations"
group-values="locations"
group-label="locationGroup"
v-model="location"
@@ -32,7 +32,7 @@
import { mapState, mapGetters } from "vuex";
import VueMultiselect from "vue-multiselect";
import NewLocation from "./Location/NewLocation.vue";
import { getLocations, getLocationTypeByDefaultFor } from "../api.js";
import { getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation } from "../api.js";
export default {
name: "Location",
@@ -40,13 +40,8 @@ export default {
NewLocation,
VueMultiselect,
},
data() {
return {
locations: [],
};
},
computed: {
...mapState(["activity"]),
...mapState(["activity", "availableLocations"]),
...mapGetters(["suggestedEntities"]),
location: {
get() {
@@ -57,53 +52,6 @@ export default {
},
},
},
mounted() {
getLocations().then(
(results) => {
getLocationTypeByDefaultFor('person').then(
(personLocationType) => {
if (personLocationType) {
const personLocation = this.makeAccompanyingPeriodLocation(personLocationType);
const concernedPersonsLocation =
this.makeConcernedPersonsLocation(personLocationType);
getLocationTypeByDefaultFor('thirdparty').then(
thirdpartyLocationType => {
const concernedThirdPartiesLocation =
this.makeConcernedThirdPartiesLocation(thirdpartyLocationType);
this.locations = [
{
locationGroup: 'Localisation du parcours',
locations: [personLocation]
},
{
locationGroup: 'Parties concernées',
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]
},
{
locationGroup: 'Autres localisations',
locations: results
}
];
}
)
} else {
this.locations = [
{
locationGroup: 'Localisations',
locations: response.results
}
];
}
if (window.default_location_id) {
let location = this.locations.filter(
(l) => l.id === window.default_location_id
);
this.$store.dispatch("updateLocation", location);
}
}
)
})
},
methods: {
labelAccompanyingCourseLocation(value) {
return `${value.address.text} (${value.locationType.title.fr})`
@@ -117,58 +65,6 @@ export default {
: value.locationType.title.fr
: '';
},
makeConcernedPersonsLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
id: e.current_household_address.address_id,
},
locationType: locationType
});
}
}
)
return locations;
},
makeConcernedThirdPartiesLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
locationType: locationType
});
}
}
)
return locations;
},
makeAccompanyingPeriodLocation(locationType) {
const accPeriodLocation = this.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {
id: accPeriodLocation.address_id,
text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}`
},
locationType: locationType
}
}
},
};
</script>

View File

@@ -1,6 +1,7 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postLocation } from './api';
import prepareLocations from './store.locations.js';
const debug = process.env.NODE_ENV !== 'production';
//console.log('window.activity', window.activity);
@@ -25,6 +26,7 @@ const store = createStore({
activity: window.activity,
socialIssuesOther: [],
socialActionsList: [],
availableLocations: [],
},
getters: {
suggestedEntities(state) {
@@ -200,6 +202,9 @@ const store = createStore({
console.log("### mutation: updateLocation", value);
state.activity.location = value;
},
addAvailableLocationGroup(state, group) {
state.availableLocations.push(group);
}
},
actions: {
addIssueSelected({ commit }, issue) {
@@ -335,4 +340,6 @@ const store = createStore({
},
});
prepareLocations(store);
export default store;

View File

@@ -0,0 +1,123 @@
import {getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation} from "./api";
const makeConcernedPersonsLocation = (locationType, store) => {
let locations = [];
store.getters.suggestedEntities.forEach(
(e) => {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -store.getters.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
id: e.current_household_address.address_id,
},
locationType: locationType
});
}
}
)
return locations;
};
const makeConcernedThirdPartiesLocation = (locationType, store) => {
let locations = [];
store.getters.suggestedEntities.forEach(
(e) => {
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -store.getters.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
locationType: locationType
});
}
}
)
return locations;
};
const makeAccompanyingPeriodLocation = (locationType, store) => {
const accPeriodLocation = store.state.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {
id: accPeriodLocation.address_id,
text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}`
},
locationType: locationType
}
};
export default function prepareLocations(store) {
// find the locations
let allLocations = getLocations().then(
(results) => {
store.commit('addAvailableLocationGroup', {
locationGroup: 'Autres localisations',
locations: results
});
}
);
let currentLocation = getUserCurrentLocation().then(
userCurrentLocation => {
if (null !== userCurrentLocation) {
store.commit('addAvailableLocationGroup', {
locationGroup: 'Ma localisation',
locations: [userCurrentLocation]
});
}
}
);
let partiesLocations = [], partyPromise;
['person', 'thirdparty'].forEach(kind => {
partyPromise = getLocationTypeByDefaultFor(kind).then(
(kindLocationType) => {
if (kindLocationType) {
let concernedKindLocations;
if (kind === 'person') {
concernedKindLocations = makeConcernedPersonsLocation(kindLocationType, store);
// add location for the parcours into suggestions
const personLocation = makeAccompanyingPeriodLocation(kindLocationType, store);
store.commit('addAvailableLocationGroup', {
locationGroup: 'Localisation du parcours',
locations: [personLocation]
});
} else {
concernedKindLocations = makeConcernedThirdPartiesLocation(kindLocationType, store);
}
store.commit('addAvailableLocationGroup', {
locationGroup: kind === 'person' ? 'Usagers concernés' : 'Tiers concernés',
locations: concernedKindLocations,
});
}
}
);
partiesLocations.push(partyPromise);
});
// when all location are loaded
Promise.all([allLocations, currentLocation, ...partiesLocations]).then(() => {
console.log('current location in activity', store.state.activity.location);
console.log('default loation id', window.default_location_id);
if (window.default_location_id) {
for (let group of store.state.availableLocations) {
console.log(group);
let location = group.locations.find((l) => l.id === window.default_location_id);
console.log(location);
if (location !== undefined) {
store.dispatch('updateLocation', location);
break;
}
}
}
});
}

View File

@@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\Request;
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
) {

View File

@@ -127,24 +127,25 @@
</div>
{% endif %}
{% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
<div class="wl-row">
<div class="wl-col title">
<h3>{{ 'Comment'|trans }}</h3>
</div>
<div class="wl-col list">
{{ activity.comment|chill_entity_render_box({
'disable_markdown': false,
'limit_lines': 3,
'metadata': false
}) }}
</div>
</div>
{% endif %}
{# Only if ACL SEE_DETAILS AND/OR only on template SHOW ??
durationTime
travelTime
comment
{% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
<div class="wl-row">
<div class="wl-col title">
<h3>{{ 'Comment'|trans }}</h3>
</div>
<div class="wl-col list">
{{ activity.comment|chill_entity_render_box({
'disable_markdown': false,
'limit_lines': 3,
'metadata': false
}) }}
</div>
</div>
{% endif %}
documents
attendee
#}

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use function in_array;
class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
@@ -64,8 +65,10 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
protected function supports($attribute, $subject)
{
if ($subject instanceof Center
&& in_array($attribute, $this->getAttributes(), true)) {
if (
$subject instanceof Center
&& in_array($attribute, $this->getAttributes(), true)
) {
return true;
}

View File

@@ -24,6 +24,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface

View File

@@ -26,7 +26,7 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
*/
private $aggregator;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -26,7 +26,7 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
*/
private $aggregator;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -26,7 +26,7 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest
*/
private $aggregator;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -24,7 +24,7 @@ final class CountActivityTest extends AbstractExportTest
*/
private $export;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -24,7 +24,7 @@ final class ListActivityTest extends AbstractExportTest
*/
private $export;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -26,7 +26,7 @@ final class StatActivityDurationSumTest extends AbstractExportTest
*/
private $export;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -25,7 +25,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
*/
private $filter;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -26,7 +26,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
*/
private $filter;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -45,7 +45,7 @@ final class ActivityTypeTest extends KernelTestCase
*/
protected $user;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -29,7 +29,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
*/
private static $prophet;
public function setUp()
protected function setUp(): void
{
parent::setUp();
}

View File

@@ -31,7 +31,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
*/
protected $container;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -44,7 +44,7 @@ final class ActivityVoterTest extends KernelTestCase
*/
protected $voter;
public function setUp()
protected function setUp(): void
{
self::bootKernel();
$this->voter = self::$kernel->getContainer()

View File

@@ -24,6 +24,7 @@ use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use function implode;
use function in_array;
use function strtr;

View File

@@ -17,6 +17,7 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function array_merge;
use function count;

View File

@@ -13,6 +13,7 @@ namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use function count;
/**

View File

@@ -19,6 +19,7 @@ use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function random_int;
class LoadAsideActivity extends Fixture implements DependentFixtureInterface

View File

@@ -18,10 +18,12 @@ class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture
{
public function load(ObjectManager $manager)
{
foreach ([
'Appel téléphonique',
'Formation',
] as $key => $label) {
foreach (
[
'Appel téléphonique',
'Formation',
] as $key => $label
) {
$category = new AsideActivityCategory();
$category->setTitle(['fr' => $label]);
$manager->persist($category);

View File

@@ -13,6 +13,7 @@ namespace Chill\AsideActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int;
class Configuration implements ConfigurationInterface

View File

@@ -32,6 +32,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array;
final class AsideActivityFormType extends AbstractType

View File

@@ -13,6 +13,7 @@ namespace Chill\AsideActivityBundle\Menu;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security;
use function in_array;
final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface

View File

@@ -26,7 +26,7 @@ final class AsideActivityControllerTest extends WebTestCase
{
use PrepareClientTrait;
public function setUp()
protected function setUp(): void
{
parent::setUp();
self::bootKernel();

View File

@@ -13,6 +13,7 @@ namespace Chill\AMLI\BudgetBundle\Calculator;
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
use OutOfBoundsException;
use function array_key_exists;
use function array_keys;
use function implode;

View File

@@ -21,6 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use function get_class;
abstract class AbstractElementController extends Controller

View File

@@ -22,6 +22,7 @@ use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Translation\TranslatorInterface;
use function array_merge;
use function count;

View File

@@ -21,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_flip;
use function asort;

View File

@@ -21,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_flip;
class ResourceType extends AbstractType

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role;
use function in_array;
class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface

View File

@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function count;
class CalendarRangeAPIController extends ApiController

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use function in_array;
/**

View File

@@ -14,6 +14,7 @@ namespace Chill\CalendarBundle\Event;
use Chill\ActivityBundle\Entity\Activity;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\HttpFoundation\RequestStack;
use function array_key_exists;
class ListenToActivityCreate

View File

@@ -20,7 +20,6 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\CommentType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable;
use Doctrine\Persistence\ObjectManager;

View File

@@ -1,6 +1,10 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api';
import {
getLocations, getLocationTypeByDefaultFor,
getUserCurrentLocation
} from "../../../../../ChillActivityBundle/Resources/public/vuejs/Activity/api";
const debug = process.env.NODE_ENV !== 'production';
@@ -82,7 +86,7 @@ const store = createStore({
}
},
mutations: {
// ConcernedGroups
addPersonsInvolved(state, payload) {
//console.log('### mutation addPersonsInvolved', payload.result.type);
@@ -94,7 +98,7 @@ const store = createStore({
state.activity.thirdParties.push(payload.result);
break;
case 'user':
state.activity.users.push(payload.result);
state.activity.users.push(payload.result);
break;
};
},
@@ -108,7 +112,7 @@ const store = createStore({
state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload);
break;
case 'user':
state.activity.users = state.activity.users.filter(user => user !== payload);
state.activity.users = state.activity.users.filter(user => user !== payload);
break;
};
},
@@ -217,9 +221,7 @@ const store = createStore({
hiddenLocation.value = value.id;
}
commit("updateLocation", value);
}
}
});

View File

@@ -92,8 +92,11 @@
%}
<div class="item-row details">
<div class="item-col">
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': accompanyingCourse, 'with_display': 'row', 'entity': calendar } %}
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {
'context': accompanyingCourse,
'with_display': 'row',
'entity': calendar
} %}
</div>
{% if calendar.comment.comment is not empty %}
@@ -123,4 +126,4 @@
</li>
</ul>
{% endblock %}
{% endblock %}

View File

@@ -26,7 +26,7 @@ final class CalendarControllerTest extends WebTestCase
/**
* Setup before each test method (see phpunit doc).
*/
public function setUp()
protected function setUp(): void
{
self::bootKernel();
$this->client = self::createClient([], [

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Console\Question\Question;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
use function count;
/**

View File

@@ -23,6 +23,7 @@ use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
use function count;
use function in_array;

View File

@@ -135,7 +135,7 @@ class CustomFieldDate extends AbstractCustomField
return null;
}
return $date->format('Y-m-d');
return $date->format('Y-m-d');
default:
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.'

View File

@@ -21,6 +21,7 @@ use LogicException;
use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use function get_class;
use function gettype;
use function is_object;

View File

@@ -18,7 +18,6 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\LessThanOrEqual;

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use function array_key_exists;
class CustomFieldText extends AbstractCustomField
@@ -65,8 +66,10 @@ class CustomFieldText extends AbstractCustomField
$attrArray = [];
if (array_key_exists(self::MULTIPLE_CF_INLINE, $options)
&& $options[self::MULTIPLE_CF_INLINE]) {
if (
array_key_exists(self::MULTIPLE_CF_INLINE, $options)
&& $options[self::MULTIPLE_CF_INLINE]
) {
$attrArray['class'] = 'multiple-cf-inline';
}

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
class CustomFieldsGroupType extends AbstractType

View File

@@ -15,6 +15,7 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use function gettype;
class CustomFieldsGroupToIdTransformer implements DataTransformerInterface

View File

@@ -14,7 +14,9 @@ namespace Chill\CustomFieldsBundle\Form\DataTransformer;
use Chill\CustomFieldsBundle\Entity\CustomField;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface;
use function array_key_exists;
use const JSON_THROW_ON_ERROR;
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
@@ -33,7 +35,9 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
// @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
$customFieldsLablels = array_map(
static function ($e) { return $e->getLabel(); },
static function ($e) {
return $e->getLabel();
},
$customFields
);

View File

@@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_key_exists;
/**

View File

@@ -17,7 +17,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class ChoicesListType extends AbstractType

View File

@@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\Request;
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
) {

View File

@@ -37,7 +37,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase
*/
private $cfProvider;
public function setUp()
protected function setUp(): void
{
self::bootKernel();
@@ -46,7 +46,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase
$this->cfChoice = $this->cfProvider->getCustomFieldByType('choice');
}
public function tearDown()
protected function tearDown(): void
{
parent::tearDown();
}

View File

@@ -34,7 +34,7 @@ final class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\
*/
private $formBuilder;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -28,7 +28,7 @@ final class CustomFieldsTextTest extends WebTestCase
*/
private $customFieldProvider;
public function setUp()
protected function setUp(): void
{
self::bootKernel();
$this->customFieldProvider = self::$kernel->getContainer()

View File

@@ -27,7 +27,7 @@ final class PostTextIntegerExtensionTest extends KernelTestCase
*/
private $formBuilder;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -27,7 +27,7 @@ final class PostTextNumberExtensionTest extends KernelTestCase
*/
private $formBuilder;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -33,7 +33,7 @@ final class CustomFieldsHelperTest extends KernelTestCase
*/
private $randomCFText;
public function setUp()
protected function setUp(): void
{
self::bootKernel();

View File

@@ -34,7 +34,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase
*/
private $cfRendering;
public function setUp()
protected function setUp(): void
{
self::bootKernel();
$this->cfRendering = self::$kernel->getContainer()

View File

@@ -36,7 +36,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase
*/
private $cfRendering;
public function setUp()
protected function setUp(): void
{
self::bootKernel();
$this->cfRendering = self::$kernel->getContainer()

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Context\Exception;
use LogicException;
use function get_class;
use function gettype;
use function is_object;

View File

@@ -28,12 +28,10 @@ use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
// TODO à mettre dans services
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -42,7 +40,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -206,8 +203,10 @@ final class DocGeneratorTemplateController extends AbstractController
$contextGenerationData = [];
if ($context instanceof DocGeneratorContextWithPublicFormInterface
&& $context->hasPublicForm($template, $entity) || $isTest) {
if (
$context instanceof DocGeneratorContextWithPublicFormInterface
&& $context->hasPublicForm($template, $entity) || $isTest
) {
if ($context instanceof DocGeneratorContextWithPublicFormInterface) {
$builder = $this->createFormBuilder(
array_merge(

View File

@@ -54,8 +54,10 @@ class DocGeneratorTemplateType extends AbstractType
'required' => true,
]);
if ($context instanceof DocGeneratorContextWithAdminFormInterface
&& $context->hasAdminForm()) {
if (
$context instanceof DocGeneratorContextWithAdminFormInterface
&& $context->hasAdminForm()
) {
$sub = $builder
->create('options', null, ['compound' => true])
->addModelTransformer(new CallbackTransformer(

View File

@@ -46,6 +46,7 @@ class RelatorioDriver implements DriverInterface
'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType),
];
$form = new FormDataPart($formFields);
dump(json_encode($data));
try {
$response = $this->relatorioClient->request('POST', $this->url, [

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class AdminMenuBuilder implements LocalMenuBuilderInterface

View File

@@ -11,13 +11,15 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Serializer\Encoder;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use function array_keys;
use function is_array;
class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInterface
class DocGenEncoder implements EncoderInterface
{
public function encode($data, string $format, array $context = [])
public function encode($data, $format, array $context = [])
{
if (!$this->isAssociative($data)) {
throw new UnexpectedValueException('Only associative arrays are allowed; lists are not allowed');
@@ -29,7 +31,7 @@ class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInte
return $result;
}
public function supportsEncoding(string $format)
public function supportsEncoding($format)
{
return 'docgen' === $format;
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Serializer\Helper;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use function array_merge;
class NormalizeNullValueHelper

View File

@@ -26,10 +26,11 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
/**
* @param Collection $object
* @param null|string $format
*
* @return array|ArrayObject|bool|float|int|string|void|null
*/
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, $format = null, array $context = [])
{
$data = [];
@@ -44,7 +45,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
return $data;
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ('docgen' !== $format) {
return false;

View File

@@ -26,6 +26,7 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use function array_filter;
use function array_key_exists;
use function array_merge;
@@ -54,7 +55,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
$this->translatableStringHelper = $translatableStringHelper;
}
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, $format = null, array $context = [])
{
$classMetadataKey = $object ?? $context['docgen:expects'] ?? null;
@@ -65,7 +66,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
if (!$this->classMetadataFactory->hasMetadataFor($classMetadataKey)) {
throw new LogicException(sprintf(
'This object does not have metadata: %s. Add groups on this entity to allow to serialize with the format %s and groups %s',
is_object($object) ? get_class($object) : '(todo' /*$context['docgen:expects'],*/ ,
is_object($object) ? get_class($object) : '(todo' /*$context['docgen:expects'],*/,
$format,
implode(', ', ($context['groups'] ?? []))
));
@@ -95,7 +96,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
return $this->normalizeObject($object, $format, $context, $expectedGroups, $metadata, $attributes);
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return 'docgen' === $format && (is_object($data) || null === $data);
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Service\Context;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class BaseContextData
{
private NormalizerInterface $normalizer;
private Security $security;
public function __construct(Security $security, NormalizerInterface $normalizer)
{
$this->security = $security;
$this->normalizer = $normalizer;
}
public function getData(): array
{
$data = [];
$user = $this->security->getUser();
$data['creator'] = $this->normalizer->normalize(
$user instanceof User ? $user : null,
'docgen',
['docgen:expects' => User::class, 'groups' => ['docgen:read']]
);
$data['createdAt'] = $this->normalizer->normalize(new DateTimeImmutable(), 'docgen', [
'docgen:expects' => DateTimeImmutable::class, 'groups' => ['docgen:read'],
]);
$data['location'] = $this->normalizer->normalize(
$user instanceof User ? $user->getCurrentLocation() : null,
'docgen',
['docgen:expects' => Location::class, 'groups' => ['docgen:read']]
);
return $data;
}
}

View File

@@ -34,6 +34,11 @@ services:
autowire: true
autoconfigure: true
Chill\DocGeneratorBundle\Service\Context\:
resource: "../Service/Context/"
autowire: true
autoconfigure: true
Chill\DocGeneratorBundle\GeneratorDriver\:
resource: "../GeneratorDriver/"
autowire: true

View File

@@ -23,7 +23,7 @@ final class DocGenEncoderTest extends TestCase
{
private DocGenEncoder $encoder;
protected function setUp()
protected function setUp(): void
{
parent::setUp();

View File

@@ -25,7 +25,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
{
private NormalizerInterface $normalizer;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
self::bootKernel();

View File

@@ -0,0 +1,68 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\DocGeneratorBundle\tests\Service\Context;
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
use Chill\MainBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* @internal
* @coversNothing
*/
final class BaseContextDataTest extends KernelTestCase
{
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
}
public function testGenerateNoContext()
{
$context = $this->buildBaseContext();
$actual = $context->getData();
$this->assertIsArray($actual);
$this->assertArrayHasKey('creator', $actual);
$this->assertArrayHasKey('createdAt', $actual);
$this->assertArrayHasKey('location', $actual);
}
public function testGenerateWithUser()
{
$security = $this->prophesize(Security::class);
$security->getUser()->willReturn(new User());
$context = $this->buildBaseContext($security->reveal());
$actual = $context->getData();
$this->assertIsArray($actual);
$this->assertArrayHasKey('creator', $actual);
$this->assertArrayHasKey('createdAt', $actual);
$this->assertArrayHasKey('location', $actual);
}
private function buildBaseContext(
?Security $security = null,
?NormalizerInterface $normalizer = null
): BaseContextData {
return new BaseContextData(
$security ?? self::$container->get(Security::class),
$normalizer ?? self::$container->get(NormalizerInterface::class)
);
}
}

View File

@@ -24,7 +24,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
/**
@@ -100,7 +99,7 @@ class DocumentPersonController extends AbstractController
$document,
[
'center' => $document->getCenter(),
'role' => new Role('CHILL_PERSON_DOCUMENT_UPDATE'),
'role' => 'CHILL_PERSON_DOCUMENT_UPDATE',
]
);
$form->handleRequest($request);
@@ -160,7 +159,7 @@ class DocumentPersonController extends AbstractController
$reachableScopes = $this->authorizationHelper
->getReachableScopes(
$this->getUser(),
new Role(PersonDocumentVoter::SEE),
PersonDocumentVoter::SEE,
$person->getCenter()
);
@@ -204,7 +203,7 @@ class DocumentPersonController extends AbstractController
$form = $this->createForm(PersonDocumentType::class, $document, [
'center' => $document->getCenter(),
'role' => new Role('CHILL_PERSON_DOCUMENT_CREATE'),
'role' => 'CHILL_PERSON_DOCUMENT_CREATE',
]);
$form->handleRequest($request);

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
/**

View File

@@ -93,7 +93,7 @@ class PersonDocumentType extends AbstractType
]);
$resolver->setRequired(['role', 'center'])
->setAllowedTypes('role', [\Symfony\Component\Security\Core\Role\Role::class])
->setAllowedTypes('role', ['string'])
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]);
}
}

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function json_decode;
use function json_encode;

View File

@@ -34,9 +34,6 @@ var download = (button) => {
key, url
;
console.log('keyData', keyData);
console.log('ivData', ivData);
button.textContent = labelPreparing;
window.fetch(urlGenerator)
@@ -48,36 +45,25 @@ var download = (button) => {
}
})
.then(data => {
url = data.url;
if (keyData.length > 0) {
return window.crypto.subtle.importKey('jwk', keyData, { name: algo, iv: iv}, false, ['decrypt']);
}
return Promise.resolve(undefined);
return window.fetch(data.url);
})
.then(nKey => {
key = nKey;
return window.fetch(url);
})
.then(r => {
console.log('r', r);
if (r.ok) {
return r.arrayBuffer();
} else {
throw new Error(r.status + r.statusText);
.then(response => {
if (response.ok) {
return response.arrayBuffer();
}
throw new Error(response.status + response.statusText);
})
.then(buffer => {
console.log('buffer', buffer);
if (keyData.length > 0) {
return window.crypto.subtle.decrypt({ name: algo, iv: iv }, key, buffer);
if (keyData.alg !== undefined) {
return window.crypto.subtle
.importKey('jwk', keyData, { name: algo, iv: iv}, false, ['decrypt'])
.then(key => {
return window.crypto.subtle.decrypt({ name: algo, iv: iv }, key, buffer);
});
}
return Promise.resolve(buffer);
})
.then(decrypted => {
console.log('decrypted', decrypted);
var
blob = new Blob([decrypted], { type: mimeType }),
url = window.URL.createObjectURL(blob)
@@ -96,7 +82,6 @@ var download = (button) => {
button.click();
})
.catch(error => {
console.log(error);
button.textContent = "";
button.appendChild(document.createTextNode("error while handling decrypted file"));
})

View File

@@ -32,7 +32,11 @@
{{ form_row(form.title) }}
{{ form_row(form.date) }}
{{ form_row(form.category) }}
{{ form_row(form.scope) }}
{% if form.scope is defined %}
{{ form_row(form.scope) }}
{% endif %}
{{ form_row(form.description) }}
{{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }}

View File

@@ -22,6 +22,7 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
@@ -101,8 +102,10 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
return false;
}
if (AccompanyingPeriod::STEP_CLOSED === $subject->getCourse()->getStep()
&& in_array($attribute, [self::CREATE, self::DELETE, self::UPDATE], true)) {
if (
AccompanyingPeriod::STEP_CLOSED === $subject->getCourse()->getStep()
&& in_array($attribute, [self::CREATE, self::DELETE, self::UPDATE], true)
) {
return false;
}
}

View File

@@ -95,8 +95,10 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera
return false;
}
if ($subject instanceof PersonDocument
&& !$this->security->isGranted(PersonVoter::SEE, $subject->getPerson())) {
if (
$subject instanceof PersonDocument
&& !$this->security->isGranted(PersonVoter::SEE, $subject->getPerson())
) {
return false;
}

View File

@@ -39,6 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
/**

Some files were not shown because too many files have changed in this diff Show More