... | ... |
@@ -21,11 +21,16 @@ use Contao\DataContainer; |
21 | 21 |
*/ |
22 | 22 |
class MemberNcNewsNotificationChangedateListener |
23 | 23 |
{ |
24 |
- public function __invoke($varValue, DataContainer $dc) |
|
24 |
+ public function __invoke($varValue, $context) |
|
25 | 25 |
{ |
26 |
- if ($varValue != $dc->activeRecord->nc_news_subscribe) |
|
26 |
+ if ($context instanceof DataContainer) |
|
27 | 27 |
{ |
28 |
- Database::getInstance()->prepare("UPDATE tl_member SET nc_news_subscribe_changed=? WHERE id=?")->execute(array(time(),$dc->id)); |
|
28 |
+ $context = $context->activeRecord; |
|
29 |
+ } |
|
30 |
+ |
|
31 |
+ if ($varValue != $context->nc_news_subscribe) |
|
32 |
+ { |
|
33 |
+ Database::getInstance()->prepare("UPDATE tl_member SET nc_news_subscribe_changed=? WHERE id=?")->execute(array(time(),$context->id)); |
|
29 | 34 |
} |
30 | 35 |
|
31 | 36 |
return $varValue; |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,33 @@ |
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_member", target="fields.nc_news_subscribe.save") |
|
21 |
+ */ |
|
22 |
+class MemberNcNewsNotificationChangedateListener |
|
23 |
+{ |
|
24 |
+ public function __invoke($varValue, DataContainer $dc) |
|
25 |
+ { |
|
26 |
+ if ($varValue != $dc->activeRecord->nc_news_subscribe) |
|
27 |
+ { |
|
28 |
+ Database::getInstance()->prepare("UPDATE tl_member SET nc_news_subscribe_changed=? WHERE id=?")->execute(array(time(),$dc->id)); |
|
29 |
+ } |
|
30 |
+ |
|
31 |
+ return $varValue; |
|
32 |
+ } |
|
33 |
+} |