Commit da35324e authored by i.mashevskyi@internetdevels.com's avatar i.mashevskyi@internetdevels.com
Browse files

Merge branch 'master' of https://git.internetdevels.com/Igor/study into ver1.0

parents 486a93f9 b174b749
......@@ -77,9 +77,6 @@
]
},
"extra": {
"patchLevel": {
"drupal/core": "-p2"
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
......@@ -88,6 +85,12 @@
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/{$name}": ["type:drupal-drush"]
},
"patches": {
"drupal/address": {
"Add startup configuration for Address": "https://www.drupal.org/files/issues/2018-11-19/address-visible_address_fields_per_field_formatter-2852800-20.patch"
}
},
"drupal-scaffold": {
"initial": {
".editorconfig": "../.editorconfig",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d27b614cac4df5734d2126ce1bf9e643",
"content-hash": "46b5eb8292c4a287ebaa7af67d4da4c8",
"packages": [
{
"name": "alchemy/zippy",
......@@ -1803,6 +1803,9 @@
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
},
"patches_applied": {
"Add startup configuration for Address": "https://www.drupal.org/files/issues/2018-11-19/address-visible_address_fields_per_field_formatter-2852800-20.patch"
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
......
......@@ -10,6 +10,7 @@ dependencies:
- field.field.user.user.field_osvita
- field.field.user.user.field_prizvische
- field.field.user.user.field_product_owner
- field.field.user.user.field_roles
- field.field.user.user.user_picture
- image.style.thumbnail
module:
......@@ -30,20 +31,20 @@ content:
settings: { }
third_party_settings: { }
field_address:
weight: 5
weight: 6
settings:
default_country: null
third_party_settings: { }
type: address_default
region: content
field_data_narodzhennya:
weight: 4
weight: 5
settings: { }
third_party_settings: { }
type: datetime_default
region: content
field_firma:
weight: 6
weight: 7
settings:
size: 60
placeholder: ''
......@@ -51,7 +52,7 @@ content:
type: string_textfield
region: content
field_name:
weight: 2
weight: 3
settings:
size: 60
placeholder: ''
......@@ -59,13 +60,13 @@ content:
type: string_textfield
region: content
field_osvita:
weight: 7
weight: 8
settings: { }
third_party_settings: { }
type: options_select
region: content
field_prizvische:
weight: 3
weight: 4
settings:
size: 60
placeholder: ''
......@@ -73,7 +74,13 @@ content:
type: string_textfield
region: content
field_product_owner:
weight: 8
weight: 9
settings: { }
third_party_settings: { }
type: options_select
region: content
field_roles:
weight: 2
settings: { }
third_party_settings: { }
type: options_select
......
......@@ -10,6 +10,7 @@ dependencies:
- field.field.user.user.field_osvita
- field.field.user.user.field_prizvische
- field.field.user.user.field_product_owner
- field.field.user.user.field_roles
- field.field.user.user.user_picture
- image.style.thumbnail
module:
......@@ -80,6 +81,13 @@ content:
third_party_settings: { }
type: entity_reference_label
region: content
field_roles:
weight: 8
label: above
settings: { }
third_party_settings: { }
type: list_default
region: content
user_picture:
type: image
weight: 0
......
......@@ -11,9 +11,9 @@ id: user.user.field_data_narodzhennya
field_name: field_data_narodzhennya
entity_type: user
bundle: user
label: 'Дата народження'
label: 'Date of birthday'
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
......
......@@ -10,9 +10,9 @@ id: user.user.field_firma
field_name: field_firma
entity_type: user
bundle: user
label: Фірма
label: Company
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
......
......@@ -10,9 +10,9 @@ id: user.user.field_name
field_name: field_name
entity_type: user
bundle: user
label: 'Ім''я'
label: Name
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
......
......@@ -11,9 +11,9 @@ id: user.user.field_osvita
field_name: field_osvita
entity_type: user
bundle: user
label: Освіта
label: Education
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
......
......@@ -10,9 +10,9 @@ id: user.user.field_prizvische
field_name: field_prizvische
entity_type: user
bundle: user
label: Прізвище
label: Surname
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
......
uuid: ad4f232a-8f99-4e4f-acec-aaeca84742f2
langcode: en
status: true
dependencies:
config:
- field.storage.user.field_roles
module:
- options
- user
id: user.user.field_roles
field_name: field_roles
entity_type: user
bundle: user
label: Roles
description: ''
required: true
translatable: false
default_value:
-
value: '1'
default_value_callback: ''
settings: { }
field_type: list_string
uuid: 24dc2226-c22a-4158-b1a8-be82b02b8272
langcode: en
status: true
dependencies:
module:
- options
- user
id: user.field_roles
field_name: field_roles
entity_type: user
type: list_string
settings:
allowed_values:
-
value: manager
label: manager
-
value: analytic
label: analytic
-
value: client
label: client
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
cdn_provider: ''
_core:
default_config_hash: _5qrDuRmWmRVjW00si3U1s1NrgrocA4N653EYGRfgEE
favicon:
mimetype: image/vnd.microsoft.icon
path: ''
url: 'http://study.loc/themes/contrib/bootstrap/favicon.ico'
use_default: true
features:
comment_user_picture: true
comment_user_verification: true
favicon: true
node_user_picture: true
logo:
path: ''
url: ''
use_default: true
schemas:
bootstrap: 8000
mybootstrap: 8000
roles:
anonymous:
theme: client
weight: '0'
weight: '-50'
authenticated:
theme: ''
weight: '0'
weight: '-45'
administrator:
theme: mybootstrap
weight: '0'
weight: '-49'
manager:
theme: manager
weight: '0'
weight: '-48'
analytic:
theme: mybootstrap
weight: '0'
weight: '-47'
client:
theme: client
weight: '0'
weight: '-46'
File mode changed from 100755 to 100644
......@@ -212,26 +212,17 @@ function create_paragraph($data) {
* Implements hook_FORM_ID_alter().
*/
function stat_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['account']['roles']['#access'] = TRUE;
unset($form['account']['roles']['#options']['administrator']);
unset($form['account']['roles']['#options']['authenticated']);
$form['account']['roles']['#type'] = 'select';
$form['field_address']['#states'] = [
'visible' => [
':input[name="roles"]' => [
'value' => 'client'
],
':input[name="field_roles"]' => ['value' => 'client'],
],
];
$form['field_product_owner']['#states'] = [
'visible' => [
[':input[name="roles"]' => [
'value' => 'analytic',
]],
[':input[name="field_roles"]' => ['value' => 'analytic']],
'or',
[':input[name="roles"]' => [
'value' => 'manager',
]],
[':input[name="field_roles"]' => ['value' => 'manager']],
],
];
$form['actions']['submit']['#submit'][] = 'stat_set_data_form_submit';
......@@ -244,20 +235,22 @@ function stat_form_user_register_form_alter(&$form, FormStateInterface $form_sta
* @param \Drupal\Core\Form\FormStateInterface $form_state
*/
function stat_set_data_form_submit(array $form, FormStateInterface $form_state) {
$role = $form_state->getValue('roles');
$roles = $form_state->getValue('field_roles');
$role = $roles[0]['value'];
$owner_roles = [
'manager',
'analytic'
];
$user = user_load_by_mail($form_state->getValue('mail'));
$user->addRole($role);
if (in_array($role, $owner_roles)) {
$values = $form_state->getValue('field_product_owner');
$nid = (int) $values[0]['target_id'];
if (!empty($nid)) {
$user = user_load_by_mail($form_state->getValue('mail'));
$node = Node::load($nid);
$owner_address = $node->get('field_owner_address')->getValue();
$user->set('field_address', $owner_address);
$user->save();
}
}
$user->save();
}
\ No newline at end of file
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