Merge branch 'issue126_household_list' into 'master'

household list of accompanying periods + upgrade DBAL version to 3.1


# Description of changes

* Household: List of accompanying periods shows all periods linked to current household members for which viewing access is granted to current user.
* Upgrade DBAL to 3.1


# Issues related

* inernal: https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/274
* ACCent: https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/126

# Tests

Not yet written

See merge request Chill-Projet/chill-bundles!204
This commit is contained in:
Julien Fastré 2021-11-08 10:57:14 +00:00
commit 21e419b338
49 changed files with 353 additions and 286 deletions

View File

@ -25,10 +25,12 @@ and this project adheres to
* [person] show current address in search results
* [person] show alt names in search results
* [admin]: links to activity admin section added again.
* [household]: View accompanying periods of current and old household members.
* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
* [admin]: links to activity admin section added again.
* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top.
* [socialWorkAction]: display of social issue and parent issues + banner context added.
* [DBAL dependencies] Upgrade to DBAL 3.1
## Test releases

View File

@ -1,19 +1,19 @@
<?php
/*
*
*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -44,7 +44,7 @@ class ActivityReason
/**
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -108,7 +108,7 @@ class ActivityReason
return $this->name;
}
}
/**
* Set category of the reason. If you set to the reason an inactive
* category, the reason will become inactive
@ -121,7 +121,7 @@ class ActivityReason
if($this->category !== $category && ! $category->getActive()) {
$this->setActive(False);
}
$this->category = $category;
return $this;

View File

@ -2,17 +2,17 @@
/*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -43,7 +43,7 @@ class ActivityReasonCategory
/**
* @var string
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -52,7 +52,7 @@ class ActivityReasonCategory
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* Array of ActivityReason
* @var ArrayCollection
@ -61,7 +61,7 @@ class ActivityReasonCategory
* mappedBy="category")
*/
private $reasons;
/**
* ActivityReasonCategory constructor.
*/
@ -69,7 +69,7 @@ class ActivityReasonCategory
{
$this->reasons = new ArrayCollection();
}
/**
* @return string
*/
@ -139,9 +139,9 @@ class ActivityReasonCategory
$reason->setActive($active);
}
}
$this->active = $active;
return $this;
}

View File

@ -44,7 +44,7 @@ class ActivityType
private ?int $id;
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private array $name = [];

View File

@ -40,7 +40,7 @@ class ActivityTypeCategory
private ?int $id;
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private array $name = [];

View File

@ -71,7 +71,7 @@ class TranslatableActivityType extends AbstractType
if ($options['active_only'] === true) {
$qb->where($qb->expr()->eq('at.active', ':active'));
$qb->setParameter('active', true, \Doctrine\DBAL\Types\Type::BOOLEAN);
$qb->setParameter('active', true, \Doctrine\DBAL\Types\Types::BOOLEAN);
}
}

View File

@ -4,7 +4,7 @@ namespace Chill\Migrations\Activity;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
/**
* Add an "active" column on activitytype table

View File

@ -22,7 +22,6 @@ final class Version20210401090853 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE activitytypecategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1000');
$this->addSql('CREATE TABLE activitytypecategory (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN activitytypecategory.name IS \'(DC2Type:json_array)\'');
$this->addSql('INSERT INTO activitytypecategory VALUES(1, \'{"fr": "Défaut", "en": "Default"}\', true)');
}

View File

@ -51,7 +51,6 @@ final class Version20210408122329 extends AbstractMigration
$this->addSql('ALTER TABLE activitytype ADD socialDataLabel VARCHAR(255) DEFAULT \'\' NOT NULL');
$this->addSql('ALTER TABLE activitytype ALTER name SET NOT NULL');
$this->addSql('ALTER TABLE activitytype ALTER active DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN activitytype.name IS \'(DC2Type:json_array)\'');
}
public function down(Schema $schema) : void

View File

@ -34,7 +34,7 @@ class CancelReason
private $canceledBy;
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name = [];

View File

@ -25,7 +25,7 @@ class Invite
private User $user;
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private array $status = [];

View File

@ -50,10 +50,7 @@ final class Version20210715141731 extends AbstractMigration
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('CREATE TABLE chill_calendar.cancel_reason (id INT NOT NULL, active BOOLEAN NOT NULL, canceledBy JSON NOT NULL, name JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.name IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledBy IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE TABLE chill_calendar.invite (id INT NOT NULL, user_id INT DEFAULT NULL, status JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_calendar.invite.status IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE INDEX IDX_F517FFA7A76ED395 ON chill_calendar.invite (user_id)');
$this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315ACD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
@ -74,7 +71,7 @@ final class Version20210715141731 extends AbstractMigration
}
public function down(Schema $schema): void
{
{
$this->addSql('ALTER TABLE chill_calendar.calendar_to_persons DROP CONSTRAINT FK_AEE94715A40A2C8');
$this->addSql('ALTER TABLE chill_calendar.calendar_to_non_professionals DROP CONSTRAINT FK_FADF2C77A40A2C8');
$this->addSql('ALTER TABLE chill_calendar.calendar_to_thirdparties DROP CONSTRAINT FK_2BAB7EFDA40A2C8');

View File

@ -34,6 +34,5 @@ final class Version20210723074557 extends AbstractMigration
$this->addSql('ALTER TABLE chill_calendar.calendar_to_non_professionals ADD CONSTRAINT fk_fadf2c77217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy TYPE JSON');
$this->addSql('ALTER TABLE chill_calendar.cancel_reason ALTER canceledBy DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN chill_calendar.cancel_reason.canceledby IS \'(DC2Type:json_array)\'');
}
}

View File

@ -40,7 +40,7 @@ class CustomField
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
@ -61,18 +61,18 @@ class CustomField
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $options = array();
/**
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -82,14 +82,14 @@ class CustomField
* @ORM\Column(type="float")
*/
private $ordering;
/**
* @var boolean
*
* @ORM\Column(type="boolean")
*/
private $required = FALSE;
const ONE_TO_ONE = 1;
const ONE_TO_MANY = 2;
@ -102,7 +102,7 @@ class CustomField
*/
private $customFieldGroup;
/**
* Get id
*
@ -112,7 +112,7 @@ class CustomField
{
return $this->id;
}
/**
* @return string
*/
@ -120,15 +120,15 @@ class CustomField
{
return $this->slug;
}
/**
* @return array
*/
function getOptions()
{
return $this->options;
}
}
/**
* Set type
*
@ -152,7 +152,7 @@ class CustomField
return $this->type;
}
/**
* Set active
*
@ -229,9 +229,9 @@ class CustomField
}
}
}
return '';
} else {
return $this->name;
};
@ -272,7 +272,7 @@ class CustomField
return $this;
}
/**
* @param $slug
* @return $this
@ -282,20 +282,20 @@ class CustomField
$this->slug = $slug;
return $this;
}
/**
* alias for isRequired
*
*
* @return boolean
*/
public function getRequired()
{
return $this->isRequired();
}
/**
* return true if the field required
*
*
* @return boolean
*/
public function isRequired()
@ -308,5 +308,5 @@ class CustomField
$this->required = $required;
return $this;
}
}

