22 | 23 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,10 @@ |
1 |
+services: |
|
2 |
+ _defaults: |
|
3 |
+ autowire: true |
|
4 |
+ autoconfigure: true |
|
5 |
+ public: false |
|
6 |
+ |
|
7 |
+ vonRotenberg\NewsmailerBundle\: |
|
8 |
+ resource: ../src |
|
9 |
+ exclude: ../src/{VonrotenbergNewsmailerBundle.php,ContaoManager,Entity,Migrations,Model,Resources,Tests,Widget} |
|
10 |
+ |
0 | 11 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,43 @@ |
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 |
+//$GLOBALS['TL_DCA']['tl_news']['palettes']['default'] = str_replace(array('{publish_legend}','{publish_legend:hide}'),array('{nc_legend:hide},nc_sent,nc_testmail;{publish_legend}','{nc_legend:hide},nc_sent,nc_testmail;{publish_legend:hide}'),$GLOBALS['TL_DCA']['tl_news']['palettes']['default']); |
|
18 |
+PaletteManipulator::create() |
|
19 |
+ ->addLegend('nc_legend','publish_legend',PaletteManipulator::POSITION_BEFORE) |
|
20 |
+ ->addField('nc_sent','nc_legend', PaletteManipulator::POSITION_APPEND) |
|
21 |
+ ->addField('nc_testmail','nc_legend', PaletteManipulator::POSITION_APPEND) |
|
22 |
+ ->applyToPalette('default','tl_news') |
|
23 |
+; |
|
24 |
+ |
|
25 |
+/** |
|
26 |
+ * Fields |
|
27 |
+ */ |
|
28 |
+ |
|
29 |
+$GLOBALS['TL_DCA']['tl_news']['fields']['nc_sent'] = array |
|
30 |
+( |
|
31 |
+ 'exclude' => true, |
|
32 |
+ 'inputType' => 'checkbox', |
|
33 |
+ 'default' => 1, |
|
34 |
+ 'eval' => array('doNotCopy'=>true), |
|
35 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
36 |
+); |
|
37 |
+ |
|
38 |
+$GLOBALS['TL_DCA']['tl_news']['fields']['nc_testmail'] = array |
|
39 |
+( |
|
40 |
+ 'exclude' => true, |
|
41 |
+ 'inputType' => 'checkbox', |
|
42 |
+ 'eval' => array('doNotSaveEmpty'=>true), |
|
43 |
+); |
0 | 44 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
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_news.nc_sent.0"> |
|
5 |
+ <source>Do not send notification</source> |
|
6 |
+ <target>Benachrichtigung nicht senden</target> |
|
7 |
+ </trans-unit> |
|
8 |
+ <trans-unit id="tl_news.nc_sent.1"> |
|
9 |
+ <source>No notification will be sent to selected member groups. To send, uncheck the box.</source> |
|
10 |
+ <target>Es wird keine Benachrichtigung an ausgewählte Mitgliedergruppen versendet. Zum Senden, Haken entfernen.</target> |
|
11 |
+ </trans-unit> |
|
12 |
+ <trans-unit id="tl_news.nc_testmail.0"> |
|
13 |
+ <source>Send test notification</source> |
|
14 |
+ <target>Testbenachrichtigung senden</target> |
|
15 |
+ </trans-unit> |
|
16 |
+ <trans-unit id="tl_news.nc_testmail.1"> |
|
17 |
+ <source>A test notification is sent to the currently logged in backend user.</source> |
|
18 |
+ <target>Es wird eine Testbenachrichtigung an den momentan eingeloggten Backend-User gesendet.</target> |
|
19 |
+ </trans-unit> |
|
20 |
+ |
|
21 |
+ <trans-unit id="tl_news.nc_legend"> |
|
22 |
+ <source>Notifications</source> |
|
23 |
+ <target>Benachrichtigungen</target> |
|
24 |
+ </trans-unit> |
|
25 |
+ </body> |
|
26 |
+ </file> |
|
27 |
+</xliff> |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
declare(strict_types=1); |
4 | 4 |
|
5 | 5 |
/* |
6 |
- * This file is part of modal bundle for Contao. |
|
6 |
+ * This file is part of newsmailer bundle for Contao. |
|
7 | 7 |
* |
8 | 8 |
* (c) Benjamin Roth |
9 | 9 |
* |
... | ... |
@@ -13,10 +13,11 @@ declare(strict_types=1); |
13 | 13 |
namespace vonRotenberg\NewsmailerBundle\ContaoManager; |
14 | 14 |
|
15 | 15 |
use Contao\CoreBundle\ContaoCoreBundle; |
16 |
+use Contao\NewsBundle\ContaoNewsBundle; |
|
16 | 17 |
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; |
17 | 18 |
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; |
18 | 19 |
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; |
19 |
-use vonRotenberg\ModalBundle\VonrotenbergNewsmailerBundle; |
|
20 |
+use vonRotenberg\NewsmailerBundle\VonrotenbergNewsmailerBundle; |
|
20 | 21 |
|
21 | 22 |
class Plugin implements BundlePluginInterface |
22 | 23 |
{ |
... | ... |
@@ -24,7 +25,10 @@ class Plugin implements BundlePluginInterface |
24 | 25 |
{ |
25 | 26 |
return [ |
26 | 27 |
BundleConfig::create(VonrotenbergNewsmailerBundle::class) |
27 |
- ->setLoadAfter([ContaoCoreBundle::class]), |
|
28 |
+ ->setLoadAfter([ |
|
29 |
+ ContaoCoreBundle::class, |
|
30 |
+ ContaoNewsBundle::class |
|
31 |
+ ]), |
|
28 | 32 |
]; |
29 | 33 |
} |
30 | 34 |
} |
10 | 10 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,87 @@ |
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\Config; |
|
16 |
+use Contao\CoreBundle\ServiceAnnotation\Callback; |
|
17 |
+use Contao\DataContainer; |
|
18 |
+use Contao\NewsModel; |
|
19 |
+use NotificationCenter\Model\Notification; |
|
20 |
+ |
|
21 |
+class NewsSendTestmailListener |
|
22 |
+{ |
|
23 |
+ /** |
|
24 |
+ * @Callback(table="tl_news", target="fields.nc_testmail.load) |
|
25 |
+ */ |
|
26 |
+ public function onLoadCallback($varValue, DataContainer $dc) |
|
27 |
+ { |
|
28 |
+ return null; |
|
29 |
+ } |
|
30 |
+ |
|
31 |
+ public function onSaveCallback($varValue, DataContainer $dc) |
|
32 |
+ { |
|
33 |
+ if ($varValue) |
|
34 |
+ { |
|
35 |
+ $News = NewsModel::findByPk($dc->id); |
|
36 |
+ |
|
37 |
+ if ($News !== null && ($Archive = $News->getRelated('pid')) !== null && ($Notification = Notification::findByPk($Archive->nc_notification)) !== null) |
|
38 |
+ { |
|
39 |
+ $arrRow = array( |
|
40 |
+ 'date' => date('d.m.Y',$News->date), |
|
41 |
+ 'headline' => $News->headline, |
|
42 |
+ 'teaser' => \Contao\StringUtil::substr(strip_tags(str_ireplace(array('<br />','<br>','<br/>','</p>','<p>'),' ',$News->teaser)),128) |
|
43 |
+ ); |
|
44 |
+ |
|
45 |
+ if (($objJumpTo = $Archive->getRelated('jumpTo')) !== null) |
|
46 |
+ { |
|
47 |
+ $arrRow['url'] = $objJumpTo->getAbsoluteUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s').'?ltoken=%%_TOKEN_%%'; |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ |
|
51 |
+ $arrNewsPlain[] = date('d.m.Y',$News->date).' - '.$News->headline; |
|
52 |
+ $arrNewsHtml[] = '<div style="margin-bottom: 15px;"><h3>'.$arrRow['date'].' '.$arrRow['headline'].'</h3><p>'.$arrRow['teaser'].'</p>'. ($arrRow['url'] ? '<p><a href="'.$arrRow['url'].'">» Ganze Nachricht lesen...</a></p>' : '') .'</div>'; |
|
53 |
+ |
|
54 |
+ // User |
|
55 |
+ $strEmail = $this->User->email; |
|
56 |
+ if (($Member = \MemberModel::findActiveByEmailAndUsername($this->User->email)) !== null) |
|
57 |
+ { |
|
58 |
+ $strLastname = $Member->firstname; |
|
59 |
+ $strFirstname = $Member->lastname; |
|
60 |
+ if ($Member->nc_news_additionalEmail) |
|
61 |
+ { |
|
62 |
+ $strEmail .= ','.$Member->nc_news_additionalEmail; |
|
63 |
+ } |
|
64 |
+ $strToken = \TokenLogin::getOrRenewUserToken($Member); |
|
65 |
+ } else { |
|
66 |
+ $arrSplitName = explode(" ", $this->User->name); |
|
67 |
+ $strLastname = array_pop($arrSplitName); |
|
68 |
+ $strFirstname = implode(" ", $arrSplitName); |
|
69 |
+ $strToken = ''; |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ $Notification->send(array |
|
73 |
+ ( |
|
74 |
+ 'member_email' => $strEmail, |
|
75 |
+ 'member_firstname' => $strFirstname, |
|
76 |
+ 'member_lastname' => $strLastname, |
|
77 |
+ 'news_topics' => implode("\n",$arrNewsPlain), |
|
78 |
+ 'news_topics_html' => "<ul>\n<li>".str_replace('%%_TOKEN_%%',$strToken,implode("</li>\n<li>",$arrNewsHtml))."</li>\n</ul>", |
|
79 |
+ 'member_login_token' => $strToken |
|
80 |
+ ), |
|
81 |
+ $GLOBALS['TL_LANGUAGE']); |
|
82 |
+ |
|
83 |
+ Message::addConfirmation($GLOBALS['TL_LANG']['tl_news']['MSC']['nc_news_testletter']); |
|
84 |
+ } |
|
85 |
+ } |
|
86 |
+ } |
|
87 |
+} |