Commit 06bda8fc authored by Sebastian Castro's avatar Sebastian Castro

Use email as custom Data

parent 4db4c6a1
......@@ -99,4 +99,4 @@ db.Option.updateMany({}, { $unset: { displayOption: "" } })
# Convert static data to new customizable fields
db.Element.updateMany( { } , { $rename: { 'website': 'data.website', 'telephone':'data.telephone', 'commitment':'data.commitment', 'description':'data.description', 'descriptionMore':'data.descriptionMore', 'openHoursMoreInfos':'data.openHoursMoreInfos', 'urls':'data.urls' } } )
db.Element.updateMany( { } , { $rename: { 'website': 'data.website', 'telephone':'data.telephone', 'commitment':'data.commitment', 'description':'data.description', 'descriptionMore':'data.descriptionMore', 'openHoursMoreInfos':'data.openHoursMoreInfos', 'urls':'data.urls', 'email':'data.email' } } )
......@@ -24,7 +24,7 @@ class ElementAdminShowEdit extends ElementAdminList
$formMapper
->with('Informations générales', array())
->add('name', 'text')
->add('email', 'text', array('required' => false))
->add('email', 'text', array('required' => false, 'disabled' => true, 'label' => 'Email de contact'))
->add('userOwnerEmail', 'text', array('required' => false))
->add('images', 'sonata_type_collection', array('by_reference' => true, 'type_options' => array('delete' => true)),
array('edit' => 'inline', 'inline' => 'table'))
......
......@@ -531,7 +531,6 @@ class Element
$privateJson = '{';
// status
$privateJson .= '"status": ' . $this->getStatus() . ',';
if ($this->email) $privateJson .= '"email":' . json_encode($this->email) . ',';
$privateJson .= '"moderationState": ' . $this->getModerationState() . ',';
// CUSTOM PRIVATE DATA
foreach ($this->getPrivateData() as $key => $value) {
......@@ -691,6 +690,9 @@ class Element
public function setCustomData($data, $privateProps)
{
if (array_key_exists('email', $data)) {
$this->setEmail($data['email']);
}
$privateData = [];
foreach ($privateProps as $key => $prop) {
if (array_key_exists($prop, $data)) {
......@@ -1494,6 +1496,9 @@ class Element
*/
public function getEmail()
{
return $this->email;
if ($this->email) return $this->email;
if (array_key_exists('email', $this->data)) return $this->data['email'];
if (array_key_exists('email', $this->privateData)) return $this->privateData['email'];
return "";
}
}
......@@ -40,7 +40,7 @@
{% endif %}
{# NAME #}
{% set baseName = field.type == "title" or field.type == "email" ? "biopen_elementbundle_element" : "data" %}
{% set baseName = field.type == "title" ? "biopen_elementbundle_element" : "data" %}
{% set fieldName = field.type == "email" ? 'email' : field.name %}
{# TYPE #}
{% set inputType = field.subtype is defined ? field.subtype : field.type == "number" ? "number" : "text" %}
......
......@@ -31,7 +31,7 @@ class ElementImportService
protected $parentCategoryIdToCreateMissingOptions;
protected $missingOptionDefaultAttributesForCreate;
protected $coreFields = ['id', 'name', 'taxonomy', 'streetAddress', 'addressLocality', 'postalCode', 'addressCountry', 'email', 'latitude', 'longitude', 'images', 'owner', 'source'];
protected $coreFields = ['id', 'name', 'taxonomy', 'streetAddress', 'addressLocality', 'postalCode', 'addressCountry', 'latitude', 'longitude', 'images', 'owner', 'source'];
protected $privateDataProps;
/**
* Constructor
......@@ -184,7 +184,6 @@ class ElementImportService
$address = new PostalAddress($row['streetAddress'], $row['addressLocality'], $row['postalCode'], $row["addressCountry"]);
$new_element->setAddress($address);
$new_element->setEmail($row['email']);
$defaultSourceName = $import ? $import->getSourceName() : 'Inconnu';
$new_element->setSourceKey( (strlen($row['source']) > 0 && $row['source'] != 'Inconnu') ? $row['source'] : $defaultSourceName);
$new_element->setSource($import);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment