Skip to content

Commit a06e5a6

Browse files
authored
Merge pull request #492 from os2ulf/release/2024-14
Release/2024 14
2 parents 4408937 + 0e0c0d6 commit a06e5a6

File tree

15 files changed

+623
-144
lines changed

15 files changed

+623
-144
lines changed

config/sync/core.entity_view_display.node.page.full.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ third_party_settings:
6262
- accordion
6363
- basic
6464
- footer
65+
- image_with_link
6566
- quote
6667
- slideshow
6768
'Inline blocks':
6869
- 'inline_block:accordion'
70+
- 'inline_block:image_with_link'
6971
- 'inline_block:quote'
7072
- 'inline_block:footer'
7173
- 'inline_block:basic'

config/sync/views.view.email_address_export.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ display:
104104
group_type: group
105105
admin_label: ''
106106
plugin_id: field
107-
label: ''
108-
exclude: true
107+
label: Navn
108+
exclude: false
109109
alter:
110110
alter_text: false
111111
text: ''
@@ -861,8 +861,8 @@ display:
861861
group_type: group
862862
admin_label: ''
863863
plugin_id: field
864-
label: ''
865-
exclude: true
864+
label: Navn
865+
exclude: false
866866
alter:
867867
alter_text: false
868868
text: ''
@@ -898,7 +898,7 @@ display:
898898
element_wrapper_type: ''
899899
element_wrapper_class: ''
900900
element_default_classes: true
901-
empty: ''
901+
empty: '{{ name }}'
902902
hide_empty: false
903903
empty_zero: true
904904
hide_alter_empty: true

webroot/modules/custom/os2uol_moderation/os2uol_moderation.module

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Drupal\Core\Entity\EntityInterface;
4+
use Drupal\os2uol_domain\DomainConfigHelper;
45