View File

@ -39,21 +39,21 @@ class Option
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
* @ORM\Column(type="string", length=15)
*/
private $key;
/**
* A json representation of text (multilingual)
*
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $text;
/**
* @var Collection
* @ORM\OneToMany(
@ -61,7 +61,7 @@ class Option
* mappedBy="parent")
*/
private $children;
/**
* @var Option
* @ORM\ManyToOne(
@ -70,19 +70,19 @@ class Option
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
/**
* @var string
* @ORM\Column(type="string", length=50, name="internal_key")
*/
private $internalKey = '';
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @return int
*/
@ -90,7 +90,7 @@ class Option
{
return $this->id;
}
/**
* @return string
*/
@ -98,7 +98,7 @@ class Option
{
return $this->key;
}
/**
* @return array
*/
@ -106,7 +106,7 @@ class Option
{
return $this->text;
}
/**
* @return Collection
*/
@ -114,7 +114,7 @@ class Option
{
return $this->children;
}
/**
* @return Option
*/
@ -122,7 +122,7 @@ class Option
{
return $this->parent;
}
/**
* @param $key
* @return $this
@ -132,7 +132,7 @@ class Option
$this->key = $key;
return $this;
}
/**
* @param array $text
* @return $this
@ -142,7 +142,7 @@ class Option
$this->text = $text;
return $this;
}
/**
* @param Option|null $parent
* @return $this
@ -153,16 +153,16 @@ class Option
$this->key = $parent->getKey();
return $this;
}
/**
*
*
* @return boolean
*/
public function hasParent()
{
return $this->parent === NULL ? false : true;
}
/**
* @return string
*/
@ -170,7 +170,7 @@ class Option
{
return $this->internalKey;
}
/**
* @return bool
*/
@ -178,7 +178,7 @@ class Option
{
return $this->active;
}
/**
* @return bool
*/
@ -186,7 +186,7 @@ class Option
{
return $this->isActive();
}
/**
* @param $internal_key
* @return $this
@ -196,7 +196,7 @@ class Option
$this->internalKey = $internal_key;
return $this;
}
/**
* @param $active
* @return $this
@ -206,5 +206,5 @@ class Option
$this->active = $active;
return $this;
}
}

View File

@ -45,7 +45,7 @@ class CustomFieldsGroup
/**
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -76,15 +76,15 @@ class CustomFieldsGroup
* @var array|null
*/
private $activeCustomFields = null;
/**
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $options = array();
/**
* CustomFieldsGroup constructor.
*/
@ -115,7 +115,7 @@ class CustomFieldsGroup
{
$this->customFields->removeElement($customField);
}
/**
* @return Collection
*/
@ -142,7 +142,7 @@ class CustomFieldsGroup
return $this->activeCustomFields;
}
/**
* Get id
*
@ -184,9 +184,9 @@ class CustomFieldsGroup
}
}
}
return '';
} else {
return $this->name;
}
@ -214,10 +214,10 @@ class CustomFieldsGroup
{
return $this->entity;
}
/**
* get options array
*
*
* @return array
*/
public function getOptions()
@ -227,7 +227,7 @@ class CustomFieldsGroup
/**
* set options array
*
*
* @param array $options
* @return CustomFieldsGroup
*/

