... | ... |
@@ -13,6 +13,9 @@ use vonRotenberg\MemberfilesBundle\Model\SecureDownloadsModel; |
13 | 13 |
/** |
14 | 14 |
* Backend modules |
15 | 15 |
*/ |
16 |
+$GLOBALS['BE_MOD']['system']['memberfiles'] = [ |
|
17 |
+ 'tables' => ['tl_memberfiles_config'] |
|
18 |
+]; |
|
16 | 19 |
$GLOBALS['BE_MOD']['accounts']['member']['tables'][] = 'tl_member_secureDownloads'; |
17 | 20 |
|
18 | 21 |
/** |
19 | 22 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,120 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * Memberfiles for Contao |
|
5 |
+ * |
|
6 |
+ * Copyright (c) 2017 Benjamin Roth |
|
7 |
+ * |
|
8 |
+ * @license commercial |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+use Contao\DataContainer; |
|
12 |
+use Contao\DC_Table; |
|
13 |
+ |
|
14 |
+$GLOBALS['TL_DCA']['tl_memberfiles_config'] = [ |
|
15 |
+ 'config' => [ |
|
16 |
+ 'dataContainer' => DC_Table::class, |
|
17 |
+ 'enableVersioning' => true, |
|
18 |
+ 'sql' => [ |
|
19 |
+ 'keys' => [ |
|
20 |
+ 'id' => 'primary' |
|
21 |
+ ] |
|
22 |
+ ] |
|
23 |
+ ], |
|
24 |
+ 'list' => [ |
|
25 |
+ 'sorting' => [ |
|
26 |
+ 'mode' => DataContainer::MODE_SORTED, |
|
27 |
+ 'fields' => ['title'], |
|
28 |
+ 'flag' => DataContainer::SORT_INITIAL_LETTER_ASC, |
|
29 |
+ 'panelLayout' => 'filter;search,limit' |
|
30 |
+ ], |
|
31 |
+ 'label' => [ |
|
32 |
+ 'fields' => ['title'], |
|
33 |
+ 'format' => '%s' |
|
34 |
+ ], |
|
35 |
+ 'global_operations' => [ |
|
36 |
+ 'all' => [ |
|
37 |
+ 'href' => 'act=select', |
|
38 |
+ 'class' => 'header_edit_all', |
|
39 |
+ 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' |
|
40 |
+ ] |
|
41 |
+ ], |
|
42 |
+ 'operations' => [ |
|
43 |
+ 'edit' => [ |
|
44 |
+ 'href' => 'act=edit', |
|
45 |
+ 'icon' => 'edit.svg' |
|
46 |
+ ], |
|
47 |
+ 'copy' => [ |
|
48 |
+ 'href' => 'act=copy', |
|
49 |
+ 'icon' => 'copy.svg' |
|
50 |
+ ], |
|
51 |
+ 'delete' => [ |
|
52 |
+ 'href' => 'act=delete', |
|
53 |
+ 'icon' => 'delete.svg', |
|
54 |
+ 'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"' |
|
55 |
+ ], |
|
56 |
+ 'show' => [ |
|
57 |
+ 'href' => 'act=show', |
|
58 |
+ 'icon' => 'show.svg' |
|
59 |
+ ] |
|
60 |
+ ] |
|
61 |
+ ], |
|
62 |
+ 'palettes' => [ |
|
63 |
+ '__selector__' => ['hasNotification'], |
|
64 |
+ 'default' => '{title_legend},title;{config_legend},source,target,regexp,fields,hasNotification', |
|
65 |
+ ], |
|
66 |
+ 'subpalettes' => [ |
|
67 |
+ 'hasNotification' => 'notification', |
|
68 |
+ ], |
|
69 |
+ 'fields' => [ |
|
70 |
+ 'id' => [ |
|
71 |
+ 'sql' => ['type' => 'integer', 'unsigned' => true, 'autoincrement' => true] |
|
72 |
+ ], |
|
73 |
+ 'tstamp' => [ |
|
74 |
+ 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0] |
|
75 |
+ ], |
|
76 |
+ 'title' => [ |
|
77 |
+ 'inputType' => 'text', |
|
78 |
+ 'exclude' => true, |
|
79 |
+ 'search' => true, |
|
80 |
+ 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], |
|
81 |
+ 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''] |
|
82 |
+ ], |
|
83 |
+ 'source' => [ |
|
84 |
+ 'exclude' => true, |
|
85 |
+ 'inputType' => 'fileTree', |
|
86 |
+ 'eval' => ['mandatory' => true, 'fieldType' => 'radio', 'tl_class' => 'clr'], |
|
87 |
+ 'sql' => ['type' => 'binary', 'length' => 16, 'fixed' => true, 'notnull'=> false] |
|
88 |
+ ], |
|
89 |
+ 'target' => [ |
|
90 |
+ 'exclude' => true, |
|
91 |
+ 'inputType' => 'fileTree', |
|
92 |
+ 'eval' => ['mandatory' => true, 'fieldType' => 'radio', 'tl_class' => 'clr'], |
|
93 |
+ 'sql' => ['type' => 'binary', 'length' => 16, 'fixed' => true, 'notnull'=> false] |
|
94 |
+ ], |
|
95 |
+ 'regexp' => [ |
|
96 |
+ 'exclude' => true, |
|
97 |
+ 'inputType' => 'text', |
|
98 |
+ 'eval' => ['mandatory' => true, 'tl_class' => 'w50', 'maxlength' => 64, 'preserveTags' => true, 'decodeEntities' => true, 'placeholder' => &$GLOBALS['TL_LANG']['tl_memberfiles_config']['regexp']['placeholder']], |
|
99 |
+ 'sql' => ['type' => 'string', 'length' => 64, 'notnull' => false] |
|
100 |
+ ], |
|
101 |
+ 'fields' => [ |
|
102 |
+ 'exclude' => true, |
|
103 |
+ 'inputType' => 'checkboxWizard', |
|
104 |
+ 'eval' => ['mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'], |
|
105 |
+ 'sql' => ['type' => 'blob', 'notnull' => false] |
|
106 |
+ ], |
|
107 |
+ 'hasNotification' => [ |
|
108 |
+ 'exclude' => true, |
|
109 |
+ 'inputType' => 'checkbox', |
|
110 |
+ 'eval' => ['submitOnChange' => true, 'tl_class' => 'w50'], |
|
111 |
+ 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''] |
|
112 |
+ ], |
|
113 |
+ 'notification' => [ |
|
114 |
+ 'exclude' => true, |
|
115 |
+ 'inputType' => 'select', |
|
116 |
+ 'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'], |
|
117 |
+ 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0] |
|
118 |
+ ], |
|
119 |
+ ] |
|
120 |
+]; |
0 | 121 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,15 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<xliff version="1.1"> |
|
3 |
+ <file datatype="php" original="contao/languages/en/modules.php" source-language="en" target-language="de"> |
|
4 |
+ <body> |
|
5 |
+ <trans-unit id="MOD.memberfiles.0"> |
|
6 |
+ <source>File vault</source> |
|
7 |
+ <target>Datei-Tresor</target> |
|
8 |
+ </trans-unit> |
|
9 |
+ <trans-unit id="MOD.memberfiles.1"> |
|
10 |
+ <source>Define file vault configurations</source> |
|
11 |
+ <target>Definieren von Datei-Tresor Konfigurationen</target> |
|
12 |
+ </trans-unit> |
|
13 |
+ </body> |
|
14 |
+ </file> |
|
15 |
+</xliff> |
0 | 16 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,102 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<xliff version="1.1"> |
|
3 |
+ <file source-language="en" target-language="de" datatype="plaintext" original="messages"> |
|
4 |
+ <body> |
|
5 |
+ <!-- Legends --> |
|
6 |
+ <trans-unit id="tl_memberfiles_config.title_legend"> |
|
7 |
+ <source>Title settings</source> |
|
8 |
+ <target>Titel-Einstellungen</target> |
|
9 |
+ </trans-unit> |
|
10 |
+ <trans-unit id="tl_memberfiles_config.config_legend"> |
|
11 |
+ <source>Configuration</source> |
|
12 |
+ <target>Konfiguration</target> |
|
13 |
+ </trans-unit> |
|
14 |
+ |
|
15 |
+ <!-- Fields --> |
|
16 |
+ <trans-unit id="tl_memberfiles_config.title.0"> |
|
17 |
+ <source>Title</source> |
|
18 |
+ <target>Titel</target> |
|
19 |
+ </trans-unit> |
|
20 |
+ <trans-unit id="tl_memberfiles_config.title.1"> |
|
21 |
+ <source>Please enter a title.</source> |
|
22 |
+ <target>Bitte geben Sie einen Titel ein.</target> |
|
23 |
+ </trans-unit> |
|
24 |
+ |
|
25 |
+ <trans-unit id="tl_memberfiles_config.source.0"> |
|
26 |
+ <source>Source directory</source> |
|
27 |
+ <target>Quellverzeichnis</target> |
|
28 |
+ </trans-unit> |
|
29 |
+ <trans-unit id="tl_memberfiles_config.source.1"> |
|
30 |
+ <source>Please select the source directory.</source> |
|
31 |
+ <target>Bitte wählen Sie das Quellverzeichnis aus.</target> |
|
32 |
+ </trans-unit> |
|
33 |
+ |
|
34 |
+ <trans-unit id="tl_memberfiles_config.target.0"> |
|
35 |
+ <source>Target directory</source> |
|
36 |
+ <target>Zielverzeichnis</target> |
|
37 |
+ </trans-unit> |
|
38 |
+ <trans-unit id="tl_memberfiles_config.target.1"> |
|
39 |
+ <source>Please select the target directory.</source> |
|
40 |
+ <target>Bitte wählen Sie das Zielverzeichnis aus.</target> |
|
41 |
+ </trans-unit> |
|
42 |
+ |
|
43 |
+ <trans-unit id="tl_memberfiles_config.regexp.0"> |
|
44 |
+ <source>Regular expression</source> |
|
45 |
+ <target>Regulärer Ausdruck</target> |
|
46 |
+ </trans-unit> |
|
47 |
+ <trans-unit id="tl_memberfiles_config.regexp.1"> |
|
48 |
+ <source>Enter a regular expression for file matching. The expressions in brackets are checked against the fields defined below.</source> |
|
49 |
+ <target>Geben Sie einen regulären Ausdruck für die Dateizuordnung ein. Die Ausdrücke in Klammern werden gegen die nachfolgend definierten Felder geprüft.</target> |
|
50 |
+ </trans-unit> |
|
51 |
+ <trans-unit id="tl_memberfiles_config.regexp.placeholder"> |
|
52 |
+ <source>e.g. ^([0-9]+)_</source> |
|
53 |
+ <target>z.B. ^([0-9]+)_</target> |
|
54 |
+ </trans-unit> |
|
55 |
+ |
|
56 |
+ <trans-unit id="tl_memberfiles_config.fields.0"> |
|
57 |
+ <source>Fields</source> |
|
58 |
+ <target>Felder</target> |
|
59 |
+ </trans-unit> |
|
60 |
+ <trans-unit id="tl_memberfiles_config.fields.1"> |
|
61 |
+ <source>Please select the required fields.</source> |
|
62 |
+ <target>Bitte wählen Sie die erforderlichen Felder aus.</target> |
|
63 |
+ </trans-unit> |
|
64 |
+ |
|
65 |
+ <trans-unit id="tl_memberfiles_config.hasNotification.0"> |
|
66 |
+ <source>Enable notifications</source> |
|
67 |
+ <target>Benachrichtigungen aktivieren</target> |
|
68 |
+ </trans-unit> |
|
69 |
+ <trans-unit id="tl_memberfiles_config.hasNotification.1"> |
|
70 |
+ <source>Send notifications for this configuration.</source> |
|
71 |
+ <target>Benachrichtigungen für diese Konfiguration senden.</target> |
|
72 |
+ </trans-unit> |
|
73 |
+ |
|
74 |
+ <trans-unit id="tl_memberfiles_config.notification.0"> |
|
75 |
+ <source>Notification</source> |
|
76 |
+ <target>Benachrichtigung</target> |
|
77 |
+ </trans-unit> |
|
78 |
+ <trans-unit id="tl_memberfiles_config.notification.1"> |
|
79 |
+ <source>Please select a notification.</source> |
|
80 |
+ <target>Bitte wählen Sie eine Benachrichtigung aus.</target> |
|
81 |
+ </trans-unit> |
|
82 |
+ |
|
83 |
+ <!-- Operations --> |
|
84 |
+ <trans-unit id="tl_memberfiles_config.edit"> |
|
85 |
+ <source>Edit configuration ID %s</source> |
|
86 |
+ <target>Konfiguration ID %s bearbeiten</target> |
|
87 |
+ </trans-unit> |
|
88 |
+ <trans-unit id="tl_memberfiles_config.copy"> |
|
89 |
+ <source>Copy configuration ID %s</source> |
|
90 |
+ <target>Konfiguration ID %s kopieren</target> |
|
91 |
+ </trans-unit> |
|
92 |
+ <trans-unit id="tl_memberfiles_config.delete"> |
|
93 |
+ <source>Delete configuration ID %s</source> |
|
94 |
+ <target>Konfiguration ID %s löschen</target> |
|
95 |
+ </trans-unit> |
|
96 |
+ <trans-unit id="tl_memberfiles_config.show"> |
|
97 |
+ <source>Show details of configuration ID %s</source> |
|
98 |
+ <target>Details der Konfiguration ID %s anzeigen</target> |
|
99 |
+ </trans-unit> |
|
100 |
+ </body> |
|
101 |
+ </file> |
|
102 |
+</xliff> |
0 | 103 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,13 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<xliff version="1.1"> |
|
3 |
+ <file datatype="php" original="contao/languages/en/modules.php" source-language="en"> |
|
4 |
+ <body> |
|
5 |
+ <trans-unit id="MOD.memberfiles.0"> |
|
6 |
+ <source>File vault</source> |
|
7 |
+ </trans-unit> |
|
8 |
+ <trans-unit id="MOD.memberfiles.1"> |
|
9 |
+ <source>Define file vault configurations</source> |
|
10 |
+ </trans-unit> |
|
11 |
+ </body> |
|
12 |
+ </file> |
|
13 |
+</xliff> |
0 | 14 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,81 @@ |
1 |
+<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
+<xliff version="1.1"> |
|
3 |
+ <file source-language="en" datatype="plaintext" original="messages"> |
|
4 |
+ <body> |
|
5 |
+ <!-- Legends --> |
|
6 |
+ <trans-unit id="tl_memberfiles_config.title_legend"> |
|
7 |
+ <source>Title settings</source> |
|
8 |
+ </trans-unit> |
|
9 |
+ <trans-unit id="tl_memberfiles_config.config_legend"> |
|
10 |
+ <source>Configuration</source> |
|
11 |
+ </trans-unit> |
|
12 |
+ |
|
13 |
+ <!-- Fields --> |
|
14 |
+ <trans-unit id="tl_memberfiles_config.title.0"> |
|
15 |
+ <source>Title</source> |
|
16 |
+ </trans-unit> |
|
17 |
+ <trans-unit id="tl_memberfiles_config.title.1"> |
|
18 |
+ <source>Please enter a title.</source> |
|
19 |
+ </trans-unit> |
|
20 |
+ |
|
21 |
+ <trans-unit id="tl_memberfiles_config.source.0"> |
|
22 |
+ <source>Source directory</source> |
|
23 |
+ </trans-unit> |
|
24 |
+ <trans-unit id="tl_memberfiles_config.source.1"> |
|
25 |
+ <source>Please select the source directory.</source> |
|
26 |
+ </trans-unit> |
|
27 |
+ |
|
28 |
+ <trans-unit id="tl_memberfiles_config.target.0"> |
|
29 |
+ <source>Target directory</source> |
|
30 |
+ </trans-unit> |
|
31 |
+ <trans-unit id="tl_memberfiles_config.target.1"> |
|
32 |
+ <source>Please select the target directory.</source> |
|
33 |
+ </trans-unit> |
|
34 |
+ |
|
35 |
+ <trans-unit id="tl_memberfiles_config.regexp.0"> |
|
36 |
+ <source>Regular expression</source> |
|
37 |
+ </trans-unit> |
|
38 |
+ <trans-unit id="tl_memberfiles_config.regexp.1"> |
|
39 |
+ <source>Enter a regular expression for file matching. The expressions in brackets are checked against the fields defined below.</source> |
|
40 |
+ </trans-unit> |
|
41 |
+ <trans-unit id="tl_memberfiles_config.regexp.placeholder"> |
|
42 |
+ <source>e.g. ^([0-9]+)_</source> |
|
43 |
+ </trans-unit> |
|
44 |
+ |
|
45 |
+ <trans-unit id="tl_memberfiles_config.fields.0"> |
|
46 |
+ <source>Fields</source> |
|
47 |
+ </trans-unit> |
|
48 |
+ <trans-unit id="tl_memberfiles_config.fields.1"> |
|
49 |
+ <source>Please select the required fields.</source> |
|
50 |
+ </trans-unit> |
|
51 |
+ |
|
52 |
+ <trans-unit id="tl_memberfiles_config.hasNotification.0"> |
|
53 |
+ <source>Enable notifications</source> |
|
54 |
+ </trans-unit> |
|
55 |
+ <trans-unit id="tl_memberfiles_config.hasNotification.1"> |
|
56 |
+ <source>Send notifications for this configuration.</source> |
|
57 |
+ </trans-unit> |
|
58 |
+ |
|
59 |
+ <trans-unit id="tl_memberfiles_config.notification.0"> |
|
60 |
+ <source>Notification</source> |
|
61 |
+ </trans-unit> |
|
62 |
+ <trans-unit id="tl_memberfiles_config.notification.1"> |
|
63 |
+ <source>Please select a notification.</source> |
|
64 |
+ </trans-unit> |
|
65 |
+ |
|
66 |
+ <!-- Operations --> |
|
67 |
+ <trans-unit id="tl_memberfiles_config.edit"> |
|
68 |
+ <source>Edit configuration ID %s</source> |
|
69 |
+ </trans-unit> |
|
70 |
+ <trans-unit id="tl_memberfiles_config.copy"> |
|
71 |
+ <source>Copy configuration ID %s</source> |
|
72 |
+ </trans-unit> |
|
73 |
+ <trans-unit id="tl_memberfiles_config.delete"> |
|
74 |
+ <source>Delete configuration ID %s</source> |
|
75 |
+ </trans-unit> |
|
76 |
+ <trans-unit id="tl_memberfiles_config.show"> |
|
77 |
+ <source>Show details of configuration ID %s</source> |
|
78 |
+ </trans-unit> |
|
79 |
+ </body> |
|
80 |
+ </file> |
|
81 |
+</xliff> |
0 | 82 |
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 |
+} |