expo qr code to get visitors email

This commit is contained in:
Bachir Soussi Chiadmi 2021-09-07 00:50:12 +02:00
parent 31790f5ab7
commit 4ea79bca79
28 changed files with 327 additions and 7 deletions

View File

@ -1,4 +0,0 @@
dependencies:
enforced:
module:
- devel

View File

@ -7,6 +7,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -119,6 +120,7 @@ third_party_settings:
group_files: group_files:
children: children:
- field_attachments - field_attachments
- field_fiche_expo
parent_name: group_htabs parent_name: group_htabs
weight: 13 weight: 13
format_type: tab format_type: tab
@ -223,6 +225,13 @@ content:
third_party_settings: { } third_party_settings: { }
type: options_select type: options_select
region: content region: content
field_fiche_expo:
weight: 18
settings:
progress_indicator: throbber
third_party_settings: { }
type: file_generic
region: content
field_linked_articles: field_linked_articles:
weight: 19 weight: 19
settings: settings:

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -207,5 +208,7 @@ content:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
hidden: hidden:
field_fiche_expo: true
langcode: true langcode: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -207,5 +208,7 @@ content:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
hidden: hidden:
field_fiche_expo: true
langcode: true langcode: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -77,6 +78,7 @@ hidden:
field_attachments: true field_attachments: true
field_distributor: true field_distributor: true
field_famille: true field_famille: true
field_fiche_expo: true
field_index: true field_index: true
field_linked_articles: true field_linked_articles: true
field_linked_materials: true field_linked_materials: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -72,6 +73,7 @@ hidden:
body: true body: true
field_attachments: true field_attachments: true
field_distributor: true field_distributor: true
field_fiche_expo: true
field_index: true field_index: true
field_linked_articles: true field_linked_articles: true
field_linked_materials: true field_linked_materials: true
@ -88,3 +90,4 @@ hidden:
langcode: true langcode: true
links: true links: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -72,6 +73,7 @@ hidden:
body: true body: true
field_attachments: true field_attachments: true
field_distributor: true field_distributor: true
field_fiche_expo: true
field_index: true field_index: true
field_linked_articles: true field_linked_articles: true
field_linked_materials: true field_linked_materials: true
@ -88,3 +90,4 @@ hidden:
langcode: true langcode: true
links: true links: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -7,6 +7,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -155,6 +156,7 @@ content:
third_party_settings: { } third_party_settings: { }
hidden: hidden:
field_famille: true field_famille: true
field_fiche_expo: true
field_index: true field_index: true
field_localisation_old: true field_localisation_old: true
field_memo: true field_memo: true
@ -170,3 +172,4 @@ hidden:
flag_projet_2: true flag_projet_2: true
langcode: true langcode: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -128,6 +129,7 @@ content:
hidden: hidden:
field_attachments: true field_attachments: true
field_famille: true field_famille: true
field_fiche_expo: true
field_index: true field_index: true
field_linked_articles: true field_linked_articles: true
field_linked_materials: true field_linked_materials: true
@ -146,3 +148,4 @@ hidden:
langcode: true langcode: true
links: true links: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -8,6 +8,7 @@ dependencies:
- field.field.node.materiau.field_attachments - field.field.node.materiau.field_attachments
- field.field.node.materiau.field_distributor - field.field.node.materiau.field_distributor
- field.field.node.materiau.field_famille - field.field.node.materiau.field_famille
- field.field.node.materiau.field_fiche_expo
- field.field.node.materiau.field_index - field.field.node.materiau.field_index
- field.field.node.materiau.field_linked_articles - field.field.node.materiau.field_linked_articles
- field.field.node.materiau.field_linked_materials - field.field.node.materiau.field_linked_materials
@ -67,6 +68,7 @@ hidden:
field_attachments: true field_attachments: true
field_distributor: true field_distributor: true
field_famille: true field_famille: true
field_fiche_expo: true
field_index: true field_index: true
field_linked_articles: true field_linked_articles: true
field_linked_materials: true field_linked_materials: true
@ -83,3 +85,4 @@ hidden:
langcode: true langcode: true
links: true links: true
search_api_excerpt: true search_api_excerpt: true
synonyms: true

View File