View File

@ -21,7 +21,7 @@ class DocGeneratorTemplate
private int $id;
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
* @Serializer\Groups({"read"})
*/
private array $name = [];

View File

@ -22,7 +22,6 @@ final class Version20210812214310 extends AbstractMigration
$this->addSql('ALTER TABLE chill_docgen_template ADD entities TEXT');
$this->addSql('ALTER TABLE chill_docgen_template ADD context VARCHAR(255)');
$this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\'');
$this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS \'(DC2Type:json_array)\'');
}
public function down(Schema $schema): void

View File

@ -34,10 +34,10 @@ class DocumentCategory
/**
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
public function __construct($bundleId, $idInsideBundle)
{
$this->bundleId = $bundleId;

View File

@ -39,14 +39,14 @@ class StoredObject implements AsyncFileInterface, Document
private $filename;
/**
* @ORM\Column(type="json_array", name="key")
* @ORM\Column(type="json", name="key")
*/
private array $keyInfos = [];
/**
*
* @var int[]
* @ORM\Column(type="json_array", name="iv")
* @ORM\Column(type="json", name="iv")
*/
private array $iv = [];
@ -69,7 +69,7 @@ class StoredObject implements AsyncFileInterface, Document
private string $type = '';
/**
* @ORM\Column(type="json_array", name="datas")
* @ORM\Column(type="json", name="datas")
* @Serializer\Groups({"read"})
*/
private array $datas = [];

View File

@ -17,7 +17,6 @@ final class Version20180605102533 extends AbstractMigration
$this->addSql('CREATE SCHEMA chill_doc');
$this->addSql('CREATE SEQUENCE chill_doc.person_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_doc.document_category (bundle_id VARCHAR(255) NOT NULL, id_inside_bundle INT NOT NULL, document_class VARCHAR(255) NOT NULL, name JSON NOT NULL, PRIMARY KEY(bundle_id, id_inside_bundle))');
$this->addSql('COMMENT ON COLUMN chill_doc.document_category.name IS \'(DC2Type:json_array)\'');
$this->addSql('CREATE TABLE chill_doc.person_document (id INT NOT NULL, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, title TEXT NOT NULL, description TEXT NOT NULL, content TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_41DA53C369A0BE36EF62EFC ON chill_doc.person_document (category_bundle_id, category_id_inside_bundle)');
$this->addSql('CREATE INDEX IDX_41DA53C682B5931 ON chill_doc.person_document (scope_id)');
@ -34,6 +33,6 @@ final class Version20180605102533 extends AbstractMigration
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SCHEMA chill_doc CASCADE');
}
}

View File

@ -16,9 +16,6 @@ final class Version20180606133338 extends AbstractMigration
$this->addSql('CREATE SEQUENCE chill_doc.stored_object_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_doc.stored_object (id INT NOT NULL, filename TEXT NOT NULL, key JSON NOT NULL, iv JSON NOT NULL, creation_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, type TEXT NOT NULL, datas JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.key IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.iv IS \'(DC2Type:json_array)\'');
$this->addSql('COMMENT ON COLUMN chill_doc.stored_object.datas IS \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE chill_doc.person_document ADD object_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_doc.person_document DROP content');
$this->addSql('ALTER TABLE chill_doc.person_document ADD CONSTRAINT FK_41DA53C232D562B FOREIGN KEY (object_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@ -46,7 +46,7 @@ class EventType
/**
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -55,7 +55,7 @@ class EventType
* @ORM\Column(type="boolean")
*/
private $active;
/**
* @var Collection
* @ORM\OneToMany(

View File

@ -44,7 +44,7 @@ class Role
/**
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
@ -53,7 +53,7 @@ class Role
* @ORM\Column(type="boolean")
*/
private $active;
/**
* @var EventType
* @ORM\ManyToOne(

View File

@ -41,19 +41,19 @@ class Status
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
private $active;
/**
* @var EventType
* @ORM\ManyToOne(

View File

@ -15,17 +15,17 @@ use Doctrine\DBAL\Types\ConversionException;
class NativeDateIntervalType extends DateIntervalType
{
const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS';
public function getName(): string
{
return \Doctrine\DBAL\Types\Type::DATEINTERVAL;
return \Doctrine\DBAL\Types\Types::DATEINTERVAL;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
{
return 'INTERVAL';
}
/**
* {@inheritdoc}
*/
@ -41,36 +41,36 @@ class NativeDateIntervalType extends DateIntervalType
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateInterval']);
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null || $value instanceof \DateInterval) {
return $value;
}
try {
$strings = explode(' ', $value);
if (count($strings) === 0) {
return null;
}
$intervalSpec = 'P';
\reset($strings);
do {
$intervalSpec .= $this->convertEntry($strings);
} while (next($strings) !== FALSE);
return new \DateInterval($intervalSpec);
} catch (\Exception $exception) {
throw $this->createConversionException($value, $exception);
}
}
private function convertEntry(&$strings)
{
$current = \current($strings);
if (is_numeric($current)) {
$next = \next($strings);
switch($next) {
@ -79,7 +79,7 @@ class NativeDateIntervalType extends DateIntervalType
$unit = 'Y';
break;
case 'mon':
case 'mons':
case 'mons':
$unit = 'M';
break;
case 'day':
@ -89,20 +89,20 @@ class NativeDateIntervalType extends DateIntervalType
default:
throw $this->createConversionException(implode('', $strings));
}
return $current.$unit;
} elseif (\preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', $current) === 1) {
$tExploded = explode(':', $current);
$intervalSpec = 'T';
$intervalSpec.= $tExploded[0].'H';
$intervalSpec.= $tExploded[1].'M';
$intervalSpec.= $tExploded[2].'S';
return $intervalSpec;
}
}
protected function createConversionException($value, $exception = null)
{
return ConversionException::conversionFailedFormat($value, $this->getName(), 'xx year xx mons xx days 01:02:03', $exception);

View File

@ -28,7 +28,7 @@ class Country
/**
* @var string
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
* @groups({"read"})
*
*/

View File

@ -43,14 +43,14 @@ class Language
/**
* @var string array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
/**
* Get id
*
* @return string
* @return string
*/
public function getId()
{
@ -59,7 +59,7 @@ class Language
/**
* Set id
*
*
* @param string $id
* @return Language
*/
@ -78,17 +78,17 @@ class Language
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string array
* @return string array
*/
public function getName()
{
return $this->name;
}
}
}

