Browse code

Update

Benjamin Roth authored on26/07/2023 15:18:55
Showing1 changed files
... ...
@@ -31,7 +31,7 @@ class PageListener {
31 31
     }
32 32
 
33 33
     /**
34
-     * @Callback(table="tl_page", target="fields.secureDownloadsFields.options"
34
+     * @Callback(table="tl_page", target="fields.secureDownloadsFields.options")
35 35
      */
36 36
     public function onSecureDownloadsFieldsOptionsCallback(?DataContainer $dc)
37 37
     {
... ...
@@ -52,7 +52,7 @@ class PageListener {
52 52
     }
53 53
 
54 54
     /**
55
-     * @Callback(table="tl_page", target="fields.sd_nc_notification.options"
55
+     * @Callback(table="tl_page", target="fields.sd_nc_notification.options")
56 56
      */
57 57
     public function onSdNcNotificationOptionsCallback(?DataContainer $dc)
58 58
     {
Browse code

Update

Benjamin Roth authored on26/07/2023 13:13:48
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
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\BackendUser;
16
+use Contao\Controller;
17
+use Contao\CoreBundle\ServiceAnnotation\Callback;
18
+use Contao\DataContainer;
19
+use Contao\System;
20
+
21
+class PageListener {
22
+
23
+    /**
24
+     * @var BackendUser
25
+     */
26
+    protected $User;
27
+
28
+    public function __construct()
29
+    {
30
+        $this->User = BackendUser::getInstance();
31
+    }
32
+
33
+    /**
34
+     * @Callback(table="tl_page", target="fields.secureDownloadsFields.options"
35
+     */
36
+    public function onSecureDownloadsFieldsOptionsCallback(?DataContainer $dc)
37
+    {
38
+        $return = array('id'=>'ID');
39
+
40
+        System::loadLanguageFile('tl_member');
41
+        Controller::loadDataContainer('tl_member');
42
+
43
+        foreach ($GLOBALS['TL_DCA']['tl_member']['fields'] as $k=>$v)
44
+        {
45
+            if (is_array($v['label']))
46
+            {
47
+                $return[$k] = $GLOBALS['TL_DCA']['tl_member']['fields'][$k]['label'][0];
48
+            }
49
+        }
50
+
51
+        return $return;
52
+    }
53
+
54
+    /**
55
+     * @Callback(table="tl_page", target="fields.sd_nc_notification.options"
56
+     */
57
+    public function onSdNcNotificationOptionsCallback(?DataContainer $dc)
58
+    {
59
+        $arrChoices = array();
60
+        $objNotifications = \Database::getInstance()->execute("SELECT id,title FROM tl_nc_notification WHERE type='secDownloads_submitted' ORDER BY title");
61
+
62
+        while ($objNotifications->next()) {
63
+            $arrChoices[$objNotifications->id] = $objNotifications->title;
64
+        }
65
+
66
+        return $arrChoices;
67
+    }
68
+
69
+}