GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 0813c3...d53f7a )
by Jan
26:03 queued 20:06
created

tl_belegungsplan_objekte::listQuestions()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 8
nop 1
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
1
<?php
2
 /**
3
 * Contao Open Source CMS
4
 *
5
 * Copyright (c) Jan Karai
6
 *
7
 * @license LGPL-3.0+
8
 */
9
10
/**
11
* Load tl_content language file
12
*/
13
System::loadLanguageFile('tl_content');
14
 
15
/**
16
 * Table tl_belegungsplan_objekte
17
 */
18
$GLOBALS['TL_DCA']['tl_belegungsplan_objekte'] = array
19
(
20
	// Config
21
	'config' => array
22
	(
23
		'dataContainer'               => 'Table',
24
		'ptable'                      => 'tl_belegungsplan_category',
25
		'ctable'                      => array('tl_belegungsplan_calender'),
26
		'switchToEdit'                => true,
27
		'enableVersioning'            => true,
28
		'sql' => array
29
		(
30
			'keys' => array
31
			(
32
				'id' => 'primary',
33
				'pid,published,sorting' => 'index'
34
			)
35
		)
36
	),
37
	// List
38
	'list' => array
39
	(
40
		'sorting' => array
41
		(
42
			'mode'                    => 4,
43
			'fields'                  => array('sorting'),
44
			'panelLayout'             => 'filter;sort,search,limit',
45
			'headerFields'            => array('title'),
46
			'child_record_callback'   => array('tl_belegungsplan_objekte', 'listQuestions')
47
		),
48
		'global_operations' => array
49
		(
50
			'all' => array
51
			(
52
				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
53
				'href'                => 'act=select',
54
				'class'               => 'header_edit_all',
55
				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
56
			)
57
		),
58
		'operations' => array
59
		(
60
			'edit' => array
61
			(
62
				'label'               => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['edit'],
63
				'href'                => 'table=tl_belegungsplan_calender',
64
				'icon'                => 'cssimport.svg'
65
			),
66
			'editheader' => array
67
			(
68
				'label'               => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['editheader'],
69
				'href'                => 'act=edit',
70
				'icon'                => 'edit.svg',
71
				'button_callback'     => array('tl_belegungsplan_objekte', 'editHeader')
72
			),
73
			'delete' => array
74
			(
75
				'label'               => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['delete'],
76
				'href'                => 'act=delete',
77
				'icon'                => 'delete.svg',
78
				'attributes'          => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
79
			),
80
			'toggle' => array
81
			(
82
				'label'               => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['toggle'],
83
				'icon'                => 'visible.svg',
84
				'attributes'          => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
85
				'button_callback'     => array('tl_belegungsplan_objekte', 'toggleIcon')
86
			),
87
			'show' => array
88
			(
89
				'label'               => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['show'],
90
				'href'                => 'act=show',
91
				'icon'                => 'show.svg'
92
			)
93
		)
94
	),
95
	// Palettes
96
	'palettes' => array
97
	(
98
		'__selector__'                => array(),
99
		'default'                     => '{title_legend},name,author,infotext;{publish_legend},published'
100
	),
101
	// Subpalettes
102
	'subpalettes' => array(
103
	),
104
	// Fields
105
	'fields' => array
106
	(
107
		'id' => array
108
		(
109
			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
110
		),
111
		'pid' => array
112
		(
113
			'foreignKey'              => 'tl_belegungsplan_category.title',
114
			'sql'                     => "int(10) unsigned NOT NULL default '0'",
115
			'relation'                => array('type'=>'belongsTo', 'load'=>'eager')
116
		),
117
		'sorting' => array
118
		(
119
			'label'                   => &$GLOBALS['TL_LANG']['MSC']['sorting'],
120
			'sorting'                 => true,
121
			'flag'                    => 11,
122
			'sql'                     => "int(10) unsigned NOT NULL default '0'"
123
		),
124
		'tstamp' => array
125
		(
126
			'sql'                     => "int(10) unsigned NOT NULL default '0'"
127
		),
128
		'name' => array
129
		(
130
			'label'                   => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['name'],
131
			'exclude'                 => true,
132
			'search'                  => true,
133
			'inputType'               => 'text',
134
			'eval'                    => array('mandatory'=>true, 'unique'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
135
			'sql'                     => "varchar(128) COLLATE utf8_bin NOT NULL default ''"
136
		),
137
		'author' => array
138
		(
139
			'label'                   => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['author'],
140
			'default'                 => BackendUser::getInstance()->id,
141
			'exclude'                 => true,
142
			'search'                  => true,
143
			'filter'                  => true,
144
			'sorting'                 => true,
145
			'flag'                    => 11,
146
			'inputType'               => 'select',
147
			'foreignKey'              => 'tl_user.name',
148
			'eval'                    => array('doNotCopy'=>true, 'chosen'=>true, 'mandatory'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50'),
149
			'sql'                     => "int(10) unsigned NOT NULL default '0'",
150
			'relation'                => array('type'=>'belongsTo', 'load'=>'eager')
151
		),
152
		'infotext' => array
153
		(
154
			'label'                   => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['infotext'],
155
			'exclude'                 => true,
156
			'search'                  => true,
157
			'inputType'               => 'text',
158
			'eval'                    => array('maxlength'=>255, 'tl_class'=>'long'),
159
			'sql'                     => "varchar(255) COLLATE utf8_bin NOT NULL default ''"
160
		),
161
		'published' => array
162
		(
163
			'label'                   => &$GLOBALS['TL_LANG']['tl_belegungsplan_objekte']['published'],
164
			'exclude'                 => true,
165
			'filter'                  => true,
166
			'flag'                    => 2,
167
			'inputType'               => 'checkbox',
168
			'eval'                    => array('doNotCopy'=>true),
169
			'sql'                     => "char(1) NOT NULL default ''"
170
		)
171
	)
172
);
173
/**
174
 * Provide miscellaneous methods that are used by the data configuration array.
175
 *
176
 * @author Jan Karai <https://www.sachsen-it.de>
177
 */
178
class tl_belegungsplan_objekte extends Backend
179
{
180
	/**
181
	 * Import the back end user object
182
	 */
183
	public function __construct()
184
	{
185
		parent::__construct();
186
		$this->import('BackendUser', 'User');
187
	}
188
	/**
189
	* Return the edit header button
190
	*
191
	* @param array  $row
192
	* @param string $href
193
	* @param string $label
194
	* @param string $title
195
	* @param string $icon
196
	* @param string $attributes
197
	*
198
	* @return string
199
	*/
200
	public function editHeader($row, $href, $label, $title, $icon, $attributes)
201
	{
202
		return '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.StringUtil::specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ';
203
	}
204
	/**
205
	* Add the type of input field
206
	*
207
	* @param array $arrRow
208
	*
209
	* @return string
210
	*/
211
	public function listQuestions($arrRow)
212
	{
213
		$key = $arrRow['published'] ? 'published' : 'unpublished';
214
		$date = Date::parse(Config::get('datimFormat'), $arrRow['tstamp']);
215
		return '
216
<div class="cte_type ' . $key . '">' . $date . '</div>
217
<div class="limit_height' . (!Config::get('doNotCollapse') ? ' h40' : '') . '">
218
' . StringUtil::insertTagToSrc($arrRow['name']) . 
219
(!empty($arrRow['infotext']) ? '<span style="color:#b3b3b3;padding-left:3px">[' . StringUtil::insertTagToSrc($arrRow['infotext']) . ']</span>' : '') . '
220
</div>' . "\n";
221
	}
222
	/**
223
	* Return the "toggle visibility" button
224
	*
225
	* @param array  $row
226
	* @param string $href
227
	* @param string $label
228
	* @param string $title
229
	* @param string $icon
230
	* @param string $attributes
231
	*
232
	* @return string
233
	*/
234
	public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
235
	{
236
		if (strlen(Input::get('tid')))
237
		{
238
			$this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1), (@func_get_arg(12) ?: null));
239
			$this->redirect($this->getReferer());
240
		}
241
		
242
		$href .= '&amp;tid='.$row['id'].'&amp;state='.($row['published'] ? '' : 1);
243
		if (!$row['published'])
244
		{
245
			$icon = 'invisible.svg';
246
		}
247
		return '<a href="'.$this->addToUrl($href).'" title="'.StringUtil::specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label, 'data-state="' . ($row['published'] ? 1 : 0) . '"').'</a> ';
248
	}