View File

@ -52,7 +52,7 @@ class Scope
*
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
* @Groups({"read"})
*/
private $name = [];

View File

@ -116,7 +116,7 @@ class User implements AdvancedUserInterface {
* Array where SAML attributes's data are stored
* @var array
*
* @ORM\Column(type="json_array", nullable=true)
* @ORM\Column(type="json", nullable=true)
*/
private $attributes;

View File

@ -20,7 +20,7 @@
namespace Chill\MainBundle\Timeline;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Doctrine\ORM\Query;
@ -31,38 +31,38 @@ use Doctrine\ORM\NativeQuery;
*/
class TimelineBuilder implements ContainerAwareInterface
{
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
/**
*
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;
/**
* Record provider
*
*
* This array has the structure `[ 'service id' => $service ]`
*
* @var TimelineProviderInterface[]
*/
private $providers = [];
/**
* Record provider and their context
*
*
* This array has the structure `[ 'context' => [ 'service id' ] ]`
*
* @var array
*/
private $providersByContext = [];
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* return an HTML string with timeline
*
@ -79,18 +79,18 @@ class TimelineBuilder implements ContainerAwareInterface
public function getTimelineHTML($context, array $args, $firstItem = 0, $number = 20)
{
list($union, $parameters) = $this->buildUnionQuery($context, $args);
//add ORDER BY clause and LIMIT
$query = $union . sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d',
$number, $firstItem);
// run query and handle results
$fetched = $this->runUnionQuery($query, $parameters);
$entitiesByKey = $this->getEntities($fetched, $context);
return $this->render($fetched, $entitiesByKey, $context, $args);
}
/**
* Return the number of items for the given context and args
*
@ -101,7 +101,7 @@ class TimelineBuilder implements ContainerAwareInterface
public function countItems($context, array $args)
{
$rsm = (new ResultSetMapping())
->addScalarResult('total', 'total', Type::INTEGER);
->addScalarResult('total', 'total', Types::INTEGER);
list($select, $parameters) = $this->buildUnionQuery($context, $args);
@ -110,10 +110,10 @@ class TimelineBuilder implements ContainerAwareInterface
$nq = $this->em->createNativeQuery($countQuery, $rsm);
$nq->setParameters($parameters);
return $nq->getSingleScalarResult();
}
/**
* add a provider id
*
@ -127,7 +127,7 @@ class TimelineBuilder implements ContainerAwareInterface
$this->providersByContext[$context][] = $id;
$this->providers[$id] = $provider;
}
/**
* Get providers by context
*
@ -141,16 +141,16 @@ class TimelineBuilder implements ContainerAwareInterface
throw new \LogicException(sprintf('No builders have been defined for "%s"'
. ' context', $context));
}
$providers = [];
foreach($this->providersByContext[$context] as $providerId) {
$providers[] = $this->providers[$providerId];
}
return $providers;
}
/**
* build the UNION query with all providers
*
@ -172,7 +172,7 @@ class TimelineBuilder implements ContainerAwareInterface
$union .= $append;
$parameters = array_merge($parameters, $selectParameters);
}
return [$union, $parameters];
}
@ -195,7 +195,7 @@ class TimelineBuilder implements ContainerAwareInterface
return $s;
}
*/
/**
* return the SQL SELECT query as a string,
*
@ -222,9 +222,9 @@ class TimelineBuilder implements ContainerAwareInterface
);
return [$sql, $data['WHERE'][1]];
}
/**
* run the UNION query and return result as an array
*
@ -236,12 +236,12 @@ class TimelineBuilder implements ContainerAwareInterface
->addScalarResult('id', 'id')
->addScalarResult('type', 'type')
->addScalarResult('date', 'date');
return $this->em->createNativeQuery($query, $resultSetMapping)
->setParameters($parameters)
->getArrayResult();
}
/**
*
* @param array $queriedIds
@ -252,11 +252,11 @@ class TimelineBuilder implements ContainerAwareInterface
{
//gather entities by type to pass all id with same type to the TimelineProvider.
$idsByType = array();
foreach($queriedIds as $result) {
$idsByType[$result['type']][] = $result['id'];
}
//fetch entities from providers
$entitiesByType = array();
foreach ($idsByType as $type => $ids) {
@ -268,10 +268,10 @@ class TimelineBuilder implements ContainerAwareInterface
}
}
}
return $entitiesByType;
}
/**
* render the timeline as HTML
*
@ -294,17 +294,17 @@ class TimelineBuilder implements ContainerAwareInterface
$timelineEntry['date'] = new \DateTime($result['date']);
$timelineEntry['template'] = $data['template'];
$timelineEntry['template_data'] = $data['template_data'];
$timelineEntries[] = $timelineEntry;
}
return $this->container->get('templating')
->render('@ChillMain/Timeline/chain_timelines.html.twig', array(
'results' => $timelineEntries
));
}
/**
* get the template data from the provider for the given entity, by type.
*

View File

@ -20,7 +20,6 @@ final class Version20210304085819 extends AbstractMigration
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN users.attributes IS \'(DC2Type:json_array)\'');
}
public function down(Schema $schema) : void

View File

@ -14,6 +14,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Repository\Household\PositionRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Security\Core\Security;
/**
* @Route("/{_locale}/person/household")
@ -24,11 +26,14 @@ class HouseholdController extends AbstractController
private PositionRepository $positionRepository;
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
private Security $security;
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository, Security $security)
{
$this->translator = $translator;
$this->positionRepository = $positionRepository;
$this->security = $security;
}
/**
@ -77,17 +82,46 @@ class HouseholdController extends AbstractController
*/
public function accompanyingPeriod(Request $request, Household $household)
{
// TODO ACL
$members = $household->getMembers();
foreach($members as $m) {
$accompanyingPeriods = $m->getPerson()->getAccompanyingPeriods();
$currentMembers = $household->getCurrentPersons();
$accompanyingPeriods = [];
foreach ($currentMembers as $p) {
$accompanyingPeriodsMember = $p->getCurrentAccompanyingPeriods();
foreach ($accompanyingPeriodsMember as $accompanyingPeriod) {
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod)) {
continue;
} else {
$accompanyingPeriods[$accompanyingPeriod->getId()] = $accompanyingPeriod;
}
}
}
$oldMembers = $household->getNonCurrentMembers();
$accompanyingPeriodsOld = [];
foreach ($oldMembers as $m) {
$accompanyingPeriodsOldMember = $m->getPerson()->getAccompanyingPeriods();
foreach ($accompanyingPeriodsOldMember as $accompanyingPeriod) {
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod)) {
continue;
} else {
$id = $accompanyingPeriod->getId();
if (!array_key_exists($id, $accompanyingPeriodsOld) && !array_key_exists($id, $accompanyingPeriods)) {
$accompanyingPeriodsOld[$id] = $accompanyingPeriod;
}
}
}
}
return $this->render('@ChillPerson/Household/accompanying_period.html.twig',
[
'household' => $household,
'accompanying_periods' => $accompanyingPeriods
'accompanying_periods' => $accompanyingPeriods,
'accompanying_periods_old' => $accompanyingPeriodsOld
]
);
}