@ -126,6 +126,7 @@ module:
mailsystem: 0 mailsystem: 0
materio_commerce: 0 materio_commerce: 0
materio_decoupled: 0 materio_decoupled: 0
materio_expo: 0
materio_flag: 0 materio_flag: 0
materio_graphql: 0 materio_graphql: 0
materio_home: 0 materio_home: 0

View File

@ -0,0 +1,27 @@
uuid: c31ef185-cef1-4e63-a11e-af52be3d4dfa
langcode: fr
status: true
dependencies:
config:
- field.storage.node.field_fiche_expo
- node.type.materiau
module:
- file
id: node.materiau.field_fiche_expo
field_name: field_fiche_expo
entity_type: node
bundle: materiau
label: 'Fiche expo'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
file_directory: fichesexpo
file_extensions: pdf
max_filesize: ''
description_field: false
handler: 'default:file'
handler_settings: { }
field_type: file

View File

@ -0,0 +1,27 @@
uuid: beb03fa0-82d7-492e-890e-e2d623d5f12e
langcode: fr
status: true
dependencies:
module:
- field_permissions
- file
- node
third_party_settings:
field_permissions:
permission_type: public
id: node.field_fiche_expo
field_name: field_fiche_expo
entity_type: node
type: file
settings:
display_field: false
display_default: false
uri_scheme: public
target_type: file
module: file
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,20 @@
uuid: 2f397526-c832-45eb-880d-592eaa058462
langcode: fr
status: true
dependencies: { }
id: config_pages
bundles:
expo_fiches:
field_fiches:
bundle: expo_fiches
name: field_fiches
entity_type_id: config_pages
rtf: 'no'
rta: 'no'
enabled: false
anonymizer: ''
notes: ''
relationship: 0
sars_filename: ''
filenames:
expo_fiches: ''

View File

@ -40,7 +40,20 @@ bundles:
notes: '' notes: ''
relationship: 0 relationship: 0
sars_filename: '' sars_filename: ''
materiau:
field_fiche_expo:
bundle: materiau
name: field_fiche_expo
entity_type_id: node
rtf: 'no'
rta: 'no'
enabled: false
anonymizer: ''
notes: ''
relationship: 0
sars_filename: ''
filenames: filenames:
thematique: '' thematique: ''
simplenews_issue: '' simplenews_issue: ''
frontpage: '' frontpage: ''
materiau: ''

View File

@ -108,6 +108,7 @@ permissions:
- 'edit any simplenews_issue content' - 'edit any simplenews_issue content'
- 'edit any static content' - 'edit any static content'
- 'edit any thematique content' - 'edit any thematique content'
- 'edit expo_fiches config page entity'
- 'edit field_company' - 'edit field_company'
- 'edit field_member_type' - 'edit field_member_type'
- 'edit field_memo' - 'edit field_memo'

View File

@ -30,6 +30,7 @@ permissions:
- 'subscribe to newsletters' - 'subscribe to newsletters'
- 'use text format wysiwyg' - 'use text format wysiwyg'
- 'view commerce_product' - 'view commerce_product'
- 'view expo_fiches config page entity'
- 'view field_showroom_files' - 'view field_showroom_files'
- 'view materio_product_type commerce_product' - 'view materio_product_type commerce_product'
- 'view privacy_policy config page entity' - 'view privacy_policy config page entity'

View File

@ -41,6 +41,7 @@ permissions:
- 'use chutier' - 'use chutier'
- 'use text format wysiwyg' - 'use text format wysiwyg'
- 'view commerce_product' - 'view commerce_product'
- 'view expo_fiches config page entity'
- 'view field_showroom_files' - 'view field_showroom_files'
- 'view materio_product_type commerce_product' - 'view materio_product_type commerce_product'
- 'view own commerce_order' - 'view own commerce_order'

View File

@ -0,0 +1 @@
materio_expo:

View File

@ -0,0 +1,5 @@
name: 'materio_expo'
type: module
description: 'My Awesome Module'
core: 8.x
package: 'Materio'

View File

@ -0,0 +1,37 @@
<?php
/**
* @file
* Contains materio_expo.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function materio_expo_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the materio_expo module.
case 'help.page.materio_expo':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('My Awesome Module') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_mail().
*/
function materio_expo_mail($key, &$message, $params) {
switch ($key) {
case 'expo_getmail_submitted':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('[EXPO] mail submitted: @mail', array('@mail' => $params['mail']));
$message['body'][] = $params['message'];
break;
}
}