249
	/**
250
	 * Disable/enable a user group
251
	 *
252
	 * @param integer       $intId
253
	 * @param boolean       $blnVisible
254
	 * @param DataContainer $dc
255
	 *
256
	 * @throws Contao\CoreBundle\Exception\AccessDeniedException
257
	 */
258
	public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null) {
259
		// Set the ID and action
260
		Input::setGet('id', $intId);
261
		Input::setGet('act', 'toggle');
262
		if($dc) {
263
			$dc->id = $intId; // see #8043
264
		}
265
		
266
		// Set the current record
267
		if($dc) {
268
			$objRow = $this->Database->prepare("SELECT * FROM tl_belegungsplan_objekte WHERE id=?")
269
									 ->limit(1)
270
									 ->execute($intId);
271
			if($objRow->numRows) {
272
				$dc->activeRecord = $objRow;
273
			}
274
		}
275
		$objVersions = new Versions('tl_belegungsplan_objekte', $intId);
276
		$objVersions->initialize();
277
		// Trigger the save_callback
278
		if(is_array($GLOBALS['TL_DCA']['tl_belegungsplan_objekte']['fields']['published']['save_callback'])) {
279
			foreach($GLOBALS['TL_DCA']['tl_belegungsplan_objekte']['fields']['published']['save_callback'] as $callback) {
280
				if(is_array($callback)) {
281
					$this->import($callback[0]);
282
					$blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $dc);
283
				}
284
				elseif(is_callable($callback)) {
285
					$blnVisible = $callback($blnVisible, $dc);
286
				}
287
			}
288
		}
289
		$time = time();
290
		// Update the database
291
		$this->Database->prepare("UPDATE tl_belegungsplan_objekte SET tstamp=$time, published='" . ($blnVisible ? '1' : '') . "' WHERE id=?")
292
					   ->execute($intId);
293
		if($dc) {
294
			$dc->activeRecord->tstamp = $time;
295
			$dc->activeRecord->published = ($blnVisible ? '1' : '');
296
		}
297
		// Trigger the onsubmit_callback
298
		if(is_array($GLOBALS['TL_DCA']['tl_belegungsplan_objekte']['config']['onsubmit_callback'])) {
299
			foreach ($GLOBALS['TL_DCA']['tl_belegungsplan_objekte']['config']['onsubmit_callback'] as $callback) {
300
				if(is_array($callback)) {
301
					$this->import($callback[0]);
302
					$this->{$callback[0]}->{$callback[1]}($dc);
303
				}
304
				elseif(is_callable($callback)) {
305
					$callback($dc);
306
				}
307
			}
308
		}
309
		$objVersions->create();
310
	}
311
}
312