View File

@ -41,14 +41,14 @@ class MaritalStatus
/**
* @var string array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $name;
/**
* Get id
*
* @return string
* @return string
*/
public function getId()
{
@ -57,7 +57,7 @@ class MaritalStatus
/**
* Set id
*
*
* @param string $id
* @return MaritalStatus
*/
@ -76,17 +76,17 @@ class MaritalStatus
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string array
* @return string array
*/
public function getName()
{
return $this->name;
}
}
}

View File

@ -406,7 +406,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* Array where customfield's data are stored
* @var array
*
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $cFData;
@ -613,6 +613,26 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $accompanyingPeriods;
}
/**
* Get current accompanyingPeriods array
*/
public function getCurrentAccompanyingPeriods(): array
{
$currentAccompanyingPeriods = [];
$currentDate = new DateTime();
foreach ($this->accompanyingPeriodParticipations as $participation)
{
$endDate = $participation->getEndDate();
if ($endDate === null || $endDate > $currentDate){
$currentAccompanyingPeriods[] = $participation->getAccompanyingPeriod();
}
}
return $currentAccompanyingPeriods;
}
/**
* Get AccompanyingPeriodParticipations Collection
*

View File

@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/**
*
*
*
*/
class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
@ -38,14 +38,14 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
public function alterQuery(QueryBuilder $qb, $data)
{
$this->addJoinAccompanyingPeriod($qb);
$clause = $qb->expr()->andX(
$qb->expr()->lte('accompanying_period.closingDate', ':date_to'),
$qb->expr()->gte('accompanying_period.closingDate', ':date_from'));
$qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
}
public function applyOn(): string
@ -59,7 +59,7 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
'label' => "Having an accompanying period closed after this date",
'data' => new \DateTime("-1 month"),
));
$builder->add('date_to', ChillDateType::class, array(
'label' => "Having an accompanying period closed before this date",
'data' => new \DateTime(),

View File

@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/**
*
*
*
*/
class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
@ -38,9 +38,9 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
public function alterQuery(QueryBuilder $qb, $data)
{
$this->addJoinAccompanyingPeriod($qb);
$clause = $qb->expr()->andX();
$clause->add(
$qb->expr()->lte('accompanying_period.openingDate', ':date_to')
);
@ -52,8 +52,8 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
);
$qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
}
public function applyOn(): string
@ -67,7 +67,7 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
'label' => "Having an accompanying period opened after this date",
'data' => new \DateTime("-1 month"),
));
$builder->add('date_to', ChillDateType::class, array(
'label' => "Having an accompanying period ending before this date, or "
. "still opened at this date",

View File

@ -21,11 +21,11 @@ use Chill\MainBundle\Export\FilterInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Form\Type\ChillDateType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
/**
*
*
*
*/
class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
@ -38,14 +38,14 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
public function alterQuery(QueryBuilder $qb, $data)
{
$this->addJoinAccompanyingPeriod($qb);
$clause = $qb->expr()->andX(
$qb->expr()->lte('accompanying_period.openingDate', ':date_to'),
$qb->expr()->gte('accompanying_period.openingDate', ':date_from'));
$qb->andWhere($clause);
$qb->setParameter('date_from', $data['date_from'], Type::DATE);
$qb->setParameter('date_to', $data['date_to'], Type::DATE);
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
}
public function applyOn(): string
@ -59,7 +59,7 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
'label' => "Having an accompanying period opened after this date",
'data' => new \DateTime("-1 month"),
));
$builder->add('date_to', ChillDateType::class, array(
'label' => "Having an accompanying period opened before this date",
'data' => new \DateTime(),

View File

@ -77,7 +77,7 @@
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div>
<div class="wl-col list">
{% for p in accompanying_period.participations %}
{% for p in accompanying_period.getCurrentParticipations %}
<span class="wl-item badge-person">
<a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">
{{ p.person|chill_entity_render_string }}

View File

@ -9,6 +9,37 @@
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' %}
{% if accompanying_periods_old|length > 0 %}
<style>
button[aria-expanded="true"] > span.folded,
button[aria-expanded="false"] > span.unfolded { display: none; }
button[aria-expanded="false"] > span.folded,
button[aria-expanded="true"] > span.unfolded { display: inline; }
</style>
<div class="accordion" id="nonCurrent">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_{{ household.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_{{ household.id }}"
aria-expanded="false"
aria-controls="collapse_{{ household.id }}">
<span class="folded">{{ 'household.Show accompanying periods of past or future memberships'|trans({'length': accompanying_periods_old|length}) }}</span>
<span class="unfolded text-secondary">{{ 'household.Hide memberships'|trans }}</span>
</button>
</h2>
<div id="collapse_{{ household.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_{{ household.id }}"
data-bs-parent="#nonCurrent">
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' with {'accompanying_periods' : accompanying_periods_old} %}
</div>
</div>
</div>
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path ('chill_person_household_summary', {'household_id' : household.id } ) }}" class="btn btn-cancel">

View File

@ -22,7 +22,7 @@ namespace Chill\PersonBundle\Widget;
use Chill\MainBundle\Templating\Widget\WidgetInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
@ -33,11 +33,11 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
use Twig\Environment;
/**
* add a widget with person list.
*
* add a widget with person list.
*
* The configuration is defined by `PersonListWidgetFactory`
*
* If the options 'custom_fields' is used, the custom fields entity will be
*
* If the options 'custom_fields' is used, the custom fields entity will be
* queried from the db and transmitted to the view under the `customFields` variable.
*/
class PersonListWidget implements WidgetInterface
@ -48,33 +48,33 @@ class PersonListWidget implements WidgetInterface
* @var PersonRepository
*/
protected $personRepository;
/**
* The entity manager
*
* @var EntityManager
*/
protected $entityManager;
/**
* the authorization helper
*
*
* @var AuthorizationHelper;
*/
protected $authorizationHelper;
/**
*
* @var TokenStorage
*/
protected $tokenStorage;
/**
*
* @var UserInterface
*/
protected $user;
public function __construct(
PersonRepository $personRepostory,
EntityManager $em,
@ -88,26 +88,26 @@ class PersonListWidget implements WidgetInterface
}
/**
*
*
* @param type $place
* @param array $context
* @param array $config
* @return string
*/
public function render(Environment $env, $place, array $context, array $config)
{
{
$numberOfItems = $config['number_of_items'] ?? 20;
$qb = $this->personRepository
->createQueryBuilder('person');
// show only the person from the authorized centers
$and = $qb->expr()->andX();
$centers = $this->authorizationHelper
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
$and->add($qb->expr()->in('person.center', ':centers'));
$qb->setParameter('centers', $centers);
// add the "only active" query
if (\array_key_exists('only_active', $config) && $config['only_active'] === true) {
@ -123,37 +123,37 @@ class PersonListWidget implements WidgetInterface
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
);
$and->add($or);
$qb->setParameter('now', new \DateTime(), Type::DATE);
$qb->setParameter('now', new \DateTime(), Types::DATE_MUTABLE);
}
if (\array_key_exists('filtering_class', $config) && $config['filtering_class'] !== NULL) {
$filteringClass = new $config['filtering_class'];
if ( ! $filteringClass instanceof PersonListWidget\PersonFilteringInterface) {
throw new \UnexpectedValueException(sprintf("the class %s does not "
. "implements %s", $config['filtering_class'],
. "implements %s", $config['filtering_class'],
PersonListWidget\PersonFilteringInterface::class));
}
$ids = $filteringClass->getPersonIds($this->entityManager,
$ids = $filteringClass->getPersonIds($this->entityManager,
$this->getUser());
$in = (new Expr())->in('person.id', ':ids');
$and->add($in);
$qb->setParameter('ids', $ids);
}
// adding the where clause to the query
$qb->where($and);
// ordering the query by lastname, firstname
$qb->addOrderBy('person.lastName', 'ASC')
->addOrderBy('person.firstName', 'ASC');
$qb->setFirstResult(0)->setMaxResults($numberOfItems);
$persons = $qb->getQuery()->getResult();
// get some custom field when the view is overriden and we want to
// get some custom field when the view is overriden and we want to
// show some custom field in the overriden view.
$cfields = array();
if (isset($config['custom_fields'])) {
@ -166,39 +166,39 @@ class PersonListWidget implements WidgetInterface
$cfields[$cf->getSlug()] = $cf;
}
}
}
}
return $env->render(
'ChillPersonBundle:Widget:homepage_person_list.html.twig',
array(
'persons' => $persons,
'customFields' => $cfields
)
);
}
/**
*
*
* @return UserInterface
* @throws \RuntimeException
*/
private function getUser()
{
$token = $this->tokenStorage->getToken();
if ($token === null) {
throw new \RuntimeException("the token should not be null");
}
$user = $token->getUser();
if (!$user instanceof UserInterface || $user == null) {
throw new \RuntimeException("the user should implement UserInterface. "
. "Are you logged in ?");
}
return $user;
}
}
}

