Browse code

Initial commit

Benjamin Roth authored on15/03/2023 23:50:38
Showing6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+* This file is part of newsmailer bundle for Contao.
7
+*
8
+* (c) Benjamin Roth
9
+*
10
+* @license LGPL-3.0-or-later
11
+*/
12
+
13
+$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['contao']['news_submitted'] = array
14
+(
15
+    'recipients'    => array
16
+    (
17
+        'member_email' // The email address of the recipient
18
+    ),
19
+    'email_text'    => array
20
+    (
21
+        'member_firstname', // The firstname of the recipient
22
+        'member_lastname', // The lastname of the recipient
23
+        'news_topics' // The titles of all new news
24
+    ),
25
+    'email_html'    => array
26
+    (
27
+        'member_firstname', // The firstname of the recipient
28
+        'member_lastname', // The lastname of the recipient
29
+        'news_topics_html', // The titles of all new news
30
+        'news_topics' // The titles of all new news
31
+    )
32
+);
0 33
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of newsmailer bundle for Contao.
5
+ *
6
+ * (c) Benjamin Roth
7
+ *
8
+ * @license LGPL-3.0-or-later
9
+ */
10
+
11
+use Contao\CoreBundle\DataContainer\PaletteManipulator;
12
+
13
+/**
14
+ * Palettes
15
+ */
16
+
17
+PaletteManipulator::create()
18
+    ->addLegend('nc_legend','protected_legend',PaletteManipulator::POSITION_BEFORE)
19
+    ->addField('nc_enable','nc_legend', PaletteManipulator::POSITION_APPEND)
20
+    ->applyToPalette('default','tl_news_archive')
21
+;
22
+$GLOBALS['TL_DCA']['tl_news_archive']['palettes']['__selector__'][] = 'nc_enable';
23
+$GLOBALS['TL_DCA']['tl_news_archive']['subpalettes']['nc_enable'] = 'nc_notification,nc_notification_groups';
24
+
25
+
26
+/**
27
+ * Fields
28
+ */
29
+
30
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_enable'] = array
31
+(
32
+    'exclude'                 => true,
33
+    'inputType'               => 'checkbox',
34
+    'eval'                    => array('tl_class'=>'w50 m12','submitOnChange'=>true),
35
+    'sql'                     => "char(1) NOT NULL default ''"
36
+);
37
+
38
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_notification_groups'] = array
39
+(
40
+    'exclude'                 => true,
41
+    'inputType'               => 'checkbox',
42
+    'foreignKey'              => 'tl_member_group.name',
43
+    'eval'                    => array('mandatory'=>true, 'multiple'=>true,'tl_class'=>'clr'),
44
+    'sql'                     => "blob NULL",
45
+    'relation'                => array('type'=>'hasMany', 'load'=>'lazy')
46
+);
47
+
48
+$GLOBALS['TL_DCA']['tl_news_archive']['fields']['nc_notification'] = array
49
+(
50
+    'exclude'                   => true,
51
+    'inputType'                 => 'select',
52
+    'eval'                      => array('mandatory'=>true,'includeBlankOption'=>true, 'chosen'=>true, 'tl_class'=>'w50'),
53
+    'sql'                       => "int(10) unsigned NOT NULL default '0'"
54
+);
0 55
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+<?xml version="1.0" ?><xliff version="1.1">
2
+    <file datatype="php" original="tl_news" source-language="en" target-language="de">
3
+        <body>
4
+            <trans-unit id="tl_nc_notification.type.news">
5
+                <source>News</source>
6
+                <target>Nachrichten</target>
7
+            </trans-unit>
8
+            <trans-unit id="tl_nc_notification.type.news_submitted.0">
9
+                <source>New news entry published</source>
10
+                <target>Neuer Newsbeitrag veröffentlicht</target>
11
+            </trans-unit>
12
+        </body>
13
+    </file>
14
+</xliff>
0 15
new file mode 100644
... ...
@@ -0,0 +1,35 @@
1
+<?xml version="1.0" ?><xliff version="1.1">
2
+    <file datatype="php" original="tl_news_archive" source-language="en" target-language="de">
3
+        <body>
4
+            <trans-unit id="tl_news_archive.nc_enable.0">
5
+                <source>Enable notifications</source>
6
+                <target>Benachrichtigungen aktivieren</target>
7
+            </trans-unit>
8
+            <trans-unit id="tl_news_archive.nc_enable.1">
9
+                <source>Allows sending notifications when publishing new news entries.</source>
10
+                <target>Ermöglicht das Versenden von Benachrichtigungen beim Veröffentlichen neuer Nachrichten.</target>
11
+            </trans-unit>
12
+            <trans-unit id="tl_news_archive.nc_notification.0">
13
+                <source>Notification</source>
14
+                <target>Benachrichtigung</target>
15
+            </trans-unit>
16
+            <trans-unit id="tl_news_archive.nc_notification.1">
17
+                <source>The notification to be sent.</source>
18
+                <target>Die zu versendende Benachrichtigung.</target>
19
+            </trans-unit>
20
+            <trans-unit id="tl_news_archive.nc_notification_groups.0">
21
+                <source>Member groups</source>
22
+                <target>Mitgliedergruppen</target>
23
+            </trans-unit>
24
+            <trans-unit id="tl_news_archive.nc_notification_groups.1">
25
+                <source>Please choose one or multiple member groups to send notifications to.</source>
26
+                <target>Bitte wählen Sie eine oder mehrere Mitgliedergruppen, an die eine Benachrichtigung versendet werden soll.</target>
27
+            </trans-unit>
28
+
29
+            <trans-unit id="tl_news_archive.nc_legend">
30
+                <source>Notifications</source>
31
+                <target>Benachrichtigungen</target>
32
+            </trans-unit>
33
+        </body>
34
+    </file>
35
+</xliff>
0 36
new file mode 100644
... ...
@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+* This file is part of newsmailer bundle for Contao.
7
+*
8
+* (c) Benjamin Roth
9
+*
10
+* @license LGPL-3.0-or-later
11
+*/
12
+
13
+namespace vonRotenberg\NewsmailerBundle\EventListener;
14
+
15
+use Contao\CoreBundle\ServiceAnnotation\Callback;
16
+use Contao\Database;
17
+use Contao\DataContainer;
18
+
19
+/**
20
+ * @Callback(table="tl_news_archive", target="fields.nc_notification.options")
21
+ */
22
+class NewsArchiveNotificationOptionsListener
23
+{
24
+    public function __invoke(DataContainer $dc)
25
+    {
26
+        $arrOptions = array();
27
+        $objNotifications = Database::getInstance()->execute("SELECT id,title FROM tl_nc_notification WHERE type='news_submitted' ORDER BY title");
28
+
29
+        while ($objNotifications->next()) {
30
+            $arrOptions[$objNotifications->id] = $objNotifications->title;
31
+        }
32
+
33
+        return $arrOptions;
34
+    }
35
+}
... ...
@@ -21,13 +21,16 @@ use NotificationCenter\Model\Notification;
21 21
 class NewsSendTestmailListener
22 22
 {
23 23
     /**
24
-     * @Callback(table="tl_news", target="fields.nc_testmail.load)
24
+     * @Callback(table="tl_news", target="fields.nc_testmail.load")
25 25
      */
26 26
     public function onLoadCallback($varValue, DataContainer $dc)
27 27
     {
28 28
         return null;
29 29
     }
30 30
 
31
+    /**
32
+     * @Callback(table="tl_news", target="fields.nc_testmail.save")
33
+     */
31 34
     public function onSaveCallback($varValue, DataContainer $dc)
32 35
     {
33 36
         if ($varValue)