1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,77 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+declare(strict_types=1); |
|
4 |
+ |
|
5 |
+/* |
|
6 |
+ * This file is part of memberfiles bundle. |
|
7 |
+ * |
|
8 |
+ * (c) vonRotenberg |
|
9 |
+ * |
|
10 |
+ * @license commercial |
|
11 |
+ */ |
|
12 |
+ |
|
13 |
+namespace vonRotenberg\MemberfilesBundle\EventListener\DataContainer; |
|
14 |
+ |
|
15 |
+use Contao\Backend; |
|
16 |
+use Contao\BackendUser; |
|
17 |
+use Contao\Controller; |
|
18 |
+use Contao\CoreBundle\ServiceAnnotation\Callback; |
|
19 |
+use Contao\DataContainer; |
|
20 |
+use Contao\File; |
|
21 |
+use Contao\Image; |
|
22 |
+use Contao\Input; |
|
23 |
+use Contao\StringUtil; |
|
24 |
+use Contao\System; |
|
25 |
+use Contao\Date; |
|
26 |
+use Contao\Config; |
|
27 |
+use vonRotenberg\MemberfilesBundle\Model\SecureDownloadsModel; |
|
28 |
+ |
|
29 |
+class MemberfilesConfigListener { |
|
30 |
+ |
|
31 |
+ /** |
|
32 |
+ * @var BackendUser |
|
33 |
+ */ |
|
34 |
+ protected $User; |
|
35 |
+ |
|
36 |
+ public function __construct() |
|
37 |
+ { |
|
38 |
+ $this->User = BackendUser::getInstance(); |
|
39 |
+ } |
|
40 |
+ |
|
41 |
+ /** |
|
42 |
+ * @Callback(table="tl_memberfiles_config", target="fields.fields.options") |
|
43 |
+ */ |
|
44 |
+ public function onFieldsOptionsCallback(?DataContainer $dc) |
|
45 |
+ { |
|
46 |
+ $return = array('id'=>'ID'); |
|
47 |
+ |
|
48 |
+ System::loadLanguageFile('tl_member'); |
|
49 |
+ Controller::loadDataContainer('tl_member'); |
|
50 |
+ |
|
51 |
+ foreach ($GLOBALS['TL_DCA']['tl_member']['fields'] as $k=>$v) |
|
52 |
+ { |
|
53 |
+ if (is_array($v['label'])) |
|
54 |
+ { |
|
55 |
+ $return[$k] = $GLOBALS['TL_DCA']['tl_member']['fields'][$k]['label'][0]; |
|
56 |
+ } |
|
57 |
+ } |
|
58 |
+ |
|
59 |
+ return $return; |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ /** |
|
63 |
+ * @Callback(table="tl_memberfiles_config", target="fields.notification.options") |
|
64 |
+ */ |
|
65 |
+ public function onNotificationOptionsCallback(?DataContainer $dc) |
|
66 |
+ { |
|
67 |
+ $arrChoices = array(); |
|
68 |
+ $objNotifications = \Database::getInstance()->execute("SELECT id,title FROM tl_nc_notification WHERE type='secDownloads_submitted' ORDER BY title"); |
|
69 |
+ |
|
70 |
+ while ($objNotifications->next()) { |
|
71 |
+ $arrChoices[$objNotifications->id] = $objNotifications->title; |
|
72 |
+ } |
|
73 |
+ |
|
74 |
+ return $arrChoices; |
|
75 |
+ } |
|
76 |
+ |
|
77 |
+} |