56
/**
67
* Implements hook_cron().
@@ -14,16 +15,44 @@ function os2uol_moderation_cron() {
1415
* Implements hook_content_moderation_notification_mail_data_alter().
1516
*/
1617
function os2uol_moderation_content_moderation_notification_mail_data_alter(EntityInterface $entity, array &$data) {
17-
// Get the active domain ID.
18-
$domain_id = \Drupal::service('domain.negotiator')->getActiveId();
19-
$config = \Drupal::config('os2uol_settings.settings');
18+
// Get the workflow associated with the entity.
19+
$workflow = \Drupal::service('content_moderation.moderation_information')->getWorkflowForEntity($entity);
20+
if ($workflow->id() !== 'application') {
21+
return;
22+
}
23+
24+
// Use the DomainConfigHelper to fetch domain-specific configuration.
25+
$config_helper = \Drupal::service('os2uol_domain.config_helper');
26+
$domain = \Drupal::service('domain.negotiator')->getActiveDomain();
27+
28+
// Validate that a valid domain was retrieved.
29+
if (!$domain) {
30+
\Drupal::logger('os2uol_moderation')->error('Unable to load the active domain.');
31+
return;
32+
}
33+
34+
// Fetch the domain-specific configuration.
35+
$domain_config = $config_helper->getDomainConfig('os2uol_settings.settings', $domain);
36+
37+
// Log the domain config for debugging purposes.
38+
\Drupal::logger('os2uol_moderation')->info('Using domain config: @config for domain: @domain_id', [
39+
'@config' => print_r($domain_config->getRawData(), TRUE),
40+
'@domain_id' => $domain->id(),
41+
]);
2042

2143
// Default fallback email address.
22-
$fallback_email = 'info@os2udoglaer.dk';
44+
$fallback_email = 'fallback@os2udoglaer.dk';
2345

2446
// Retrieve the configured "From" and "Reply-To" email for the active domain.
25-
$from_email = $config->get('from_reply_to_email') ?: $fallback_email;
26-
$reply_to_email = $config->get('from_reply_to_email') ?: $fallback_email;
47+
$from_email = $domain_config->get('from_reply_to_email') ?: $fallback_email;
48+
$reply_to_email = $domain_config->get('from_reply_to_email') ?: $fallback_email;
49+
50+
// Log the resolved emails for debugging purposes.
51+
\Drupal::logger('os2uol_moderation')->info('Resolved From and Reply-To emails: From: @from, Reply-To: @reply_to for domain: @domain_id', [
52+
'@from' => $from_email,
53+
'@reply_to' => $reply_to_email,
54+
'@domain_id' => $domain->id(),
55+
]);
2756

2857
// Set the "From", "Reply-To", and "Return-Path" headers.
2958
$data['headers']['From'] = $from_email;
@@ -34,6 +63,27 @@ function os2uol_moderation_content_moderation_notification_mail_data_alter(Entit
3463
\Drupal::logger('os2uol_moderation')->info('Using From and Reply-To addresses: @from, @reply_to for domain: @domain_id', [
3564
'@from' => $from_email,
3665
'@reply_to' => $reply_to_email,
37-
'@domain_id' => $domain_id,
66+
'@domain_id' => $domain->id(),
3867
]);
3968
}
69+
70+
/**
71+
* Implements hook_views_query_alter().
72+
*/
73+
function os2uol_moderation_views_query_alter($view, \Drupal\views\Plugin\views\query\QueryPluginBase $query) {
74+
// Target the specific view and display.
75+
if ($view->id() === 'workbench_recent_content' && $view->current_display === 'embed_1') {
76+
// Ensure the query is SQL-based.
77+
if ($query instanceof \Drupal\views\Plugin\views\query\Sql) {
78+
// Add an explicit WHERE clause to exclude "trash" moderation state.
79+
$query->addWhereExpression(0, "
80+
NOT EXISTS (
81+
SELECT 1
82+
FROM {content_moderation_state_field_data} cms
83+
WHERE cms.content_entity_id = node_field_data.nid
84+
AND cms.moderation_state = 'trash'
85+
)
86+
");
87+
}
88+
}
89+
}

webroot/modules/custom/os2uol_pretix/os2uol_pretix.install

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,70 @@ function os2uol_pretix_update_10001(&$sandbox) {
4040
$schema->createTable('pretix_queue', $table_schema['pretix_queue']);
4141

4242
}
43+
44+
/**
45+
* Add defaults to domain config
46+
*/
47+
function os2uol_pretix_update_10003(&$sandbox) {
48+
$config = \Drupal::configFactory()->getEditable('os2uol_settings.settings');
49+
$config
50+
->set('pretix_order_placed_subject', 'Bestilling / [node:title]')
51+
->set('pretix_order_placed_message', ['format' => 'basic_html', 'value' => '<p>
52+
Kære [user:field_name]<br>
53+
Der er kommet en ny bestilling på <a href="[node:url]">[node:title]</a>.
54+
</p>
55+
<p>
56+
[pretix_order:lines]
57+
</p>
58+
<p>
59+
----
60+
</p>
61+
<p>
62+
Denne mail er sendt automatisk fra [site:name].
63+
</p>'])
64+
->set('pretix_order_canceled_subject', 'Afbestilling / [node:title]')
65+
->set('pretix_order_canceled_message', ['format' => 'basic_html', 'value' => '<p>
66+
Kære [user:field_name]<br>
67+
Der er desværre kommet en afbestilling på <a href="[node:url]">[node:title]</a>.
68+
</p>
69+
<p>
70+
[pretix_order:lines]
71+
</p>
72+
<p>
73+
----
74+
</p>
75+
<p>
76+
Denne mail er sendt automatisk fra [site:name].
77+
</p>'])
78+
->set('pretix_order_line', ['format' => 'basic_html', 'value' => '<p>
79+
<strong>[pretix_order_line:line_number]# [pretix_order_line:name] [pretix_order_line:date_from]</strong>
80+
</p>
81+
<p>
82+
<strong>BESTILLINGSDATA</strong>
83+
</p>
84+
<p>
85+
[pretix_order_line:questions]
86+
</p>
87+
<p>
88+
<strong>ANTAL</strong>
89+
</p>
90+
<p>
91+
Antal billetter: [pretix_order_line:quantity]
92+
</p>
93+
<p>
94+
Ledige billetter: [pretix_order_line:availability]
95+
</p>
96+
<p>
97+
<strong>PRIS</strong>
98+
</p>
99+
<p>
100+
Enhedspris: [pretix_order_line:item_price] kr.
101+
</p>
102+
<p>
103+
Pris i alt: [pretix_order_line:total_price] kr.
104+
</p>'])
105+
->set('pretix_question', ['format' => 'basic_html', 'value' => '<p>
106+
[pretix_question:question]: [pretix_question:answer]
107+
</p>'])
108+
->save();
109+
}

0 commit comments

Comments
 (0)