View File

@ -27,7 +27,7 @@ use Chill\MainBundle\Entity\User;
/**
* Interface to implement on classes called in configuration for
* PersonListWidget (`person_list`), under the key `filtering_class` :
*
*
* ```
* widgets:
* homepage:
@ -35,41 +35,41 @@ use Chill\MainBundle\Entity\User;
* # where \FQDN\To\Class implements PersonFiltering
* class_filtering: \FQDN\To\Class
* ```
*
*
*/
interface PersonFilteringInterface
interface PersonFilteringInterface
{
/**
* Return an array of persons id to show.
*
* Those ids are inserted into the query like this (where ids is the array
*
* Those ids are inserted into the query like this (where ids is the array
* returned by this class) :
*
*
* ```
* SELECT p FROM ChillPersonBundle:Persons p
* SELECT p FROM ChillPersonBundle:Persons p
* WHERE p.id IN (:ids)
* AND
* AND
* -- security/authorization statement: restraint person to authorized centers
* p.center in :authorized_centers
* ```
*
*
* Example of use : filtering based on custom field data :
* ```
class HomepagePersonFiltering implements PersonFilteringInterface {
public function getPersonIds(EntityManager $em, User $user)
{
$rsmBuilder = new ResultSetMappingBuilder($em);
$rsmBuilder->addScalarResult('id', 'id', Type::BIGINT);
$rsmBuilder->addScalarResult('id', 'id', Types::BIGINT);
$personTable = $em->getClassMetadata('ChillPersonBundle:Person')
->getTableName();
$personIdColumn = $em->getClassMetadata('ChillPersonBundle:Person')
->getColumnName('id');
$personCfDataColumn = $em->getClassMetadata('ChillPersonBundle:Person')
->getColumnName('cfData');
return $em->createNativeQuery(sprintf("SELECT %s FROM %s WHERE "
. "jsonb_exists(%s, 'school-2fb5440e-192c-11e6-b2fd-74d02b0c9b55')",
$personIdColumn, $personTable, $personCfDataColumn), $rsmBuilder)
@ -77,7 +77,7 @@ interface PersonFilteringInterface
}
}
* ```
*
*
* @param EntityManager $em
* @return int[] an array of persons id to show
*/

View File

@ -17,7 +17,6 @@ class Version20150607231010 extends AbstractMigration
. 'recorded.';
}
/**
* @param Schema $schema
*/
@ -28,36 +27,26 @@ class Version20150607231010 extends AbstractMigration
'Migration can only be executed safely on \'postgresql\'.'
);
// retrieve center for setting a default center
$centers = $this->connection->fetchAll('SELECT id FROM centers');
if (count($centers) > 0) {
$defaultCenterId = $centers[0]['id'];
} else { // if no center, performs other checks
//check if there are data in person table
$nbPeople = $this->connection->fetchColumn('SELECT count(*) FROM person');
if ($nbPeople > 0) {
// we have data ! We have to create a center !
$newCenterId = $this->connection->fetchColumn('SELECT nextval(\'centers_id_seq\');');
$this->addSql(
'INSERT INTO centers (id, name) VALUES (:id, :name)',
['id' => $newCenterId, 'name' => 'Auto-created center']
);
$defaultCenterId = $newCenterId;
}
}
$this->addSql('ALTER TABLE person ADD center_id INT');
// retrieve center for setting a default center
$stmt = $this->connection->executeQuery("SELECT id FROM centers ORDER BY id ASC LIMIT 1");
$center = $stmt->fetchOne();
if ($center !== false) {
$defaultCenterId = $center['id'];
}
if (isset($defaultCenterId)) {
$this->addSql('UPDATE person SET center_id = :id', array('id' => $defaultCenterId));
}
// this will fail if a person is defined, which should not happen any more at this
// time of writing (2021-11-09)
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
$this->addSql('ALTER TABLE person '
. 'ADD CONSTRAINT FK_person_center FOREIGN KEY (center_id) '
. 'REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
$this->addSql('CREATE INDEX IDX_person_center ON person (center_id)');
}

