Browse code

Progress live

Benjamin Roth authored on12/12/2022 09:35:54
Showing4 changed files
1 1
deleted file mode 100644
... ...
@@ -1,315 +0,0 @@
1
-<?php
2
-
3
-/**
4
- * TeamList for Contao
5
- *
6
- * Copyright (c) 2016 Benjamin Roth
7
- *
8
- * @license LGPL-3.0+
9
- */
10
-
11
-/**
12
- * Table tl_eSM_team
13
- */
14
-
15
-use Contao\DC_Table;
16
-use Contao\DataContainer;
17
-
18
-$GLOBALS['TL_DCA']['tl_eSM_team'] = array
19
-(
20
-
21
-	// Config
22
-	'config' => array
23
-	(
24
-		'dataContainer'               => DC_Table::class,
25
-        'ptable'                      => 'tl_eSM_team_group',
26
-		'enableVersioning'            => true,
27
-		'sql' => array
28
-		(
29
-			'keys' => array
30
-			(
31
-				'id' => 'primary',
32
-                'pid' => 'index',
33
-                'pid,published' => 'index'
34
-            )
35
-		)
36
-	),
37
-
38
-	// List
39
-	'list' => array
40
-	(
41
-		'sorting' => array
42
-		(
43
-
44
-			'mode'                    => DataContainer::MODE_PARENT,
45
-			'fields'                  => array('division', 'lastname'),
46
-            'headerFields'            => array('title'),
47
-            'panelLayout'             => 'filter,search;sort,limit',
48
-//            'child_record_callback'   => array('tl_eSM_team', 'listMembers')
49
-        ),
50
-        'label' => array
51
-        (
52
-
53
-        ),
54
-		'global_operations' => array
55
-		(
56
-			'all' => array
57
-			(
58
-				'href'                => 'act=select',
59
-				'class'               => 'header_edit_all',
60
-				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
61
-			)
62
-		),
63
-		'operations' => array
64
-		(
65
-			'edit' => array
66
-			(
67
-				'href'                => 'act=edit',
68
-				'icon'                => 'edit.svg'
69
-			),
70
-			'copy' => array
71
-			(
72
-				'href'                => 'act=paste&amp;mode=copy',
73
-                'attributes'          => 'onclick="Backend.getScrollOffset()"',
74
-				'icon'                => 'copy.svg'
75
-			),
76
-            'cut' => array
77
-            (
78
-                'href'                => 'act=paste&amp;mode=cut',
79
-                'icon'                => 'cut.svg',
80
-                'attributes'          => 'onclick="Backend.getScrollOffset()"'
81
-            ),
82
-			'delete' => array
83
-			(
84
-				'href'                => 'act=delete',
85
-				'icon'                => 'delete.svg',
86
-                'attributes'          => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
87
-			),
88
-			'toggle' => array
89
-			(
90
-                'href'                => 'act=toggle&amp;field=invisible',
91
-				'icon'                => 'visible.svg',
92
-//				'button_callback'     => array('tl_eSM_team', 'toggleIcon')
93
-			),
94
-            'show' => array
95
-            (
96
-                'href'                => 'act=show',
97
-                'icon'                => 'show.svg'
98
-            )
99
-		)
100
-	),
101
-
102
-	// Palettes
103
-	'palettes' => array
104
-	(
105
-		'default'                     => '{person_legend},firstname,lastname,comment;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
106
-	),
107
-
108
-	// Subpalettes
109
-	'subpalettes' => array
110
-	(
111
-	),
112
-
113
-	// Fields
114
-	'fields' => array
115
-	(
116
-		'id' => array
117
-		(
118
-			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
119
-		),
120
-        'pid' => array
121
-        (
122
-          'foreignKey'              => 'tl_faq_category.title',
123
-          'sql'                     => "int(10) unsigned NOT NULL default '0'",
124
-          'relation'                => array('type'=>'belongsTo', 'load'=>'eager')
125
-        ),
126
-		'tstamp' => array
127
-		(
128
-			'sql'                     => "int(10) unsigned NOT NULL default '0'"
129
-		),
130
-		'firstname' => array
131
-		(
132
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['firstname'],
133
-			'exclude'                 => true,
134
-			'search'                  => true,
135
-			'inputType'               => 'text',
136
-			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
137
-			'sql'                     => "varchar(128) NOT NULL default ''"
138
-		),
139
-		'lastname' => array
140
-		(
141
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['lastname'],
142
-			'exclude'                 => true,
143
-			'search'                  => true,
144
-			'inputType'               => 'text',
145
-			'eval'                    => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'w50'),
146
-			'sql'                     => "varchar(128) NOT NULL default ''"
147
-		),
148
-		'position' => array
149
-		(
150
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['position'],
151
-			'exclude'                 => true,
152
-			'search'                  => true,
153
-			'inputType'               => 'text',
154
-			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
155
-			'sql'                     => "varchar(128) NOT NULL default ''"
156
-		),
157
-        'comment' => array
158
-        (
159
-            'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['comment'],
160
-            'exclude'                 => true,
161
-            'inputType'               => 'textarea',
162
-            'eval'                    => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'clr'),
163
-            'sql'                     => "varchar(128) NOT NULL default ''"
164
-        ),
165
-		'division' => array
166
-		(
167
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['division'],
168
-			'exclude'                 => true,
169
-			'filter'                  => true,
170
-			'inputType'               => 'select',
171
-			'options'                 => $GLOBALS['eSM_team']['divisions'],
172
-			'reference'               => &$GLOBALS['TL_LANG']['REF']['divisions'],
173
-			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
174
-			'sql'                     => "varchar(128) NOT NULL default ''"
175
-		),
176
-		'singleSRC' => array
177
-		(
178
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['singleSRC'],
179
-			'exclude'                 => true,
180
-			'inputType'               => 'fileTree',
181
-			'eval'                    => array('filesOnly'=>true, 'extensions'=>Config::get('validImageTypes'), 'fieldType'=>'radio', 'mandatory'=>true),
182
-			'sql'                     => "binary(16) NULL"
183
-		),
184
-		'published' => array
185
-		(
186
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['published'],
187
-			'exclude'                 => true,
188
-			'filter'                  => true,
189
-			'inputType'               => 'checkbox',
190
-			'default'                 => '1',
191
-			'eval'                    => array('doNotCopy'=>true),
192
-			'sql'                     => "char(1) NOT NULL default ''"
193
-		),
194
-	)
195
-);
196
-
197
-/**
198
- * Provide miscellaneous methods that are used by the data configuration array.
199
- */
200
-class tl_eSM_team extends Backend
201
-{
202
-
203
-	/**
204
-	 * Import the back end user object
205
-	 */
206
-	public function __construct()
207
-	{
208
-		parent::__construct();
209
-		$this->import('BackendUser', 'User');
210
-	}
211
-
212
-  /**
213
-   * Add the type of input field
214
-   *
215
-   * @param array $arrRow
216
-   *
217
-   * @return string
218
-   */
219
-  public function listMembers($arrRow)
220
-  {
221
-    return '
222
-<div style="float: left; width: 35%;">' . $arrRow['firstname'] . ' ' . $arrRow['lastname'] . '</div>
223
-<div style="font-size: .625rem; color: #c6c6c6;"><strong>[' . $arrRow['position'] . ']</strong></div>' . "\n";
224
-  }
225
-
226
-	/**
227
-	 * Return the "toggle visibility" button
228
-	 *
229
-	 * @param array  $row
230
-	 * @param string $href
231
-	 * @param string $label
232
-	 * @param string $title
233
-	 * @param string $icon
234
-	 * @param string $attributes
235
-	 *
236
-	 * @return string
237
-	 */
238
-	public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
239
-	{
240
-		if (strlen(Input::get('tid')))
241
-		{
242
-			$this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1), (@func_get_arg(12) ?: null));
243
-			$this->redirect($this->getReferer());
244
-		}
245
-
246
-		// Check permissions AFTER checking the tid, so hacking attempts are logged
247
-		if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
248
-		{
249
-			return '';
250
-		}
251
-
252
-		$href .= '&amp;tid='.$row['id'].'&amp;state='.($row['published'] ? '' : 1);
253
-
254
-		if (!$row['published'])
255
-		{
256
-			$icon = 'invisible.gif';
257
-		}
258
-
259
-		return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label, 'data-state="' . ($row['published'] ? 1 : 0) . '"').'</a> ';
260
-	}
261
-
262
-
263
-	/**
264
-	 * Disable/enable a user group
265
-	 *
266
-	 * @param integer       $intId
267
-	 * @param boolean       $blnVisible
268
-	 * @param DataContainer $dc
269
-	 */
270
-	public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null)
271
-	{
272
-		// Set the ID and action
273
-		Input::setGet('id', $intId);
274
-		Input::setGet('act', 'toggle');
275
-
276
-		if ($dc)
277
-		{
278
-			$dc->id = $intId; // see #8043
279
-		}
280
-
281
-		// Check the field access
282
-		if (!$this->User->hasAccess('tl_eSM_team::published', 'alexf'))
283
-		{
284
-			$this->log('Not enough permissions to publish/unpublish teammember ID "'.$intId.'"', __METHOD__, TL_ERROR);
285
-			$this->redirect('contao/main.php?act=error');
286
-		}
287
-
288
-		$objVersions = new Versions('tl_eSM_team', $intId);
289
-		$objVersions->initialize();
290
-
291
-		// Trigger the save_callback
292
-		if (is_array($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback']))
293
-		{
294
-			foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'] as $callback)
295
-			{
296
-				if (is_array($callback))
297
-				{
298
-					$this->import($callback[0]);
299
-					$blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, ($dc ?: $this));
300
-				}
301
-				elseif (is_callable($callback))
302
-				{
303
-					$blnVisible = $callback($blnVisible, ($dc ?: $this));
304
-				}
305
-			}
306
-		}
307
-
308
-		// Update the database
309
-		$this->Database->prepare("UPDATE tl_eSM_team SET tstamp=". time() .", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")
310
-			->execute($intId);
311
-
312
-		$objVersions->create();
313
-		$this->log('A new version of record "tl_eSM_team.id='.$intId.'" has been created'.$this->getParentEntries('tl_eSM_team', $intId), __METHOD__, TL_GENERAL);
314
-	}
315
-}
316 0
\ No newline at end of file
317 1
deleted file mode 100644
... ...
@@ -1,160 +0,0 @@
1
-<?php
2
-
3
-/**
4
- * TeamList for Contao
5
- *
6
- * Copyright (c) 2016 Benjamin Roth
7
- *
8
- * @license LGPL-3.0+
9
- */
10
-
11
-/**
12
- * Table tl_eSM_team_group
13
- */
14
-
15
-use Contao\DC_Table;
16
-use Contao\DataContainer;
17
-use Contao\System;
18
-use Contao\CoreBundle\Security\ContaoCorePermissions;
19
-
20
-$GLOBALS['TL_DCA']['tl_eSM_team_group'] = array
21
-(
22
-
23
-	// Config
24
-	'config' => array
25
-	(
26
-		'dataContainer'               => DC_Table::class,
27
-        'ctable'                      => array('tl_eSM_team'),
28
-        'switchToEdit'                => true,
29
-        'enableVersioning'            => true,
30
-		'sql' => array
31
-		(
32
-			'keys' => array
33
-			(
34
-				'id' => 'primary'
35
-			)
36
-		)
37
-	),
38
-
39
-	// List
40
-	'list' => array
41
-	(
42
-		'sorting' => array
43
-		(
44
-			'mode'                    => DataContainer::MODE_SORTED,
45
-			'fields'                  => array('title'),
46
-			'flag'                    => 1,
47
-			'panelLayout'             => 'filter,search;sort,limit',
48
-		),
49
-		'label' => array
50
-		(
51
-			'fields'                  => array('title'),
52
-			'format'                  => '%s'
53
-		),
54
-		'global_operations' => array
55
-		(
56
-			'all' => array
57
-			(
58
-				'href'                => 'act=select',
59
-				'class'               => 'header_edit_all',
60
-				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
61
-			)
62
-		),
63
-		'operations' => array
64
-		(
65
-            'edit' => array
66
-            (
67
-                'href'                => 'table=tl_eSM_team',
68
-                'icon'                => 'edit.svg'
69
-            ),
70
-            'editheader' => array
71
-            (
72
-                'href'                => 'act=edit',
73
-                'icon'                => 'header.svg',
74
-                'button_callback'     => array('tl_eSM_team_group', 'editHeader')
75
-            ),
76
-			'copy' => array
77
-			(
78
-				'href'                => 'act=copy',
79
-				'icon'                => 'copy.svg'
80
-			),
81
-            'delete' => array
82
-            (
83
-                'href'                => 'act=delete',
84
-                'icon'                => 'delete.svg',
85
-                'attributes'          => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
86
-            ),
87
-            'show' => array
88
-            (
89
-                'href'                => 'act=show',
90
-                'icon'                => 'show.svg'
91
-            )
92
-		)
93
-	),
94
-
95
-	// Palettes
96
-	'palettes' => array
97
-	(
98
-		'default'                     => '{title_legend},title'
99
-	),
100
-
101
-	// Subpalettes
102
-	'subpalettes' => array
103
-	(
104
-	),
105
-
106
-	// Fields
107
-	'fields' => array
108
-	(
109
-		'id' => array
110
-		(
111
-			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
112
-		),
113
-		'tstamp' => array
114
-		(
115
-			'sql'                     => "int(10) unsigned NOT NULL default '0'"
116
-		),
117
-		'title' => array
118
-		(
119
-			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['title'],
120
-			'exclude'                 => true,
121
-			'search'                  => true,
122
-			'inputType'               => 'text',
123
-			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
124
-			'sql'                     => "varchar(128) NOT NULL default ''"
125
-		)
126
-	)
127
-);
128
-
129
-/**
130
- * Provide miscellaneous methods that are used by the data configuration array.
131
- */
132
-class tl_eSM_team_group extends Backend
133
-{
134
-
135
-	/**
136
-	 * Import the back end user object
137
-	 */
138
-	public function __construct()
139
-	{
140
-		parent::__construct();
141
-		$this->import('BackendUser', 'User');
142
-	}
143
-
144
-  /**
145
-   * Return the edit header button
146
-   *
147
-   * @param array  $row
148
-   * @param string $href
149
-   * @param string $label
150
-   * @param string $title
151
-   * @param string $icon
152
-   * @param string $attributes
153
-   *
154
-   * @return string
155
-   */
156
-  public function editHeader($row, $href, $label, $title, $icon, $attributes)
157
-  {
158
-    return System::getContainer()->get('security.helper')->isGranted(ContaoCorePermissions::USER_CAN_EDIT_FIELDS_OF_TABLE,'tl_eSM_team') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.gif$/i', '_.gif', $icon)).' ';
159
-  }
160
-}
161 0
\ No newline at end of file
162 1
new file mode 100644
... ...
@@ -0,0 +1,314 @@
1
+<?php
2
+/**
3
+ * TeamList for Contao
4
+ *
5
+ * Copyright (c) 2016 Benjamin Roth
6
+ *
7
+ * @license LGPL-3.0+
8
+ */
9
+
10
+/**
11
+ * Table tl_esm_team
12
+ */
13
+
14
+use Contao\DC_Table;
15
+use Contao\DataContainer;
16
+
17
+$GLOBALS['TL_DCA']['tl_esm_team'] = array
18
+(
19
+
20
+	// Config
21
+	'config' => array
22
+	(
23
+		'dataContainer'               => DC_Table::class,
24
+        'ptable'                      => 'tl_esm_team_group',
25
+		'enableVersioning'            => true,
26
+		'sql' => array
27
+		(
28
+			'keys' => array
29
+			(
30
+				'id' => 'primary',
31
+                'pid' => 'index',
32
+                'pid,published' => 'index'
33
+            )
34
+		)
35
+	),
36
+
37
+	// List
38
+	'list' => array
39
+	(
40
+		'sorting' => array
41
+		(
42
+
43
+			'mode'                    => DataContainer::MODE_PARENT,
44
+			'fields'                  => array('division', 'lastname'),
45
+            'headerFields'            => array('title'),
46
+            'panelLayout'             => 'filter,search;sort,limit',
47
+//            'child_record_callback'   => array('tl_esm_team', 'listMembers')
48
+        ),
49
+        'label' => array
50
+        (
51
+
52
+        ),
53
+		'global_operations' => array
54
+		(
55
+			'all' => array
56
+			(
57
+				'href'                => 'act=select',
58
+				'class'               => 'header_edit_all',
59
+				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
60
+			)
61
+		),
62
+		'operations' => array
63
+		(
64
+			'edit' => array
65
+			(
66
+				'href'                => 'act=edit',
67
+				'icon'                => 'edit.svg'
68
+			),
69
+			'copy' => array
70
+			(
71
+				'href'                => 'act=paste&amp;mode=copy',
72
+                'attributes'          => 'onclick="Backend.getScrollOffset()"',
73
+				'icon'                => 'copy.svg'
74
+			),
75
+            'cut' => array
76
+            (
77
+                'href'                => 'act=paste&amp;mode=cut',
78
+                'icon'                => 'cut.svg',
79
+                'attributes'          => 'onclick="Backend.getScrollOffset()"'
80
+            ),
81
+			'delete' => array
82
+			(
83
+				'href'                => 'act=delete',
84
+				'icon'                => 'delete.svg',
85
+                'attributes'          => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
86
+			),
87
+			'toggle' => array
88
+			(
89
+                'href'                => 'act=toggle&amp;field=invisible',
90
+				'icon'                => 'visible.svg',
91
+//				'button_callback'     => array('tl_esm_team', 'toggleIcon')
92
+			),
93
+            'show' => array
94
+            (
95
+                'href'                => 'act=show',
96
+                'icon'                => 'show.svg'
97
+            )
98
+		)
99
+	),
100
+
101
+	// Palettes
102
+	'palettes' => array
103
+	(
104
+		'default'                     => '{person_legend},firstname,lastname,comment;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
105
+	),
106
+
107
+	// Subpalettes
108
+	'subpalettes' => array
109
+	(
110
+	),
111
+
112
+	// Fields
113
+	'fields' => array
114
+	(
115
+		'id' => array
116
+		(
117
+			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
118
+		),
119
+        'pid' => array
120
+        (
121
+          'foreignKey'              => 'tl_faq_category.title',
122
+          'sql'                     => "int(10) unsigned NOT NULL default '0'",
123
+          'relation'                => array('type'=>'belongsTo', 'load'=>'eager')
124
+        ),
125
+		'tstamp' => array
126
+		(
127
+			'sql'                     => "int(10) unsigned NOT NULL default '0'"
128
+		),
129
+		'firstname' => array
130
+		(
131
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['firstname'],
132
+			'exclude'                 => true,
133
+			'search'                  => true,
134
+			'inputType'               => 'text',
135
+			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
136
+			'sql'                     => "varchar(128) NOT NULL default ''"
137
+		),
138
+		'lastname' => array
139
+		(
140
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['lastname'],
141
+			'exclude'                 => true,
142
+			'search'                  => true,
143
+			'inputType'               => 'text',
144
+			'eval'                    => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'w50'),
145
+			'sql'                     => "varchar(128) NOT NULL default ''"
146
+		),
147
+		'position' => array
148
+		(
149
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['position'],
150
+			'exclude'                 => true,
151
+			'search'                  => true,
152
+			'inputType'               => 'text',
153
+			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
154
+			'sql'                     => "varchar(128) NOT NULL default ''"
155
+		),
156
+        'comment' => array
157
+        (
158
+            'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['comment'],
159
+            'exclude'                 => true,
160
+            'inputType'               => 'textarea',
161
+            'eval'                    => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'clr'),
162
+            'sql'                     => "varchar(128) NOT NULL default ''"
163
+        ),
164
+		'division' => array
165
+		(
166
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['division'],
167
+			'exclude'                 => true,
168
+			'filter'                  => true,
169
+			'inputType'               => 'select',
170
+			'options'                 => $GLOBALS['eSM_team']['divisions'],
171
+			'reference'               => &$GLOBALS['TL_LANG']['REF']['divisions'],
172
+			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
173
+			'sql'                     => "varchar(128) NOT NULL default ''"
174
+		),
175
+		'singleSRC' => array
176
+		(
177
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['singleSRC'],
178
+			'exclude'                 => true,
179
+			'inputType'               => 'fileTree',
180
+			'eval'                    => array('filesOnly'=>true, 'extensions'=>Config::get('validImageTypes'), 'fieldType'=>'radio', 'mandatory'=>true),
181
+			'sql'                     => "binary(16) NULL"
182
+		),
183
+		'published' => array
184
+		(
185
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team']['published'],
186
+			'exclude'                 => true,
187
+			'filter'                  => true,
188
+			'inputType'               => 'checkbox',
189
+			'default'                 => '1',
190
+			'eval'                    => array('doNotCopy'=>true),
191
+			'sql'                     => "char(1) NOT NULL default ''"
192
+		),
193
+	)
194
+);
195
+
196
+/**
197
+ * Provide miscellaneous methods that are used by the data configuration array.
198
+ */
199
+class tl_esm_team extends Backend
200
+{
201
+
202
+	/**
203
+	 * Import the back end user object
204
+	 */
205
+	public function __construct()
206
+	{
207
+		parent::__construct();
208
+		$this->import('BackendUser', 'User');
209
+	}
210
+
211
+  /**
212
+   * Add the type of input field
213
+   *
214
+   * @param array $arrRow
215
+   *
216
+   * @return string
217
+   */
218
+  public function listMembers($arrRow)
219
+  {
220
+    return '
221
+<div style="float: left; width: 35%;">' . $arrRow['firstname'] . ' ' . $arrRow['lastname'] . '</div>
222
+<div style="font-size: .625rem; color: #c6c6c6;"><strong>[' . $arrRow['position'] . ']</strong></div>' . "\n";
223
+  }
224
+
225
+	/**
226
+	 * Return the "toggle visibility" button
227
+	 *
228
+	 * @param array  $row
229
+	 * @param string $href
230
+	 * @param string $label
231
+	 * @param string $title
232
+	 * @param string $icon
233
+	 * @param string $attributes
234
+	 *
235
+	 * @return string
236
+	 */
237
+	public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
238
+	{
239
+		if (strlen(Input::get('tid')))
240
+		{
241
+			$this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1), (@func_get_arg(12) ?: null));
242
+			$this->redirect($this->getReferer());
243
+		}
244
+
245
+		// Check permissions AFTER checking the tid, so hacking attempts are logged
246
+		if (!$this->User->hasAccess('tl_esm_team::published', 'alexf'))
247
+		{
248
+			return '';
249
+		}
250
+
251
+		$href .= '&amp;tid='.$row['id'].'&amp;state='.($row['published'] ? '' : 1);
252
+
253
+		if (!$row['published'])
254
+		{
255
+			$icon = 'invisible.gif';
256
+		}
257
+
258
+		return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label, 'data-state="' . ($row['published'] ? 1 : 0) . '"').'</a> ';
259
+	}
260
+
261
+
262
+	/**
263
+	 * Disable/enable a user group
264
+	 *
265
+	 * @param integer       $intId
266
+	 * @param boolean       $blnVisible
267
+	 * @param DataContainer $dc
268
+	 */
269
+	public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null)
270
+	{
271
+		// Set the ID and action
272
+		Input::setGet('id', $intId);
273
+		Input::setGet('act', 'toggle');
274
+
275
+		if ($dc)
276
+		{
277
+			$dc->id = $intId; // see #8043
278
+		}
279
+
280
+		// Check the field access
281
+		if (!$this->User->hasAccess('tl_esm_team::published', 'alexf'))
282
+		{
283
+			$this->log('Not enough permissions to publish/unpublish teammember ID "'.$intId.'"', __METHOD__, TL_ERROR);
284
+			$this->redirect('contao/main.php?act=error');
285
+		}
286
+
287
+		$objVersions = new Versions('tl_esm_team', $intId);
288
+		$objVersions->initialize();
289
+
290
+		// Trigger the save_callback
291
+		if (is_array($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback']))
292
+		{
293
+			foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'] as $callback)
294
+			{
295
+				if (is_array($callback))
296
+				{
297
+					$this->import($callback[0]);
298
+					$blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, ($dc ?: $this));
299
+				}
300
+				elseif (is_callable($callback))
301
+				{
302
+					$blnVisible = $callback($blnVisible, ($dc ?: $this));
303
+				}
304
+			}
305
+		}
306
+
307
+		// Update the database
308
+		$this->Database->prepare("UPDATE tl_esm_team SET tstamp=". time() .", published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")
309
+			->execute($intId);
310
+
311
+		$objVersions->create();
312
+		$this->log('A new version of record "tl_esm_team.id='.$intId.'" has been created'.$this->getParentEntries('tl_esm_team', $intId), __METHOD__, TL_GENERAL);
313
+	}
314
+}
0 315
new file mode 100644
... ...
@@ -0,0 +1,159 @@
1
+<?php
2
+/**
3
+ * TeamList for Contao
4
+ *
5
+ * Copyright (c) 2016 Benjamin Roth
6
+ *
7
+ * @license LGPL-3.0+
8
+ */
9
+
10
+/**
11
+ * Table tl_esm_team_group
12
+ */
13
+
14
+use Contao\DC_Table;
15
+use Contao\DataContainer;
16
+use Contao\System;
17
+use Contao\CoreBundle\Security\ContaoCorePermissions;
18
+
19
+$GLOBALS['TL_DCA']['tl_esm_team_group'] = array
20
+(
21
+
22
+	// Config
23
+	'config' => array
24
+	(
25
+		'dataContainer'               => DC_Table::class,
26
+        'ctable'                      => array('tl_esm_team'),
27
+        'switchToEdit'                => true,
28
+        'enableVersioning'            => true,
29
+		'sql' => array
30
+		(
31
+			'keys' => array
32
+			(
33
+				'id' => 'primary'
34
+			)
35
+		)
36
+	),
37
+
38
+	// List
39
+	'list' => array
40
+	(
41
+		'sorting' => array
42
+		(
43
+			'mode'                    => DataContainer::MODE_SORTED,
44
+			'fields'                  => array('title'),
45
+			'flag'                    => 1,
46
+			'panelLayout'             => 'filter,search;sort,limit',
47
+		),
48
+		'label' => array
49
+		(
50
+			'fields'                  => array('title'),
51
+			'format'                  => '%s'
52
+		),
53
+		'global_operations' => array
54
+		(
55
+			'all' => array
56
+			(
57
+				'href'                => 'act=select',
58
+				'class'               => 'header_edit_all',
59
+				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
60
+			)
61
+		),
62
+		'operations' => array
63
+		(
64
+            'edit' => array
65
+            (
66
+                'href'                => 'table=tl_esm_team',
67
+                'icon'                => 'edit.svg'
68
+            ),
69
+            'editheader' => array
70
+            (
71
+                'href'                => 'act=edit',
72
+                'icon'                => 'header.svg',
73
+                'button_callback'     => array('tl_esm_team_group', 'editHeader')
74
+            ),
75
+			'copy' => array
76
+			(
77
+				'href'                => 'act=copy',
78
+				'icon'                => 'copy.svg'
79
+			),
80
+            'delete' => array
81
+            (
82
+                'href'                => 'act=delete',
83
+                'icon'                => 'delete.svg',
84
+                'attributes'          => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
85
+            ),
86
+            'show' => array
87
+            (
88
+                'href'                => 'act=show',
89
+                'icon'                => 'show.svg'
90
+            )
91
+		)
92
+	),
93
+
94
+	// Palettes
95
+	'palettes' => array
96
+	(
97
+		'default'                     => '{title_legend},title'
98
+	),
99
+
100
+	// Subpalettes
101
+	'subpalettes' => array
102
+	(
103
+	),
104
+
105
+	// Fields
106
+	'fields' => array
107
+	(
108
+		'id' => array
109
+		(
110
+			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
111
+		),
112
+		'tstamp' => array
113
+		(
114
+			'sql'                     => "int(10) unsigned NOT NULL default '0'"
115
+		),
116
+		'title' => array
117
+		(
118
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team_group']['title'],
119
+			'exclude'                 => true,
120
+			'search'                  => true,
121
+			'inputType'               => 'text',
122
+			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
123
+			'sql'                     => "varchar(128) NOT NULL default ''"
124
+		)
125
+	)
126
+);
127
+
128
+/**
129
+ * Provide miscellaneous methods that are used by the data configuration array.
130
+ */
131
+class tl_esm_team_group extends Backend
132
+{
133
+
134
+	/**
135
+	 * Import the back end user object
136
+	 */
137
+	public function __construct()
138
+	{
139
+		parent::__construct();
140
+		$this->import('BackendUser', 'User');
141
+	}
142
+
143
+  /**
144
+   * Return the edit header button
145
+   *
146
+   * @param array  $row
147
+   * @param string $href
148
+   * @param string $label
149
+   * @param string $title
150
+   * @param string $icon
151
+   * @param string $attributes
152
+   *
153
+   * @return string
154
+   */
155
+  public function editHeader($row, $href, $label, $title, $icon, $attributes)
156
+  {
157
+    return System::getContainer()->get('security.helper')->isGranted(ContaoCorePermissions::USER_CAN_EDIT_FIELDS_OF_TABLE, 'tl_esm_team') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.gif$/i', '_.gif', $icon)).' ';
158
+  }
159
+}