View File

@ -0,0 +1,14 @@
materio_expo.qr_controller_getfile:
path: '/materio_expo/qr/file/{ref}'
defaults:
_controller: '\Drupal\materio_expo\Controller\QRController::getfile'
# _title: 'Get File'
requirements:
_permission: 'access content'
materio_expo.get_email:
path: '/materio_expo/qr/form/{ref}'
defaults:
_form: '\Drupal\materio_expo\Form\GetEmail'
# _title: ''
requirements:
_access: 'TRUE'

View File

@ -0,0 +1,45 @@
<?php
namespace Drupal\materio_expo\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;
/**
* Class QRController.
*/
class QRController extends ControllerBase {
/**
* Hello.
*
* @return string
* Return Hello string.
*/
public function getfile($ref) {
//? https://drupal.stackexchange.com/questions/255216/how-to-do-a-redirectresponse-with-a-destination-query-parameter
//* get node from ref
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $entity_storage->getQuery()
->condition('type', 'materiau')
->condition('status', '1')
->condition('field_reference', $ref);
$results = $query->execute();
$nid = array_pop($results);
$node = $entity_storage->load($nid);
//* get file from node
$file = $node->get('field_fiche_expo')->referencedEntities()[0];
//* redirect to file
return new RedirectResponse($file->createFileUrl());
// return [
// '#type' => 'markup',
// '#markup' => $this->t("Implement method: getfile with parameter(s): $ref"),
// ];
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Drupal\materio_expo\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
// use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;
/**
* Class GetEmail.
*/
class GetEmail extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'get_email';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $ref = null) {
// check if email cookie is already present
$session = \Drupal::request()->getSession();
$alreadysetemail = $session->get('materio_expo_email');
if($alreadysetemail){
// https://x-team.com/blog/drupal-goto/
$url = Url::fromRoute('materio_expo.qr_controller_getfile', ['ref'=>$ref], ['absolute' => TRUE]);
return new RedirectResponse($url->toString());
}else{
$form['email'] = [
'#type' => 'email',
// '#title' => $this->t('Email'),
'#attributes' => [
'placeholder' => $this->t('Email')
],
'#weight' => '0',
];
$form['ref'] = [
'#type' => 'hidden',
'#value' => $ref
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Submit"),
];
return $form;
}
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
//* send form submission by email
$mailManager = \Drupal::service('plugin.manager.mail');
$module = 'materio_expo';
$key = 'expo_getmail_submitted';
$to = \Drupal::config('system.site')->get('mail');
$params['mail'] = $values['mail'];
$params['message'] = $values['mail'];
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$send = true;
$result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
if ($result['result'] !== true) {
$logger = \Drupal::logger('flag_lists');
$logger->error('There was a problem sending your message.' . $values['mail']);
}
//* record email as session variable
// https://drupal.stackexchange.com/questions/197576/storing-data-session-for-anonymous-user
$session = \Drupal::request()->getSession();
$session->set('materio_expo_email', true);
//* redirect to getfile controller
$ref = $values['ref'];
$form_state->setRedirect('materio_expo.qr_controller_getfile', ['ref'=>$ref]);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -97,6 +97,7 @@ export let _v_sitebranding_block, _v_user_block, _v_header_menu,
drupalDecoupled.route_name.indexOf('user') !== -1 || drupalDecoupled.route_name.indexOf('user') !== -1 ||
drupalDecoupled.route_name.indexOf('entity.webform.canonical') !== -1 || drupalDecoupled.route_name.indexOf('entity.webform.canonical') !== -1 ||
drupalDecoupled.route_name.indexOf('entity.webform.confirmation') !== -1 || drupalDecoupled.route_name.indexOf('entity.webform.confirmation') !== -1 ||
drupalDecoupled.route_name.indexOf('materio_expo.qr_controller_getfile') !== -1 ||
(drupalDecoupled.route_name === 'entity.node.canonical' && drupalDecoupled.entity_bundle === 'simplenews_issue') (drupalDecoupled.route_name === 'entity.node.canonical' && drupalDecoupled.entity_bundle === 'simplenews_issue')
) { ) {
console.debug('NO VUEJS') console.debug('NO VUEJS')