View File

@ -15,7 +15,6 @@ final class Version20200310090632 extends AbstractMigration
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_person_closingmotive ADD parent_id INT DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN chill_person_closingmotive.name IS \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE chill_person_closingmotive ADD CONSTRAINT FK_92351ECE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_person_closingmotive (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_92351ECE727ACA70 ON chill_person_closingmotive (parent_id)');
$this->addsql("ALTER TABLE chill_person_closingmotive ADD ordering DOUBLE PRECISION DEFAULT '0' NOT NULL;");

View File

@ -24,6 +24,5 @@ final class Version20210419112619 extends AbstractMigration
public function down(Schema $schema) : void
{
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
}
}

View File

@ -26,6 +26,12 @@ household:
many {Montrer # anciennes ou futures appartenances}
other {Montrer # anciennes ou futures appartenances}
}
Show accompanying periods of past or future memberships: >-
{length, plural,
one {Montrer les parcours d'une ancienne appartenance}
many {Montrer # parcours des anciennes ou futures appartenances}
other {Montrer # parcours des anciennes ou futures appartenances}
}
Hide memberships: Masquer
Those members does not share address: Ces usagers ne partagent pas l'adresse du ménage.
Any persons into this position: Aucune personne n'appartient au ménage à cette position.

View File

@ -1,19 +1,19 @@
<?php
/*
*
*
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -74,7 +74,7 @@ class Report implements HasCenterInterface, HasScopeInterface
/**
* @var array
* @ORM\Column(type="json_array")
* @ORM\Column(type="json")
*/
private $cFData;
@ -233,7 +233,7 @@ class Report implements HasCenterInterface, HasScopeInterface
{
return $this->cFGroup;
}
/**
* @return Center
*/

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\Role\Role;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Chill\MainBundle\Entity\Center;
/**
@ -120,13 +120,13 @@ class SingleTaskRepository extends EntityRepository
throw new \UnexpectedValueException("params 'center' should be an instance of ".Center::class);
}
}
if (\array_key_exists('unassigned', $params) and $params['unassigned'] === true) {
if (\array_key_exists('user', $params) and !empty($params['user'])) {
throw new \UnexpectedValueException("You should not require for "
. "unassigned tasks and tasks assigned to some user.");
}
$qb->andWhere($qb->expr()->isNull('st.assignee'));
}
@ -139,7 +139,7 @@ class SingleTaskRepository extends EntityRepository
$qb->andWhere($qb->expr()->eq('st.circle', ':scope'));
$qb->setParameter('scope', $params['scope']);
}
if (\array_key_exists('types', $params) && $params['types'] !== NULL) {
if (count($params['types']) > 0) {
$qb->andWhere($qb->expr()->in('st.type', ':types'));
@ -154,7 +154,7 @@ class SingleTaskRepository extends EntityRepository
if (\array_key_exists('is_closed', $params)) {
$qb->andWhere($this->buildIsClosed($qb, !$params['is_closed']));
}
}
protected function addTypeFilter(QueryBuilder $qb, $params)
@ -191,7 +191,7 @@ class SingleTaskRepository extends EntityRepository
->add($this->buildNowIsAfterStartDate($qb, true))
;
}
$qb->setParameter('now', new \DateTime('today'), Type::DATE);
$qb->setParameter('now', new \DateTime('today'), Types::DATE_MUTABLE);
$qb->andWhere($andWhere);
}

View File

@ -19,8 +19,7 @@ final class Version20190307111314 extends AbstractMigration
$this->addSql('CREATE SEQUENCE chill_third_party_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_third_party (id INT NOT NULL, name VARCHAR(255) NOT NULL, telephone VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, comment TEXT DEFAULT NULL, type JSON DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_third_party.type IS \'(DC2Type:json_array)\'');
}
public function down(Schema $schema): void