From c484e4075863f058b471a636d21452519cb55ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 1 Sep 2019 22:04:55 +0200 Subject: [PATCH] Added an DB field for filetype filtering to attachment types. --- src/Entity/Attachments/AttachmentType.php | 28 +++++++++++++++++++++++ src/Migrations/Version20190829104643.php | 5 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 92bf9817..ac7991f1 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -56,6 +56,7 @@ use App\Entity\Base\StructuralDBElement; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use s9e\TextFormatter\Configurator\RendererGenerators\PHP\XPathConvertor\Convertors\SingleByteStringManipulation; /** * Class AttachmentType. @@ -82,6 +83,12 @@ class AttachmentType extends StructuralDBElement */ protected $parent; + /** + * @var string + * @ORM\Column(type="string", length=65535) + */ + protected $filetype_filter; + /** * Get all attachements ("Attachement" objects) with this type. * @@ -98,6 +105,27 @@ class AttachmentType extends StructuralDBElement return $this->attachments; } + /** + * Gets an filter, which file types are allowed for attachment files. + * @return string + */ + public function getFiletypeFilter(): string + { + return $this->filetype_filter; + } + + /** + * @param string $filetype_filter + * @return AttachmentType + */ + public function setFiletypeFilter(string $filetype_filter): AttachmentType + { + $this->filetype_filter = $filetype_filter; + return $this; + } + + + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. diff --git a/src/Migrations/Version20190829104643.php b/src/Migrations/Version20190829104643.php index e6809bc1..5947939d 100644 --- a/src/Migrations/Version20190829104643.php +++ b/src/Migrations/Version20190829104643.php @@ -49,11 +49,14 @@ final class Version20190829104643 extends AbstractMigration //Use float values for pricedetails amount, to use with non integer part units $this->addSql('ALTER TABLE pricedetails CHANGE orderdetails_id orderdetails_id INT DEFAULT NULL, CHANGE id_currency id_currency INT DEFAULT NULL, CHANGE price_related_quantity price_related_quantity DOUBLE PRECISION NOT NULL, CHANGE min_discount_quantity min_discount_quantity DOUBLE PRECISION NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); - //Fix typo in attachment table names $this->addSql("ALTER TABLE attachements RENAME TO attachments;"); $this->addSql("ALTER TABLE attachement_types RENAME TO attachment_types;"); + //Add an filetye filter field to attachment types + $this->addSql('ALTER TABLE attachment_types ADD filetype_filter VARCHAR(65535) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + + //Fill empty timestamps with current date $tables = ["attachments", "attachment_types", "categories", "devices", "footprints", "manufacturers", "orderdetails", "pricedetails", "storelocations", "suppliers"];